VirtualBox

Changeset 21860 in vbox for trunk


Ignore:
Timestamp:
Jul 29, 2009 9:39:25 AM (15 years ago)
Author:
vboxsync
Message:

DHCP Server: fix for passing on commandline options with no values (for e.g. --begin-config)

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/DHCPServerImpl.cpp

    r20596 r21860  
    249249        return S_OK;
    250250
    251     m.dhcp.setOption(DHCPCFG_NETNAME, Utf8Str(aNetworkName));
     251    m.dhcp.setOption(DHCPCFG_NETNAME, Utf8Str(aNetworkName), true);
    252252    Bstr tmp(aTrunkName);
    253253    if (!tmp.isEmpty())
    254         m.dhcp.setOption(DHCPCFG_TRUNKNAME, Utf8Str(tmp));
    255     m.dhcp.setOption(DHCPCFG_TRUNKTYPE, Utf8Str(aTrunkType));
     254        m.dhcp.setOption(DHCPCFG_TRUNKNAME, Utf8Str(tmp), true);
     255    m.dhcp.setOption(DHCPCFG_TRUNKTYPE, Utf8Str(aTrunkType), true);
    256256    //temporary hack for testing
    257257    //    DHCPCFG_NAME
     
    261261    RTStrPrintf (strMAC, sizeof(strMAC), "080027%02X%02X%02X",
    262262                 guid.ptr()->au8[0], guid.ptr()->au8[1], guid.ptr()->au8[2]);
    263     m.dhcp.setOption(DHCPCFG_MACADDRESS, strMAC);
    264     m.dhcp.setOption(DHCPCFG_IPADDRESS,  Utf8Str(m.IPAddress));
     263    m.dhcp.setOption(DHCPCFG_MACADDRESS, strMAC, true);
     264    m.dhcp.setOption(DHCPCFG_IPADDRESS,  Utf8Str(m.IPAddress), true);
    265265    //        DHCPCFG_LEASEDB,
    266266    //        DHCPCFG_VERBOSE,
    267267    //        DHCPCFG_GATEWAY,
    268     m.dhcp.setOption(DHCPCFG_LOWERIP,  Utf8Str(m.lowerIP));
    269     m.dhcp.setOption(DHCPCFG_UPPERIP,  Utf8Str(m.upperIP));
    270     m.dhcp.setOption(DHCPCFG_NETMASK,  Utf8Str(m.networkMask));
     268    m.dhcp.setOption(DHCPCFG_LOWERIP,  Utf8Str(m.lowerIP), true);
     269    m.dhcp.setOption(DHCPCFG_UPPERIP,  Utf8Str(m.upperIP), true);
     270    m.dhcp.setOption(DHCPCFG_NETMASK,  Utf8Str(m.networkMask), true);
    271271
    272272    //        DHCPCFG_HELP,
    273273    //        DHCPCFG_VERSION,
    274274    //        DHCPCFG_NOTOPT_MAXVAL
    275     m.dhcp.setOption(DHCPCFG_BEGINCONFIG,  "");
     275    m.dhcp.setOption(DHCPCFG_BEGINCONFIG,  "", true);
    276276
    277277    return RT_FAILURE(m.dhcp.start()) ? E_FAIL : S_OK;
  • trunk/src/VBox/Main/DHCPServerRunner.cpp

    r21404 r21860  
    6464}
    6565
     66DHCPServerRunner::DHCPServerRunner()
     67{
     68    mProcess = NIL_RTPROCESS;
     69    for (unsigned i = 0; i < DHCPCFG_NOTOPT_MAXVAL; i++)
     70    {
     71        mOptionEnabled[i] = false;
     72    }
     73}
     74
    6675void DHCPServerRunner::detachFromServer()
    6776{
     
    97106    for (unsigned i = 0; i < DHCPCFG_NOTOPT_MAXVAL; i++)
    98107    {
    99         if (mOptions[i].length())
     108        if (mOptionEnabled[i])
    100109        {
    101110            const ARGDEF * pArgDef = getArgDef((DHCPCFG)i);
    102111            args[index++] = pArgDef->Name;      // e.g. "--network"
    103             args[index++] = mOptions[i].raw();  // value
     112
     113            /* value can be null for e.g. --begin-config has no value
     114             * and thus check the mOptions string length here
     115             */
     116            if (mOptions[i].length())
     117                args[index++] = mOptions[i].raw();  // value
    104118        }
    105119    }
  • trunk/src/VBox/Main/include/DHCPServerRunner.h

    r21387 r21860  
    5353{
    5454public:
    55     DHCPServerRunner() : mProcess (NIL_RTPROCESS) {}
     55    DHCPServerRunner();
    5656    ~DHCPServerRunner() { stop(); /* don't leave abandoned servers */}
    5757
    58     int setOption(DHCPCFG opt, const char *val)
     58    int setOption(DHCPCFG opt, const char *val, bool enabled)
    5959    {
    6060        if(opt == 0 || opt >= DHCPCFG_NOTOPT_MAXVAL)
     
    7575            mOptions[opt] = val;
    7676        }
     77        mOptionEnabled[opt] = enabled;
    7778        return VINF_SUCCESS;
    7879    }
     
    8586private:
    8687    com::Utf8Str mOptions[DHCPCFG_NOTOPT_MAXVAL];
     88    bool mOptionEnabled[DHCPCFG_NOTOPT_MAXVAL];
    8789    RTPROCESS mProcess;
    8890};
Note: See TracChangeset for help on using the changeset viewer.

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