Changeset 50213 in vbox for trunk/src/VBox/NetworkServices/DHCP
- Timestamp:
- Jan 24, 2014 8:23:12 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 91785
- Location:
- trunk/src/VBox/NetworkServices/DHCP
- Files:
-
- 4 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 }
Note:
See TracChangeset
for help on using the changeset viewer.