- Timestamp:
- Jul 6, 2013 5:42:33 PM (12 years ago)
- Location:
- trunk/src/VBox/NetworkServices/DHCP
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/DHCP/Config.cpp
r47019 r47020 65 65 } 66 66 67 /* Configs 67 /* Configs 68 68 NetworkConfigEntity(std::string name, 69 69 ConfigEntity* pCfg, 70 70 ClientMatchCriteria* criteria, 71 RTNETADDRIPV4& networkID, 71 RTNETADDRIPV4& networkID, 72 72 RTNETADDRIPV4& networkMask) 73 73 */ … … 89 89 90 90 /* 91 * XXX: it sounds like a hack, we use packet descriptor to get the session, 92 * instead use corresponding functions in NetworkManager to fetch client identification 91 * XXX: it sounds like a hack, we use packet descriptor to get the session, 92 * instead use corresponding functions in NetworkManager to fetch client identification 93 93 * (note: it isn't only mac driven) and XID for the session. 94 94 */ 95 95 96 96 /** 97 * XXX: what about leases ... Lease is a committed Session.... 97 * XXX: what about leases ... Lease is a committed Session.... 98 98 */ 99 99 Session& SessionManager::getClientSessionByDhcpPacket(const RTNETBOOTP *pDhcpMsg, size_t cbDhcpMsg) 100 100 { 101 101 102 102 VecClientIterator it; 103 103 bool fDhcpValid = false; … … 121 121 { 122 122 /* We hasn't got any session for this client */ 123 m_clients.push_back(Client(pDhcpMsg->bp_chaddr.Mac, 123 m_clients.push_back(Client(pDhcpMsg->bp_chaddr.Mac, 124 124 pDhcpMsg->bp_xid)); 125 125 Client& client = m_clients.back(); 126 client.m_sessions.insert(Map2ClientSessionType(xid, Session(&client, xid))); 126 client.m_sessions.insert(Map2ClientSessionType(xid, Session(&client, xid))); 127 127 Assert(client.m_sessions[xid].m_pClient); 128 128 return client.m_sessions[xid]; … … 149 149 /* MAY: todo */ 150 150 rc = ConfigurationManager::findOption(RTNET_DHCP_OPT_LEASE_TIME, pDhcpMsg, cbDhcpMsg, opt); 151 151 152 152 /* MAY: not now */ 153 153 rc = ConfigurationManager::findOption(RTNET_DHCP_OPT_CLIENT_ID, pDhcpMsg, cbDhcpMsg, opt); 154 /* XXX: MAY 154 /* XXX: MAY 155 155 ConfigurationManager::findOption(RTNET_DHCP_OPT_VENDOR_CLASS_IDENTIFIER, pDhcpMsg, opt); 156 156 */ … … 179 179 /* MAY */ 180 180 ConfigurationManager::findOption(RTNET_DHCP_OPT_CLIENT_ID, pDhcpMsg, cbDhcpMsg, opt); 181 /* XXX: MAY 181 /* XXX: MAY 182 182 ConfigurationManager::findOption(RTNET_DHCP_OPT_VENDOR_CLASS_IDENTIFIER, pDhcpMsg, opt); 183 183 */ … … 219 219 if (!g_ConfigurationManager) 220 220 g_ConfigurationManager = new ConfigurationManager(); 221 221 222 222 return g_ConfigurationManager; 223 223 } … … 294 294 295 295 /** 296 * We've find the config for session ... 297 * XXX: using Session's private members 296 * We've find the config for session ... 297 * XXX: using Session's private members 298 298 */ 299 299 int ConfigurationManager::findConfiguration4Session(Session& session) 300 300 { 301 /* XXX: state switching broken? 301 /* XXX: state switching broken? 302 302 * XXX: DHCPDECLINE and DHCPINFO should we support them. 303 303 */ … … 313 313 else 314 314 return VERR_INTERNAL_ERROR; /* XXX: is it really *internal* error? Perhaps some misconfiguration */ 315 315 316 316 } 317 317 … … 322 322 { 323 323 /** 324 * Well, session hasn't get the config. 324 * Well, session hasn't get the config. 325 325 */ 326 326 AssertPtrReturn(session.m_pCfg, VERR_INTERNAL_ERROR); 327 327 328 328 bool fWithAddressHint = (session.addressHint.u != 0); 329 329 330 330 if (fWithAddressHint) 331 331 { … … 349 349 */ 350 350 AssertReturn(session.m_state == DHCPDISCOVERRECEIEVED, VERR_INTERNAL_ERROR); 351 351 352 352 /** 353 353 * XXX: this is wrong allocation check... … … 355 355 */ 356 356 MapSession2Ip4AddressIterator it = m_allocations.find(session); 357 357 358 358 if (it == m_allocations.end()) 359 359 { 360 360 /* XXX: not optimal allocation */ 361 361 const NetworkConfigEntity *pNetCfg = dynamic_cast<const NetworkConfigEntity *>(session.m_pCfg); 362 362 363 363 /** 364 364 * Check config class. 365 365 */ 366 366 AssertPtrReturn(pNetCfg, VERR_INTERNAL_ERROR); 367 367 368 368 uint32_t u32Address = RT_N2H_U32(pNetCfg->lowerIp().u); 369 369 while (u32Address < RT_N2H_U32(pNetCfg->upperIp().u)) … … 380 380 if (RT_N2H_U32(addressIterator->second.u) == u32Address) 381 381 { 382 /* 383 * This address is taken 384 * XXX: check if session isn't expired... if expired we can 385 * reuse it for this request 382 /* 383 * This address is taken 384 * XXX: check if session isn't expired... if expired we can 385 * reuse it for this request 386 386 */ 387 387 /* XXX: fTakeAddress = true; owning session is expired */ … … 390 390 } 391 391 } /* end of for over allocations */ 392 392 393 393 if (!fFound) 394 394 { … … 401 401 u32Address ++; 402 402 } /* end of while over candidates */ 403 404 } 405 403 404 } 405 406 406 /* XXX: really??? */ 407 407 session.switchTo(DHCPOFFERPREPARED); … … 414 414 /**/ 415 415 session.switchTo(DHCPACKNAKPREPARED); 416 416 417 417 /* XXX: clean up the rest of the session, now this session LEASE!!! */ 418 418 return VINF_SUCCESS; … … 425 425 426 426 427 NetworkConfigEntity *ConfigurationManager::addNetwork(NetworkConfigEntity *pCfg, 427 NetworkConfigEntity *ConfigurationManager::addNetwork(NetworkConfigEntity *pCfg, 428 428 const RTNETADDRIPV4& networkId, 429 429 const RTNETADDRIPV4& netmask, 430 RTNETADDRIPV4& LowerAddress, 430 RTNETADDRIPV4& LowerAddress, 431 431 RTNETADDRIPV4& UpperAddress) 432 432 { 433 433 static int id; 434 434 char name[64]; 435 435 436 436 RTStrPrintf(name, RT_ELEMENTS(name), "network-%d", id); 437 437 std::string strname(name); 438 438 id++; 439 439 440 440 441 441 if (!LowerAddress.u) 442 442 LowerAddress = networkId; … … 445 445 UpperAddress.u = networkId.u | (~netmask.u); 446 446 447 return new NetworkConfigEntity(strname, 448 g_RootConfig, 447 return new NetworkConfigEntity(strname, 448 g_RootConfig, 449 449 g_AnyClient, 450 450 5, 451 451 networkId, 452 452 netmask, 453 LowerAddress, 453 LowerAddress, 454 454 UpperAddress); 455 455 } 456 456 457 HostConfigEntity *ConfigurationManager::addHost(NetworkConfigEntity* pCfg, 458 const RTNETADDRIPV4& address, 457 HostConfigEntity *ConfigurationManager::addHost(NetworkConfigEntity* pCfg, 458 const RTNETADDRIPV4& address, 459 459 ClientMatchCriteria *criteria) 460 460 { 461 461 static int id; 462 462 char name[64]; 463 463 464 464 RTStrPrintf(name, RT_ELEMENTS(name), "host-%d", id); 465 465 std::string strname(name); 466 466 id++; 467 467 468 468 return new HostConfigEntity(address, strname, pCfg, criteria); 469 } 469 } 470 470 471 471 /** … … 495 495 /* Ubuntu ???*/ 496 496 BootPReplyMsg.BootPHeader.bp_ciaddr = address; 497 498 /* options: 497 498 /* options: 499 499 * - IP lease time 500 500 * - message type … … 503 503 RawOption opt; 504 504 RT_ZERO(opt); 505 505 506 506 /* XXX: can't store options per session */ 507 507 Client *client = unconst(session.m_pClient); 508 508 AssertPtr(client); 509 509 510 510 opt.u8OptId = RTNET_DHCP_OPT_MSG_TYPE; 511 511 opt.au8RawOpt[0] = RTNET_DHCP_MT_OFFER; … … 523 523 client->rawOptions.push_back(opt); 524 524 525 processParameterReqList(session); 525 processParameterReqList(session); 526 526 527 527 return doReply(session); … … 541 541 address = ConfigurationManager::getConfigurationManager()->getSessionAddress(session); 542 542 BootPReplyMsg.BootPHeader.bp_ciaddr = address; 543 544 545 /* rfc2131 4.3.1 is about DHCPDISCOVER and this value is equal to ciaddr from 546 * DHCPREQUEST or 0 ... 543 544 545 /* rfc2131 4.3.1 is about DHCPDISCOVER and this value is equal to ciaddr from 546 * DHCPREQUEST or 0 ... 547 547 * XXX: Using addressHint is not correct way to initialize [cy]iaddress... 548 548 */ … … 551 551 552 552 Assert(BootPReplyMsg.BootPHeader.bp_yiaddr.u); 553 554 /* options: 553 554 /* options: 555 555 * - IP address lease time (if DHCPREQUEST) 556 556 * - message type … … 585 585 prepareReplyPacket4Session(session); 586 586 587 /* this field filed in prepareReplyPacket4Session, and 587 /* this field filed in prepareReplyPacket4Session, and 588 588 * RFC 2131 require to have it zero fo NAK. 589 589 */ 590 590 BootPReplyMsg.BootPHeader.bp_yiaddr.u = 0; 591 591 592 /* options: 592 /* options: 593 593 * - message type (if DHCPREQUEST) 594 594 * - server identifier … … 611 611 612 612 /** 613 * 613 * 614 614 */ 615 615 int NetworkManager::prepareReplyPacket4Session(const Session& session) … … 624 624 BootPReplyMsg.BootPHeader.bp_secs = 0; 625 625 /* XXX: bp_flags should be processed specially */ 626 BootPReplyMsg.BootPHeader.bp_flags = 0; 626 BootPReplyMsg.BootPHeader.bp_flags = 0; 627 627 BootPReplyMsg.BootPHeader.bp_ciaddr.u = 0; 628 628 BootPReplyMsg.BootPHeader.bp_giaddr.u = 0; … … 631 631 BootPReplyMsg.BootPHeader.bp_chaddr.Mac = session.m_pClient->m_mac; 632 632 633 BootPReplyMsg.BootPHeader.bp_yiaddr = 634 ConfigurationManager::getConfigurationManager()->getSessionAddress(session); 633 BootPReplyMsg.BootPHeader.bp_yiaddr = 634 ConfigurationManager::getConfigurationManager()->getSessionAddress(session); 635 635 636 636 BootPReplyMsg.BootPHeader.bp_siaddr.u = 0; 637 637 638 638 639 639 BootPReplyMsg.BootPHeader.bp_vend.Dhcp.dhcp_cookie = RT_H2N_U32_C(RTNET_DHCP_COOKIE); 640 640 641 memset(&BootPReplyMsg.BootPHeader.bp_vend.Dhcp.dhcp_opts[0], 642 '\0', 641 memset(&BootPReplyMsg.BootPHeader.bp_vend.Dhcp.dhcp_opts[0], 642 '\0', 643 643 RTNET_DHCP_OPT_SIZE); 644 644 … … 650 650 { 651 651 int rc; 652 652 653 653 /* 654 654 Options.... … … 663 663 664 664 Cursor.optIPv4Addr(RTNET_DHCP_OPT_SERVER_ID, m_OurAddress); 665 665 666 666 while(!cl->rawOptions.empty()) 667 667 { … … 694 694 } 695 695 696 /* 696 /* 697 697 */ 698 698 #if 0 699 699 if (!(pDhcpMsg->bp_flags & RTNET_DHCP_FLAGS_NO_BROADCAST)) /** @todo need to see someone set this flag to check that it's correct. */ 700 700 { 701 rc = VBoxNetUDPUnicast(m_pSession, 702 m_hIf, 701 rc = VBoxNetUDPUnicast(m_pSession, 702 m_hIf, 703 703 m_pIfBuf, 704 m_OurAddress, 705 &m_OurMac, 704 m_OurAddress, 705 &m_OurMac, 706 706 RTNETIPV4_PORT_BOOTPS, /* sender */ 707 IPv4AddrBrdCast, 708 &BootPReplyMsg.BootPHeader->bp_chaddr.Mac, 707 IPv4AddrBrdCast, 708 &BootPReplyMsg.BootPHeader->bp_chaddr.Mac, 709 709 RTNETIPV4_PORT_BOOTPC, /* receiver */ 710 710 &BootPReplyMsg, cbBooPReplyMsg); … … 712 712 else 713 713 #endif 714 rc = VBoxNetUDPBroadcast(m_pSession, 715 m_hIf, 714 rc = VBoxNetUDPBroadcast(m_pSession, 715 m_hIf, 716 716 m_pIfBuf, 717 m_OurAddress, 718 &m_OurMac, 717 m_OurAddress, 718 &m_OurMac, 719 719 RTNETIPV4_PORT_BOOTPS, /* sender */ 720 RTNETIPV4_PORT_BOOTPC, 720 RTNETIPV4_PORT_BOOTPC, 721 721 &BootPReplyMsg, RTNET_DHCP_NORMAL_SIZE); 722 722 723 723 AssertRCReturn(rc,rc); 724 724 725 725 return VINF_SUCCESS; 726 726 } … … 730 730 { 731 731 /* request parameter list */ 732 RawOption opt; 732 RawOption opt; 733 733 int idxParam = 0; 734 734 … … 745 745 { 746 746 747 RT_ZERO(opt); 747 RT_ZERO(opt); 748 748 opt.u8OptId = pReqList[idxParam]; 749 749 switch(pReqList[idxParam]) -
trunk/src/VBox/NetworkServices/DHCP/Config.h
r47019 r47020 33 33 */ 34 34 DHCPNONSENSE, 35 /** We've received dhcp discover => 35 /** We've received dhcp discover => 36 36 * we're starting new client and/or session. 37 37 * Using XID (we record session) … … 44 44 DHCPOFFERPREPARED, 45 45 /** 46 * This more, session state, we responsed, to 46 * This more, session state, we responsed, to 47 47 * client with DHCPOFFER using session's XID 48 48 */ … … 58 58 /** 59 59 * We've been able to furfill client's request for (XID) session, erased others Client 60 * 's sessions ... and send DHCPACK (should be Lease bind at this point?) 60 * 's sessions ... and send DHCPACK (should be Lease bind at this point?) 61 61 */ 62 62 DHCPACKSENT, … … 90 90 91 91 /** 92 * This class joins client and the lease ... 92 * This class joins client and the lease ... 93 93 * at the begining client might request several address assignments... 94 * 94 * 95 95 * So session here is descriptor joining client to each of it's requests. 96 96 * When client finalizes its selection ... only single assignment is chosen, … … 100 100 { 101 101 public: 102 Session(const Client *client = NULL, 103 uint32_t xid = 0, 104 CLIENTSESSIONSTATE enmState = DHCPNONSENSE): 102 Session(const Client *client = NULL, 103 uint32_t xid = 0, 104 CLIENTSESSIONSTATE enmState = DHCPNONSENSE): 105 105 m_pClient(client), 106 106 m_state(enmState), … … 112 112 RT_ZERO(reqParamList); 113 113 } 114 114 115 115 bool operator < (const Session& s) const; 116 116 117 117 int switchTo(CLIENTSESSIONSTATE); 118 118 /* XXX private: */ … … 120 120 /**/ 121 121 const Client* m_pClient; 122 /* We don't store the state in the client, because client might initiate several 122 /* We don't store the state in the client, because client might initiate several 123 123 * sessions. 124 124 */ 125 125 CLIENTSESSIONSTATE m_state; 126 /** 127 * uniq identificator of session 126 /** 127 * uniq identificator of session 128 128 */ 129 129 uint32_t m_u32Xid; 130 130 131 131 /* dhcp-opts: request address */ 132 132 RTNETADDRIPV4 addressHint; … … 156 156 private: 157 157 const Client *m_pClient; 158 158 159 159 bool operator == (const Session& session) const 160 160 { … … 168 168 typedef MapLease2Ip4Address::iterator MapLease2Ip4AddressIterator; 169 169 170 /* 171 * it's a basic representation of 170 /* 171 * it's a basic representation of 172 172 * of out undestanding what client is 173 * XXX: Client might sends Option 61 (RFC2132 9.14 "Client-identifier") signalling 173 * XXX: Client might sends Option 61 (RFC2132 9.14 "Client-identifier") signalling 174 174 * that we may identify it in special way 175 * 175 * 176 176 * XXX: Client might send Option 60 (RFC2132 9.13 "Vendor class undentifier") 177 * in response it's expected server sends Option 43 (RFC2132 8.4. "Vendor Specific Information") 177 * in response it's expected server sends Option 43 (RFC2132 8.4. "Vendor Specific Information") 178 178 */ 179 class Client 179 class Client 180 180 { 181 181 public: … … 183 183 /* XXX: Option 60 and 61 */ 184 184 Client(const RTMAC& mac, uint32_t xid = 0); 185 186 bool operator== (const RTMAC& mac) const 187 { 188 return ( m_mac.au16[0] == mac.au16[0] 189 && m_mac.au16[1] == mac.au16[1] 185 186 bool operator== (const RTMAC& mac) const 187 { 188 return ( m_mac.au16[0] == mac.au16[0] 189 && m_mac.au16[1] == mac.au16[1] 190 190 && m_mac.au16[2] == mac.au16[2]); 191 191 } 192 192 /** Dumps client query */ 193 193 void dump(); 194 194 195 195 /* XXX! private: */ 196 196 197 197 RTMAC m_mac; 198 198 Map2ClientSession m_sessions; … … 213 213 214 214 static SessionManager* getSessionManager(); 215 215 216 216 /** 217 217 * This method we call on every DHCP packet we've received. … … 219 219 */ 220 220 Session& getClientSessionByDhcpPacket(const RTNETBOOTP* pDhcpMsg, size_t cbPacket); 221 221 222 222 /* XXX: DHCPDECLINE */ 223 223 void releaseClientSession(Session& session); … … 226 226 227 227 private: 228 228 229 229 VecClient m_clients; 230 230 … … 251 251 */ 252 252 int findConfiguration4Session(Session& session); 253 253 254 254 /** 255 255 * XXX: it's could be done on DHCPOFFER or on DHCPACK (rfc2131 gives freedom here 256 * 3.1.2, what is strict that allocation should do address check before real 257 * allocation)... 256 * 3.1.2, what is strict that allocation should do address check before real 257 * allocation)... 258 258 */ 259 259 int allocateConfiguration4Session(Session& session); 260 260 261 261 /* 262 262 * We call this before DHCPACK sent and after DHCPREQUEST received ... … … 266 266 267 267 static int findOption(uint8_t uOption, PCRTNETBOOTP pDhcpMsg, size_t cbDhcpMsg, RawOption& opt); 268 269 NetworkConfigEntity *addNetwork(NetworkConfigEntity *pCfg, 268 269 NetworkConfigEntity *addNetwork(NetworkConfigEntity *pCfg, 270 270 const RTNETADDRIPV4& networkId, 271 271 const RTNETADDRIPV4& netmask, 272 RTNETADDRIPV4& UpperAddress, 272 RTNETADDRIPV4& UpperAddress, 273 273 RTNETADDRIPV4& LowerAddress); 274 274 275 275 HostConfigEntity *addHost(NetworkConfigEntity*, const RTNETADDRIPV4&, ClientMatchCriteria*); 276 276 277 277 RTNETADDRIPV4 getSessionAddress(const Session& session); 278 278 … … 321 321 case RTNET_DHCP_OPT_ROUTERS: 322 322 return m_routers; 323 323 324 324 } 325 325 /* XXX: Grrr !!! */ … … 345 345 public: 346 346 static NetworkManager *getNetworkManager(); 347 347 348 348 int offer4Session(Session& ses); 349 349 int ack(Session& ses); … … 352 352 const RTNETADDRIPV4& getOurAddress(){ return m_OurAddress;} 353 353 const RTNETADDRIPV4& getOurNetmask(){ return m_OurNetmask;} 354 const RTMAC& getOurMac() {return m_OurMac;} 354 const RTMAC& getOurMac() {return m_OurMac;} 355 355 356 356 void setOurAddress(const RTNETADDRIPV4& aAddress){ m_OurAddress = aAddress;} 357 357 void setOurNetmask(const RTNETADDRIPV4& aNetmask){ m_OurNetmask = aNetmask;} 358 void setOurMac(const RTMAC& aMac) {m_OurMac = aMac;} 358 void setOurMac(const RTMAC& aMac) {m_OurMac = aMac;} 359 359 360 360 /* XXX: artifacts should be hidden or removed from here. */ … … 377 377 RTNETADDRIPV4 m_OurNetmask; 378 378 RTMAC m_OurMac; 379 379 380 380 NetworkManager(){} 381 381 virtual ~NetworkManager(){} … … 401 401 m_right = right; 402 402 } 403 403 404 404 virtual bool check(const Client& client) const 405 405 { … … 418 418 m_right = right; 419 419 } 420 420 421 421 virtual bool check(const Client& client) const 422 422 { … … 440 440 public: 441 441 MACClientMatchCriteria(const RTMAC& mac):m_mac(mac){} 442 442 443 443 virtual bool check(const Client& client) const 444 444 { … … 475 475 { 476 476 public: 477 BaseConfigEntity(const ClientMatchCriteria *criteria = NULL, 477 BaseConfigEntity(const ClientMatchCriteria *criteria = NULL, 478 478 int matchingLevel = 0) 479 479 : m_criteria(criteria), … … 486 486 return 0; 487 487 } 488 488 489 489 /* Should return how strong matching */ 490 virtual int match(const Client& client, const BaseConfigEntity **cfg) const 490 virtual int match(const Client& client, const BaseConfigEntity **cfg) const 491 491 { 492 492 int iMatch = (m_criteria && m_criteria->check(client)? m_MatchLevel: 0); … … 557 557 unconst(m_parentCfg)->add(this); 558 558 } 559 559 560 560 std::string m_name; 561 561 const BaseConfigEntity *m_parentCfg; … … 564 564 565 565 /** 566 * Network specific entries 566 * Network specific entries 567 567 */ 568 568 class NetworkConfigEntity:public ConfigEntity … … 574 574 const ClientMatchCriteria *criteria, 575 575 int matchlvl, 576 const RTNETADDRIPV4& networkID, 576 const RTNETADDRIPV4& networkID, 577 577 const RTNETADDRIPV4& networkMask, 578 578 const RTNETADDRIPV4& lowerIP, … … 585 585 { 586 586 }; 587 587 588 588 NetworkConfigEntity(std::string name, 589 589 const BaseConfigEntity *cfg, 590 590 const ClientMatchCriteria *criteria, 591 const RTNETADDRIPV4& networkID, 591 const RTNETADDRIPV4& networkID, 592 592 const RTNETADDRIPV4& networkMask): 593 593 ConfigEntity(name, cfg, criteria, 5), … … 612 612 613 613 614 /** 614 /** 615 615 * Host specific entry 616 616 * Address pool is contains one element … … 622 622 HostConfigEntity(const RTNETADDRIPV4& addr, 623 623 std::string name, 624 const NetworkConfigEntity *cfg, 624 const NetworkConfigEntity *cfg, 625 625 const ClientMatchCriteria *criteria): 626 NetworkConfigEntity(name, 627 static_cast<const ConfigEntity*>(cfg), 628 criteria, 629 10, 630 cfg->networkId(), 631 cfg->netmask(), 632 addr, 626 NetworkConfigEntity(name, 627 static_cast<const ConfigEntity*>(cfg), 628 criteria, 629 10, 630 cfg->networkId(), 631 cfg->netmask(), 632 addr, 633 633 addr) 634 634 { … … 636 636 } 637 637 638 virtual int match(const Client& client) const 639 { 638 virtual int match(const Client& client) const 639 { 640 640 return (m_criteria->check(client) ? 10 : 0); 641 641 } … … 653 653 #if 0 654 654 /** 655 * Shared regions e.g. some of configured networks declarations 655 * Shared regions e.g. some of configured networks declarations 656 656 * are cover each other. 657 * XXX: Shared Network is join on Network config entities with possible 658 * overlaps in address pools. for a moment we won't configure and use them them 657 * XXX: Shared Network is join on Network config entities with possible 658 * overlaps in address pools. for a moment we won't configure and use them them 659 659 */ 660 660 class SharedNetworkConfigEntity: public NetworkEntity … … 663 663 SharedNetworkConfigEntity(){} 664 664 int match(const Client& client) const { return m_criteria.match(client)? 3 : 0;} 665 665 666 666 SharedNetworkConfigEntity(NetworkEntity& network) 667 667 { … … 669 669 } 670 670 virtual ~SharedNetworkConfigEntity(){} 671 671 672 672 std::vector<NetworkConfigEntity> Networks; 673 673 674 674 }; 675 675 #endif -
trunk/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp
r47019 r47020 80 80 * DHCP server instance. 81 81 */ 82 class VBoxNetDhcp: public VBoxNetBaseService 82 class VBoxNetDhcp: public VBoxNetBaseService 83 83 { 84 84 public: … … 104 104 /** @name The DHCP server specific configuration data members. 105 105 * @{ */ 106 /* 106 /* 107 107 * XXX: what was the plan? SQL3 or plain text file? 108 * How it will coexists with managment from VBoxManagement, who should manage db 108 * How it will coexists with managment from VBoxManagement, who should manage db 109 109 * in that case (VBoxManage, VBoxSVC ???) 110 110 */ … … 117 117 118 118 ComPtr<INATNetwork> m_NATNetwork; 119 119 120 120 /* 121 121 * We will ignore cmd line parameters IFF there will be some DHCP specific arguments … … 125 125 126 126 /* 127 * -b -n 10.0.1.2 -m 255.255.255.0 -> to the list processing in 128 */ 129 typedef struct 127 * -b -n 10.0.1.2 -m 255.255.255.0 -> to the list processing in 128 */ 129 typedef struct 130 130 { 131 131 char Key; … … 302 302 /** 303 303 * Parse the DHCP specific arguments. 304 * 304 * 305 305 * This callback caled for each paramenter so 306 306 * .... 307 * we nee post analisys of the parameters, at least 308 * for -b, -g, -l, -u, -m 307 * we nee post analisys of the parameters, at least 308 * for -b, -g, -l, -u, -m 309 309 */ 310 310 int VBoxNetDhcp::parseOpt(int rc, const RTGETOPTUNION& Val) … … 320 320 { 321 321 /* Begin config. */ 322 case 'b': 322 case 'b': 323 323 CmdParameterll.push_back(prm); 324 324 break; … … 347 347 { 348 348 HRESULT hrc = S_OK; 349 /* ok, here we should initiate instance of dhcp server 350 * and listener for Dhcp configuration events 349 /* ok, here we should initiate instance of dhcp server 350 * and listener for Dhcp configuration events 351 351 */ 352 352 AssertRCReturn(virtualbox.isNull(), VERR_INTERNAL_ERROR); 353 353 354 hrc = virtualbox->FindDHCPServerByNetworkName(com::Bstr(m_Network.c_str()).raw(), 354 hrc = virtualbox->FindDHCPServerByNetworkName(com::Bstr(m_Network.c_str()).raw(), 355 355 m_DhcpServer.asOutParam()); 356 356 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 357 357 358 hrc = virtualbox->FindNATNetworkByName(com::Bstr(m_Network.c_str()).raw(), 358 hrc = virtualbox->FindNATNetworkByName(com::Bstr(m_Network.c_str()).raw(), 359 359 m_NATNetwork.asOutParam()); 360 360 … … 367 367 368 368 /** 369 * if we have nat netework of the same name 369 * if we have nat netework of the same name 370 370 * this is good chance that we are assigned to this network. 371 371 */ … … 395 395 { 396 396 /* just fetch option array and add options to config */ 397 /* per VM-settings ??? 398 * 399 * - we have vms with attached adapters with known mac-addresses 397 /* per VM-settings ??? 398 * 399 * - we have vms with attached adapters with known mac-addresses 400 400 * - mac-addresses might be changed as well as names, how keep our config cleaned ???? 401 401 */ … … 404 404 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 405 405 406 #if 0 406 #if 0 407 407 for (int i = 0; i < sf.size(); ++i) 408 408 { 409 409 RTPrintf("%d: %s\n", i, com::Utf8Str(sf[i]).c_str()); 410 410 } 411 412 #endif 411 412 #endif 413 413 com::Bstr strUpperIp, strLowerIp; 414 414 415 415 RTNETADDRIPV4 LowerAddress; 416 416 RTNETADDRIPV4 UpperAddress; … … 419 419 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 420 420 RTNetStrToIPv4Addr(com::Utf8Str(strUpperIp).c_str(), &UpperAddress); 421 421 422 422 423 423 hrc = m_DhcpServer->COMGETTER(LowerIP)(strLowerIp.asOutParam()); … … 428 428 networkId.u = m_Ipv4Address.u & m_Ipv4Netmask.u; 429 429 std::string name = std::string("default"); 430 431 NetworkConfigEntity *pCfg = confManager->addNetwork(unconst(g_RootConfig), 430 431 NetworkConfigEntity *pCfg = confManager->addNetwork(unconst(g_RootConfig), 432 432 networkId, 433 433 m_Ipv4Netmask, 434 LowerAddress, 434 LowerAddress, 435 435 UpperAddress); 436 436 … … 439 439 { 440 440 CmdParameterIterator it; 441 441 442 442 RTNETADDRIPV4 networkId; 443 443 networkId.u = m_Ipv4Address.u & m_Ipv4Netmask.u; … … 445 445 RTNETADDRIPV4 LowerAddress; 446 446 RTNETADDRIPV4 UpperAddress; 447 447 448 448 LowerAddress = networkId; 449 449 UpperAddress.u = RT_H2N_U32(RT_N2H_U32(LowerAddress.u) | RT_N2H_U32(netmask.u)); … … 463 463 case 'b': 464 464 /* config */ 465 NetworkConfigEntity(strname, 465 NetworkConfigEntity(strname, 466 466 g_RootConfig, 467 467 g_AnyClient, … … 633 633 /* XXX: per-host configuration */ 634 634 } 635 635 636 636 SessionManager *sesionManager = SessionManager::getSessionManager(); 637 637 Session& session = sesionManager->getClientSessionByDhcpPacket(pDhcpMsg, cb); 638 638 /* XXX: switch -> private */ 639 639 session.switchTo(DHCPDISCOVERRECEIEVED); 640 640 641 641 ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager(); 642 642 int rc = confManager->findConfiguration4Session(session); … … 671 671 /* XXX: switch -> private */ 672 672 session.switchTo(DHCPREQUESTRECEIVED); 673 673 674 674 ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager(); 675 675 int rc = confManager->findConfiguration4Session(session); … … 683 683 else 684 684 rc = netManager->nak(session); 685 685 686 686 AssertRCReturn(rc, false); 687 687 … … 773 773 && m_pCurMsg) 774 774 { 775 /* XXX: export this to debugPrinfDhcpMsg or variant and other method export 775 /* XXX: export this to debugPrinfDhcpMsg or variant and other method export 776 776 * to base class 777 777 */
Note:
See TracChangeset
for help on using the changeset viewer.