VirtualBox

Changeset 10961 in vbox


Ignore:
Timestamp:
Jul 29, 2008 10:12:17 PM (17 years ago)
Author:
vboxsync
Message:

intnet: Use iprt/net.h and share the network protocol structures and stuff with the rest.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp

    r10924 r10961  
    3838#include <iprt/time.h>
    3939#include <iprt/handletable.h>
     40#include <iprt/net.h>
    4041
    4142
     
    6162typedef INTNETADDRTYPE *PINTNETADDRTYPE;
    6263
    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 INTNETADDRIPX
    85 {
    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 INTNETADDRU
    100 {
    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;
    12064
    12165/**
     
    12771    INTNETADDRTYPE enmType;
    12872    /** The address. */
    129     INTNETADDRU Addr;
     73    RTNETADDRU Addr;
    13074} INTNETADDR;
    13175/** Pointer to an address. */
     
    293237
    294238
    295 /**
    296  * Ethernet header.
    297  */
    298239#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 */
     245typedef struct INTNETARPIPV6
     246{
     247    RTNETARPHDR     Hdr;
    435248    /** The sender hardware address. */
    436249    PDMMAC          ar_sha;
    437250    /** The sender protocol address. */
    438     INTNETADDRIPV4  ar_spa;
     251    RTNETADDRIPV6   ar_spa;
    439252    /** The target hardware address. */
    440253    PDMMAC          ar_tha;
    441254    /** 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;
    466256} INTNETARPIPV6;
    467257#pragma pack(0)
     
    561351 * @param   cbAddr          The address size.
    562352 */
    563 DECLINLINE(bool) intnetR0AddrUIsEqualEx(PCINTNETADDRU pAddr1, PCINTNETADDRU pAddr2, uint8_t const cbAddr)
     353DECLINLINE(bool) intnetR0AddrUIsEqualEx(PCRTNETADDRU pAddr1, PCRTNETADDRU pAddr2, uint8_t const cbAddr)
    564354{
    565355    switch (cbAddr)
     
    589379 * @param   cbAddr      The address size (optimization).
    590380 */
    591 static int intnetR0IfAddrCacheLookupSlow(PCINTNETADDRCACHE pCache, PCINTNETADDRU pAddr, uint8_t const cbAddr)
     381static int intnetR0IfAddrCacheLookupSlow(PCINTNETADDRCACHE pCache, PCRTNETADDRU pAddr, uint8_t const cbAddr)
    592382{
    593383    unsigned i = pCache->cEntries - 2;
     
    595385    while (i >= 1)
    596386    {
    597         if (intnetR0AddrUIsEqualEx((PCINTNETADDRU)pbEntry, pAddr, cbAddr))
     387        if (intnetR0AddrUIsEqualEx((PCRTNETADDRU)pbEntry, pAddr, cbAddr))
    598388            return i;
    599389        pbEntry -= pCache->cbEntry;
     
    612402 * @param   cbAddr          The address size (optimization).
    613403 */
    614 DECLINLINE(int) intnetR0IfAddrCacheLookup(PCINTNETADDRCACHE pCache, PCINTNETADDRU pAddr, uint8_t const cbAddr)
     404DECLINLINE(int) intnetR0IfAddrCacheLookup(PCINTNETADDRCACHE pCache, PCRTNETADDRU pAddr, uint8_t const cbAddr)
    615405{
    616406    Assert(pCache->cbAddress == cbAddr);
     
    622412    unsigned i = pCache->cEntries;
    623413    if (    i > 0
    624         &&  intnetR0AddrUIsEqualEx((PCINTNETADDRU)pCache->pbEntries, pAddr, cbAddr))
     414        &&  intnetR0AddrUIsEqualEx((PCRTNETADDRU)pCache->pbEntries, pAddr, cbAddr))
    625415        return 0;
    626416    if (i <= 1)
     
    631421     */
    632422    i--;
    633     if (intnetR0AddrUIsEqualEx((PCINTNETADDRU)(pCache->pbEntries + pCache->cbEntry * i), pAddr, cbAddr))
     423    if (intnetR0AddrUIsEqualEx((PCRTNETADDRU)(pCache->pbEntries + pCache->cbEntry * i), pAddr, cbAddr))
    634424        return i;
    635425    if (i <= 1)
     
    639429}
    640430
     431
    641432/** Same as intnetR0IfAddrCacheLookup except we expect the address to be present already. */
    642 DECLINLINE(int) intnetR0IfAddrCacheLookupLikely(PCINTNETADDRCACHE pCache, PCINTNETADDRU pAddr, uint8_t const cbAddr)
     433DECLINLINE(int) intnetR0IfAddrCacheLookupLikely(PCINTNETADDRCACHE pCache, PCRTNETADDRU pAddr, uint8_t const cbAddr)
    643434{
    644435    /** @todo implement this. */
     
    659450 * @param   cbAddr      The address size (optimization).
    660451 */
    661 static int intnetR0IfAddrCacheInCacheUnlikelySlow(PCINTNETADDRCACHE pCache, PCINTNETADDRU pAddr, uint8_t const cbAddr)
     452static int intnetR0IfAddrCacheInCacheUnlikelySlow(PCINTNETADDRCACHE pCache, PCRTNETADDRU pAddr, uint8_t const cbAddr)
    662453{
    663454    /*
     
    668459    while (i >= 1)
    669460    {
    670         if (RT_UNLIKELY(intnetR0AddrUIsEqualEx((PCINTNETADDRU)pbEntry, pAddr, cbAddr)))
     461        if (RT_UNLIKELY(intnetR0AddrUIsEqualEx((PCRTNETADDRU)pbEntry, pAddr, cbAddr)))
    671462            return i;
    672463        pbEntry -= pCache->cbEntry;
     
    686477 * @param   cbAddr          The address size (optimization).
    687478 */
    688 DECLINLINE(int) intnetR0IfAddrCacheLookupUnlikely(PCINTNETADDRCACHE pCache, PCINTNETADDRU pAddr, uint8_t const cbAddr)
     479DECLINLINE(int) intnetR0IfAddrCacheLookupUnlikely(PCINTNETADDRCACHE pCache, PCRTNETADDRU pAddr, uint8_t const cbAddr)
    689480{
    690481    Assert(pCache->cbAddress == cbAddr);
     
    696487    unsigned i = pCache->cEntries;
    697488    if (RT_UNLIKELY(   i > 0
    698                     && intnetR0AddrUIsEqualEx((PCINTNETADDRU)pCache->pbEntries, pAddr, cbAddr)))
     489                    && intnetR0AddrUIsEqualEx((PCRTNETADDRU)pCache->pbEntries, pAddr, cbAddr)))
    699490        return 0;
    700491    if (RT_LIKELY(i <= 1))
     
    705496     */
    706497    i--;
    707     if (RT_UNLIKELY(intnetR0AddrUIsEqualEx((PCINTNETADDRU)(pCache->pbEntries + pCache->cbEntry * i), pAddr, cbAddr)))
     498    if (RT_UNLIKELY(intnetR0AddrUIsEqualEx((PCRTNETADDRU)(pCache->pbEntries + pCache->cbEntry * i), pAddr, cbAddr)))
    708499        return i;
    709500    if (i <= 1)
     
    744535 * @param   cbAddr          The address size (optimization).
    745536 */
    746 DECLINLINE(void) intnetR0IfAddrCacheDelete(PINTNETIF pIf, PINTNETADDRCACHE pCache, PCINTNETADDRU pAddr, uint8_t const cbAddr)
     537DECLINLINE(void) intnetR0IfAddrCacheDelete(PINTNETIF pIf, PINTNETADDRCACHE pCache, PCRTNETADDRU pAddr, uint8_t const cbAddr)
    747538{
    748539    int i = intnetR0IfAddrCacheLookup(pCache, pAddr, cbAddr);
     
    763554 * @param   cbAddr          The address size (optimization).
    764555 */
    765 DECLINLINE(void) intnetR0NetworkAddrCacheDelete(PINTNETNETWORK pNetwork, PCINTNETADDRU pAddr,
     556DECLINLINE(void) intnetR0NetworkAddrCacheDelete(PINTNETNETWORK pNetwork, PCRTNETADDRU pAddr,
    766557                                                INTNETADDRTYPE const enmType, uint8_t const cbAddr)
    767558{
     
    786577 * @param   cbAddr          The address size (optimization).
    787578 */
    788 DECLINLINE(void) intnetR0NetworkAddrCacheDeleteMinusIf(PINTNETNETWORK pNetwork, PINTNETIF pIfSender, PCINTNETADDRU pAddr,
     579DECLINLINE(void) intnetR0NetworkAddrCacheDeleteMinusIf(PINTNETNETWORK pNetwork, PINTNETIF pIfSender, PCRTNETADDRU pAddr,
    789580                                                       INTNETADDRTYPE const enmType, uint8_t const cbAddr)
    790581{
     
    807598 * @param   pAddr       The address.
    808599 */
    809 static void intnetR0IfAddrCacheAddIt(PINTNETIF pIf, PINTNETADDRCACHE pCache, PCINTNETADDRU pAddr)
     600static void intnetR0IfAddrCacheAddIt(PINTNETIF pIf, PINTNETADDRCACHE pCache, PCRTNETADDRU pAddr)
    810601{
    811602    if (!pCache->cEntriesAlloc)
     
    861652 * @param   cbAddr      The size of the address (optimization).
    862653 */
    863 static void intnetR0IfAddrCacheAddSlow(PINTNETIF pIf, PINTNETADDRCACHE pCache, PCINTNETADDRU pAddr, uint8_t const cbAddr)
     654static void intnetR0IfAddrCacheAddSlow(PINTNETIF pIf, PINTNETADDRCACHE pCache, PCRTNETADDRU pAddr, uint8_t const cbAddr)
    864655{
    865656    /*
     
    871662    while (--cLeft > 1)
    872663    {
    873         if (RT_LIKELY(intnetR0AddrUIsEqualEx((PCINTNETADDRU)pbEntry, pAddr, cbAddr)))
     664        if (RT_LIKELY(intnetR0AddrUIsEqualEx((PCRTNETADDRU)pbEntry, pAddr, cbAddr)))
    874665        {
    875666            /** @todo usage/ageing? */
     
    895686 * @param   cbAddr      The size of the address (optimization).
    896687 */
    897 DECLINLINE(void) intnetR0IfAddrCacheAdd(PINTNETIF pIf, PINTNETADDRCACHE pCache, PCINTNETADDRU pAddr, uint8_t const cbAddr)
     688DECLINLINE(void) intnetR0IfAddrCacheAdd(PINTNETIF pIf, PINTNETADDRCACHE pCache, PCRTNETADDRU pAddr, uint8_t const cbAddr)
    898689{
    899690    Assert(pCache->cbAddress == cbAddr);
     
    904695    unsigned i = pCache->cEntries;
    905696    if (RT_LIKELY(   i > 0
    906                   && intnetR0AddrUIsEqualEx((PCINTNETADDRU)pCache->pbEntries, pAddr, cbAddr)))
     697                  && intnetR0AddrUIsEqualEx((PCRTNETADDRU)pCache->pbEntries, pAddr, cbAddr)))
    907698    {
    908699        /** @todo usage/ageing? */
     
    916707     */
    917708    i--;
    918     if (RT_LIKELY(intnetR0AddrUIsEqualEx((PCINTNETADDRU)pCache->pbEntries, pAddr, cbAddr)))
     709    if (RT_LIKELY(intnetR0AddrUIsEqualEx((PCRTNETADDRU)pCache->pbEntries, pAddr, cbAddr)))
    919710    {
    920711        /** @todo usage/ageing? */
     
    940731 *                          size of the frame without the ethernet header.
    941732 */
    942 static void intnetR0IfSniffIPv4SourceAddr(PINTNETIF pIf, PCINTNETIPV4 pHdr, uint32_t cbPacket)
     733static void intnetR0IfSniffIPv4SourceAddr(PINTNETIF pIf, PCRTNETIPV4 pHdr, uint32_t cbPacket)
    943734{
    944735    /*
    945736     * Check the header size.
    946737     */
    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. */
    948739        return;
    949740    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)
    951742        ||  cbPacket < cbHdr)
    952743        return;
     
    955746     * Ignore 255.255.255.255 (broadcast), 0.0.0.0 (null) and already cached addresses.
    956747     */
    957     INTNETADDRU Addr;
     748    RTNETADDRU Addr;
    958749    Addr.au32[0] = pHdr->ip_src;
    959750    if (Addr.au32[0] == UINT32_C(0xffffffff))
     
    965756    {
    966757#if 0 /** @todo quick DHCP check? */
    967         if (pHdr->ip_p != INTNETIPV4_PROT_UDP)
     758        if (pHdr->ip_p != RTNETIPV4_PROT_UDP)
    968759            return;
    969760#endif
     
    998789 *                          request 'cause of min ethernet frame size).
    999790 */
    1000 static void intnetR0IfSniffArpSourceAddr(PINTNETIF pIf, PCINTNETARPHDR pHdr, uint32_t cbPacket)
     791static void intnetR0IfSniffArpSourceAddr(PINTNETIF pIf, PCRTNETARPHDR pHdr, uint32_t cbPacket)
    1001792{
    1002793    /*
     
    1005796    if (RT_UNLIKELY(    cbPacket <= sizeof(*pHdr)
    1006797                    ||  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)
    1012803                         /** @todo Read up on inverse ARP. */
    1013804                        )
     
    1019810     * Deal with the protocols.
    1020811     */
    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))
    1023814    {
    1024815        /*
    1025816         * IPv4.
    1026817         */
    1027         PCINTNETARPIPV4 pReq = (PCINTNETARPIPV4)pHdr;
     818        PCRTNETARPIPV4 pReq = (PCRTNETARPIPV4)pHdr;
    1028819        if (RT_UNLIKELY(    pHdr->ar_plen == sizeof(pReq->ar_spa)
    1029820                        ||  cbPacket < sizeof(*pReq)
     
    1032823            return;
    1033824
    1034         if (INTNET_ARPOP_IS_REPLY(RT_BE2H_U16(pHdr->ar_oper)))
     825        if (RTNET_ARPOP_IS_REPLY(RT_BE2H_U16(pHdr->ar_oper)))
    1035826        {
    1036827            Addr.IPv4 = pReq->ar_tpa;
     
    1040831        intnetR0IfAddrCacheAdd(pIf, &pIf->aAddrCache[kIntNetAddrType_IPv4], &Addr, sizeof(pReq->ar_spa));
    1041832    }
    1042     else if (pHdr->ar_ptype == RT_H2BE_U16(INTNET_ETHERTYPE_IPV6))
     833    else if (pHdr->ar_ptype == RT_H2BE_U16(RTNET_ETHERTYPE_IPV6))
    1043834    {
    1044835        /*
     
    1052843            return;
    1053844
    1054         if (INTNET_ARPOP_IS_REPLY(RT_BE2H_U16(pHdr->ar_oper)))
     845        if (RTNET_ARPOP_IS_REPLY(RT_BE2H_U16(pHdr->ar_oper)))
    1055846        {
    1056847            Addr.IPv6 = pReq->ar_tpa;
     
    1079870     * Fish out the ethertype and look for stuff we can handle.
    1080871     */
    1081     if (cbFrame <= sizeof(INTNETETHERHDR))
     872    if (cbFrame <= sizeof(RTNETETHERHDR))
    1082873        return;
    1083     cbFrame -= sizeof(INTNETETHERHDR);
    1084 
    1085     uint16_t EtherType = ((PCINTNETETHERHDR)pbFrame)->EtherType;
    1086     if (EtherType == RT_H2BE_U16(INTNET_ETHERTYPE_IPV4))
    1087         intnetR0IfSniffIPv4SourceAddr(pIf, (PCINTNETIPV4)((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);
    1088879#if 0 /** @todo IntNet: implement IPv6 for wireless MAC sharing. */
    1089     else if (EtherType == RT_H2BE_U16(INTNET_ETHERTYPE_IPV6))
    1090         intnetR0IfSniffIPv6SourceAddr(pIf, (PCINTNETIPV6)((PCINTNETETHERHDR)pbFrame + 1), cbFrame);
     880    else if (EtherType == RT_H2BE_U16(RTNET_ETHERTYPE_IPV6))
     881        intnetR0IfSniffIPv6SourceAddr(pIf, (PCINTNETIPV6)((PCRTNETETHERHDR)pbFrame + 1), cbFrame);
    1091882#endif
    1092883#if 0 /** @todo IntNet: implement IPX for wireless MAC sharing? */
     
    1095886             || EtherType == RT_H2BE_U16(0x8138) //??
    1096887             )
    1097         intnetR0IfSniffIpxSourceAddr(pIf, (PCINTNETIPX)((PCINTNETETHERHDR)pbFrame + 1), cbFrame);
     888        intnetR0IfSniffIpxSourceAddr(pIf, (PCINTNETIPX)((PCRTNETETHERHDR)pbFrame + 1), cbFrame);
    1098889#endif
    1099     else if (EtherType == RT_H2BE_U16(INTNET_ETHERTYPE_ARP))
    1100         intnetR0IfSniffArpSourceAddr(pIf, (PCINTNETARPHDR)((PCINTNETETHERHDR)pbFrame + 1), cbFrame);
     890    else if (EtherType == RT_H2BE_U16(RTNET_ETHERTYPE_ARP))
     891        intnetR0IfSniffArpSourceAddr(pIf, (PCRTNETARPHDR)((PCRTNETETHERHDR)pbFrame + 1), cbFrame);
    1101892}
    1102893
     
    14921283 * @param   pEthHdr         Pointer to the ethernet header.
    14931284 */
    1494 static bool intnetR0NetworkSendMulticast(PINTNETNETWORK pNetwork, PINTNETIF pIfSender, uint32_t fSrc, PINTNETSG pSG, bool fTrunkLocked, PCINTNETETHERHDR pEthHdr)
     1285static bool intnetR0NetworkSendMulticast(PINTNETNETWORK pNetwork, PINTNETIF pIfSender, uint32_t fSrc, PINTNETSG pSG, bool fTrunkLocked, PCRTNETETHERHDR pEthHdr)
    14951286{
    14961287    /** @todo implement multicast */
     
    15121303 * @param   pEthHdr         Pointer to the ethernet header.
    15131304 */
    1514 static bool intnetR0NetworkSendUnicast(PINTNETNETWORK pNetwork, PINTNETIF pIfSender, uint32_t fSrc, PINTNETSG pSG, bool fTrunkLocked, PCINTNETETHERHDR pEthHdr)
     1305static bool intnetR0NetworkSendUnicast(PINTNETNETWORK pNetwork, PINTNETIF pIfSender, uint32_t fSrc, PINTNETSG pSG, bool fTrunkLocked, PCRTNETETHERHDR pEthHdr)
    15151306{
    15161307    /*
     
    16051396    Assert(pSG->cSegsUsed >= 1);
    16061397    Assert(pSG->cSegsUsed <= pSG->cSegsAlloc);
    1607     if (pSG->cbTotal < sizeof(INTNETETHERHDR))
     1398    if (pSG->cbTotal < sizeof(RTNETETHERHDR))
    16081399        return fRc;
    16091400
     
    16201411     * Get the ethernet header (might theoretically involve multiple segments).
    16211412     */
    1622     INTNETETHERHDR EthHdr;
     1413    RTNETETHERHDR EthHdr;
    16231414    if (RT_LIKELY(pSG->aSegs[0].cb >= sizeof(EthHdr)))
    1624         EthHdr = *(PCINTNETETHERHDR)pSG->aSegs[0].pv;
     1415        EthHdr = *(PCRTNETETHERHDR)pSG->aSegs[0].pv;
    16251416    else
    16261417    {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette