Changeset 50213 in vbox for trunk/src/VBox/NetworkServices
- Timestamp:
- Jan 24, 2014 8:23:12 AM (11 years ago)
- Location:
- trunk/src/VBox/NetworkServices
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/DHCP/ClientDataInt.h
r49563 r50213 37 37 } 38 38 ~ClientData(){} 39 39 40 40 /* client information */ 41 41 RTNETADDRIPV4 m_address; 42 42 RTNETADDRIPV4 m_network; 43 43 RTMAC m_mac; 44 44 45 45 bool fHasClient; 46 46 47 47 /* Lease part */ 48 bool fHasLease; 48 bool fHasLease; 49 49 /** lease isn't commited */ 50 50 bool fBinding; … … 64 64 NetworkConfigEntity *pCfg; 65 65 }; 66 66 67 #endif -
trunk/src/VBox/NetworkServices/DHCP/Config.cpp
r49920 r50213 1 1 /* $Id$ */ 2 /** @file 3 * Configuration for DHCP. 4 */ 5 6 /* 7 * Copyright (C) 2013-2014 Oracle Corporation 8 * 9 * This file is part of VirtualBox Open Source Edition (OSE), as 10 * available from http://www.virtualbox.org. This file is free software; 11 * you can redistribute it and/or modify it under the terms of the GNU 12 * General Public License (GPL) as published by the Free Software 13 * Foundation, in version 2 as it comes in the "COPYING" file of the 14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 */ 17 2 18 3 19 /** … … 131 147 bool fFileExists; 132 148 }; 133 149 134 150 ConfigurationManager *ConfigurationManager::getConfigurationManager() 135 151 { … … 174 190 { 175 191 m->m_leaseStorageFilename = leaseStorageFileName; 176 192 177 193 xml::XmlFileParser parser; 178 194 xml::Document doc; … … 208 224 if (!lease->nameEquals(tagXMLLease.c_str())) 209 225 continue; 210 226 211 227 ClientData *data = new ClientData(); 212 228 Lease l(data); 213 if (l.fromXML(lease)) 229 if (l.fromXML(lease)) 214 230 { 215 231 … … 242 258 if (!root) 243 259 return VERR_INTERNAL_ERROR; 244 260 245 261 root->setAttribute(tagXMLLeasesAttributeVersion.c_str(), tagXMLLeasesVersion_1_0.c_str()); 246 262 … … 388 404 if (l != Lease::NullLease) 389 405 { 390 /* Here we should take lease from the m_allocation which was feed with leases 406 /* Here we should take lease from the m_allocation which was feed with leases 391 407 * on start 392 408 */ … … 476 492 Lease l = client.lease(); 477 493 AssertReturn(l != Lease::NullLease, VERR_INTERNAL_ERROR); 478 494 479 495 if (l.isInBindingPhase()) 480 496 { … … 491 507 return VINF_SUCCESS; 492 508 } 493 509 494 510 l = Lease(client); /* re-new */ 495 511 return VINF_SUCCESS; … … 668 684 RT_ZERO(BootPReplyMsg); 669 685 cbBooPReplyMsg = 0; 670 686 671 687 m_OurAddress.u = 0; 672 688 m_OurNetmask.u = 0; … … 803 819 804 820 prepareReplyPacket4Client(client, u32Xid); 805 821 806 822 Lease l = client.lease(); 807 823 address = l.getAddress(); … … 926 942 Cursor.optIPv4Addr(RTNET_DHCP_OPT_SERVER_ID, m->m_OurAddress); 927 943 928 const Lease l = client.lease(); 944 const Lease l = client.lease(); 929 945 const std::map<uint8_t, RawOption>& options = l.options(); 930 946 931 for(std::vector<RawOption>::const_iterator it = extra.begin(); 947 for(std::vector<RawOption>::const_iterator it = extra.begin(); 932 948 it != extra.end(); ++it) 933 949 { … … 938 954 } 939 955 940 for(std::map<uint8_t, RawOption>::const_iterator it = options.begin(); 956 for(std::map<uint8_t, RawOption>::const_iterator it = options.begin(); 941 957 it != options.end(); ++it) 942 958 { … … 953 969 #if 0 954 970 /** @todo need to see someone set this flag to check that it's correct. */ 955 if (!(pDhcpMsg->bp_flags & RTNET_DHCP_FLAGS_NO_BROADCAST)) 971 if (!(pDhcpMsg->bp_flags & RTNET_DHCP_FLAGS_NO_BROADCAST)) 956 972 { 957 973 rc = VBoxNetUDPUnicast(m_pSession, … … 970 986 rc = m->m_service->hlpUDPBroadcast(RTNETIPV4_PORT_BOOTPS, /* sender */ 971 987 RTNETIPV4_PORT_BOOTPC, 972 &m->BootPReplyMsg, 988 &m->BootPReplyMsg, 973 989 RTNET_DHCP_NORMAL_SIZE); 974 990 … … 979 995 980 996 981 int NetworkManager::processParameterReqList(const Client& client, const uint8_t *pu8ReqList, 997 int NetworkManager::processParameterReqList(const Client& client, const uint8_t *pu8ReqList, 982 998 int cReqList, std::vector<RawOption>& extra) 983 999 { 984 1000 const Lease l = client.lease(); 985 1001 986 1002 const NetworkConfigEntity *pNetCfg = l.getConfig(); 987 1003 … … 1224 1240 if (!valueAddition) return false; 1225 1241 1226 xml::ElementNode *address = node->createChild(tagXMLLeaseAddress.c_str()); 1242 xml::ElementNode *address = node->createChild(tagXMLLeaseAddress.c_str()); 1227 1243 if (!address) return false; 1228 1244 … … 1230 1246 if (!valueAddition) return false; 1231 1247 1232 xml::ElementNode *time = node->createChild(tagXMLLeaseTime.c_str()); 1248 xml::ElementNode *time = node->createChild(tagXMLLeaseTime.c_str()); 1233 1249 if (!time) return false; 1234 1250 1235 valueAddition = time->setAttribute(tagXMLTimeAttributeIssued.c_str(), 1251 valueAddition = time->setAttribute(tagXMLTimeAttributeIssued.c_str(), 1236 1252 m->u64TimestampLeasingStarted); 1237 1253 if (!valueAddition) return false; 1238 1254 1239 valueAddition = time->setAttribute(tagXMLTimeAttributeExpiration.c_str(), 1255 valueAddition = time->setAttribute(tagXMLTimeAttributeExpiration.c_str(), 1240 1256 m->u32LeaseExpirationPeriod); 1241 1257 if (!valueAddition) return false; … … 1266 1282 if (!valueExists) return false; 1267 1283 rc = RTNetStrToIPv4Addr(addressValue.c_str(), &m->m_address); 1268 1284 1269 1285 /* Time */ 1270 1286 const xml::ElementNode *time = node->findChildElement(tagXMLLeaseTime.c_str()); 1271 1287 if (!time) return false; 1272 1288 1273 valueExists = time->getAttributeValue(tagXMLTimeAttributeIssued.c_str(), 1289 valueExists = time->getAttributeValue(tagXMLTimeAttributeIssued.c_str(), 1274 1290 &m->u64TimestampLeasingStarted); 1275 1291 if (!valueExists) return false; 1276 1292 m->fBinding = false; 1277 1278 valueExists = time->getAttributeValue(tagXMLTimeAttributeExpiration.c_str(), 1293 1294 valueExists = time->getAttributeValue(tagXMLTimeAttributeExpiration.c_str(), 1279 1295 &m->u32LeaseExpirationPeriod); 1280 1296 if (!valueExists) return false; … … 1287 1303 const Lease Lease::NullLease; 1288 1304 1289 1290 1305 const Client Client::NullClient; -
trunk/src/VBox/NetworkServices/DHCP/Config.h
r49926 r50213 17 17 18 18 #ifndef _CONFIG_H_ 19 # 19 #define _CONFIG_H_ 20 20 21 21 #include <iprt/asm-math.h> … … 121 121 bool isInBindingPhase() const; 122 122 /* returns 0 if in binding state */ 123 uint64_t issued() const; 123 uint64_t issued() const; 124 124 125 125 void setExpiration(uint32_t); -
trunk/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp
r49859 r50213 254 254 case 'l': 255 255 case 'u': 256 case 'g': 256 case 'g': 257 257 { 258 258 char buf[17]; … … 287 287 netManager->setOurMac(getMacAddress()); 288 288 netManager->setService(this); 289 289 290 290 if (isMainNeeded()) 291 291 rc = initWithMain(); … … 465 465 case 'b': 466 466 break; 467 467 468 468 } 469 469 } 470 470 471 471 ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager(); 472 472 AssertPtrReturn(confManager, VERR_INTERNAL_ERROR); … … 569 569 570 570 { 571 VBoxNetALock(this); 571 VBoxNetALock(this); 572 572 ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager(); 573 573 confManager->flushAddressList(RTNET_DHCP_OPT_DNS); … … 575 575 for (AddressList::iterator it = nameservers.begin(); it != nameservers.end(); ++it) 576 576 confManager->addToAddressList(RTNET_DHCP_OPT_DNS, *it); 577 577 578 578 confManager->setString(RTNET_DHCP_OPT_DOMAIN_NAME, domain); 579 579 } 580 580 } 581 581 582 582 return VINF_SUCCESS; 583 583 } -
trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp
r50082 r50213 224 224 break; 225 225 } 226 226 227 227 case VBoxEventType_OnNATNetworkPortForward: 228 228 { … … 540 540 541 541 size_t idx = 0; 542 for (struct pbuf *q = pPBuf; q != NULL; q = q->next, ++idx) 542 for (struct pbuf *q = pPBuf; q != NULL; q = q->next, ++idx) 543 543 { 544 544 AssertReturn(idx < RT_ELEMENTS(VBoxNetLwipNAT::aXmitSeg), ERR_MEM); … … 605 605 address.u = RT_MAKE_U32_FROM_U8( 10, 0, 2, 2); // NB: big-endian 606 606 setIpv4Address(address); 607 607 608 608 address.u = RT_H2N_U32_C(0xffffff00); 609 609 setIpv4Netmask(address); … … 701 701 702 702 /** This method executed on main thread, only at the end threr're one threads started explcitly (LWIP and later in ::run() 703 * RECV) 703 * RECV) 704 704 */ 705 705 int VBoxNetLwipNAT::init() … … 777 777 unsigned long i = 0; 778 778 for (AddressToOffsetMapping::iterator it = tmp.begin(); 779 it != tmp.end() && i < RT_ELEMENTS(m_lo2off); 779 it != tmp.end() && i < RT_ELEMENTS(m_lo2off); 780 780 ++it, ++i) 781 781 { … … 942 942 cbFrame - sizeof(PDMNETWORKGSO))) 943 943 return VERR_INVALID_PARAMETER; 944 944 945 945 cbFrame -= sizeof(PDMNETWORKGSO); 946 946 uint8_t abHdrScratch[256]; … … 1127 1127 Log(("%d-%s rule: %ls\n", idxRules, (fIsIPv6 ? "IPv6" : "IPv4"), rules[idxRules])); 1128 1128 RT_ZERO(Rule); 1129 1129 1130 1130 int rc = netPfStrToPf(com::Utf8Str(rules[idxRules]).c_str(), 0, &Rule.Pfr); 1131 1131 if (RT_FAILURE(rc)) 1132 1132 continue; 1133 1133 1134 1134 vec.push_back(Rule); 1135 1135 } -
trunk/src/VBox/NetworkServices/NetLib/ComHostUtils.cpp
r49830 r50213 122 122 * variant but it's C++11. 123 123 */ 124 int hostDnsServers(const ComHostPtr& host, const RTNETADDRIPV4& networkid, 124 int hostDnsServers(const ComHostPtr& host, const RTNETADDRIPV4& networkid, 125 125 /*const*/ AddressToOffsetMapping& mapping, AddressList& servers) 126 126 { … … 166 166 167 167 ComBstrArray strs; 168 if (SUCCEEDED(host->COMGETTER(SearchStrings)(ComSafeArrayAsOutParam(strs)))) 168 if (SUCCEEDED(host->COMGETTER(SearchStrings)(ComSafeArrayAsOutParam(strs)))) 169 169 { 170 170 for (unsigned int i = 0; i < strs.size(); ++i) … … 193 193 194 194 195 int createNatListener(ComNatListenerPtr& listener, const ComVirtualBoxPtr& vboxptr, 195 int createNatListener(ComNatListenerPtr& listener, const ComVirtualBoxPtr& vboxptr, 196 196 NATNetworkEventAdapter *adapter, /* const */ ComEventTypeArray& events) 197 197 { -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.cpp
r49842 r50213 726 726 { 727 727 AssertMsgReturn(isMainNeeded(), ("It's expected that we need Main"), VERR_INTERNAL_ERROR); 728 728 729 729 /* start receiving thread */ 730 730 int rc = RTThreadCreate(&m->m_hThrRecv, /* thread handle*/ … … 743 743 { 744 744 m->m_EventQ->processEventQueue(0); 745 745 746 746 if (m->fShutdown) 747 747 break; -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h
r49842 r50213 57 57 }; 58 58 59 # ifndef BASE_SERVICES_ONLY 59 # ifndef BASE_SERVICES_ONLY 60 60 class VBoxNetBaseService: public VBoxNetHlpUDPService, public VBoxNetLockee 61 61 { -
trunk/src/VBox/NetworkServices/NetLib/shared_ptr.h
r49339 r50213 3 3 4 4 #ifdef __cplusplus 5 template<typename T> 5 template<typename T> 6 6 class SharedPtr 7 7 { 8 struct imp 8 struct imp 9 9 { 10 10 imp(T *pTrg = NULL, int cnt = 1): ptr(pTrg),refcnt(cnt){} … … 15 15 }; 16 16 17 17 18 18 public: 19 19 SharedPtr(T *t = NULL):p(NULL) … … 21 21 p = new imp(t); 22 22 } 23 23 24 24 ~SharedPtr() 25 25 { … … 40 40 { 41 41 if (p == rhs.p) return *this; 42 42 43 43 p->refcnt--; 44 if (p->refcnt == 0) 44 if (p->refcnt == 0) 45 45 delete p; 46 46 … … 57 57 } 58 58 59 59 60 60 T *operator->() 61 61 { … … 63 63 } 64 64 65 65 66 66 const T*operator->() const 67 67 { … … 79 79 }; 80 80 #endif 81 81 82 #endif -
trunk/src/VBox/NetworkServices/NetLib/utils.h
r49825 r50213 33 33 typedef std::map<RTNETADDRIPV4, int> AddressToOffsetMapping; 34 34 35 35 36 36 inline bool isDhcpRequired(const ComNatPtr& nat) 37 37 { … … 39 39 if (FAILED(nat->COMGETTER(NeedDhcpServer)(&fNeedDhcpServer))) 40 40 return false; 41 41 42 42 return fNeedDhcpServer; 43 43 } … … 49 49 dhcp.asOutParam()); 50 50 AssertComRCReturn(hrc, VERR_NOT_FOUND); 51 51 52 52 return VINF_SUCCESS; 53 53 } … … 60 60 61 61 AssertComRCReturn(hrc, VERR_NOT_FOUND); 62 62 63 63 return VINF_SUCCESS; 64 64 } … … 120 120 typedef ListenerImpl<NATNetworkListener, NATNetworkEventAdapter*> NATNetworkListenerImpl; 121 121 122 # if VBOX_WITH_XPCOM 122 # if VBOX_WITH_XPCOM 123 123 class NS_CLASSINFO_NAME(NATNetworkListenerImpl); 124 124 # endif … … 127 127 typedef com::SafeArray<VBoxEventType_T> ComEventTypeArray; 128 128 129 /* XXX: const is commented out because of compilation erro on Windows host, but it's intended that this function 129 /* XXX: const is commented out because of compilation erro on Windows host, but it's intended that this function 130 130 isn't modify event type array */ 131 int createNatListener(ComNatListenerPtr& listener, const ComVirtualBoxPtr& vboxptr, 131 int createNatListener(ComNatListenerPtr& listener, const ComVirtualBoxPtr& vboxptr, 132 132 NATNetworkEventAdapter *adapter, /* const */ ComEventTypeArray& events); 133 133 #endif
Note:
See TracChangeset
for help on using the changeset viewer.