Index: /trunk/src/VBox/NetworkServices/Dhcpd/Config.cpp
===================================================================
--- /trunk/src/VBox/NetworkServices/Dhcpd/Config.cpp	(revision 79567)
+++ /trunk/src/VBox/NetworkServices/Dhcpd/Config.cpp	(revision 79568)
@@ -247,5 +247,5 @@
     if (m_strNetwork.isEmpty())
     {
-        LogDHCP(("network name is not specified\n"));
+        LogRel(("network name is not specified\n"));
         return false;
     }
@@ -269,5 +269,5 @@
         m_MacAddress.au8[5] = Uuid.Gen.au8Node[5];
 
-        LogDHCP(("MAC address is not specified: will use generated MAC %RTmac\n", &m_MacAddress));
+        LogRel(("MAC address is not specified: will use generated MAC %RTmac\n", &m_MacAddress));
         fMACGenerated = true;
     }
@@ -276,5 +276,5 @@
     if (m_MacAddress.au8[0] & 0x01)
     {
-        LogDHCP(("MAC address is not unicast: %RTmac\n", &m_MacAddress));
+        LogRel(("MAC address is not unicast: %RTmac\n", &m_MacAddress));
         return VERR_GENERAL_FAILURE;
     }
@@ -283,5 +283,5 @@
     if ((m_IPv4Address.au8[0] & 0xe0) == 0xe0)
     {
-        LogDHCP(("IP address is not unicast: %RTnaipv4\n", m_IPv4Address.u));
+        LogRel(("IP address is not unicast: %RTnaipv4\n", m_IPv4Address.u));
         return VERR_GENERAL_FAILURE;
     }
@@ -292,5 +292,5 @@
     if (RT_FAILURE(rc) || cPrefixBits == 0)
     {
-        LogDHCP(("IP mask is not valid: %RTnaipv4\n", m_IPv4Netmask.u));
+        LogRel(("IP mask is not valid: %RTnaipv4\n", m_IPv4Netmask.u));
         return VERR_GENERAL_FAILURE;
     }
@@ -299,5 +299,5 @@
     if ((m_IPv4PoolFirst.u & m_IPv4Netmask.u) != (m_IPv4Address.u & m_IPv4Netmask.u))
     {
-        LogDHCP(("first pool address is outside the network %RTnaipv4/%d: %RTnaipv4\n",
+        LogRel(("first pool address is outside the network %RTnaipv4/%d: %RTnaipv4\n",
                  (m_IPv4Address.u & m_IPv4Netmask.u), cPrefixBits, m_IPv4PoolFirst.u));
         return VERR_GENERAL_FAILURE;
@@ -307,5 +307,5 @@
     if ((m_IPv4PoolLast.u & m_IPv4Netmask.u) != (m_IPv4Address.u & m_IPv4Netmask.u))
     {
-        LogDHCP(("last pool address is outside the network %RTnaipv4/%d: %RTnaipv4\n",
+        LogRel(("last pool address is outside the network %RTnaipv4/%d: %RTnaipv4\n",
                  (m_IPv4Address.u & m_IPv4Netmask.u), cPrefixBits, m_IPv4PoolLast.u));
         return VERR_GENERAL_FAILURE;
@@ -315,5 +315,5 @@
     if (RT_N2H_U32(m_IPv4PoolLast.u) < RT_N2H_U32(m_IPv4PoolFirst.u))
     {
-        LogDHCP(("pool range is invalid: %RTnaipv4 - %RTnaipv4\n",
+        LogRel(("pool range is invalid: %RTnaipv4 - %RTnaipv4\n",
                  m_IPv4PoolFirst.u, m_IPv4PoolLast.u));
         return VERR_GENERAL_FAILURE;
@@ -324,5 +324,5 @@
         && RT_N2H_U32(m_IPv4Address.u)   <= RT_N2H_U32(m_IPv4PoolLast.u))
     {
-        LogDHCP(("server address inside the pool range %RTnaipv4 - %RTnaipv4: %RTnaipv4\n",
+        LogRel(("server address inside the pool range %RTnaipv4 - %RTnaipv4: %RTnaipv4\n",
                  m_IPv4PoolFirst.u, m_IPv4PoolLast.u, m_IPv4Address.u));
         return VERR_GENERAL_FAILURE;
@@ -330,7 +330,7 @@
 
     if (!fMACGenerated)
-        LogDHCP(("MAC address %RTmac\n", &m_MacAddress));
-    LogDHCP(("IP address %RTnaipv4/%d\n", m_IPv4Address.u, cPrefixBits));
-    LogDHCP(("address pool %RTnaipv4 - %RTnaipv4\n", m_IPv4PoolFirst.u, m_IPv4PoolLast.u));
+        LogRel(("MAC address %RTmac\n", &m_MacAddress));
+    LogRel(("IP address %RTnaipv4/%d\n", m_IPv4Address.u, cPrefixBits));
+    LogRel(("address pool %RTnaipv4 - %RTnaipv4\n", m_IPv4PoolFirst.u, m_IPv4PoolLast.u));
 
     return VINF_SUCCESS;
@@ -770,5 +770,5 @@
             i_parseVMConfig(pElmChild);
         else
-            LogDHCP(("Ignoring unexpected DHCPServer child: %s\n", pElmChild->getName()));
+            LogRel(("Ignoring unexpected DHCPServer child: %s\n", pElmChild->getName()));
     }
 }
Index: /trunk/src/VBox/NetworkServices/Dhcpd/DHCPD.cpp
===================================================================
--- /trunk/src/VBox/NetworkServices/Dhcpd/DHCPD.cpp	(revision 79567)
+++ /trunk/src/VBox/NetworkServices/Dhcpd/DHCPD.cpp	(revision 79568)
@@ -221,5 +221,5 @@
  * @throws  std::bad_alloc
  */
-DhcpServerMessage *DHCPD::i_createMessage(int type, DhcpClientMessage &req)
+DhcpServerMessage *DHCPD::i_createMessage(int type, const DhcpClientMessage &req)
 {
     return new DhcpServerMessage(req, type, m_pConfig->getIPv4Address());
@@ -251,5 +251,5 @@
  * @throws  std::bad_alloc
  */
-DhcpServerMessage *DHCPD::i_doDiscover(DhcpClientMessage &req)
+DhcpServerMessage *DHCPD::i_doDiscover(const DhcpClientMessage &req)
 {
     /** @todo
@@ -317,5 +317,5 @@
  * @throws  std::bad_alloc
  */
-DhcpServerMessage *DHCPD::i_doRequest(DhcpClientMessage &req)
+DhcpServerMessage *DHCPD::i_doRequest(const DhcpClientMessage &req)
 {
     OptRequestedAddress reqAddr(req);
@@ -367,5 +367,5 @@
  * @throws  std::bad_alloc
  */
-DhcpServerMessage *DHCPD::i_doInform(DhcpClientMessage &req)
+DhcpServerMessage *DHCPD::i_doInform(const DhcpClientMessage &req)
 {
     if (req.ciaddr().u == 0)
Index: /trunk/src/VBox/NetworkServices/Dhcpd/DHCPD.h
===================================================================
--- /trunk/src/VBox/NetworkServices/Dhcpd/DHCPD.h	(revision 79567)
+++ /trunk/src/VBox/NetworkServices/Dhcpd/DHCPD.h	(revision 79568)
@@ -62,11 +62,11 @@
     /** @name DHCP message processing methods
      * @{ */
-    DhcpServerMessage *i_doDiscover(DhcpClientMessage &req);
-    DhcpServerMessage *i_doRequest(DhcpClientMessage &req);
-    DhcpServerMessage *i_doInform(DhcpClientMessage &req);
+    DhcpServerMessage *i_doDiscover(const DhcpClientMessage &req);
+    DhcpServerMessage *i_doRequest(const DhcpClientMessage &req);
+    DhcpServerMessage *i_doInform(const DhcpClientMessage &req);
     DhcpServerMessage *i_doDecline(const DhcpClientMessage &req) RT_NOEXCEPT;
     DhcpServerMessage *i_doRelease(const DhcpClientMessage &req) RT_NOEXCEPT;
 
-    DhcpServerMessage *i_createMessage(int type, DhcpClientMessage &req);
+    DhcpServerMessage *i_createMessage(int type, const DhcpClientMessage &req);
     /** @} */
 
Index: /trunk/src/VBox/NetworkServices/Dhcpd/Db.cpp
===================================================================
--- /trunk/src/VBox/NetworkServices/Dhcpd/Db.cpp	(revision 79567)
+++ /trunk/src/VBox/NetworkServices/Dhcpd/Db.cpp	(revision 79568)
@@ -159,5 +159,6 @@
  * Serializes the binding to XML for the lease database.
  *
- * @throw  std::bad_alloc
+ * @throw   std::bad_alloc
+ * @note    DHCPServerImpl.cpp contains a reader, keep it in sync.
  */
 void Binding::toXML(xml::ElementNode *pElmParent) const
@@ -204,121 +205,109 @@
  * Deserializes the binding from the XML lease database.
  *
- * @param   pElmLease   The "Lease" element.
+ * @param   pElmLease   The "Lease" element to serialize into.
  * @return  Pointer to the resulting binding, NULL on failure.
  * @throw   std::bad_alloc
+ * @note    DHCPServerImpl.cpp contains a similar reader, keep it in sync.
  */
 Binding *Binding::fromXML(const xml::ElementNode *pElmLease)
 {
-    /* Lease/@network seems to always have bogus value, ignore it. */
-
-    /*
-     * Lease/@mac
-     */
-    RTCString strMac;
-    bool fHasMac = pElmLease->getAttributeValue("mac", &strMac);
-    if (!fHasMac)
-        return NULL;
+    /* Note! Lease/@network seems to always have bogus value, ignore it. */
+    /* Note! We parse the mandatory attributes and elements first, then
+             the optional ones.  This means things appear a little jumbled. */
+
+    /*
+     * Lease/@mac - mandatory.
+     */
+    const char *pszMacAddress = pElmLease->findAttributeValue("mac");
+    if (!pszMacAddress)
+        DHCP_LOG_RET_NULL(("Binding::fromXML: <Lease> element without 'mac' attribute! Skipping lease.\n"));
 
     RTMAC mac;
-    int rc = RTNetStrToMacAddr(strMac.c_str(), &mac);
+    int rc = RTNetStrToMacAddr(pszMacAddress, &mac);
     if (RT_FAILURE(rc))
-        return NULL;
-
-    OptClientId id;
-    RTCString strId;
-    bool fHasId = pElmLease->getAttributeValue("id", &strId);
-    if (fHasId)
-    {
-        /*
-         * Decode from "de:ad:be:ef".
-         */
-        /** @todo RTStrConvertHexBytes() doesn't grok colons */
-        size_t   cbBytes = strId.length() / 2;
-        uint8_t *pbBytes = new uint8_t[cbBytes];
-        rc = RTStrConvertHexBytes(strId.c_str(), pbBytes, cbBytes, 0);
-        if (RT_SUCCESS(rc))
-        {
-            try
-            {
-                std::vector<uint8_t> rawopt(pbBytes, pbBytes + cbBytes);
-                id = OptClientId(rawopt);
-            }
-            catch (std::bad_alloc &)
-            {
-                delete[] pbBytes;
-                throw;
-            }
-        }
-        delete[] pbBytes;
-    }
-
-    /*
-     * Lease/@state - not present in old leases file.  We will try to
-     * infer from lease time below.
-     */
-    RTCString strState;
-    bool fHasState = pElmLease->getAttributeValue("state", &strState);
-
-    /*
-     * Lease/Address
-     */
-    const xml::ElementNode *ndAddress = pElmLease->findChildElement("Address");
-    if (ndAddress == NULL)
-        return NULL;
-
-    /*
-     * Lease/Address/@value
-     */
-    RTCString strAddress;
-    bool fHasValue = ndAddress->getAttributeValue("value", &strAddress);
-    if (!fHasValue)
-        return NULL;
+        DHCP_LOG_RET_NULL(("Binding::fromXML: Malformed mac address attribute value '%s': %Rrc - Skipping lease.\n",
+                           pszMacAddress, rc));
+
+    /*
+     * Lease/Address/@value - mandatory.
+     */
+    const char *pszAddress = pElmLease->findChildElementAttributeValue("Address", "value");
+    if (!pszAddress)
+        DHCP_LOG_RET_NULL(("Binding::fromXML: Could not find <Address> with a 'value' attribute! Skipping lease.\n"));
 
     RTNETADDRIPV4 addr;
-    rc = RTNetStrToIPv4Addr(strAddress.c_str(), &addr);
+    rc = RTNetStrToIPv4Addr(pszAddress, &addr);
     if (RT_FAILURE(rc))
-        return NULL;
-
-    /*
-     * Lease/Time
-     */
-    const xml::ElementNode *ndTime = pElmLease->findChildElement("Time");
-    if (ndTime == NULL)
-        return NULL;
-
-    /*
-     * Lease/Time/@issued
-     */
-    int64_t issued;
-    bool fHasIssued = ndTime->getAttributeValue("issued", &issued);
-    if (!fHasIssued)
-        return NULL;
-
-    /*
-     * Lease/Time/@expiration
-     */
-    uint32_t duration;
-    bool fHasExpiration = ndTime->getAttributeValue("expiration", &duration);
-    if (!fHasExpiration)
-        return NULL;
+        DHCP_LOG_RET_NULL(("Binding::fromXML: Malformed IPv4 address value '%s': %Rrc - Skipping lease.\n", pszAddress, rc));
+
+    /*
+     * Lease/Time - mandatory.
+     */
+    const xml::ElementNode *pElmTime = pElmLease->findChildElement("Time");
+    if (pElmTime == NULL)
+        DHCP_LOG_RET_NULL(("Binding::fromXML: No <Time> element under <Lease mac=%RTmac>! Skipping lease.\n", &mac));
+
+    /*
+     * Lease/Time/@issued - mandatory.
+     */
+    int64_t secIssued;
+    if (!pElmTime->getAttributeValue("issued", &secIssued))
+        DHCP_LOG_RET_NULL(("Binding::fromXML: <Time> element for %RTmac has no valid 'issued' attribute! Skipping lease.\n", &mac));
+
+    /*
+     * Lease/Time/@expiration - mandatory.
+     */
+    uint32_t cSecToLive;
+    if (!pElmTime->getAttributeValue("expiration", &cSecToLive))
+        DHCP_LOG_RET_NULL(("Binding::fromXML: <Time> element for %RTmac has no valid 'expiration' attribute! Skipping lease.\n", &mac));
 
     std::unique_ptr<Binding> b(new Binding(addr));
-    b->m_id = ClientId(mac, id);
-
-    if (fHasState)
-    {
-        b->m_issued = Timestamp::absSeconds(issued);
-        b->m_secLease = duration;
-        b->setState(strState.c_str());
+
+    /*
+     * Lease/@state - mandatory but not present in old leases file, so pretent
+     *                we're loading an expired one if absent.
+     */
+    const char *pszState = pElmLease->findAttributeValue("state");
+    if (pszState)
+    {
+        b->m_issued = Timestamp::absSeconds(secIssued);
+        b->setState(pszState);
     }
     else
     {   /** @todo XXX: old code wrote timestamps instead of absolute time. */
         /* pretend that lease has just ended */
-        Timestamp fakeIssued = Timestamp::now();
-        fakeIssued.subSeconds(duration);
-        b->m_issued = fakeIssued;
-        b->m_secLease = duration;
-        b->m_state = Binding::EXPIRED;
-    }
+        LogRel(("Binding::fromXML: No 'state' attribute for <Lease mac=%RTmac> (ts=%RI64 ttl=%RU32)! Assuming EXPIRED.\n",
+                &mac, secIssued, cSecToLive));
+        b->m_issued = Timestamp::now().subSeconds(cSecToLive);
+        b->m_state  = Binding::EXPIRED;
+    }
+    b->m_secLease   = cSecToLive;
+
+
+    /*
+     * Lease/@id - optional, ignore if bad.
+     * Value format: "deadbeef..." or "de:ad:be:ef...".
+     */
+    const char *pszClientId = pElmLease->findAttributeValue("id");
+    if (pszClientId)
+    {
+        uint8_t abBytes[255];
+        size_t  cbActual;
+        rc = RTStrConvertHexBytesEx(pszClientId, abBytes, sizeof(abBytes), RTSTRCONVERTHEXBYTES_F_SEP_COLON, NULL, &cbActual);
+        if (RT_SUCCESS(rc))
+        {
+            b->m_id = ClientId(mac, OptClientId(std::vector<uint8_t>(&abBytes[0], &abBytes[cbActual]))); /* throws bad_alloc */
+            if (rc != VINF_BUFFER_UNDERFLOW && rc != VINF_SUCCESS)
+                LogRel(("Binding::fromXML: imperfect 'id' attribute: rc=%Rrc, cbActual=%u, '%s'\n", rc, cbActual, pszClientId));
+        }
+        else
+        {
+            LogRel(("Binding::fromXML: ignoring malformed 'id' attribute: rc=%Rrc, cbActual=%u, '%s'\n",
+                    rc, cbActual, pszClientId));
+            b->m_id = ClientId(mac, OptClientId());
+        }
+    }
+    else
+        b->m_id = ClientId(mac, OptClientId());
 
     return b.release();
@@ -433,7 +422,7 @@
 
     if (addr.u != 0)
-        LogDHCP(("> allocateAddress %RTnaipv4 to client %R[id]\n", addr.u, &id));
+        LogRel(("> allocateAddress %RTnaipv4 to client %R[id]\n", addr.u, &id));
     else
-        LogDHCP(("> allocateAddress to client %R[id]\n", &id));
+        LogRel(("> allocateAddress to client %R[id]\n", &id));
 
     /*
@@ -456,5 +445,5 @@
         if (b->m_id == id)
         {
-            LogDHCP(("> ... found existing binding %R[binding]\n", b));
+            LogRel(("> ... found existing binding %R[binding]\n", b));
             return b;
         }
@@ -464,5 +453,5 @@
             Assert(addrBinding == NULL);
             addrBinding = b;
-            LogDHCP(("> .... noted existing binding %R[binding]\n", addrBinding));
+            LogRel(("> .... noted existing binding %R[binding]\n", addrBinding));
         }
 
@@ -473,5 +462,5 @@
             {
                 freeBinding = b;
-                LogDHCP(("> .... noted free binding %R[binding]\n", freeBinding));
+                LogRel(("> .... noted free binding %R[binding]\n", freeBinding));
                 continue;
             }
@@ -485,5 +474,5 @@
                 {
                     reuseBinding = b;
-                    LogDHCP(("> .... noted released binding %R[binding]\n", reuseBinding));
+                    LogRel(("> .... noted released binding %R[binding]\n", reuseBinding));
                 }
             }
@@ -495,5 +484,5 @@
                 {
                     reuseBinding = b;
-                    LogDHCP(("> .... noted expired binding %R[binding]\n", reuseBinding));
+                    LogRel(("> .... noted expired binding %R[binding]\n", reuseBinding));
                 }
             }
@@ -510,5 +499,5 @@
             addrBinding = i_createBinding(addr, id);
             Assert(addrBinding != NULL);
-            LogDHCP(("> .... creating new binding for this address %R[binding]\n", addrBinding));
+            LogRel(("> .... creating new binding for this address %R[binding]\n", addrBinding));
             return addrBinding;
         }
@@ -516,9 +505,9 @@
         if (addrBinding->m_state <= Binding::EXPIRED) /* not in use */
         {
-            LogDHCP(("> .... reusing %s binding for this address\n", addrBinding->stateName()));
+            LogRel(("> .... reusing %s binding for this address\n", addrBinding->stateName()));
             addrBinding->giveTo(id);
             return addrBinding;
         }
-        LogDHCP(("> .... cannot reuse %s binding for this address\n", addrBinding->stateName()));
+        LogRel(("> .... cannot reuse %s binding for this address\n", addrBinding->stateName()));
     }
 
@@ -530,5 +519,5 @@
     {
         idBinding = freeBinding;
-        LogDHCP(("> .... reusing free binding\n"));
+        LogRel(("> .... reusing free binding\n"));
     }
     else
@@ -536,20 +525,17 @@
         idBinding = i_createBinding();
         if (idBinding != NULL)
-            LogDHCP(("> .... creating new binding\n"));
+            LogRel(("> .... creating new binding\n"));
         else
         {
             idBinding = reuseBinding;
             if (idBinding != NULL)
-                LogDHCP(("> .... reusing %s binding %R[binding]\n", reuseBinding->stateName(), reuseBinding));
+                LogRel(("> .... reusing %s binding %R[binding]\n", reuseBinding->stateName(), reuseBinding));
             else
-            {
-                LogDHCP(("> .... failed to allocate binding\n"));
-                return NULL;
-            }
+                DHCP_LOG_RET_NULL(("> .... failed to allocate binding\n"));
         }
     }
 
     idBinding->giveTo(id);
-    LogDHCP(("> .... allocated %R[binding]\n", idBinding));
+    LogRel(("> .... allocated %R[binding]\n", idBinding));
 
     return idBinding;
@@ -576,12 +562,9 @@
         if (req.messageType() == RTNET_DHCP_MT_DISCOVER)
         {
-            LogDHCP(("DISCOVER: ignoring invalid requested address\n"));
+            LogRel(("DISCOVER: ignoring invalid requested address\n"));
             reqAddr = OptRequestedAddress();
         }
         else
-        {
-            LogDHCP(("rejecting invalid requested address\n"));
-            return NULL;
-        }
+            DHCP_LOG_RET_NULL(("rejecting invalid requested address\n"));
     }
 
@@ -621,5 +604,5 @@
     if (!addressBelongs(pNewBinding->m_addr))
     {
-        LogDHCP(("Binding for out of range address %RTnaipv4 ignored\n", pNewBinding->m_addr.u));
+        LogRel(("Binding for out of range address %RTnaipv4 ignored\n", pNewBinding->m_addr.u));
         return VERR_OUT_OF_RANGE;
     }
@@ -631,6 +614,6 @@
         if (pNewBinding->m_addr.u == b->m_addr.u)
         {
-            LogDHCP(("> ADD: %R[binding]\n", pNewBinding));
-            LogDHCP(("> .... duplicate ip: %R[binding]\n", b));
+            LogRel(("> ADD: %R[binding]\n", pNewBinding));
+            LogRel(("> .... duplicate ip: %R[binding]\n", b));
             return VERR_DUPLICATE;
         }
@@ -638,6 +621,6 @@
         if (pNewBinding->m_id == b->m_id)
         {
-            LogDHCP(("> ADD: %R[binding]\n", pNewBinding));
-            LogDHCP(("> .... duplicate id: %R[binding]\n", b));
+            LogRel(("> ADD: %R[binding]\n", pNewBinding));
+            LogRel(("> .... duplicate id: %R[binding]\n", b));
             return VERR_DUPLICATE;
         }
@@ -734,5 +717,5 @@
 int Db::writeLeases(const RTCString &strFilename) const RT_NOEXCEPT
 {
-    LogDHCP(("writing leases to %s\n", strFilename.c_str()));
+    LogRel(("writing leases to %s\n", strFilename.c_str()));
 
     /** @todo This could easily be written directly to the file w/o going thru
@@ -777,15 +760,15 @@
     catch (const xml::EIPRTFailure &e)
     {
-        LogDHCP(("%s\n", e.what()));
+        LogRel(("%s\n", e.what()));
         return e.rc();
     }
     catch (const RTCError &e)
     {
-        LogDHCP(("%s\n", e.what()));
+        LogRel(("%s\n", e.what()));
         return VERR_GENERAL_FAILURE;
     }
     catch (...)
     {
-        LogDHCP(("Unknown exception while writing '%s'\n", strFilename.c_str()));
+        LogRel(("Unknown exception while writing '%s'\n", strFilename.c_str()));
         return VERR_UNEXPECTED_EXCEPTION;
     }
@@ -806,5 +789,5 @@
 int Db::loadLeases(const RTCString &strFilename) RT_NOEXCEPT
 {
-    LogDHCP(("loading leases from %s\n", strFilename.c_str()));
+    LogRel(("loading leases from %s\n", strFilename.c_str()));
 
     /*
@@ -819,15 +802,15 @@
     catch (const xml::EIPRTFailure &e)
     {
-        LogDHCP(("%s\n", e.what()));
+        LogRel(("%s\n", e.what()));
         return e.rc();
     }
     catch (const RTCError &e)
     {
-        LogDHCP(("%s\n", e.what()));
+        LogRel(("%s\n", e.what()));
         return VERR_GENERAL_FAILURE;
     }
     catch (...)
     {
-        LogDHCP(("Unknown exception while reading and parsing '%s'\n", strFilename.c_str()));
+        LogRel(("Unknown exception while reading and parsing '%s'\n", strFilename.c_str()));
         return VERR_UNEXPECTED_EXCEPTION;
     }
@@ -839,10 +822,10 @@
     if (!pElmRoot)
     {
-        LogDHCP(("No root element in '%s'\n", strFilename.c_str()));
+        LogRel(("No root element in '%s'\n", strFilename.c_str()));
         return VERR_NOT_FOUND;
     }
     if (!pElmRoot->nameEquals("Leases"))
     {
-        LogDHCP(("No root element is not 'Leases' in '%s', but '%s'\n", strFilename.c_str(), pElmRoot->getName()));
+        LogRel(("No root element is not 'Leases' in '%s', but '%s'\n", strFilename.c_str(), pElmRoot->getName()));
         return VERR_NOT_FOUND;
     }
@@ -864,5 +847,5 @@
         }
         else
-            LogDHCP(("Ignoring unexpected element '%s' under 'Leases'...\n", pElmLease->getName()));
+            LogRel(("Ignoring unexpected element '%s' under 'Leases'...\n", pElmLease->getName()));
     }
 
@@ -892,7 +875,7 @@
         bool fExpired = pBinding->expire();
         if (!fExpired)
-            LogDHCP(("> LOAD:         lease %R[binding]\n", pBinding));
+            LogRel(("> LOAD:         lease %R[binding]\n", pBinding));
         else
-            LogDHCP(("> LOAD: EXPIRED lease %R[binding]\n", pBinding));
+            LogRel(("> LOAD: EXPIRED lease %R[binding]\n", pBinding));
 
         int rc = i_addBinding(pBinding);
@@ -901,5 +884,5 @@
         return rc;
     }
-    LogDHCP(("> LOAD: failed to load lease!\n"));
+    LogRel(("> LOAD: failed to load lease!\n"));
     return VERR_PARSE_ERROR;
 }
Index: /trunk/src/VBox/NetworkServices/Dhcpd/Db.h
===================================================================
--- /trunk/src/VBox/NetworkServices/Dhcpd/Db.h	(revision 79567)
+++ /trunk/src/VBox/NetworkServices/Dhcpd/Db.h	(revision 79568)
@@ -51,8 +51,8 @@
 private:
     const RTNETADDRIPV4 m_addr;
-    State m_state;
-    ClientId m_id;
-    Timestamp m_issued;
-    uint32_t m_secLease;
+    State               m_state;
+    ClientId            m_id;
+    Timestamp           m_issued;
+    uint32_t            m_secLease;
 
 public:
Index: /trunk/src/VBox/NetworkServices/Dhcpd/DhcpMessage.cpp
===================================================================
--- /trunk/src/VBox/NetworkServices/Dhcpd/DhcpMessage.cpp	(revision 79567)
+++ /trunk/src/VBox/NetworkServices/Dhcpd/DhcpMessage.cpp	(revision 79568)
@@ -16,4 +16,8 @@
  */
 
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
 #include "DhcpdInternal.h"
 #include "DhcpMessage.h"
@@ -21,87 +25,77 @@
 
 #include <iprt/string.h>
-#include <iprt/stream.h>
 
 
 
 DhcpMessage::DhcpMessage()
-  : m_xid(0), m_flags(0),
-    m_ciaddr(), m_yiaddr(), m_siaddr(), m_giaddr(),
-    m_sname(), m_file(),
-    m_optMessageType()
-{
-}
-
+    : m_xid(0)
+    , m_flags(0)
+    , m_ciaddr()
+    , m_yiaddr()
+    , m_siaddr()
+    , m_giaddr()
+#if 0 /* not currently unused  */
+    , m_sname()
+    , m_file()
+#endif
+    , m_optMessageType()
+{
+}
+
+
+/*********************************************************************************************************************************
+*   DhcpClientMessage Implementation                                                                                             *
+*********************************************************************************************************************************/
 
 /* static */
 DhcpClientMessage *DhcpClientMessage::parse(bool broadcasted, const void *buf, size_t buflen)
 {
+    /*
+     * Validate the request.
+     */
     if (buflen < RT_OFFSETOF(RTNETBOOTP, bp_vend.Dhcp.dhcp_opts))
-    {
-        RTPrintf("%s: %zu bytes datagram is too short\n", __FUNCTION__, buflen);
-        return NULL;
-    }
+        DHCP_LOG2_RET_NULL(("DhcpClientMessage::parse: %zu bytes datagram is too short\n", buflen));
 
     PCRTNETBOOTP bp = (PCRTNETBOOTP)buf;
 
     if (bp->bp_op != RTNETBOOTP_OP_REQUEST)
-    {
-        RTPrintf("%s: bad opcode: %d\n", __FUNCTION__, bp->bp_op);
-        return NULL;
-    }
+        DHCP_LOG2_RET_NULL(("DhcpClientMessage::parse: bad opcode: %d\n", bp->bp_op));
 
     if (bp->bp_htype != RTNET_ARP_ETHER)
-    {
-        RTPrintf("%s: unsupported htype %d\n", __FUNCTION__, bp->bp_htype);
-        return NULL;
-    }
+        DHCP_LOG2_RET_NULL(("DhcpClientMessage::parse: unsupported htype %d\n", bp->bp_htype));
 
     if (bp->bp_hlen != sizeof(RTMAC))
-    {
-        RTPrintf("%s: unexpected hlen %d\n", __FUNCTION__, bp->bp_hlen);
-        return NULL;
-    }
+        DHCP_LOG2_RET_NULL(("DhcpClientMessage::parse: unexpected hlen %d\n", bp->bp_hlen));
 
     if (   (bp->bp_chaddr.Mac.au8[0] & 0x01) != 0
         && (bp->bp_flags & RTNET_DHCP_FLAG_BROADCAST) == 0)
-    {
-        RTPrintf("%s: multicast chaddr %RTmac without broadcast flag\n",
-                 __FUNCTION__, &bp->bp_chaddr.Mac);
-    }
+        LogRel2(("DhcpClientMessage::parse: multicast chaddr %RTmac without broadcast flag\n", &bp->bp_chaddr.Mac));
 
     /* we don't want to deal with forwarding */
     if (bp->bp_giaddr.u != 0)
-    {
-        RTPrintf("%s: giaddr %RTnaipv4\n", __FUNCTION__, bp->bp_giaddr.u);
-        return NULL;
-    }
+        DHCP_LOG2_RET_NULL(("DhcpClientMessage::parse: giaddr %RTnaipv4\n", bp->bp_giaddr.u));
 
     if (bp->bp_hops != 0)
-    {
-        RTPrintf("%s: non-zero hops %d\n", __FUNCTION__, bp->bp_hops);
-        return NULL;
-    }
-
+        DHCP_LOG2_RET_NULL(("DhcpClientMessage::parse: non-zero hops %d\n", bp->bp_hops));
+
+    if (bp->bp_vend.Dhcp.dhcp_cookie != RT_H2N_U32_C(RTNET_DHCP_COOKIE))
+        DHCP_LOG2_RET_NULL(("DhcpClientMessage::parse: bad cookie %#RX32\n", bp->bp_vend.Dhcp.dhcp_cookie));
+
+    /*
+     * Convert it into a DhcpClientMessage instance.
+     */
     std::unique_ptr<DhcpClientMessage> msg(new DhcpClientMessage());
 
     msg->m_broadcasted = broadcasted;
-
-    msg->m_xid = bp->bp_xid;
-    msg->m_flags = bp->bp_flags;
-
-    msg->m_mac = bp->bp_chaddr.Mac;
-
-    msg->m_ciaddr = bp->bp_ciaddr;
-    msg->m_yiaddr = bp->bp_yiaddr;
-    msg->m_siaddr = bp->bp_siaddr;
-    msg->m_giaddr = bp->bp_giaddr;
-
-    if (bp->bp_vend.Dhcp.dhcp_cookie != RT_H2N_U32_C(RTNET_DHCP_COOKIE))
-    {
-        RTPrintf("bad cookie\n");
-        return NULL;
-    }
-
-    int fOptOverload = msg->parseOptions(&bp->bp_vend.Dhcp.dhcp_opts, buflen - RT_OFFSETOF(RTNETBOOTP, bp_vend.Dhcp.dhcp_opts));
+    msg->m_xid         = bp->bp_xid;
+    msg->m_flags       = bp->bp_flags;
+    msg->m_mac         = bp->bp_chaddr.Mac;
+    msg->m_ciaddr      = bp->bp_ciaddr;
+    msg->m_yiaddr      = bp->bp_yiaddr;
+    msg->m_siaddr      = bp->bp_siaddr;
+    msg->m_giaddr      = bp->bp_giaddr;
+
+    int fOptOverload = msg->i_parseOptions(&bp->bp_vend.Dhcp.dhcp_opts[0],
+                                           buflen - RT_OFFSETOF(RTNETBOOTP, bp_vend.Dhcp.dhcp_opts));
     if (fOptOverload < 0)
         return NULL;
@@ -110,8 +104,9 @@
     if (fOptOverload & RTNET_DHCP_OPTION_OVERLOAD_FILE)
     {
-        int status = msg->parseOptions(bp->bp_file, sizeof(bp->bp_file));
+        int status = msg->i_parseOptions(bp->bp_file, sizeof(bp->bp_file));
         if (status != 0)
             return NULL;
     }
+#if 0 /* not currently unused  */
     else if (bp->bp_file[0] != '\0')
     {
@@ -122,12 +117,14 @@
             msg->m_file.assign(pszFile, len);
     }
+#endif
 
     /* "... followed by the 'sname' field." */
     if (fOptOverload & RTNET_DHCP_OPTION_OVERLOAD_SNAME)
     {
-        int status = msg->parseOptions(bp->bp_sname, sizeof(bp->bp_sname));
+        int status = msg->i_parseOptions(bp->bp_sname, sizeof(bp->bp_sname));
         if (status != 0) /* NB: this includes "nested" Option Overload */
             return NULL;
     }
+#if 0 /* not currently unused  */
     else if (bp->bp_sname[0] != '\0')
     {
@@ -138,4 +135,5 @@
             msg->m_sname.assign(pszSName, len);
     }
+#endif
 
     msg->m_optMessageType = OptMessageType(*msg);
@@ -149,60 +147,47 @@
 
 
-int DhcpClientMessage::parseOptions(const void *buf, size_t buflen)
-{
-    int            fOptOverload = 0;
-    const uint8_t *data        = static_cast<const uint8_t *>(buf);
-    while (buflen > 0)
-    {
-        uint8_t const opt = *data++;
-        --buflen;
-
-        if (opt == RTNET_DHCP_OPT_PAD)
+int DhcpClientMessage::i_parseOptions(const uint8_t *pbBuf, size_t cbBuf) RT_NOEXCEPT
+{
+    int fOptOverload = 0;
+    while (cbBuf > 0)
+    {
+        uint8_t const bOpt = *pbBuf++;
+        --cbBuf;
+
+        if (bOpt == RTNET_DHCP_OPT_PAD)
             continue;
 
-        if (opt == RTNET_DHCP_OPT_END)
-            break;
-
-        if (buflen == 0)
-        {
-            RTPrintf("option %d has no length field\n", opt);
-            return -1;
-        }
-
-        uint8_t optlen = *data++;
-        --buflen;
-
-        if (optlen > buflen)
-        {
-            RTPrintf("option %d truncated (length %d, but only %lu bytes left)\n", opt, optlen, (unsigned long)buflen);
-            return -1;
-        }
+        if (bOpt == RTNET_DHCP_OPT_END)
+            break;
+
+        if (cbBuf == 0)
+            DHCP_LOG_RET(-1, ("option %d has no length field\n", bOpt));
+
+        uint8_t const cbOpt = *pbBuf++;
+        --cbBuf;
+
+        if (cbOpt > cbBuf)
+            DHCP_LOG_RET(-1, ("option %d truncated (length %d, but only %zu bytes left)\n", bOpt, cbOpt, cbBuf));
 
 #if 0
-        rawopts_t::const_iterator it(m_optmap.find(opt));
+        rawopts_t::const_iterator it(m_optmap.find(bOpt));
         if (it != m_optmap.cend())
             return -1;
 #endif
-        if (opt == RTNET_DHCP_OPT_OPTION_OVERLOAD)
+        if (bOpt == RTNET_DHCP_OPT_OPTION_OVERLOAD)
         {
-            if (optlen != 1)
-            {
-                RTPrintf("Overload Option (option %d) has invalid length %d\n", opt, optlen);
-                return -1;
-            }
-
-            fOptOverload = *data;
+            if (cbOpt != 1)
+                DHCP_LOG_RET(-1, ("Overload Option (option %d) has invalid length %d\n", bOpt, cbOpt));
+
+            fOptOverload = *pbBuf;
 
             if ((fOptOverload & ~RTNET_DHCP_OPTION_OVERLOAD_MASK) != 0)
-            {
-                RTPrintf("Overload Option (option %d) has invalid value 0x%x\n", opt, fOptOverload);
-                return -1;
-            }
+                DHCP_LOG_RET(-1, ("Overload Option (option %d) has invalid value 0x%x\n", bOpt, fOptOverload));
         }
         else
-            m_rawopts.insert(std::make_pair(opt, octets_t(data, data + optlen)));
-
-        data   += optlen;
-        buflen -= optlen;
+            m_rawopts.insert(std::make_pair(bOpt, octets_t(pbBuf, pbBuf + cbOpt)));
+
+        pbBuf += cbOpt;
+        cbBuf -= cbOpt;
     }
 
@@ -211,79 +196,85 @@
 
 
-void DhcpClientMessage::dump() const
+void DhcpClientMessage::dump() const RT_NOEXCEPT
 {
     switch (m_optMessageType.value())
     {
         case RTNET_DHCP_MT_DISCOVER:
-            LogDHCP(("DISCOVER"));
+            LogRel(("DISCOVER"));
             break;
 
         case RTNET_DHCP_MT_REQUEST:
-            LogDHCP(("REQUEST"));
+            LogRel(("REQUEST"));
             break;
 
         case RTNET_DHCP_MT_INFORM:
-            LogDHCP(("INFORM"));
+            LogRel(("INFORM"));
             break;
 
         case RTNET_DHCP_MT_DECLINE:
-            LogDHCP(("DECLINE"));
+            LogRel(("DECLINE"));
             break;
 
         case RTNET_DHCP_MT_RELEASE:
-            LogDHCP(("RELEASE"));
+            LogRel(("RELEASE"));
             break;
 
         default:
-            LogDHCP(("<Unknown Mesage Type %d>", m_optMessageType.value()));
+            LogRel(("<Unknown Mesage Type %d>", m_optMessageType.value()));
             break;
     }
 
     if (OptRapidCommit(*this).present())
-        LogDHCP((" (rapid commit)"));
-
-
-    const OptServerId sid(*this);
-    if (sid.present())
-        LogDHCP((" for server %RTnaipv4", sid.value().u));
-
-    LogDHCP((" xid 0x%08x", m_xid));
-    LogDHCP((" chaddr %RTmac\n", &m_mac));
-
-    const OptClientId cid(*this);
-    if (cid.present()) {
-        if (cid.value().size() > 0)
-            LogDHCP((" client id: %.*Rhxs\n", cid.value().size(), &cid.value().front()));
-        else
-            LogDHCP((" client id: <empty>\n"));
-    }
-
-    LogDHCP((" ciaddr %RTnaipv4", m_ciaddr.u));
-    if (m_yiaddr.u != 0)
-        LogDHCP((" yiaddr %RTnaipv4", m_yiaddr.u));
-    if (m_siaddr.u != 0)
-        LogDHCP((" siaddr %RTnaipv4", m_siaddr.u));
-    if (m_giaddr.u != 0)
-        LogDHCP((" giaddr %RTnaipv4", m_giaddr.u));
-    LogDHCP(("%s\n", broadcast() ? "broadcast" : ""));
-
-
-    const OptRequestedAddress reqAddr(*this);
-    if (reqAddr.present())
-        LogDHCP((" requested address %RTnaipv4", reqAddr.value().u));
-    const OptLeaseTime reqLeaseTime(*this);
-    if (reqLeaseTime.present())
-        LogDHCP((" requested lease time %d", reqAddr.value()));
-    if (reqAddr.present() || reqLeaseTime.present())
-        LogDHCP(("\n"));
-
-    const OptParameterRequest params(*this);
-    if (params.present())
-    {
-        LogDHCP((" params {"));
-        typedef OptParameterRequest::value_t::const_iterator it_t;
-        for (it_t it = params.value().begin(); it != params.value().end(); ++it)
-            LogDHCP((" %d", *it));
-        LogDHCP((" }\n"));
+        LogRel((" (rapid commit)"));
+
+    try
+    {
+        const OptServerId sid(*this);
+        if (sid.present())
+            LogRel((" for server %RTnaipv4", sid.value().u));
+
+        LogRel((" xid 0x%08x", m_xid));
+        LogRel((" chaddr %RTmac\n", &m_mac));
+
+        const OptClientId cid(*this);
+        if (cid.present()) {
+            if (cid.value().size() > 0)
+                LogRel((" client id: %.*Rhxs\n", cid.value().size(), &cid.value().front()));
+            else
+                LogRel((" client id: <empty>\n"));
+        }
+
+        LogRel((" ciaddr %RTnaipv4", m_ciaddr.u));
+        if (m_yiaddr.u != 0)
+            LogRel((" yiaddr %RTnaipv4", m_yiaddr.u));
+        if (m_siaddr.u != 0)
+            LogRel((" siaddr %RTnaipv4", m_siaddr.u));
+        if (m_giaddr.u != 0)
+            LogRel((" giaddr %RTnaipv4", m_giaddr.u));
+        LogRel(("%s\n", broadcast() ? "broadcast" : ""));
+
+
+        const OptRequestedAddress reqAddr(*this);
+        if (reqAddr.present())
+            LogRel((" requested address %RTnaipv4", reqAddr.value().u));
+        const OptLeaseTime reqLeaseTime(*this);
+        if (reqLeaseTime.present())
+            LogRel((" requested lease time %d", reqAddr.value()));
+        if (reqAddr.present() || reqLeaseTime.present())
+            LogRel(("\n"));
+
+        const OptParameterRequest params(*this);
+        if (params.present())
+        {
+            LogRel((" params {"));
+            typedef OptParameterRequest::value_t::const_iterator it_t;
+            for (it_t it = params.value().begin(); it != params.value().end(); ++it)
+                LogRel((" %d", *it));
+            LogRel((" }\n"));
+        }
+    }
+    catch (std::bad_alloc &)
+    {
+        LogRel(("bad_alloc during dumping\n"));
     }
 
@@ -292,5 +283,6 @@
     {
         const uint8_t optcode = (*it).first;
-        switch (optcode) {
+        switch (optcode)
+        {
             case OptMessageType::optcode:      /* FALLTHROUGH */
             case OptClientId::optcode:         /* FALLTHROUGH */
@@ -304,20 +296,24 @@
                 if (fHeader)
                 {
-                    LogDHCP((" other options:"));
+                    LogRel((" other options:"));
                     fHeader = false;
                 }
-                LogDHCP((" %d", optcode));
+                LogRel((" %d", optcode));
                 break;
         }
     }
     if (!fHeader)
-        LogDHCP(("\n"));
-}
-
-
-DhcpServerMessage::DhcpServerMessage(const DhcpClientMessage &req,
-                                     uint8_t messageTypeParam, RTNETADDRIPV4 serverAddr)
-  : DhcpMessage(),
-    m_optServerId(serverAddr)
+        LogRel(("\n"));
+}
+
+
+
+/*********************************************************************************************************************************
+*   DhcpServerMessage Implementation                                                                                             *
+*********************************************************************************************************************************/
+
+DhcpServerMessage::DhcpServerMessage(const DhcpClientMessage &req, uint8_t messageTypeParam, RTNETADDRIPV4 serverAddr)
+    : DhcpMessage()
+    , m_optServerId(serverAddr)
 {
     m_dst.u = 0xffffffff;       /* broadcast */
@@ -336,5 +332,5 @@
 
 
-void DhcpServerMessage::maybeUnicast(const DhcpClientMessage &req)
+void DhcpServerMessage::maybeUnicast(const DhcpClientMessage &req) RT_NOEXCEPT
 {
     if (!req.broadcast() && req.ciaddr().u != 0)
@@ -343,4 +339,7 @@
 
 
+/**
+ * @throws  std::bad_alloc
+ */
 void DhcpServerMessage::addOption(DhcpOption *opt)
 {
@@ -349,14 +348,17 @@
 
 
+/**
+ * @throws  std::bad_alloc
+ */
 void DhcpServerMessage::addOptions(const optmap_t &optmap)
 {
-    for (optmap_t::const_iterator it ( optmap.begin() );
-         it != optmap.end(); ++it)
-    {
+    for (optmap_t::const_iterator it( optmap.begin() ); it != optmap.end(); ++it)
         m_optmap << it->second;
-    }
-}
-
-
+}
+
+
+/**
+ * @throws  std::bad_alloc
+ */
 int DhcpServerMessage::encode(octets_t &data)
 {
@@ -393,5 +395,5 @@
          it != m_optmap.end(); ++it)
     {
-        RTPrintf("encoding option %d\n", it->first);
+        LogRel3(("encoding option %d\n", it->first));
         DhcpOption &opt = *it->second;
         data << opt;
@@ -400,6 +402,7 @@
     data << OptEnd();
 
-    if (data.size() < 548)      /* XXX */
-        data.resize(548);
+    AssertCompile(RTNET_DHCP_NORMAL_SIZE == 548);
+    if (data.size() < RTNET_DHCP_NORMAL_SIZE)      /* XXX */
+        data.resize(RTNET_DHCP_NORMAL_SIZE);
 
     return VINF_SUCCESS;
Index: /trunk/src/VBox/NetworkServices/Dhcpd/DhcpMessage.h
===================================================================
--- /trunk/src/VBox/NetworkServices/Dhcpd/DhcpMessage.h	(revision 79567)
+++ /trunk/src/VBox/NetworkServices/Dhcpd/DhcpMessage.h	(revision 79568)
@@ -29,12 +29,14 @@
 
 
-
+/**
+ * Base class for internal DHCP client and server message representations.
+ */
 class DhcpMessage
 {
 protected:
-    uint32_t m_xid;
-    uint16_t m_flags;
+    uint32_t        m_xid;
+    uint16_t        m_flags;
 
-    RTMAC m_mac;
+    RTMAC           m_mac;
 
     RTNETADDRIPV4   m_ciaddr;
@@ -43,90 +45,103 @@
     RTNETADDRIPV4   m_giaddr;
 
-    RTCString m_sname;
-    RTCString m_file;
+#if 0 /* not currently unused, so avoid wasting time on them for now.  */
+    RTCString       m_sname;  /**< @note Not necessarily UTF-8 clean. */
+    RTCString       m_file;   /**< @note Not necessarily UTF-8 clean. */
+#endif
 
-    OptMessageType m_optMessageType;
+    OptMessageType  m_optMessageType;
+
+protected:
+    DhcpMessage();
 
 public:
-    DhcpMessage();
+    /** @name Accessors
+     * @{ */
+    uint32_t        xid() const RT_NOEXCEPT                     { return m_xid; }
 
+    uint16_t        flags() const RT_NOEXCEPT                   { return m_flags; }
+    bool            broadcast() const RT_NOEXCEPT               { return (m_flags & RTNET_DHCP_FLAG_BROADCAST) != 0; }
 
-    uint32_t xid() const { return m_xid; }
+    const RTMAC     &mac() const RT_NOEXCEPT                    { return m_mac; }
 
-    uint16_t flags() const { return m_flags; }
-    bool broadcast() const { return (m_flags & RTNET_DHCP_FLAG_BROADCAST) != 0; }
+    RTNETADDRIPV4   ciaddr() const RT_NOEXCEPT                  { return m_ciaddr; }
+    RTNETADDRIPV4   yiaddr() const RT_NOEXCEPT                  { return m_yiaddr; }
+    RTNETADDRIPV4   siaddr() const RT_NOEXCEPT                  { return m_siaddr; }
+    RTNETADDRIPV4   giaddr() const RT_NOEXCEPT                  { return m_giaddr; }
 
-    const RTMAC &mac() const { return m_mac; }
+    void            setCiaddr(RTNETADDRIPV4 addr) RT_NOEXCEPT   { m_ciaddr = addr; }
+    void            setYiaddr(RTNETADDRIPV4 addr) RT_NOEXCEPT   { m_yiaddr = addr; }
+    void            setSiaddr(RTNETADDRIPV4 addr) RT_NOEXCEPT   { m_siaddr = addr; }
+    void            setGiaddr(RTNETADDRIPV4 addr) RT_NOEXCEPT   { m_giaddr = addr; }
 
-    RTNETADDRIPV4 ciaddr() const { return m_ciaddr; }
-    RTNETADDRIPV4 yiaddr() const { return m_yiaddr; }
-    RTNETADDRIPV4 siaddr() const { return m_siaddr; }
-    RTNETADDRIPV4 giaddr() const { return m_giaddr; }
-
-    void setCiaddr(RTNETADDRIPV4 addr) { m_ciaddr = addr; }
-    void setYiaddr(RTNETADDRIPV4 addr) { m_yiaddr = addr; }
-    void setSiaddr(RTNETADDRIPV4 addr) { m_siaddr = addr; }
-    void setGiaddr(RTNETADDRIPV4 addr) { m_giaddr = addr; }
-
-    uint8_t messageType() const RT_NOEXCEPT
+    uint8_t         messageType() const RT_NOEXCEPT
     {
         Assert(m_optMessageType.present());
         return m_optMessageType.value();
     }
+    /** @} */
 };
 
 
+/**
+ * Decoded DHCP client message.
+ *
+ * This is the internal decoded representation of a DHCP message picked up from
+ * the wire.
+ */
 class DhcpClientMessage
-  : public DhcpMessage
+    : public DhcpMessage
 {
 protected:
-    rawopts_t m_rawopts;
-    ClientId m_id;
-    bool m_broadcasted;
+    rawopts_t       m_rawopts;
+    ClientId        m_id;
+    bool            m_broadcasted;
 
 public:
     static DhcpClientMessage *parse(bool broadcasted, const void *buf, size_t buflen);
 
-    bool broadcasted() const { return m_broadcasted; }
+    /** @name Getters
+     * @{ */
+    bool            broadcasted() const RT_NOEXCEPT             { return m_broadcasted; }
+    const rawopts_t &rawopts() const RT_NOEXCEPT                { return m_rawopts; }
+    const ClientId &clientId() const RT_NOEXCEPT                { return m_id; }
+    /** @} */
 
-    const rawopts_t &rawopts() const { return m_rawopts; }
-    const ClientId &clientId() const { return m_id; }
-
-    void dump() const;
+    void            dump() const RT_NOEXCEPT;
 
 protected:
-    int parseOptions(const void *buf, size_t buflen);
+    int             i_parseOptions(const uint8_t *pbBuf, size_t cbBuf) RT_NOEXCEPT;
 };
 
 
 
+/**
+ * DHCP server message for encoding.
+ */
 class DhcpServerMessage
-  : public DhcpMessage
+    : public DhcpMessage
 {
 protected:
-    RTNETADDRIPV4 m_dst;
-
-    OptServerId m_optServerId;
-
-    optmap_t m_optmap;
+    RTNETADDRIPV4   m_dst;
+    OptServerId     m_optServerId;
+    optmap_t        m_optmap;
 
 public:
-    DhcpServerMessage(const DhcpClientMessage &req,
-                      uint8_t messageType, RTNETADDRIPV4 serverAddr);
+    DhcpServerMessage(const DhcpClientMessage &req, uint8_t messageType, RTNETADDRIPV4 serverAddr);
 
-    RTNETADDRIPV4 dst() const { return m_dst; }
-    void setDst(RTNETADDRIPV4 aDst) { m_dst = aDst; }
+    /** @name Accessors
+     * @{ */
+    RTNETADDRIPV4   dst() const RT_NOEXCEPT                     { return m_dst; }
+    void            setDst(RTNETADDRIPV4 aDst) RT_NOEXCEPT      { m_dst = aDst; }
 
-    void maybeUnicast(const DhcpClientMessage &req);
+    void            maybeUnicast(const DhcpClientMessage &req) RT_NOEXCEPT;
 
-    void addOption(DhcpOption *opt);
-    void addOption(const DhcpOption &opt)
-    {
-        addOption(opt.clone());
-    }
+    void            addOption(DhcpOption *opt);
+    void            addOption(const DhcpOption &opt)            { addOption(opt.clone()); }
 
-    void addOptions(const optmap_t &optmap);
+    void            addOptions(const optmap_t &optmap);
+    /** @} */
 
-    int encode(octets_t &data);
+    int             encode(octets_t &data);
 };
 
Index: /trunk/src/VBox/NetworkServices/Dhcpd/DhcpdInternal.h
===================================================================
--- /trunk/src/VBox/NetworkServices/Dhcpd/DhcpdInternal.h	(revision 79567)
+++ /trunk/src/VBox/NetworkServices/Dhcpd/DhcpdInternal.h	(revision 79568)
@@ -63,12 +63,18 @@
 
 
-/** @def LogDHCP
- * Wrapper around LogRel.  */
-#if 1
-# define LogDHCP LogRel
-#else
-# include <iprt/stream.h>
-# define LogDHCP(args) RTPrintf args
-#endif
+/** @name LogXRel + return NULL helpers
+ * @{ */
+#define DHCP_LOG_RET_NULL(a_MsgArgs)        do { LogRel(a_MsgArgs);     return NULL; } while (0)
+#define DHCP_LOG2_RET_NULL(a_MsgArgs)       do { LogRel2(a_MsgArgs);    return NULL; } while (0)
+#define DHCP_LOG3_RET_NULL(a_MsgArgs)       do { LogRel3(a_MsgArgs);    return NULL; } while (0)
+/** @} */
+
+
+/** @name LogXRel + return a_rcRet helpers
+ * @{ */
+#define DHCP_LOG_RET(a_rcRet, a_MsgArgs)    do { LogRel(a_MsgArgs);     return (a_rcRet); } while (0)
+#define DHCP_LOG2_RET(a_rcRet, a_MsgArgs)   do { LogRel2(a_MsgArgs);    return (a_rcRet); } while (0)
+#define DHCP_LOG3_RET(a_rcRet, a_MsgArgs)   do { LogRel3(a_MsgArgs);    return (a_rcRet); } while (0)
+/** @} */
 
 #endif /* !VBOX_INCLUDED_SRC_Dhcpd_DhcpdInternal_h */
Index: /trunk/src/VBox/NetworkServices/Dhcpd/IPv4Pool.cpp
===================================================================
--- /trunk/src/VBox/NetworkServices/Dhcpd/IPv4Pool.cpp	(revision 79567)
+++ /trunk/src/VBox/NetworkServices/Dhcpd/IPv4Pool.cpp	(revision 79568)
@@ -76,5 +76,5 @@
         if (a_Range.FirstAddr <= prev->LastAddr)
         {
-            LogDHCP(("%08x-%08x conflicts with %08x-%08x\n",
+            LogRel(("%08x-%08x conflicts with %08x-%08x\n",
                      a_Range.FirstAddr, a_Range.LastAddr,
                      prev->FirstAddr, prev->LastAddr));
@@ -127,4 +127,5 @@
             IPv4Range trimmed = *itBeg;
             trimmed.FirstAddr += 1;
+            Assert(trimmed.FirstAddr <= trimmed.LastAddr);
             m_pool.erase(itBeg);
             try
Index: /trunk/src/VBox/NetworkServices/Dhcpd/VBoxNetDhcpd.cpp
===================================================================
--- /trunk/src/VBox/NetworkServices/Dhcpd/VBoxNetDhcpd.cpp	(revision 79567)
+++ /trunk/src/VBox/NetworkServices/Dhcpd/VBoxNetDhcpd.cpp	(revision 79568)
@@ -741,36 +741,43 @@
                     || ip_addr_cmp(ip_current_dest_addr(), &ip_addr_any);
 
-    DhcpClientMessage *msgIn = DhcpClientMessage::parse(broadcasted, p->payload, p->len);
-    if (msgIn == NULL)
-        return;
-
-    std::unique_ptr<DhcpClientMessage> autoFreeMsgIn(msgIn);
-
-    DhcpServerMessage *msgOut = m_server.process(*msgIn);
-    if (msgOut == NULL)
-        return;
-
-    std::unique_ptr<DhcpServerMessage> autoFreeMsgOut(msgOut);
-
-    ip_addr_t dst = { msgOut->dst().u };
-    if (ip_addr_cmp(&dst, &ip_addr_any))
-        ip_addr_copy(dst, ip_addr_broadcast);
-
-    octets_t data;
-    int rc = msgOut->encode(data);
-    if (RT_FAILURE(rc))
-        return;
-
-    unique_ptr_pbuf q ( pbuf_alloc(PBUF_RAW, (u16_t)data.size(), PBUF_RAM) );
-    if (!q)
-        return;
-
-    err_t error = pbuf_take(q.get(), &data.front(), (u16_t)data.size());
-    if (error != ERR_OK)
-        return;
-
-    error = udp_sendto(pcb, q.get(), &dst, RTNETIPV4_PORT_BOOTPC);
-    if (error != ERR_OK)
-        return;
+    try
+    {
+        DhcpClientMessage *msgIn = DhcpClientMessage::parse(broadcasted, p->payload, p->len);
+        if (msgIn == NULL)
+            return;
+
+        std::unique_ptr<DhcpClientMessage> autoFreeMsgIn(msgIn);
+
+        DhcpServerMessage *msgOut = m_server.process(*msgIn);
+        if (msgOut == NULL)
+            return;
+
+        std::unique_ptr<DhcpServerMessage> autoFreeMsgOut(msgOut);
+
+        ip_addr_t dst = { msgOut->dst().u };
+        if (ip_addr_cmp(&dst, &ip_addr_any))
+            ip_addr_copy(dst, ip_addr_broadcast);
+
+        octets_t data;
+        int rc = msgOut->encode(data);
+        if (RT_FAILURE(rc))
+            return;
+
+        unique_ptr_pbuf q ( pbuf_alloc(PBUF_RAW, (u16_t)data.size(), PBUF_RAM) );
+        if (!q)
+            return;
+
+        err_t error = pbuf_take(q.get(), &data.front(), (u16_t)data.size());
+        if (error != ERR_OK)
+            return;
+
+        error = udp_sendto(pcb, q.get(), &dst, RTNETIPV4_PORT_BOOTPC);
+        if (error != ERR_OK)
+            return;
+    }
+    catch (std::bad_alloc &)
+    {
+        LogRel(("VBoxNetDhcpd::dhcp4Recv: Caught std::bad_alloc!\n"));
+    }
 }
 
