Changeset 92372 in vbox for trunk/src/VBox/Frontends/VBoxManage/VBoxManageDHCPServer.cpp
- Timestamp:
- Nov 11, 2021 2:45:18 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 148226
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDHCPServer.cpp
r86820 r92372 44 44 using namespace com; 45 45 46 DECLARE_TRANSLATION_CONTEXT(DHCPServer); 46 47 47 48 /********************************************************************************************************************************* … … 61 62 case DHCPD_CMD_COMMON_OPT_NETWORK: \ 62 63 if ((a_pCtx)->pszInterface != NULL) \ 63 return errorSyntax( "Either --network or --interface, not both"); \64 return errorSyntax(DHCPServer::tr("Either --network or --interface, not both")); \ 64 65 (a_pCtx)->pszNetwork = ValueUnion.psz; \ 65 66 break; \ 66 67 case DHCPD_CMD_COMMON_OPT_INTERFACE: \ 67 68 if ((a_pCtx)->pszNetwork != NULL) \ 68 return errorSyntax( "Either --interface or --network, not both"); \69 return errorSyntax(DHCPServer::tr("Either --interface or --network, not both")); \ 69 70 (a_pCtx)->pszInterface = ValueUnion.psz; \ 70 71 break … … 176 177 if (FAILED(hrc)) 177 178 { 178 errorArgument( "Failed to locate host-only interface '%s'", pCtx->pszInterface);179 errorArgument(DHCPServer::tr("Failed to locate host-only interface '%s'"), pCtx->pszInterface); 179 180 return ptrRet; 180 181 } … … 190 191 return ptrRet; 191 192 if (pCtx->pszNetwork) 192 errorArgument( "Failed to find DHCP server for network '%s'", pCtx->pszNetwork);193 errorArgument(DHCPServer::tr("Failed to find DHCP server for network '%s'"), pCtx->pszNetwork); 193 194 else 194 errorArgument( "Failed to find DHCP server for host-only interface '%s' (network '%ls')",195 errorArgument(DHCPServer::tr("Failed to find DHCP server for host-only interface '%s' (network '%ls')"), 195 196 pCtx->pszInterface, bstrNetName.raw()); 196 197 } 197 198 else 198 errorSyntax( "You need to specify either --network or --interface to identify the DHCP server");199 errorSyntax(DHCPServer::tr("You need to specify either --network or --interface to identify the DHCP server")); 199 200 return ptrRet; 200 201 } … … 470 471 case 'g': // --global Sets the option scope to 'global'. 471 472 if (fNeedValueOrRemove) 472 return errorSyntax( "Incomplete option sequence preseeding '--global'");473 return errorSyntax(DHCPServer::tr("Incomplete option sequence preseeding '--global'")); 473 474 Scope.setGlobal(); 474 475 break; … … 476 477 case 'G': // --group 477 478 if (fNeedValueOrRemove) 478 return errorSyntax( "Incomplete option sequence preseeding '--group'");479 return errorSyntax(DHCPServer::tr("Incomplete option sequence preseeding '--group'")); 479 480 if (!*ValueUnion.psz) 480 return errorSyntax( "Group name cannot be empty");481 return errorSyntax(DHCPServer::tr("Group name cannot be empty")); 481 482 Scope.setGroup(ValueUnion.psz); 482 483 break; … … 484 485 case 'E': // --mac-address 485 486 if (fNeedValueOrRemove) 486 return errorSyntax( "Incomplete option sequence preseeding '--mac-address'");487 return errorSyntax(DHCPServer::tr("Incomplete option sequence preseeding '--mac-address'")); 487 488 RTStrPrintf(szMACAddress, sizeof(szMACAddress), "%RTmac", &ValueUnion.MacAddr); 488 489 Scope.setMACAddress(szMACAddress); … … 491 492 case 'M': // --vm Sets the option scope to ValueUnion.psz + 0. 492 493 if (fNeedValueOrRemove) 493 return errorSyntax( "Incomplete option sequence preseeding '--vm'");494 return errorSyntax(DHCPServer::tr("Incomplete option sequence preseeding '--vm'")); 494 495 Scope.setMachineNIC(ValueUnion.psz); 495 496 break; … … 497 498 case 'n': // --nic Sets the option scope to pszVmName + (ValueUnion.u8 - 1). 498 499 if (Scope.getScope() != DHCPConfigScope_MachineNIC) 499 return errorSyntax( "--nic option requires a --vm preceeding selecting the VM it should apply to");500 return errorSyntax(DHCPServer::tr("--nic option requires a --vm preceeding selecting the VM it should apply to")); 500 501 if (fNeedValueOrRemove) 501 return errorSyntax( "Incomplete option sequence preseeding '--nic=%u", ValueUnion.u8);502 return errorSyntax(DHCPServer::tr("Incomplete option sequence preseeding '--nic=%u"), ValueUnion.u8); 502 503 if (ValueUnion.u8 < 1) 503 return errorSyntax( "invalid NIC number: %u", ValueUnion.u8);504 return errorSyntax(DHCPServer::tr("invalid NIC number: %u"), ValueUnion.u8); 504 505 Scope.setMachineSlot(ValueUnion.u8 - 1); 505 506 break; … … 536 537 NULL, &cbRet); 537 538 if (RT_FAILURE(vrc)) 538 return errorArgument("Malformed hex string given to --set-opt-hex %u: %s\n", idAddOpt, ValueUnion.psz); 539 return errorArgument(DHCPServer::tr("Malformed hex string given to --set-opt-hex %u: %s\n"), 540 idAddOpt, ValueUnion.psz); 539 541 if (iPass == 1) 540 542 { … … 550 552 case 'D': // --del-opt num 551 553 if (pCtx->pCmdDef->fSubcommandScope == HELP_SCOPE_DHCPSERVER_ADD) 552 return errorSyntax( "--del-opt does not apply to the 'add' subcommand");554 return errorSyntax(DHCPServer::tr("--del-opt does not apply to the 'add' subcommand")); 553 555 if (iPass == 1) 554 556 { … … 562 564 case DHCP_ADDMOD_UNFORCE_OPTION: // --unforce-opt 563 565 if (pCtx->pCmdDef->fSubcommandScope == HELP_SCOPE_DHCPSERVER_ADD) 564 return errorSyntax( "--unforce-opt does not apply to the 'add' subcommand");566 return errorSyntax(DHCPServer::tr("--unforce-opt does not apply to the 'add' subcommand")); 565 567 RT_FALL_THROUGH(); 566 568 case DHCP_ADDMOD_UNSUPPRESS_OPTION: // --unsupress-opt 567 569 if (pCtx->pCmdDef->fSubcommandScope == HELP_SCOPE_DHCPSERVER_ADD) 568 return errorSyntax( "--unsuppress-opt does not apply to the 'add' subcommand");570 return errorSyntax(DHCPServer::tr("--unsuppress-opt does not apply to the 'add' subcommand")); 569 571 RT_FALL_THROUGH(); 570 572 case DHCP_ADDMOD_FORCE_OPTION: // --force-opt … … 624 626 case DHCP_ADDMOD_ZAP_OPTIONS: 625 627 if (pCtx->pCmdDef->fSubcommandScope == HELP_SCOPE_DHCPSERVER_ADD) 626 return errorSyntax( "--zap-options does not apply to the 'add' subcommand");628 return errorSyntax(DHCPServer::tr("--zap-options does not apply to the 'add' subcommand")); 627 629 if (iPass == 1) 628 630 { … … 666 668 case 'R': // --remove-config 667 669 if (pCtx->pCmdDef->fSubcommandScope == HELP_SCOPE_DHCPSERVER_ADD) 668 return errorSyntax( "--remove-config does not apply to the 'add' subcommand");670 return errorSyntax(DHCPServer::tr("--remove-config does not apply to the 'add' subcommand")); 669 671 if (Scope.getScope() == DHCPConfigScope_Global) 670 return errorSyntax( "--remove-config cannot be applied to the global config");672 return errorSyntax(DHCPServer::tr("--remove-config cannot be applied to the global config")); 671 673 if (iPass == 1) 672 674 { … … 681 683 case 'f': // --fixed-address 682 684 if (Scope.getScope() != DHCPConfigScope_MachineNIC && Scope.getScope() != DHCPConfigScope_MAC) 683 return errorSyntax( "--fixed-address can only be applied to a VM NIC or an MAC address");685 return errorSyntax(DHCPServer::tr("--fixed-address can only be applied to a VM NIC or an MAC address")); 684 686 if (iPass == 1) 685 687 { … … 715 717 { 716 718 if (Scope.getScope() != DHCPConfigScope_Group) 717 return errorSyntax( "A group must be selected to perform condition alterations.");719 return errorSyntax(DHCPServer::tr("A group must be selected to perform condition alterations.")); 718 720 if (!*ValueUnion.psz) 719 return errorSyntax( "Condition value cannot be empty"); /* or can it? */721 return errorSyntax(DHCPServer::tr("Condition value cannot be empty")); /* or can it? */ 720 722 if (iPass != 1) 721 723 break; … … 810 812 } 811 813 if (!fFound) 812 rcExit = RTMsgErrorExitFailure( "Could not find any condition of type %d with value '%s' to delete",814 rcExit = RTMsgErrorExitFailure(DHCPServer::tr("Could not find any condition of type %d with value '%s' to delete"), 813 815 enmType, ValueUnion.psz); 814 816 } … … 818 820 case DHCP_ADDMOD_ZAP_CONDITIONS: 819 821 if (Scope.getScope() != DHCPConfigScope_Group) 820 return errorSyntax( "--zap-conditions can only be with a group selected");822 return errorSyntax(DHCPServer::tr("--zap-conditions can only be with a group selected")); 821 823 if (iPass == 1) 822 824 { … … 837 839 case 'i': // --id 838 840 if (fNeedValueOrRemove) 839 return errorSyntax( "Incomplete option sequence preseeding '--id=%u", ValueUnion.u8);841 return errorSyntax(DHCPServer::tr("Incomplete option sequence preseeding '--id=%u"), ValueUnion.u8); 840 842 u8OptId = ValueUnion.u8; 841 843 fNeedValueOrRemove = true; … … 844 846 case 'p': // --value 845 847 if (!fNeedValueOrRemove) 846 return errorSyntax( "--value without --id=dhcp-opt-no");848 return errorSyntax(DHCPServer::tr("--value without --id=dhcp-opt-no")); 847 849 if (iPass == 1) 848 850 { … … 858 860 case 'r': // --remove 859 861 if (pCtx->pCmdDef->fSubcommandScope == HELP_SCOPE_DHCPSERVER_ADD) 860 return errorSyntax( "--remove does not apply to the 'add' subcommand");862 return errorSyntax(DHCPServer::tr("--remove does not apply to the 'add' subcommand")); 861 863 if (!fNeedValueOrRemove) 862 return errorSyntax( "--remove without --id=dhcp-opt-no");864 return errorSyntax(DHCPServer::tr("--remove without --id=dhcp-opt-no")); 863 865 864 866 if (iPass == 1) … … 885 887 */ 886 888 if (!pCtx->pszNetwork && !pCtx->pszInterface) 887 return errorSyntax( "You need to specify either --network or --interface to identify the DHCP server");889 return errorSyntax(DHCPServer::tr("You need to specify either --network or --interface to identify the DHCP server")); 888 890 889 891 if (pCtx->pCmdDef->fSubcommandScope == HELP_SCOPE_DHCPSERVER_ADD) 890 892 { 891 893 if (!pszServerIp) 892 rcExit = errorSyntax( "Missing required option: --ip");894 rcExit = errorSyntax(DHCPServer::tr("Missing required option: --ip")); 893 895 if (!pszNetmask) 894 rcExit = errorSyntax( "Missing required option: --netmask");896 rcExit = errorSyntax(DHCPServer::tr("Missing required option: --netmask")); 895 897 if (!pszLowerIp) 896 rcExit = errorSyntax( "Missing required option: --lowerip");898 rcExit = errorSyntax(DHCPServer::tr("Missing required option: --lowerip")); 897 899 if (!pszUpperIp) 898 rcExit = errorSyntax( "Missing required option: --upperip");900 rcExit = errorSyntax(DHCPServer::tr("Missing required option: --upperip")); 899 901 if (rcExit != RTEXITCODE_SUCCESS) 900 902 return rcExit; … … 914 916 CHECK_ERROR(host, FindHostNetworkInterfaceByName(Bstr(pCtx->pszInterface).mutableRaw(), hif.asOutParam())); 915 917 if (FAILED(rc)) 916 return errorArgument( "Could not find interface '%s'", pCtx->pszInterface);918 return errorArgument(DHCPServer::tr("Could not find interface '%s'"), pCtx->pszInterface); 917 919 918 920 CHECK_ERROR(hif, COMGETTER(NetworkName) (NetName.asOutParam())); 919 921 if (FAILED(rc)) 920 return errorArgument( "Could not get network name for the interface '%s'", pCtx->pszInterface);922 return errorArgument(DHCPServer::tr("Could not get network name for the interface '%s'"), pCtx->pszInterface); 921 923 } 922 924 else … … 929 931 { 930 932 if (SUCCEEDED(rc)) 931 return errorArgument( "DHCP server already exists");933 return errorArgument(DHCPServer::tr("DHCP server already exists")); 932 934 933 935 CHECK_ERROR(pCtx->pArg->virtualBox, CreateDHCPServer(NetName.mutableRaw(), ptrDHCPServer.asOutParam())); 934 936 if (FAILED(rc)) 935 return errorArgument( "Failed to create the DHCP server");937 return errorArgument(DHCPServer::tr("Failed to create the DHCP server")); 936 938 } 937 939 else if (FAILED(rc)) 938 return errorArgument( "DHCP server does not exist");940 return errorArgument(DHCPServer::tr("DHCP server does not exist")); 939 941 940 942 /* … … 968 970 CHECK_ERROR2_STMT(hrc, ptrDHCPServer, SetConfiguration(bstrServerIp.raw(), bstrNetmask.raw(), 969 971 bstrLowerIp.raw(), bstrUpperIp.raw()), 970 rcExit = errorArgument( "Failed to set configuration (%ls, %ls, %ls, %ls)", bstrServerIp.raw(),972 rcExit = errorArgument(DHCPServer::tr("Failed to set configuration (%ls, %ls, %ls, %ls)"), bstrServerIp.raw(), 971 973 bstrNetmask.raw(), bstrLowerIp.raw(), bstrUpperIp.raw())); 972 974 } … … 1020 1022 if (SUCCEEDED(hrc)) 1021 1023 return RTEXITCODE_SUCCESS; 1022 errorArgument( "Failed to remove server");1024 errorArgument(DHCPServer::tr("Failed to remove server")); 1023 1025 } 1024 1026 return RTEXITCODE_FAILURE; … … 1087 1089 if (SUCCEEDED(hrc)) 1088 1090 return RTEXITCODE_SUCCESS; 1089 errorArgument( "Failed to start the server");1091 errorArgument(DHCPServer::tr("Failed to start the server")); 1090 1092 GlueHandleComErrorNoCtx(ptrDHCPServer, hrc); 1091 1093 } … … 1131 1133 if (SUCCEEDED(hrc)) 1132 1134 return RTEXITCODE_SUCCESS; 1133 errorArgument( "Failed to restart the server");1135 errorArgument(DHCPServer::tr("Failed to restart the server")); 1134 1136 GlueHandleComErrorNoCtx(ptrDHCPServer, hrc); 1135 1137 } … … 1175 1177 if (SUCCEEDED(hrc)) 1176 1178 return RTEXITCODE_SUCCESS; 1177 errorArgument( "Failed to stop the server");1179 errorArgument(DHCPServer::tr("Failed to stop the server")); 1178 1180 GlueHandleComErrorNoCtx(ptrDHCPServer, hrc); 1179 1181 } … … 1222 1224 1223 1225 if (!fHaveMacAddress) 1224 return errorSyntax( "You need to specify a MAC address too look for");1226 return errorSyntax(DHCPServer::tr("You need to specify a MAC address too look for")); 1225 1227 1226 1228 /* … … 1250 1252 RTTimeToStringEx(RTTimeExplode(&Time, RTTimeSpecSetSeconds(&TimeSpec, secExpire)), szExpire, sizeof(szExpire), 0); 1251 1253 1252 RTPrintf( "IP Address: %ls\n"1253 "MAC Address: %RTmac\n"1254 "State: %ls\n"1255 "Issued: %s (%RU64)\n"1256 "Expire: %s (%RU64)\n"1257 "TTL: %RU64 sec, currently %RU64 sec left\n",1254 RTPrintf(DHCPServer::tr("IP Address: %ls\n" 1255 "MAC Address: %RTmac\n" 1256 "State: %ls\n" 1257 "Issued: %s (%RU64)\n" 1258 "Expire: %s (%RU64)\n" 1259 "TTL: %RU64 sec, currently %RU64 sec left\n"), 1258 1260 bstrAddress.raw(), 1259 1261 &MacAddress, … … 1330 1332 return errorNoSubcommand(); 1331 1333 } 1332
Note:
See TracChangeset
for help on using the changeset viewer.