github.com/metacubex/sing-tun@v0.2.7-0.20240512075008-89e7c6208eec/internal/winipcfg/types_test.go (about) 1 /* SPDX-License-Identifier: MIT 2 * 3 * Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved. 4 */ 5 6 package winipcfg 7 8 import ( 9 "testing" 10 "unsafe" 11 ) 12 13 const ( 14 mibIPInterfaceRowSize = 168 15 mibIPInterfaceRowInterfaceLUIDOffset = 8 16 mibIPInterfaceRowInterfaceIndexOffset = 16 17 mibIPInterfaceRowMaxReassemblySizeOffset = 20 18 mibIPInterfaceRowInterfaceIdentifierOffset = 24 19 mibIPInterfaceRowMinRouterAdvertisementIntervalOffset = 32 20 mibIPInterfaceRowMaxRouterAdvertisementIntervalOffset = 36 21 mibIPInterfaceRowAdvertisingEnabledOffset = 40 22 mibIPInterfaceRowForwardingEnabledOffset = 41 23 mibIPInterfaceRowWeakHostSendOffset = 42 24 mibIPInterfaceRowWeakHostReceiveOffset = 43 25 mibIPInterfaceRowUseAutomaticMetricOffset = 44 26 mibIPInterfaceRowUseNeighborUnreachabilityDetectionOffset = 45 27 mibIPInterfaceRowManagedAddressConfigurationSupportedOffset = 46 28 mibIPInterfaceRowOtherStatefulConfigurationSupportedOffset = 47 29 mibIPInterfaceRowAdvertiseDefaultRouteOffset = 48 30 mibIPInterfaceRowRouterDiscoveryBehaviorOffset = 52 31 mibIPInterfaceRowDadTransmitsOffset = 56 32 mibIPInterfaceRowBaseReachableTimeOffset = 60 33 mibIPInterfaceRowRetransmitTimeOffset = 64 34 mibIPInterfaceRowPathMTUDiscoveryTimeoutOffset = 68 35 mibIPInterfaceRowLinkLocalAddressBehaviorOffset = 72 36 mibIPInterfaceRowLinkLocalAddressTimeoutOffset = 76 37 mibIPInterfaceRowZoneIndicesOffset = 80 38 mibIPInterfaceRowSitePrefixLengthOffset = 144 39 mibIPInterfaceRowMetricOffset = 148 40 mibIPInterfaceRowNLMTUOffset = 152 41 mibIPInterfaceRowConnectedOffset = 156 42 mibIPInterfaceRowSupportsWakeUpPatternsOffset = 157 43 mibIPInterfaceRowSupportsNeighborDiscoveryOffset = 158 44 mibIPInterfaceRowSupportsRouterDiscoveryOffset = 159 45 mibIPInterfaceRowReachableTimeOffset = 160 46 mibIPInterfaceRowTransmitOffloadOffset = 164 47 mibIPInterfaceRowReceiveOffloadOffset = 165 48 mibIPInterfaceRowDisableDefaultRoutesOffset = 166 49 50 mibIPInterfaceTableSize = 176 51 mibIPInterfaceTableTableOffset = 8 52 53 mibIfRow2Size = 1352 54 mibIfRow2InterfaceIndexOffset = 8 55 mibIfRow2InterfaceGUIDOffset = 12 56 mibIfRow2AliasOffset = 28 57 mibIfRow2DescriptionOffset = 542 58 mibIfRow2PhysicalAddressLengthOffset = 1056 59 mibIfRow2PhysicalAddressOffset = 1060 60 mibIfRow2PermanentPhysicalAddressOffset = 1092 61 mibIfRow2MTUOffset = 1124 62 mibIfRow2TypeOffset = 1128 63 mibIfRow2TunnelTypeOffset = 1132 64 mibIfRow2MediaTypeOffset = 1136 65 mibIfRow2PhysicalMediumTypeOffset = 1140 66 mibIfRow2AccessTypeOffset = 1144 67 mibIfRow2DirectionTypeOffset = 1148 68 mibIfRow2InterfaceAndOperStatusFlagsOffset = 1152 69 mibIfRow2OperStatusOffset = 1156 70 mibIfRow2AdminStatusOffset = 1160 71 mibIfRow2MediaConnectStateOffset = 1164 72 mibIfRow2NetworkGUIDOffset = 1168 73 mibIfRow2ConnectionTypeOffset = 1184 74 mibIfRow2TransmitLinkSpeedOffset = 1192 75 mibIfRow2ReceiveLinkSpeedOffset = 1200 76 mibIfRow2InOctetsOffset = 1208 77 mibIfRow2InUcastPktsOffset = 1216 78 mibIfRow2InNUcastPktsOffset = 1224 79 mibIfRow2InDiscardsOffset = 1232 80 mibIfRow2InErrorsOffset = 1240 81 mibIfRow2InUnknownProtosOffset = 1248 82 mibIfRow2InUcastOctetsOffset = 1256 83 mibIfRow2InMulticastOctetsOffset = 1264 84 mibIfRow2InBroadcastOctetsOffset = 1272 85 mibIfRow2OutOctetsOffset = 1280 86 mibIfRow2OutUcastPktsOffset = 1288 87 mibIfRow2OutNUcastPktsOffset = 1296 88 mibIfRow2OutDiscardsOffset = 1304 89 mibIfRow2OutErrorsOffset = 1312 90 mibIfRow2OutUcastOctetsOffset = 1320 91 mibIfRow2OutMulticastOctetsOffset = 1328 92 mibIfRow2OutBroadcastOctetsOffset = 1336 93 mibIfRow2OutQLenOffset = 1344 94 95 mibIfTable2Size = 1360 96 mibIfTable2TableOffset = 8 97 98 rawSockaddrInetSize = 28 99 rawSockaddrInetDataOffset = 2 100 101 mibUnicastIPAddressRowSize = 80 102 mibUnicastIPAddressRowInterfaceLUIDOffset = 32 103 mibUnicastIPAddressRowInterfaceIndexOffset = 40 104 mibUnicastIPAddressRowPrefixOriginOffset = 44 105 mibUnicastIPAddressRowSuffixOriginOffset = 48 106 mibUnicastIPAddressRowValidLifetimeOffset = 52 107 mibUnicastIPAddressRowPreferredLifetimeOffset = 56 108 mibUnicastIPAddressRowOnLinkPrefixLengthOffset = 60 109 mibUnicastIPAddressRowSkipAsSourceOffset = 61 110 mibUnicastIPAddressRowDadStateOffset = 64 111 mibUnicastIPAddressRowScopeIDOffset = 68 112 mibUnicastIPAddressRowCreationTimeStampOffset = 72 113 114 mibUnicastIPAddressTableSize = 88 115 mibUnicastIPAddressTableTableOffset = 8 116 117 mibAnycastIPAddressRowSize = 48 118 mibAnycastIPAddressRowInterfaceLUIDOffset = 32 119 mibAnycastIPAddressRowInterfaceIndexOffset = 40 120 mibAnycastIPAddressRowScopeIDOffset = 44 121 122 mibAnycastIPAddressTableSize = 56 123 mibAnycastIPAddressTableTableOffset = 8 124 125 ipAddressPrefixSize = 32 126 ipAddressPrefixPrefixLengthOffset = 28 127 128 mibIPforwardRow2Size = 104 129 mibIPforwardRow2InterfaceIndexOffset = 8 130 mibIPforwardRow2DestinationPrefixOffset = 12 131 mibIPforwardRow2NextHopOffset = 44 132 mibIPforwardRow2SitePrefixLengthOffset = 72 133 mibIPforwardRow2ValidLifetimeOffset = 76 134 mibIPforwardRow2PreferredLifetimeOffset = 80 135 mibIPforwardRow2MetricOffset = 84 136 mibIPforwardRow2ProtocolOffset = 88 137 mibIPforwardRow2LoopbackOffset = 92 138 mibIPforwardRow2AutoconfigureAddressOffset = 93 139 mibIPforwardRow2PublishOffset = 94 140 mibIPforwardRow2ImmortalOffset = 95 141 mibIPforwardRow2AgeOffset = 96 142 mibIPforwardRow2OriginOffset = 100 143 144 mibIPforwardTable2Size = 112 145 mibIPforwardTable2TableOffset = 8 146 ) 147 148 func TestIPAdapterWINSServerAddress(t *testing.T) { 149 s := IPAdapterWINSServerAddress{} 150 sp := uintptr(unsafe.Pointer(&s)) 151 const actualIPAdapterWINSServerAddressSize = unsafe.Sizeof(s) 152 153 if actualIPAdapterWINSServerAddressSize != ipAdapterWINSServerAddressSize { 154 t.Errorf("Size of IPAdapterWINSServerAddress is %d, although %d is expected.", actualIPAdapterWINSServerAddressSize, ipAdapterWINSServerAddressSize) 155 } 156 157 offset := uintptr(unsafe.Pointer(&s.Next)) - sp 158 if offset != ipAdapterWINSServerAddressNextOffset { 159 t.Errorf("IPAdapterWINSServerAddress.Next offset is %d although %d is expected", offset, ipAdapterWINSServerAddressNextOffset) 160 } 161 162 offset = uintptr(unsafe.Pointer(&s.Address)) - sp 163 if offset != ipAdapterWINSServerAddressAddressOffset { 164 t.Errorf("IPAdapterWINSServerAddress.Address offset is %d although %d is expected", offset, ipAdapterWINSServerAddressAddressOffset) 165 } 166 } 167 168 func TestIPAdapterGatewayAddress(t *testing.T) { 169 s := IPAdapterGatewayAddress{} 170 sp := uintptr(unsafe.Pointer(&s)) 171 const actualIPAdapterGatewayAddressSize = unsafe.Sizeof(s) 172 173 if actualIPAdapterGatewayAddressSize != ipAdapterGatewayAddressSize { 174 t.Errorf("Size of IPAdapterGatewayAddress is %d, although %d is expected.", actualIPAdapterGatewayAddressSize, ipAdapterGatewayAddressSize) 175 } 176 177 offset := uintptr(unsafe.Pointer(&s.Next)) - sp 178 if offset != ipAdapterGatewayAddressNextOffset { 179 t.Errorf("IPAdapterGatewayAddress.Next offset is %d although %d is expected", offset, ipAdapterGatewayAddressNextOffset) 180 } 181 182 offset = uintptr(unsafe.Pointer(&s.Address)) - sp 183 if offset != ipAdapterGatewayAddressAddressOffset { 184 t.Errorf("IPAdapterGatewayAddress.Address offset is %d although %d is expected", offset, ipAdapterGatewayAddressAddressOffset) 185 } 186 } 187 188 func TestIPAdapterDNSSuffix(t *testing.T) { 189 s := IPAdapterDNSSuffix{} 190 sp := uintptr(unsafe.Pointer(&s)) 191 const actualIPAdapterDNSSuffixSize = unsafe.Sizeof(s) 192 193 if actualIPAdapterDNSSuffixSize != ipAdapterDNSSuffixSize { 194 t.Errorf("Size of IPAdapterDNSSuffix is %d, although %d is expected.", actualIPAdapterDNSSuffixSize, ipAdapterDNSSuffixSize) 195 } 196 197 offset := uintptr(unsafe.Pointer(&s.str)) - sp 198 if offset != ipAdapterDNSSuffixStringOffset { 199 t.Errorf("IPAdapterDNSSuffix.str offset is %d although %d is expected", offset, ipAdapterDNSSuffixStringOffset) 200 } 201 } 202 203 func TestInAdapterAddresses(t *testing.T) { 204 s := IPAdapterAddresses{} 205 sp := uintptr(unsafe.Pointer(&s)) 206 const actualIn6AddrSize = unsafe.Sizeof(s) 207 208 if actualIn6AddrSize != ipAdapterAddressesSize { 209 t.Errorf("Size of IPAdapterAddresses is %d, although %d is expected.", actualIn6AddrSize, ipAdapterAddressesSize) 210 } 211 212 offset := uintptr(unsafe.Pointer(&s.IfIndex)) - sp 213 if offset != ipAdapterAddressesIfIndexOffset { 214 t.Errorf("IPAdapterAddresses.IfIndex offset is %d although %d is expected", offset, ipAdapterAddressesIfIndexOffset) 215 } 216 217 offset = uintptr(unsafe.Pointer(&s.Next)) - sp 218 if offset != ipAdapterAddressesNextOffset { 219 t.Errorf("IPAdapterAddresses.Next offset is %d although %d is expected", offset, ipAdapterAddressesNextOffset) 220 } 221 222 offset = uintptr(unsafe.Pointer(&s.adapterName)) - sp 223 if offset != ipAdapterAddressesAdapterNameOffset { 224 t.Errorf("IPAdapterAddresses.adapterName offset is %d although %d is expected", offset, ipAdapterAddressesAdapterNameOffset) 225 } 226 227 offset = uintptr(unsafe.Pointer(&s.FirstUnicastAddress)) - sp 228 if offset != ipAdapterAddressesFirstUnicastAddressOffset { 229 t.Errorf("IPAdapterAddresses.FirstUnicastAddress offset is %d although %d is expected", offset, ipAdapterAddressesFirstUnicastAddressOffset) 230 } 231 232 offset = uintptr(unsafe.Pointer(&s.FirstAnycastAddress)) - sp 233 if offset != ipAdapterAddressesFirstAnycastAddressOffset { 234 t.Errorf("IPAdapterAddresses.FirstAnycastAddress offset is %d although %d is expected", offset, ipAdapterAddressesFirstAnycastAddressOffset) 235 } 236 237 offset = uintptr(unsafe.Pointer(&s.FirstMulticastAddress)) - sp 238 if offset != ipAdapterAddressesFirstMulticastAddressOffset { 239 t.Errorf("IPAdapterAddresses.FirstMulticastAddress offset is %d although %d is expected", offset, ipAdapterAddressesFirstMulticastAddressOffset) 240 } 241 242 offset = uintptr(unsafe.Pointer(&s.FirstDNSServerAddress)) - sp 243 if offset != ipAdapterAddressesFirstDNSServerAddressOffset { 244 t.Errorf("IPAdapterAddresses.FirstDNSServerAddress offset is %d although %d is expected", offset, ipAdapterAddressesFirstDNSServerAddressOffset) 245 } 246 247 offset = uintptr(unsafe.Pointer(&s.dnsSuffix)) - sp 248 if offset != ipAdapterAddressesDNSSuffixOffset { 249 t.Errorf("IPAdapterAddresses.DNSSuffix offset is %d although %d is expected", offset, ipAdapterAddressesDNSSuffixOffset) 250 } 251 252 offset = uintptr(unsafe.Pointer(&s.description)) - sp 253 if offset != ipAdapterAddressesDescriptionOffset { 254 t.Errorf("IPAdapterAddresses.Description offset is %d although %d is expected", offset, ipAdapterAddressesDescriptionOffset) 255 } 256 257 offset = uintptr(unsafe.Pointer(&s.friendlyName)) - sp 258 if offset != ipAdapterAddressesFriendlyNameOffset { 259 t.Errorf("IPAdapterAddresses.FriendlyName offset is %d although %d is expected", offset, ipAdapterAddressesFriendlyNameOffset) 260 } 261 262 offset = uintptr(unsafe.Pointer(&s.physicalAddress)) - sp 263 if offset != ipAdapterAddressesPhysicalAddressOffset { 264 t.Errorf("IPAdapterAddresses.PhysicalAddress offset is %d although %d is expected", offset, ipAdapterAddressesPhysicalAddressOffset) 265 } 266 267 offset = uintptr(unsafe.Pointer(&s.physicalAddressLength)) - sp 268 if offset != ipAdapterAddressesPhysicalAddressLengthOffset { 269 t.Errorf("IPAdapterAddresses.PhysicalAddressLength offset is %d although %d is expected", offset, ipAdapterAddressesPhysicalAddressLengthOffset) 270 } 271 272 offset = uintptr(unsafe.Pointer(&s.Flags)) - sp 273 if offset != ipAdapterAddressesFlagsOffset { 274 t.Errorf("IPAdapterAddresses.Flags offset is %d although %d is expected", offset, ipAdapterAddressesFlagsOffset) 275 } 276 277 offset = uintptr(unsafe.Pointer(&s.MTU)) - sp 278 if offset != ipAdapterAddressesMTUOffset { 279 t.Errorf("IPAdapterAddresses.MTU offset is %d although %d is expected", offset, ipAdapterAddressesMTUOffset) 280 } 281 282 offset = uintptr(unsafe.Pointer(&s.IfType)) - sp 283 if offset != ipAdapterAddressesIfTypeOffset { 284 t.Errorf("IPAdapterAddresses.IfType offset is %d although %d is expected", offset, ipAdapterAddressesIfTypeOffset) 285 } 286 287 offset = uintptr(unsafe.Pointer(&s.OperStatus)) - sp 288 if offset != ipAdapterAddressesOperStatusOffset { 289 t.Errorf("IPAdapterAddresses.OperStatus offset is %d although %d is expected", offset, ipAdapterAddressesOperStatusOffset) 290 } 291 292 offset = uintptr(unsafe.Pointer(&s.IPv6IfIndex)) - sp 293 if offset != ipAdapterAddressesIPv6IfIndexOffset { 294 t.Errorf("IPAdapterAddresses.IPv6IfIndex offset is %d although %d is expected", offset, ipAdapterAddressesIPv6IfIndexOffset) 295 } 296 297 offset = uintptr(unsafe.Pointer(&s.ZoneIndices)) - sp 298 if offset != ipAdapterAddressesZoneIndicesOffset { 299 t.Errorf("IPAdapterAddresses.ZoneIndices offset is %d although %d is expected", offset, ipAdapterAddressesZoneIndicesOffset) 300 } 301 302 offset = uintptr(unsafe.Pointer(&s.FirstPrefix)) - sp 303 if offset != ipAdapterAddressesFirstPrefixOffset { 304 t.Errorf("IPAdapterAddresses.FirstPrefix offset is %d although %d is expected", offset, ipAdapterAddressesFirstPrefixOffset) 305 } 306 307 offset = uintptr(unsafe.Pointer(&s.TransmitLinkSpeed)) - sp 308 if offset != ipAdapterAddressesTransmitLinkSpeedOffset { 309 t.Errorf("IPAdapterAddresses.TransmitLinkSpeed offset is %d although %d is expected", offset, ipAdapterAddressesTransmitLinkSpeedOffset) 310 } 311 312 offset = uintptr(unsafe.Pointer(&s.ReceiveLinkSpeed)) - sp 313 if offset != ipAdapterAddressesReceiveLinkSpeedOffset { 314 t.Errorf("IPAdapterAddresses.ReceiveLinkSpeed offset is %d although %d is expected", offset, ipAdapterAddressesReceiveLinkSpeedOffset) 315 } 316 317 offset = uintptr(unsafe.Pointer(&s.FirstWINSServerAddress)) - sp 318 if offset != ipAdapterAddressesFirstWINSServerAddressOffset { 319 t.Errorf("IPAdapterAddresses.FirstWINSServerAddress offset is %d although %d is expected", offset, ipAdapterAddressesFirstWINSServerAddressOffset) 320 } 321 322 offset = uintptr(unsafe.Pointer(&s.FirstGatewayAddress)) - sp 323 if offset != ipAdapterAddressesFirstGatewayAddressOffset { 324 t.Errorf("IPAdapterAddresses.FirstGatewayAddress offset is %d although %d is expected", offset, ipAdapterAddressesFirstGatewayAddressOffset) 325 } 326 327 offset = uintptr(unsafe.Pointer(&s.Ipv4Metric)) - sp 328 if offset != ipAdapterAddressesIPv4MetricOffset { 329 t.Errorf("IPAdapterAddresses.IPv4Metric offset is %d although %d is expected", offset, ipAdapterAddressesIPv4MetricOffset) 330 } 331 332 offset = uintptr(unsafe.Pointer(&s.Ipv6Metric)) - sp 333 if offset != ipAdapterAddressesIPv6MetricOffset { 334 t.Errorf("IPAdapterAddresses.IPv6Metric offset is %d although %d is expected", offset, ipAdapterAddressesIPv6MetricOffset) 335 } 336 337 offset = uintptr(unsafe.Pointer(&s.LUID)) - sp 338 if offset != ipAdapterAddressesLUIDOffset { 339 t.Errorf("IPAdapterAddresses.LUID offset is %d although %d is expected", offset, ipAdapterAddressesLUIDOffset) 340 } 341 342 offset = uintptr(unsafe.Pointer(&s.DHCPv4Server)) - sp 343 if offset != ipAdapterAddressesDHCPv4ServerOffset { 344 t.Errorf("IPAdapterAddresses.DHCPv4Server offset is %d although %d is expected", offset, ipAdapterAddressesDHCPv4ServerOffset) 345 } 346 347 offset = uintptr(unsafe.Pointer(&s.CompartmentID)) - sp 348 if offset != ipAdapterAddressesCompartmentIDOffset { 349 t.Errorf("IPAdapterAddresses.CompartmentID offset is %d although %d is expected", offset, ipAdapterAddressesCompartmentIDOffset) 350 } 351 352 offset = uintptr(unsafe.Pointer(&s.NetworkGUID)) - sp 353 if offset != ipAdapterAddressesNetworkGUIDOffset { 354 t.Errorf("IPAdapterAddresses.NetworkGUID offset is %d although %d is expected", offset, ipAdapterAddressesNetworkGUIDOffset) 355 } 356 357 offset = uintptr(unsafe.Pointer(&s.ConnectionType)) - sp 358 if offset != ipAdapterAddressesConnectionTypeOffset { 359 t.Errorf("IPAdapterAddresses.ConnectionType offset is %d although %d is expected", offset, ipAdapterAddressesConnectionTypeOffset) 360 } 361 362 offset = uintptr(unsafe.Pointer(&s.TunnelType)) - sp 363 if offset != ipAdapterAddressesTunnelTypeOffset { 364 t.Errorf("IPAdapterAddresses.TunnelType offset is %d although %d is expected", offset, ipAdapterAddressesTunnelTypeOffset) 365 } 366 367 offset = uintptr(unsafe.Pointer(&s.DHCPv6Server)) - sp 368 if offset != ipAdapterAddressesDHCPv6ServerOffset { 369 t.Errorf("IPAdapterAddresses.DHCPv6Server offset is %d although %d is expected", offset, ipAdapterAddressesDHCPv6ServerOffset) 370 } 371 372 offset = uintptr(unsafe.Pointer(&s.dhcpv6ClientDUID)) - sp 373 if offset != ipAdapterAddressesDHCPv6ClientDUIDOffset { 374 t.Errorf("IPAdapterAddresses.DHCPv6ClientDUID offset is %d although %d is expected", offset, ipAdapterAddressesDHCPv6ClientDUIDOffset) 375 } 376 377 offset = uintptr(unsafe.Pointer(&s.dhcpv6ClientDUIDLength)) - sp 378 if offset != ipAdapterAddressesDHCPv6ClientDUIDLengthOffset { 379 t.Errorf("IPAdapterAddresses.DHCPv6ClientDUIDLength offset is %d although %d is expected", offset, ipAdapterAddressesDHCPv6ClientDUIDLengthOffset) 380 } 381 382 offset = uintptr(unsafe.Pointer(&s.DHCPv6IAID)) - sp 383 if offset != ipAdapterAddressesDHCPv6IAIDOffset { 384 t.Errorf("IPAdapterAddresses.DHCPv6IAID offset is %d although %d is expected", offset, ipAdapterAddressesDHCPv6IAIDOffset) 385 } 386 387 offset = uintptr(unsafe.Pointer(&s.FirstDNSSuffix)) - sp 388 if offset != ipAdapterAddressesFirstDNSSuffixOffset { 389 t.Errorf("IPAdapterAddresses.FirstDNSSuffix offset is %d although %d is expected", offset, ipAdapterAddressesFirstDNSSuffixOffset) 390 } 391 } 392 393 func TestMibIPInterfaceRow(t *testing.T) { 394 s := MibIPInterfaceRow{} 395 sp := uintptr(unsafe.Pointer(&s)) 396 const actualTestMibIPInterfaceRowSize = unsafe.Sizeof(s) 397 398 if actualTestMibIPInterfaceRowSize != mibIPInterfaceRowSize { 399 t.Errorf("Size of MibIPInterfaceRow is %d, although %d is expected.", actualTestMibIPInterfaceRowSize, mibIPInterfaceRowSize) 400 } 401 402 offset := uintptr(unsafe.Pointer(&s.InterfaceLUID)) - sp 403 if offset != mibIPInterfaceRowInterfaceLUIDOffset { 404 t.Errorf("MibIPInterfaceRow.InterfaceLUID offset is %d although %d is expected", offset, mibIPInterfaceRowInterfaceLUIDOffset) 405 } 406 407 offset = uintptr(unsafe.Pointer(&s.InterfaceIndex)) - sp 408 if offset != mibIPInterfaceRowInterfaceIndexOffset { 409 t.Errorf("MibIPInterfaceRow.InterfaceIndex offset is %d although %d is expected", offset, mibIPInterfaceRowInterfaceIndexOffset) 410 } 411 412 offset = uintptr(unsafe.Pointer(&s.MaxReassemblySize)) - sp 413 if offset != mibIPInterfaceRowMaxReassemblySizeOffset { 414 t.Errorf("mibIPInterfaceRow.MaxReassemblySize offset is %d although %d is expected", offset, mibIPInterfaceRowMaxReassemblySizeOffset) 415 } 416 417 offset = uintptr(unsafe.Pointer(&s.InterfaceIdentifier)) - sp 418 if offset != mibIPInterfaceRowInterfaceIdentifierOffset { 419 t.Errorf("MibIPInterfaceRow.InterfaceIdentifier offset is %d although %d is expected", offset, mibIPInterfaceRowInterfaceIdentifierOffset) 420 } 421 422 offset = uintptr(unsafe.Pointer(&s.MinRouterAdvertisementInterval)) - sp 423 if offset != mibIPInterfaceRowMinRouterAdvertisementIntervalOffset { 424 t.Errorf("MibIPInterfaceRow.MinRouterAdvertisementInterval offset is %d although %d is expected", offset, mibIPInterfaceRowMinRouterAdvertisementIntervalOffset) 425 } 426 427 offset = uintptr(unsafe.Pointer(&s.MaxRouterAdvertisementInterval)) - sp 428 if offset != mibIPInterfaceRowMaxRouterAdvertisementIntervalOffset { 429 t.Errorf("MibIPInterfaceRow.MaxRouterAdvertisementInterval offset is %d although %d is expected", offset, mibIPInterfaceRowMaxRouterAdvertisementIntervalOffset) 430 } 431 432 offset = uintptr(unsafe.Pointer(&s.AdvertisingEnabled)) - sp 433 if offset != mibIPInterfaceRowAdvertisingEnabledOffset { 434 t.Errorf("MibIPInterfaceRow.AdvertisingEnabled offset is %d although %d is expected", offset, mibIPInterfaceRowAdvertisingEnabledOffset) 435 } 436 437 offset = uintptr(unsafe.Pointer(&s.ForwardingEnabled)) - sp 438 if offset != mibIPInterfaceRowForwardingEnabledOffset { 439 t.Errorf("MibIPInterfaceRow.ForwardingEnabled offset is %d although %d is expected", offset, mibIPInterfaceRowForwardingEnabledOffset) 440 } 441 442 offset = uintptr(unsafe.Pointer(&s.WeakHostSend)) - sp 443 if offset != mibIPInterfaceRowWeakHostSendOffset { 444 t.Errorf("MibIPInterfaceRow.WeakHostSend offset is %d although %d is expected", offset, mibIPInterfaceRowWeakHostSendOffset) 445 } 446 447 offset = uintptr(unsafe.Pointer(&s.WeakHostReceive)) - sp 448 if offset != mibIPInterfaceRowWeakHostReceiveOffset { 449 t.Errorf("MibIPInterfaceRow.WeakHostReceive offset is %d although %d is expected", offset, mibIPInterfaceRowWeakHostReceiveOffset) 450 } 451 452 offset = uintptr(unsafe.Pointer(&s.UseAutomaticMetric)) - sp 453 if offset != mibIPInterfaceRowUseAutomaticMetricOffset { 454 t.Errorf("MibIPInterfaceRow.UseAutomaticMetric offset is %d although %d is expected", offset, mibIPInterfaceRowUseAutomaticMetricOffset) 455 } 456 457 offset = uintptr(unsafe.Pointer(&s.UseNeighborUnreachabilityDetection)) - sp 458 if offset != mibIPInterfaceRowUseNeighborUnreachabilityDetectionOffset { 459 t.Errorf("MibIPInterfaceRow.UseNeighborUnreachabilityDetection offset is %d although %d is expected", offset, mibIPInterfaceRowUseNeighborUnreachabilityDetectionOffset) 460 } 461 462 offset = uintptr(unsafe.Pointer(&s.ManagedAddressConfigurationSupported)) - sp 463 if offset != mibIPInterfaceRowManagedAddressConfigurationSupportedOffset { 464 t.Errorf("MibIPInterfaceRow.ManagedAddressConfigurationSupported offset is %d although %d is expected", offset, mibIPInterfaceRowManagedAddressConfigurationSupportedOffset) 465 } 466 467 offset = uintptr(unsafe.Pointer(&s.OtherStatefulConfigurationSupported)) - sp 468 if offset != mibIPInterfaceRowOtherStatefulConfigurationSupportedOffset { 469 t.Errorf("MibIPInterfaceRow.OtherStatefulConfigurationSupported offset is %d although %d is expected", offset, mibIPInterfaceRowOtherStatefulConfigurationSupportedOffset) 470 } 471 472 offset = uintptr(unsafe.Pointer(&s.AdvertiseDefaultRoute)) - sp 473 if offset != mibIPInterfaceRowAdvertiseDefaultRouteOffset { 474 t.Errorf("MibIPInterfaceRow.AdvertiseDefaultRoute offset is %d although %d is expected", offset, mibIPInterfaceRowAdvertiseDefaultRouteOffset) 475 } 476 477 offset = uintptr(unsafe.Pointer(&s.RouterDiscoveryBehavior)) - sp 478 if offset != mibIPInterfaceRowRouterDiscoveryBehaviorOffset { 479 t.Errorf("MibIPInterfaceRow.RouterDiscoveryBehavior offset is %d although %d is expected", offset, mibIPInterfaceRowRouterDiscoveryBehaviorOffset) 480 } 481 482 offset = uintptr(unsafe.Pointer(&s.DadTransmits)) - sp 483 if offset != mibIPInterfaceRowDadTransmitsOffset { 484 t.Errorf("MibIPInterfaceRow.DadTransmits offset is %d although %d is expected", offset, mibIPInterfaceRowDadTransmitsOffset) 485 } 486 487 offset = uintptr(unsafe.Pointer(&s.BaseReachableTime)) - sp 488 if offset != mibIPInterfaceRowBaseReachableTimeOffset { 489 t.Errorf("MibIPInterfaceRow.BaseReachableTime offset is %d although %d is expected", offset, mibIPInterfaceRowBaseReachableTimeOffset) 490 } 491 492 offset = uintptr(unsafe.Pointer(&s.RetransmitTime)) - sp 493 if offset != mibIPInterfaceRowRetransmitTimeOffset { 494 t.Errorf("MibIPInterfaceRow.RetransmitTime offset is %d although %d is expected", offset, mibIPInterfaceRowRetransmitTimeOffset) 495 } 496 497 offset = uintptr(unsafe.Pointer(&s.PathMTUDiscoveryTimeout)) - sp 498 if offset != mibIPInterfaceRowPathMTUDiscoveryTimeoutOffset { 499 t.Errorf("MibIPInterfaceRow.PathMTUDiscoveryTimeout offset is %d although %d is expected", offset, mibIPInterfaceRowPathMTUDiscoveryTimeoutOffset) 500 } 501 502 offset = uintptr(unsafe.Pointer(&s.LinkLocalAddressBehavior)) - sp 503 if offset != mibIPInterfaceRowLinkLocalAddressBehaviorOffset { 504 t.Errorf("MibIPInterfaceRow.LinkLocalAddressBehavior offset is %d although %d is expected", offset, mibIPInterfaceRowLinkLocalAddressBehaviorOffset) 505 } 506 507 offset = uintptr(unsafe.Pointer(&s.LinkLocalAddressTimeout)) - sp 508 if offset != mibIPInterfaceRowLinkLocalAddressTimeoutOffset { 509 t.Errorf("MibIPInterfaceRow.LinkLocalAddressTimeout offset is %d although %d is expected", offset, mibIPInterfaceRowLinkLocalAddressTimeoutOffset) 510 } 511 512 offset = uintptr(unsafe.Pointer(&s.ZoneIndices)) - sp 513 if offset != mibIPInterfaceRowZoneIndicesOffset { 514 t.Errorf("MibIPInterfaceRow.ZoneIndices offset is %d although %d is expected", offset, mibIPInterfaceRowZoneIndicesOffset) 515 } 516 517 offset = uintptr(unsafe.Pointer(&s.SitePrefixLength)) - sp 518 if offset != mibIPInterfaceRowSitePrefixLengthOffset { 519 t.Errorf("MibIPInterfaceRow.SitePrefixLength offset is %d although %d is expected", offset, mibIPInterfaceRowSitePrefixLengthOffset) 520 } 521 522 offset = uintptr(unsafe.Pointer(&s.Metric)) - sp 523 if offset != mibIPInterfaceRowMetricOffset { 524 t.Errorf("MibIPInterfaceRow.Metric offset is %d although %d is expected", offset, mibIPInterfaceRowMetricOffset) 525 } 526 527 offset = uintptr(unsafe.Pointer(&s.NLMTU)) - sp 528 if offset != mibIPInterfaceRowNLMTUOffset { 529 t.Errorf("MibIPInterfaceRow.NLMTU offset is %d although %d is expected", offset, mibIPInterfaceRowNLMTUOffset) 530 } 531 532 offset = uintptr(unsafe.Pointer(&s.Connected)) - sp 533 if offset != mibIPInterfaceRowConnectedOffset { 534 t.Errorf("MibIPInterfaceRow.Connected offset is %d although %d is expected", offset, mibIPInterfaceRowConnectedOffset) 535 } 536 537 offset = uintptr(unsafe.Pointer(&s.SupportsWakeUpPatterns)) - sp 538 if offset != mibIPInterfaceRowSupportsWakeUpPatternsOffset { 539 t.Errorf("MibIPInterfaceRow.SupportsWakeUpPatterns offset is %d although %d is expected", offset, mibIPInterfaceRowSupportsWakeUpPatternsOffset) 540 } 541 542 offset = uintptr(unsafe.Pointer(&s.SupportsNeighborDiscovery)) - sp 543 if offset != mibIPInterfaceRowSupportsNeighborDiscoveryOffset { 544 t.Errorf("MibIPInterfaceRow.SupportsNeighborDiscovery offset is %d although %d is expected", offset, mibIPInterfaceRowSupportsNeighborDiscoveryOffset) 545 } 546 547 offset = uintptr(unsafe.Pointer(&s.SupportsRouterDiscovery)) - sp 548 if offset != mibIPInterfaceRowSupportsRouterDiscoveryOffset { 549 t.Errorf("MibIPInterfaceRow.SupportsRouterDiscovery offset is %d although %d is expected", offset, mibIPInterfaceRowSupportsRouterDiscoveryOffset) 550 } 551 552 offset = uintptr(unsafe.Pointer(&s.ReachableTime)) - sp 553 if offset != mibIPInterfaceRowReachableTimeOffset { 554 t.Errorf("MibIPInterfaceRow.ReachableTime offset is %d although %d is expected", offset, mibIPInterfaceRowReachableTimeOffset) 555 } 556 557 offset = uintptr(unsafe.Pointer(&s.TransmitOffload)) - sp 558 if offset != mibIPInterfaceRowTransmitOffloadOffset { 559 t.Errorf("MibIPInterfaceRow.TransmitOffload offset is %d although %d is expected", offset, mibIPInterfaceRowTransmitOffloadOffset) 560 } 561 562 offset = uintptr(unsafe.Pointer(&s.ReceiveOffload)) - sp 563 if offset != mibIPInterfaceRowReceiveOffloadOffset { 564 t.Errorf("MibIPInterfaceRow.ReceiveOffload offset is %d although %d is expected", offset, mibIPInterfaceRowReceiveOffloadOffset) 565 } 566 567 offset = uintptr(unsafe.Pointer(&s.DisableDefaultRoutes)) - sp 568 if offset != mibIPInterfaceRowDisableDefaultRoutesOffset { 569 t.Errorf("MibIPInterfaceRow.DisableDefaultRoutes offset is %d although %d is expected", offset, mibIPInterfaceRowDisableDefaultRoutesOffset) 570 } 571 } 572 573 func TestMibIPInterfaceTable(t *testing.T) { 574 s := mibIPInterfaceTable{} 575 sp := uintptr(unsafe.Pointer(&s)) 576 const actualmibIPInterfaceTableSize = unsafe.Sizeof(s) 577 578 if actualmibIPInterfaceTableSize != mibIPInterfaceTableSize { 579 t.Errorf("Size of mibIPInterfaceTable is %d, although %d is expected.", actualmibIPInterfaceTableSize, mibIPInterfaceTableSize) 580 } 581 582 offset := uintptr(unsafe.Pointer(&s.table)) - sp 583 if offset != mibIPInterfaceTableTableOffset { 584 t.Errorf("mibIPInterfaceTable.table offset is %d although %d is expected", offset, mibIPInterfaceTableTableOffset) 585 } 586 } 587 588 func TestMibIfRow2(t *testing.T) { 589 s := MibIfRow2{} 590 sp := uintptr(unsafe.Pointer(&s)) 591 const actualMibIfRow2Size = unsafe.Sizeof(s) 592 593 if actualMibIfRow2Size != mibIfRow2Size { 594 t.Errorf("Size of MibIfRow2 is %d, although %d is expected.", actualMibIfRow2Size, mibIfRow2Size) 595 } 596 597 offset := uintptr(unsafe.Pointer(&s.InterfaceIndex)) - sp 598 if offset != mibIfRow2InterfaceIndexOffset { 599 t.Errorf("MibIfRow2.InterfaceIndex offset is %d although %d is expected", offset, mibIfRow2InterfaceIndexOffset) 600 } 601 602 offset = uintptr(unsafe.Pointer(&s.InterfaceGUID)) - sp 603 if offset != mibIfRow2InterfaceGUIDOffset { 604 t.Errorf("MibIfRow2.InterfaceGUID offset is %d although %d is expected", offset, mibIfRow2InterfaceGUIDOffset) 605 } 606 607 offset = uintptr(unsafe.Pointer(&s.alias)) - sp 608 if offset != mibIfRow2AliasOffset { 609 t.Errorf("MibIfRow2.alias offset is %d although %d is expected", offset, mibIfRow2AliasOffset) 610 } 611 612 offset = uintptr(unsafe.Pointer(&s.description)) - sp 613 if offset != mibIfRow2DescriptionOffset { 614 t.Errorf("MibIfRow2.description offset is %d although %d is expected", offset, mibIfRow2DescriptionOffset) 615 } 616 617 offset = uintptr(unsafe.Pointer(&s.physicalAddressLength)) - sp 618 if offset != mibIfRow2PhysicalAddressLengthOffset { 619 t.Errorf("MibIfRow2.physicalAddressLength offset is %d although %d is expected", offset, mibIfRow2PhysicalAddressLengthOffset) 620 } 621 622 offset = uintptr(unsafe.Pointer(&s.physicalAddress)) - sp 623 if offset != mibIfRow2PhysicalAddressOffset { 624 t.Errorf("MibIfRow2.physicalAddress offset is %d although %d is expected", offset, mibIfRow2PhysicalAddressOffset) 625 } 626 627 offset = uintptr(unsafe.Pointer(&s.permanentPhysicalAddress)) - sp 628 if offset != mibIfRow2PermanentPhysicalAddressOffset { 629 t.Errorf("MibIfRow2.permanentPhysicalAddress offset is %d although %d is expected", offset, mibIfRow2PermanentPhysicalAddressOffset) 630 } 631 632 offset = uintptr(unsafe.Pointer(&s.MTU)) - sp 633 if offset != mibIfRow2MTUOffset { 634 t.Errorf("MibIfRow2.MTU offset is %d although %d is expected", offset, mibIfRow2MTUOffset) 635 } 636 637 offset = uintptr(unsafe.Pointer(&s.Type)) - sp 638 if offset != mibIfRow2TypeOffset { 639 t.Errorf("MibIfRow2.Type offset is %d although %d is expected", offset, mibIfRow2TypeOffset) 640 } 641 642 offset = uintptr(unsafe.Pointer(&s.TunnelType)) - sp 643 if offset != mibIfRow2TunnelTypeOffset { 644 t.Errorf("MibIfRow2.TunnelType offset is %d although %d is expected", offset, mibIfRow2TunnelTypeOffset) 645 } 646 647 offset = uintptr(unsafe.Pointer(&s.MediaType)) - sp 648 if offset != mibIfRow2MediaTypeOffset { 649 t.Errorf("MibIfRow2.MediaType offset is %d although %d is expected", offset, mibIfRow2MediaTypeOffset) 650 } 651 652 offset = uintptr(unsafe.Pointer(&s.PhysicalMediumType)) - sp 653 if offset != mibIfRow2PhysicalMediumTypeOffset { 654 t.Errorf("MibIfRow2.PhysicalMediumType offset is %d although %d is expected", offset, mibIfRow2PhysicalMediumTypeOffset) 655 } 656 657 offset = uintptr(unsafe.Pointer(&s.AccessType)) - sp 658 if offset != mibIfRow2AccessTypeOffset { 659 t.Errorf("MibIfRow2.AccessType offset is %d although %d is expected", offset, mibIfRow2AccessTypeOffset) 660 } 661 662 offset = uintptr(unsafe.Pointer(&s.DirectionType)) - sp 663 if offset != mibIfRow2DirectionTypeOffset { 664 t.Errorf("MibIfRow2.DirectionType offset is %d although %d is expected", offset, mibIfRow2DirectionTypeOffset) 665 } 666 667 offset = uintptr(unsafe.Pointer(&s.InterfaceAndOperStatusFlags)) - sp 668 if offset != mibIfRow2InterfaceAndOperStatusFlagsOffset { 669 t.Errorf("MibIfRow2.InterfaceAndOperStatusFlags offset is %d although %d is expected", offset, mibIfRow2InterfaceAndOperStatusFlagsOffset) 670 } 671 672 offset = uintptr(unsafe.Pointer(&s.OperStatus)) - sp 673 if offset != mibIfRow2OperStatusOffset { 674 t.Errorf("MibIfRow2.OperStatus offset is %d although %d is expected", offset, mibIfRow2OperStatusOffset) 675 } 676 677 offset = uintptr(unsafe.Pointer(&s.AdminStatus)) - sp 678 if offset != mibIfRow2AdminStatusOffset { 679 t.Errorf("MibIfRow2.AdminStatus offset is %d although %d is expected", offset, mibIfRow2AdminStatusOffset) 680 } 681 682 offset = uintptr(unsafe.Pointer(&s.MediaConnectState)) - sp 683 if offset != mibIfRow2MediaConnectStateOffset { 684 t.Errorf("MibIfRow2.MediaConnectState offset is %d although %d is expected", offset, mibIfRow2MediaConnectStateOffset) 685 } 686 687 offset = uintptr(unsafe.Pointer(&s.NetworkGUID)) - sp 688 if offset != mibIfRow2NetworkGUIDOffset { 689 t.Errorf("MibIfRow2.NetworkGUID offset is %d although %d is expected", offset, mibIfRow2NetworkGUIDOffset) 690 } 691 692 offset = uintptr(unsafe.Pointer(&s.ConnectionType)) - sp 693 if offset != mibIfRow2ConnectionTypeOffset { 694 t.Errorf("MibIfRow2.ConnectionType offset is %d although %d is expected", offset, mibIfRow2ConnectionTypeOffset) 695 } 696 697 offset = uintptr(unsafe.Pointer(&s.TransmitLinkSpeed)) - sp 698 if offset != mibIfRow2TransmitLinkSpeedOffset { 699 t.Errorf("MibIfRow2.TransmitLinkSpeed offset is %d although %d is expected", offset, mibIfRow2TransmitLinkSpeedOffset) 700 } 701 702 offset = uintptr(unsafe.Pointer(&s.ReceiveLinkSpeed)) - sp 703 if offset != mibIfRow2ReceiveLinkSpeedOffset { 704 t.Errorf("MibIfRow2.ReceiveLinkSpeed offset is %d although %d is expected", offset, mibIfRow2ReceiveLinkSpeedOffset) 705 } 706 707 offset = uintptr(unsafe.Pointer(&s.InOctets)) - sp 708 if offset != mibIfRow2InOctetsOffset { 709 t.Errorf("MibIfRow2.InOctets offset is %d although %d is expected", offset, mibIfRow2InOctetsOffset) 710 } 711 712 offset = uintptr(unsafe.Pointer(&s.InUcastPkts)) - sp 713 if offset != mibIfRow2InUcastPktsOffset { 714 t.Errorf("MibIfRow2.InUcastPkts offset is %d although %d is expected", offset, mibIfRow2InUcastPktsOffset) 715 } 716 717 offset = uintptr(unsafe.Pointer(&s.InNUcastPkts)) - sp 718 if offset != mibIfRow2InNUcastPktsOffset { 719 t.Errorf("MibIfRow2.InNUcastPkts offset is %d although %d is expected", offset, mibIfRow2InNUcastPktsOffset) 720 } 721 722 offset = uintptr(unsafe.Pointer(&s.InDiscards)) - sp 723 if offset != mibIfRow2InDiscardsOffset { 724 t.Errorf("MibIfRow2.InDiscards offset is %d although %d is expected", offset, mibIfRow2InDiscardsOffset) 725 } 726 727 offset = uintptr(unsafe.Pointer(&s.InErrors)) - sp 728 if offset != mibIfRow2InErrorsOffset { 729 t.Errorf("MibIfRow2.InErrors offset is %d although %d is expected", offset, mibIfRow2InErrorsOffset) 730 } 731 732 offset = uintptr(unsafe.Pointer(&s.InUnknownProtos)) - sp 733 if offset != mibIfRow2InUnknownProtosOffset { 734 t.Errorf("MibIfRow2.InUnknownProtos offset is %d although %d is expected", offset, mibIfRow2InUnknownProtosOffset) 735 } 736 737 offset = uintptr(unsafe.Pointer(&s.InUcastOctets)) - sp 738 if offset != mibIfRow2InUcastOctetsOffset { 739 t.Errorf("MibIfRow2.InUcastOctets offset is %d although %d is expected", offset, mibIfRow2InUcastOctetsOffset) 740 } 741 742 offset = uintptr(unsafe.Pointer(&s.InMulticastOctets)) - sp 743 if offset != mibIfRow2InMulticastOctetsOffset { 744 t.Errorf("MibIfRow2.InMulticastOctets offset is %d although %d is expected", offset, mibIfRow2InMulticastOctetsOffset) 745 } 746 747 offset = uintptr(unsafe.Pointer(&s.InBroadcastOctets)) - sp 748 if offset != mibIfRow2InBroadcastOctetsOffset { 749 t.Errorf("MibIfRow2.InBroadcastOctets offset is %d although %d is expected", offset, mibIfRow2InBroadcastOctetsOffset) 750 } 751 752 offset = uintptr(unsafe.Pointer(&s.OutOctets)) - sp 753 if offset != mibIfRow2OutOctetsOffset { 754 t.Errorf("MibIfRow2.OutOctets offset is %d although %d is expected", offset, mibIfRow2OutOctetsOffset) 755 } 756 757 offset = uintptr(unsafe.Pointer(&s.OutUcastPkts)) - sp 758 if offset != mibIfRow2OutUcastPktsOffset { 759 t.Errorf("MibIfRow2.OutUcastPkts offset is %d although %d is expected", offset, mibIfRow2OutUcastPktsOffset) 760 } 761 762 offset = uintptr(unsafe.Pointer(&s.OutNUcastPkts)) - sp 763 if offset != mibIfRow2OutNUcastPktsOffset { 764 t.Errorf("MibIfRow2.OutNUcastPkts offset is %d although %d is expected", offset, mibIfRow2OutNUcastPktsOffset) 765 } 766 767 offset = uintptr(unsafe.Pointer(&s.OutDiscards)) - sp 768 if offset != mibIfRow2OutDiscardsOffset { 769 t.Errorf("MibIfRow2.OutDiscards offset is %d although %d is expected", offset, mibIfRow2OutDiscardsOffset) 770 } 771 772 offset = uintptr(unsafe.Pointer(&s.OutErrors)) - sp 773 if offset != mibIfRow2OutErrorsOffset { 774 t.Errorf("MibIfRow2.OutErrors offset is %d although %d is expected", offset, mibIfRow2OutErrorsOffset) 775 } 776 777 offset = uintptr(unsafe.Pointer(&s.OutUcastOctets)) - sp 778 if offset != mibIfRow2OutUcastOctetsOffset { 779 t.Errorf("MibIfRow2.OutUcastOctets offset is %d although %d is expected", offset, mibIfRow2OutUcastOctetsOffset) 780 } 781 782 offset = uintptr(unsafe.Pointer(&s.OutMulticastOctets)) - sp 783 if offset != mibIfRow2OutMulticastOctetsOffset { 784 t.Errorf("MibIfRow2.OutMulticastOctets offset is %d although %d is expected", offset, mibIfRow2OutMulticastOctetsOffset) 785 } 786 787 offset = uintptr(unsafe.Pointer(&s.OutBroadcastOctets)) - sp 788 if offset != mibIfRow2OutBroadcastOctetsOffset { 789 t.Errorf("MibIfRow2.OutBroadcastOctets offset is %d although %d is expected", offset, mibIfRow2OutBroadcastOctetsOffset) 790 } 791 792 offset = uintptr(unsafe.Pointer(&s.OutQLen)) - sp 793 if offset != mibIfRow2OutQLenOffset { 794 t.Errorf("MibIfRow2.OutQLen offset is %d although %d is expected", offset, mibIfRow2OutQLenOffset) 795 } 796 } 797 798 func TestMibIfTable2(t *testing.T) { 799 s := mibIfTable2{} 800 sp := uintptr(unsafe.Pointer(&s)) 801 const actualmibIfTable2Size = unsafe.Sizeof(s) 802 803 if actualmibIfTable2Size != mibIfTable2Size { 804 t.Errorf("Size of mibIfTable2 is %d, although %d is expected.", actualmibIfTable2Size, mibIfTable2Size) 805 } 806 807 offset := uintptr(unsafe.Pointer(&s.table)) - sp 808 if offset != mibIfTable2TableOffset { 809 t.Errorf("mibIfTable2.table offset is %d although %d is expected", offset, mibIfTable2TableOffset) 810 } 811 } 812 813 func TestRawSockaddrInet(t *testing.T) { 814 s := RawSockaddrInet{} 815 sp := uintptr(unsafe.Pointer(&s)) 816 const actualRawSockaddrInetSize = unsafe.Sizeof(s) 817 818 if actualRawSockaddrInetSize != rawSockaddrInetSize { 819 t.Errorf("Size of RawSockaddrInet is %d, although %d is expected.", actualRawSockaddrInetSize, rawSockaddrInetSize) 820 } 821 822 offset := uintptr(unsafe.Pointer(&s.data)) - sp 823 if offset != rawSockaddrInetDataOffset { 824 t.Errorf("RawSockaddrInet.data offset is %d although %d is expected", offset, rawSockaddrInetDataOffset) 825 } 826 } 827 828 func TestMibUnicastIPAddressRow(t *testing.T) { 829 s := MibUnicastIPAddressRow{} 830 sp := uintptr(unsafe.Pointer(&s)) 831 const actualMibUnicastIPAddressRowSize = unsafe.Sizeof(s) 832 833 if actualMibUnicastIPAddressRowSize != mibUnicastIPAddressRowSize { 834 t.Errorf("Size of MibUnicastIPAddressRow is %d, although %d is expected.", actualMibUnicastIPAddressRowSize, mibUnicastIPAddressRowSize) 835 } 836 837 offset := uintptr(unsafe.Pointer(&s.InterfaceLUID)) - sp 838 if offset != mibUnicastIPAddressRowInterfaceLUIDOffset { 839 t.Errorf("MibUnicastIPAddressRow.InterfaceLUID offset is %d although %d is expected", offset, mibUnicastIPAddressRowInterfaceLUIDOffset) 840 } 841 842 offset = uintptr(unsafe.Pointer(&s.InterfaceIndex)) - sp 843 if offset != mibUnicastIPAddressRowInterfaceIndexOffset { 844 t.Errorf("MibUnicastIPAddressRow.InterfaceIndex offset is %d although %d is expected", offset, mibUnicastIPAddressRowInterfaceIndexOffset) 845 } 846 847 offset = uintptr(unsafe.Pointer(&s.PrefixOrigin)) - sp 848 if offset != mibUnicastIPAddressRowPrefixOriginOffset { 849 t.Errorf("MibUnicastIPAddressRow.PrefixOrigin offset is %d although %d is expected", offset, mibUnicastIPAddressRowPrefixOriginOffset) 850 } 851 852 offset = uintptr(unsafe.Pointer(&s.SuffixOrigin)) - sp 853 if offset != mibUnicastIPAddressRowSuffixOriginOffset { 854 t.Errorf("MibUnicastIPAddressRow.SuffixOrigin offset is %d although %d is expected", offset, mibUnicastIPAddressRowSuffixOriginOffset) 855 } 856 857 offset = uintptr(unsafe.Pointer(&s.ValidLifetime)) - sp 858 if offset != mibUnicastIPAddressRowValidLifetimeOffset { 859 t.Errorf("MibUnicastIPAddressRow.ValidLifetime offset is %d although %d is expected", offset, mibUnicastIPAddressRowValidLifetimeOffset) 860 } 861 862 offset = uintptr(unsafe.Pointer(&s.PreferredLifetime)) - sp 863 if offset != mibUnicastIPAddressRowPreferredLifetimeOffset { 864 t.Errorf("MibUnicastIPAddressRow.PreferredLifetime offset is %d although %d is expected", offset, mibUnicastIPAddressRowPreferredLifetimeOffset) 865 } 866 867 offset = uintptr(unsafe.Pointer(&s.OnLinkPrefixLength)) - sp 868 if offset != mibUnicastIPAddressRowOnLinkPrefixLengthOffset { 869 t.Errorf("MibUnicastIPAddressRow.OnLinkPrefixLength offset is %d although %d is expected", offset, mibUnicastIPAddressRowOnLinkPrefixLengthOffset) 870 } 871 872 offset = uintptr(unsafe.Pointer(&s.SkipAsSource)) - sp 873 if offset != mibUnicastIPAddressRowSkipAsSourceOffset { 874 t.Errorf("MibUnicastIPAddressRow.SkipAsSource offset is %d although %d is expected", offset, mibUnicastIPAddressRowSkipAsSourceOffset) 875 } 876 877 offset = uintptr(unsafe.Pointer(&s.DadState)) - sp 878 if offset != mibUnicastIPAddressRowDadStateOffset { 879 t.Errorf("MibUnicastIPAddressRow.DadState offset is %d although %d is expected", offset, mibUnicastIPAddressRowDadStateOffset) 880 } 881 882 offset = uintptr(unsafe.Pointer(&s.ScopeID)) - sp 883 if offset != mibUnicastIPAddressRowScopeIDOffset { 884 t.Errorf("MibUnicastIPAddressRow.ScopeID offset is %d although %d is expected", offset, mibUnicastIPAddressRowScopeIDOffset) 885 } 886 887 offset = uintptr(unsafe.Pointer(&s.CreationTimeStamp)) - sp 888 if offset != mibUnicastIPAddressRowCreationTimeStampOffset { 889 t.Errorf("MibUnicastIPAddressRow.CreationTimeStamp offset is %d although %d is expected", offset, mibUnicastIPAddressRowCreationTimeStampOffset) 890 } 891 } 892 893 func TestMibUnicastIPAddressTable(t *testing.T) { 894 s := mibUnicastIPAddressTable{} 895 sp := uintptr(unsafe.Pointer(&s)) 896 const actualmibUnicastIPAddressTableSize = unsafe.Sizeof(s) 897 898 if actualmibUnicastIPAddressTableSize != mibUnicastIPAddressTableSize { 899 t.Errorf("Size of mibUnicastIPAddressTable is %d, although %d is expected.", actualmibUnicastIPAddressTableSize, mibUnicastIPAddressTableSize) 900 } 901 902 offset := uintptr(unsafe.Pointer(&s.table)) - sp 903 if offset != mibUnicastIPAddressTableTableOffset { 904 t.Errorf("mibUnicastIPAddressTable.table offset is %d although %d is expected", offset, mibUnicastIPAddressTableTableOffset) 905 } 906 } 907 908 func TestMibAnycastIPAddressRow(t *testing.T) { 909 s := MibAnycastIPAddressRow{} 910 sp := uintptr(unsafe.Pointer(&s)) 911 const actualMibAnycastIPAddressRowSize = unsafe.Sizeof(s) 912 913 if actualMibAnycastIPAddressRowSize != mibAnycastIPAddressRowSize { 914 t.Errorf("Size of MibAnycastIPAddressRow is %d, although %d is expected.", actualMibAnycastIPAddressRowSize, mibAnycastIPAddressRowSize) 915 } 916 917 offset := uintptr(unsafe.Pointer(&s.InterfaceLUID)) - sp 918 if offset != mibAnycastIPAddressRowInterfaceLUIDOffset { 919 t.Errorf("MibAnycastIPAddressRow.InterfaceLUID offset is %d although %d is expected", offset, mibAnycastIPAddressRowInterfaceLUIDOffset) 920 } 921 922 offset = uintptr(unsafe.Pointer(&s.InterfaceIndex)) - sp 923 if offset != mibAnycastIPAddressRowInterfaceIndexOffset { 924 t.Errorf("MibAnycastIPAddressRow.InterfaceIndex offset is %d although %d is expected", offset, mibAnycastIPAddressRowInterfaceIndexOffset) 925 } 926 927 offset = uintptr(unsafe.Pointer(&s.ScopeID)) - sp 928 if offset != mibAnycastIPAddressRowScopeIDOffset { 929 t.Errorf("MibAnycastIPAddressRow.ScopeID offset is %d although %d is expected", offset, mibAnycastIPAddressRowScopeIDOffset) 930 } 931 } 932 933 func TestMibAnycastIPAddressTable(t *testing.T) { 934 s := mibAnycastIPAddressTable{} 935 sp := uintptr(unsafe.Pointer(&s)) 936 const actualmibAnycastIPAddressTableSize = unsafe.Sizeof(s) 937 938 if actualmibAnycastIPAddressTableSize != mibAnycastIPAddressTableSize { 939 t.Errorf("Size of mibAnycastIPAddressTable is %d, although %d is expected.", actualmibAnycastIPAddressTableSize, mibAnycastIPAddressTableSize) 940 } 941 942 offset := uintptr(unsafe.Pointer(&s.table)) - sp 943 if offset != mibAnycastIPAddressTableTableOffset { 944 t.Errorf("mibAnycastIPAddressTable.table offset is %d although %d is expected", offset, mibAnycastIPAddressTableTableOffset) 945 } 946 } 947 948 func TestIPAddressPrefix(t *testing.T) { 949 s := IPAddressPrefix{} 950 sp := uintptr(unsafe.Pointer(&s)) 951 const actualIPAddressPrefixSize = unsafe.Sizeof(s) 952 953 if actualIPAddressPrefixSize != ipAddressPrefixSize { 954 t.Errorf("Size of IPAddressPrefix is %d, although %d is expected.", actualIPAddressPrefixSize, ipAddressPrefixSize) 955 } 956 957 offset := uintptr(unsafe.Pointer(&s.PrefixLength)) - sp 958 if offset != ipAddressPrefixPrefixLengthOffset { 959 t.Errorf("IPAddressPrefix.PrefixLength offset is %d although %d is expected", offset, ipAddressPrefixPrefixLengthOffset) 960 } 961 } 962 963 func TestMibIPforwardRow2(t *testing.T) { 964 s := MibIPforwardRow2{} 965 sp := uintptr(unsafe.Pointer(&s)) 966 const actualMibIPforwardRow2Size = unsafe.Sizeof(s) 967 968 if actualMibIPforwardRow2Size != mibIPforwardRow2Size { 969 t.Errorf("Size of MibIPforwardRow2 is %d, although %d is expected.", actualMibIPforwardRow2Size, mibIPforwardRow2Size) 970 } 971 972 offset := uintptr(unsafe.Pointer(&s.InterfaceIndex)) - sp 973 if offset != mibIPforwardRow2InterfaceIndexOffset { 974 t.Errorf("MibIPforwardRow2.InterfaceIndex offset is %d although %d is expected", offset, mibIPforwardRow2InterfaceIndexOffset) 975 } 976 977 offset = uintptr(unsafe.Pointer(&s.DestinationPrefix)) - sp 978 if offset != mibIPforwardRow2DestinationPrefixOffset { 979 t.Errorf("MibIPforwardRow2.DestinationPrefix offset is %d although %d is expected", offset, mibIPforwardRow2DestinationPrefixOffset) 980 } 981 982 offset = uintptr(unsafe.Pointer(&s.NextHop)) - sp 983 if offset != mibIPforwardRow2NextHopOffset { 984 t.Errorf("MibIPforwardRow2.NextHop offset is %d although %d is expected", offset, mibIPforwardRow2NextHopOffset) 985 } 986 987 offset = uintptr(unsafe.Pointer(&s.SitePrefixLength)) - sp 988 if offset != mibIPforwardRow2SitePrefixLengthOffset { 989 t.Errorf("MibIPforwardRow2.SitePrefixLength offset is %d although %d is expected", offset, mibIPforwardRow2SitePrefixLengthOffset) 990 } 991 992 offset = uintptr(unsafe.Pointer(&s.ValidLifetime)) - sp 993 if offset != mibIPforwardRow2ValidLifetimeOffset { 994 t.Errorf("MibIPforwardRow2.ValidLifetime offset is %d although %d is expected", offset, mibIPforwardRow2ValidLifetimeOffset) 995 } 996 997 offset = uintptr(unsafe.Pointer(&s.PreferredLifetime)) - sp 998 if offset != mibIPforwardRow2PreferredLifetimeOffset { 999 t.Errorf("MibIPforwardRow2.PreferredLifetime offset is %d although %d is expected", offset, mibIPforwardRow2PreferredLifetimeOffset) 1000 } 1001 1002 offset = uintptr(unsafe.Pointer(&s.Metric)) - sp 1003 if offset != mibIPforwardRow2MetricOffset { 1004 t.Errorf("MibIPforwardRow2.Metric offset is %d although %d is expected", offset, mibIPforwardRow2MetricOffset) 1005 } 1006 1007 offset = uintptr(unsafe.Pointer(&s.Protocol)) - sp 1008 if offset != mibIPforwardRow2ProtocolOffset { 1009 t.Errorf("MibIPforwardRow2.Protocol offset is %d although %d is expected", offset, mibIPforwardRow2ProtocolOffset) 1010 } 1011 1012 offset = uintptr(unsafe.Pointer(&s.Loopback)) - sp 1013 if offset != mibIPforwardRow2LoopbackOffset { 1014 t.Errorf("MibIPforwardRow2.Loopback offset is %d although %d is expected", offset, mibIPforwardRow2LoopbackOffset) 1015 } 1016 1017 offset = uintptr(unsafe.Pointer(&s.AutoconfigureAddress)) - sp 1018 if offset != mibIPforwardRow2AutoconfigureAddressOffset { 1019 t.Errorf("MibIPforwardRow2.AutoconfigureAddress offset is %d although %d is expected", offset, mibIPforwardRow2AutoconfigureAddressOffset) 1020 } 1021 1022 offset = uintptr(unsafe.Pointer(&s.Publish)) - sp 1023 if offset != mibIPforwardRow2PublishOffset { 1024 t.Errorf("MibIPforwardRow2.Publish offset is %d although %d is expected", offset, mibIPforwardRow2PublishOffset) 1025 } 1026 1027 offset = uintptr(unsafe.Pointer(&s.Immortal)) - sp 1028 if offset != mibIPforwardRow2ImmortalOffset { 1029 t.Errorf("MibIPforwardRow2.Immortal offset is %d although %d is expected", offset, mibIPforwardRow2ImmortalOffset) 1030 } 1031 1032 offset = uintptr(unsafe.Pointer(&s.Age)) - sp 1033 if offset != mibIPforwardRow2AgeOffset { 1034 t.Errorf("MibIPforwardRow2.Age offset is %d although %d is expected", offset, mibIPforwardRow2AgeOffset) 1035 } 1036 1037 offset = uintptr(unsafe.Pointer(&s.Origin)) - sp 1038 if offset != mibIPforwardRow2OriginOffset { 1039 t.Errorf("MibIPforwardRow2.Origin offset is %d although %d is expected", offset, mibIPforwardRow2OriginOffset) 1040 } 1041 } 1042 1043 func TestMibIPforwardTable2(t *testing.T) { 1044 s := mibIPforwardTable2{} 1045 sp := uintptr(unsafe.Pointer(&s)) 1046 const actualmibIPforwardTable2Size = unsafe.Sizeof(s) 1047 1048 if actualmibIPforwardTable2Size != mibIPforwardTable2Size { 1049 t.Errorf("Size of mibIPforwardTable2 is %d, although %d is expected.", actualmibIPforwardTable2Size, mibIPforwardTable2Size) 1050 } 1051 1052 offset := uintptr(unsafe.Pointer(&s.table)) - sp 1053 if offset != mibIPforwardTable2TableOffset { 1054 t.Errorf("mibIPforwardTable2.table offset is %d although %d is expected", offset, mibIPforwardTable2TableOffset) 1055 } 1056 }