Changeset 79563 in vbox for trunk/src/VBox/NetworkServices/Dhcpd/Db.cpp
- Timestamp:
- Jul 6, 2019 1:22:56 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 131853
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/Dhcpd/Db.cpp
r79530 r79563 36 36 * Registers the ClientId format type callback ("%R[binding]"). 37 37 */ 38 void Binding::registerFormat() 38 void Binding::registerFormat() RT_NOEXCEPT 39 39 { 40 40 if (!g_fFormatRegistered) … … 87 87 } 88 88 89 const char *Binding::stateName() const 89 const char *Binding::stateName() const RT_NOEXCEPT 90 90 { 91 91 switch (m_state) … … 108 108 109 109 110 Binding &Binding::setState(const char *pszStateName) 110 Binding &Binding::setState(const char *pszStateName) RT_NOEXCEPT 111 111 { 112 112 if (strcmp(pszStateName, "free") == 0) … … 137 137 * @param tsDeadline The expiry deadline to use. 138 138 */ 139 bool Binding::expire(Timestamp tsDeadline) 139 bool Binding::expire(Timestamp tsDeadline) RT_NOEXCEPT 140 140 { 141 141 if (m_state <= Binding::EXPIRED) … … 232 232 /* 233 233 * Decode from "de:ad:be:ef". 234 * XXX: RTStrConvertHexBytes() doesn't grok colons235 234 */ 236 size_t cbBytes = strId.length() / 2; 237 uint8_t *pBytes = new uint8_t[cbBytes]; 238 rc = RTStrConvertHexBytes(strId.c_str(), pBytes, cbBytes, 0); 235 /** @todo RTStrConvertHexBytes() doesn't grok colons */ 236 size_t cbBytes = strId.length() / 2; 237 uint8_t *pbBytes = new uint8_t[cbBytes]; 238 rc = RTStrConvertHexBytes(strId.c_str(), pbBytes, cbBytes, 0); 239 239 if (RT_SUCCESS(rc)) 240 240 { 241 std::vector<uint8_t> rawopt(pBytes, pBytes + cbBytes); 242 id = OptClientId(rawopt); 243 } 244 delete[] pBytes; 241 try 242 { 243 std::vector<uint8_t> rawopt(pbBytes, pbBytes + cbBytes); 244 id = OptClientId(rawopt); 245 } 246 catch (std::bad_alloc &) 247 { 248 delete[] pbBytes; 249 throw; 250 } 251 } 252 delete[] pbBytes; 245 253 } 246 254 … … 305 313 } 306 314 else 307 { /* XXX: old code wrote timestamps instead of absolute time. */315 { /** @todo XXX: old code wrote timestamps instead of absolute time. */ 308 316 /* pretend that lease has just ended */ 309 317 Timestamp fakeIssued = Timestamp::now(); … … 341 349 m_pConfig = pConfig; 342 350 343 m_pool.init(pConfig->getIPv4PoolFirst(), 344 pConfig->getIPv4PoolLast()); 345 346 return VINF_SUCCESS; 351 return m_pool.init(pConfig->getIPv4PoolFirst(), pConfig->getIPv4PoolLast()); 347 352 } 348 353 … … 351 356 * Expire old binding (leases). 352 357 */ 353 void Db::expire() 358 void Db::expire() RT_NOEXCEPT 354 359 { 355 360 const Timestamp now = Timestamp::now(); … … 609 614 * @param pNewBinding The new binding to add. 610 615 */ 611 int Db::i_addBinding(Binding *pNewBinding) 616 int Db::i_addBinding(Binding *pNewBinding) RT_NOEXCEPT 612 617 { 613 618 /* … … 662 667 * @param req The DHCP request. 663 668 */ 664 void Db::cancelOffer(const DhcpClientMessage &req) 669 void Db::cancelOffer(const DhcpClientMessage &req) RT_NOEXCEPT 665 670 { 666 671 const OptRequestedAddress reqAddr(req); … … 697 702 * @param req The DHCP request. 698 703 * @returns true if found and released, otherwise false. 699 */ 700 bool Db::releaseBinding(const DhcpClientMessage &req) 704 * @throws nothing 705 */ 706 bool Db::releaseBinding(const DhcpClientMessage &req) RT_NOEXCEPT 701 707 { 702 708 const RTNETADDRIPV4 addr = req.ciaddr(); … … 726 732 * @param strFilename The file to write it to. 727 733 */ 728 int Db::writeLeases(const RTCString &strFilename) const 734 int Db::writeLeases(const RTCString &strFilename) const RT_NOEXCEPT 729 735 { 730 736 LogDHCP(("writing leases to %s\n", strFilename.c_str())); 737 738 /** @todo This could easily be written directly to the file w/o going thru 739 * a xml::Document, xml::XmlFileWriter, hammering the heap and being 740 * required to catch a lot of different exceptions at various points. 741 * (RTStrmOpen, bunch of RTStrmPrintf using \%RMas and \%RMes., 742 * RTStrmClose closely followed by a couple of renames.) 743 */ 731 744 732 745 /* … … 789 802 * @returns IPRT status code. 790 803 * @param strFilename The file to load it from. 791 */ 792 int Db::loadLeases(const RTCString &strFilename) 804 * @throws nothing 805 */ 806 int Db::loadLeases(const RTCString &strFilename) RT_NOEXCEPT 793 807 { 794 808 LogDHCP(("loading leases from %s\n", strFilename.c_str())); … … 863 877 * @return IPRT status code. 864 878 */ 865 int Db::i_loadLease(const xml::ElementNode *pElmLease) 879 int Db::i_loadLease(const xml::ElementNode *pElmLease) RT_NOEXCEPT 866 880 { 867 881 Binding *pBinding = NULL; … … 878 892 bool fExpired = pBinding->expire(); 879 893 if (!fExpired) 880 LogDHCP(("> LOAD: lease %R[binding]\n", pBinding));894 LogDHCP(("> LOAD: lease %R[binding]\n", pBinding)); 881 895 else 882 896 LogDHCP(("> LOAD: EXPIRED lease %R[binding]\n", pBinding));
Note:
See TracChangeset
for help on using the changeset viewer.