Changeset 36084 in vbox
- Timestamp:
- Feb 25, 2011 1:01:42 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvIntNet.cpp
r36082 r36084 1231 1231 1232 1232 /** 1233 * Queries the 'fixed' policy config value and sets the corresponding flag.1234 *1235 * @returns VBox status code (error set on failure).1236 * @param pDrvIns The driver instance.1237 * @param pszName The value name.1238 * @param fFixedFlag The open network flag.1239 * @param pfFlags The flags variable to update.1240 */1241 static int drvIntNetR3CfgFixedPolicy(PPDMDRVINS pDrvIns, const char *pszName, uint32_t fFixedFlag, uint32_t *pfFlags)1242 {1243 bool fFixed;1244 int rc = CFGMR3QueryBoolDef(pDrvIns->pCfg, pszName, &fFixed, false /*fDef*/);1245 if (RT_SUCCESS(rc))1246 {1247 if (fFixed)1248 *pfFlags |= fFixedFlag;1249 }1250 else1251 rc = PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS,1252 N_("Configuration error: Failed to query the value of \"%s\""), pszName);1253 return rc;1254 }1255 1256 1257 /**1258 1233 * Queries a policy config value and translates it into open network flag. 1259 1234 * … … 1263 1238 * @param paFlags The open network flag descriptors. 1264 1239 * @param cFlags The number of descriptors. 1240 * @param fFlags The fixed flag. 1265 1241 * @param pfFlags The flags variable to update. 1266 1242 */ 1267 static int drvIntNetR3CfgGetPolicy(PPDMDRVINS pDrvIns, const char *pszName, PCDRVINTNETFLAG paFlags, size_t cFlags, uint32_t *pfFlags) 1243 static int drvIntNetR3CfgGetPolicy(PPDMDRVINS pDrvIns, const char *pszName, PCDRVINTNETFLAG paFlags, size_t cFlags, 1244 uint32_t fFixedFlag, uint32_t *pfFlags) 1268 1245 { 1269 1246 char szValue[64]; 1270 1247 int rc = CFGMR3QueryString(pDrvIns->pCfg, pszName, szValue, sizeof(szValue)); 1271 if (RT_SUCCESS(rc)) 1272 { 1273 size_t i = cFlags; 1274 while (i-- > 0) 1275 if (!strcmp(paFlags[i].pszChoice, szValue)) 1276 { 1277 *pfFlags |= paFlags[i].fFlag; 1278 return VINF_SUCCESS; 1279 } 1280 if (!strcmp(szValue, "none")) 1248 if (RT_FAILURE(rc)) 1249 { 1250 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 1281 1251 return VINF_SUCCESS; 1282 1283 rc = PDMDrvHlpVMSetError(pDrvIns, VERR_INVALID_PARAMETER, RT_SRC_POS, 1284 N_("Configuration error: The value of \"%s\" is unknown: \"%s\""), pszName, szValue); 1285 } 1286 else if (rc == VERR_CFGM_VALUE_NOT_FOUND) 1252 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, 1253 N_("Configuration error: Failed to query value of \"%s\""), pszName); 1254 } 1255 1256 /* 1257 * Check for +fixed first, so it can be stripped off. 1258 */ 1259 char *pszSep = strpbrk(szValue, "+,;"); 1260 if (*pszSep) 1261 { 1262 *pszSep++ = '\0'; 1263 const char *pszFixed = RTStrStripL(pszSep); 1264 if (strcmp(pszFixed, "fixed")) 1265 { 1266 *pszSep = '+'; 1267 return PDMDrvHlpVMSetError(pDrvIns, VERR_INVALID_PARAMETER, RT_SRC_POS, 1268 N_("Configuration error: The value of \"%s\" is unknown: \"%s\""), pszName, szValue); 1269 } 1270 *pfFlags |= fFixedFlag; 1271 RTStrStripR(szValue); 1272 } 1273 1274 /* 1275 * Match against the flag values. 1276 */ 1277 size_t i = cFlags; 1278 while (i-- > 0) 1279 if (!strcmp(paFlags[i].pszChoice, szValue)) 1280 { 1281 *pfFlags |= paFlags[i].fFlag; 1282 return VINF_SUCCESS; 1283 } 1284 1285 if (!strcmp(szValue, "none")) 1287 1286 return VINF_SUCCESS; 1288 else 1289 rc = PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, 1290 N_("Configuration error: Failed to query value of \"%s\""), pszName); 1291 return rc; 1287 1288 if (!strcmp(szValue, "fixed")) 1289 { 1290 *pfFlags |= fFixedFlag; 1291 return VINF_SUCCESS; 1292 } 1293 1294 return PDMDrvHlpVMSetError(pDrvIns, VERR_INVALID_PARAMETER, RT_SRC_POS, 1295 N_("Configuration error: The value of \"%s\" is unknown: \"%s\""), pszName, szValue); 1292 1296 } 1293 1297 … … 1347 1351 "|RequireAsRestrictivePolicy" 1348 1352 "|AccessPolicy" 1349 "|AccessPolicyFixed"1350 1353 "|PromiscPolicyClients" 1351 1354 "|PromiscPolicyHost" 1352 1355 "|PromiscPolicyWire" 1353 "|PromiscPolicyFixed"1354 1356 "|IfPolicyPromisc" 1355 "|IfPolicyFixed"1356 1357 "|TrunkPolicyHost" 1357 1358 "|TrunkPolicyWire" 1358 "|TrunkPolicyFixed"1359 1359 "|IsService" 1360 1360 "|IgnoreConnectFailure", … … 1453 1453 1454 1454 /** @cfgm{AccessPolicy, string, "none"} 1455 * The access policy of the network: public, restricted or none. A 1456 * "public" network is accessible to everyone on the same host, while a 1455 * The access policy of the network: 1456 * public, public+fixed, restricted, restricted+fixed, none or fixed. 1457 * 1458 * A "public" network is accessible to everyone on the same host, while a 1457 1459 * "restricted" one is only accessible to VMs & services started by the 1458 1460 * same user. The "none" policy, which is the default, means no policy … … 1465 1467 }; 1466 1468 rc = drvIntNetR3CfgGetPolicy(pDrvIns, "AccessPolicy", &s_aAccessPolicyFlags[0], RT_ELEMENTS(s_aAccessPolicyFlags), 1467 &OpenReq.fFlags); 1468 AssertRCReturn(rc, rc); 1469 /** @cfgm{AccessPolicyFixed, boolean, false} 1470 * Whether the access policy is to be locked against further changes. */ 1471 rc = drvIntNetR3CfgFixedPolicy(pDrvIns, "AccessPolicyFixed", INTNET_OPEN_FLAGS_ACCESS_FIXED, &OpenReq.fFlags); 1469 INTNET_OPEN_FLAGS_ACCESS_FIXED, &OpenReq.fFlags); 1472 1470 AssertRCReturn(rc, rc); 1473 1471 1474 1472 /** @cfgm{PromiscPolicyClients, string, "none"} 1475 1473 * The network wide promiscuous mode policy for client (non-trunk) 1476 * interfaces: allow, deny, none. */1474 * interfaces: allow, allow+fixed, deny, deny+fixed, none or fixed. */ 1477 1475 static const DRVINTNETFLAG s_aPromiscPolicyClient[] = 1478 1476 { … … 1481 1479 }; 1482 1480 rc = drvIntNetR3CfgGetPolicy(pDrvIns, "PromiscPolicyClients", &s_aPromiscPolicyClient[0], RT_ELEMENTS(s_aPromiscPolicyClient), 1483 &OpenReq.fFlags);1481 INTNET_OPEN_FLAGS_PROMISC_FIXED, &OpenReq.fFlags); 1484 1482 AssertRCReturn(rc, rc); 1485 1483 /** @cfgm{PromiscPolicyHost, string, "none"} 1486 1484 * The promiscuous mode policy for the trunk-host 1487 * connection: allow, deny, none. */1485 * connection: allow, allow+fixed, deny, deny+fixed, none or fixed. */ 1488 1486 static const DRVINTNETFLAG s_aPromiscPolicyHost[] = 1489 1487 { … … 1492 1490 }; 1493 1491 rc = drvIntNetR3CfgGetPolicy(pDrvIns, "PromiscPolicyHost", &s_aPromiscPolicyHost[0], RT_ELEMENTS(s_aPromiscPolicyHost), 1494 &OpenReq.fFlags);1492 INTNET_OPEN_FLAGS_PROMISC_FIXED, &OpenReq.fFlags); 1495 1493 AssertRCReturn(rc, rc); 1496 1494 /** @cfgm{PromiscPolicyWire, string, "none"} 1497 1495 * The promiscuous mode policy for the trunk-host 1498 * connection: allow, deny, none. */1496 * connection: allow, allow+fixed, deny, deny+fixed, none or fixed. */ 1499 1497 static const DRVINTNETFLAG s_aPromiscPolicyWire[] = 1500 1498 { … … 1503 1501 }; 1504 1502 rc = drvIntNetR3CfgGetPolicy(pDrvIns, "PromiscPolicyWire", &s_aPromiscPolicyWire[0], RT_ELEMENTS(s_aPromiscPolicyWire), 1505 &OpenReq.fFlags); 1506 AssertRCReturn(rc, rc); 1507 /** @cfgm{PromiscPolicyFixed, boolean, false} 1508 * Whether the promiscuous mode policies are to be locked against further 1509 * changes. */ 1510 rc = drvIntNetR3CfgFixedPolicy(pDrvIns, "PromiscPolicyFixed", INTNET_OPEN_FLAGS_PROMISC_FIXED, &OpenReq.fFlags); 1503 INTNET_OPEN_FLAGS_PROMISC_FIXED, &OpenReq.fFlags); 1511 1504 AssertRCReturn(rc, rc); 1512 1505 … … 1514 1507 /** @cfgm{IfPolicyPromisc, string, "none"} 1515 1508 * The promiscuous mode policy for this 1516 * interface: deny, allow-all, allow-network, none. */ 1509 * interface: deny, deny+fixed, allow-all, allow-all+fixed, allow-network, 1510 * allow-network+fixed, none or fixed. */ 1517 1511 static const DRVINTNETFLAG s_aIfPolicyPromisc[] = 1518 1512 { 1519 1513 { "allow-all", INTNET_OPEN_FLAGS_IF_PROMISC_ALLOW | INTNET_OPEN_FLAGS_IF_PROMISC_SEE_TRUNK }, 1520 1514 { "allow-network", INTNET_OPEN_FLAGS_IF_PROMISC_ALLOW | INTNET_OPEN_FLAGS_IF_PROMISC_NO_TRUNK }, 1521 { "deny", INTNET_OPEN_FLAGS_IF_PROMISC_DENY 1515 { "deny", INTNET_OPEN_FLAGS_IF_PROMISC_DENY } 1522 1516 }; 1523 1517 rc = drvIntNetR3CfgGetPolicy(pDrvIns, "IfPolicyPromisc", &s_aIfPolicyPromisc[0], RT_ELEMENTS(s_aIfPolicyPromisc), 1524 &OpenReq.fFlags);1518 INTNET_OPEN_FLAGS_IF_FIXED, &OpenReq.fFlags); 1525 1519 AssertRCReturn(rc, rc); 1526 1520 1527 /** @cfgm{IfPolicyFixed, boolean, false}1528 * Whether the interface policies are to be locked against further1529 * changes. */1530 rc = drvIntNetR3CfgFixedPolicy(pDrvIns, "IfPolicyFixed", INTNET_OPEN_FLAGS_IF_FIXED, &OpenReq.fFlags);1531 AssertRCReturn(rc, rc);1532 1533 1521 1534 1522 /** @cfgm{TrunkPolicyHost, string, "none"} 1535 * The trunk-host policy: enabled, disabled, non 1523 * The trunk-host policy: promisc, promisc+fixed, enabled, enabled+fixed, 1524 * disabled, disabled+fixed, none or fixed 1525 * 1536 1526 * This can be used to prevent packages to be routed to the host. */ 1537 1527 static const DRVINTNETFLAG s_aTrunkPolicyHost[] = 1538 1528 { 1539 { "enabled", INTNET_OPEN_FLAGS_TRUNK_HOST_ENABLED }, 1540 { "disabled", INTNET_OPEN_FLAGS_TRUNK_HOST_DISABLED } 1529 { "promisc", INTNET_OPEN_FLAGS_TRUNK_HOST_ENABLED | INTNET_OPEN_FLAGS_TRUNK_HOST_PROMISC_MODE }, 1530 { "enabled", INTNET_OPEN_FLAGS_TRUNK_HOST_ENABLED }, 1531 { "disabled", INTNET_OPEN_FLAGS_TRUNK_HOST_DISABLED } 1541 1532 }; 1542 1533 rc = drvIntNetR3CfgGetPolicy(pDrvIns, "TrunkPolicyHost", &s_aTrunkPolicyHost[0], RT_ELEMENTS(s_aTrunkPolicyHost), 1543 &OpenReq.fFlags);1534 INTNET_OPEN_FLAGS_TRUNK_FIXED, &OpenReq.fFlags); 1544 1535 AssertRCReturn(rc, rc); 1545 1536 /** @cfgm{TrunkPolicyWire, string, "none"} 1546 * The trunk-host policy: enabled, disabled, non 1547 * This can be used to prevent packages to be routed to the host. */ 1537 * The trunk-host policy: promisc, promisc+fixed, enabled, enabled+fixed, 1538 * disabled, disabled+fixed, none or fixed. 1539 * 1540 * This can be used to prevent packages to be routed to the wire. */ 1548 1541 static const DRVINTNETFLAG s_aTrunkPolicyWire[] = 1549 1542 { 1550 { "enabled", INTNET_OPEN_FLAGS_TRUNK_WIRE_ENABLED }, 1551 { "disabled", INTNET_OPEN_FLAGS_TRUNK_WIRE_DISABLED } 1543 { "promisc", INTNET_OPEN_FLAGS_TRUNK_WIRE_ENABLED | INTNET_OPEN_FLAGS_TRUNK_WIRE_PROMISC_MODE }, 1544 { "enabled", INTNET_OPEN_FLAGS_TRUNK_WIRE_ENABLED }, 1545 { "disabled", INTNET_OPEN_FLAGS_TRUNK_WIRE_DISABLED } 1552 1546 }; 1553 1547 rc = drvIntNetR3CfgGetPolicy(pDrvIns, "TrunkPolicyWire", &s_aTrunkPolicyWire[0], RT_ELEMENTS(s_aTrunkPolicyWire), 1554 &OpenReq.fFlags); 1555 AssertRCReturn(rc, rc); 1556 /** @cfgm{TrunkPolicyFixed, boolean, false} 1557 * Whether the trunk policies are to be locked against further changes. */ 1558 rc = drvIntNetR3CfgFixedPolicy(pDrvIns, "TrunkPolicyFixed", INTNET_OPEN_FLAGS_TRUNK_FIXED, &OpenReq.fFlags); 1548 INTNET_OPEN_FLAGS_TRUNK_FIXED, &OpenReq.fFlags); 1559 1549 AssertRCReturn(rc, rc); 1560 1550
Note:
See TracChangeset
for help on using the changeset viewer.