Changeset 39410 in vbox
- Timestamp:
- Nov 24, 2011 3:30:16 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NAT/VBoxNetNAT.cpp
r38636 r39410 151 151 m_MacAddress.au8[4] = 0x41; 152 152 m_MacAddress.au8[5] = 0x42; 153 m_Ipv4Address.u = RT_H2N_U32_C(RT_BSWAP_U32_C(RT_MAKE_U32_FROM_U8( 10, 0, 2, 1)));154 m_Ipv4Netmask.u = 0xffff0000;153 m_Ipv4Address.u = RT_H2N_U32_C(RT_BSWAP_U32_C(RT_MAKE_U32_FROM_U8( 10, 0, 2, 2))); 154 m_Ipv4Netmask.u = RT_H2N_U32_C(0xffffff); 155 155 cPkt = 0; 156 156 cUrgPkt = 0; … … 161 161 { 162 162 int rc; 163 #if 0 164 using namespace com; 165 HRESULT hrc = com::Initialize(); 166 if (FAILED(hrc)) 167 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to initialize COM!"); 168 #endif 163 169 164 170 /* 165 171 * Initialize slirp. 166 172 */ 167 rc = slirp_init(&m_pNATState, m_Ipv4Address.u, m_Ipv4Netmask.u, m_fPassDomain, false,0, this);173 rc = slirp_init(&m_pNATState, RT_H2N_U32_C(RT_BSWAP_U32_C(RT_MAKE_U32_FROM_U8( 10, 0, 2, 0))), m_Ipv4Netmask.u, m_fPassDomain, false, 0x40, 100, this); 168 174 AssertReleaseRC(rc); 169 175 … … 238 244 { 239 245 uint16_t const u16Type = pHdr->u16Type; 240 if (RT_LIKELY( u16Type == INTNETHDR_TYPE_FRAME 241 || u16Type == INTNETHDR_TYPE_GSO)) 246 size_t cbFrame = pHdr->cbFrame; 247 size_t cbIgnored; 248 void *pvSlirpFrame; 249 struct mbuf *m; 250 switch (u16Type) 242 251 { 243 size_t cbFrame = pHdr->cbFrame; 244 size_t cbIgnored; 245 void *pvSlirpFrame; 246 struct mbuf *m; 247 if (u16Type == INTNETHDR_TYPE_FRAME) 248 { 252 case INTNETHDR_TYPE_FRAME: 249 253 m = slirp_ext_m_get(g_pNAT->m_pNATState, cbFrame, &pvSlirpFrame, &cbIgnored); 250 254 if (!m) … … 260 264 (PFNRT)SendWorker, 2, m, cbFrame); 261 265 AssertReleaseRC(rc); 262 }263 else266 break; 267 case INTNETHDR_TYPE_GSO: 264 268 { 265 269 /** @todo pass these unmodified. */ … … 282 286 if (!m) 283 287 { 284 LogRel(("NAT: Can't allocate send buffer cbSegFrame=%u seg=%u/%u\n", cbSegFrame, iSeg, cSegs)); 288 LogRel(("NAT: Can't allocate send buffer cbSegFrame=%u seg=%u/%u\n", 289 cbSegFrame, iSeg, cSegs)); 285 290 break; 286 291 } 287 292 memcpy(pvSlirpFrame, pvSegFrame, cbFrame); 288 293 289 rc = RTReqCallEx(m_pReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, 294 rc = RTReqCallEx(m_pReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, 295 RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, 290 296 (PFNRT)SendWorker, 2, m, cbSegFrame); 291 297 AssertReleaseRC(rc); … … 293 299 IntNetRingSkipFrame(&m_pIfBuf->Recv); 294 300 } 301 break; 302 case INTNETHDR_TYPE_PADDING: 303 IntNetRingSkipFrame(&m_pIfBuf->Recv); 304 break; 305 default: 306 IntNetRingSkipFrame(&m_pIfBuf->Recv); 307 STAM_REL_COUNTER_INC(&m_pIfBuf->cStatBadFrames); 308 break; 309 } 295 310 296 311 #ifndef RT_OS_WINDOWS 297 312 /* kick select() */ 298 size_t cbIgnored;299 313 rc = RTPipeWrite(m_hPipeWrite, "", 1, &cbIgnored); 300 314 AssertRC(rc); … … 305 319 #endif 306 320 } 307 else if (u16Type == INTNETHDR_TYPE_PADDING) 308 IntNetRingSkipFrame(&m_pIfBuf->Recv); 309 else 310 { 311 IntNetRingSkipFrame(&m_pIfBuf->Recv); 312 STAM_REL_COUNTER_INC(&m_pIfBuf->cStatBadFrames); 313 } 314 } 321 natNotifyNATThread(); 315 322 316 323 }
Note:
See TracChangeset
for help on using the changeset viewer.