Changeset 75648 in vbox for trunk/src/VBox/NetworkServices/Dhcpd
- Timestamp:
- Nov 21, 2018 6:02:38 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 126827
- Location:
- trunk/src/VBox/NetworkServices/Dhcpd
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/Dhcpd/ClientId.h
r75617 r75648 35 35 ClientId() 36 36 : m_mac(), m_id() {} 37 ClientId(const RTMAC &mac , const OptClientId &id)38 : m_mac(mac ), m_id(id) {}37 ClientId(const RTMAC &macParam, const OptClientId &idParam) 38 : m_mac(macParam), m_id(idParam) {} 39 39 40 40 const RTMAC &mac() const { return m_mac; } -
trunk/src/VBox/NetworkServices/Dhcpd/Config.cpp
r75617 r75648 589 589 /** @todo r=bird: Visual C++ 2010 does not grok this use of 'auto'. */ 590 590 // XXX: debug 591 for ( auto it: m_GlobalOptions) {592 std::shared_ptr<DhcpOption> opt(it .second);591 for (optmap_t::const_iterator it = m_GlobalOptions.begin(); it != m_GlobalOptions.end(); ++it) { 592 std::shared_ptr<DhcpOption> opt(it->second); 593 593 594 594 octets_t data; … … 596 596 597 597 bool space = false; 598 for (auto c: data) { 598 for (octets_t::const_iterator itData = data.begin(); itData != data.end(); ++itData) { 599 uint8_t c = *itData; 599 600 if (space) 600 601 std::cout << " "; … … 854 855 optmap << new OptSubnetMask(m_IPv4Netmask); 855 856 856 for (auto optreq: reqOpts.value()) 857 { 857 const OptParameterRequest::value_t& reqValue = reqOpts.value(); 858 for (octets_t::const_iterator itOptReq = reqValue.begin(); itOptReq != reqValue.end(); ++itOptReq) 859 { 860 uint8_t optreq = *itOptReq; 858 861 std::cout << ">>> requested option " << (int)optreq << std::endl; 859 862 … … 890 893 if (vmopts != NULL) 891 894 { 892 for ( auto it: *vmopts) {893 std::shared_ptr<DhcpOption> opt(it .second);895 for (optmap_t::const_iterator it = vmopts->begin(); it != vmopts->end(); ++it) { 896 std::shared_ptr<DhcpOption> opt(it->second); 894 897 if (optmap.count(opt->optcode()) == 0 && opt->optcode() > 127) 895 898 { … … 900 903 } 901 904 902 for ( auto it: m_GlobalOptions) {903 std::shared_ptr<DhcpOption> opt(it .second);905 for (optmap_t::const_iterator it = m_GlobalOptions.begin(); it != m_GlobalOptions.end(); ++it) { 906 std::shared_ptr<DhcpOption> opt(it->second); 904 907 if (optmap.count(opt->optcode()) == 0 && opt->optcode() > 127) 905 908 { -
trunk/src/VBox/NetworkServices/Dhcpd/Db.cpp
r75573 r75648 500 500 idBinding = reuseBinding; 501 501 LogDHCP(("> .... reusing %s binding %R[binding]\n", 502 reuseBinding->stateName() ));502 reuseBinding->stateName(), reuseBinding)); 503 503 } 504 504 } -
trunk/src/VBox/NetworkServices/Dhcpd/Db.h
r75617 r75648 51 51 Binding(const Binding &); 52 52 53 explicit Binding(RTNETADDRIPV4 addr )54 : m_addr(addr ), m_state(FREE),53 explicit Binding(RTNETADDRIPV4 addrParam) 54 : m_addr(addrParam), m_state(FREE), 55 55 m_issued(), m_secLease() {} 56 56 57 Binding(RTNETADDRIPV4 addr , const ClientId &id)58 : m_addr(addr ), m_state(FREE), m_id(id),57 Binding(RTNETADDRIPV4 addrParam, const ClientId &idParam) 58 : m_addr(addrParam), m_state(FREE), m_id(idParam), 59 59 m_issued(), m_secLease() {} 60 60 … … 70 70 TimeStamp issued() const { return m_issued; } 71 71 72 Binding &setState(State state )72 Binding &setState(State stateParam) 73 73 { 74 m_state = state ;74 m_state = stateParam; 75 75 return *this; 76 76 } … … 85 85 } 86 86 87 Binding &giveTo(const ClientId &id )87 Binding &giveTo(const ClientId &idParam) 88 88 { 89 m_id = id ;89 m_id = idParam; 90 90 m_state = FREE; 91 91 return *this; -
trunk/src/VBox/NetworkServices/Dhcpd/Defs.h
r75617 r75648 24 24 25 25 #include <map> 26 #include <vector> 27 28 #if __cplusplus >= 199711 26 29 #include <memory> 27 #include <vector> 30 using std::shared_ptr; 31 #else 32 #include <tr1/memory> 33 using std::tr1::shared_ptr; 34 #endif 28 35 29 36 typedef std::vector<uint8_t> octets_t; … … 32 39 33 40 class DhcpOption; 34 typedef std::map<uint8_t, std::shared_ptr<DhcpOption> > optmap_t;41 typedef std::map<uint8_t, std::shared_ptr<DhcpOption> > optmap_t; 35 42 36 43 inline bool operator==(const RTMAC &l, const RTMAC &r) -
trunk/src/VBox/NetworkServices/Dhcpd/DhcpMessage.cpp
r75617 r75648 38 38 if (buflen < RT_OFFSETOF(RTNETBOOTP, bp_vend.Dhcp.dhcp_opts)) 39 39 { 40 RTPrintf("%s: %zu bytes datagram is too short\n", __ func__, buflen);40 RTPrintf("%s: %zu bytes datagram is too short\n", __FUNCTION__, buflen); 41 41 return NULL; 42 42 } … … 46 46 if (bp->bp_op != RTNETBOOTP_OP_REQUEST) 47 47 { 48 RTPrintf("%s: bad opcode: %d\n", __ func__, bp->bp_op);48 RTPrintf("%s: bad opcode: %d\n", __FUNCTION__, bp->bp_op); 49 49 return NULL; 50 50 } … … 52 52 if (bp->bp_htype != RTNET_ARP_ETHER) 53 53 { 54 RTPrintf("%s: unsupported htype %d\n", __ func__, bp->bp_htype);54 RTPrintf("%s: unsupported htype %d\n", __FUNCTION__, bp->bp_htype); 55 55 return NULL; 56 56 } … … 58 58 if (bp->bp_hlen != sizeof(RTMAC)) 59 59 { 60 RTPrintf("%s: unexpected hlen %d\n", __ func__, bp->bp_hlen);60 RTPrintf("%s: unexpected hlen %d\n", __FUNCTION__, bp->bp_hlen); 61 61 return NULL; 62 62 } … … 66 66 { 67 67 RTPrintf("%s: multicast chaddr %RTmac without broadcast flag\n", 68 __ func__, &bp->bp_chaddr.Mac);68 __FUNCTION__, &bp->bp_chaddr.Mac); 69 69 } 70 70 … … 72 72 if (bp->bp_giaddr.u != 0) 73 73 { 74 RTPrintf("%s: giaddr %RTnaipv4\n", __ func__, bp->bp_giaddr.u);74 RTPrintf("%s: giaddr %RTnaipv4\n", __FUNCTION__, bp->bp_giaddr.u); 75 75 return NULL; 76 76 } … … 78 78 if (bp->bp_hops != 0) 79 79 { 80 RTPrintf("%s: non-zero hops %d\n", __ func__, bp->bp_hops);80 RTPrintf("%s: non-zero hops %d\n", __FUNCTION__, bp->bp_hops); 81 81 return NULL; 82 82 } … … 323 323 324 324 DhcpServerMessage::DhcpServerMessage(const DhcpClientMessage &req, 325 uint8_t messageType , RTNETADDRIPV4 serverAddr)325 uint8_t messageTypeParam, RTNETADDRIPV4 serverAddr) 326 326 : DhcpMessage(), 327 327 m_optServerId(serverAddr) … … 329 329 m_dst.u = 0xffffffff; /* broadcast */ 330 330 331 m_optMessageType = OptMessageType(messageType );331 m_optMessageType = OptMessageType(messageTypeParam); 332 332 333 333 /* copy values from the request (cf. RFC2131 Table 3) */ -
trunk/src/VBox/NetworkServices/Dhcpd/DhcpOptions.cpp
r75617 r75648 36 36 optmap_t &operator<<(optmap_t &optmap, const std::shared_ptr<DhcpOption> &option) 37 37 { 38 if ( option == NULL)38 if (!option) 39 39 return optmap; 40 40 -
trunk/src/VBox/NetworkServices/Dhcpd/DhcpOptions.h
r75617 r75648 342 342 static OptValue *parse(const char *pcszValue) 343 343 { 344 value_t v;344 typename OptValueBase<T>::value_t v; 345 345 int rc = DhcpOption::parse1(v, pcszValue); 346 346 if (RT_FAILURE(rc)) … … 544 544 static OptList *parse(const char *pcszValue) 545 545 { 546 value_t v;546 typename OptListBase<T>::value_t v; 547 547 int rc = DhcpOption::parseList(v, pcszValue); 548 548 if (RT_FAILURE(rc) || v.empty()) -
trunk/src/VBox/NetworkServices/Dhcpd/Makefile.kmk
r75617 r75648 29 29 ifdef VBOX_WITH_HARDENING 30 30 PROGRAMS += VBoxNetDhcpdHardened 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 31 DLLS += VBoxNetDhcpd 37 32 else 38 33 PROGRAMS += VBoxNetDhcpd 39 34 endif 40 35 41 VBoxNetDhcpd_TEMPLATE := $(if-expr defined(VBOX_WITH_HARDENING),VBOXMAINDLL,VBOXMAINCLIENTEXE) 42 VBoxNetDhcpd_NAME := VBoxNetDhcpd 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 VBoxNetDhcpd_TEMPLATE := $(if-expr defined(VBOX_WITH_HARDENING),VBoxR3Dll,VBOXR3EXE) 44 VBoxNetDhcpd_NAME = VBoxNetDHCP 43 45 # VBoxNetDhcpd_DEFS = IPv6 44 # VBoxNet LwipNAT_DEFS.linux = WITH_VALGRIND45 VBoxNetDhcpd_DEFS.win = VBOX_COM_OUTOFPROC_MODULE _WIN32_WINNT=0x501 # Windows XP46 # VBoxNetDhcpd_DEFS.linux = WITH_VALGRIND 47 #VBoxNetDhcpd_DEFS.win = VBOX_COM_OUTOFPROC_MODULE _WIN32_WINNT=0x501 # Windows XP 46 48 47 49 # (current dir is for for lwipopts.h) 48 50 VBoxNetDhcpd_INCS += . $(addprefix ../../Devices/Network/lwip-new/,$(LWIP_INCS)) 49 51 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)) 52 VBoxNetDhcpd_DEFS = KBUILD_TYPE=\"$(KBUILD_TYPE)\" 53 ifneq ($(KBUILD_TARGET),win) 54 VBoxNetDhcpd_DEFS += VBOX_WITH_XPCOM 55 VBoxNetDhcpd_INCS += $(VBOX_XPCOM_INCS) 56 ifneq ($(KBUILD_TARGET),darwin) 57 # We want -std=c++11 for 4.7 and newer compilers, and -std=c++0x for older ones. 58 VBoxNetDhcpd_CXXFLAGS += -std=$(if $(VBOX_GCC_VERSION_CXX),$(if $(VBOX_GCC_VERSION_CXX) < 40700,c++0x,c++11),c++0x) 59 endif 60 endif 61 VBoxNetDhcpd_SOURCES = ../../Main/glue/VBoxLogRelCreate.cpp \ 62 ../../Main/glue/GetVBoxUserHomeDirectory.cpp \ 63 ClientId.cpp \ 64 Config.cpp \ 65 DHCPD.cpp \ 66 Db.cpp \ 67 DhcpMessage.cpp \ 68 DhcpOptions.cpp \ 69 IPv4Pool.cpp \ 70 TimeStamp.cpp \ 71 VBoxNetDhcpd.cpp \ 72 $(addprefix ../../Devices/Network/lwip-new/,$(LWIP_SOURCES)) 61 73 62 VBoxNet LwipNAT_LIBS = $(LIB_RUNTIME)74 VBoxNetDhcpd_LIBS = $(LIB_RUNTIME) 63 75 64 VBoxNet LwipNAT_LIBS.solaris += socket nsl65 VBoxNet LwipNAT_LDFLAGS.win = /SUBSYSTEM:windows76 VBoxNetDhcpd_LIBS.solaris += socket nsl 77 VBoxNetDhcpd_LDFLAGS.win = /SUBSYSTEM:windows 66 78 67 79 ifeq ($(KBUILD_TARGET),win) -
trunk/src/VBox/NetworkServices/Dhcpd/VBoxNetDhcpd.cpp
r75617 r75648 17 17 18 18 #include <iprt/cdefs.h> 19 20 /* 21 * Need to get host/network order conversion stuff from Windows headers, 22 * so we do not define them in LWIP and then try to re-define them in 23 * Windows headers. 24 */ 25 #ifdef RT_OS_WINDOWS 26 # include <iprt/win/winsock2.h> 27 #endif 28 29 19 30 #include <iprt/param.h> 20 31 #include <iprt/err.h> … … 52 63 #include <memory> 53 64 65 #ifdef RT_OS_WINDOWS 66 # include <iprt/win/windows.h> 67 #endif 54 68 55 69 struct delete_pbuf … … 448 462 i, cSegs, 449 463 &cbSegFrame); 450 ifInput(pvSegFrame, cbFrame);464 ifInput(pvSegFrame, (uint32_t)cbFrame); 451 465 } 452 466 } … … 729 743 730 744 ip_addr_t dst = { msgOut->dst().u }; 731 if (ip_addr_ isany(&dst))745 if (ip_addr_cmp(&dst, &ip_addr_any)) 732 746 ip_addr_copy(dst, ip_addr_broadcast); 733 747 … … 738 752 739 753 unique_ptr_pbuf q ( pbuf_alloc(PBUF_RAW, (u16_t)data.size(), PBUF_RAM) ); 740 if ( q == NULL)754 if (!q) 741 755 return; 742 756 743 error = pbuf_take(q.get(), &data.front(), data.size());757 error = pbuf_take(q.get(), &data.front(), (u16_t)data.size()); 744 758 if (error != ERR_OK) 745 759 return;
Note:
See TracChangeset
for help on using the changeset viewer.