VirtualBox

Changeset 79867 in vbox


Ignore:
Timestamp:
Jul 18, 2019 8:33:32 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
132265
Message:

VBoxManage/dhcpserver: Adding support for option forcing & suppression. bugref:9288

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/en_US/man_VBoxManage-dhcpserver.xml

    r79853 r79867  
    5252        <arg choice="opt" rep="repeat">--set-opt=<replaceable>dhcp-opt-no value</replaceable></arg>
    5353        <arg choice="opt" rep="repeat">--set-opt-hex=<replaceable>dhcp-opt-no hexstring</replaceable></arg>
     54        <arg choice="opt" rep="repeat">--force-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     55        <arg choice="opt" rep="repeat">--supress-opt=<replaceable>dhcp-opt-no</replaceable></arg>
    5456        <arg choice="opt">--min-lease-time=<replaceable>seconds</replaceable></arg>
    5557        <arg choice="opt">--default-lease-time=<replaceable>seconds</replaceable></arg>
     
    6163        <arg choice="opt" rep="repeat">--set-opt=<replaceable>dhcp-opt-no value</replaceable></arg>
    6264        <arg choice="opt" rep="repeat">--set-opt-hex=<replaceable>dhcp-opt-no hexstring</replaceable></arg>
     65        <arg choice="opt" rep="repeat">--force-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     66        <arg choice="opt" rep="repeat">--supress-opt=<replaceable>dhcp-opt-no</replaceable></arg>
    6367        <arg choice="opt" rep="repeat">--incl-mac=<replaceable>address</replaceable></arg>
    6468        <arg choice="opt" rep="repeat">--excl-mac=<replaceable>address</replaceable></arg>
     
    8387        <arg choice="opt" rep="repeat">--set-opt=<replaceable>dhcp-opt-no value</replaceable></arg>
    8488        <arg choice="opt" rep="repeat">--set-opt-hex=<replaceable>dhcp-opt-no hexstring</replaceable></arg>
     89        <arg choice="opt" rep="repeat">--force-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     90        <arg choice="opt" rep="repeat">--supress-opt=<replaceable>dhcp-opt-no</replaceable></arg>
    8591        <arg choice="opt">--min-lease-time=<replaceable>seconds</replaceable></arg>
    8692        <arg choice="opt">--default-lease-time=<replaceable>seconds</replaceable></arg>
     
    9399        <arg choice="opt" rep="repeat">--set-opt=<replaceable>dhcp-opt-no value</replaceable></arg>
    94100        <arg choice="opt" rep="repeat">--set-opt-hex=<replaceable>dhcp-opt-no hexstring</replaceable></arg>
     101        <arg choice="opt" rep="repeat">--force-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     102        <arg choice="opt" rep="repeat">--supress-opt=<replaceable>dhcp-opt-no</replaceable></arg>
    95103        <arg choice="opt">--min-lease-time=<replaceable>seconds</replaceable></arg>
    96104        <arg choice="opt">--default-lease-time=<replaceable>seconds</replaceable></arg>
     
    115123      <sbr/>
    116124      <arg choice="opt" rep="repeat">
     125        <arg choice="opt">--global</arg>
     126        <arg choice="opt" rep="repeat">--del-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     127        <arg choice="opt" rep="repeat">--set-opt=<replaceable>dhcp-opt-no value</replaceable></arg>
     128        <arg choice="opt" rep="repeat">--set-opt-hex=<replaceable>dhcp-opt-no hexstring</replaceable></arg>
     129        <arg choice="opt" rep="repeat">--force-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     130        <arg choice="opt" rep="repeat">--unforce-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     131        <arg choice="opt" rep="repeat">--supress-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     132        <arg choice="opt" rep="repeat">--unsupress-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     133        <arg choice="opt">--min-lease-time=<replaceable>seconds</replaceable></arg>
     134        <arg choice="opt">--default-lease-time=<replaceable>seconds</replaceable></arg>
     135        <arg choice="opt">--max-lease-time=<replaceable>seconds</replaceable></arg>
     136        <arg choice="opt">--remove-config</arg>
     137      </arg>
     138      <sbr/>
     139      <arg choice="opt" rep="repeat">
    117140        <arg choice="req">--group=<replaceable>name</replaceable></arg>
    118141        <arg choice="opt" rep="repeat">--set-opt=<replaceable>dhcp-opt-no value</replaceable></arg>
    119142        <arg choice="opt" rep="repeat">--set-opt-hex=<replaceable>dhcp-opt-no hexstring</replaceable></arg>
     143        <arg choice="opt" rep="repeat">--force-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     144        <arg choice="opt" rep="repeat">--unforce-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     145        <arg choice="opt" rep="repeat">--supress-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     146        <arg choice="opt" rep="repeat">--unsupress-opt=<replaceable>dhcp-opt-no</replaceable></arg>
    120147        <arg choice="opt" rep="repeat">--del-mac=<replaceable>address</replaceable></arg>
    121148        <arg choice="opt" rep="repeat">--incl-mac=<replaceable>address</replaceable></arg>
     
    144171      <sbr/>
    145172      <arg choice="opt" rep="repeat">
    146         <arg choice="opt">--global</arg>
    147         <arg choice="opt" rep="repeat">--del-opt=<replaceable>dhcp-opt-no</replaceable></arg>
    148         <arg choice="opt" rep="repeat">--set-opt=<replaceable>dhcp-opt-no value</replaceable></arg>
    149         <arg choice="opt" rep="repeat">--set-opt-hex=<replaceable>dhcp-opt-no hexstring</replaceable></arg>
    150         <arg choice="opt">--min-lease-time=<replaceable>seconds</replaceable></arg>
    151         <arg choice="opt">--default-lease-time=<replaceable>seconds</replaceable></arg>
    152         <arg choice="opt">--max-lease-time=<replaceable>seconds</replaceable></arg>
    153         <arg choice="opt">--remove-config</arg>
    154       </arg>
    155       <sbr/>
    156       <arg choice="opt" rep="repeat">
    157173        <arg choice="req">--vm=<replaceable>name|uuid</replaceable></arg>
    158174        <arg choice="opt">--nic=<replaceable>1-N</replaceable></arg>
     
    160176        <arg choice="opt" rep="repeat">--set-opt=<replaceable>dhcp-opt-no value</replaceable></arg>
    161177        <arg choice="opt" rep="repeat">--set-opt-hex=<replaceable>dhcp-opt-no hexstring</replaceable></arg>
     178        <arg choice="opt" rep="repeat">--force-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     179        <arg choice="opt" rep="repeat">--unforce-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     180        <arg choice="opt" rep="repeat">--supress-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     181        <arg choice="opt" rep="repeat">--unsupress-opt=<replaceable>dhcp-opt-no</replaceable></arg>
    162182        <arg choice="opt">--min-lease-time=<replaceable>seconds</replaceable></arg>
    163183        <arg choice="opt">--default-lease-time=<replaceable>seconds</replaceable></arg>
     
    172192        <arg choice="opt" rep="repeat">--set-opt=<replaceable>dhcp-opt-no value</replaceable></arg>
    173193        <arg choice="opt" rep="repeat">--set-opt-hex=<replaceable>dhcp-opt-no hexstring</replaceable></arg>
     194        <arg choice="opt" rep="repeat">--force-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     195        <arg choice="opt" rep="repeat">--unforce-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     196        <arg choice="opt" rep="repeat">--supress-opt=<replaceable>dhcp-opt-no</replaceable></arg>
     197        <arg choice="opt" rep="repeat">--unsupress-opt=<replaceable>dhcp-opt-no</replaceable></arg>
    174198        <arg choice="opt">--min-lease-time=<replaceable>seconds</replaceable></arg>
    175199        <arg choice="opt">--default-lease-time=<replaceable>seconds</replaceable></arg>
     
    324348        </varlistentry>
    325349        <varlistentry>
     350          <term><option>--force-opt=<replaceable>dhcp-opt-no</replaceable></option></term>
     351          <listitem><para>Forces the specified DHCP option number (0-255) onto to be
     352            sent to the client whether it requested it or not (provided the option is
     353            configured with a value at some level).
     354          </para></listitem>
     355        </varlistentry>
     356        <varlistentry>
     357          <term><option>--suppress-opt=<replaceable>dhcp-opt-no</replaceable></option></term>
     358          <listitem><para>Prevents the specified DHCP option number (0-255) from being
     359            sent to the client when present in this or a high configuration scope.
     360          </para></listitem>
     361        </varlistentry>
     362        <varlistentry>
    326363          <term><option>--min-lease-time=<replaceable>seconds</replaceable></option></term>
    327364          <listitem><para>Sets the minimum lease time for the current scope in seconds.
     
    424461        </varlistentry>
    425462        <varlistentry>
     463          <term><option>--unforce-opt=<replaceable>dhcp-opt-no</replaceable></option></term>
     464          <listitem><para>Removes the specified DHCP option number (0-255) from the forced
     465            option list (i.e. the reverse of <option>--force-opt</option>).  Like with
     466            <option>--set-opt</option> the scope of the deletion is governed by the
     467            <option>--global</option>, <option>--vm</option>, <option>--mac-address</option>
     468            and <option>--group</option> options.
     469          </para></listitem>
     470        </varlistentry>
     471        <varlistentry>
     472          <term><option>--unsuppress-opt=<replaceable>dhcp-opt-no</replaceable></option></term>
     473          <listitem><para>Removes the specified DHCP option number (0-255) from the supressed
     474            option list (i.e. the reverse of <option>--suppress-opt</option>). Like with
     475            <option>--set-opt</option> the scope of the deletion is governed by the
     476            <option>--global</option>, <option>--vm</option>, <option>--mac-address</option>
     477            and <option>--group</option> options.
     478          </para></listitem>
     479        </varlistentry>
     480        <varlistentry>
    426481          <term><option>--remove-config</option></term>
    427482          <listitem><para>Removes the configuration currently being scoped.  The
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDHCPServer.cpp

    r79845 r79867  
    316316{
    317317    DHCP_ADDMOD = 1000,
     318    DHCP_ADDMOD_FORCE_OPTION,
     319    DHCP_ADDMOD_UNFORCE_OPTION,
     320    DHCP_ADDMOD_SUPPRESS_OPTION,
     321    DHCP_ADDMOD_UNSUPPRESS_OPTION,
    318322    DHCP_ADDMOD_ZAP_OPTIONS,
    319323    DHCP_ADDMOD_INCL_MAC,
     
    369373        { "--set-opt-hex",      'x',                            RTGETOPT_REQ_UINT8   },
    370374        { "--del-opt",          'D',                            RTGETOPT_REQ_UINT8   },
     375        { "--force-opt",        DHCP_ADDMOD_FORCE_OPTION,       RTGETOPT_REQ_UINT8   },
     376        { "--unforce-opt",      DHCP_ADDMOD_UNFORCE_OPTION,     RTGETOPT_REQ_UINT8   },
     377        { "--suppress-opt",     DHCP_ADDMOD_SUPPRESS_OPTION,    RTGETOPT_REQ_UINT8   },
     378        { "--unsuppress-opt",   DHCP_ADDMOD_UNSUPPRESS_OPTION,  RTGETOPT_REQ_UINT8   },
    371379        { "--zap-options",      DHCP_ADDMOD_ZAP_OPTIONS,        RTGETOPT_REQ_NOTHING },
    372380        { "--min-lease-time",   'q' ,                           RTGETOPT_REQ_UINT32  },
     
    552560                    break;
    553561
     562                case DHCP_ADDMOD_UNFORCE_OPTION:    // --unforce-opt
     563                    if (pCtx->pCmdDef->fSubcommandScope == HELP_SCOPE_DHCPSERVER_ADD)
     564                        return errorSyntax("--unforce-opt does not apply to the 'add' subcommand");
     565                case DHCP_ADDMOD_UNSUPPRESS_OPTION: // --unsupress-opt
     566                    if (pCtx->pCmdDef->fSubcommandScope == HELP_SCOPE_DHCPSERVER_ADD)
     567                        return errorSyntax("--unsuppress-opt does not apply to the 'add' subcommand");
     568                case DHCP_ADDMOD_FORCE_OPTION:      // --force-opt
     569                case DHCP_ADDMOD_SUPPRESS_OPTION:   // --suppress-opt
     570                    if (iPass == 1)
     571                    {
     572                        DHCPOption_T const enmOption = (DHCPOption_T)ValueUnion.u8;
     573                        bool const fForced = vrc == DHCP_ADDMOD_FORCE_OPTION || vrc == DHCP_ADDMOD_UNFORCE_OPTION;
     574
     575                        /* Get the current option list: */
     576                        ComPtr<IDHCPConfig> &ptrConfig = Scope.getConfig(ptrDHCPServer);
     577                        if (ptrConfig.isNull())
     578                            return RTEXITCODE_FAILURE;
     579                        com::SafeArray<DHCPOption_T> Options;
     580                        if (fForced)
     581                            CHECK_ERROR2I_STMT(ptrConfig, COMGETTER(ForcedOptions)(ComSafeArrayAsOutParam(Options)),
     582                                               rcExit = RTEXITCODE_FAILURE; break);
     583                        else
     584                            CHECK_ERROR2I_STMT(ptrConfig, COMGETTER(SuppressedOptions)(ComSafeArrayAsOutParam(Options)),
     585                                               rcExit = RTEXITCODE_FAILURE; break);
     586                        if (vrc == DHCP_ADDMOD_FORCE_OPTION || vrc == DHCP_ADDMOD_SUPPRESS_OPTION)
     587                        {
     588                            /* Add if not present. */
     589                            size_t iSrc;
     590                            for (iSrc = 0; iSrc < Options.size(); iSrc++)
     591                                if (Options[iSrc] == enmOption)
     592                                    break;
     593                            if (iSrc < Options.size())
     594                                break; /* already present */
     595                            Options.push_back(enmOption);
     596                        }
     597                        else
     598                        {
     599                            /* Remove */
     600                            size_t iDst = 0;
     601                            for (size_t iSrc = 0; iSrc < Options.size(); iSrc++)
     602                            {
     603                                DHCPOption_T enmCurOpt = Options[iSrc];
     604                                if (enmCurOpt != enmOption)
     605                                    Options[iDst++] = enmCurOpt;
     606                            }
     607                            if (iDst == Options.size())
     608                                break; /* Not found. */
     609                            Options.resize(iDst);
     610                        }
     611
     612                        /* Update the option list: */
     613                        if (fForced)
     614                            CHECK_ERROR2I_STMT(ptrConfig, COMSETTER(ForcedOptions)(ComSafeArrayAsInParam(Options)),
     615                                               rcExit = RTEXITCODE_FAILURE);
     616                        else
     617                            CHECK_ERROR2I_STMT(ptrConfig, COMSETTER(SuppressedOptions)(ComSafeArrayAsInParam(Options)),
     618                                               rcExit = RTEXITCODE_FAILURE);
     619                    }
     620                    break;
     621
    554622                case DHCP_ADDMOD_ZAP_OPTIONS:
    555623                    if (pCtx->pCmdDef->fSubcommandScope == HELP_SCOPE_DHCPSERVER_ADD)
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp

    r79847 r79867  
    814814
    815815    com::SafeArray<DHCPOption_T>         Options;
     816    HRESULT hrc;
     817    CHECK_ERROR2_STMT(hrc, ptrConfig, COMGETTER(ForcedOptions(ComSafeArrayAsOutParam(Options))), hrcRet = hrc);
     818    if (FAILED(hrc))
     819        RTPrintf("    Forced options:   %Rhrc\n", hrc);
     820    else if (Options.size() == 0)
     821        RTPrintf("    Forced options:   None\n");
     822    else
     823    {
     824        RTPrintf("    Forced options:   ");
     825        for (size_t i = 0; i < Options.size(); i++)
     826            RTPrintf(i ? ", %u" : "%u", Options[i]);
     827        RTPrintf("\n");
     828    }
     829
     830    CHECK_ERROR2_STMT(hrc, ptrConfig, COMGETTER(SuppressedOptions(ComSafeArrayAsOutParam(Options))), hrcRet = hrc);
     831    if (FAILED(hrc))
     832        RTPrintf("    Suppressed opt.s: %Rhrc\n", hrc);
     833    else if (Options.size() == 0)
     834        RTPrintf("    Suppressed opts.: None\n");
     835    else
     836    {
     837        RTPrintf("    Suppressed opts.: ");
     838        for (size_t i = 0; i < Options.size(); i++)
     839            RTPrintf(i ? ", %u" : "%u", Options[i]);
     840        RTPrintf("\n");
     841    }
     842
    816843    com::SafeArray<DHCPOptionEncoding_T> Encodings;
    817844    com::SafeArray<BSTR>                 Values;
    818     HRESULT hrc;
    819845    CHECK_ERROR2_STMT(hrc, ptrConfig, GetAllOptions(ComSafeArrayAsOutParam(Options),
    820846                                                    ComSafeArrayAsOutParam(Encodings),
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette