Changeset 88756 in vbox for trunk/src/VBox
- Timestamp:
- Apr 28, 2021 8:42:47 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageNATNetwork.cpp
r88755 r88756 174 174 175 175 const char *pNetName = NULL; 176 const char *pNetworkCidr = NULL; 176 const char *pPrefixIPv4 = NULL; 177 const char *pPrefixIPv6 = NULL; 177 178 int enable = -1; 178 179 int dhcp = -1; … … 187 188 LONG loopback6Offset = 0; /* ignore me */ 188 189 190 #define NATNET_CMD_OPT_IPV6_PREFIX (256 + '6') 189 191 static const RTGETOPTDEF g_aNATNetworkIPOptions[] = 190 192 { 191 { "--netname", 't', RTGETOPT_REQ_STRING }, 192 { "--network", 'n', RTGETOPT_REQ_STRING }, 193 { "--dhcp", 'h', RTGETOPT_REQ_BOOL }, 194 { "--ipv6", '6', RTGETOPT_REQ_BOOL }, 195 { "--enable", 'e', RTGETOPT_REQ_NOTHING }, 196 { "--disable", 'd', RTGETOPT_REQ_NOTHING }, 197 { "--port-forward-4", 'p', RTGETOPT_REQ_STRING }, 198 { "--port-forward-6", 'P', RTGETOPT_REQ_STRING }, 199 { "--loopback-4", 'l', RTGETOPT_REQ_STRING }, 200 { "--loopback-6", 'L', RTGETOPT_REQ_STRING }, 193 { "--netname", 't', RTGETOPT_REQ_STRING }, 194 { "--network", 'n', RTGETOPT_REQ_STRING }, /* old name */ 195 { "--ipv4-prefix", 'n', RTGETOPT_REQ_STRING }, /* new name */ 196 { "--dhcp", 'h', RTGETOPT_REQ_BOOL }, 197 { "--ipv6", '6', RTGETOPT_REQ_BOOL }, /* old name */ 198 { "--ipv6-enable", '6', RTGETOPT_REQ_BOOL }, /* new name */ 199 { "--ipv6-prefix", NATNET_CMD_OPT_IPV6_PREFIX, RTGETOPT_REQ_STRING }, 200 { "--enable", 'e', RTGETOPT_REQ_NOTHING }, 201 { "--disable", 'd', RTGETOPT_REQ_NOTHING }, 202 { "--port-forward-4", 'p', RTGETOPT_REQ_STRING }, 203 { "--port-forward-6", 'P', RTGETOPT_REQ_STRING }, 204 { "--loopback-4", 'l', RTGETOPT_REQ_STRING }, 205 { "--loopback-6", 'L', RTGETOPT_REQ_STRING }, 201 206 }; 202 207 … … 218 223 219 224 case 'n': // --network 220 if (p NetworkCidr)225 if (pPrefixIPv4) 221 226 return errorSyntax(USAGE_NATNETWORK, "You can only specify --network only once."); 222 p NetworkCidr= ValueUnion.psz;227 pPrefixIPv4 = ValueUnion.psz; 223 228 break; 224 229 … … 245 250 return errorSyntax(USAGE_NATNETWORK, "You can specify --ipv6 only once."); 246 251 ipv6 = ValueUnion.f; 252 break; 253 254 case NATNET_CMD_OPT_IPV6_PREFIX: 255 if (pPrefixIPv6) 256 return errorSyntax(USAGE_NATNETWORK, "You can specify --ipv6-prefix only once."); 257 pPrefixIPv6 = ValueUnion.psz; 247 258 break; 248 259 … … 330 341 { 331 342 case OP_ADD: 332 if (!p NetworkCidr)343 if (!pPrefixIPv4) 333 344 return errorSyntax(USAGE_NATNETWORK, "You need to specify the --network option"); 334 345 break; … … 365 376 case OP_MODIFY: 366 377 { 367 if (p NetworkCidr)368 { 369 CHECK_ERROR(net, COMSETTER(Network)(Bstr(p NetworkCidr).raw()));378 if (pPrefixIPv4) 379 { 380 CHECK_ERROR(net, COMSETTER(Network)(Bstr(pPrefixIPv4).raw())); 370 381 if (FAILED(rc)) 371 382 return errorArgument("Failed to set configuration"); … … 378 389 } 379 390 380 if (ipv6 >= 0) 381 { 382 CHECK_ERROR(net, COMSETTER(IPv6Enabled) ((BOOL)ipv6)); 391 /* 392 * If we are asked to disable IPv6, do it early so that 393 * the same command can also set IPv6 prefix to empty if 394 * it so wishes. 395 */ 396 if (ipv6 == 0) 397 { 398 CHECK_ERROR(net, COMSETTER(IPv6Enabled)(FALSE)); 399 if (FAILED(rc)) 400 return errorArgument("Failed to set configuration"); 401 } 402 403 if (pPrefixIPv6) 404 { 405 CHECK_ERROR(net, COMSETTER(IPv6Prefix)(Bstr(pPrefixIPv6).raw())); 406 if (FAILED(rc)) 407 return errorArgument("Failed to set configuration"); 408 } 409 410 /* 411 * If we are asked to enable IPv6, do it late, so that the 412 * same command can also set IPv6 prefix. 413 */ 414 if (ipv6 > 0) 415 { 416 CHECK_ERROR(net, COMSETTER(IPv6Enabled)(TRUE)); 383 417 if (FAILED(rc)) 384 418 return errorArgument("Failed to set configuration");
Note:
See TracChangeset
for help on using the changeset viewer.