Changeset 48420 in vbox
- Timestamp:
- Sep 11, 2013 5:04:47 AM (11 years ago)
- Location:
- trunk/src/VBox/NetworkServices/DHCP
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/DHCP/Config.cpp
r48367 r48420 43 43 static NetworkManager *g_NetworkManager = NetworkManager::getNetworkManager(); 44 44 45 45 int BaseConfigEntity::match(Client& client, BaseConfigEntity **cfg) 46 { 47 int iMatch = (m_criteria && m_criteria->check(client)? m_MatchLevel: 0); 48 if (m_children.empty()) 49 { 50 if (iMatch > 0) 51 { 52 *cfg = this; 53 return iMatch; 54 } 55 } 56 else 57 { 58 *cfg = this; 59 /* XXX: hack */ 60 BaseConfigEntity *matching = this; 61 int matchingLevel = m_MatchLevel; 62 63 for (std::vector<BaseConfigEntity *>::iterator it = m_children.begin(); 64 it != m_children.end(); 65 ++it) 66 { 67 iMatch = (*it)->match(client, &matching); 68 if (iMatch > matchingLevel) 69 { 70 *cfg = matching; 71 matchingLevel = iMatch; 72 } 73 } 74 return matchingLevel; 75 } 76 return iMatch; 77 } 46 78 47 79 /* Client */ … … 353 385 } 354 386 387 int ConfigurationManager::addToAddressList(uint8_t u8OptId, RTNETADDRIPV4& address) 388 { 389 switch(u8OptId) 390 { 391 case RTNET_DHCP_OPT_DNS: 392 m_nameservers.push_back(address); 393 break; 394 case RTNET_DHCP_OPT_ROUTERS: 395 m_routers.push_back(address); 396 break; 397 default: 398 Log(("dhcp-opt: list (%d) unsupported\n", u8OptId)); 399 } 400 return VINF_SUCCESS; 401 } 402 403 int ConfigurationManager::flushAddressList(uint8_t u8OptId) 404 { 405 switch(u8OptId) 406 { 407 case RTNET_DHCP_OPT_DNS: 408 m_nameservers.clear(); 409 break; 410 case RTNET_DHCP_OPT_ROUTERS: 411 m_routers.clear(); 412 break; 413 default: 414 Log(("dhcp-opt: list (%d) unsupported\n", u8OptId)); 415 } 416 return VINF_SUCCESS; 417 } 418 419 const Ipv4AddressContainer& ConfigurationManager::getAddressList(uint8_t u8OptId) 420 { 421 switch(u8OptId) 422 { 423 case RTNET_DHCP_OPT_DNS: 424 return m_nameservers; 425 426 case RTNET_DHCP_OPT_ROUTERS: 427 return m_routers; 428 429 } 430 /* XXX: Grrr !!! */ 431 return m_empty; 432 } 433 355 434 /** 356 435 * Network manager -
trunk/src/VBox/NetworkServices/DHCP/Config.h
r47501 r48420 196 196 197 197 /* Should return how strong matching */ 198 virtual int match(Client& client, BaseConfigEntity **cfg) 199 { 200 int iMatch = (m_criteria && m_criteria->check(client)? m_MatchLevel: 0); 201 if (m_children.empty()) 202 { 203 if (iMatch > 0) 204 { 205 *cfg = this; 206 return iMatch; 207 } 208 } 209 else 210 { 211 *cfg = this; 212 /* XXX: hack */ 213 BaseConfigEntity *matching = this; 214 int matchingLevel = m_MatchLevel; 215 216 for (std::vector<BaseConfigEntity *>::iterator it = m_children.begin(); 217 it != m_children.end(); 218 ++it) 219 { 220 iMatch = (*it)->match(client, &matching); 221 if (iMatch > matchingLevel) 222 { 223 *cfg = matching; 224 matchingLevel = iMatch; 225 } 226 } 227 return matchingLevel; 228 } 229 return iMatch; 230 } 198 virtual int match(Client& client, BaseConfigEntity **cfg); 231 199 virtual uint32_t expirationPeriod() const = 0; 232 200 protected: … … 344 312 const ClientMatchCriteria *criteria): 345 313 NetworkConfigEntity(name, 346 static_cast<const ConfigEntity*>(cfg), 347 criteria, 348 10, 349 cfg->networkId(), 350 cfg->netmask(), 351 addr, 352 addr) 314 static_cast<const ConfigEntity*>(cfg), criteria, 10, 315 cfg->networkId(), cfg->netmask(), addr, addr) 353 316 { 354 317 /* upper addr == lower addr */ … … 432 395 433 396 HostConfigEntity *addHost(NetworkConfigEntity*, const RTNETADDRIPV4&, ClientMatchCriteria*); 434 435 int addToAddressList(uint8_t u8OptId, RTNETADDRIPV4& address) 436 { 437 switch(u8OptId) 438 { 439 case RTNET_DHCP_OPT_DNS: 440 m_nameservers.push_back(address); 441 break; 442 case RTNET_DHCP_OPT_ROUTERS: 443 m_routers.push_back(address); 444 break; 445 default: 446 Log(("dhcp-opt: list (%d) unsupported\n", u8OptId)); 447 } 448 return VINF_SUCCESS; 449 } 450 451 int flushAddressList(uint8_t u8OptId) 452 { 453 switch(u8OptId) 454 { 455 case RTNET_DHCP_OPT_DNS: 456 m_nameservers.clear(); 457 break; 458 case RTNET_DHCP_OPT_ROUTERS: 459 m_routers.clear(); 460 break; 461 default: 462 Log(("dhcp-opt: list (%d) unsupported\n", u8OptId)); 463 } 464 return VINF_SUCCESS; 465 } 466 467 const Ipv4AddressContainer& getAddressList(uint8_t u8OptId) 468 { 469 switch(u8OptId) 470 { 471 case RTNET_DHCP_OPT_DNS: 472 return m_nameservers; 473 474 case RTNET_DHCP_OPT_ROUTERS: 475 return m_routers; 476 477 } 478 /* XXX: Grrr !!! */ 479 return m_empty; 480 } 397 int addToAddressList(uint8_t u8OptId, RTNETADDRIPV4& address); 398 int flushAddressList(uint8_t u8OptId); 399 const Ipv4AddressContainer& getAddressList(uint8_t u8OptId); 481 400 482 401 private:
Note:
See TracChangeset
for help on using the changeset viewer.