[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[patch] generalize loopback network interface name



Loopback network interface name is lo on GNU/Linux and lo0 on GNU/kFreeBSD.
This patch generalizes it with a macro.

Tested on GNU/kFreeBSD.
Could affect GNU/Linux (but it shouldn't).


Cheers,
Luca Favatella
Index: debian/changelog
===================================================================
--- debian/changelog	(.../trunk/packages/netcfg)	(revision 59616)
+++ debian/changelog	(.../branches/d-i/kfreebsd/packages/netcfg)	(revision 59625)
@@ -1,3 +1,11 @@
+netcfg (1.52) UNRELEASED; urgency=low
+
+  [ Aurelien Jarno ]
+  * Loopback network interface name is lo on GNU/Linux and lo0 on
+    GNU/kFreeBSD; generalize it with a macro.
+
+ -- Luca Favatella <slackydeb@gmail.com>  Thu, 23 Jul 2009 00:44:44 +0200
+
 netcfg (1.51) unstable; urgency=low
 
   [ Luca Favatella ]
Index: netcfg-common.c
===================================================================
--- netcfg-common.c	(.../trunk/packages/netcfg)	(revision 59616)
+++ netcfg-common.c	(.../branches/d-i/kfreebsd/packages/netcfg)	(revision 59625)
@@ -46,6 +46,12 @@
 
 #include <ifaddrs.h>
 
+#ifdef __FreeBSD_kernel__
+#define LO_IF	"lo0"
+#else
+#define LO_IF	"lo"
+#endif
+
 /* Set if there is currently a progress bar displayed. */
 int netcfg_progress_displayed = 0;
 
@@ -685,8 +691,8 @@
     if ((fp = file_open(INTERFACES_FILE, "w"))) {
         fprintf(fp, HELPFUL_COMMENT);
         fprintf(fp, "\n# The loopback network interface\n");
-        fprintf(fp, "auto lo\n");
-        fprintf(fp, "iface lo inet loopback\n");
+        fprintf(fp, "auto "LO_IF"\n");
+        fprintf(fp, "iface "LO_IF" inet loopback\n");
         fclose(fp);
     }
 }
@@ -707,8 +713,8 @@
     if ((fp = file_open(INTERFACES_FILE, "w"))) {
         fprintf(fp, HELPFUL_COMMENT);
         fprintf(fp, "\n# The loopback network interface\n");
-        fprintf(fp, "auto lo\n");
-        fprintf(fp, "iface lo inet loopback\n");
+        fprintf(fp, "auto "LO_IF"\n");
+        fprintf(fp, "iface "LO_IF" inet loopback\n");
         fclose(fp);
     }
     

Reply to: