VirtualBox

Changeset 79617 in vbox


Ignore:
Timestamp:
Jul 9, 2019 12:38:17 AM (5 years ago)
Author:
vboxsync
Message:

VBoxManage/dhcpserver: More code cleanups, untested. bugref:9288

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDHCPServer.cpp

    r79616 r79617  
    3939#include "VBoxManage.h"
    4040
    41 #include <string>
    4241#include <vector>
    4342#include <map>
     
    7574*   Structures and Typedefs                                                                                                      *
    7675*********************************************************************************************************************************/
     76/** Pointer to a dhcpserver command context. */
     77typedef struct DHCPDCMDCTX *PDHCPDCMDCTX;
     78
    7779/**
    7880 * Definition of a dhcpserver command, with handler and various flags.
     
    8890     * @param   pCtx            Pointer to command context to use.
    8991     */
    90     DECLR3CALLBACKMEMBER(RTEXITCODE, pfnHandler, (struct DHCPDCMDCTX *pCtx, int argc, char **argv));
     92    DECLR3CALLBACKMEMBER(RTEXITCODE, pfnHandler, (PDHCPDCMDCTX pCtx, int argc, char **argv));
    9193
    9294    /** The sub-command scope flags. */
     
    110112    const char     *pszInterface;
    111113} DHCPDCMDCTX;
    112 /** Pointer to a dhcpserver command context. */
    113 typedef DHCPDCMDCTX *PDHCPDCMDCTX;
    114 
    115 typedef std::pair<DhcpOpt_T, std::string> DhcpOptSpec;
     114
     115typedef std::pair<DhcpOpt_T, Utf8Str> DhcpOptSpec;
    116116typedef std::vector<DhcpOptSpec> DhcpOpts;
    117117typedef DhcpOpts::iterator DhcpOptIterator;
     
    122122struct VmNameSlotKey
    123123{
    124     const std::string VmName;
     124    const Utf8Str VmName;
    125125    uint8_t u8Slot;
    126126
    127     VmNameSlotKey(const std::string &aVmName, uint8_t aSlot)
     127    VmNameSlotKey(const Utf8Str &aVmName, uint8_t aSlot)
    128128        : VmName(aVmName)
    129129        , u8Slot(aSlot)
     
    319319                if (RT_FAILURE(vrc))
    320320                    return errorFetchValue(1, "--add-opt", vrc, &ValueUnion);
    321                 pScopeOptions->push_back(DhcpOptSpec((DhcpOpt_T)idAddOpt, std::string(ValueUnion.psz)));
     321                pScopeOptions->push_back(DhcpOptSpec((DhcpOpt_T)idAddOpt, Utf8Str(ValueUnion.psz)));
    322322                break;
    323323            }
     
    346346                if (!fNeedValueOrRemove)
    347347                    return errorSyntax("--value without --id=dhcp-opt-no");
    348                 pScopeOptions->push_back(DhcpOptSpec((DhcpOpt_T)u8OptId, std::string(ValueUnion.psz)));
     348                pScopeOptions->push_back(DhcpOptSpec((DhcpOpt_T)u8OptId, Utf8Str(ValueUnion.psz)));
    349349                fNeedValueOrRemove = false;
    350350                break;
     
    438438
    439439        if (!pszDhcpdIp)
     440        {
    440441            CHECK_ERROR2_RET(hrc, svr, COMGETTER(IPAddress)(bstrDhcpdIp.asOutParam()), RTEXITCODE_FAILURE);
     442        }
    441443        if (!pszNetmask)
     444        {
    442445            CHECK_ERROR2_RET(hrc, svr, COMGETTER(NetworkMask)(bstrNetmask.asOutParam()), RTEXITCODE_FAILURE);
     446        }
    443447        if (!pszLowerIp)
     448        {
    444449            CHECK_ERROR2_RET(hrc, svr, COMGETTER(LowerIP)(bstrNetmask.asOutParam()), RTEXITCODE_FAILURE);
     450        }
    445451        if (!pszUpperIp)
     452        {
    446453            CHECK_ERROR2_RET(hrc, svr, COMGETTER(UpperIP)(bstrNetmask.asOutParam()), RTEXITCODE_FAILURE);
     454        }
    447455
    448456        CHECK_ERROR2_STMT(hrc, svr, SetConfiguration(bstrDhcpdIp.raw(), bstrNetmask.raw(), bstrLowerIp.raw(), bstrUpperIp.raw()),
     
    451459
    452460    if (fEnabled >= 0)
     461    {
    453462        CHECK_ERROR2_STMT(hrc, svr, COMSETTER(Enabled)((BOOL)fEnabled), rcExit = RTEXITCODE_FAILURE);
     463    }
    454464
    455465    /* Remove options: */
    456466    for (DhcpOptIdIterator itOptId = GlobalDhcpOptions2Delete.begin(); itOptId != GlobalDhcpOptions2Delete.end(); ++itOptId)
     467    {
    457468        CHECK_ERROR2_STMT(hrc, svr, RemoveGlobalOption(*itOptId), rcExit = RTEXITCODE_FAILURE);
     469    }
    458470
    459471    for (VmSlot2OptionIdsIterator itIdVector = VmSlot2Options2Delete.begin();
    460472         itIdVector != VmSlot2Options2Delete.end(); ++itIdVector)
     473    {
    461474        for (DhcpOptIdIterator itOptId = itIdVector->second.begin(); itOptId != itIdVector->second.end(); ++itOptId)
     475        {
    462476            CHECK_ERROR2_STMT(hrc, svr, RemoveVmSlotOption(Bstr(itIdVector->first.VmName.c_str()).raw(),
    463477                                                           itIdVector->first.u8Slot, *itOptId),
    464478                              rcExit = RTEXITCODE_FAILURE);
     479        }
     480    }
    465481
    466482    /* Global Options */
    467483    for (DhcpOptIterator itOpt = GlobalDhcpOptions.begin(); itOpt != GlobalDhcpOptions.end(); ++itOpt)
     484    {
    468485        CHECK_ERROR2_STMT(hrc, svr, AddGlobalOption(itOpt->first, com::Bstr(itOpt->second.c_str()).raw()),
    469486                          rcExit = RTEXITCODE_FAILURE);
     487    }
    470488
    471489    /* VM slot options. */
    472490    for (VmSlot2OptionsIterator it = VmSlot2Options.begin(); it != VmSlot2Options.end(); ++it)
     491    {
    473492        for (DhcpOptIterator itOpt = it->second.begin(); itOpt != it->second.end(); ++itOpt)
     493        {
    474494            CHECK_ERROR2_STMT(hrc, svr, AddVmSlotOption(Bstr(it->first.VmName.c_str()).raw(), it->first.u8Slot, itOpt->first,
    475495                                                        com::Bstr(itOpt->second.c_str()).raw()),
    476496                              rcExit = RTEXITCODE_FAILURE);
     497        }
     498    }
    477499
    478500    return rcExit;
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