[vbox-dev] Patch to enable intnet and hifdev networking in VBoxBFE on Win32

Jan Schunk scpcom at web.de
Mon Jun 11 20:55:30 GMT 2007


Here are my patches to enable intnet and hifdev networking in VBoxBFE on Win32.
I use to enter the guid on command-line, eg. {1234ABCD-AB34-CD34-EF34-123456789ABC} it may also be possible to etrieve the GUID via some Win32 API.

--- e:\SOFTWARE\opsystem\vbox-build\VirtualBox-OSE-1.4.0\src\VBox\Frontends\VBoxBFE\VBoxBFE.cpp	Wed Jun 06 08:05:56 2007
+++ e:\SOFTWARE\opsystem\vbox-build\VirtualBox-OSE-trunk\src\VBox\Frontends\VBoxBFE\VBoxBFE.cpp	Mon Jun 11 22:40:08 2007
@@ -203,6 +203,9 @@
     bool        fHaveFd;    /**< Set if fd is valid. */
     int32_t     fd;         /**< The file descriptor of a HIF device.*/
 #endif
+#if defined(__WIN__)
+    char szGUID[39];    /**< The device GUID of a HIF device. */
+#endif
 } BFENETDEV, *PBFENETDEV;
 
 /** Array of network device configurations. */
@@ -298,7 +301,11 @@
              "  -[no]ioapic        Enable or disable the IO-APIC (default: disabled)\n"
              "  -audio             Enable audio\n"
              "  -natdev<1-N>       Configure NAT for network device N\n"
+#if defined(__WIN__)
+             "  -hifdev<1-N> <dev> <mac> <guid> Use existing Host Interface Network Device with the given name, MAC address and GUID\n"
+#else
              "  -hifdev<1-N> <dev> <mac> Use existing Host Interface Network Device with the given name and MAC address\n"
+#endif
 #if 0
              "  -netsniff<1-N>     Enable packet sniffer\n"
 #endif
@@ -552,6 +559,23 @@
                     return SyntaxError("Invalid MAC address: %s\n", argv[curArg]);
                 g_aNetDevs[i].Mac.au8[j] = ((c1 & 0x0f) << 4) | (c2 & 0x0f);
             }
+            
+#if defined(__WIN__)
+            /* The HIF device GUID. */
+            g_aNetDevs[i].szGUID[0] = 0;
+            if (    g_aNetDevs[i].enmType == BFENETDEV::HIF)
+            {
+                if (++curArg >= argc)
+                    return SyntaxError("The TAP network device GUID is missing! (%s)\n", pszArg);
+                if (strlen(argv[curArg]) != 38)
+                    return SyntaxError("The TAP network device GUID has an invalid length: %s (%s)\n", argv[curArg], pszArg);
+                const char *pszGUID = argv[curArg];
+                for (unsigned j = 0; j < 39; j++)
+                {                
+                    g_aNetDevs[i].szGUID[j] = *pszGUID++;
+                }
+            }
+#endif
         }
         else if (strncmp(pszArg, "-netsniff", 9) == 0)
         {
@@ -1543,7 +1567,7 @@
                      */
                     rc = CFGMR3InsertString(pCfg, "Device", g_aNetDevs[ulInstance].pszName);            UPDATE_RC();
                     rc = CFGMR3InsertString(pCfg, "HostInterfaceName", g_aNetDevs[ulInstance].pszName); UPDATE_RC();
-                    rc = CFGMR3InsertString(pCfg, "GUID", g_aNetDevs[ulInstance].pszName /*pszGUID*/);  UPDATE_RC();
+                    rc = CFGMR3InsertBytes(pCfg,  "GUID", &g_aNetDevs[ulInstance].szGUID[0], strlen(g_aNetDevs[ulInstance].szGUID)+1);          UPDATE_RC();
 
 
 #else /* !__LINUX__ && !__L4__ */
@@ -1557,6 +1581,9 @@
                 /*
                  * Internal networking.
                  */
+                rc = CFGMR3InsertString(pLunL0, "Driver", "IntNet");                UPDATE_RC();
+                rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg);                     UPDATE_RC();
+
                 rc = CFGMR3InsertString(pCfg, "Network", g_aNetDevs[ulInstance].pszName); UPDATE_RC();
             }
         }

License: MIT

_______________________________________________________________
SMS schreiben mit WEB.DE FreeMail - einfach, schnell und
kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192





More information about the vbox-dev mailing list