X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=blobdiff_plain;f=src%2Finstall%2Bsetup%2Finstall%2Fnic.c;h=0c5c3d545e3e6ce02e2d037fe330ad81cdc541cc;hp=5ae74e56d70ded25c04e69524ef0cc874ac66708;hb=b4e381a8484404542ed6132b968ca11757e158b1;hpb=cd1a2927226c734d96478e12bb768256fb64a06a diff --git a/src/install+setup/install/nic.c b/src/install+setup/install/nic.c index 5ae74e56d7..0c5c3d545e 100644 --- a/src/install+setup/install/nic.c +++ b/src/install+setup/install/nic.c @@ -1,98 +1,97 @@ -/* 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. - * - * $Id: nic.c,v 1.8.2.2 2005/12/24 09:08:26 franck78 Exp $ - * - */ - -#include "install.h" - -#include -#include -#include - -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; -} - +/* 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 +#include +#include + +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; +}