-/* SmoothWall install program.\r
- *\r
- * This program is distributed under the terms of the GNU General Public\r
- * Licence. See the file COPYING for details.\r
- *\r
- * (c) Lawrence Manning, 2001\r
- * Contains stuff related to firing up the network card, including a crude\r
- * autodector.\r
- * \r
- * $Id: nic.c,v 1.8.2.2 2005/12/24 09:08:26 franck78 Exp $\r
- * \r
- */\r
-\r
-#include "install.h"\r
-\r
-#include <sys/socket.h>\r
-#include <netinet/in.h>\r
-#include <arpa/inet.h>\r
-\r
-extern FILE *flog;\r
-extern char *mylog;\r
-extern char **ctr;\r
-extern struct nic nics[];\r
-\r
-int networkmenu(struct keyvalue *ethernetkv)\r
-{\r
- int rc;\r
- char driver[STRING_SIZE] = "";\r
- char driveroptions[STRING_SIZE] = "";\r
- int result = 0;\r
- char commandstring[STRING_SIZE];\r
- char address[STRING_SIZE], netmask[STRING_SIZE];\r
- int done;\r
- char description[1000];\r
- char message[1000];\r
- char title[STRING_SIZE];\r
- done = 0;\r
-\r
- while (!done)\r
- {\r
- rc = newtWinTernary(ctr[TR_CONFIGURE_NETWORKING], ctr[TR_PROBE], \r
- ctr[TR_SELECT], ctr[TR_CANCEL], ctr[TR_CONFIGURE_NETWORKING_LONG]);\r
- \r
- if (rc == 0 || rc == 1)\r
- {\r
- probecards(driver, driveroptions);\r
- if (!strlen(driver))\r
- errorbox(ctr[TR_PROBE_FAILED]);\r
- else\r
- {\r
- findnicdescription(driver, description);\r
- sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);\r
- sprintf(message, ctr[TR_FOUND_NIC], NAME, description);\r
- newtWinMessage(title, ctr[TR_OK], message);\r
- } \r
- } \r
- else if (rc == 2)\r
- choosecards(driver, driveroptions);\r
- else\r
- done = 1; \r
- \r
- if (strlen(driver))\r
- done = 1;\r
- }\r
- \r
- if (!strlen(driver))\r
- goto EXIT;\r
-\r
- /* Default is a GREEN nic only. */\r
- /* Smoothie is not untarred yet, so we have to delay actually writing the\r
- * settings till later. */\r
- replacekeyvalue(ethernetkv, "CONFIG_TYPE", "0");\r
- replacekeyvalue(ethernetkv, "GREEN_DRIVER", driver);\r
- replacekeyvalue(ethernetkv, "GREEN_DRIVER_OPTIONS", driveroptions);\r
- replacekeyvalue(ethernetkv, "GREEN_DEV", "eth0");\r
- replacekeyvalue(ethernetkv, "GREEN_DISPLAYDRIVER", driver);\r
- \r
- if (!(changeaddress(ethernetkv, "GREEN", 0, "")))\r
- goto EXIT;\r
- \r
- strcpy(address, ""); findkey(ethernetkv, "GREEN_ADDRESS", address);\r
- strcpy(netmask, ""); findkey(ethernetkv, "GREEN_NETMASK", netmask);\r
-\r
- snprintf(commandstring, STRING_SIZE, "/bin/ifconfig eth0 %s netmask %s up", \r
- address, netmask);\r
- if (mysystem(commandstring))\r
- {\r
- errorbox(ctr[TR_INTERFACE_FAILED_TO_COME_UP]);\r
- goto EXIT;\r
- }\r
-\r
- result = 1;\r
- \r
-EXIT:\r
- \r
- return result;\r
-}\r
-\r
+/* SmoothWall install program.
+ *
+ * This program is distributed under the terms of the GNU General Public
+ * Licence. See the file COPYING for details.
+ *
+ * (c) Lawrence Manning, 2001
+ * Contains stuff related to firing up the network card, including a crude
+ * autodector.
+ *
+ */
+
+#include "install.h"
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+extern FILE *flog;
+extern char *mylog;
+
+extern char **ctr;
+
+extern struct nic nics[];
+
+int networkmenu(struct keyvalue *ethernetkv)
+{
+ int rc;
+ char driver[STRING_SIZE] = "";
+ char driveroptions[STRING_SIZE] = "";
+ int result = 0;
+ char commandstring[STRING_SIZE];
+ char address[STRING_SIZE], netmask[STRING_SIZE];
+ int done;
+ char description[1000];
+ char message[1000];
+ char title[STRING_SIZE];
+ done = 0;
+
+ while (!done)
+ {
+ rc = newtWinTernary(ctr[TR_CONFIGURE_NETWORKING], ctr[TR_PROBE],
+ ctr[TR_SELECT], ctr[TR_CANCEL], ctr[TR_CONFIGURE_NETWORKING_LONG]);
+
+ if (rc == 0 || rc == 1)
+ {
+ probecards(driver, driveroptions);
+ if (!strlen(driver))
+ errorbox(ctr[TR_PROBE_FAILED]);
+ else
+ {
+ findnicdescription(driver, description);
+ sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);
+ sprintf(message, ctr[TR_FOUND_NIC], NAME, description);
+ newtWinMessage(title, ctr[TR_OK], message);
+ }
+ }
+ else if (rc == 2)
+ choosecards(driver, driveroptions);
+ else
+ done = 1;
+
+ if (strlen(driver))
+ done = 1;
+ }
+
+ if (!strlen(driver))
+ goto EXIT;
+
+ /* Default is a GREEN nic only. */
+ /* Smoothie is not untarred yet, so we have to delay actually writing the
+ * settings till later. */
+ replacekeyvalue(ethernetkv, "CONFIG_TYPE", "0");
+ replacekeyvalue(ethernetkv, "GREEN_DRIVER", driver);
+ replacekeyvalue(ethernetkv, "GREEN_DRIVER_OPTIONS", driveroptions);
+ replacekeyvalue(ethernetkv, "GREEN_DEV", "eth0");
+ replacekeyvalue(ethernetkv, "GREEN_DISPLAYDRIVER", driver);
+
+ if (!(changeaddress(ethernetkv, "GREEN", 0, "")))
+ goto EXIT;
+
+ strcpy(address, ""); findkey(ethernetkv, "GREEN_ADDRESS", address);
+ strcpy(netmask, ""); findkey(ethernetkv, "GREEN_NETMASK", netmask);
+
+ snprintf(commandstring, STRING_SIZE, "/bin/ifconfig eth0 %s netmask %s up",
+ address, netmask);
+ if (mysystem(commandstring))
+ {
+ errorbox(ctr[TR_INTERFACE_FAILED_TO_COME_UP]);
+ goto EXIT;
+ }
+
+ result = 1;
+
+EXIT:
+
+ return result;
+}