Changeset 10843 in vbox for trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp
- Timestamp:
- Jul 23, 2008 9:49:52 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp
r10819 r10843 1167 1167 1168 1168 /** 1169 * Sets the MAC address of an interface. 1170 * 1171 * @returns VBox status code. 1172 * @param pIntNet The instance handle. 1173 * @param hIf The interface handle. 1174 * @param pSession The caller's session. 1175 * @param pMAC The new MAC address. 1176 */ 1177 INTNETR0DECL(int) INTNETR0IfSetMacAddress(PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, PCPDMMAC pMac) 1178 { 1179 LogFlow(("INTNETR0IfSetMacAddress: pIntNet=%p hIf=%RX32 pMac=%p:{%.6Rhxs}\n", pIntNet, hIf, pMac, pMac)); 1180 1181 /* 1182 * Validate & translate input. 1183 */ 1184 AssertPtrReturn(pIntNet, VERR_INVALID_PARAMETER); 1185 AssertPtrReturn(pMac, VERR_INVALID_PARAMETER); 1186 PINTNETIF pIf = (PINTNETIF)RTHandleTableLookupWithCtx(pIntNet->hHtIfs, hIf, pSession); 1187 if (!pIf) 1188 { 1189 Log(("INTNETR0IfSetMacAddress: returns VERR_INVALID_HANDLE\n")); 1190 return VERR_INVALID_HANDLE; 1191 } 1192 1193 /* 1194 * Grab the network semaphore and make the change. 1195 */ 1196 int rc; 1197 PINTNETNETWORK pNetwork = pIf->pNetwork; 1198 if (pNetwork) 1199 { 1200 rc = RTSemFastMutexRequest(pNetwork->FastMutex); 1201 if (RT_SUCCESS(rc)) 1202 { 1203 if (memcmp(&pIf->Mac, pMac, sizeof(pIf->Mac))) 1204 { 1205 Log(("INTNETR0IfSetMacAddress: hIf=%RX32: Changed from %.6Rhxs -> %.6Rhxs\n", 1206 hIf, &pIf->Mac, pMac)); 1207 pIf->Mac = *pMac; 1208 pIf->fMacSet = true; 1209 } 1210 1211 rc = RTSemFastMutexRelease(pNetwork->FastMutex); 1212 } 1213 } 1214 else 1215 rc = VERR_WRONG_ORDER; 1216 1217 intnetR0IfRelease(pIf, pSession); 1218 return rc; 1219 } 1220 1221 1222 /** 1223 * VMMR0 request wrapper for INTNETR0IfSetMacAddress. 1224 * 1225 * @returns see INTNETR0IfSetMacAddress. 1226 * @param pIntNet The internal networking instance. 1227 * @param pSession The caller's session. 1228 * @param pReq The request packet. 1229 */ 1230 INTNETR0DECL(int) INTNETR0IfSetMacAddressReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETIFSETMACADDRESSREQ pReq) 1231 { 1232 if (RT_UNLIKELY(pReq->Hdr.cbReq != sizeof(*pReq))) 1233 return VERR_INVALID_PARAMETER; 1234 return INTNETR0IfSetMacAddress(pIntNet, pReq->hIf, pSession, &pReq->Mac); 1235 } 1236 1237 1238 /** 1169 1239 * Worker for intnetR0IfSetActive. 1170 1240 * … … 1256 1326 return VERR_WRONG_ORDER; 1257 1327 return intnetR0NetworkSetIfActive(pNetwork, pIf, fActive); 1328 } 1329 1330 1331 /** 1332 * Sets the active property of an interface. 1333 * 1334 * @returns VBox status code. 1335 * @param pIntNet The instance handle. 1336 * @param hIf The interface handle. 1337 * @param pSession The caller's session. 1338 * @param fActive The new state. 1339 */ 1340 INTNETR0DECL(int) INTNETR0IfSetActive(PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, bool fActive) 1341 { 1342 LogFlow(("INTNETR0IfSetActive: pIntNet=%p hIf=%RX32 fActive=%RTbool\n", pIntNet, hIf, fActive)); 1343 1344 /* 1345 * Validate & translate input. 1346 */ 1347 AssertPtrReturn(pIntNet, VERR_INVALID_PARAMETER); 1348 PINTNETIF pIf = (PINTNETIF)RTHandleTableLookupWithCtx(pIntNet->hHtIfs, hIf, pSession); 1349 if (!pIf) 1350 { 1351 Log(("INTNETR0IfSetActive: returns VERR_INVALID_HANDLE\n")); 1352 return VERR_INVALID_HANDLE; 1353 } 1354 1355 /* 1356 * Hand it to the network since it might involve the trunk 1357 * and things are tricky there wrt to locking order. 1358 */ 1359 int rc; 1360 PINTNETNETWORK pNetwork = pIf->pNetwork; 1361 if (pNetwork) 1362 rc = intnetR0NetworkSetIfActive(pNetwork, pIf, fActive); 1363 else 1364 rc = VERR_WRONG_ORDER; 1365 1366 intnetR0IfRelease(pIf, pSession); 1367 return rc; 1368 } 1369 1370 1371 /** 1372 * VMMR0 request wrapper for INTNETR0IfSetActive. 1373 * 1374 * @returns see INTNETR0IfSetActive. 1375 * @param pIntNet The internal networking instance. 1376 * @param pSession The caller's session. 1377 * @param pReq The request packet. 1378 */ 1379 INTNETR0DECL(int) INTNETR0IfSetActiveReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETIFSETACTIVEREQ pReq) 1380 { 1381 if (RT_UNLIKELY(pReq->Hdr.cbReq != sizeof(*pReq))) 1382 return VERR_INVALID_PARAMETER; 1383 return INTNETR0IfSetActive(pIntNet, pReq->hIf, pSession, pReq->fActive); 1258 1384 } 1259 1385
Note:
See TracChangeset
for help on using the changeset viewer.