Index: /trunk/src/VBox/NetworkServices/DHCP/ClientDataInt.h
===================================================================
--- /trunk/src/VBox/NetworkServices/DHCP/ClientDataInt.h	(revision 49563)
+++ /trunk/src/VBox/NetworkServices/DHCP/ClientDataInt.h	(revision 49563)
@@ -0,0 +1,66 @@
+/* $Id$ */
+/** @file
+ * Config.h
+ */
+
+/*
+ * Copyright (C) 2013 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifndef __CLIENT_DATA_INT_H__
+#define __CLIENT_DATA_INT_H__
+
+class ClientData
+{
+public:
+    ClientData()
+    {
+        m_address.u = 0;
+        m_network.u = 0;
+        fHasLease = false;
+        fHasClient = false;
+        fBinding = true;
+        u64TimestampBindingStarted = 0;
+        u64TimestampLeasingStarted = 0;
+        u32LeaseExpirationPeriod = 0;
+        u32BindExpirationPeriod = 0;
+        pCfg = NULL;
+
+    }
+    ~ClientData(){}
+    
+    /* client information */
+    RTNETADDRIPV4 m_address;
+    RTNETADDRIPV4 m_network;
+    RTMAC m_mac;
+    
+    bool fHasClient;
+
+    /* Lease part */
+    bool fHasLease; 
+    /** lease isn't commited */
+    bool fBinding;
+
+    /** Timestamp when lease commited. */
+    uint64_t u64TimestampLeasingStarted;
+    /** Period when lease is expired in secs. */
+    uint32_t u32LeaseExpirationPeriod;
+
+    /** timestamp when lease was bound */
+    uint64_t u64TimestampBindingStarted;
+    /* Period when binding is expired in secs. */
+    uint32_t u32BindExpirationPeriod;
+
+    MapOptionId2RawOption options;
+
+    NetworkConfigEntity *pCfg;
+};
+#endif
Index: /trunk/src/VBox/NetworkServices/DHCP/Config.cpp
===================================================================
--- /trunk/src/VBox/NetworkServices/DHCP/Config.cpp	(revision 49562)
+++ /trunk/src/VBox/NetworkServices/DHCP/Config.cpp	(revision 49563)
@@ -28,52 +28,5 @@
 
 #include "Config.h"
-
-/* types */
-class ClientData
-{
-public:
-    ClientData()
-    {
-        m_address.u = 0;
-        m_network.u = 0;
-        fHasLease = false;
-        fHasClient = false;
-        fBinding = true;
-        u64TimestampBindingStarted = 0;
-        u64TimestampLeasingStarted = 0;
-        u32LeaseExpirationPeriod = 0;
-        u32BindExpirationPeriod = 0;
-        pCfg = NULL;
-
-    }
-    ~ClientData(){}
-    
-    /* client information */
-    RTNETADDRIPV4 m_address;
-    RTNETADDRIPV4 m_network;
-    RTMAC m_mac;
-    
-    bool fHasClient;
-
-    /* Lease part */
-    bool fHasLease; 
-    /** lease isn't commited */
-    bool fBinding;
-
-    /** Timestamp when lease commited. */
-    uint64_t u64TimestampLeasingStarted;
-    /** Period when lease is expired in secs. */
-    uint32_t u32LeaseExpirationPeriod;
-
-    /** timestamp when lease was bound */
-    uint64_t u64TimestampBindingStarted;
-    /* Period when binding is expired in secs. */
-    uint32_t u32BindExpirationPeriod;
-
-    MapOptionId2RawOption options;
-
-    NetworkConfigEntity *pCfg;
-};
-
+#include "ClientDataInt.h"
 
 bool operator== (const Lease& lhs, const Lease& rhs)
Index: /trunk/src/VBox/NetworkServices/DHCP/Config.h
===================================================================
--- /trunk/src/VBox/NetworkServices/DHCP/Config.h	(revision 49562)
+++ /trunk/src/VBox/NetworkServices/DHCP/Config.h	(revision 49563)
@@ -519,4 +519,8 @@
     void setRingBuffer(PINTNETBUF);
 
+    bool handleDhcpReqDiscover(PCRTNETBOOTP pDhcpMsg, size_t cb);
+    bool handleDhcpReqRequest(PCRTNETBOOTP pDhcpMsg, size_t cb);
+    bool handleDhcpReqDecline(PCRTNETBOOTP pDhcpMsg, size_t cb);
+    bool handleDhcpReqRelease(PCRTNETBOOTP pDhcpMsg, size_t cb);
 private:
     NetworkManager();
Index: /trunk/src/VBox/NetworkServices/DHCP/Makefile.kmk
===================================================================
--- /trunk/src/VBox/NetworkServices/DHCP/Makefile.kmk	(revision 49562)
+++ /trunk/src/VBox/NetworkServices/DHCP/Makefile.kmk	(revision 49563)
@@ -45,4 +45,5 @@
 	VBoxNetDHCP.cpp \
 	Config.cpp \
+	NetworkManagerDhcp.cpp \
 	../NetLib/VBoxNetIntIf.cpp \
 	../NetLib/VBoxNetUDP.cpp \
Index: /trunk/src/VBox/NetworkServices/DHCP/NetworkManagerDhcp.cpp
===================================================================
--- /trunk/src/VBox/NetworkServices/DHCP/NetworkManagerDhcp.cpp	(revision 49563)
+++ /trunk/src/VBox/NetworkServices/DHCP/NetworkManagerDhcp.cpp	(revision 49563)
@@ -0,0 +1,184 @@
+/* $Id$ */
+/** @file
+ * NetworkManagerDhcp - Network Manager part handling Dhcp.
+ */
+
+/*
+ * Copyright (C) 2013 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <iprt/asm.h>
+#include <iprt/cdefs.h>
+#include <iprt/net.h>
+#include <iprt/param.h>
+#include <iprt/path.h>
+#include <iprt/stream.h>
+#include <iprt/time.h>
+#include <iprt/string.h>
+
+#include "../NetLib/shared_ptr.h"
+
+#include <vector>
+#include <list>
+#include <string>
+#include <map>
+
+#include <VBox/sup.h>
+#include <VBox/intnet.h>
+#include "Config.h"
+#include "ClientDataInt.h"
+
+/**
+ * The client is requesting an offer.
+ *
+ * @returns true.
+ *
+ * @param   pDhcpMsg    The message.
+ * @param   cb          The message size.
+ */
+bool NetworkManager::handleDhcpReqDiscover(PCRTNETBOOTP pDhcpMsg, size_t cb)
+{
+    RawOption opt;
+    memset(&opt, 0, sizeof(RawOption));
+    /* 1. Find client */
+    ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager();
+    Client client = confManager->getClientByDhcpPacket(pDhcpMsg, cb);
+
+    /* 2. Find/Bind lease for client */
+    Lease lease = confManager->allocateLease4Client(client, pDhcpMsg, cb);
+    AssertReturn(lease != Lease::NullLease, VINF_SUCCESS);
+
+    int rc = ConfigurationManager::extractRequestList(pDhcpMsg, cb, opt);
+
+    /* 3. Send of offer */
+
+    lease.bindingPhase(true);
+    lease.phaseStart(RTTimeMilliTS());
+    lease.setExpiration(300); /* 3 min. */
+    offer4Client(client, pDhcpMsg->bp_xid, opt.au8RawOpt, opt.cbRawOpt);
+
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * The client is requesting an offer.
+ *
+ * @returns true.
+ *
+ * @param   pDhcpMsg    The message.
+ * @param   cb          The message size.
+ */
+bool NetworkManager::handleDhcpReqRequest(PCRTNETBOOTP pDhcpMsg, size_t cb)
+{
+    ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager();
+
+    /* 1. find client */
+    Client client = confManager->getClientByDhcpPacket(pDhcpMsg, cb);
+
+    /* 2. find bound lease */
+    Lease l = client.lease();
+    if (l != Lease::NullLease)
+    {
+
+        if (l.isExpired())
+        {
+            /* send client to INIT state */
+            Client c(client);
+            nak(client, pDhcpMsg->bp_xid);
+            confManager->expireLease4Client(c);
+            return true;
+        }
+        else {
+            /* XXX: Validate request */
+            RawOption opt;
+            RT_ZERO(opt);
+
+            Client c(client);
+            int rc = confManager->commitLease4Client(c);
+            AssertRCReturn(rc, false);
+
+            rc = ConfigurationManager::extractRequestList(pDhcpMsg, cb, opt);
+            AssertRCReturn(rc, false);
+
+            ack(client, pDhcpMsg->bp_xid, opt.au8RawOpt, opt.cbRawOpt);
+        }
+    }
+    else
+    {
+        nak(client, pDhcpMsg->bp_xid);
+    }
+    return true;
+}
+
+
+/**
+ * The client is declining an offer we've made.
+ *
+ * @returns true.
+ *
+ * @param   pDhcpMsg    The message.
+ * @param   cb          The message size.
+ */
+bool NetworkManager::handleDhcpReqDecline(PCRTNETBOOTP, size_t)
+{
+    /** @todo Probably need to match the server IP here to work correctly with
+     *        other servers. */
+
+    /*
+     * The client is supposed to pass us option 50, requested address,
+     * from the offer. We also match the lease state. Apparently the
+     * MAC address is not supposed to be checked here.
+     */
+
+    /** @todo this is not required in the initial implementation, do it later. */
+    return true;
+}
+
+
+/**
+ * The client is releasing its lease - good boy.
+ *
+ * @returns true.
+ *
+ * @param   pDhcpMsg    The message.
+ * @param   cb          The message size.
+ */
+bool NetworkManager::handleDhcpReqRelease(PCRTNETBOOTP, size_t)
+{
+    /** @todo Probably need to match the server IP here to work correctly with
+     *        other servers. */
+
+    /*
+     * The client may pass us option 61, client identifier, which we should
+     * use to find the lease by.
+     *
+     * We're matching MAC address and lease state as well.
+     */
+
+    /*
+     * If no client identifier or if we couldn't find a lease by using it,
+     * we will try look it up by the client IP address.
+     */
+
+
+    /*
+     * If found, release it.
+     */
+
+
+    /** @todo this is not required in the initial implementation, do it later. */
+    return true;
+}
+
Index: /trunk/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp
===================================================================
--- /trunk/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp	(revision 49562)
+++ /trunk/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp	(revision 49563)
@@ -394,17 +394,19 @@
     if (pDhcpMsg->bp_op == RTNETBOOTP_OP_REQUEST)
     {
+        NetworkManager *networkManager = NetworkManager::getNetworkManager();
+
         switch (uMsgType)
         {
             case RTNET_DHCP_MT_DISCOVER:
-                return handleDhcpReqDiscover(pDhcpMsg, cb);
+                return networkManager->handleDhcpReqDiscover(pDhcpMsg, cb);
 
             case RTNET_DHCP_MT_REQUEST:
-                return handleDhcpReqRequest(pDhcpMsg, cb);
+                return networkManager->handleDhcpReqRequest(pDhcpMsg, cb);
 
             case RTNET_DHCP_MT_DECLINE:
-                return handleDhcpReqDecline(pDhcpMsg, cb);
+                return networkManager->handleDhcpReqDecline(pDhcpMsg, cb);
 
             case RTNET_DHCP_MT_RELEASE:
-                return handleDhcpReqRelease(pDhcpMsg, cb);
+                return networkManager->handleDhcpReqRelease(pDhcpMsg, cb);
 
             case RTNET_DHCP_MT_INFORM:
@@ -419,153 +421,4 @@
     return false;
 }
-
-
-/**
- * The client is requesting an offer.
- *
- * @returns true.
- *
- * @param   pDhcpMsg    The message.
- * @param   cb          The message size.
- */
-bool VBoxNetDhcp::handleDhcpReqDiscover(PCRTNETBOOTP pDhcpMsg, size_t cb)
-{
-    RawOption opt;
-    memset(&opt, 0, sizeof(RawOption));
-    /* 1. Find client */
-    ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager();
-    Client client = confManager->getClientByDhcpPacket(pDhcpMsg, cb);
-
-    /* 2. Find/Bind lease for client */
-    Lease lease = confManager->allocateLease4Client(client, pDhcpMsg, cb);
-    AssertReturn(lease != Lease::NullLease, VINF_SUCCESS);
-
-    int rc = ConfigurationManager::extractRequestList(pDhcpMsg, cb, opt);
-
-    /* 3. Send of offer */
-    NetworkManager *networkManager = NetworkManager::getNetworkManager();
-
-    lease.bindingPhase(true);
-    lease.phaseStart(RTTimeMilliTS());
-    lease.setExpiration(300); /* 3 min. */
-    networkManager->offer4Client(client, pDhcpMsg->bp_xid, opt.au8RawOpt, opt.cbRawOpt);
-
-    return VINF_SUCCESS;
-}
-
-
-/**
- * The client is requesting an offer.
- *
- * @returns true.
- *
- * @param   pDhcpMsg    The message.
- * @param   cb          The message size.
- */
-bool VBoxNetDhcp::handleDhcpReqRequest(PCRTNETBOOTP pDhcpMsg, size_t cb)
-{
-    ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager();
-    NetworkManager *networkManager = NetworkManager::getNetworkManager();
-
-    /* 1. find client */
-    Client client = confManager->getClientByDhcpPacket(pDhcpMsg, cb);
-
-    /* 2. find bound lease */
-    Lease l = client.lease();
-    if (l != Lease::NullLease)
-    {
-
-        if (l.isExpired())
-        {
-            /* send client to INIT state */
-            Client c(client);
-            networkManager->nak(client, pDhcpMsg->bp_xid);
-            confManager->expireLease4Client(c);
-            return true;
-        }
-        else {
-            /* XXX: Validate request */
-            RawOption opt;
-            RT_ZERO(opt);
-
-            Client c(client);
-            int rc = confManager->commitLease4Client(c);
-            AssertRCReturn(rc, false);
-
-            rc = ConfigurationManager::extractRequestList(pDhcpMsg, cb, opt);
-            AssertRCReturn(rc, false);
-
-            networkManager->ack(client, pDhcpMsg->bp_xid, opt.au8RawOpt, opt.cbRawOpt);
-        }
-    }
-    else
-    {
-        networkManager->nak(client, pDhcpMsg->bp_xid);
-    }
-    return true;
-}
-
-
-/**
- * The client is declining an offer we've made.
- *
- * @returns true.
- *
- * @param   pDhcpMsg    The message.
- * @param   cb          The message size.
- */
-bool VBoxNetDhcp::handleDhcpReqDecline(PCRTNETBOOTP, size_t)
-{
-    /** @todo Probably need to match the server IP here to work correctly with
-     *        other servers. */
-
-    /*
-     * The client is supposed to pass us option 50, requested address,
-     * from the offer. We also match the lease state. Apparently the
-     * MAC address is not supposed to be checked here.
-     */
-
-    /** @todo this is not required in the initial implementation, do it later. */
-    debugPrint(1, true, "DECLINE is not implemented");
-    return true;
-}
-
-
-/**
- * The client is releasing its lease - good boy.
- *
- * @returns true.
- *
- * @param   pDhcpMsg    The message.
- * @param   cb          The message size.
- */
-bool VBoxNetDhcp::handleDhcpReqRelease(PCRTNETBOOTP, size_t)
-{
-    /** @todo Probably need to match the server IP here to work correctly with
-     *        other servers. */
-
-    /*
-     * The client may pass us option 61, client identifier, which we should
-     * use to find the lease by.
-     *
-     * We're matching MAC address and lease state as well.
-     */
-
-    /*
-     * If no client identifier or if we couldn't find a lease by using it,
-     * we will try look it up by the client IP address.
-     */
-
-
-    /*
-     * If found, release it.
-     */
-
-
-    /** @todo this is not required in the initial implementation, do it later. */
-    debugPrint(1, true, "RELEASE is not implemented");
-    return true;
-}
-
 
 /**
