Changeset 10961 in vbox
- Timestamp:
- Jul 29, 2008 10:12:17 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp
r10924 r10961 38 38 #include <iprt/time.h> 39 39 #include <iprt/handletable.h> 40 #include <iprt/net.h> 40 41 41 42 … … 61 62 typedef INTNETADDRTYPE *PINTNETADDRTYPE; 62 63 63 /**64 * IPv4 address.65 */66 typedef RTUINT32U INTNETADDRIPV4;67 /** Pointer to a IPv4 address. */68 typedef INTNETADDRIPV4 *PINTNETADDRIPV4;69 /** Pointer to a const IPv4 address. */70 typedef INTNETADDRIPV4 const *PCINTNETADDRIPV4;71 72 /**73 * IPv6 address.74 */75 typedef RTUINT128U INTNETADDRIPV6;76 /** Pointer to a IPv4 address. */77 typedef INTNETADDRIPV6 *PINTNETADDRIPV6;78 /** Pointer to a const IPv4 address. */79 typedef INTNETADDRIPV6 const *PCINTNETADDRIPV6;80 81 /**82 * IPX address.83 */84 typedef struct INTNETADDRIPX85 {86 /** The network ID. */87 uint32_t Network;88 /** The node ID. (Defaults to the MAC address apparently.) */89 PDMMAC Node;90 } INTNETADDRIPX;91 /** Pointer to an IPX address. */92 typedef INTNETADDRIPX *PINTNETADDRIPX;93 /** Pointer to a const IPX address. */94 typedef INTNETADDRIPX const *PCINTNETADDRIPX;95 96 /**97 * Address union.98 */99 typedef union INTNETADDRU100 {101 /** 64-bit view. */102 uint64_t au64[2];103 /** 32-bit view. */104 uint32_t au32[4];105 /** 16-bit view. */106 uint16_t au16[8];107 /** 8-bit view. */108 uint8_t au8[16];109 /** IPv4 view. */110 INTNETADDRIPV4 IPv4;111 /** IPv6 view. */112 INTNETADDRIPV6 IPv6;113 /** IPX view. */114 INTNETADDRIPX Ipx;115 } INTNETADDRU;116 /** Pointer to an address union. */117 typedef INTNETADDRU *PINTNETADDRU;118 /** Pointer to a const address union. */119 typedef INTNETADDRU const *PCINTNETADDRU;120 64 121 65 /** … … 127 71 INTNETADDRTYPE enmType; 128 72 /** The address. */ 129 INTNETADDRU Addr;73 RTNETADDRU Addr; 130 74 } INTNETADDR; 131 75 /** Pointer to an address. */ … … 293 237 294 238 295 /**296 * Ethernet header.297 */298 239 #pragma pack(1) 299 typedef struct INTNETETHERHDR 300 { 301 PDMMAC MacDst; 302 PDMMAC MacSrc; 303 uint16_t EtherType; 304 } INTNETETHERHDR; 305 #pragma pack() 306 /** Pointer to an ethernet header. */ 307 typedef INTNETETHERHDR *PINTNETETHERHDR; 308 /** Pointer to a const ethernet header. */ 309 typedef INTNETETHERHDR const *PCINTNETETHERHDR; 310 311 /** @name EtherType 312 * @{ */ 313 #define INTNET_ETHERTYPE_IPV4 UINT16_C(0x0800) 314 #define INTNET_ETHERTYPE_ARP UINT16_C(0x0806) 315 #define INTNET_ETHERTYPE_IPV6 UINT16_C(0x86dd) 316 /** @} */ 317 318 319 #pragma pack(1) 320 typedef struct INTNETIPV4 321 { 322 #ifdef RT_BIG_ENDIAN 323 unsigned int ip_v : 4; 324 unsigned int ip_hl : 4; 325 unsigned int ip_tos : 8; 326 unsigned int ip_len : 16; 327 #else 328 unsigned int ip_hl : 4; 329 unsigned int ip_v : 4; 330 unsigned int ip_tos : 8; 331 unsigned int ip_len : 16; 332 #endif 333 uint16_t ip_id; 334 uint16_t ip_off; 335 uint8_t ip_ttl; 336 uint8_t ip_p; 337 uint16_t ip_sum; 338 uint32_t ip_src; 339 uint32_t ip_dst; 340 /* more */ 341 uint32_t ip_options[1]; 342 } INTNETIPV4; 343 typedef INTNETIPV4 *PINTNETIPV4; 344 typedef INTNETIPV4 const *PCINTNETIPV4; 345 346 347 typedef struct INTNETUDPV4 348 { 349 uint16_t uh_sport; 350 uint16_t uh_dport; 351 uint16_t uh_ulen; 352 uint16_t uh_sum; 353 } INTNETUDPV4; 354 typedef INTNETUDPV4 *PINTNETUDPV4; 355 typedef INTNETUDPV4 const *PCINTNETUDPV4; 356 357 358 typedef struct INTNETDHCP 359 { 360 uint8_t Op; 361 uint8_t HType; 362 uint8_t HLen; 363 uint8_t Hops; 364 uint32_t XID; 365 uint16_t Secs; 366 uint16_t Flags; 367 uint32_t CIAddr; 368 uint32_t YIAddr; 369 uint32_t SIAddr; 370 uint32_t GIAddr; 371 uint8_t CHAddr[16]; 372 uint8_t SName[64]; 373 uint8_t File[128]; 374 uint8_t abMagic[4]; 375 uint8_t DhcpOpt; 376 uint8_t DhcpLen; /* 1 */ 377 uint8_t DhcpReq; 378 uint8_t abOptions[57]; 379 } INTNETDHCP; 380 typedef INTNETDHCP *PINTNETDHCP; 381 typedef INTNETDHCP const *PCINTNETDHCP; 382 383 #pragma pack(0) 384 385 /** IPv4: UDP */ 386 #define INTNETIPV4_PROT_UDP 7 387 388 389 /** ARP hardware type - ethernet. */ 390 #define INTNET_ARP_ETHER UINT16_C(1) 391 392 /** @name ARP operations 393 * @{ */ 394 #define INTNET_ARPOP_REQUEST UINT16_C(1) /**< Request hardward address given a protocol address (ARP). */ 395 #define INTNET_ARPOP_REPLY UINT16_C(2) 396 #define INTNET_ARPOP_REVREQUEST UINT16_C(3) /**< Request protocol address given a hardware address (RARP). */ 397 #define INTNET_ARPOP_REVREPLY UINT16_C(4) 398 #define INTNET_ARPOP_INVREQUEST UINT16_C(8) /**< Inverse ARP. */ 399 #define INTNET_ARPOP_INVREPLY UINT16_C(9) 400 #define INTNET_ARPOP_IS_REQUEST(Op) ((Op) & 1) 401 #define INTNET_ARPOP_IS_REPLY(Op) (!INTNET_ARPOP_IS_REQUEST(Op)) 402 /** @} */ 403 404 #pragma pack(1) 405 /** 406 * Ethernet ARP header. 407 */ 408 typedef struct INTNETARPHDR 409 { 410 /** The hardware type. */ 411 uint16_t ar_htype; 412 /** The protocol type (ethertype). */ 413 uint16_t ar_ptype; 414 /** The hardware address length. */ 415 uint8_t ar_hlen; 416 /** The protocol address length. */ 417 uint8_t ar_plen; 418 /** The operation. */ 419 uint16_t ar_oper; 420 } INTNETARPHDR; 421 #pragma pack(0) 422 /** Pointer to an ethernet ARP header. */ 423 typedef INTNETARPHDR *PINTNETARPHDR; 424 /** Pointer to a const ethernet ARP header. */ 425 typedef INTNETARPHDR const *PCINTNETARPHDR; 426 427 428 #pragma pack(1) 429 /** 430 * Ethernet IPv4 + 6-byte MAC ARP request packet. 431 */ 432 typedef struct INTNETARPIPV4 433 { 434 INTNETARPHDR Hdr; 240 /** 241 * Ethernet IPv6 + 6-byte MAC ARP request packet. 242 * 243 * @todo check if this exists and is actually used. 244 */ 245 typedef struct INTNETARPIPV6 246 { 247 RTNETARPHDR Hdr; 435 248 /** The sender hardware address. */ 436 249 PDMMAC ar_sha; 437 250 /** The sender protocol address. */ 438 INTNETADDRIPV4ar_spa;251 RTNETADDRIPV6 ar_spa; 439 252 /** The target hardware address. */ 440 253 PDMMAC ar_tha; 441 254 /** The arget protocol address. */ 442 INTNETADDRIPV4 ar_tpa; 443 } INTNETARPIPV4; 444 #pragma pack(0) 445 /** Pointer to an ethernet IPv4+MAC ARP request packet. */ 446 typedef INTNETARPIPV4 *PINTNETARPIPV4; 447 /** Pointer to a const ethernet IPv4+MAC ARP request packet. */ 448 typedef INTNETARPIPV4 const *PCINTNETARPIPV4; 449 450 451 #pragma pack(1) 452 /** 453 * Ethernet IPv6 + 6-byte MAC ARP request packet. 454 */ 455 typedef struct INTNETARPIPV6 456 { 457 INTNETARPHDR Hdr; 458 /** The sender hardware address. */ 459 PDMMAC ar_sha; 460 /** The sender protocol address. */ 461 INTNETADDRIPV6 ar_spa; 462 /** The target hardware address. */ 463 PDMMAC ar_tha; 464 /** The arget protocol address. */ 465 INTNETADDRIPV6 ar_tpa; 255 RTNETADDRIPV6 ar_tpa; 466 256 } INTNETARPIPV6; 467 257 #pragma pack(0) … … 561 351 * @param cbAddr The address size. 562 352 */ 563 DECLINLINE(bool) intnetR0AddrUIsEqualEx(PC INTNETADDRU pAddr1, PCINTNETADDRU pAddr2, uint8_t const cbAddr)353 DECLINLINE(bool) intnetR0AddrUIsEqualEx(PCRTNETADDRU pAddr1, PCRTNETADDRU pAddr2, uint8_t const cbAddr) 564 354 { 565 355 switch (cbAddr) … … 589 379 * @param cbAddr The address size (optimization). 590 380 */ 591 static int intnetR0IfAddrCacheLookupSlow(PCINTNETADDRCACHE pCache, PC INTNETADDRU pAddr, uint8_t const cbAddr)381 static int intnetR0IfAddrCacheLookupSlow(PCINTNETADDRCACHE pCache, PCRTNETADDRU pAddr, uint8_t const cbAddr) 592 382 { 593 383 unsigned i = pCache->cEntries - 2; … … 595 385 while (i >= 1) 596 386 { 597 if (intnetR0AddrUIsEqualEx((PC INTNETADDRU)pbEntry, pAddr, cbAddr))387 if (intnetR0AddrUIsEqualEx((PCRTNETADDRU)pbEntry, pAddr, cbAddr)) 598 388 return i; 599 389 pbEntry -= pCache->cbEntry; … … 612 402 * @param cbAddr The address size (optimization). 613 403 */ 614 DECLINLINE(int) intnetR0IfAddrCacheLookup(PCINTNETADDRCACHE pCache, PC INTNETADDRU pAddr, uint8_t const cbAddr)404 DECLINLINE(int) intnetR0IfAddrCacheLookup(PCINTNETADDRCACHE pCache, PCRTNETADDRU pAddr, uint8_t const cbAddr) 615 405 { 616 406 Assert(pCache->cbAddress == cbAddr); … … 622 412 unsigned i = pCache->cEntries; 623 413 if ( i > 0 624 && intnetR0AddrUIsEqualEx((PC INTNETADDRU)pCache->pbEntries, pAddr, cbAddr))414 && intnetR0AddrUIsEqualEx((PCRTNETADDRU)pCache->pbEntries, pAddr, cbAddr)) 625 415 return 0; 626 416 if (i <= 1) … … 631 421 */ 632 422 i--; 633 if (intnetR0AddrUIsEqualEx((PC INTNETADDRU)(pCache->pbEntries + pCache->cbEntry * i), pAddr, cbAddr))423 if (intnetR0AddrUIsEqualEx((PCRTNETADDRU)(pCache->pbEntries + pCache->cbEntry * i), pAddr, cbAddr)) 634 424 return i; 635 425 if (i <= 1) … … 639 429 } 640 430 431 641 432 /** Same as intnetR0IfAddrCacheLookup except we expect the address to be present already. */ 642 DECLINLINE(int) intnetR0IfAddrCacheLookupLikely(PCINTNETADDRCACHE pCache, PC INTNETADDRU pAddr, uint8_t const cbAddr)433 DECLINLINE(int) intnetR0IfAddrCacheLookupLikely(PCINTNETADDRCACHE pCache, PCRTNETADDRU pAddr, uint8_t const cbAddr) 643 434 { 644 435 /** @todo implement this. */ … … 659 450 * @param cbAddr The address size (optimization). 660 451 */ 661 static int intnetR0IfAddrCacheInCacheUnlikelySlow(PCINTNETADDRCACHE pCache, PC INTNETADDRU pAddr, uint8_t const cbAddr)452 static int intnetR0IfAddrCacheInCacheUnlikelySlow(PCINTNETADDRCACHE pCache, PCRTNETADDRU pAddr, uint8_t const cbAddr) 662 453 { 663 454 /* … … 668 459 while (i >= 1) 669 460 { 670 if (RT_UNLIKELY(intnetR0AddrUIsEqualEx((PC INTNETADDRU)pbEntry, pAddr, cbAddr)))461 if (RT_UNLIKELY(intnetR0AddrUIsEqualEx((PCRTNETADDRU)pbEntry, pAddr, cbAddr))) 671 462 return i; 672 463 pbEntry -= pCache->cbEntry; … … 686 477 * @param cbAddr The address size (optimization). 687 478 */ 688 DECLINLINE(int) intnetR0IfAddrCacheLookupUnlikely(PCINTNETADDRCACHE pCache, PC INTNETADDRU pAddr, uint8_t const cbAddr)479 DECLINLINE(int) intnetR0IfAddrCacheLookupUnlikely(PCINTNETADDRCACHE pCache, PCRTNETADDRU pAddr, uint8_t const cbAddr) 689 480 { 690 481 Assert(pCache->cbAddress == cbAddr); … … 696 487 unsigned i = pCache->cEntries; 697 488 if (RT_UNLIKELY( i > 0 698 && intnetR0AddrUIsEqualEx((PC INTNETADDRU)pCache->pbEntries, pAddr, cbAddr)))489 && intnetR0AddrUIsEqualEx((PCRTNETADDRU)pCache->pbEntries, pAddr, cbAddr))) 699 490 return 0; 700 491 if (RT_LIKELY(i <= 1)) … … 705 496 */ 706 497 i--; 707 if (RT_UNLIKELY(intnetR0AddrUIsEqualEx((PC INTNETADDRU)(pCache->pbEntries + pCache->cbEntry * i), pAddr, cbAddr)))498 if (RT_UNLIKELY(intnetR0AddrUIsEqualEx((PCRTNETADDRU)(pCache->pbEntries + pCache->cbEntry * i), pAddr, cbAddr))) 708 499 return i; 709 500 if (i <= 1) … … 744 535 * @param cbAddr The address size (optimization). 745 536 */ 746 DECLINLINE(void) intnetR0IfAddrCacheDelete(PINTNETIF pIf, PINTNETADDRCACHE pCache, PC INTNETADDRU pAddr, uint8_t const cbAddr)537 DECLINLINE(void) intnetR0IfAddrCacheDelete(PINTNETIF pIf, PINTNETADDRCACHE pCache, PCRTNETADDRU pAddr, uint8_t const cbAddr) 747 538 { 748 539 int i = intnetR0IfAddrCacheLookup(pCache, pAddr, cbAddr); … … 763 554 * @param cbAddr The address size (optimization). 764 555 */ 765 DECLINLINE(void) intnetR0NetworkAddrCacheDelete(PINTNETNETWORK pNetwork, PC INTNETADDRU pAddr,556 DECLINLINE(void) intnetR0NetworkAddrCacheDelete(PINTNETNETWORK pNetwork, PCRTNETADDRU pAddr, 766 557 INTNETADDRTYPE const enmType, uint8_t const cbAddr) 767 558 { … … 786 577 * @param cbAddr The address size (optimization). 787 578 */ 788 DECLINLINE(void) intnetR0NetworkAddrCacheDeleteMinusIf(PINTNETNETWORK pNetwork, PINTNETIF pIfSender, PC INTNETADDRU pAddr,579 DECLINLINE(void) intnetR0NetworkAddrCacheDeleteMinusIf(PINTNETNETWORK pNetwork, PINTNETIF pIfSender, PCRTNETADDRU pAddr, 789 580 INTNETADDRTYPE const enmType, uint8_t const cbAddr) 790 581 { … … 807 598 * @param pAddr The address. 808 599 */ 809 static void intnetR0IfAddrCacheAddIt(PINTNETIF pIf, PINTNETADDRCACHE pCache, PC INTNETADDRU pAddr)600 static void intnetR0IfAddrCacheAddIt(PINTNETIF pIf, PINTNETADDRCACHE pCache, PCRTNETADDRU pAddr) 810 601 { 811 602 if (!pCache->cEntriesAlloc) … … 861 652 * @param cbAddr The size of the address (optimization). 862 653 */ 863 static void intnetR0IfAddrCacheAddSlow(PINTNETIF pIf, PINTNETADDRCACHE pCache, PC INTNETADDRU pAddr, uint8_t const cbAddr)654 static void intnetR0IfAddrCacheAddSlow(PINTNETIF pIf, PINTNETADDRCACHE pCache, PCRTNETADDRU pAddr, uint8_t const cbAddr) 864 655 { 865 656 /* … … 871 662 while (--cLeft > 1) 872 663 { 873 if (RT_LIKELY(intnetR0AddrUIsEqualEx((PC INTNETADDRU)pbEntry, pAddr, cbAddr)))664 if (RT_LIKELY(intnetR0AddrUIsEqualEx((PCRTNETADDRU)pbEntry, pAddr, cbAddr))) 874 665 { 875 666 /** @todo usage/ageing? */ … … 895 686 * @param cbAddr The size of the address (optimization). 896 687 */ 897 DECLINLINE(void) intnetR0IfAddrCacheAdd(PINTNETIF pIf, PINTNETADDRCACHE pCache, PC INTNETADDRU pAddr, uint8_t const cbAddr)688 DECLINLINE(void) intnetR0IfAddrCacheAdd(PINTNETIF pIf, PINTNETADDRCACHE pCache, PCRTNETADDRU pAddr, uint8_t const cbAddr) 898 689 { 899 690 Assert(pCache->cbAddress == cbAddr); … … 904 695 unsigned i = pCache->cEntries; 905 696 if (RT_LIKELY( i > 0 906 && intnetR0AddrUIsEqualEx((PC INTNETADDRU)pCache->pbEntries, pAddr, cbAddr)))697 && intnetR0AddrUIsEqualEx((PCRTNETADDRU)pCache->pbEntries, pAddr, cbAddr))) 907 698 { 908 699 /** @todo usage/ageing? */ … … 916 707 */ 917 708 i--; 918 if (RT_LIKELY(intnetR0AddrUIsEqualEx((PC INTNETADDRU)pCache->pbEntries, pAddr, cbAddr)))709 if (RT_LIKELY(intnetR0AddrUIsEqualEx((PCRTNETADDRU)pCache->pbEntries, pAddr, cbAddr))) 919 710 { 920 711 /** @todo usage/ageing? */ … … 940 731 * size of the frame without the ethernet header. 941 732 */ 942 static void intnetR0IfSniffIPv4SourceAddr(PINTNETIF pIf, PC INTNETIPV4 pHdr, uint32_t cbPacket)733 static void intnetR0IfSniffIPv4SourceAddr(PINTNETIF pIf, PCRTNETIPV4 pHdr, uint32_t cbPacket) 943 734 { 944 735 /* 945 736 * Check the header size. 946 737 */ 947 if (cbPacket < RT_UOFFSETOF( INTNETIPV4, ip_options)) /** @todo check minimum size requirements here. */738 if (cbPacket < RT_UOFFSETOF(RTNETIPV4, ip_options)) /** @todo check minimum size requirements here. */ 948 739 return; 949 740 uint32_t cbHdr = (uint32_t)pHdr->ip_hl * 4; 950 if ( cbHdr < RT_UOFFSETOF( INTNETIPV4, ip_options)741 if ( cbHdr < RT_UOFFSETOF(RTNETIPV4, ip_options) 951 742 || cbPacket < cbHdr) 952 743 return; … … 955 746 * Ignore 255.255.255.255 (broadcast), 0.0.0.0 (null) and already cached addresses. 956 747 */ 957 INTNETADDRU Addr;748 RTNETADDRU Addr; 958 749 Addr.au32[0] = pHdr->ip_src; 959 750 if (Addr.au32[0] == UINT32_C(0xffffffff)) … … 965 756 { 966 757 #if 0 /** @todo quick DHCP check? */ 967 if (pHdr->ip_p != INTNETIPV4_PROT_UDP)758 if (pHdr->ip_p != RTNETIPV4_PROT_UDP) 968 759 return; 969 760 #endif … … 998 789 * request 'cause of min ethernet frame size). 999 790 */ 1000 static void intnetR0IfSniffArpSourceAddr(PINTNETIF pIf, PC INTNETARPHDR pHdr, uint32_t cbPacket)791 static void intnetR0IfSniffArpSourceAddr(PINTNETIF pIf, PCRTNETARPHDR pHdr, uint32_t cbPacket) 1001 792 { 1002 793 /* … … 1005 796 if (RT_UNLIKELY( cbPacket <= sizeof(*pHdr) 1006 797 || pHdr->ar_hlen != sizeof(PDMMAC) 1007 || pHdr->ar_htype != RT_H2BE_U16( INTNET_ARP_ETHER)1008 || ( pHdr->ar_oper != RT_H2BE_U16( INTNET_ARPOP_REQUEST)1009 && pHdr->ar_oper != RT_H2BE_U16( INTNET_ARPOP_REPLY)1010 && pHdr->ar_oper != RT_H2BE_U16( INTNET_ARPOP_REVREQUEST)1011 && pHdr->ar_oper != RT_H2BE_U16( INTNET_ARPOP_REVREPLY)798 || pHdr->ar_htype != RT_H2BE_U16(RTNET_ARP_ETHER) 799 || ( pHdr->ar_oper != RT_H2BE_U16(RTNET_ARPOP_REQUEST) 800 && pHdr->ar_oper != RT_H2BE_U16(RTNET_ARPOP_REPLY) 801 && pHdr->ar_oper != RT_H2BE_U16(RTNET_ARPOP_REVREQUEST) 802 && pHdr->ar_oper != RT_H2BE_U16(RTNET_ARPOP_REVREPLY) 1012 803 /** @todo Read up on inverse ARP. */ 1013 804 ) … … 1019 810 * Deal with the protocols. 1020 811 */ 1021 INTNETADDRU Addr;1022 if (pHdr->ar_ptype == RT_H2BE_U16( INTNET_ETHERTYPE_IPV4))812 RTNETADDRU Addr; 813 if (pHdr->ar_ptype == RT_H2BE_U16(RTNET_ETHERTYPE_IPV4)) 1023 814 { 1024 815 /* 1025 816 * IPv4. 1026 817 */ 1027 PC INTNETARPIPV4 pReq = (PCINTNETARPIPV4)pHdr;818 PCRTNETARPIPV4 pReq = (PCRTNETARPIPV4)pHdr; 1028 819 if (RT_UNLIKELY( pHdr->ar_plen == sizeof(pReq->ar_spa) 1029 820 || cbPacket < sizeof(*pReq) … … 1032 823 return; 1033 824 1034 if ( INTNET_ARPOP_IS_REPLY(RT_BE2H_U16(pHdr->ar_oper)))825 if (RTNET_ARPOP_IS_REPLY(RT_BE2H_U16(pHdr->ar_oper))) 1035 826 { 1036 827 Addr.IPv4 = pReq->ar_tpa; … … 1040 831 intnetR0IfAddrCacheAdd(pIf, &pIf->aAddrCache[kIntNetAddrType_IPv4], &Addr, sizeof(pReq->ar_spa)); 1041 832 } 1042 else if (pHdr->ar_ptype == RT_H2BE_U16( INTNET_ETHERTYPE_IPV6))833 else if (pHdr->ar_ptype == RT_H2BE_U16(RTNET_ETHERTYPE_IPV6)) 1043 834 { 1044 835 /* … … 1052 843 return; 1053 844 1054 if ( INTNET_ARPOP_IS_REPLY(RT_BE2H_U16(pHdr->ar_oper)))845 if (RTNET_ARPOP_IS_REPLY(RT_BE2H_U16(pHdr->ar_oper))) 1055 846 { 1056 847 Addr.IPv6 = pReq->ar_tpa; … … 1079 870 * Fish out the ethertype and look for stuff we can handle. 1080 871 */ 1081 if (cbFrame <= sizeof( INTNETETHERHDR))872 if (cbFrame <= sizeof(RTNETETHERHDR)) 1082 873 return; 1083 cbFrame -= sizeof( INTNETETHERHDR);1084 1085 uint16_t EtherType = ((PC INTNETETHERHDR)pbFrame)->EtherType;1086 if (EtherType == RT_H2BE_U16( INTNET_ETHERTYPE_IPV4))1087 intnetR0IfSniffIPv4SourceAddr(pIf, (PC INTNETIPV4)((PCINTNETETHERHDR)pbFrame + 1), cbFrame);874 cbFrame -= sizeof(RTNETETHERHDR); 875 876 uint16_t EtherType = ((PCRTNETETHERHDR)pbFrame)->EtherType; 877 if (EtherType == RT_H2BE_U16(RTNET_ETHERTYPE_IPV4)) 878 intnetR0IfSniffIPv4SourceAddr(pIf, (PCRTNETIPV4)((PCRTNETETHERHDR)pbFrame + 1), cbFrame); 1088 879 #if 0 /** @todo IntNet: implement IPv6 for wireless MAC sharing. */ 1089 else if (EtherType == RT_H2BE_U16( INTNET_ETHERTYPE_IPV6))1090 intnetR0IfSniffIPv6SourceAddr(pIf, (PCINTNETIPV6)((PC INTNETETHERHDR)pbFrame + 1), cbFrame);880 else if (EtherType == RT_H2BE_U16(RTNET_ETHERTYPE_IPV6)) 881 intnetR0IfSniffIPv6SourceAddr(pIf, (PCINTNETIPV6)((PCRTNETETHERHDR)pbFrame + 1), cbFrame); 1091 882 #endif 1092 883 #if 0 /** @todo IntNet: implement IPX for wireless MAC sharing? */ … … 1095 886 || EtherType == RT_H2BE_U16(0x8138) //?? 1096 887 ) 1097 intnetR0IfSniffIpxSourceAddr(pIf, (PCINTNETIPX)((PC INTNETETHERHDR)pbFrame + 1), cbFrame);888 intnetR0IfSniffIpxSourceAddr(pIf, (PCINTNETIPX)((PCRTNETETHERHDR)pbFrame + 1), cbFrame); 1098 889 #endif 1099 else if (EtherType == RT_H2BE_U16( INTNET_ETHERTYPE_ARP))1100 intnetR0IfSniffArpSourceAddr(pIf, (PC INTNETARPHDR)((PCINTNETETHERHDR)pbFrame + 1), cbFrame);890 else if (EtherType == RT_H2BE_U16(RTNET_ETHERTYPE_ARP)) 891 intnetR0IfSniffArpSourceAddr(pIf, (PCRTNETARPHDR)((PCRTNETETHERHDR)pbFrame + 1), cbFrame); 1101 892 } 1102 893 … … 1492 1283 * @param pEthHdr Pointer to the ethernet header. 1493 1284 */ 1494 static bool intnetR0NetworkSendMulticast(PINTNETNETWORK pNetwork, PINTNETIF pIfSender, uint32_t fSrc, PINTNETSG pSG, bool fTrunkLocked, PC INTNETETHERHDR pEthHdr)1285 static bool intnetR0NetworkSendMulticast(PINTNETNETWORK pNetwork, PINTNETIF pIfSender, uint32_t fSrc, PINTNETSG pSG, bool fTrunkLocked, PCRTNETETHERHDR pEthHdr) 1495 1286 { 1496 1287 /** @todo implement multicast */ … … 1512 1303 * @param pEthHdr Pointer to the ethernet header. 1513 1304 */ 1514 static bool intnetR0NetworkSendUnicast(PINTNETNETWORK pNetwork, PINTNETIF pIfSender, uint32_t fSrc, PINTNETSG pSG, bool fTrunkLocked, PC INTNETETHERHDR pEthHdr)1305 static bool intnetR0NetworkSendUnicast(PINTNETNETWORK pNetwork, PINTNETIF pIfSender, uint32_t fSrc, PINTNETSG pSG, bool fTrunkLocked, PCRTNETETHERHDR pEthHdr) 1515 1306 { 1516 1307 /* … … 1605 1396 Assert(pSG->cSegsUsed >= 1); 1606 1397 Assert(pSG->cSegsUsed <= pSG->cSegsAlloc); 1607 if (pSG->cbTotal < sizeof( INTNETETHERHDR))1398 if (pSG->cbTotal < sizeof(RTNETETHERHDR)) 1608 1399 return fRc; 1609 1400 … … 1620 1411 * Get the ethernet header (might theoretically involve multiple segments). 1621 1412 */ 1622 INTNETETHERHDR EthHdr;1413 RTNETETHERHDR EthHdr; 1623 1414 if (RT_LIKELY(pSG->aSegs[0].cb >= sizeof(EthHdr))) 1624 EthHdr = *(PC INTNETETHERHDR)pSG->aSegs[0].pv;1415 EthHdr = *(PCRTNETETHERHDR)pSG->aSegs[0].pv; 1625 1416 else 1626 1417 {
Note:
See TracChangeset
for help on using the changeset viewer.