golang.zx2c4.com/wireguard/windows@v0.5.4-0.20230123132234-dcc0eb72a04b/tunnel/firewall/types_windows_test.go (about) 1 /* SPDX-License-Identifier: MIT 2 * 3 * Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved. 4 */ 5 6 package firewall 7 8 import ( 9 "testing" 10 "unsafe" 11 ) 12 13 func TestWtFwpByteBlobSize(t *testing.T) { 14 const actualWtFwpByteBlobSize = unsafe.Sizeof(wtFwpByteBlob{}) 15 16 if actualWtFwpByteBlobSize != wtFwpByteBlob_Size { 17 t.Errorf("Size of FwpByteBlob is %d, although %d is expected.", actualWtFwpByteBlobSize, 18 wtFwpByteBlob_Size) 19 } 20 } 21 22 func TestWtFwpByteBlobOffsets(t *testing.T) { 23 s := wtFwpByteBlob{} 24 sp := uintptr(unsafe.Pointer(&s)) 25 26 offset := uintptr(unsafe.Pointer(&s.data)) - sp 27 28 if offset != wtFwpByteBlob_data_Offset { 29 t.Errorf("FwpByteBlob.data offset is %d although %d is expected", offset, wtFwpByteBlob_data_Offset) 30 return 31 } 32 } 33 34 func TestWtFwpmAction0Size(t *testing.T) { 35 const actualWtFwpmAction0Size = unsafe.Sizeof(wtFwpmAction0{}) 36 37 if actualWtFwpmAction0Size != wtFwpmAction0_Size { 38 t.Errorf("Size of wtFwpmAction0 is %d, although %d is expected.", actualWtFwpmAction0Size, 39 wtFwpmAction0_Size) 40 } 41 } 42 43 func TestWtFwpmAction0Offsets(t *testing.T) { 44 s := wtFwpmAction0{} 45 sp := uintptr(unsafe.Pointer(&s)) 46 47 offset := uintptr(unsafe.Pointer(&s.filterType)) - sp 48 49 if offset != wtFwpmAction0_filterType_Offset { 50 t.Errorf("wtFwpmAction0.filterType offset is %d although %d is expected", offset, 51 wtFwpmAction0_filterType_Offset) 52 return 53 } 54 } 55 56 func TestWtFwpBitmapArray64Size(t *testing.T) { 57 const actualWtFwpBitmapArray64Size = unsafe.Sizeof(wtFwpBitmapArray64{}) 58 59 if actualWtFwpBitmapArray64Size != wtFwpBitmapArray64_Size { 60 t.Errorf("Size of wtFwpBitmapArray64 is %d, although %d is expected.", actualWtFwpBitmapArray64Size, 61 wtFwpBitmapArray64_Size) 62 } 63 } 64 65 func TestWtFwpByteArray6Size(t *testing.T) { 66 const actualWtFwpByteArray6Size = unsafe.Sizeof(wtFwpByteArray6{}) 67 68 if actualWtFwpByteArray6Size != wtFwpByteArray6_Size { 69 t.Errorf("Size of wtFwpByteArray6 is %d, although %d is expected.", actualWtFwpByteArray6Size, 70 wtFwpByteArray6_Size) 71 } 72 } 73 74 func TestWtFwpByteArray16Size(t *testing.T) { 75 const actualWtFwpByteArray16Size = unsafe.Sizeof(wtFwpByteArray16{}) 76 77 if actualWtFwpByteArray16Size != wtFwpByteArray16_Size { 78 t.Errorf("Size of wtFwpByteArray16 is %d, although %d is expected.", actualWtFwpByteArray16Size, 79 wtFwpByteArray16_Size) 80 } 81 } 82 83 func TestWtFwpConditionValue0Size(t *testing.T) { 84 const actualWtFwpConditionValue0Size = unsafe.Sizeof(wtFwpConditionValue0{}) 85 86 if actualWtFwpConditionValue0Size != wtFwpConditionValue0_Size { 87 t.Errorf("Size of wtFwpConditionValue0 is %d, although %d is expected.", actualWtFwpConditionValue0Size, 88 wtFwpConditionValue0_Size) 89 } 90 } 91 92 func TestWtFwpConditionValue0Offsets(t *testing.T) { 93 s := wtFwpConditionValue0{} 94 sp := uintptr(unsafe.Pointer(&s)) 95 96 offset := uintptr(unsafe.Pointer(&s.value)) - sp 97 98 if offset != wtFwpConditionValue0_uint8_Offset { 99 t.Errorf("wtFwpConditionValue0.value offset is %d although %d is expected", offset, wtFwpConditionValue0_uint8_Offset) 100 return 101 } 102 } 103 104 func TestWtFwpV4AddrAndMaskSize(t *testing.T) { 105 const actualWtFwpV4AddrAndMaskSize = unsafe.Sizeof(wtFwpV4AddrAndMask{}) 106 107 if actualWtFwpV4AddrAndMaskSize != wtFwpV4AddrAndMask_Size { 108 t.Errorf("Size of wtFwpV4AddrAndMask is %d, although %d is expected.", actualWtFwpV4AddrAndMaskSize, 109 wtFwpV4AddrAndMask_Size) 110 } 111 } 112 113 func TestWtFwpV4AddrAndMaskOffsets(t *testing.T) { 114 s := wtFwpV4AddrAndMask{} 115 sp := uintptr(unsafe.Pointer(&s)) 116 117 offset := uintptr(unsafe.Pointer(&s.mask)) - sp 118 119 if offset != wtFwpV4AddrAndMask_mask_Offset { 120 t.Errorf("wtFwpV4AddrAndMask.mask offset is %d although %d is expected", offset, 121 wtFwpV4AddrAndMask_mask_Offset) 122 return 123 } 124 } 125 126 func TestWtFwpV6AddrAndMaskSize(t *testing.T) { 127 const actualWtFwpV6AddrAndMaskSize = unsafe.Sizeof(wtFwpV6AddrAndMask{}) 128 129 if actualWtFwpV6AddrAndMaskSize != wtFwpV6AddrAndMask_Size { 130 t.Errorf("Size of wtFwpV6AddrAndMask is %d, although %d is expected.", actualWtFwpV6AddrAndMaskSize, 131 wtFwpV6AddrAndMask_Size) 132 } 133 } 134 135 func TestWtFwpV6AddrAndMaskOffsets(t *testing.T) { 136 s := wtFwpV6AddrAndMask{} 137 sp := uintptr(unsafe.Pointer(&s)) 138 139 offset := uintptr(unsafe.Pointer(&s.prefixLength)) - sp 140 141 if offset != wtFwpV6AddrAndMask_prefixLength_Offset { 142 t.Errorf("wtFwpV6AddrAndMask.prefixLength offset is %d although %d is expected", offset, 143 wtFwpV6AddrAndMask_prefixLength_Offset) 144 return 145 } 146 } 147 148 func TestWtFwpValue0Size(t *testing.T) { 149 const actualWtFwpValue0Size = unsafe.Sizeof(wtFwpValue0{}) 150 151 if actualWtFwpValue0Size != wtFwpValue0_Size { 152 t.Errorf("Size of wtFwpValue0 is %d, although %d is expected.", actualWtFwpValue0Size, wtFwpValue0_Size) 153 } 154 } 155 156 func TestWtFwpValue0Offsets(t *testing.T) { 157 s := wtFwpValue0{} 158 sp := uintptr(unsafe.Pointer(&s)) 159 160 offset := uintptr(unsafe.Pointer(&s.value)) - sp 161 162 if offset != wtFwpValue0_value_Offset { 163 t.Errorf("wtFwpValue0.value offset is %d although %d is expected", offset, wtFwpValue0_value_Offset) 164 return 165 } 166 } 167 168 func TestWtFwpmDisplayData0Size(t *testing.T) { 169 const actualWtFwpmDisplayData0Size = unsafe.Sizeof(wtFwpmDisplayData0{}) 170 171 if actualWtFwpmDisplayData0Size != wtFwpmDisplayData0_Size { 172 t.Errorf("Size of wtFwpmDisplayData0 is %d, although %d is expected.", actualWtFwpmDisplayData0Size, 173 wtFwpmDisplayData0_Size) 174 } 175 } 176 177 func TestWtFwpmDisplayData0Offsets(t *testing.T) { 178 s := wtFwpmDisplayData0{} 179 sp := uintptr(unsafe.Pointer(&s)) 180 181 offset := uintptr(unsafe.Pointer(&s.description)) - sp 182 183 if offset != wtFwpmDisplayData0_description_Offset { 184 t.Errorf("wtFwpmDisplayData0.description offset is %d although %d is expected", offset, 185 wtFwpmDisplayData0_description_Offset) 186 return 187 } 188 } 189 190 func TestWtFwpmFilterCondition0Size(t *testing.T) { 191 const actualWtFwpmFilterCondition0Size = unsafe.Sizeof(wtFwpmFilterCondition0{}) 192 193 if actualWtFwpmFilterCondition0Size != wtFwpmFilterCondition0_Size { 194 t.Errorf("Size of wtFwpmFilterCondition0 is %d, although %d is expected.", 195 actualWtFwpmFilterCondition0Size, wtFwpmFilterCondition0_Size) 196 } 197 } 198 199 func TestWtFwpmFilterCondition0Offsets(t *testing.T) { 200 s := wtFwpmFilterCondition0{} 201 sp := uintptr(unsafe.Pointer(&s)) 202 203 offset := uintptr(unsafe.Pointer(&s.matchType)) - sp 204 205 if offset != wtFwpmFilterCondition0_matchType_Offset { 206 t.Errorf("wtFwpmFilterCondition0.matchType offset is %d although %d is expected", offset, 207 wtFwpmFilterCondition0_matchType_Offset) 208 return 209 } 210 211 offset = uintptr(unsafe.Pointer(&s.conditionValue)) - sp 212 213 if offset != wtFwpmFilterCondition0_conditionValue_Offset { 214 t.Errorf("wtFwpmFilterCondition0.conditionValue offset is %d although %d is expected", offset, 215 wtFwpmFilterCondition0_conditionValue_Offset) 216 return 217 } 218 } 219 220 func TestWtFwpmFilter0Size(t *testing.T) { 221 const actualWtFwpmFilter0Size = unsafe.Sizeof(wtFwpmFilter0{}) 222 223 if actualWtFwpmFilter0Size != wtFwpmFilter0_Size { 224 t.Errorf("Size of wtFwpmFilter0 is %d, although %d is expected.", actualWtFwpmFilter0Size, 225 wtFwpmFilter0_Size) 226 } 227 } 228 229 func TestWtFwpmFilter0Offsets(t *testing.T) { 230 s := wtFwpmFilter0{} 231 sp := uintptr(unsafe.Pointer(&s)) 232 233 offset := uintptr(unsafe.Pointer(&s.displayData)) - sp 234 235 if offset != wtFwpmFilter0_displayData_Offset { 236 t.Errorf("wtFwpmFilter0.displayData offset is %d although %d is expected", offset, 237 wtFwpmFilter0_displayData_Offset) 238 return 239 } 240 241 offset = uintptr(unsafe.Pointer(&s.flags)) - sp 242 243 if offset != wtFwpmFilter0_flags_Offset { 244 t.Errorf("wtFwpmFilter0.flags offset is %d although %d is expected", offset, wtFwpmFilter0_flags_Offset) 245 return 246 } 247 248 offset = uintptr(unsafe.Pointer(&s.providerKey)) - sp 249 250 if offset != wtFwpmFilter0_providerKey_Offset { 251 t.Errorf("wtFwpmFilter0.providerKey offset is %d although %d is expected", offset, 252 wtFwpmFilter0_providerKey_Offset) 253 return 254 } 255 256 offset = uintptr(unsafe.Pointer(&s.providerData)) - sp 257 258 if offset != wtFwpmFilter0_providerData_Offset { 259 t.Errorf("wtFwpmFilter0.providerData offset is %d although %d is expected", offset, 260 wtFwpmFilter0_providerData_Offset) 261 return 262 } 263 264 offset = uintptr(unsafe.Pointer(&s.layerKey)) - sp 265 266 if offset != wtFwpmFilter0_layerKey_Offset { 267 t.Errorf("wtFwpmFilter0.layerKey offset is %d although %d is expected", offset, 268 wtFwpmFilter0_layerKey_Offset) 269 return 270 } 271 272 offset = uintptr(unsafe.Pointer(&s.subLayerKey)) - sp 273 274 if offset != wtFwpmFilter0_subLayerKey_Offset { 275 t.Errorf("wtFwpmFilter0.subLayerKey offset is %d although %d is expected", offset, 276 wtFwpmFilter0_subLayerKey_Offset) 277 return 278 } 279 280 offset = uintptr(unsafe.Pointer(&s.weight)) - sp 281 282 if offset != wtFwpmFilter0_weight_Offset { 283 t.Errorf("wtFwpmFilter0.weight offset is %d although %d is expected", offset, 284 wtFwpmFilter0_weight_Offset) 285 return 286 } 287 288 offset = uintptr(unsafe.Pointer(&s.numFilterConditions)) - sp 289 290 if offset != wtFwpmFilter0_numFilterConditions_Offset { 291 t.Errorf("wtFwpmFilter0.numFilterConditions offset is %d although %d is expected", offset, 292 wtFwpmFilter0_numFilterConditions_Offset) 293 return 294 } 295 296 offset = uintptr(unsafe.Pointer(&s.filterCondition)) - sp 297 298 if offset != wtFwpmFilter0_filterCondition_Offset { 299 t.Errorf("wtFwpmFilter0.filterCondition offset is %d although %d is expected", offset, 300 wtFwpmFilter0_filterCondition_Offset) 301 return 302 } 303 304 offset = uintptr(unsafe.Pointer(&s.action)) - sp 305 306 if offset != wtFwpmFilter0_action_Offset { 307 t.Errorf("wtFwpmFilter0.action offset is %d although %d is expected", offset, 308 wtFwpmFilter0_action_Offset) 309 return 310 } 311 312 offset = uintptr(unsafe.Pointer(&s.providerContextKey)) - sp 313 314 if offset != wtFwpmFilter0_providerContextKey_Offset { 315 t.Errorf("wtFwpmFilter0.providerContextKey offset is %d although %d is expected", offset, 316 wtFwpmFilter0_providerContextKey_Offset) 317 return 318 } 319 320 offset = uintptr(unsafe.Pointer(&s.reserved)) - sp 321 322 if offset != wtFwpmFilter0_reserved_Offset { 323 t.Errorf("wtFwpmFilter0.reserved offset is %d although %d is expected", offset, 324 wtFwpmFilter0_reserved_Offset) 325 return 326 } 327 328 offset = uintptr(unsafe.Pointer(&s.filterID)) - sp 329 330 if offset != wtFwpmFilter0_filterID_Offset { 331 t.Errorf("wtFwpmFilter0.filterID offset is %d although %d is expected", offset, 332 wtFwpmFilter0_filterID_Offset) 333 return 334 } 335 336 offset = uintptr(unsafe.Pointer(&s.effectiveWeight)) - sp 337 338 if offset != wtFwpmFilter0_effectiveWeight_Offset { 339 t.Errorf("wtFwpmFilter0.effectiveWeight offset is %d although %d is expected", offset, 340 wtFwpmFilter0_effectiveWeight_Offset) 341 return 342 } 343 } 344 345 func TestWtFwpProvider0Size(t *testing.T) { 346 const actualWtFwpProvider0Size = unsafe.Sizeof(wtFwpProvider0{}) 347 348 if actualWtFwpProvider0Size != wtFwpProvider0_Size { 349 t.Errorf("Size of wtFwpProvider0 is %d, although %d is expected.", actualWtFwpProvider0Size, 350 wtFwpProvider0_Size) 351 } 352 } 353 354 func TestWtFwpProvider0Offsets(t *testing.T) { 355 s := wtFwpProvider0{} 356 sp := uintptr(unsafe.Pointer(&s)) 357 358 offset := uintptr(unsafe.Pointer(&s.displayData)) - sp 359 360 if offset != wtFwpProvider0_displayData_Offset { 361 t.Errorf("wtFwpProvider0.displayData offset is %d although %d is expected", offset, 362 wtFwpProvider0_displayData_Offset) 363 return 364 } 365 366 offset = uintptr(unsafe.Pointer(&s.flags)) - sp 367 368 if offset != wtFwpProvider0_flags_Offset { 369 t.Errorf("wtFwpProvider0.flags offset is %d although %d is expected", offset, 370 wtFwpProvider0_flags_Offset) 371 return 372 } 373 374 offset = uintptr(unsafe.Pointer(&s.providerData)) - sp 375 376 if offset != wtFwpProvider0_providerData_Offset { 377 t.Errorf("wtFwpProvider0.providerData offset is %d although %d is expected", offset, 378 wtFwpProvider0_providerData_Offset) 379 return 380 } 381 382 offset = uintptr(unsafe.Pointer(&s.serviceName)) - sp 383 384 if offset != wtFwpProvider0_serviceName_Offset { 385 t.Errorf("wtFwpProvider0.serviceName offset is %d although %d is expected", offset, 386 wtFwpProvider0_serviceName_Offset) 387 return 388 } 389 } 390 391 func TestWtFwpmSession0Size(t *testing.T) { 392 const actualWtFwpmSession0Size = unsafe.Sizeof(wtFwpmSession0{}) 393 394 if actualWtFwpmSession0Size != wtFwpmSession0_Size { 395 t.Errorf("Size of wtFwpmSession0 is %d, although %d is expected.", actualWtFwpmSession0Size, 396 wtFwpmSession0_Size) 397 } 398 } 399 400 func TestWtFwpmSession0Offsets(t *testing.T) { 401 s := wtFwpmSession0{} 402 sp := uintptr(unsafe.Pointer(&s)) 403 404 offset := uintptr(unsafe.Pointer(&s.displayData)) - sp 405 406 if offset != wtFwpmSession0_displayData_Offset { 407 t.Errorf("wtFwpmSession0.displayData offset is %d although %d is expected", offset, 408 wtFwpmSession0_displayData_Offset) 409 return 410 } 411 412 offset = uintptr(unsafe.Pointer(&s.flags)) - sp 413 414 if offset != wtFwpmSession0_flags_Offset { 415 t.Errorf("wtFwpmSession0.flags offset is %d although %d is expected", offset, wtFwpmSession0_flags_Offset) 416 return 417 } 418 419 offset = uintptr(unsafe.Pointer(&s.txnWaitTimeoutInMSec)) - sp 420 421 if offset != wtFwpmSession0_txnWaitTimeoutInMSec_Offset { 422 t.Errorf("wtFwpmSession0.txnWaitTimeoutInMSec offset is %d although %d is expected", offset, 423 wtFwpmSession0_txnWaitTimeoutInMSec_Offset) 424 return 425 } 426 427 offset = uintptr(unsafe.Pointer(&s.processId)) - sp 428 429 if offset != wtFwpmSession0_processId_Offset { 430 t.Errorf("wtFwpmSession0.processId offset is %d although %d is expected", offset, 431 wtFwpmSession0_processId_Offset) 432 return 433 } 434 435 offset = uintptr(unsafe.Pointer(&s.sid)) - sp 436 437 if offset != wtFwpmSession0_sid_Offset { 438 t.Errorf("wtFwpmSession0.sid offset is %d although %d is expected", offset, wtFwpmSession0_sid_Offset) 439 return 440 } 441 442 offset = uintptr(unsafe.Pointer(&s.username)) - sp 443 444 if offset != wtFwpmSession0_username_Offset { 445 t.Errorf("wtFwpmSession0.username offset is %d although %d is expected", offset, 446 wtFwpmSession0_username_Offset) 447 return 448 } 449 450 offset = uintptr(unsafe.Pointer(&s.kernelMode)) - sp 451 452 if offset != wtFwpmSession0_kernelMode_Offset { 453 t.Errorf("wtFwpmSession0.kernelMode offset is %d although %d is expected", offset, 454 wtFwpmSession0_kernelMode_Offset) 455 return 456 } 457 } 458 459 func TestWtFwpmSublayer0Size(t *testing.T) { 460 const actualWtFwpmSublayer0Size = unsafe.Sizeof(wtFwpmSublayer0{}) 461 462 if actualWtFwpmSublayer0Size != wtFwpmSublayer0_Size { 463 t.Errorf("Size of wtFwpmSublayer0 is %d, although %d is expected.", actualWtFwpmSublayer0Size, 464 wtFwpmSublayer0_Size) 465 } 466 } 467 468 func TestWtFwpmSublayer0Offsets(t *testing.T) { 469 s := wtFwpmSublayer0{} 470 sp := uintptr(unsafe.Pointer(&s)) 471 472 offset := uintptr(unsafe.Pointer(&s.displayData)) - sp 473 474 if offset != wtFwpmSublayer0_displayData_Offset { 475 t.Errorf("wtFwpmSublayer0.displayData offset is %d although %d is expected", offset, 476 wtFwpmSublayer0_displayData_Offset) 477 return 478 } 479 480 offset = uintptr(unsafe.Pointer(&s.flags)) - sp 481 482 if offset != wtFwpmSublayer0_flags_Offset { 483 t.Errorf("wtFwpmSublayer0.flags offset is %d although %d is expected", offset, 484 wtFwpmSublayer0_flags_Offset) 485 return 486 } 487 488 offset = uintptr(unsafe.Pointer(&s.providerKey)) - sp 489 490 if offset != wtFwpmSublayer0_providerKey_Offset { 491 t.Errorf("wtFwpmSublayer0.providerKey offset is %d although %d is expected", offset, 492 wtFwpmSublayer0_providerKey_Offset) 493 return 494 } 495 496 offset = uintptr(unsafe.Pointer(&s.providerData)) - sp 497 498 if offset != wtFwpmSublayer0_providerData_Offset { 499 t.Errorf("wtFwpmSublayer0.providerData offset is %d although %d is expected", offset, 500 wtFwpmSublayer0_providerData_Offset) 501 return 502 } 503 504 offset = uintptr(unsafe.Pointer(&s.weight)) - sp 505 506 if offset != wtFwpmSublayer0_weight_Offset { 507 t.Errorf("wtFwpmSublayer0.weight offset is %d although %d is expected", offset, 508 wtFwpmSublayer0_weight_Offset) 509 return 510 } 511 }