VirtualBox

Changeset 11538

Show
Ignore:
Timestamp:
08/21/08 17:16:07 (3 months ago)
Author:
vboxsync
Message:

pcnet: Rearranged the giant frame detection, adding the VLAN EtherType? to iprt/net.h. Btw. to make things easier to read, don't do if (error) do-lots; else do-what-we're-here-for; because then the reader will have to skip lots of code when following the normal execution path. Also, there is hardly any point in using the 'register' keyword these days.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/iprt/net.h

    r11445 r11538  
    134134#define RTNET_ETHERTYPE_ARP     UINT16_C(0x0806) 
    135135#define RTNET_ETHERTYPE_IPV6    UINT16_C(0x86dd) 
     136#define RTNET_ETHERTYPE_VLAN    UINT16_C(0x8100) 
    136137#define RTNET_ETHERTYPE_IPX_1   UINT16_C(0x8037) 
    137138#define RTNET_ETHERTYPE_IPX_2   UINT16_C(0x8137) 
  • trunk/src/VBox/Devices/Network/DevPCNet.cpp

    r11437 r11538  
    6464#include <iprt/string.h> 
    6565#include <iprt/time.h> 
     66#include <iprt/net.h> 
    6667#ifdef IN_RING3 
    6768# include <iprt/mem.h> 
     
    43864387    PCNetState *pThis = INETWORKPORT_2_DATA(pInterface); 
    43874388    int         rc; 
    4388     static bool firstBigFrameLoss = true; 
    43894389 
    43904390    STAM_PROFILE_ADV_START(&pThis->StatReceive, a); 
     
    43934393 
    43944394    /* 
    4395      * Determine max ethernet frame size with vlan tag (TPID == 0x8100) or without it 
    4396      * (excluding CRC which is not transferred)
    4397      * It consists of 14-byte header [+ 4-byte vlan tag] + 1500-byte body. 
     4395     * Check for the max ethernet frame size, taking the IEEE 802.1Q (VLAN) tag into 
     4396     * account. Note that we are *not* expecting the CRC Checksum
     4397     * Ethernet frames consists of a 14-byte header [+ 4-byte vlan tag] + a 1500-byte body. 
    43984398     */ 
    4399     register unsigned maxFrameSize = ((uint16_t*)pvBuf)[6] == 0x81 ? 1518 : 1514; 
    4400     if (RT_UNLIKELY(cb > maxFrameSize)) 
    4401     { 
    4402         if (RT_UNLIKELY(firstBigFrameLoss)) 
    4403         { 
    4404             firstBigFrameLoss = false; 
    4405             Log(("#%d Received frame exceeds max size (%u > %u). " 
    4406                  "Further frame losses will be reported at level5\n", 
    4407                  PCNET_INST_NR, (unsigned)cb, maxFrameSize)); 
    4408         } 
    4409         else 
    4410             Log5(("#%d Received frame exceeds max size (%u > %u)\n", 
    4411                   PCNET_INST_NR, (unsigned)cb, (unsigned)maxFrameSize)); 
    4412     } 
    4413     else 
     4399    if (RT_LIKELY(   cb <= 1514 
     4400                  || (   cb <= 1518 
     4401                      && ((PCRTNETETHERHDR)pvBuf)->EtherType == RT_H2BE_U16_C(RTNET_ETHERTYPE_VLAN)))) 
    44144402    { 
    44154403        if (cb > 70) /* unqualified guess */ 
     
    44184406        pThis->Led.Actual.s.fReading = 0; 
    44194407    } 
     4408#ifdef LOG_ENABLED 
     4409    else 
     4410    { 
     4411        static bool s_fFirstBigFrameLoss = true; 
     4412        unsigned cbMaxFrame = ((PCRTNETETHERHDR)pvBuf)->EtherType == RT_H2BE_U16_C(RTNET_ETHERTYPE_VLAN) 
     4413                            ? 1518 : 1514; 
     4414        if (s_fFirstBigFrameLoss) 
     4415        { 
     4416            s_fFirstBigFrameLoss = false; 
     4417            Log(("PCNet#%d: Received giant frame %zu, max %u. (Further giants will be reported at level5.)\n", 
     4418                 PCNET_INST_NR, cb, cbMaxFrame)); 
     4419        } 
     4420        else 
     4421            Log5(("PCNet#%d: Received giant frame %zu bytes, max %u.\n", 
     4422                  PCNET_INST_NR, cb, cbMaxFrame)); 
     4423    } 
     4424#endif /* LOG_ENABLED */ 
    44204425 
    44214426    PDMCritSectLeave(&pThis->CritSect); 
  • trunk/src/VBox/Runtime/testcase/tstUuid.cpp

    r11413 r11538  
    106106    CHECK_EXPR(memcmp(&Uuid3, &Uuid, sizeof(Uuid)) == 0); 
    107107 
    108 #if 0 /** @todo make less verbose and print the bits that remain unchanged. */ 
     108#if 1 /** @todo make less verbose and print the bits that remain unchanged. */ 
    109109    /* 
    110110     * checking the clock seq and time hi and version bits... 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy