network.patch

diff --git a/src/app/virtualbox/src/VBox/Devices/Network/DevE1000.cpp b/src/app/virtualbox/src/VBox/Devices/Network/DevE1000.cpp
index aa3eb87..fc2660a 100644
--- a/src/app/virtualbox/src/VBox/Devices/Network/DevE1000.cpp
+++ b/src/app/virtualbox/src/VBox/Devices/Network/DevE1000.cpp
@@ -7519,6 +7519,35 @@ static DECLCALLBACK(int) e1kR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGM
             pThis->fR0Enabled ? "enabled" : "disabled",
             pThis->fRCEnabled ? "enabled" : "disabled"));
 
+    /* For Genode attach already here to be able to overwrite mac address */
+    /* Network driver */
+    rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "Network Port");
+    if (RT_SUCCESS(rc))
+    {
+
+        /* Genode: read out the mac address from nic_session interface */      
+        PPDMINETWORKCONFIG  pDrvConfig = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMINETWORKCONFIG);
+        Assert(pDrvConfig && pDrvConfig->pfnGetMac);                           
+        pDrvConfig->pfnGetMac(pDrvConfig, &pThis->macConfigured);
+
+        if (rc == VINF_NAT_DNS)
+            PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "NoDNSforNAT",
+                                       N_("A Domain Name Server (DNS) for NAT networking could not be determined. Ensure that your host is correctly connected to an ISP. If you ignore this warning the guest will not be able to perform nameserver lookups and it will probably observe delays if trying so"));
+        pThis->pDrvR3 = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMINETWORKUP);
+        AssertMsgReturn(pThis->pDrvR3, ("Failed to obtain the PDMINETWORKUP interface!\n"), VERR_PDM_MISSING_INTERFACE_BELOW);
+
+        pThis->pDrvR0 = PDMIBASER0_QUERY_INTERFACE(PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBASER0), PDMINETWORKUP);
+        pThis->pDrvRC = PDMIBASERC_QUERY_INTERFACE(PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBASERC), PDMINETWORKUP);
+    }
+    else if (   rc == VERR_PDM_NO_ATTACHED_DRIVER
+             || rc == VERR_PDM_CFG_MISSING_DRIVER_NAME)
+    {
+        /* No error! */
+        E1kLog(("%s This adapter is not attached to any network!\n", pThis->szPrf));
+    }
+    else
+        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to attach the network LUN"));
+
     /* Initialize the EEPROM. */
     pThis->eeprom.init(pThis->macConfigured);
 
@@ -7677,28 +7706,6 @@ static DECLCALLBACK(int) e1kR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGM
         return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to attach the status LUN"));
     pThis->pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);
 
-    /* Network driver */
-    rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "Network Port");
-    if (RT_SUCCESS(rc))
-    {
-        if (rc == VINF_NAT_DNS)
-            PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "NoDNSforNAT",
-                                       N_("A Domain Name Server (DNS) for NAT networking could not be determined. Ensure that your host is correctly connected to an ISP. If you ignore this warning the guest will not be able to perform nameserver lookups and it will probably observe delays if trying so"));
-        pThis->pDrvR3 = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMINETWORKUP);
-        AssertMsgReturn(pThis->pDrvR3, ("Failed to obtain the PDMINETWORKUP interface!\n"), VERR_PDM_MISSING_INTERFACE_BELOW);
-
-        pThis->pDrvR0 = PDMIBASER0_QUERY_INTERFACE(PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBASER0), PDMINETWORKUP);
-        pThis->pDrvRC = PDMIBASERC_QUERY_INTERFACE(PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBASERC), PDMINETWORKUP);
-    }
-    else if (   rc == VERR_PDM_NO_ATTACHED_DRIVER
-             || rc == VERR_PDM_CFG_MISSING_DRIVER_NAME)
-    {
-        /* No error! */
-        E1kLog(("%s This adapter is not attached to any network!\n", pThis->szPrf));
-    }
-    else
-        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to attach the network LUN"));
-
     rc = RTSemEventCreate(&pThis->hEventMoreRxDescAvail);
     if (RT_FAILURE(rc))
         return rc;
diff --git a/src/app/virtualbox/src/VBox/Devices/Network/DevPCNet.cpp b/src/app/virtualbox/src/VBox/Devices/Network/DevPCNet.cpp
index 481267e..80f4af9 100644
--- a/src/app/virtualbox/src/VBox/Devices/Network/DevPCNet.cpp
+++ b/src/app/virtualbox/src/VBox/Devices/Network/DevPCNet.cpp
@@ -5056,6 +5056,11 @@ static DECLCALLBACK(int) pcnetConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGM
     rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "Network Port");
     if (RT_SUCCESS(rc))
     {
+        /* Genode: read out the mac address from nic_session interface */
+        PPDMINETWORKCONFIG  pDrvConfig = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMINETWORKCONFIG);
+        Assert(pDrvConfig && pDrvConfig->pfnGetMac);
+        pDrvConfig->pfnGetMac(pDrvConfig, &pThis->MacConfigured);
+
         if (rc == VINF_NAT_DNS)
         {
 #ifdef RT_OS_LINUX
