Changeset 79621 in vbox for trunk/src/VBox/NetworkServices/Dhcpd
- Timestamp:
- Jul 9, 2019 1:14:53 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 131923
- Location:
- trunk/src/VBox/NetworkServices/Dhcpd
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/Dhcpd/Config.cpp
r79613 r79621 29 29 #include <iprt/string.h> 30 30 #include <iprt/uuid.h> 31 #include <iprt/cpp/path.h> 31 32 32 33 #include <VBox/com/com.h> /* For log initialization. */ … … 735 736 m_strTrunk = ""; 736 737 737 m_strLeaseFilename = pElmServer->findAttributeValue("leaseFilename"); /* optional */ 738 m_strLeasesFilename = pElmServer->findAttributeValue("leasesFilename"); /* optional */ 739 if (m_strLeasesFilename.isEmpty()) 740 { 741 int rc = m_strLeasesFilename.assignNoThrow(getHome()); 742 if (RT_SUCCESS(rc)) 743 rc = RTPathAppendCxx(m_strLeasesFilename, getBaseName()); 744 if (RT_SUCCESS(rc)) 745 rc = m_strLeasesFilename.appendNoThrow("-Dhcpd.leases"); 746 if (RT_FAILURE(rc)) 747 throw ConfigFileError("Unexpected error constructing default m_strLeasesFilename value: %Rrc", rc); 748 } 738 749 739 750 i_getIPv4AddrAttribute(pElmServer, "IPAddress", &m_IPv4Address); -
trunk/src/VBox/NetworkServices/Dhcpd/Config.h
r79613 r79621 46 46 RTCString m_strNetwork; /**< The name of the internal network the DHCP server is connected to. */ 47 47 RTCString m_strBaseName; /**< m_strNetwork sanitized to be usable in a path component. */ 48 RTCString m_strLease Filename; /**< The lease filename if one given. Dhcpd will pick a default if empty. */48 RTCString m_strLeasesFilename;/**< The lease DB filename. */ 49 49 50 50 RTCString m_strTrunk; /**< The trunk name of the internal network. */ … … 93 93 const RTCString &getNetwork() const RT_NOEXCEPT { return m_strNetwork; } 94 94 const RTCString &getBaseName() const RT_NOEXCEPT { return m_strBaseName; } 95 const RTCString &getLease Filename() const RT_NOEXCEPT { return m_strLeaseFilename; }95 const RTCString &getLeasesFilename() const RT_NOEXCEPT { return m_strLeasesFilename; } 96 96 97 97 const RTCString &getTrunk() const RT_NOEXCEPT { return m_strTrunk; } -
trunk/src/VBox/NetworkServices/Dhcpd/DHCPD.cpp
r79613 r79621 25 25 26 26 #include <iprt/message.h> 27 #include <iprt/cpp/path.h>28 27 29 28 … … 44 43 Assert(pConfig); 45 44 AssertReturn(!m_pConfig, VERR_INVALID_STATE); 46 47 /* leases filename */ 48 int rc; 49 if (pConfig->getLeaseFilename().isEmpty()) 50 rc = m_strLeasesFilename.assignNoThrow(pConfig->getLeaseFilename()); 51 else 52 { 53 rc = m_strLeasesFilename.assignNoThrow(pConfig->getHome()); 54 if (RT_SUCCESS(rc)) 55 rc = RTPathAppendCxx(m_strLeasesFilename, pConfig->getBaseName()); 56 if (RT_SUCCESS(rc)) 57 rc = m_strLeasesFilename.appendNoThrow("-Dhcpd.leases"); 58 } 45 m_pConfig = pConfig; 46 47 /* Load the lease database, ignoring most issues except being out of memory: */ 48 int rc = m_db.init(pConfig); 59 49 if (RT_SUCCESS(rc)) 60 50 { 61 /* Load the lease database, ignoring most issues except being out of memory: */ 62 rc = m_db.init(pConfig); 63 if (RT_SUCCESS(rc)) 64 { 65 rc = i_loadLeases(); 66 if (rc != VERR_NO_MEMORY) 67 { 68 m_pConfig = pConfig; 69 rc = VINF_SUCCESS; 70 } 71 else 72 { 73 LogRel(("Ran out of memory loading leases from '%s'. Try rename or delete the file.\n", 74 m_strLeasesFilename.c_str())); 75 RTMsgError("Ran out of memory loading leases from '%s'. Try rename or delete the file.\n", 76 m_strLeasesFilename.c_str()); 77 } 78 } 51 rc = i_loadLeases(); 52 if (rc != VERR_NO_MEMORY) 53 return VINF_SUCCESS; 54 55 /** @todo macro for this: */ 56 LogRel(( "Ran out of memory loading leases from '%s'. Try rename or delete the file.\n", 57 pConfig->getLeasesFilename().c_str())); 58 RTMsgError("Ran out of memory loading leases from '%s'. Try rename or delete the file.\n", 59 pConfig->getLeasesFilename().c_str()); 79 60 } 80 61 return rc; … … 83 64 84 65 /** 85 * Load leases from m_strLeasesFilename.66 * Load leases from pConfig->getLeasesFilename(). 86 67 */ 87 68 int DHCPD::i_loadLeases() RT_NOEXCEPT 88 69 { 89 return m_db.loadLeases(m_ strLeasesFilename);90 } 91 92 93 /** 94 * Save the current leases to m_strLeasesFilename, doing expiry first.70 return m_db.loadLeases(m_pConfig->getLeasesFilename()); 71 } 72 73 74 /** 75 * Save the current leases to pConfig->getLeasesFilename(), doing expiry first. 95 76 * 96 77 * This is called after m_db is updated during a client request, so the on disk … … 104 85 { 105 86 m_db.expire(); 106 m_db.writeLeases(m_ strLeasesFilename);87 m_db.writeLeases(m_pConfig->getLeasesFilename()); 107 88 } 108 89 -
trunk/src/VBox/NetworkServices/Dhcpd/DHCPD.h
r79568 r79621 40 40 /** The DHCP configuration. */ 41 41 const Config *m_pConfig; 42 /** The lease database filename. */43 RTCString m_strLeasesFilename;44 42 /** The lease database. */ 45 43 Db m_db;
Note:
See TracChangeset
for help on using the changeset viewer.