Changeset 44824 in vbox for trunk/src/VBox/NetworkServices/NetLib
- Timestamp:
- Feb 25, 2013 6:30:42 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 83953
- Location:
- trunk/src/VBox/NetworkServices/NetLib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.cpp
r39685 r44824 37 37 #include <VBox/sup.h> 38 38 #include <VBox/intnet.h> 39 #include <VBox/intnetinline.h> 39 40 #include <VBox/vmm/vmm.h> 40 41 #include <VBox/version.h> … … 69 70 VBoxNetBaseService::VBoxNetBaseService() 70 71 { 72 int rc = RTCritSectInit(&m_csThis); 73 AssertRC(rc); 71 74 } 72 75 VBoxNetBaseService::~VBoxNetBaseService() … … 92 95 m_pSession = NIL_RTR0PTR; 93 96 } 97 RTCritSectDelete(&m_csThis); 94 98 } 95 99 … … 97 101 { 98 102 /* numbers from DrvIntNet */ 99 m_cbSendBuf = 36* _1K;100 m_cbRecvBuf = 2 18* _1K;103 m_cbSendBuf = 128 * _1K; 104 m_cbRecvBuf = 256 * _1K; 101 105 m_hIf = INTNET_HANDLE_INVALID; 102 106 m_pIfBuf = NULL; … … 124 128 int rc = RTGetOptInit(&State, argc, argv, paOptionArray, m_vecOptionDefs.size(), 0, 0 /*fFlags*/); 125 129 AssertRCReturn(rc, 49); 130 #if 0 131 /* default initialization */ 132 m_enmTrunkType = kIntNetTrunkType_WhateverNone; 133 #endif 126 134 Log2(("BaseService: parseArgs enter\n")); 127 135 … … 309 317 } 310 318 319 int VBoxNetBaseService::waitForIntNetEvent(int cMillis) 320 { 321 int rc = VINF_SUCCESS; 322 INTNETIFWAITREQ WaitReq; 323 LogFlowFunc(("ENTER:cMillis: %d\n", cMillis)); 324 WaitReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 325 WaitReq.Hdr.cbReq = sizeof(WaitReq); 326 WaitReq.pSession = m_pSession; 327 WaitReq.hIf = m_hIf; 328 WaitReq.cMillies = cMillis; 329 330 rc = SUPR3CallVMMR0Ex(NIL_RTR0PTR, NIL_VMCPUID, VMMR0_DO_INTNET_IF_WAIT, 0, &WaitReq.Hdr); 331 LogFlowFuncLeaveRC(rc); 332 return rc; 333 } 334 335 /* S/G API */ 336 int VBoxNetBaseService::sendBufferOnWire(PCINTNETSEG pcSg, int cSg, size_t cbFrame) 337 { 338 int rc = VINF_SUCCESS; 339 PINTNETHDR pHdr = NULL; 340 uint8_t *pu8Frame = NULL; 341 int offFrame = 0; 342 int idxSg = 0; 343 /* Allocate frame */ 344 rc = IntNetRingAllocateFrame(&m_pIfBuf->Send, cbFrame, &pHdr, (void **)&pu8Frame); 345 AssertRCReturn(rc, rc); 346 /* Now we fill pvFrame with S/G above */ 347 for (idxSg = 0; idxSg < cSg; ++idxSg) 348 { 349 memcpy(&pu8Frame[offFrame], pcSg[idxSg].pv, pcSg[idxSg].cb); 350 offFrame+=pcSg[idxSg].cb; 351 } 352 /* Commit */ 353 IntNetRingCommitFrame(&m_pIfBuf->Send, pHdr); 354 355 LogFlowFuncLeaveRC(rc); 356 return rc; 357 } 358 /** 359 * forcible ask for send packet on the "wire" 360 */ 361 void VBoxNetBaseService::flushWire() 362 { 363 int rc = VINF_SUCCESS; 364 INTNETIFSENDREQ SendReq; 365 SendReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 366 SendReq.Hdr.cbReq = sizeof(SendReq); 367 SendReq.pSession = m_pSession; 368 SendReq.hIf = m_hIf; 369 rc = SUPR3CallVMMR0Ex(NIL_RTR0PTR, NIL_VMCPUID, VMMR0_DO_INTNET_IF_SEND, 0, &SendReq.Hdr); 370 AssertRCReturnVoid(rc); 371 LogFlowFuncLeave(); 372 373 } 374 311 375 /** 312 376 * Print debug message depending on the m_cVerbosity level. -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h
r44529 r44824 18 18 #ifndef ___VBoxNetBaseService_h___ 19 19 #define ___VBoxNetBaseService_h___ 20 #include <iprt/critsect.h> 20 21 class VBoxNetBaseService 21 22 { … … 26 27 int tryGoOnline(void); 27 28 void shutdown(void); 29 int syncEnter() { return RTCritSectEnter(&this->m_csThis);} 30 int syncLeave() { return RTCritSectLeave(&this->m_csThis);} 31 int waitForIntNetEvent(int cMillis); 32 int sendBufferOnWire(PCINTNETSEG pSg, int cSg, size_t cbBuffer); 33 void flushWire(); 28 34 virtual void usage(void) = 0; 29 35 virtual void run(void) = 0; … … 42 48 RTMAC m_MacAddress; 43 49 RTNETADDRIPV4 m_Ipv4Address; 50 /* cs for syncing */ 51 RTCRITSECT m_csThis; 44 52 /** @} */ 45 53 /** @name The network interface
Note:
See TracChangeset
for help on using the changeset viewer.