Changeset 10524 in vbox for trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp
- Timestamp:
- Jul 11, 2008 1:21:35 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp
r10485 r10524 171 171 * @param hIF The interface handle to validate and translate. 172 172 */ 173 DECLINLINE(PINTNETIF) INTNETHandle2IFPtr(PINTNET pIntNet, INTNETIFHANDLE hIF)173 DECLINLINE(PINTNETIF) intnetHandle2IFPtr(PINTNET pIntNet, INTNETIFHANDLE hIF) 174 174 { 175 175 Assert(pIntNet); … … 202 202 * @param pIF The interface which we're allocating a handle for. 203 203 */ 204 static INTNETIFHANDLE INTNETHandleAllocate(PINTNET pIntNet, PINTNETIF pIF)204 static INTNETIFHANDLE intnetHandleAllocate(PINTNET pIntNet, PINTNETIF pIF) 205 205 { 206 206 Assert(pIF); … … 287 287 * @param h The handle we're freeing. 288 288 */ 289 static void INTNETHandleFree(PINTNET pIntNet, INTNETIFHANDLE h)290 { 291 Assert( INTNETHandle2IFPtr(pIntNet, h));289 static void intnetHandleFree(PINTNET pIntNet, INTNETIFHANDLE h) 290 { 291 Assert(intnetHandle2IFPtr(pIntNet, h)); 292 292 PINTNETHT pHT = &pIntNet->IfHandles; 293 293 const uint32_t i = h & INTNET_HANDLE_INDEX_MASK; … … 327 327 * ensuring that there is sufficient space for the frame. 328 328 */ 329 static unsigned INTNETRingReadFrame(PINTNETBUF pBuf, PINTNETRINGBUF pRingBuf, void *pvFrame)329 static unsigned intnetRingReadFrame(PINTNETBUF pBuf, PINTNETRINGBUF pRingBuf, void *pvFrame) 330 330 { 331 331 Assert(pRingBuf->offRead < pBuf->cbBuf); … … 359 359 * @param cbFrame The size of the frame. 360 360 */ 361 static int INTNETRingWriteFrame(PINTNETBUF pBuf, PINTNETRINGBUF pRingBuf, const void *pvFrame, uint32_t cbFrame)361 static int intnetRingWriteFrame(PINTNETBUF pBuf, PINTNETRINGBUF pRingBuf, const void *pvFrame, uint32_t cbFrame) 362 362 { 363 363 /* … … 465 465 { 466 466 LogFlow(("intnetIfSend: pIf=%p:{.hIf=%RX32}\n", pIf, pIf->hIf)); 467 int rc = INTNETRingWriteFrame(pIf->pIntBuf, &pIf->pIntBuf->Recv, pvFrame, cbFrame);467 int rc = intnetRingWriteFrame(pIf->pIntBuf, &pIf->pIntBuf->Recv, pvFrame, cbFrame); 468 468 if (VBOX_SUCCESS(rc)) 469 469 { … … 486 486 RTSemEventSignal(pIf->Event); 487 487 RTThreadYield(); 488 rc = INTNETRingWriteFrame(pIf->pIntBuf, &pIf->pIntBuf->Recv, pvFrame, cbFrame);488 rc = intnetRingWriteFrame(pIf->pIntBuf, &pIf->pIntBuf->Recv, pvFrame, cbFrame); 489 489 if (VBOX_SUCCESS(rc)) 490 490 { … … 607 607 */ 608 608 AssertReturn(pIntNet, VERR_INVALID_PARAMETER); 609 PINTNETIF pIf = INTNETHandle2IFPtr(pIntNet, hIf);609 PINTNETIF pIf = intnetHandle2IFPtr(pIntNet, hIf); 610 610 if (!pIf) 611 611 return VERR_INVALID_HANDLE; … … 684 684 */ 685 685 AssertReturn(pIntNet, VERR_INVALID_PARAMETER); 686 PINTNETIF pIf = INTNETHandle2IFPtr(pIntNet, hIf);686 PINTNETIF pIf = intnetHandle2IFPtr(pIntNet, hIf); 687 687 if (!pIf) 688 688 return VERR_INVALID_HANDLE; … … 737 737 */ 738 738 AssertReturn(pIntNet, VERR_INVALID_PARAMETER); 739 PINTNETIF pIf = INTNETHandle2IFPtr(pIntNet, hIf);739 PINTNETIF pIf = intnetHandle2IFPtr(pIntNet, hIf); 740 740 if (!pIf) 741 741 return VERR_INVALID_HANDLE; … … 773 773 */ 774 774 AssertReturn(pIntNet, VERR_INVALID_PARAMETER); 775 PINTNETIF pIf = INTNETHandle2IFPtr(pIntNet, hIf);775 PINTNETIF pIf = intnetHandle2IFPtr(pIntNet, hIf); 776 776 if (!pIf) 777 777 return VERR_INVALID_HANDLE; … … 813 813 */ 814 814 AssertReturn(pIntNet, VERR_INVALID_PARAMETER); 815 PINTNETIF pIf = INTNETHandle2IFPtr(pIntNet, hIf);815 PINTNETIF pIf = intnetHandle2IFPtr(pIntNet, hIf); 816 816 if (!pIf) 817 817 { … … 862 862 */ 863 863 AssertReturn(pIntNet, VERR_INVALID_PARAMETER); 864 PINTNETIF pIf = INTNETHandle2IFPtr(pIntNet, hIf);864 PINTNETIF pIf = intnetHandle2IFPtr(pIntNet, hIf); 865 865 if (!pIf) 866 866 { … … 934 934 */ 935 935 AssertPtrReturn(pIntNet, VERR_INVALID_PARAMETER); 936 PINTNETIF pIf = INTNETHandle2IFPtr(pIntNet, hIf);936 PINTNETIF pIf = intnetHandle2IFPtr(pIntNet, hIf); 937 937 if (!pIf) 938 938 return VERR_INVALID_HANDLE; … … 967 967 * @param pvUser2 Pointer to the INTNET instance data. 968 968 */ 969 static DECLCALLBACK(void) INTNETIfDestruct(void *pvObj, void *pvUser1, void *pvUser2)970 { 971 LogFlow((" INTNETIfDestruct: pvObj=%p pvUser1=%p pvUser2=%p\n", pvObj, pvUser1, pvUser2));969 static DECLCALLBACK(void) intnetIfDestruct(void *pvObj, void *pvUser1, void *pvUser2) 970 { 971 LogFlow(("intnetIfDestruct: pvObj=%p pvUser1=%p pvUser2=%p\n", pvObj, pvUser1, pvUser2)); 972 972 PINTNETIF pIf = (PINTNETIF)pvUser1; 973 973 PINTNET pIntNet = (PINTNET)pvUser2; … … 978 978 if (pIf->hIf != INTNET_HANDLE_INVALID) 979 979 { 980 INTNETHandleFree(pIntNet, pIf->hIf);980 intnetHandleFree(pIntNet, pIf->hIf); 981 981 ASMAtomicXchgSize(&pIf->hIf, INTNET_HANDLE_INVALID); 982 982 } … … 1086 1086 * @param phIf Where to store the interface handle. 1087 1087 */ 1088 static int INTNETNetworkCreateIf(PINTNETNETWORK pNetwork, PSUPDRVSESSION pSession, unsigned cbSend, unsigned cbRecv, PINTNETIFHANDLE phIf)1089 { 1090 LogFlow((" INTNETNetworkCreateIf: pNetwork=%p pSession=%p cbSend=%u cbRecv=%u phIf=%p\n",1088 static int intnetNetworkCreateIf(PINTNETNETWORK pNetwork, PSUPDRVSESSION pSession, unsigned cbSend, unsigned cbRecv, PINTNETIFHANDLE phIf) 1089 { 1090 LogFlow(("intnetNetworkCreateIf: pNetwork=%p pSession=%p cbSend=%u cbRecv=%u phIf=%p\n", 1091 1091 pNetwork, pSession, cbSend, cbRecv, phIf)); 1092 1092 … … 1150 1150 * Register the interface with the session. 1151 1151 */ 1152 pIf->pvObj = SUPR0ObjRegister(pSession, SUPDRVOBJTYPE_INTERNAL_NETWORK_INTERFACE, INTNETIfDestruct, pIf, pNetwork->pIntNet);1152 pIf->pvObj = SUPR0ObjRegister(pSession, SUPDRVOBJTYPE_INTERNAL_NETWORK_INTERFACE, intnetIfDestruct, pIf, pNetwork->pIntNet); 1153 1153 if (pIf->pvObj) 1154 1154 { 1155 pIf->hIf = INTNETHandleAllocate(pNetwork->pIntNet, pIf);1155 pIf->hIf = intnetHandleAllocate(pNetwork->pIntNet, pIf); 1156 1156 if (pIf->hIf != INTNET_HANDLE_INVALID) 1157 1157 { 1158 1158 *phIf = pIf->hIf; 1159 LogFlow((" INTNETNetworkCreateIf: returns VINF_SUCCESS *phIf=%p\n", *phIf));1159 LogFlow(("intnetNetworkCreateIf: returns VINF_SUCCESS *phIf=%p\n", *phIf)); 1160 1160 return VINF_SUCCESS; 1161 1161 } … … 1163 1163 1164 1164 SUPR0ObjRelease(pIf->pvObj, pSession); 1165 LogFlow((" INTNETNetworkCreateIf: returns %Vrc\n", rc));1165 LogFlow(("intnetNetworkCreateIf: returns %Vrc\n", rc)); 1166 1166 return rc; 1167 1167 } … … 1179 1179 } 1180 1180 RTMemFree(pIf); 1181 LogFlow((" INTNETNetworkCreateIf: returns %Vrc\n", rc));1181 LogFlow(("intnetNetworkCreateIf: returns %Vrc\n", rc)); 1182 1182 return rc; 1183 1183 } … … 1185 1185 1186 1186 /** 1187 * Close a network which was opened/created using INTNETOpenNetwork()/INTNETCreateNetwork().1187 * Close a network which was opened/created using intnetOpenNetwork()/intnetCreateNetwork(). 1188 1188 * 1189 1189 * @param pNetwork The network to close. 1190 1190 * @param pSession The session handle. 1191 1191 */ 1192 static int INTNETNetworkClose(PINTNETNETWORK pNetwork, PSUPDRVSESSION pSession)1193 { 1194 LogFlow((" INTNETNetworkClose: pNetwork=%p pSession=%p\n", pNetwork, pSession));1192 static int intnetNetworkClose(PINTNETNETWORK pNetwork, PSUPDRVSESSION pSession) 1193 { 1194 LogFlow(("intnetNetworkClose: pNetwork=%p pSession=%p\n", pNetwork, pSession)); 1195 1195 AssertPtrReturn(pSession, VERR_INVALID_PARAMETER); 1196 1196 AssertPtrReturn(pNetwork, VERR_INVALID_PARAMETER); … … 1201 1201 int rc = SUPR0ObjRelease(pNetwork->pvObj, pSession); 1202 1202 RTSpinlockRelease(pIntNet->Spinlock, &Tmp); 1203 LogFlow((" INTNETNetworkClose: return %Vrc\n", rc));1203 LogFlow(("intnetNetworkClose: return %Vrc\n", rc)); 1204 1204 return rc; 1205 1205 } … … 1214 1214 * @param pvUser2 Pointer to the INTNET instance data. 1215 1215 */ 1216 static DECLCALLBACK(void) INTNETNetworkDestruct(void *pvObj, void *pvUser1, void *pvUser2)1217 { 1218 LogFlow((" INTNETNetworkDestruct: pvObj=%p pvUser1=%p pvUser2=%p\n", pvObj, pvUser1, pvUser2));1216 static DECLCALLBACK(void) intnetNetworkDestruct(void *pvObj, void *pvUser1, void *pvUser2) 1217 { 1218 LogFlow(("intnetNetworkDestruct: pvObj=%p pvUser1=%p pvUser2=%p\n", pvObj, pvUser1, pvUser2)); 1219 1219 RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER; 1220 1220 PINTNETNETWORK pNetwork = (PINTNETNETWORK)pvUser1; … … 1277 1277 * @param ppNetwork Where to store the pointer to the network on success. 1278 1278 */ 1279 static int INTNETOpenNetwork(PINTNET pIntNet, PSUPDRVSESSION pSession, const char *pszNetwork, PINTNETNETWORK *ppNetwork)1280 { 1281 LogFlow((" INTNETOpenNetwork: pIntNet=%p pSession=%p pszNetwork=%p:{%s} ppNetwork=%p\n",1279 static int intnetOpenNetwork(PINTNET pIntNet, PSUPDRVSESSION pSession, const char *pszNetwork, PINTNETNETWORK *ppNetwork) 1280 { 1281 LogFlow(("intnetOpenNetwork: pIntNet=%p pSession=%p pszNetwork=%p:{%s} ppNetwork=%p\n", 1282 1282 pIntNet, pSession, pszNetwork, pszNetwork, ppNetwork)); 1283 1283 … … 1323 1323 } 1324 1324 } 1325 LogFlow((" INTNETOpenNetwork: returns %Vrc *ppNetwork=%p\n", rc, *ppNetwork));1325 LogFlow(("intnetOpenNetwork: returns %Vrc *ppNetwork=%p\n", rc, *ppNetwork)); 1326 1326 return rc; 1327 1327 } … … 1330 1330 RTSpinlockRelease(pIntNet->Spinlock, &Tmp); 1331 1331 1332 LogFlow((" INTNETOpenNetwork: returns VERR_FILE_NOT_FOUND\n"));1332 LogFlow(("intnetOpenNetwork: returns VERR_FILE_NOT_FOUND\n")); 1333 1333 return VERR_FILE_NOT_FOUND; 1334 1334 } … … 1349 1349 * @param ppNetwork Where to store the network. 1350 1350 */ 1351 static int INTNETCreateNetwork(PINTNET pIntNet, PSUPDRVSESSION pSession, const char *pszNetwork, bool fRestrictAccess, PINTNETNETWORK *ppNetwork)1352 { 1353 LogFlow((" INTNETCreateNetwork: pIntNet=%p pSession=%p pszNetwork=%p:{%s} ppNetwork=%p\n",1351 static int intnetCreateNetwork(PINTNET pIntNet, PSUPDRVSESSION pSession, const char *pszNetwork, bool fRestrictAccess, PINTNETNETWORK *ppNetwork) 1352 { 1353 LogFlow(("intnetCreateNetwork: pIntNet=%p pSession=%p pszNetwork=%p:{%s} ppNetwork=%p\n", 1354 1354 pIntNet, pSession, pszNetwork, pszNetwork, ppNetwork)); 1355 1355 … … 1371 1371 { 1372 1372 RTSpinlockRelease(pIntNet->Spinlock, &Tmp); 1373 LogFlow((" INTNETCreateNetwork: returns VERR_ALREADY_EXISTS\n"));1373 LogFlow(("intnetCreateNetwork: returns VERR_ALREADY_EXISTS\n")); 1374 1374 return VERR_ALREADY_EXISTS; 1375 1375 } … … 1395 1395 * Register the object in the current session. 1396 1396 */ 1397 pNew->pvObj = SUPR0ObjRegister(pSession, SUPDRVOBJTYPE_INTERNAL_NETWORK, INTNETNetworkDestruct, pNew, pIntNet);1397 pNew->pvObj = SUPR0ObjRegister(pSession, SUPDRVOBJTYPE_INTERNAL_NETWORK, intnetNetworkDestruct, pNew, pIntNet); 1398 1398 if (pNew->pvObj) 1399 1399 { … … 1416 1416 { 1417 1417 *ppNetwork = pNew; 1418 LogFlow((" INTNETCreateNetwork: returns VINF_SUCCESS *ppNetwork=%p\n", pNew));1418 LogFlow(("intnetCreateNetwork: returns VINF_SUCCESS *ppNetwork=%p\n", pNew)); 1419 1419 return VINF_SUCCESS; 1420 1420 } … … 1422 1422 /* The release will destroy the object. */ 1423 1423 SUPR0ObjRelease(pNew->pvObj, pSession); 1424 LogFlow((" INTNETCreateNetwork: returns %Vrc\n", rc));1424 LogFlow(("intnetCreateNetwork: returns %Vrc\n", rc)); 1425 1425 return rc; 1426 1426 } … … 1431 1431 } 1432 1432 RTMemFree(pNew); 1433 LogFlow((" INTNETCreateNetwork: returns %Vrc\n", rc));1433 LogFlow(("intnetCreateNetwork: returns %Vrc\n", rc)); 1434 1434 return rc; 1435 1435 } … … 1508 1508 */ 1509 1509 PINTNETNETWORK pNetwork; 1510 rc = INTNETOpenNetwork(pIntNet, pSession, pszNetwork, &pNetwork);1510 rc = intnetOpenNetwork(pIntNet, pSession, pszNetwork, &pNetwork); 1511 1511 if (rc == VERR_FILE_NOT_FOUND) 1512 rc = INTNETCreateNetwork(pIntNet, pSession, pszNetwork, !(fFlags & INTNET_OPEN_FLAGS_PUBLIC), &pNetwork);1512 rc = intnetCreateNetwork(pIntNet, pSession, pszNetwork, !(fFlags & INTNET_OPEN_FLAGS_PUBLIC), &pNetwork); 1513 1513 if (VBOX_SUCCESS(rc)) 1514 1514 { … … 1518 1518 * interface is destroyed or the last session is doing cleanup (order problems). 1519 1519 */ 1520 rc = INTNETNetworkCreateIf(pNetwork, pSession, cbSend, cbRecv, phIf);1520 rc = intnetNetworkCreateIf(pNetwork, pSession, cbSend, cbRecv, phIf); 1521 1521 if (VBOX_FAILURE(rc)) 1522 INTNETNetworkClose(pNetwork, pSession);1522 intnetNetworkClose(pNetwork, pSession); 1523 1523 } 1524 1524
Note:
See TracChangeset
for help on using the changeset viewer.