Changeset 28025 in vbox for trunk/src/VBox/NetworkServices/NetLib
- Timestamp:
- Apr 7, 2010 6:37:43 AM (15 years ago)
- Location:
- trunk/src/VBox/NetworkServices/NetLib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NetLib/VBoxNetARP.cpp
r27856 r28025 44 44 { 45 45 /* 46 * Valid IntNet Ethernet frame? 46 * Valid IntNet Ethernet frame? Skip GSO, no ARP in there. 47 47 */ 48 48 PCINTNETHDR pHdr = INTNETRingGetNextFrameToRead(&pBuf->Recv); -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetUDP.cpp
r27856 r28025 29 29 #include <iprt/rand.h> 30 30 #include <VBox/log.h> 31 #include <VBox/pdmnetinline.h> 31 32 #include <VBox/intnetinline.h> 32 33 … … 64 65 */ 65 66 PCINTNETHDR pHdr = INTNETRingGetNextFrameToRead(&pBuf->Recv); 66 if (!pHdr || pHdr->u16Type != INTNETHDR_TYPE_FRAME) 67 if ( !pHdr 68 || ( pHdr->u16Type != INTNETHDR_TYPE_FRAME 69 && pHdr->u16Type != INTNETHDR_TYPE_GSO)) 67 70 return NULL; 68 71 69 72 size_t cbFrame = pHdr->cbFrame; 70 73 const void *pvFrame = INTNETHdrGetFramePtr(pHdr, pBuf); 74 PCPDMNETWORKGSO pGso = NULL; 75 if (pHdr->u16Type == INTNETHDR_TYPE_GSO) 76 { 77 pGso = (PCPDMNETWORKGSO)pvFrame; 78 if (!PDMNetGsoIsValid(pGso, cbFrame, cbFrame - sizeof(*pGso))) 79 return NULL; 80 /** @todo IPv6 UDP support, goes for this entire function really. Not really 81 * important yet since this is currently only used by the DHCP server. */ 82 if (pGso->u8Type != PDMNETWORKGSOTYPE_IPV4_UDP) 83 return NULL; 84 pvFrame = pGso + 1; 85 cbFrame -= sizeof(*pGso); 86 } 87 71 88 PCRTNETETHERHDR pEthHdr = (PCRTNETETHERHDR)pvFrame; 72 89 if (pHdrs) … … 106 123 107 124 /* 125 * If we're working on a GSO frame, we need to make sure the length fields 126 * are set correctly (they are usually set to 0). 127 */ 128 if (pGso) 129 PDMNetGsoPrepForDirectUse(pGso, (void *)pvFrame, cbFrame, false /*fHeaderChecskum*/, false /*fPayloadChecksum*/); 130 131 /* 108 132 * IP validation and matching. 109 133 */ … … 118 142 /* Valid IPv4 header? */ 119 143 size_t const offIpHdr = (uintptr_t)pIpHdr - (uintptr_t)pEthHdr; 120 if (!RTNetIPv4IsHdrValid(pIpHdr, cbFrame - offIpHdr, cbFrame - offIpHdr ))144 if (!RTNetIPv4IsHdrValid(pIpHdr, cbFrame - offIpHdr, cbFrame - offIpHdr, !pGso /*fChecksum*/)) 121 145 return NULL; 122 146 … … 132 156 return NULL; 133 157 134 /* Validate the UDP header according to flags. */ 135 size_t offUdpHdr = (uintptr_t)pUdpHdr - (uintptr_t)pEthHdr; 136 if (fFlags & (VBOXNETUDP_MATCH_CHECKSUM | VBOXNETUDP_MATCH_REQUIRE_CHECKSUM)) 158 if (!pGso) 137 159 { 138 if (!RTNetIPv4IsUDPValid(pIpHdr, pUdpHdr, pUdpHdr + 1, cbFrame - offUdpHdr)) 139 return NULL; 140 if ( (fFlags & VBOXNETUDP_MATCH_REQUIRE_CHECKSUM) 141 && !pUdpHdr->uh_sum) 142 return NULL; 143 } 144 else 145 { 146 if (!RTNetIPv4IsUDPSizeValid(pIpHdr, pUdpHdr, cbFrame - offUdpHdr)) 147 return NULL; 160 /* Validate the UDP header according to flags. */ 161 size_t offUdpHdr = (uintptr_t)pUdpHdr - (uintptr_t)pEthHdr; 162 if (fFlags & (VBOXNETUDP_MATCH_CHECKSUM | VBOXNETUDP_MATCH_REQUIRE_CHECKSUM)) 163 { 164 if (!RTNetIPv4IsUDPValid(pIpHdr, pUdpHdr, pUdpHdr + 1, cbFrame - offUdpHdr, true /*fChecksum*/)) 165 return NULL; 166 if ( (fFlags & VBOXNETUDP_MATCH_REQUIRE_CHECKSUM) 167 && !pUdpHdr->uh_sum) 168 return NULL; 169 } 170 else 171 { 172 if (!RTNetIPv4IsUDPSizeValid(pIpHdr, pUdpHdr, cbFrame - offUdpHdr)) 173 return NULL; 174 } 148 175 } 149 176
Note:
See TracChangeset
for help on using the changeset viewer.