1 #ifndef _NETIODEF_ 2 #define _NETIODEF_ 3 4 #pragma once 5 6 #ifdef __cplusplus 7 extern "C" { 8 #endif 9 10 #include "ws2def.h" 11 #include "ws2ipdef.h" 12 #include "mswsockdef.h" 13 #include "mstcpip.h" 14 #include "nldef.h" 15 16 #include "ifdef.h" 17 18 #ifndef ASSERT 19 #define ASSERT(x) ((void)0) 20 #define NETIODEF_DEFINED_ASSERT 21 #endif 22 23 #ifndef NETIO_INLINE 24 #if DBG 25 #define NETIO_INLINE __inline 26 #else 27 #define NETIO_INLINE __forceinline 28 #endif 29 #endif 30 31 #define IS_POWER_OF_TWO(x) (((x) != 0) && (((x) & ((x) - 1)) == 0)) 32 #define IS_VALID_IPV4_MASK(x) ((x.S_un.S_addr == (ULONG)-1) || IS_POWER_OF_TWO(~RtlUlongByteSwap(x.S_un.S_addr)+1)) 33 34 #ifndef BYTE_ORDER 35 36 #define _LITTLE_ENDIAN 1234 37 #define _BIG_ENDIAN 4321 38 #define _PDP_ENDIAN 3412 39 40 #if defined(i286) || defined(i386) || defined(_AMD64_) || defined(_IA64_) 41 #define BYTE_ORDER _LITTLE_ENDIAN 42 #endif 43 44 #endif /* BYTE_ORDER */ 45 46 typedef UINT8 HANDLE8, *PHANDLE8; 47 typedef UINT16 HANDLE16, *PHANDLE16; 48 typedef UINT32 HANDLE32, *PHANDLE32; 49 typedef UINT64 HANDLE64, *PHANDLE64; 50 51 #define MAKE_DD_DEVICE_NAME(x) (L"\\Device\\" x) 52 #define MAKE_WIN_DEVICE_NAME(x) (L"\\\\.\\" x) 53 54 #define DL_ADDRESS_LENGTH_MAXIMUM IF_MAX_PHYS_ADDRESS_LENGTH 55 #define DL_HEADER_LENGTH_MAXIMUM 64 56 #define DL_ETHERNET_HEADER_LENGTH_MAXIMUM (sizeof(ETHERNET_HEADER) + sizeof(SNAP_HEADER)) 57 #define DL_TUNNEL_HEADER_LENGTH_MAXIMUM max(sizeof(IPV4_HEADER), sizeof(IPV6_HEADER)) 58 59 #define EUI48_BROADCAST_INIT {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} 60 61 #define SNAP_DSAP 0xaa 62 #define SNAP_SSAP 0xaa 63 #define SNAP_CONTROL 0x03 64 #define SNAP_OUI 0x00 65 66 #define SNAP_TYPE_ARP ETHERNET_TYPE_ARP 67 #define SNAP_TYPE_IPV4 ETHERNET_TYPE_IPV4 68 #define SNAP_TYPE_IPV6 ETHERNET_TYPE_IPV6 69 70 #define ETH_LENGTH_OF_HEADER 14 71 #define ETH_LENGTH_OF_VLAN_HEADER 4 72 #define ETH_LENGTH_OF_SNAP_HEADER 8 73 74 #define ETHERNET_TYPE_MINIMUM 0x0600 75 #define ETHERNET_TYPE_IPV4 0x0800 76 #define ETHERNET_TYPE_ARP 0x0806 77 #define ETHERNET_TYPE_IPV6 0x86dd 78 #define ETHERNET_TYPE_802_1Q 0x8100 79 80 #define TOKENRING_ACCESSCONTROL 0x10 81 #define TOKENRING_FRAMECONTROL 0x40 82 83 #define SOURCEROUTE_RD_MAXIMUM 8 84 #define SOURCEROUTE_SIZE_MAXIMUM (sizeof(SOURCEROUTE_HEADER) + 2 * SOURCEROUTE_RD_MAXIMUM) 85 86 #define SOURCEROUTE_UNSPECIFIED_INIT {{sizeof(SOURCEROUTE_HEADER), TokenRingSpanningTreeExplorer}, {0}} 87 88 #define TOKENRING_MTU_DEFAULT 1500 89 #define TOKENRING_SOURCEROUTE_INDICATOR 0x80 90 91 #define FDDI_FRAMECODE 0x57 92 #define FDDI_MTU 4352 93 94 #define ARCNET_BROADCAST_MASK 0xff 95 #define ARCNET_BROADCAST_VALUE 0x00 96 #define ARCNET_PROTOCOL_ARP 0xd5 97 #define ARCNET_PROTOCOL_IPV4 0xd4 98 #define ARCNET_PROTOCOL_IPV6 0xc4 99 100 #define ip4_hdr _IPV4_HEADER 101 #define ip4_ver_hlen VersionAndHeaderLength 102 #define ip4_ver Version 103 #define ip4_hlen HeaderLength 104 #define ip4_tos TypeOfService 105 #define ip4_len TotalLength 106 #define ip4_id Identification 107 #define ip4_flags_offset FlagsAndOffset 108 #define ip4_flags Flags 109 #define ip4_offset FragmentOffset 110 #define ip4_ttl TimeToLive 111 #define ip4_protocol Protocol 112 #define ip4_xsum HeaderChecksum 113 #define ip4_src SourceAddress 114 #define ip4_dest DestinationAddress 115 116 #define IP_VER_MASK 0xF0 117 #define IPV4_VERSION 4 118 #define IPV4_DEFAULT_VERHLEN ((IPV4_VERSION << 4) | (sizeof(IPV4_HEADER) / sizeof(UINT32))) 119 #define IPV4_TOS_MASK 0xFC 120 121 #define MAX_IPV4_PACKET 65535 122 #define MAX_IPV4_PAYLOAD (MAX_IPV4_PACKET - sizeof(IPV4_HEADER)) 123 124 #define MAX_IPV4_HLEN 60 125 126 #define IPV4_MINIMUM_MTU 576 127 #define IPV4_MINIMUM_ULMTU (IPV4_MINIMUM_MTU - sizeof(IPV4_HEADER)) 128 129 #define MAX_IP_OPTIONS_LENGTH ((0xF * sizeof(UINT32)) - sizeof(IPV4_HEADER)) 130 #define SIZEOF_IP_OPT_ROUTING_HEADER 3 131 #define SIZEOF_IP_OPT_TIMESTAMP_HEADER 4 132 #define SIZEOF_IP_OPT_SECURITY 11 133 #define SIZEOF_IP_OPT_STREAMIDENTIFIER 4 134 #define SIZEOF_IP_OPT_ROUTERALERT 4 135 #define IP4_OFF_MASK 0xff1f 136 137 #define icmp4_hdr _ICMPV4_MESSAGE 138 #define icmp4_type Header.Type 139 #define icmp4_code Header.Code 140 #define icmp4_cksum Header.Checksum 141 #define icmp4_un_data32 Data32 142 #define icmp4_un_data16 Data16 143 #define icmp4_un_data8 Data8 144 #define icmp4_dataun Data 145 #define icmp4_data32 icmp4_dataun.icmp4_un_data32 146 #define icmp4_data16 icmp4_dataun.icmp4_un_data16 147 #define icmp4_data8 icmp4_dataun.icmp4_un_data8 148 #define icmp4_pptr icmp4_data32[0] 149 #define icmp4_mtu icmp4_data32[0] 150 #define icmp4_id icmp4_data16[0] 151 #define icmp4_seq icmp4_data16[1] 152 #define icmp4_maxdelay icmp4_data16[0] 153 154 #define RsType RsHeader.icmp4_type 155 #define RsCode RsHeader.icmp4_code 156 #define RsCksum RsHeader.icmp4_cksum 157 #define RsReserved RsHeader.icmp4_data32[0] 158 159 #define RaType RaHeader.icmp4_type 160 #define RaCode RaHeader.icmp4_code 161 #define RaCksum RaHeader.icmp4_cksum 162 #define RaNumAddr RaHeader.icmp4_data8[0] 163 #define RaAddrEntrySize RaHeader.icmp4_data8[1] 164 #define RaAddrLifetime RaHeader.icmp4_data16[1] 165 166 #define ICMPV4_INVALID_PREFERENCE_LEVEL 0x80000000 167 168 #define icmp4_ts_type Header.icmp4_type 169 #define icmp4_ts_code Header.icmp4_code 170 #define icmp4_ts_cksum Header.icmp4_cksum 171 #define icmp4_ts_id Header.icmp4_id 172 #define icmp4_ts_seq Header.icmp4_seq 173 #define icmp4_ts_originate OriginateTimestamp 174 #define icmp4_ts_receive ReceiveTimestamp 175 #define icmp4_ts_transmit TransmitTimestamp 176 177 #define IGMP_QUERY_TYPE 0x11 178 #define IGMP_VERSION1_REPORT_TYPE 0x12 179 #define IGMP_VERSION2_REPORT_TYPE 0x16 180 #define IGMP_LEAVE_GROUP_TYPE 0x17 181 #define IGMP_VERSION3_REPORT_TYPE 0x22 182 183 #define ip6_hdr _IPV6_HEADER 184 #define ip6_flow VersionClassFlow 185 #define ip6_plen PayloadLength 186 #define ip6_nxt NextHeader 187 #define ip6_hops HopLimit 188 #define ip6_hlim HopLimit 189 #define ip6_src SourceAddress 190 #define ip6_dst DestinationAddress 191 192 #define IP_VER_MASK 0xF0 193 #define IPV6_VERSION 0x60 194 195 #define IPV6_TRAFFIC_CLASS_MASK 0x0000C00F 196 #define IPV6_ECN_MASK 0x00003000 197 #define IPV6_FLOW_LABEL_MASK 0xFFFF0F00 198 #define MAX_IPV6_PAYLOAD 65535 199 #define MAX_IPV6_PACKET (MAX_IPV6_PAYLOAD + sizeof(IPV6_HEADER)) 200 201 #define IPV6_ECN_SHIFT 12 202 203 #define IPV6_MINIMUM_MTU 1280 204 #define IPV6_MINIMUM_ULMTU (IPV6_MINIMUM_MTU - sizeof(IPV6_HEADER)) 205 206 #define IPV6_TRAFFIC_CLASS(VersionClassFlow) \ 207 ((UCHAR)((((VersionClassFlow) & IPV6_TRAFFIC_CLASS_MASK) >> 12) + \ 208 (((VersionClassFlow) & IPV6_TRAFFIC_CLASS_MASK) << 4))) 209 210 #define ip6_frag _IPV6_FRAGMENT_HEADER 211 #define ip6f_nxt NextHeader 212 #define ip6f_reserved Reserved 213 #define ip6f_offlg OffsetAndFlags 214 #define ip6f_ident Id 215 216 #define IP6F_OFF_MASK 0xf8ff 217 #define IP6F_RESERVED_MASK 0x0600 218 #define IP6F_MORE_FRAG 0x0100 219 220 #define EXT_LEN_UNIT 8 221 222 #define IPV6_EXTENSION_HEADER_LENGTH(Blocks) ((Blocks + 1) * EXT_LEN_UNIT) 223 #define MAX_IPV6_EXTENSION_HEADER_LENGTH IPV6_EXTENSION_HEADER_LENGTH(0xFF) 224 #define IPV6_EXTENSION_HEADER_BLOCKS(Length) ((Length / EXT_LEN_UNIT) - 1) 225 #define IP_AUTHENTICATION_HEADER_LENGTH(Blocks) ((Blocks + 2) * 4) 226 #define IP_AUTHENTICATION_HEADER_BLOCKS(Length) (((Length + sizeof(AUTHENTICATION_HEADER)) / 4) - 2) 227 228 #define IPV6_ROUTER_ALERT_LENGTH IPV6_EXTENSION_HEADER_LENGTH(0) 229 230 #define ip6_hbh _IPV6_EXTENSION_HEADER 231 #define ip6h_nxt NextHeader 232 #define ip6h_len Length 233 #define ip6_dest _IPV6_EXTENSION_HEADER 234 #define ip6d_nxt NextHeader 235 #define ip6d_len Length 236 237 #define IP6OPT_TYPE(Type) ((Type) & 0xc0) 238 #define IP6OPT_TYPE_SKIP 0x00 239 #define IP6OPT_TYPE_DISCARD 0x40 240 #define IP6OPT_TYPE_FORCEICMP 0x80 241 #define IP6OPT_TYPE_ICMP 0xc0 242 243 #define IP6OPT_MUTABLE 0x20 244 #define IP6OPT_ISMUTABLE(Type) (((Type) & IP6OPT_MUTABLE) != 0) 245 246 #define ip6_opt_jumbo _IPV6_OPTION_JUMBOGRAM 247 #define ip6oj_type Header.Type 248 #define ip6oj_len Header.DataLength 249 #define ip6oj_jumbo_len JumbogramLength 250 251 #define ip6_opt_router _IPV6_OPTION_ROUTER_ALERT 252 #define ip6or_type Header.Type 253 #define ip6or_len Header.DataLength 254 #define ip6or_value Value 255 256 #define SIZEOF_IPV6_ROUTERALERT IPV6_EXTENSION_HEADER_LENGTH(0) 257 258 #define ip6_rthdr _IPV6_ROUTING_HEADER 259 #define ip6r_nxt NextHeader 260 #define ip6r_len Length 261 #define ip6r_type RoutingType 262 #define ip6r_segleft SegmentsLeft 263 264 #define icmp6_hdr _ICMPV6_MESSAGE 265 #define icmp6_type Header.Type 266 #define icmp6_code Header.Code 267 #define icmp6_cksum Header.Checksum 268 #define icmp6_un_data32 Data32 269 #define icmp6_un_data16 Data16 270 #define icmp6_un_data8 Data8 271 #define icmp6_dataun Data 272 273 #define icmp6_data32 icmp6_dataun.icmp6_un_data32 274 #define icmp6_data16 icmp6_dataun.icmp6_un_data16 275 #define icmp6_data8 icmp6_dataun.icmp6_un_data8 276 #define icmp6_pptr icmp6_data32[0] 277 #define icmp6_mtu icmp6_data32[0] 278 #define icmp6_id icmp6_data16[0] 279 #define icmp6_seq icmp6_data16[1] 280 #define icmp6_maxdelay icmp6_data16[0] 281 282 #define ICMP6_INFOMSG_MASK 0x80 283 284 #define ICMP6_DST_UNREACH_NOROUTE 0 285 #define ICMP6_DST_UNREACH_ADMIN 1 286 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 287 #define ICMP6_DST_UNREACH_ADDR 3 288 #define ICMP6_DST_UNREACH_NOPORT 4 289 290 #define ICMP6_TIME_EXCEED_TRANSIT 0 291 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 292 293 #define ICMP6_PARAMPROB_HEADER 0 294 #define ICMP6_PARAMPROB_NEXTHEADER 1 295 #define ICMP6_PARAMPROB_OPTION 2 296 297 #define ICMPV6_ECHO_REQUEST_FLAG_REVERSE 0x1 298 299 #define nd_rs_type nd_rs_hdr.icmp6_type 300 #define nd_rs_code nd_rs_hdr.icmp6_code 301 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum 302 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] 303 304 #define nd_ra_type nd_ra_hdr.icmp6_type 305 #define nd_ra_code nd_ra_hdr.icmp6_code 306 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum 307 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] 308 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] 309 #define ND_RA_FLAG_MANAGED 0x80 310 #define ND_RA_FLAG_OTHER 0x40 311 #define ND_RA_FLAG_HOME_AGENT 0x20 312 #define ND_RA_FLAG_PREFERENCE 0x18 313 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] 314 315 #define nd_ns_type nd_ns_hdr.icmp6_type 316 #define nd_ns_code nd_ns_hdr.icmp6_code 317 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum 318 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] 319 320 #define nd_na_type nd_na_hdr.icmp6_type 321 #define nd_na_code nd_na_hdr.icmp6_code 322 #define nd_na_cksum nd_na_hdr.icmp6_cksum 323 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] 324 325 #if (BYTE_ORDER == _BIG_ENDIAN) 326 #define ND_NA_FLAG_ROUTER 0x80000000 327 #define ND_NA_FLAG_SOLICITED 0x40000000 328 #define ND_NA_FLAG_OVERRIDE 0x20000000 329 #else 330 #define ND_NA_FLAG_ROUTER 0x00000080 331 #define ND_NA_FLAG_SOLICITED 0x00000040 332 #define ND_NA_FLAG_OVERRIDE 0x00000020 333 #endif /* (BYTE_ORDER == _BIG_ENDIAN) */ 334 335 #define nd_rd_type nd_rd_hdr.icmp6_type 336 #define nd_rd_code nd_rd_hdr.icmp6_code 337 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum 338 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] 339 340 #define ND_OPT_PI_FLAG_ONLINK 0x80 341 #define ND_OPT_PI_FLAG_AUTO 0x40 342 #define ND_OPT_PI_FLAG_ROUTER_ADDR 0x20 343 #define ND_OPT_PI_FLAG_SITE_PREFIX 0x10 344 #define ND_OPT_PI_FLAG_ROUTE 0x01 345 346 #define ND_OPT_RI_FLAG_PREFERENCE 0x18 347 348 #define TH_MAX_LEN (0x0F << 2) 349 #define TH_FIN 0x01 350 #define TH_SYN 0x02 351 #define TH_RST 0x04 352 #define TH_PSH 0x08 353 #define TH_ACK 0x10 354 #define TH_URG 0x20 355 #define TH_ECE 0x40 356 #define TH_CWR 0x80 357 #define TH_ALL (TH_FIN | TH_SYN | TH_RST | TH_PSH | TH_ACK | TH_URG | TH_ECE | TH_CWR) 358 #define TH_SYN_ALL (TH_FIN | TH_SYN | TH_RST | TH_ACK) 359 360 #define TH_OPT_EOL 0x00 361 #define TH_OPT_NOP 0x01 362 #define TH_OPT_MSS 0x02 363 #define TH_OPT_WS 0x03 364 #define TH_OPT_SACK_PERMITTED 0x04 365 #define TH_OPT_SACK 0x05 366 #define TH_OPT_TS 0x08 367 368 #define DL_SIZEOF_TUNNEL_ADDRESS(AddressBytes) (FIELD_OFFSET(DL_TUNNEL_ADDRESS, IpAddress) + (AddressBytes)) 369 #define DL_SIZEOF_IPV4_TUNNEL_ADDRESS DL_SIZEOF_TUNNEL_ADDRESS(sizeof(IN_ADDR)) 370 #define DL_SIZEOF_IPV6_TUNNEL_ADDRESS DL_SIZEOF_TUNNEL_ADDRESS(sizeof(IN6_ADDR)) 371 372 #define FL_PACKET_TYPE_FLAGS (NDIS_PACKET_TYPE_ALL_MULTICAST | NDIS_PACKET_TYPE_PROMISCUOUS) 373 374 #define mld_type IcmpHeader.Type 375 #define mld_checksum IcmpHeader.Checksum 376 377 #ifndef _DEFINE_DL_ADDRESS_TYPE_ 378 #define _DEFINE_DL_ADDRESS_TYPE_ 379 typedef enum { 380 DlUnicast, 381 DlMulticast, 382 DlBroadcast 383 } DL_ADDRESS_TYPE, *PDL_ADDRESS_TYPE; 384 #endif 385 386 union _DL_OUI { 387 UINT8 Byte[3]; 388 struct { 389 UINT8 Group:1; 390 UINT8 Local:1; 391 }; 392 }; 393 typedef union _DL_OUI DL_OUI, *PDL_OUI; 394 395 union _DL_EI48 { 396 UINT8 Byte[3]; 397 }; 398 typedef union _DL_EI48 DL_EI48, *PDL_EI48; 399 400 union _DL_EUI48 { 401 UINT8 Byte[6]; 402 struct { 403 DL_OUI Oui; 404 DL_EI48 Ei48; 405 }; 406 }; 407 408 C_ASSERT(DL_ADDRESS_LENGTH_MAXIMUM >= sizeof(DL_EUI48)); 409 410 extern CONST DL_EUI48 eui48_broadcast; 411 412 union _DL_EI64 { 413 UINT8 Byte[5]; 414 }; 415 typedef union _DL_EI64 DL_EI64, *PDL_EI64; 416 417 union _DL_EUI64 { 418 UINT8 Byte[8]; 419 UINT64 Value; 420 struct { 421 DL_OUI Oui; 422 union { 423 DL_EI64 Ei64; 424 struct { 425 UINT8 Type; 426 UINT8 Tse; 427 DL_EI48 Ei48; 428 }; 429 }; 430 }; 431 }; 432 typedef union _DL_EUI64 DL_EUI64, *PDL_EUI64; 433 434 typedef struct _SNAP_HEADER { 435 UINT8 Dsap; 436 UINT8 Ssap; 437 UINT8 Control; 438 UINT8 Oui[3]; 439 UINT16 Type; 440 } SNAP_HEADER, *PSNAP_HEADER; 441 442 typedef struct _ETHERNET_HEADER { 443 DL_EUI48 Destination; 444 DL_EUI48 Source; 445 union { 446 UINT16 Type; 447 UINT16 Length; 448 }; 449 } ETHERNET_HEADER, *PETHERNET_HEADER; 450 451 C_ASSERT(ETH_LENGTH_OF_HEADER == sizeof(ETHERNET_HEADER)); 452 C_ASSERT(ETH_LENGTH_OF_SNAP_HEADER == sizeof(SNAP_HEADER)); 453 454 typedef struct _VLAN_TAG { 455 union { 456 UINT16 Tag; 457 struct { 458 UINT16 VID:12; 459 UINT16 CFI:1; 460 UINT16 User_Priority:3; 461 }; 462 }; 463 UINT16 Type; 464 } VLAN_TAG; 465 466 C_ASSERT(ETH_LENGTH_OF_VLAN_HEADER == sizeof(VLAN_TAG)); 467 468 NETIO_INLINE 469 DL_ADDRESS_TYPE 470 EthernetAddressType( 471 _In_reads_(sizeof(DL_EUI48)) CONST UCHAR *Address) 472 { 473 if (((PDL_EUI48) Address)->Oui.Group) 474 { 475 if (RtlEqualMemory(Address, &eui48_broadcast, sizeof(DL_EUI48))) 476 { 477 return DlBroadcast; 478 } 479 return DlMulticast; 480 } 481 else 482 { 483 return DlUnicast; 484 } 485 } 486 487 typedef struct _TOKENRING_HEADER { 488 UINT8 AcccessControl; 489 UINT8 FrameControl; 490 DL_EUI48 Destination; 491 DL_EUI48 Source; 492 } TOKENRING_HEADER, *PTOKENRING_HEADER; 493 494 typedef struct _SOURCEROUTE_HEADER { 495 union { 496 struct { 497 UINT8 Length:5; 498 UINT8 BroadcastIndicator:3; 499 }; 500 UINT8 Bil; 501 }; 502 union { 503 struct { 504 UINT8 Direction:1; 505 UINT8 LargestFrame:4; 506 UINT8 Reserved:3; 507 }; 508 UINT8 Dlf; 509 }; 510 UINT16 Rd[0]; 511 } SOURCEROUTE_HEADER, *PSOURCEROUTE_HEADER; 512 513 typedef enum { 514 TokenRingSpecificallyRoutedFrame = 0, 515 TokenRingAllRoutesExplorer = 4, 516 TokenRingSpanningTreeExplorer = 6, 517 } TOKENRING_BROADCAST_INDICATOR, *PTOKENRING_BROADCAST_INDICATOR; 518 519 extern CONST SOURCEROUTE_HEADER sourceroute_unspecified; 520 521 C_ASSERT((sizeof(TOKENRING_HEADER) + sizeof(SNAP_HEADER) + SOURCEROUTE_SIZE_MAXIMUM) < DL_HEADER_LENGTH_MAXIMUM); 522 523 __inline 524 BOOLEAN 525 TokenRingGetSourceRouteIndicator( 526 _In_ CONST UNALIGNED DL_EUI48 *Source) 527 { 528 return ((Source->Byte[0] & TOKENRING_SOURCEROUTE_INDICATOR) != 0); 529 } 530 531 __inline 532 VOID 533 TokenRingSetSourceRouteIndicator( 534 _Out_ UNALIGNED DL_EUI48 *Source) 535 { 536 Source->Byte[0] |= TOKENRING_SOURCEROUTE_INDICATOR; 537 } 538 539 __inline 540 VOID 541 TokenRingResetSourceRouteIndicator( 542 _Out_ UNALIGNED DL_EUI48 *Source) 543 { 544 Source->Byte[0] &= ~TOKENRING_SOURCEROUTE_INDICATOR; 545 } 546 547 NETIO_INLINE 548 DL_ADDRESS_TYPE 549 TokenRingAddressType( 550 _In_ CONST UCHAR *Address) 551 { 552 if (TokenRingGetSourceRouteIndicator((PDL_EUI48) Address)) 553 { 554 if (RtlEqualMemory(Address, &eui48_broadcast, sizeof(DL_EUI48))) 555 { 556 return DlBroadcast; 557 } 558 return DlMulticast; 559 } 560 else 561 { 562 return DlUnicast; 563 } 564 } 565 566 typedef struct _FDDI_HEADER { 567 UINT8 FrameCode; 568 DL_EUI48 Destination; 569 DL_EUI48 Source; 570 } FDDI_HEADER, *PFDDI_HEADER; 571 572 typedef struct _ARCNET_HEADER { 573 UINT8 Source; 574 UINT8 Destination; 575 UINT8 Protocol; 576 } ARCNET_HEADER, *PARCNET_HEADER; 577 578 typedef struct _ICMP_HEADER { 579 UINT8 Type; 580 UINT8 Code; 581 UINT16 Checksum; 582 } ICMP_HEADER, *PICMP_HEADER; 583 584 typedef struct _ICMP_MESSAGE { 585 ICMP_HEADER Header; 586 union { 587 UINT32 Data32[1]; 588 UINT16 Data16[2]; 589 UINT8 Data8[4]; 590 } Data; 591 } ICMP_MESSAGE, *PICMP_MESSAGE; 592 593 typedef ICMP_HEADER ICMPV6_HEADER, *PICMPV6_HEADER; 594 typedef ICMP_MESSAGE ICMPV6_MESSAGE, *PICMPV6_MESSAGE; 595 596 typedef struct _IPV4_HEADER { 597 union { 598 UINT8 VersionAndHeaderLength; 599 struct { 600 UINT8 HeaderLength:4; 601 UINT8 Version:4; 602 }; 603 }; 604 union { 605 UINT8 TypeOfServiceAndEcnField; 606 struct { 607 UINT8 EcnField:2; 608 UINT8 TypeOfService:6; 609 }; 610 }; 611 UINT16 TotalLength; 612 UINT16 Identification; 613 union { 614 UINT16 FlagsAndOffset; 615 struct { 616 UINT16 DontUse1:5; 617 UINT16 MoreFragments:1; 618 UINT16 DontFragment:1; 619 UINT16 Reserved:1; 620 UINT16 DontUse2:8; 621 }; 622 }; 623 UINT8 TimeToLive; 624 UINT8 Protocol; 625 UINT16 HeaderChecksum; 626 IN_ADDR SourceAddress; 627 IN_ADDR DestinationAddress; 628 } IPV4_HEADER, *PIPV4_HEADER; 629 630 C_ASSERT(sizeof(IPV4_HEADER) == 20); 631 632 __inline 633 UCHAR 634 Ip4HeaderLengthInBytes( 635 _In_ CONST UNALIGNED IPV4_HEADER *Header) 636 { 637 return (Header->HeaderLength << 2); 638 } 639 640 #if defined(_NTDDK_) || defined(_NTRTL_) 641 __inline 642 UINT16 643 Ip4FragmentOffset( 644 _In_ CONST UNALIGNED IPV4_HEADER *Header) 645 { 646 return RtlUshortByteSwap(Header->FlagsAndOffset & IP4_OFF_MASK) << 3; 647 } 648 #endif 649 650 typedef struct _IPV4_OPTION_HEADER { 651 union { 652 UINT8 OptionType; 653 struct { 654 UINT8 OptionNumber:5; 655 UINT8 OptionClass:2; 656 UINT8 CopiedFlag:1; 657 }; 658 }; 659 UINT8 OptionLength; 660 } IPV4_OPTION_HEADER, *PIPV4_OPTION_HEADER; 661 662 C_ASSERT(sizeof(IPV4_OPTION_HEADER) == 2); 663 664 #if !defined(IP_EXPORT_INCLUDED) 665 typedef enum { 666 IP_OPT_EOL = 0x00, 667 IP_OPT_NOP = 0x01, 668 IP_OPT_SECURITY = 0x82, 669 IP_OPT_LSRR = 0x83, 670 IP_OPT_TS = 0x44, 671 IP_OPT_RR = 0x07, 672 IP_OPT_SSRR = 0x89, 673 IP_OPT_SID = 0x88, 674 IP_OPT_ROUTER_ALERT = 0x94, 675 IP_OPT_MULTIDEST = 0x95, 676 } IPV4_OPTION_TYPE; 677 #else 678 typedef ULONG IPV4_OPTION_TYPE; 679 #endif 680 681 typedef struct _IPV4_TIMESTAMP_OPTION { 682 #ifdef __cplusplus 683 IPV4_OPTION_HEADER OptionHeader; 684 #else 685 IPV4_OPTION_HEADER; 686 #endif 687 UINT8 Pointer; 688 union { 689 UINT8 FlagsOverflow; 690 struct { 691 UINT8 Flags:4; 692 UINT8 Overflow:4; 693 }; 694 }; 695 } IPV4_TIMESTAMP_OPTION, *PIPV4_TIMESTAMP_OPTION; 696 697 typedef enum { 698 IP_OPTION_TIMESTAMP_ONLY = 0, 699 IP_OPTION_TIMESTAMP_ADDRESS = 1, 700 IP_OPTION_TIMESTAMP_SPECIFIC_ADDRESS = 3 701 } IP_OPTION_TIMESTAMP_FLAGS; 702 703 typedef struct _IPV4_ROUTING_HEADER { 704 #ifdef __cplusplus 705 IPV4_OPTION_HEADER OptionHeader; 706 #else 707 IPV4_OPTION_HEADER; 708 #endif 709 UINT8 Pointer; 710 } IPV4_ROUTING_HEADER, UNALIGNED *PIPV4_ROUTING_HEADER; 711 712 typedef ICMP_HEADER ICMPV4_HEADER, *PICMPV4_HEADER; 713 typedef ICMP_MESSAGE ICMPV4_MESSAGE, *PICMPV4_MESSAGE; 714 715 typedef enum { 716 ICMP4_UNREACH_NET = 0, 717 ICMP4_UNREACH_HOST = 1, 718 ICMP4_UNREACH_PROTOCOL = 2, 719 ICMP4_UNREACH_PORT = 3, 720 ICMP4_UNREACH_FRAG_NEEDED = 4, 721 ICMP4_UNREACH_SOURCEROUTE_FAILED = 5, 722 ICMP4_UNREACH_NET_UNKNOWN = 6, 723 ICMP4_UNREACH_HOST_UNKNOWN = 7, 724 ICMP4_UNREACH_ISOLATED = 8, 725 ICMP4_UNREACH_NET_ADMIN = 9, 726 ICMP4_UNREACH_HOST_ADMIN = 10, 727 ICMP4_UNREACH_NET_TOS = 11, 728 ICMP4_UNREACH_HOST_TOS = 12, 729 ICMP4_UNREACH_ADMIN = 13, 730 } ICMP4_UNREACH_CODE, *PICMP4_UNREACH_CODE; 731 732 typedef enum { 733 ICMP4_TIME_EXCEED_TRANSIT = 0, 734 ICMP4_TIME_EXCEED_REASSEMBLY = 1, 735 } ICMP4_TIME_EXCEED_CODE, *PICMP4_TIME_EXCEED_CODE; 736 737 typedef struct _ICMPV4_ROUTER_SOLICIT { 738 ICMPV4_MESSAGE RsHeader; 739 } ICMPV4_ROUTER_SOLICIT, *PICMPV4_ROUTER_SOLICIT; 740 741 typedef struct _ICMPV4_ROUTER_ADVERT_HEADER { 742 ICMPV4_MESSAGE RaHeader; 743 } ICMPV4_ROUTER_ADVERT_HEADER, *PICMPV4_ROUTER_ADVERT_HEADER; 744 745 typedef struct _ICMPV4_ROUTER_ADVERT_ENTRY { 746 IN_ADDR RouterAdvertAddr; 747 LONG PreferenceLevel; 748 } ICMPV4_ROUTER_ADVERT_ENTRY, *PICMPV4_ROUTER_ADVERT_ENTRY; 749 750 typedef struct _ICMPV4_TIMESTAMP_MESSAGE { 751 ICMPV4_MESSAGE Header; 752 UINT32 OriginateTimestamp; 753 UINT32 ReceiveTimestamp; 754 UINT32 TransmitTimestamp; 755 } ICMPV4_TIMESTAMP_MESSAGE, *PICMPV4_TIMESTAMP_MESSAGE; 756 757 typedef struct _ICMPV4_ADDRESS_MASK_MESSAGE { 758 ICMPV4_MESSAGE Header; 759 UINT32 AddressMask; 760 } ICMPV4_ADDRESS_MASK_MESSAGE, *PICMPV4_ADDRESS_MASK_MESSAGE; 761 762 typedef struct _ARP_HEADER { 763 USHORT HardwareAddressSpace; 764 USHORT ProtocolAddressSpace; 765 UCHAR HardwareAddressLength; 766 UCHAR ProtocolAddressLength; 767 USHORT Opcode; 768 UCHAR SenderHardwareAddress[0]; 769 } ARP_HEADER, *PARP_HEADER; 770 771 typedef enum { 772 ARP_REQUEST = 1, 773 ARP_RESPONSE = 2 774 } ARP_OPCODE; 775 776 typedef enum { 777 ARP_HW_ENET = 1, 778 ARP_HW_802 = 6 779 } ARP_HARDWARE_TYPE; 780 781 typedef struct _IGMP_HEADER { 782 union { 783 struct { 784 UINT8 Type:4; 785 UINT8 Version:4; 786 }; 787 UINT8 VersionType; 788 }; 789 union { 790 UINT8 Reserved; 791 UINT8 MaxRespTime; 792 UINT8 Code; 793 }; 794 UINT16 Checksum; 795 IN_ADDR MulticastAddress; 796 } IGMP_HEADER, *PIGMP_HEADER; 797 798 typedef enum { 799 IGMP_MAX_RESP_CODE_TYPE_NORMAL = 0, 800 IGMP_MAX_RESP_CODE_TYPE_FLOAT 801 } IGMP_MAX_RESP_CODE_TYPE; 802 803 typedef struct _IGMPV3_QUERY_HEADER { 804 UINT8 Type; 805 union { 806 UINT8 MaxRespCode; 807 struct { 808 UINT8 MaxRespCodeMantissa:4; 809 UINT8 MaxRespCodeExponent:3; 810 UINT8 MaxRespCodeType:1; 811 }; 812 }; 813 UINT16 Checksum; 814 IN_ADDR MulticastAddress; 815 UINT8 QuerierRobustnessVariable:3; 816 UINT8 SuppressRouterSideProcessing:1; 817 UINT8 Reserved:4; 818 union { 819 UINT8 QueriersQueryInterfaceCode; 820 struct { 821 UINT8 QQCMantissa:4; 822 UINT8 QQCExponent:3; 823 UINT8 QQCType:1; 824 }; 825 }; 826 UINT16 SourceCount; 827 } IGMPV3_QUERY_HEADER, *PIGMPV3_QUERY_HEADER; 828 829 typedef struct _IGMPV3_REPORT_RECORD_HEADER { 830 UINT8 Type; 831 UINT8 AuxillaryDataLength; 832 UINT16 SourceCount; 833 IN_ADDR MulticastAddress; 834 } IGMPV3_REPORT_RECORD_HEADER, *PIGMPV3_REPORT_RECORD_HEADER; 835 836 typedef struct _IGMPV3_REPORT_HEADER_ { 837 UINT8 Type; 838 UINT8 Reserved; 839 UINT16 Checksum; 840 UINT16 Reserved2; 841 UINT16 RecordCount; 842 } IGMPV3_REPORT_HEADER, *PIGMPV3_REPORT_HEADER; 843 844 typedef struct _IPV6_HEADER { 845 UINT32 VersionClassFlow; 846 UINT16 PayloadLength; 847 UINT8 NextHeader; 848 UINT8 HopLimit; 849 IN6_ADDR SourceAddress; 850 IN6_ADDR DestinationAddress; 851 } IPV6_HEADER, *PIPV6_HEADER; 852 853 typedef struct _IPV6_FRAGMENT_HEADER { 854 UINT8 NextHeader; 855 UINT8 Reserved; 856 union { 857 struct { 858 UINT16 DontUse1:8; 859 UINT16 MoreFragments:1; 860 UINT16 ReservedBits:2; 861 UINT16 DontUse2:5; 862 }; 863 UINT16 OffsetAndFlags; 864 }; 865 UINT32 Id; 866 } IPV6_FRAGMENT_HEADER, *PIPV6_FRAGMENT_HEADER; 867 868 C_ASSERT(sizeof(IPV6_FRAGMENT_HEADER) == 8); 869 870 #if defined(_NTDDK_) || defined(_NTRTL_) 871 __inline 872 UINT16 873 Ip6FragmentOffset( 874 _In_ CONST UNALIGNED IPV6_FRAGMENT_HEADER *Header) 875 { 876 return RtlUshortByteSwap(Header->OffsetAndFlags & IP6F_OFF_MASK); 877 } 878 #endif 879 880 typedef struct _IPV6_EXTENSION_HEADER { 881 UINT8 NextHeader; 882 UINT8 Length; 883 } IPV6_EXTENSION_HEADER, *PIPV6_EXTENSION_HEADER; 884 885 typedef struct _IPV6_OPTION_HEADER { 886 UINT8 Type; 887 UINT8 DataLength; 888 } IPV6_OPTION_HEADER, *PIPV6_OPTION_HEADER; 889 890 typedef enum { 891 IP6OPT_PAD1 = 0x00, 892 IP6OPT_PADN = 0x01, 893 IP6OPT_TUNNEL_LIMIT = 0x04, 894 IP6OPT_ROUTER_ALERT = 0x05, 895 IP6OPT_JUMBO = 0xc2, 896 IP6OPT_NSAP_ADDR = 0xc3, 897 } IPV6_OPTION_TYPE, *PIPV6_OPTION_TYPE; 898 899 typedef struct _IPV6_OPTION_JUMBOGRAM { 900 IPV6_OPTION_HEADER Header; 901 UINT8 JumbogramLength[4]; 902 } IPV6_OPTION_JUMBOGRAM, *PIPV6_OPTION_JUMBOGRAM; 903 904 typedef struct _IPV6_OPTION_ROUTER_ALERT { 905 IPV6_OPTION_HEADER Header; 906 UINT8 Value[2]; 907 } IPV6_OPTION_ROUTER_ALERT, *PIPV6_OPTION_ROUTER_ALERT; 908 909 typedef _Struct_size_bytes_(_Inexpressible_(Length)) struct _IPV6_ROUTING_HEADER { 910 UCHAR NextHeader; 911 UCHAR Length; 912 UCHAR RoutingType; 913 UCHAR SegmentsLeft; 914 UCHAR Reserved[4]; 915 } IPV6_ROUTING_HEADER, *PIPV6_ROUTING_HEADER; 916 917 typedef struct nd_router_solicit { 918 ICMPV6_MESSAGE nd_rs_hdr; 919 } ND_ROUTER_SOLICIT_HEADER, *PND_ROUTER_SOLICIT_HEADER; 920 921 typedef struct nd_router_advert { 922 ICMPV6_MESSAGE nd_ra_hdr; 923 UINT32 nd_ra_reachable; 924 UINT32 nd_ra_retransmit; 925 } ND_ROUTER_ADVERT_HEADER, *PND_ROUTER_ADVERT_HEADER; 926 927 typedef union _IPV6_ROUTER_ADVERTISEMENT_FLAGS { 928 struct { 929 UINT8 Reserved:3; 930 UINT8 Preference:2; 931 UINT8 HomeAgent:1; 932 UINT8 OtherStatefulConfiguration:1; 933 UINT8 ManagedAddressConfiguration:1; 934 }; 935 UINT8 Value; 936 } IPV6_ROUTER_ADVERTISEMENT_FLAGS, *PIPV6_ROUTER_ADVERTISEMENT_FLAGS; 937 938 typedef struct nd_neighbor_solicit { 939 ICMPV6_MESSAGE nd_ns_hdr; 940 IN6_ADDR nd_ns_target; 941 } ND_NEIGHBOR_SOLICIT_HEADER, *PND_NEIGHBOR_SOLICIT_HEADER; 942 943 typedef struct nd_neighbor_advert { 944 ICMPV6_MESSAGE nd_na_hdr; 945 IN6_ADDR nd_na_target; 946 } ND_NEIGHBOR_ADVERT_HEADER, *PND_NEIGHBOR_ADVERT_HEADER; 947 948 typedef union _IPV6_NEIGHBOR_ADVERTISEMENT_FLAGS { 949 struct { 950 UINT8 Reserved1:5; 951 UINT8 Override:1; 952 UINT8 Solicited:1; 953 UINT8 Router:1; 954 UINT8 Reserved2[3]; 955 }; 956 UINT32 Value; 957 } IPV6_NEIGHBOR_ADVERTISEMENT_FLAGS, *PIPV6_NEIGHBOR_ADVERTISEMENT_FLAGS; 958 959 typedef struct nd_redirect { 960 ICMPV6_MESSAGE nd_rd_hdr; 961 IN6_ADDR nd_rd_target; 962 IN6_ADDR nd_rd_dst; 963 } ND_REDIRECT_HEADER, *PND_REDIRECT_HEADER; 964 965 typedef struct nd_opt_hdr { 966 UINT8 nd_opt_type; 967 UINT8 nd_opt_len; 968 } ND_OPTION_HDR, *PND_OPTION_HDR; 969 970 typedef enum { 971 ND_OPT_SOURCE_LINKADDR = 1, 972 ND_OPT_TARGET_LINKADDR = 2, 973 ND_OPT_PREFIX_INFORMATION = 3, 974 ND_OPT_REDIRECTED_HEADER = 4, 975 ND_OPT_MTU = 5, 976 ND_OPT_NBMA_SHORTCUT_LIMIT = 6, 977 ND_OPT_ADVERTISEMENT_INTERVAL = 7, 978 ND_OPT_HOME_AGENT_INFORMATION = 8, 979 ND_OPT_SOURCE_ADDR_LIST = 9, 980 ND_OPT_TARGET_ADDR_LIST = 10, 981 ND_OPT_ROUTE_INFO = 24, 982 } ND_OPTION_TYPE, *PND_OPTION_TYPE; 983 984 typedef struct nd_opt_prefix_info { 985 UINT8 nd_opt_pi_type; 986 UINT8 nd_opt_pi_len; 987 UINT8 nd_opt_pi_prefix_len; 988 union { 989 UINT8 nd_opt_pi_flags_reserved; 990 struct { 991 UINT8 Route : 1; // Least significant bit. 992 UINT8 Reserved1 : 3; 993 UINT8 SitePrefix : 1; 994 UINT8 RouterAddress : 1; 995 UINT8 Autonomous : 1; 996 UINT8 OnLink : 1; 997 } Flags; 998 }; 999 UINT32 nd_opt_pi_valid_time; 1000 UINT32 nd_opt_pi_preferred_time; 1001 union { 1002 UINT32 nd_opt_pi_reserved2; 1003 struct { 1004 UINT8 nd_opt_pi_reserved3[3]; 1005 UINT8 nd_opt_pi_site_prefix_len; 1006 }; 1007 }; 1008 IN6_ADDR nd_opt_pi_prefix; 1009 } ND_OPTION_PREFIX_INFO, *PND_OPTION_PREFIX_INFO; 1010 1011 typedef struct nd_opt_rd_hdr { 1012 UINT8 nd_opt_rh_type; 1013 UINT8 nd_opt_rh_len; 1014 UINT16 nd_opt_rh_reserved1; 1015 UINT32 nd_opt_rh_reserved2; 1016 } ND_OPTION_RD_HDR, *PND_OPTION_RD_HDR; 1017 1018 typedef struct nd_opt_mtu { 1019 UINT8 nd_opt_mtu_type; 1020 UINT8 nd_opt_mtu_len; 1021 UINT16 nd_opt_mtu_reserved; 1022 UINT32 nd_opt_mtu_mtu; 1023 } ND_OPTION_MTU, *PND_OPTION_MTU; 1024 1025 typedef struct nd_opt_route_info { 1026 UINT8 nd_opt_ri_type; 1027 UINT8 nd_opt_ri_len; 1028 UINT8 nd_opt_ri_prefix_len; 1029 union { 1030 UINT8 nd_opt_ri_flags_reserved; 1031 struct { 1032 UINT8 Reserved:3; 1033 UINT8 Preference:2; 1034 } Flags; 1035 }; 1036 UINT32 nd_opt_ri_route_lifetime; 1037 IN6_ADDR nd_opt_ri_prefix; 1038 } ND_OPTION_ROUTE_INFO, *PND_OPTION_ROUTE_INFO; 1039 1040 typedef struct _MLD_HEADER { 1041 ICMPV6_HEADER IcmpHeader; 1042 UINT16 MaxRespTime; 1043 UINT16 Reserved; 1044 IN6_ADDR MulticastAddress; 1045 } MLD_HEADER, *PMLD_HEADER; 1046 1047 typedef enum { 1048 MLD_MAX_RESP_CODE_TYPE_NORMAL = 0, 1049 MLD_MAX_RESP_CODE_TYPE_FLOAT 1050 } MLD_MAX_RESP_CODE_TYPE; 1051 1052 typedef struct _MLDV2_QUERY_HEADER { 1053 ICMPV6_HEADER IcmpHeader; 1054 union { 1055 UINT16 MaxRespCode; 1056 struct { 1057 UINT16 MaxRespCodeMantissaHi:4; 1058 UINT16 MaxRespCodeExponent:3; 1059 UINT16 MaxRespCodeType:1; 1060 UINT16 MaxRespCodeMantissaLo:8; 1061 }; 1062 }; 1063 UINT16 Reserved; 1064 IN6_ADDR MulticastAddress; 1065 UINT8 QuerierRobustnessVariable:3; 1066 UINT8 SuppressRouterSideProcessing:1; 1067 UINT8 QueryReserved:4; 1068 union { 1069 UINT8 QueriersQueryInterfaceCode; 1070 struct { 1071 UINT8 QQCMantissa:4; 1072 UINT8 QQCExponent:3; 1073 UINT8 QQCType:1; 1074 }; 1075 }; 1076 UINT16 SourceCount; 1077 } MLDV2_QUERY_HEADER, *PMLDV2_QUERY_HEADER; 1078 1079 typedef struct _MLDV2_REPORT_RECORD_HEADER { 1080 UINT8 Type; 1081 UINT8 AuxillaryDataLength; 1082 UINT16 SourceCount; 1083 IN6_ADDR MulticastAddress; 1084 } MLDV2_REPORT_RECORD_HEADER, *PMLDV2_REPORT_RECORD_HEADER; 1085 1086 typedef struct _MLDV2_REPORT_HEADER { 1087 ICMPV6_HEADER IcmpHeader; 1088 UINT16 Reserved; 1089 UINT16 RecordCount; 1090 } MLDV2_REPORT_HEADER, *PMLDV2_REPORT_HEADER; 1091 1092 typedef UINT32 SEQ_NUM, *PSEQ_NUM; 1093 1094 #pragma pack(push, 1) 1095 1096 typedef struct tcp_hdr { 1097 UINT16 th_sport; 1098 UINT16 th_dport; 1099 SEQ_NUM th_seq; 1100 SEQ_NUM th_ack; 1101 UINT8 th_x2:4; 1102 UINT8 th_len:4; 1103 UINT8 th_flags; 1104 UINT16 th_win; 1105 UINT16 th_sum; 1106 UINT16 th_urp; 1107 } TCP_HDR; 1108 #if NDIS_RECEIVE_UNALIGNED 1109 typedef TCP_HDR UNALIGNED *PTCP_HDR; 1110 #else 1111 typedef TCP_HDR *PTCP_HDR; 1112 #endif 1113 1114 typedef struct tcp_opt_mss { 1115 UINT8 Kind; 1116 UINT8 Length; 1117 UINT16 Mss; 1118 } TCP_OPT_MSS; 1119 1120 typedef struct tcp_opt_ws { 1121 UINT8 Kind; 1122 UINT8 Length; 1123 UINT8 ShiftCnt; 1124 } TCP_OPT_WS; 1125 1126 typedef struct tcp_opt_sack_permitted { 1127 UINT8 Kind; 1128 UINT8 Length; 1129 } TCP_OPT_SACK_PERMITTED; 1130 1131 typedef struct tcp_opt_sack { 1132 UINT8 Kind; 1133 UINT8 Length; 1134 struct tcp_opt_sack_block { 1135 SEQ_NUM Left; 1136 SEQ_NUM Right; 1137 } Block[0]; 1138 } TCP_OPT_SACK; 1139 1140 typedef struct tcp_opt_ts { 1141 UINT8 Kind; 1142 UINT8 Length; 1143 UINT32 Val; 1144 UINT32 EcR; 1145 } TCP_OPT_TS; 1146 1147 typedef struct tcp_opt_unknown { 1148 UINT8 Kind; 1149 UINT8 Length; 1150 } TCP_OPT_UNKNOWN; 1151 1152 #pragma pack(pop) 1153 1154 typedef struct DL_TUNNEL_ADDRESS { 1155 COMPARTMENT_ID CompartmentId; 1156 SCOPE_ID ScopeId; 1157 UCHAR IpAddress[0]; 1158 } DL_TUNNEL_ADDRESS, *PDL_TUNNEL_ADDRESS; 1159 1160 C_ASSERT(DL_ADDRESS_LENGTH_MAXIMUM >= DL_SIZEOF_IPV4_TUNNEL_ADDRESS); 1161 C_ASSERT(DL_ADDRESS_LENGTH_MAXIMUM >= DL_SIZEOF_IPV6_TUNNEL_ADDRESS); 1162 1163 typedef enum _TUNNEL_SUB_TYPE { 1164 TUNNEL_SUB_TYPE_NONE = 0, 1165 TUNNEL_SUB_TYPE_CP = 1, 1166 TUNNEL_SUB_TYPE_IPTLS = 2 1167 } TUNNEL_SUB_TYPE, *PTUNNEL_SUB_TYPE; 1168 1169 #pragma pack(push, 1) 1170 1171 typedef struct DL_TEREDO_ADDRESS { 1172 UINT8 Reserved[6]; 1173 union { 1174 DL_EUI64 Eui64; 1175 struct { 1176 USHORT Flags; 1177 USHORT MappedPort; 1178 IN_ADDR MappedAddress; 1179 }; 1180 }; 1181 } DL_TEREDO_ADDRESS, *PDL_TEREDO_ADDRESS; 1182 1183 typedef struct _IPTLS_METADATA { 1184 ULONGLONG SequenceNumber; 1185 } IPTLS_METADATA,*PIPTLS_METADATA; 1186 1187 #pragma pack(pop) 1188 1189 C_ASSERT(DL_ADDRESS_LENGTH_MAXIMUM >= sizeof(DL_TEREDO_ADDRESS)); 1190 1191 typedef enum _NPI_MODULEID_TYPE { 1192 MIT_GUID = 1, 1193 MIT_IF_LUID, 1194 } NPI_MODULEID_TYPE; 1195 1196 typedef struct _NPI_MODULEID { 1197 USHORT Length; 1198 NPI_MODULEID_TYPE Type; 1199 #ifdef __midl 1200 [switch_type(NPI_MODULEID_TYPE), switch_is(Type)] 1201 #endif 1202 union { 1203 #ifdef __midl 1204 [case(MIT_GUID)] 1205 #endif 1206 GUID Guid; 1207 #ifdef __midl 1208 [case(MIT_IF_LUID)] 1209 #endif 1210 LUID IfLuid; 1211 #ifdef __midl 1212 [default]; 1213 #endif 1214 }; 1215 } NPI_MODULEID; 1216 typedef CONST NPI_MODULEID *PNPI_MODULEID; 1217 1218 #if !defined(__midl) 1219 __inline 1220 BOOLEAN 1221 NmrIsEqualNpiModuleId( 1222 _In_ PNPI_MODULEID ModuleId1, 1223 _In_ PNPI_MODULEID ModuleId2) 1224 { 1225 if (ModuleId1->Type == ModuleId2->Type) 1226 { 1227 if (ModuleId1->Type == MIT_GUID) 1228 { 1229 #ifdef __cplusplus 1230 return !!InlineIsEqualGUID(ModuleId1->Guid, ModuleId2->Guid); 1231 #else 1232 return (BOOLEAN)InlineIsEqualGUID(&ModuleId1->Guid, 1233 &ModuleId2->Guid); 1234 #endif 1235 } 1236 else if (ModuleId1->Type == MIT_IF_LUID) 1237 { 1238 return (BOOLEAN)RtlEqualMemory(&ModuleId1->IfLuid, 1239 &ModuleId2->IfLuid, 1240 sizeof(LUID)); 1241 } 1242 } 1243 return FALSE; 1244 } 1245 #endif 1246 1247 typedef GUID NPIID; 1248 typedef CONST NPIID *PNPIID; 1249 1250 extern CONST NPI_MODULEID NPI_MS_NMR_MODULEID; 1251 extern CONST NPIID NPI_FRAMING_LAYER_ID; 1252 extern CONST NPI_MODULEID NPI_MS_TUN_MODULEID; 1253 extern CONST NPI_MODULEID NPI_MS_FL48_MODULEID; 1254 extern CONST NPI_MODULEID NPI_MS_FL68_MODULEID; 1255 extern CONST NPI_MODULEID NPI_MS_FL4L_MODULEID; 1256 extern CONST NPI_MODULEID NPI_MS_FL6L_MODULEID; 1257 extern CONST NPI_MODULEID NPI_MS_FL4T_MODULEID; 1258 extern CONST NPI_MODULEID NPI_MS_FL6T_MODULEID; 1259 extern CONST NPI_MODULEID NPI_MS_WANARPV4_MODULEID; 1260 extern CONST NPI_MODULEID NPI_MS_WANARPV6_MODULEID; 1261 extern CONST NPI_MODULEID NPI_MS_FL_WANARP_MODULEID; 1262 extern CONST NPI_MODULEID NPI_MS_NDIS_MODULEID; 1263 extern CONST NPIID NPI_NETWORK_LAYER_ID; 1264 extern CONST NPI_MODULEID NPI_MS_IPV6_MODULEID; 1265 extern CONST NPI_MODULEID NPI_MS_IPV4_MODULEID; 1266 1267 #ifdef NETIODEF_DEFINED_ASSERT 1268 #undef ASSERT 1269 #endif 1270 1271 #ifdef __cplusplus 1272 } 1273 #endif 1274 1275 #endif /* _NETIODEF_ */ 1276