VirtualBox

Changeset 75513 in vbox for trunk/src


Ignore:
Timestamp:
Nov 16, 2018 11:57:04 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
126671
Message:

Rolled back r126670.

Location:
trunk/src/VBox
Files:
13 edited

Legend:

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

    r75512 r75513  
    5252    OP_ADD = 1000,
    5353    OP_REMOVE,
    54     OP_MODIFY,
    55     OP_RESTART
     54    OP_MODIFY
    5655} OPCODE;
    5756
     
    320319
    321320    if(   enmCode != OP_REMOVE
    322        && enmCode != OP_RESTART
    323321       && GlobalDhcpOptions.empty()
    324322       && VmSlot2Options.empty())
     
    376374    }
    377375
    378     if (enmCode == OP_RESTART)
    379     {
    380         CHECK_ERROR(svr, Restart());
    381         if(FAILED(rc))
    382             return errorArgument("Failed to restart server");
    383     }
    384     else if (enmCode == OP_REMOVE)
    385     {
    386         CHECK_ERROR(a->virtualBox, RemoveDHCPServer(svr));
    387         if(FAILED(rc))
    388             return errorArgument("Failed to remove server");
    389     }
    390     else
     376    if(enmCode != OP_REMOVE)
    391377    {
    392378        if (pIp || pNetmask || pLowerIp || pUpperIp)
     
    439425        }
    440426    }
     427    else
     428    {
     429        CHECK_ERROR(a->virtualBox, RemoveDHCPServer(svr));
     430        if(FAILED(rc))
     431            return errorArgument("Failed to remove server");
     432    }
    441433
    442434    return RTEXITCODE_SUCCESS;
     
    456448    else if (strcmp(a->argv[0], "remove") == 0)
    457449        rcExit = handleOp(a, OP_REMOVE, 1);
    458     else if (strcmp(a->argv[0], "restart") == 0)
    459         rcExit = handleOp(a, OP_RESTART, 1);
    460450    else
    461451        rcExit = errorSyntax(USAGE_DHCPSERVER, "Invalid parameter '%s'", Utf8Str(a->argv[0]).c_str());
  • trunk/src/VBox/Main/Makefile.kmk

    r75512 r75513  
    7979        $(if $(VBOX_WITH_HGCM),VBOX_WITH_HGCM,) \
    8080        $(if $(VBOX_WITH_HOSTNETIF_API),VBOX_WITH_HOSTNETIF_API,) \
    81         $(if $(VBOX_WITH_DHCPD),VBOX_WITH_DHCPD,) \
    8281        $(if $(VBOX_WITH_LIVE_MIGRATION),VBOX_WITH_LIVE_MIGRATION,) \
    8382        $(if $(VBOX_WITH_MIDL_PROXY_STUB),VBOX_WITH_MIDL_PROXY_STUB,) \
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r75512 r75513  
    17911791  <interface
    17921792    name="IDHCPServer" extends="$unknown"
    1793     uuid="197717d2-a742-4966-a529-d1467e903feb"
     1793    uuid="00c8f974-92c5-44a1-8f3f-702469fdd04b"
    17941794    wsmap="managed"
    17951795    reservedMethods="2" reservedAttributes="6"
     
    19531953        <result name="E_FAIL">
    19541954          Failed to stop the process.
    1955         </result>
    1956       </desc>
    1957     </method>
    1958 
    1959     <method name="restart">
    1960       <desc>
    1961         Restart running DHCP server process.
    1962         <result name="E_FAIL">
    1963           Failed to restart the process.
    19641955        </result>
    19651956      </desc>
  • trunk/src/VBox/Main/include/DHCPServerImpl.h

    r75512 r75513  
    5050    static const std::string kDsrKeyLowerIp;
    5151    static const std::string kDsrKeyUpperIp;
    52     static const std::string kDsrKeyConfig;
    5352};
    5453
     
    126125                  const com::Utf8Str &aTrunkType);
    127126    HRESULT stop();
    128     HRESULT restart();
    129127
    130128    struct Data;
  • trunk/src/VBox/Main/include/NetworkServiceRunner.h

    r75512 r75513  
    3636
    3737    int setOption(const std::string& key, const std::string& val);
    38     void clearOptions();
    3938
    4039    int  start(bool aKillProcOnStop);
  • trunk/src/VBox/Main/src-server/DHCPServerImpl.cpp

    r75512 r75513  
    2525
    2626#include <iprt/asm.h>
    27 #include <iprt/file.h>
    2827#include <iprt/net.h>
    29 #include <iprt/path.h>
    3028#include <iprt/cpp/utils.h>
    31 #include <iprt/cpp/xml.h>
    3229
    3330#include <VBox/com/array.h>
     
    4138const std::string DHCPServerRunner::kDsrKeyLowerIp = "--lower-ip";
    4239const std::string DHCPServerRunner::kDsrKeyUpperIp = "--upper-ip";
    43 const std::string DHCPServerRunner::kDsrKeyConfig  = "--config";
    4440
    4541
     
    4945        : enabled(FALSE)
    5046        , router(false)
    51     {
    52         tempConfigFileName[0] = '\0';
    53     }
     47    {}
    5448
    5549    Utf8Str IPAddress;
     
    6357    settings::DhcpOptionMap GlobalDhcpOptions;
    6458    settings::VmSlot2OptionsMap VmSlot2Options;
    65 
    66     char tempConfigFileName[RTPATH_MAX];
    67     com::Utf8Str networkName;
    68     com::Utf8Str trunkName;
    69     com::Utf8Str trunkType;
    7059};
    7160
     
    10998    if (autoUninitSpan.uninitDone())
    11099        return;
    111 
    112     if (m->dhcp.isRunning())
    113         stop();
    114100
    115101    unconst(mVirtualBox) = NULL;
     
    613599
    614600
    615 DECLINLINE(void) addOptionChild(xml::ElementNode *pParent, uint32_t OptCode, const settings::DhcpOptValue &OptValue)
    616 {
    617     xml::ElementNode *pOption = pParent->createChild("Option");
    618     pOption->setAttribute("name", OptCode);
    619     pOption->setAttribute("encoding", OptValue.encoding);
    620     pOption->setAttribute("value", OptValue.text.c_str());
    621 }
    622 
    623 
    624 HRESULT DHCPServer::restart()
    625 {
    626     if (!m->dhcp.isRunning())
    627         return E_FAIL;
    628     /*
    629         * Disabled servers will be brought down, but won't be restarted.
    630         * (see DHCPServer::start)
    631         */
    632     HRESULT hrc = stop();
    633     if (SUCCEEDED(hrc))
    634         hrc = start(m->networkName, m->trunkName, m->trunkType);
    635     return hrc;
    636 }
    637 
    638 
    639601HRESULT DHCPServer::start(const com::Utf8Str &aNetworkName,
    640602                          const com::Utf8Str &aTrunkName,
     
    645607        return S_OK;
    646608
    647     /*
    648      * @todo: the existing code cannot handle concurrent attempts to start DHCP server.
    649      * Note that technically it may receive different parameters from different callers.
    650      */
    651     m->networkName = aNetworkName;
    652     m->trunkName = aTrunkName;
    653     m->trunkType = aTrunkType;
    654 
    655     m->dhcp.clearOptions();
    656 #ifdef VBOX_WITH_DHCPD
    657     int rc = RTPathTemp(m->tempConfigFileName, sizeof(m->tempConfigFileName));
    658     if (RT_FAILURE(rc))
    659         return E_FAIL;
    660     rc = RTPathAppend(m->tempConfigFileName, sizeof(m->tempConfigFileName), "dhcp-config-XXXXX.xml");
    661     if (RT_FAILURE(rc))
    662     {
    663         m->tempConfigFileName[0] = '\0';
    664         return E_FAIL;
    665     }
    666     rc = RTFileCreateTemp(m->tempConfigFileName, 0600);
    667     if (RT_FAILURE(rc))
    668     {
    669         m->tempConfigFileName[0] = '\0';
    670         return E_FAIL;
    671     }
    672 
    673     xml::Document doc;
    674     xml::ElementNode *pElmRoot = doc.createRootElement("DHCPServer");
    675     pElmRoot->setAttribute("networkName", m->networkName.c_str());
    676     if (!m->trunkName.isEmpty())
    677         pElmRoot->setAttribute("trunkName", m->trunkName.c_str());
    678     pElmRoot->setAttribute("trunkType", m->trunkType.c_str());
    679     pElmRoot->setAttribute("IPAddress",  Utf8Str(m->IPAddress).c_str());
    680     pElmRoot->setAttribute("networkMask", Utf8Str(m->GlobalDhcpOptions[DhcpOpt_SubnetMask].text).c_str());
    681     pElmRoot->setAttribute("lowerIP", Utf8Str(m->lowerIP).c_str());
    682     pElmRoot->setAttribute("upperIP", Utf8Str(m->upperIP).c_str());
    683 
    684     /* Process global options */
    685     xml::ElementNode *pOptions = pElmRoot->createChild("Options");
    686     // settings::DhcpOptionMap::const_iterator itGlobal;
    687     for (settings::DhcpOptionMap::const_iterator it = m->GlobalDhcpOptions.begin();
    688          it != m->GlobalDhcpOptions.end();
    689          ++it)
    690         addOptionChild(pOptions, (*it).first, (*it).second);
    691 
    692     /* Process network-adapter-specific options */
    693     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    694     HRESULT hrc = S_OK;
    695     ComPtr<IMachine> machine;
    696     ComPtr<INetworkAdapter> nic;
    697     settings::VmSlot2OptionsIterator it;
    698     for(it = m->VmSlot2Options.begin(); it != m->VmSlot2Options.end(); ++it)
    699     {
    700         alock.release();
    701         hrc = mVirtualBox->FindMachine(Bstr(it->first.VmName).raw(), machine.asOutParam());
    702         alock.acquire();
    703 
    704         if (FAILED(hrc))
    705             continue;
    706 
    707         alock.release();
    708         hrc = machine->GetNetworkAdapter(it->first.Slot, nic.asOutParam());
    709         alock.acquire();
    710 
    711         if (FAILED(hrc))
    712             continue;
    713 
    714         com::Bstr mac;
    715 
    716         alock.release();
    717         hrc = nic->COMGETTER(MACAddress)(mac.asOutParam());
    718         alock.acquire();
    719 
    720         if (FAILED(hrc)) /* no MAC address ??? */
    721             continue;
    722 
    723         /* Convert MAC address from XXXXXXXXXXXX to XX:XX:XX:XX:XX:XX */
    724         Utf8Str strMacWithoutColons(mac);
    725         const char *pszSrc = strMacWithoutColons.c_str();
    726         RTMAC binaryMac;
    727         if (RTStrConvertHexBytes(pszSrc, &binaryMac, sizeof(binaryMac), 0) != VINF_SUCCESS)
    728             continue;
    729         char szMac[18]; /* "XX:XX:XX:XX:XX:XX" */
    730         if (RTStrPrintHexBytes(szMac, sizeof(szMac), &binaryMac, sizeof(binaryMac), RTSTRPRINTHEXBYTES_F_SEP_COLON) != VINF_SUCCESS)
    731             continue;
    732 
    733         xml::ElementNode *pMacConfig = pElmRoot->createChild("Config");
    734         pMacConfig->setAttribute("MACAddress", szMac);
    735 
    736         com::Utf8Str encodedOption;
    737         settings::DhcpOptionMap &map = i_findOptMapByVmNameSlot(it->first.VmName, it->first.Slot);
    738         settings::DhcpOptionMap::const_iterator itAdapterOption;
    739         for (itAdapterOption = map.begin(); itAdapterOption != map.end(); ++itAdapterOption)
    740             addOptionChild(pMacConfig, (*itAdapterOption).first, (*itAdapterOption).second);
    741     }
    742 
    743     xml::XmlFileWriter writer(doc);
    744     writer.write(m->tempConfigFileName, true);
    745 
    746     m->dhcp.setOption(DHCPServerRunner::kDsrKeyConfig, m->tempConfigFileName);
    747 #else /* !VBOX_WITH_DHCPD */
    748609    /* Commmon Network Settings */
    749610    m->dhcp.setOption(NetworkServiceRunner::kNsrKeyNetwork, aNetworkName.c_str());
     
    767628    m->dhcp.setOption(DHCPServerRunner::kDsrKeyLowerIp, Utf8Str(m->lowerIP).c_str());
    768629    m->dhcp.setOption(DHCPServerRunner::kDsrKeyUpperIp, Utf8Str(m->upperIP).c_str());
    769 #endif /* !VBOX_WITH_DHCPD */
    770630
    771631    /* XXX: This parameters Dhcp Server will fetch via API */
     
    777637HRESULT DHCPServer::stop (void)
    778638{
    779 #ifdef VBOX_WITH_DHCPD
    780     if (m->tempConfigFileName[0])
    781     {
    782         RTFileDelete(m->tempConfigFileName);
    783         m->tempConfigFileName[0] = 0;
    784     }
    785 #endif /* VBOX_WITH_DHCPD */
    786639    return RT_FAILURE(m->dhcp.stop()) ? E_FAIL : S_OK;
    787640}
  • trunk/src/VBox/Main/src-server/NetworkServiceRunner.cpp

    r75512 r75513  
    6666    m->mOptions.insert(std::map<std::string, std::string>::value_type(key, val));
    6767    return VINF_SUCCESS;
    68 }
    69 
    70 
    71 void NetworkServiceRunner::clearOptions()
    72 {
    73     m->mOptions.clear();
    7468}
    7569
  • trunk/src/VBox/NetworkServices/Dhcpd/Db.cpp

    r75512 r75513  
    291291     */
    292292    const xml::ElementNode *ndTime = ndLease->findChildElement("Time");
    293     if (ndTime == NULL)
     293    if (time == NULL)
    294294        return NULL;
    295295
  • trunk/src/VBox/NetworkServices/Dhcpd/Defs.h

    r75512 r75513  
    2727#include <vector>
    2828
    29 #ifdef _MSC_VER
    30 # define __func__ __FUNCTION__
    31 #endif
    32 
    3329typedef std::vector<uint8_t> octets_t;
    3430
     
    3632
    3733class DhcpOption;
    38 typedef std::map<uint8_t, std::shared_ptr<DhcpOption> > optmap_t;
     34typedef std::map<uint8_t, std::shared_ptr<DhcpOption>> optmap_t;
    3935
    4036inline bool operator==(const RTMAC &l, const RTMAC &r)
  • trunk/src/VBox/NetworkServices/Dhcpd/DhcpOptions.cpp

    r75512 r75513  
    3636optmap_t &operator<<(optmap_t &optmap, const std::shared_ptr<DhcpOption> &option)
    3737{
    38     if (option == nullptr)
     38    if (option == NULL)
    3939        return optmap;
    4040
  • trunk/src/VBox/NetworkServices/Dhcpd/Makefile.kmk

    r75512 r75513  
    2929 ifdef VBOX_WITH_HARDENING
    3030  PROGRAMS += VBoxNetDhcpdHardened
    31   DLLS += VBoxNetDhcpd
     31  VBoxNetDhcpdHardened_TEMPLATE = VBOXR3HARDENEDEXE
     32  VBoxNetDhcpdHardened_NAME     = VBoxNetDhcpd
     33  VBoxNetDhcpdHardened_DEFS     = SERVICE_NAME=\"VBoxNetDhcpd\"
     34  VBoxNetDhcpdHardened_SOURCES  = VBoxNetDhcpdHardened.cpp
     35  VBoxNetDhcpdHardened_SOURCES.win = $(VBoxNetLwipNAT_0_OUTDIR)/VBoxNetDhcpd-icon.rc
     36  VBoxNetDhcpdHardened_LDFLAGS.win = /SUBSYSTEM:windows
    3237 else
    3338  PROGRAMS += VBoxNetDhcpd
    3439 endif
    3540
    36  VBoxNetDhcpdHardened_TEMPLATE = VBOXR3HARDENEDEXE
    37  VBoxNetDhcpdHardened_NAME     = VBoxNetDHCP
    38  VBoxNetDhcpdHardened_DEFS     = SERVICE_NAME=\"VBoxNetDhcpd\"
    39  VBoxNetDhcpdHardened_SOURCES  = VBoxNetDhcpdHardened.cpp
    40  VBoxNetDhcpdHardened_SOURCES.win = $(VBoxNetDhcpd_0_OUTDIR)/VBoxNetDhcpd-icon.rc
    41  VBoxNetDhcpdHardened_LDFLAGS.win = /SUBSYSTEM:windows
    42 
    43  if1of ($(KBUILD_TARGET),win linux solaris)
    44   VBoxNetDhcpd_TEMPLATE := $(if-expr defined(VBOX_WITH_HARDENING),VBoxR3DllDhcpd,VBoxR3ExeDhcpd)
    45  else
    46   VBoxNetDhcpd_TEMPLATE := $(if-expr defined(VBOX_WITH_HARDENING),VBoxR3Dll,VBOXR3EXE)
    47  endif
    48  VBoxNetDhcpd_NAME      = VBoxNetDHCP
     41 VBoxNetDhcpd_TEMPLATE := $(if-expr defined(VBOX_WITH_HARDENING),VBOXMAINDLL,VBOXMAINCLIENTEXE)
     42 VBoxNetDhcpd_NAME     := VBoxNetDhcpd
    4943 # VBoxNetDhcpd_DEFS      = IPv6
    50  # VBoxNetDhcpd_DEFS.linux = WITH_VALGRIND
    51  #VBoxNetDhcpd_DEFS.win  = VBOX_COM_OUTOFPROC_MODULE _WIN32_WINNT=0x501 # Windows XP
     44 # VBoxNetLwipNAT_DEFS.linux = WITH_VALGRIND
     45 VBoxNetDhcpd_DEFS.win  = VBOX_COM_OUTOFPROC_MODULE _WIN32_WINNT=0x501 # Windows XP
    5246
    5347 # (current dir is for for lwipopts.h)
    5448 VBoxNetDhcpd_INCS += . $(addprefix ../../Devices/Network/lwip-new/,$(LWIP_INCS))
    5549
    56  VBoxNetDhcpd_DEFS    = KBUILD_TYPE=\"$(KBUILD_TYPE)\"
    57  ifneq ($(KBUILD_TARGET),win)
    58   VBoxNetDhcpd_DEFS  += VBOX_WITH_XPCOM
    59   VBoxNetDhcpd_INCS  += $(VBOX_XPCOM_INCS)
    60   VBoxNetDhcpd_CXXFLAGS += -std=c++11
    61  endif
    62  VBoxNetDhcpd_SOURCES = ../../Main/glue/VBoxLogRelCreate.cpp \
    63                         ../../Main/glue/GetVBoxUserHomeDirectory.cpp \
    64                         ClientId.cpp \
    65                         Config.cpp \
    66                         DHCPD.cpp \
    67                         Db.cpp \
    68                         DhcpMessage.cpp \
    69                         DhcpOptions.cpp \
    70                         IPv4Pool.cpp \
    71                         TimeStamp.cpp \
    72                         VBoxNetDhcpd.cpp \
    73                         $(addprefix ../../Devices/Network/lwip-new/,$(LWIP_SOURCES))
     50 VBoxNetDhcpd_SOURCES  =
     51 VBoxNetDhcpd_SOURCES += ClientId.cpp
     52 VBoxNetDhcpd_SOURCES += Config.cpp
     53 VBoxNetDhcpd_SOURCES += DHCPD.cpp
     54 VBoxNetDhcpd_SOURCES += Db.cpp
     55 VBoxNetDhcpd_SOURCES += DhcpMessage.cpp
     56 VBoxNetDhcpd_SOURCES += DhcpOptions.cpp
     57 VBoxNetDhcpd_SOURCES += IPv4Pool.cpp
     58 VBoxNetDhcpd_SOURCES += TimeStamp.cpp
     59 VBoxNetDhcpd_SOURCES += VBoxNetDhcpd.cpp
     60 VBoxNetDhcpd_SOURCES += $(addprefix ../../Devices/Network/lwip-new/,$(LWIP_SOURCES))
    7461
    75  VBoxNetDhcpd_LIBS = $(LIB_RUNTIME)
     62 VBoxNetLwipNAT_LIBS = $(LIB_RUNTIME)
    7663
    77  VBoxNetDhcpd_LIBS.solaris += socket nsl
    78  VBoxNetDhcpd_LDFLAGS.win = /SUBSYSTEM:windows
     64 VBoxNetLwipNAT_LIBS.solaris += socket nsl
     65 VBoxNetLwipNAT_LDFLAGS.win = /SUBSYSTEM:windows
    7966
    8067 ifeq ($(KBUILD_TARGET),win)
  • trunk/src/VBox/NetworkServices/Dhcpd/VBoxNetDhcpd.cpp

    r75512 r75513  
    5252#include <memory>
    5353
    54 #ifdef RT_OS_WINDOWS /* WinMain */
    55 #undef htonl
    56 #undef ntohl
    57 # include <iprt/win/windows.h>
    58 #endif
    5954
    6055struct delete_pbuf
     
    453448                                                     i, cSegs,
    454449                                                     &cbSegFrame);
    455                 ifInput(pvSegFrame, (uint32_t)cbFrame);
     450                ifInput(pvSegFrame, cbFrame);
    456451            }
    457452        }
     
    743738
    744739    unique_ptr_pbuf q ( pbuf_alloc(PBUF_RAW, (u16_t)data.size(), PBUF_RAM) );
    745     if (q == nullptr)
    746         return;
    747 
    748     error = pbuf_take(q.get(), &data.front(), (u16_t)data.size());
     740    if (q == NULL)
     741        return;
     742
     743    error = pbuf_take(q.get(), &data.front(), data.size());
    749744    if (error != ERR_OK)
    750745        return;
  • trunk/src/VBox/NetworkServices/Makefile.kmk

    r75512 r75513  
    2222ifdef VBOX_WITH_MAIN
    2323 # Include sub-makefiles.
    24  ifndef VBOX_WITH_DHCPD
    25   include $(PATH_SUB_CURRENT)/DHCP/Makefile.kmk
    26  else
    27   include $(PATH_SUB_CURRENT)/Dhcpd/Makefile.kmk
    28  endif
     24 include $(PATH_SUB_CURRENT)/DHCP/Makefile.kmk
    2925 ifdef VBOX_WITH_NAT_SERVICE
    3026  include $(PATH_SUB_CURRENT)/NAT/Makefile.kmk
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