From: <ow...@us...> - 2008-08-11 06:54:46
|
Revision: 1667 http://ipcop.svn.sourceforge.net/ipcop/?rev=1667&view=rev Author: owes Date: 2008-08-11 06:54:56 +0000 (Mon, 11 Aug 2008) Log Message: ----------- Add menu for NIC that is not auto-detectable (ISA). Not fully completed yet. Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2008-08-11 06:04:52 UTC (rev 1666) +++ ipcop/trunk/src/installer/networking.c 2008-08-11 06:54:56 UTC (rev 1667) @@ -39,37 +39,35 @@ struct network_s { - char *module; /* kernel module */ - char *options; /* modprobe parameters */ - char *device; /* eth0, eth1 etc. */ - char *description; - char colour[10]; /* GREEN, RED, BLUE, ORANGE, ---- */ - char *address; /* MAC address */ + char *module; /* kernel module */ + char *options; /* modprobe parameters */ + char *device; /* eth0, eth1 etc. */ + char *description; + char colour[10]; /* GREEN, RED, BLUE, ORANGE, ---- */ + char *address; /* MAC address */ }; -struct isa_nic -{ - char *description; - char *module; -}; /* list of ISA (and others) cards that are not auto-detected */ -struct isa_nic *isa_nics; +#define ISA_MAX 256 // arbitrary value, should be more than sufficient + // to hold all non auto detectable cards +char *isa_nics_module[ISA_MAX]; +char *isa_nics_description[ISA_MAX]; static NODEKV *eth_kv; -static char kv_red_type[STRING_SIZE] = ""; /* extra variable for red type */ +static char kv_red_type[STRING_SIZE] = ""; /* extra variable for red type */ static int hardware_scanned = 0; static struct network_s *networks; /* make our own table for easier handling */ -static int changed_config; /* something has changed */ -static int changed_type; /* red type */ -static int changed_hostname; /* hostname (DHCP Red) */ -static int changed_green; /* IP and netmask green */ -static int changed_red; /* IP and netmask red */ -static int changed_blue; /* IP and netmask blue */ -static int changed_orange; /* IP and netmask orange */ -static int changed_dnsgateway; /* DNS1, DNS2 and gateway */ +static int changed_config; /* something has changed */ +static int changed_type; /* red type */ +static int changed_hostname; /* hostname (DHCP Red) */ +static int changed_green; /* IP and netmask green */ +static int changed_red; /* IP and netmask red */ +static int changed_blue; /* IP and netmask blue */ +static int changed_orange; /* IP and netmask orange */ +static int changed_dnsgateway; /* DNS1, DNS2 and gateway */ static char default_ip[STRING_SIZE] = "192.168.1.1"; static char default_netmask[STRING_SIZE] = "255.255.255.0"; @@ -77,1005 +75,993 @@ static char mac_buffer[STRING_SIZE]; -/* - get device MAC address -*/ -static char *get_mac(char *device) +/* Read list of ISA network cards */ +static void readisanics(void) { - FILE *f; + int i; + FILE *f; + char buffer[STRING_SIZE]; - snprintf(mac_buffer, STRING_SIZE, "/sys/class/net/%s/address", device); - f = fopen(mac_buffer, "r"); - if ( f != NULL ) - { - if ( fgets(mac_buffer, STRING_SIZE, f) ) - { - stripnl(mac_buffer); - return mac_buffer; + /* clean the list */ + for (i = 0; i < ISA_MAX; i++) { + if (isa_nics_module[i] != NULL) { + free(isa_nics_module[i]); + isa_nics_module[i] = NULL; + } + if (isa_nics_description[i] != NULL) { + free(isa_nics_description[i]); + isa_nics_description[i] = NULL; + } } + + if (!(f = fopen("/var/ipcop/ethernet/modules-list", "r"))) + return; + + /* Insert MANUAL at top */ + isa_nics_description[0] = strdup(gettext("TR_MANUAL")); + isa_nics_module[0] = strdup(""); + i = 1; + + while ((fgets(buffer, STRING_SIZE, f) != NULL) && (i < ISA_MAX)) { + char *ptr = strchr(buffer, ','); + + stripnl(buffer); + /* We expect at least 3 characters. + Simply skip lines containing comment character. + Also skip lines not containing comma. + */ + if ((strlen(buffer) < 3) || strchr(buffer, '#') || (ptr == NULL)) { + continue; + } + + isa_nics_description[i] = strdup(ptr + 1); + *ptr = 0; + isa_nics_module[i] = strdup(buffer); + i++; + } fclose(f); - } - return ""; + + /* Output the found list for testing purposes */ + fprintf(flog, "ISA list\n"); + for (i = 0; isa_nics_module[i] != NULL; i++) { + fprintf(flog, "%s, %s\n", isa_nics_module[i], isa_nics_description[i]); + } } -/* - Filter function for scanning directory /sys/class/net -*/ -static int filter_net(const struct dirent *d) +/* Get device MAC address */ +static char *getmac(char *device) { - int i; + FILE *f; - if ( !strcmp(d->d_name, "lo") || !strcmp(d->d_name, ".") || !strcmp(d->d_name, "..") ) - { - /* these are not really interesting */ - return 0; - } - - for (i = 0; i < numnetwork; i++) - { - if ( networks[i].device[0] && !strcmp(d->d_name, networks[i].device) ) - { - /* we've already got this one listed */ - return 0; + snprintf(mac_buffer, STRING_SIZE, "/sys/class/net/%s/address", device); + f = fopen(mac_buffer, "r"); + if (f != NULL) { + if (fgets(mac_buffer, STRING_SIZE, f)) { + stripnl(mac_buffer); + return mac_buffer; + } + fclose(f); } - } - /* not in our list (yet) */ - return 1; + return ""; } -/* - modprobe some module, then look for new net device +/* + Filter function for scanning directory /sys/class/net + Used by scandir in probe_card function. + Return 0 to skip a dir entry */ -static void probe_card(char *module, char *options) +static int filternet(const struct dirent *d) { - char command[STRING_SIZE]; - struct dirent **scndir; - int newcards; - int i, j; + int i; - /* owes: ToDo test if module already loaded ? */ + if (!strcmp(d->d_name, "lo") || !strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) { + /* these are not really interesting */ + return 0; + } - snprintf(command, STRING_SIZE, "/sbin/modprobe %s %s", module, options); - if ( mysystem(command) ) - { - /* errorbox ? */ - return; - } + for (i = 0; i < numnetwork; i++) { + if (networks[i].device[0] && !strcmp(d->d_name, networks[i].device)) { + /* we've already got this one listed */ + return 0; + } + } - /* new card found ? */ - newcards = scandir ("/sys/class/net", &scndir, filter_net, alphasort); - if ( newcards ) - { - fprintf(flog, "probed %s, found %d\n", module, newcards); + /* not in our list (yet) */ + return 1; +} - for (i = 0, j = 0; (i < numnetwork) && (j < newcards); i++) - { - if ( !networks[i].device[0] && !strcmp(module, networks[i].module) ) - { - free(networks[i].device); - networks[i].device = strdup(scndir[j]->d_name); - /* get and store MAC address */ - networks[i].address = get_mac(networks[i].device); - j++; - fprintf(flog, " hwlist %s device %s MAC %s\n", module, networks[i].device, networks[i].address); - } + +/* Modprobe some module, then look for new net device */ +static void probecard(char *module, char *options) +{ + char command[STRING_SIZE]; + struct dirent **scndir; + int newcards; + int i, j; + + /* owes: ToDo test if module already loaded ? */ + + snprintf(command, STRING_SIZE, "/sbin/modprobe %s %s", module, options); + if (mysystem(command)) { + /* errorbox ? */ + return; } - if ( j < newcards ) - { - fprintf(flog, " some stray modprobe?\n"); + /* new card found ? */ + newcards = scandir("/sys/class/net", &scndir, filternet, alphasort); + if (newcards) { + fprintf(flog, "probed %s, found %d\n", module, newcards); + + for (i = 0, j = 0; (i < numnetwork) && (j < newcards); i++) { + if (!networks[i].device[0] && !strcmp(module, networks[i].module)) { + free(networks[i].device); + networks[i].device = strdup(scndir[j]->d_name); + /* get and store MAC address */ + networks[i].address = getmac(networks[i].device); + j++; + fprintf(flog, " hwlist %s device %s MAC %s\n", module, networks[i].device, networks[i].address); + } + } + + if (j < newcards) { + fprintf(flog, " some stray modprobe?\n"); + } } - } } -/* - Use discover to find hardware, build list with detected network cards -*/ -static void scan_cards(void) +/* Use discover to find hardware, build list with detected network cards */ +static void scancards(void) { - int i; + int i; - if ( hardware_scanned ) - { - return; - } - hardware_scanned = 1; + if (hardware_scanned) { + return; + } + hardware_scanned = 1; - /* scan for NICs, disable SCSI */ - scan_hardware(0, 0, 0, 1); - numnetwork = 0; + /* scan for NICs, disable SCSI */ + scan_hardware(0, 0, 0, 1); + numnetwork = 0; - /* setup our own table */ - for (i = 0; i < numhardwares; i++) - { - if ( hardwares[i].type == network ) - { - networks = realloc(networks, sizeof(struct network_s) * (numnetwork + 1)); - networks[numnetwork].module = hardwares[i].module; - networks[numnetwork].options = strdup(""); - networks[numnetwork].device = strdup(""); - networks[numnetwork].description = hardwares[i].description; - strcpy(networks[numnetwork].colour, "----"); - networks[numnetwork].address = strdup(""); + /* setup our own table */ + for (i = 0; i < numhardwares; i++) { + if (hardwares[i].type == network) { + networks = realloc(networks, sizeof(struct network_s) * (numnetwork + 1)); + networks[numnetwork].module = hardwares[i].module; + networks[numnetwork].options = strdup(""); + networks[numnetwork].device = strdup(""); + networks[numnetwork].description = hardwares[i].description; + strcpy(networks[numnetwork].colour, "----"); + networks[numnetwork].address = strdup(""); - numnetwork++; + numnetwork++; + } } - } - if ( !flag_installer ) - { - /* - special case, we already have module(s) and card(s) - match ethernet/settings to hwlist + if (!flag_installer) { + /* + special case, we already have module(s) and card(s) + match ethernet/settings to hwlist - owes: this may need some more intelligence to cover situations where NICs where added/removed etc. - */ - int c, j, n; - char key[STRING_SIZE]; + owes: this may need some more intelligence to cover situations where NICs where added/removed etc. + */ + int c, j, n; + char key[STRING_SIZE]; - for (i = 0; i < CFG_COLOURS_COUNT-1; i++) - { - snprintf(key, STRING_SIZE, "%s_COUNT", ipcop_colours_text[i]); - c = atoi(find_kv(eth_kv, key)); + for (i = 0; i < CFG_COLOURS_COUNT - 1; i++) { + snprintf(key, STRING_SIZE, "%s_COUNT", ipcop_colours_text[i]); + c = atoi(find_kv(eth_kv, key)); - for (j = 1; j <= c; j++) - { - snprintf(key, STRING_SIZE, "%s_%d_DRIVER", ipcop_colours_text[i], j); + for (j = 1; j <= c; j++) { + snprintf(key, STRING_SIZE, "%s_%d_DRIVER", ipcop_colours_text[i], j); - for (n = 0; n < numnetwork; n++) - { - if ( !networks[n].device[0] && (find_kv(eth_kv, key) != NULL) && !strcmp(networks[n].module, find_kv(eth_kv, key)) ) - { - /* 3,2,1 meins */ - strcpy(networks[n].colour, ipcop_colours_text[i]); - snprintf(key, STRING_SIZE, "%s_%d_DEV", ipcop_colours_text[i], j); - networks[n].device = strdup(find_kv(eth_kv, key)); + for (n = 0; n < numnetwork; n++) { + if (!networks[n].device[0] && (find_kv(eth_kv, key) != NULL) + && !strcmp(networks[n].module, find_kv(eth_kv, key))) { + /* 3,2,1 meins */ + strcpy(networks[n].colour, ipcop_colours_text[i]); + snprintf(key, STRING_SIZE, "%s_%d_DEV", ipcop_colours_text[i], j); + networks[n].device = strdup(find_kv(eth_kv, key)); - /* owes: copy driver options here */ + /* owes: copy driver options here */ - /* find MAC address */ - networks[n].address = strdup(get_mac(networks[n].device)); - } + /* find MAC address */ + networks[n].address = strdup(getmac(networks[n].device)); + } + } + } } - } } - } - for (i = 0; i < numnetwork; i++) - { - if ( !networks[i].device[0] ) - { - probe_card(networks[i].module, ""); + for (i = 0; i < numnetwork; i++) { + if (!networks[i].device[0]) { + probecard(networks[i].module, ""); + } } - } } /* - Verify IP address and netmask + Verify IP address and netmask + Used by newt for IP entry fields. + Return 0 if the character is invalid. */ -static int filter_ip(newtComponent entry, void * data, int ch, int cursor) +static int filterip(newtComponent entry, void *data, int ch, int cursor) { - if ( ((ch >= '0') && (ch <= '9')) || (ch == '.') || (ch == '\r') || (ch >= NEWT_KEY_EXTRA_BASE) ) - return ch; - return 0; + if (((ch >= '0') && (ch <= '9')) || (ch == '.') || (ch == '\r') || (ch >= NEWT_KEY_EXTRA_BASE)) + return ch; + return 0; } -/* - Choose type of internet connection: analog modem, isdn, PPPoE, PPtP, dhcp (ethernet), static (ethernet) -*/ +/* Choose type of internet connection: analog modem, isdn, PPPoE, PPtP, dhcp (ethernet), static (ethernet) */ static void redconfigtype(void) { - int i; - newtComponent networkform; - newtComponent text; - newtComponent ok, cancel; - struct newtExitStruct exitstruct; - char keyvalue[STRING_SIZE]; - char message[STRING_SIZE_LARGE]; - int numLines; + int i; + newtComponent networkform; + newtComponent text; + newtComponent ok, cancel; + struct newtExitStruct exitstruct; + char keyvalue[STRING_SIZE]; + char message[STRING_SIZE_LARGE]; + int numLines; - snprintf(message, STRING_SIZE, gettext("TR_RED_CONFIGURATION_TYPE_LONG")); - text = newtTextboxReflowed(1, 1, message, 68, 0, 0, 0); - numLines = newtTextboxGetNumLines(text); + snprintf(message, STRING_SIZE, gettext("TR_RED_CONFIGURATION_TYPE_LONG")); + text = newtTextboxReflowed(1, 1, message, 68, 0, 0, 0); + numLines = newtTextboxGetNumLines(text); - snprintf(message, STRING_SIZE, gettext("TR_INTERFACE"), "RED"); - newtCenteredWindow(72, 14+numLines, message); - networkform = newtForm(NULL, NULL, 0); - newtFormAddComponent(networkform, text); + snprintf(message, STRING_SIZE, gettext("TR_INTERFACE"), "RED"); + newtCenteredWindow(72, 14 + numLines, message); + networkform = newtForm(NULL, NULL, 0); + newtFormAddComponent(networkform, text); - /* No point in translating all */ - char *radio_text[CFG_RED_COUNT] = { gettext("TR_ANALOG_MODEM"), "ISDN", "PPPOE", "PPTP", gettext("TR_STATIC"), "DHCP" }; - newtComponent radio[CFG_RED_COUNT]; + /* No point in translating all */ + char *radio_text[CFG_RED_COUNT] = + { gettext("TR_ANALOG_MODEM"), "ISDN", "PPPOE", "PPTP", gettext("TR_STATIC"), "DHCP" }; + newtComponent radio[CFG_RED_COUNT]; - /* default value is PPPoE if nothing found in cfg file */ - strcpy(keyvalue, "PPPOE"); - if ( find_kv_default(eth_kv, "RED_1_TYPE", keyvalue) == 0 ) - { - update_kv(ð_kv, "RED_1_TYPE", "PPPOE"); - /* keep RED_TYPE for now */ - update_kv(ð_kv, "RED_TYPE", "PPPOE"); - changed_config = 1; - } - /* build radio buttons and add to window */ - for (i = 0; i < CFG_RED_COUNT ; i++) - { - radio[i] = newtRadiobutton(2, i+numLines+2, radio_text[i], (strcmp(keyvalue, ipcop_red_text[i]) == 0), i == 0 ? NULL : radio[i-1]); - newtFormAddComponents(networkform, radio[i], NULL); - } + /* default value is PPPoE if nothing found in cfg file */ + strcpy(keyvalue, "PPPOE"); + if (find_kv_default(eth_kv, "RED_1_TYPE", keyvalue) == 0) { + update_kv(ð_kv, "RED_1_TYPE", "PPPOE"); + /* keep RED_TYPE for now */ + update_kv(ð_kv, "RED_TYPE", "PPPOE"); + changed_config = 1; + } + /* build radio buttons and add to window */ + for (i = 0; i < CFG_RED_COUNT; i++) { + radio[i] = + newtRadiobutton(2, i + numLines + 2, radio_text[i], (strcmp(keyvalue, ipcop_red_text[i]) == 0), + i == 0 ? NULL : radio[i - 1]); + newtFormAddComponents(networkform, radio[i], NULL); + } - ok = newtButton(6, 9+numLines, gettext("TR_OK")); - cancel = newtButton(26, 9+numLines, gettext("TR_CANCEL")); - newtFormAddComponents(networkform, ok, cancel, NULL); + ok = newtButton(6, 9 + numLines, gettext("TR_OK")); + cancel = newtButton(26, 9 + numLines, gettext("TR_CANCEL")); + newtFormAddComponents(networkform, ok, cancel, NULL); - newtRefresh(); - newtDrawForm(networkform); + newtRefresh(); + newtDrawForm(networkform); - newtFormRun(networkform, &exitstruct); + newtFormRun(networkform, &exitstruct); - if ( exitstruct.u.co == ok ) - { - newtComponent selected = newtRadioGetCurrent(radio[1]); - for (i = 0; i < CFG_RED_COUNT ; i++) - { - if ( (selected == radio[i]) && strcmp(keyvalue, ipcop_red_text[i]) ) - { - /* config type has changed, update cfg file and set flag */ - update_kv(ð_kv, "RED_1_TYPE", ipcop_red_text[i]); - strcpy(kv_red_type, ipcop_red_text[i]); - /* keep RED_TYPE for now */ - update_kv(ð_kv, "RED_TYPE", ipcop_red_text[i]); + if (exitstruct.u.co == ok) { + newtComponent selected = newtRadioGetCurrent(radio[1]); + for (i = 0; i < CFG_RED_COUNT; i++) { + if ((selected == radio[i]) && strcmp(keyvalue, ipcop_red_text[i])) { + /* config type has changed, update cfg file and set flag */ + update_kv(ð_kv, "RED_1_TYPE", ipcop_red_text[i]); + strcpy(kv_red_type, ipcop_red_text[i]); + /* keep RED_TYPE for now */ + update_kv(ð_kv, "RED_TYPE", ipcop_red_text[i]); - if ( !strcmp(ipcop_red_text[i], "ANALOG") || !strcmp(ipcop_red_text[i], "ISDN") ) - { - update_kv(ð_kv, "RED_1_DEV", ""); - update_kv(ð_kv, "RED_COUNT", "0"); + if (!strcmp(ipcop_red_text[i], "ANALOG") || !strcmp(ipcop_red_text[i], "ISDN")) { + update_kv(ð_kv, "RED_1_DEV", ""); + update_kv(ð_kv, "RED_COUNT", "0"); - /* keep CONFIG_TYPE for now */ - update_kv(ð_kv, "CONFIG_TYPE", "0"); - } - else - { - update_kv(ð_kv, "RED_COUNT", "1"); + /* keep CONFIG_TYPE for now */ + update_kv(ð_kv, "CONFIG_TYPE", "0"); + } + else { + update_kv(ð_kv, "RED_COUNT", "1"); - /* keep CONFIG_TYPE for now */ - update_kv(ð_kv, "CONFIG_TYPE", "2"); + /* keep CONFIG_TYPE for now */ + update_kv(ð_kv, "CONFIG_TYPE", "2"); + } + changed_config = 1; + changed_type = 1; + break; + } } - changed_config = 1; - changed_type = 1; - break; - } } - } - newtFormDestroy(networkform); - newtPopWindow(); + newtFormDestroy(networkform); + newtPopWindow(); } -/* - Update some settings -*/ -static void update_settings(char *colour, int n) +/* Update some settings */ +static void updatesettings(char *colour, int n) { - char key[STRING_SIZE]; + char key[STRING_SIZE]; - fprintf(flog, "colour %s, index %d\n", colour, n); + fprintf(flog, "colour %s, index %d\n", colour, n); - if ( n == -1 ) - { - /* was occupied, now empty */ - snprintf(key, STRING_SIZE, "%s_1_DEV", colour); - update_kv(ð_kv, key, ""); - snprintf(key, STRING_SIZE, "%s_1_DRIVER", colour); - update_kv(ð_kv, key, ""); - snprintf(key, STRING_SIZE, "%s_COUNT", colour); - update_kv(ð_kv, key, "0"); + if (n == -1) { + /* was occupied, now empty */ + snprintf(key, STRING_SIZE, "%s_1_DEV", colour); + update_kv(ð_kv, key, ""); + snprintf(key, STRING_SIZE, "%s_1_DRIVER", colour); + update_kv(ð_kv, key, ""); + snprintf(key, STRING_SIZE, "%s_COUNT", colour); + update_kv(ð_kv, key, "0"); - /* owes: old format keep until change completed */ - snprintf(key, STRING_SIZE, "%s_DEV", colour); - update_kv(ð_kv, key, ""); - snprintf(key, STRING_SIZE, "%s_DRIVER", colour); - update_kv(ð_kv, key, ""); - } - else - { - snprintf(key, STRING_SIZE, "%s_1_DEV", colour); - update_kv(ð_kv, key, networks[n].device); - snprintf(key, STRING_SIZE, "%s_1_DRIVER", colour); - update_kv(ð_kv, key, networks[n].module); - snprintf(key, STRING_SIZE, "%s_COUNT", colour); - update_kv(ð_kv, key, "1"); + /* owes: old format keep until change completed */ + snprintf(key, STRING_SIZE, "%s_DEV", colour); + update_kv(ð_kv, key, ""); + snprintf(key, STRING_SIZE, "%s_DRIVER", colour); + update_kv(ð_kv, key, ""); + } + else { + snprintf(key, STRING_SIZE, "%s_1_DEV", colour); + update_kv(ð_kv, key, networks[n].device); + snprintf(key, STRING_SIZE, "%s_1_DRIVER", colour); + update_kv(ð_kv, key, networks[n].module); + snprintf(key, STRING_SIZE, "%s_COUNT", colour); + update_kv(ð_kv, key, "1"); - /* owes: old format keep until change completed */ - snprintf(key, STRING_SIZE, "%s_DEV", colour); - update_kv(ð_kv, key, networks[n].device); - snprintf(key, STRING_SIZE, "%s_DRIVER", colour); - update_kv(ð_kv, key, networks[n].module); - } + /* owes: old format keep until change completed */ + snprintf(key, STRING_SIZE, "%s_DEV", colour); + update_kv(ð_kv, key, networks[n].device); + snprintf(key, STRING_SIZE, "%s_DRIVER", colour); + update_kv(ð_kv, key, networks[n].module); + } } -/* - Assign 1 card to some colour -*/ +/* Assign 1 card to some colour */ static void cardconfig(int n) { - char info[STRING_SIZE_LARGE]; - int i, j; - int rc, choice; - char *colourchoices[10]; - char command[STRING_SIZE]; + char info[STRING_SIZE_LARGE]; + int i, j; + int rc, choice; + char *colourchoices[10]; + char command[STRING_SIZE]; - /* owes: ToDo could do with some fancy text here */ - snprintf(info, STRING_SIZE_LARGE, "%s\nMAC Address: %s Device: %s\nCurrently assigned to: %s", - networks[n].description, networks[n].address, networks[n].device, networks[n].colour); + /* owes: ToDo could do with some fancy text here */ + snprintf(info, STRING_SIZE_LARGE, "%s\nMAC Address: %s Device: %s\nCurrently assigned to: %s", + networks[n].description, networks[n].address, networks[n].device, networks[n].colour); - for (choice = 0, i = 0; i < CFG_COLOURS_COUNT-1; i++) - { - int used = 0; - - /* skip RED if type is ANALOG or ISDN */ - if ( !strcmp(ipcop_colours_text[i], "RED") && (!strcmp(kv_red_type, "ANALOG") || !strcmp(kv_red_type, "ISDN")) ) - { - continue; - } + for (choice = 0, i = 0; i < CFG_COLOURS_COUNT - 1; i++) { + int used = 0; - /* test for already used colours here */ - for (j = 0; j < numnetwork && !used; j++) - { + /* skip RED if type is ANALOG or ISDN */ + if (!strcmp(ipcop_colours_text[i], "RED") && (!strcmp(kv_red_type, "ANALOG") || !strcmp(kv_red_type, "ISDN"))) { + continue; + } - if ( !strcmp(ipcop_colours_text[i], networks[j].colour) ) - { - used = 1; - } - } + /* test for already used colours here */ + for (j = 0; j < numnetwork && !used; j++) { - if ( !used ) - { - colourchoices[choice++] = ipcop_colours_text[i]; + if (!strcmp(ipcop_colours_text[i], networks[j].colour)) { + used = 1; + } + } + + if (!used) { + colourchoices[choice++] = ipcop_colours_text[i]; + } } - } - colourchoices[choice++] = gettext("TR_NOT_USED"); - colourchoices[choice++] = NULL; + colourchoices[choice++] = gettext("TR_NOT_USED"); + colourchoices[choice++] = NULL; - /* make the card blink during selection if supported */ - snprintf(command, STRING_SIZE, "/sbin/ifconfig %s up", networks[n].device); - mysystem(command); - snprintf(command, STRING_SIZE, "/usr/sbin/ethtool -p %s &", networks[n].device); - mysystem(command); + /* make the card blink during selection if supported */ + snprintf(command, STRING_SIZE, "/sbin/ifconfig %s up", networks[n].device); + mysystem(command); + snprintf(command, STRING_SIZE, "/usr/sbin/ethtool -p %s &", networks[n].device); + mysystem(command); - choice = 0; - rc = newtWinMenu(gettext("TR_CARD_ASSIGNMENT"), - info, 65, 5, 5, 11, - colourchoices, &choice, gettext("TR_OK"), gettext("TR_QUIT"), NULL); + choice = 0; + rc = newtWinMenu(gettext("TR_CARD_ASSIGNMENT"), + info, 65, 5, 5, 11, colourchoices, &choice, gettext("TR_OK"), gettext("TR_QUIT"), NULL); - if ( (rc == 0) || (rc == 1) ) - { - if ( !strcmp(colourchoices[choice], gettext("TR_NOT_USED")) ) - { - if ( strcmp(networks[n].colour, ipcop_colours_text[CFG_COLOURS_COUNT-1]) ) - { - update_settings(networks[n].colour, -1); - } - strcpy(networks[n].colour, ipcop_colours_text[CFG_COLOURS_COUNT-1]); + if ((rc == 0) || (rc == 1)) { + if (!strcmp(colourchoices[choice], gettext("TR_NOT_USED"))) { + if (strcmp(networks[n].colour, ipcop_colours_text[CFG_COLOURS_COUNT - 1])) { + updatesettings(networks[n].colour, -1); + } + strcpy(networks[n].colour, ipcop_colours_text[CFG_COLOURS_COUNT - 1]); + } + else { + if (strcmp(networks[n].colour, ipcop_colours_text[CFG_COLOURS_COUNT - 1])) { + updatesettings(networks[n].colour, -1); + } + strcpy(networks[n].colour, colourchoices[choice]); + updatesettings(networks[n].colour, n); + } } - else - { - if ( strcmp(networks[n].colour, ipcop_colours_text[CFG_COLOURS_COUNT-1]) ) - { - update_settings(networks[n].colour, -1); - } - strcpy(networks[n].colour, colourchoices[choice]); - update_settings(networks[n].colour, n); - } - } - strcpy(command, "/bin/killall ethtool"); - mysystem(command); + strcpy(command, "/bin/killall ethtool"); + mysystem(command); } -/* - Detect cards, list cards and assign colours to them. -*/ +/* Add a card manually from the ISA nic list */ +static void addcardmanual(void) +{ + int done; + int rc; + int choice; + + choice = 0; + done = 0; + while (done == 0) { + rc = newtWinMenu(gettext("TR_SELECT_NETWORK_DRIVER"), + gettext("TR_SELECT_NETWORK_DRIVER_LONG"), 65, 5, 5, 11, + isa_nics_description, &choice, gettext("TR_OK"), gettext("TR_CANCEL"), NULL); + + if ((rc == 0) || (rc == 1)) { + if (choice == 0) { + newtWinMessage(gettext("TR_CARD_ASSIGNMENT"), gettext("TR_OK"), "Sorry, not implemented yet."); + } + else { + /* + OWES: modprobe module here, add to list of cards in case of success + probably want to return in case of success + continue with the list in case of failure + */ + } + } + else { + done = 1; + } + } +} + + +/* Detect cards, list cards and assign colours to them. */ static void cardlist(void) { - int i, count; - int rc, choice; - char *cardchoices[10]; + int i, count; + int rc, choice; + char *cardchoices[10]; - scan_cards(); + scancards(); - for (;;) - { - choice = -1; - for (count = 0, i = 0; i < numnetwork; i++) - { - char line[STRING_SIZE]; + for (;;) { + choice = -1; + for (count = 0, i = 0; i < numnetwork; i++) { + char line[STRING_SIZE]; - /* set first unused card as default choice */ - if ( (choice == -1) && !strcmp(networks[i].colour, "----") ) - { - choice = count; - } - snprintf(line, STRING_SIZE, "%-60.60s (%s)", networks[i].description, networks[i].colour); - cardchoices[count++] = strdup(line); - } - cardchoices[count] = NULL; + /* set first unused card as default choice */ + if ((choice == -1) && !strcmp(networks[i].colour, "----")) { + choice = count; + } + snprintf(line, STRING_SIZE, "%-60.60s (%s)", networks[i].description, networks[i].colour); + cardchoices[count++] = strdup(line); + } + cardchoices[count] = NULL; - rc = newtWinMenu(gettext("TR_CARD_ASSIGNMENT"), - gettext("TR_CARD_ASSIGNMENT_LONG"), 65, 5, 5, 11, - cardchoices, &choice, gettext("TR_OK"), gettext("TR_MANUAL"), gettext("TR_QUIT"), NULL); + rc = newtWinMenu(gettext("TR_CARD_ASSIGNMENT"), + gettext("TR_CARD_ASSIGNMENT_LONG"), 65, 5, 5, 11, + cardchoices, &choice, gettext("TR_OK"), gettext("TR_MANUAL"), gettext("TR_QUIT"), NULL); - for (i = 0; i < numnetwork; i++) - { - free(cardchoices[i]); - } + for (i = 0; i < numnetwork; i++) { + free(cardchoices[i]); + } - switch ( rc ) - { - case 0: - case 1: - cardconfig(choice); - break; - case 2: - newtWinMessage(ipcop_gettext("TR_CARD_ASSIGNMENT"), ipcop_gettext("TR_OK"), "Sorry, not implemented yet."); - /* manually add some card/module */ - break; - case 3: - /* owes: ToDo test if we have green and possibly red here */ - return; + switch (rc) { + case 0: + case 1: + cardconfig(choice); + break; + case 2: + addcardmanual(); + break; + case 3: + /* owes: ToDo test if we have green and possibly red here */ + return; + } } - } } -/* - Change red hostname, used if type is DHCP -*/ +/* Change red hostname, used if type is DHCP */ static void changehostname(void) { - newtComponent networkform; - newtComponent text; - newtComponent ok, cancel; - struct newtExitStruct exitstruct; - char keyvalue[STRING_SIZE]; - char message[STRING_SIZE_LARGE]; - newtComponent dhcphostnamelabel; - newtComponent dhcphostnameentry; - const char *dhcphostnameresult; - int error; - int numLines; + newtComponent networkform; + newtComponent text; + newtComponent ok, cancel; + struct newtExitStruct exitstruct; + char keyvalue[STRING_SIZE]; + char message[STRING_SIZE_LARGE]; + newtComponent dhcphostnamelabel; + newtComponent dhcphostnameentry; + const char *dhcphostnameresult; + int error; + int numLines; - snprintf(message, STRING_SIZE_LARGE, gettext("TR_DHCP_HOSTNAME_LONG")); - text = newtTextboxReflowed(1, 1, message, 68, 0, 0, 0); - numLines = newtTextboxGetNumLines(text); + snprintf(message, STRING_SIZE_LARGE, gettext("TR_DHCP_HOSTNAME_LONG")); + text = newtTextboxReflowed(1, 1, message, 68, 0, 0, 0); + numLines = newtTextboxGetNumLines(text); - snprintf(message, STRING_SIZE, gettext("TR_INTERFACE"), "RED"); - newtCenteredWindow(72, 9+numLines, message); - networkform = newtForm(NULL, NULL, 0); - newtFormAddComponent(networkform, text); + snprintf(message, STRING_SIZE, gettext("TR_INTERFACE"), "RED"); + newtCenteredWindow(72, 9 + numLines, message); + networkform = newtForm(NULL, NULL, 0); + newtFormAddComponent(networkform, text); - /* DHCP hostname */ - dhcphostnamelabel = newtTextbox(2, 2+numLines, 18, 1, 0); - newtTextboxSetText(dhcphostnamelabel, gettext("TR_DHCP_HOSTNAME")); - strcpy(keyvalue, ""); - if ( find_kv_default(eth_kv, "RED_DHCP_HOSTNAME", keyvalue) == 0 ) - { - NODEKV *main_kv = NULL; - if ( read_kv_from_file(&main_kv, CONFIG_ROOT "/main/settings") ) - { - find_kv_default(main_kv, "HOSTNAME", keyvalue); - free_kv(&main_kv); + /* DHCP hostname */ + dhcphostnamelabel = newtTextbox(2, 2 + numLines, 18, 1, 0); + newtTextboxSetText(dhcphostnamelabel, gettext("TR_DHCP_HOSTNAME")); + strcpy(keyvalue, ""); + if (find_kv_default(eth_kv, "RED_DHCP_HOSTNAME", keyvalue) == 0) { + NODEKV *main_kv = NULL; + if (read_kv_from_file(&main_kv, "/var/ipcop/main/settings")) { + find_kv_default(main_kv, "HOSTNAME", keyvalue); + free_kv(&main_kv); + } } - } - dhcphostnameentry = newtEntry(20, 2+numLines, keyvalue, 20, &dhcphostnameresult, 0); - newtFormAddComponent(networkform, dhcphostnamelabel); - newtFormAddComponent(networkform, dhcphostnameentry); + dhcphostnameentry = newtEntry(20, 2 + numLines, keyvalue, 20, &dhcphostnameresult, 0); + newtFormAddComponent(networkform, dhcphostnamelabel); + newtFormAddComponent(networkform, dhcphostnameentry); - ok = newtButton(6, 4+numLines, gettext("TR_OK")); - cancel = newtButton(26, 4+numLines, gettext("TR_CANCEL")); - newtFormAddComponents(networkform, ok, cancel, NULL); + ok = newtButton(6, 4 + numLines, gettext("TR_OK")); + cancel = newtButton(26, 4 + numLines, gettext("TR_CANCEL")); + newtFormAddComponents(networkform, ok, cancel, NULL); - newtRefresh(); - newtDrawForm(networkform); + newtRefresh(); + newtDrawForm(networkform); - do - { - error = 0; - newtFormRun(networkform, &exitstruct); + do { + error = 0; + newtFormRun(networkform, &exitstruct); - if ( exitstruct.u.co == ok ) - { - if ( !strlen(dhcphostnameresult) ) - { - errorbox(gettext("TR_DHCP_HOSTNAME_CR")); - error = 1; - } - else - { - update_kv(ð_kv, "RED_DHCP_HOSTNAME", (char *)dhcphostnameresult); - changed_config = 1; - changed_hostname = 1; - } + if (exitstruct.u.co == ok) { + if (!strlen(dhcphostnameresult)) { + errorbox(gettext("TR_DHCP_HOSTNAME_CR")); + error = 1; + } + else { + update_kv(ð_kv, "RED_DHCP_HOSTNAME", (char *) dhcphostnameresult); + changed_config = 1; + changed_hostname = 1; + } + } } - } - while ( error ); + while (error); - newtFormDestroy(networkform); - newtPopWindow(); + newtFormDestroy(networkform); + newtPopWindow(); } -/* - Small window to change IP and Netmask of some colour -*/ +/* Small window to change IP and Netmask of some colour */ static void changeaddress(char *colour, int *changed_flag) { - newtComponent networkform; - newtComponent text; - newtComponent ok, cancel; - struct newtExitStruct exitstruct; - char keyvalue[STRING_SIZE]; - char addresskey[STRING_SIZE]; - char netmaskkey[STRING_SIZE]; - char netaddresskey[STRING_SIZE]; - char broadcastkey[STRING_SIZE]; - newtComponent addresslabel; - newtComponent netmasklabel; - newtComponent addressentry; - newtComponent netmaskentry; - const char *addressresult; - const char *netmaskresult; - char message[STRING_SIZE_LARGE]; - int error; - int numLines; + newtComponent networkform; + newtComponent text; + newtComponent ok, cancel; + struct newtExitStruct exitstruct; + char keyvalue[STRING_SIZE]; + char addresskey[STRING_SIZE]; + char netmaskkey[STRING_SIZE]; + char netaddresskey[STRING_SIZE]; + char broadcastkey[STRING_SIZE]; + newtComponent addresslabel; + newtComponent netmasklabel; + newtComponent addressentry; + newtComponent netmaskentry; + const char *addressresult; + const char *netmaskresult; + char message[STRING_SIZE_LARGE]; + int error; + int numLines; - char old_addresskey[STRING_SIZE]; - char old_netmaskkey[STRING_SIZE]; - char old_netaddresskey[STRING_SIZE]; - char old_broadcastkey[STRING_SIZE]; + char old_addresskey[STRING_SIZE]; + char old_netmaskkey[STRING_SIZE]; + char old_netaddresskey[STRING_SIZE]; + char old_broadcastkey[STRING_SIZE]; - /* Build some key strings. */ - sprintf(addresskey, "%s_1_ADDRESS", colour); - sprintf(netmaskkey, "%s_1_NETMASK", colour); - sprintf(netaddresskey, "%s_1_NETADDRESS", colour); - sprintf(broadcastkey, "%s_1_BROADCAST", colour); + /* Build some key strings. */ + sprintf(addresskey, "%s_1_ADDRESS", colour); + sprintf(netmaskkey, "%s_1_NETMASK", colour); + sprintf(netaddresskey, "%s_1_NETADDRESS", colour); + sprintf(broadcastkey, "%s_1_BROADCAST", colour); - /* owes: old format keep until change completed */ - sprintf(old_addresskey, "%s_ADDRESS", colour); - sprintf(old_netmaskkey, "%s_NETMASK", colour); - sprintf(old_netaddresskey, "%s_NETADDRESS", colour); - sprintf(old_broadcastkey, "%s_BROADCAST", colour); + /* owes: old format keep until change completed */ + sprintf(old_addresskey, "%s_ADDRESS", colour); + sprintf(old_netmaskkey, "%s_NETMASK", colour); + sprintf(old_netaddresskey, "%s_NETADDRESS", colour); + sprintf(old_broadcastkey, "%s_BROADCAST", colour); - snprintf(message, STRING_SIZE, gettext("TR_ENTER_THE_IP_ADDRESS_INFORMATION"), colour); - text = newtTextboxReflowed(1, 1, message, 68, 0, 0, 0); - numLines = newtTextboxGetNumLines(text); + snprintf(message, STRING_SIZE, gettext("TR_ENTER_THE_IP_ADDRESS_INFORMATION"), colour); + text = newtTextboxReflowed(1, 1, message, 68, 0, 0, 0); + numLines = newtTextboxGetNumLines(text); - snprintf(message, STRING_SIZE, gettext("TR_INTERFACE"), colour); - newtCenteredWindow(72, 10+numLines, message); - networkform = newtForm(NULL, NULL, 0); - newtFormAddComponent(networkform, text); + snprintf(message, STRING_SIZE, gettext("TR_INTERFACE"), colour); + newtCenteredWindow(72, 10 + numLines, message); + networkform = newtForm(NULL, NULL, 0); + newtFormAddComponent(networkform, text); - /* Address */ - addresslabel = newtTextbox(2, 2+numLines, 18, 1, 0); - newtTextboxSetText(addresslabel, gettext("TR_IP_ADDRESS_PROMPT")); - if ( !strcmp(colour, "GREEN") ) - { - /* green only for now */ - strcpy(keyvalue, default_ip); - } - else - { - strcpy(keyvalue, ""); - } - find_kv_default(eth_kv, addresskey, keyvalue); - addressentry = newtEntry(20, 2+numLines, keyvalue, 20, &addressresult, 0); - newtEntrySetFilter(addressentry, filter_ip, NULL); - newtFormAddComponent(networkform, addresslabel); - newtFormAddComponent(networkform, addressentry); - - /* Netmask */ - netmasklabel = newtTextbox(2, 3+numLines, 18, 1, 0); - newtTextboxSetText(netmasklabel, gettext("TR_NETMASK_PROMPT")); - strcpy(keyvalue, default_netmask); - find_kv_default(eth_kv, netmaskkey, keyvalue); - netmaskentry = newtEntry(20, 3+numLines, keyvalue, 20, &netmaskresult, 0); - newtEntrySetFilter(netmaskentry, filter_ip, NULL); - newtFormAddComponent(networkform, netmasklabel); - newtFormAddComponent(networkform, netmaskentry); + /* Address */ + addresslabel = newtTextbox(2, 2 + numLines, 18, 1, 0); + newtTextboxSetText(addresslabel, gettext("TR_IP_ADDRESS_PROMPT")); + if (!strcmp(colour, "GREEN")) { + /* green only for now */ + strcpy(keyvalue, default_ip); + } + else { + strcpy(keyvalue, ""); + } + find_kv_default(eth_kv, addresskey, keyvalue); + addressentry = newtEntry(20, 2 + numLines, keyvalue, 20, &addressresult, 0); + newtEntrySetFilter(addressentry, filterip, NULL); + newtFormAddComponent(networkform, addresslabel); + newtFormAddComponent(networkform, addressentry); - ok = newtButton(6, 5+numLines, gettext("TR_OK")); - cancel = newtButton(26, 5+numLines, gettext("TR_CANCEL")); - newtFormAddComponents(networkform, ok, cancel, NULL); + /* Netmask */ + netmasklabel = newtTextbox(2, 3 + numLines, 18, 1, 0); + newtTextboxSetText(netmasklabel, gettext("TR_NETMASK_PROMPT")); + strcpy(keyvalue, default_netmask); + find_kv_default(eth_kv, netmaskkey, keyvalue); + netmaskentry = newtEntry(20, 3 + numLines, keyvalue, 20, &netmaskresult, 0); + newtEntrySetFilter(netmaskentry, filterip, NULL); + newtFormAddComponent(networkform, netmasklabel); + newtFormAddComponent(networkform, netmaskentry); - newtRefresh(); - newtDrawForm(networkform); + ok = newtButton(6, 5 + numLines, gettext("TR_OK")); + cancel = newtButton(26, 5 + numLines, gettext("TR_CANCEL")); + newtFormAddComponents(networkform, ok, cancel, NULL); - do - { - error = 0; - newtFormRun(networkform, &exitstruct); + newtRefresh(); + newtDrawForm(networkform); - if ( exitstruct.u.co == ok ) - { + do { + error = 0; + newtFormRun(networkform, &exitstruct); - strcpy(message, gettext("TR_INVALID_FIELDS")); - if ( inet_addr(addressresult) == INADDR_NONE ) - { - strcat(message, gettext("TR_IP_ADDRESS_CR")); - error = 1; - } - if ( inet_addr(netmaskresult) == INADDR_NONE ) - { - strcat(message, gettext("TR_NETWORK_MASK_CR")); - error = 1; - } + if (exitstruct.u.co == ok) { - if ( error ) - { - errorbox(message); - } - else - { - /* all is well, calc netaddress, broadcast and store everything */ - unsigned long int intaddress; - unsigned long int intnetaddress; - unsigned long int intnetmask; - unsigned long int intbroadcast; - struct in_addr i_addr; - char *netaddress; - char *broadcast; + strcpy(message, gettext("TR_INVALID_FIELDS")); + if (inet_addr(addressresult) == INADDR_NONE) { + strcat(message, gettext("TR_IP_ADDRESS_CR")); + error = 1; + } + if (inet_addr(netmaskresult) == INADDR_NONE) { + strcat(message, gettext("TR_NETWORK_MASK_CR")); + error = 1; + } - update_kv(ð_kv, addresskey, (char *)addressresult); - update_kv(ð_kv, old_addresskey, (char *)addressresult); - update_kv(ð_kv, netmaskkey, (char *)netmaskresult); - update_kv(ð_kv, old_netmaskkey, (char *)netmaskresult); - /* calculate netaddress */ - intaddress = inet_addr(addressresult); - intnetmask = inet_addr(netmaskresult); - /* calculate broadcast */ - intnetaddress = intaddress & intnetmask; - i_addr.s_addr = intnetaddress; - netaddress = inet_ntoa(i_addr); - update_kv(ð_kv, netaddresskey, (char *)netaddress); - update_kv(ð_kv, old_netaddresskey, (char *)netaddress); + if (error) { + errorbox(message); + } + else { + /* all is well, calc netaddress, broadcast and store everything */ + unsigned long int intaddress; + unsigned long int intnetaddress; + unsigned long int intnetmask; + unsigned long int intbroadcast; + struct in_addr i_addr; + char *netaddress; + char *broadcast; - intbroadcast = intnetaddress | ~intnetmask; - i_addr.s_addr = intbroadcast; - broadcast = inet_ntoa(i_addr); - update_kv(ð_kv, broadcastkey, (char *)broadcast); - update_kv(ð_kv, old_broadcastkey, (char *)broadcast); + update_kv(ð_kv, addresskey, (char *) addressresult); + update_kv(ð_kv, old_addresskey, (char *) addressresult); + update_kv(ð_kv, netmaskkey, (char *) netmaskresult); + update_kv(ð_kv, old_netmaskkey, (char *) netmaskresult); + /* calculate netaddress */ + intaddress = inet_addr(addressresult); + intnetmask = inet_addr(netmaskresult); + /* calculate broadcast */ + intnetaddress = intaddress & intnetmask; + i_addr.s_addr = intnetaddress; + netaddress = inet_ntoa(i_addr); + update_kv(ð_kv, netaddresskey, (char *) netaddress); + update_kv(ð_kv, old_netaddresskey, (char *) netaddress); - changed_config = 1; - *changed_flag = 1; - } + intbroadcast = intnetaddress | ~intnetmask; + i_addr.s_addr = intbroadcast; + broadcast = inet_ntoa(i_addr); + update_kv(ð_kv, broadcastkey, (char *) broadcast); + update_kv(ð_kv, old_broadcastkey, (char *) broadcast); + + changed_config = 1; + *changed_flag = 1; + } + } } - } - while ( error ); + while (error); - newtFormDestroy(networkform); - newtPopWindow(); + newtFormDestroy(networkform); + newtPopWindow(); } -/* - Small window to select which colour IP to change -*/ +/* Small window to select which colour IP to change */ static void selectchangeaddress(void) { - char *menuchoices[10]; - char key[STRING_SIZE]; - char keyvalue[STRING_SIZE]; - int rc; - int i; - int choice; + char *menuchoices[10]; + char key[STRING_SIZE]; + char keyvalue[STRING_SIZE]; + int rc; + int i; + int choice; - choice = 0; - for (i = 0; i < CFG_COLOURS_COUNT; i++) - { - snprintf(key, STRING_SIZE, "%s_DEV", ipcop_colours_text[i]); - strcpy(keyvalue, ""); - find_kv_default(eth_kv, key, keyvalue); - if ( keyvalue[0] ) - { - menuchoices[choice++] = ipcop_colours_text[i]; + choice = 0; + for (i = 0; i < CFG_COLOURS_COUNT; i++) { + snprintf(key, STRING_SIZE, "%s_DEV", ipcop_colours_text[i]); + strcpy(keyvalue, ""); + find_kv_default(eth_kv, key, keyvalue); + if (keyvalue[0]) { + menuchoices[choice++] = ipcop_colours_text[i]; + } } - } - menuchoices[choice] = NULL; - choice = 0; + menuchoices[choice] = NULL; + choice = 0; - for (;;) - { - rc = newtWinMenu(gettext("TR_CARD_ASSIGNMENT"), - gettext("TR_SELECT_THE_INTERFACE_YOU_WISH_TO_RECONFIGURE"), 65, 5, 5, 11, - menuchoices, &choice, gettext("TR_OK"), gettext("TR_QUIT"), NULL); + for (;;) { + rc = newtWinMenu(gettext("TR_CARD_ASSIGNMENT"), + gettext("TR_SELECT_THE_INTERFACE_YOU_WISH_TO_RECONFIGURE"), 65, 5, 5, 11, + menuchoices, &choice, gettext("TR_OK"), gettext("TR_QUIT"), NULL); - if (rc == 2) - break; + if (rc == 2) + break; - if ( !strcmp(menuchoices[choice], "GREEN") ) - { - changeaddress("GREEN", &changed_green); + if (!strcmp(menuchoices[choice], "GREEN")) { + changeaddress("GREEN", &changed_green); + } + if (!strcmp(menuchoices[choice], "RED")) { + changeaddress("RED", &changed_red); + } + if (!strcmp(menuchoices[choice], "BLUE")) { + changeaddress("BLUE", &changed_blue); + } + if (!strcmp(menuchoices[choice], "ORANGE")) { + changeaddress("ORANGE", &changed_orange); + } } - if ( !strcmp(menuchoices[choice], "RED") ) - { - changeaddress("RED", &changed_red); - } - if ( !strcmp(menuchoices[choice], "BLUE") ) - { - changeaddress("BLUE", &changed_blue); - } - if ( !strcmp(menuchoices[choice], "ORANGE") ) - { - changeaddress("ORANGE", &changed_orange); - } - } } -/* - Change DNS Server(s) and default gateway if type is STATIC -*/ +/* Change DNS Server(s) and default gateway if type is STATIC */ static void changednsgateway(void) { - newtComponent networkform; - newtComponent text; - newtComponent ok, cancel; - struct newtExitStruct exitstruct; - char keyvalue[STRING_SIZE]; - newtComponent dns1label; - newtComponent dns2label; - newtComponent gatewaylabel; - newtComponent dns1entry; - newtComponent dns2entry; - newtComponent gatewayentry; - const char *dns1result; - const char *dns2result; - const char *gatewayresult; - char message[STRING_SIZE_LARGE]; - int error; - int numLines; + newtComponent networkform; + newtComponent text; + newtComponent ok, cancel; + struct newtExitStruct exitstruct; + char keyvalue[STRING_SIZE]; + newtComponent dns1label; + newtComponent dns2label; + newtComponent gatewaylabel; + newtComponent dns1entry; + newtComponent dns2entry; + newtComponent gatewayentry; + const char *dns1result; + const char *dns2result; + const char *gatewayresult; + char message[STRING_SIZE_LARGE]; + int error; + int numLines; - snprintf(message, STRING_SIZE, gettext("TR_DNS_AND_GATEWAY_SETTINGS_LONG")); - text = newtTextboxReflowed(1, 1, message, 68, 0, 0, 0); - numLines = newtTextboxGetNumLines(text); + snprintf(message, STRING_SIZE, gettext("TR_DNS_AND_GATEWAY_SETTINGS_LONG")); + text = newtTextboxReflowed(1, 1, message, 68, 0, 0, 0); + numLines = newtTextboxGetNumLines(text); - newtCenteredWindow(72, 11+numLines, gettext("TR_DNS_AND_GATEWAY_SETTINGS")); - networkform = newtForm(NULL, NULL, 0); - newtFormAddComponent(networkform, text); + newtCenteredWindow(72, 11 + numLines, gettext("TR_DNS_AND_GATEWAY_SETTINGS")); + networkform = newtForm(NULL, NULL, 0); + newtFormAddComponent(networkform, text); - /* DNS1 */ - dns1label = newtTextbox(2, 2+numLines, 18, 1, 0); - newtTextboxSetText(dns1label, gettext("TR_PRIMARY_DNS")); - strcpy(keyvalue, ""); - find_kv_default(eth_kv, "DNS1", keyvalue); - dns1entry = newtEntry(20, 2+numLines, keyvalue, 20, &dns1result, 0); - newtEntrySetFilter(dns1entry, filter_ip, NULL); - newtFormAddComponent(networkform, dns1label); - newtFormAddComponent(networkform, dns1entry); + /* DNS1 */ + dns1label = newtTextbox(2, 2 + numLines, 18, 1, 0); + newtTextboxSetText(dns1label, gettext("TR_PRIMARY_DNS")); + strcpy(keyvalue, ""); + find_kv_default(eth_kv, "DNS1", keyvalue); + dns1entry = newtEntry(20, 2 + numLines, keyvalue, 20, &dns1result, 0); + newtEntrySetFilter(dns1entry, filterip, NULL); + newtFormAddComponent(networkform, dns1label); + newtFormAddComponent(networkform, dns1entry); - /* DNS2 */ - dns2label = newtTextbox(2, 3+numLines, 18, 1, 0); - newtTextboxSetText(dns2label, gettext("TR_SECONDARY_DNS")); - strcpy(keyvalue, ""); - find_kv_default(eth_kv, "DNS2", keyvalue); - dns2entry = newtEntry(20, 3+numLines, keyvalue, 20, &dns2result, 0); - newtEntrySetFilter(dns2entry, filter_ip, NULL); - newtFormAddComponent(networkform, dns2label); - newtFormAddComponent(networkform, dns2entry); + /* DNS2 */ + dns2label = newtTextbox(2, 3 + numLines, 18, 1, 0); + newtTextboxSetText(dns2label, gettext("TR_SECONDARY_DNS")); + strcpy(keyvalue, ""); + find_kv_default(eth_kv, "DNS2", keyvalue); + dns2entry = newtEntry(20, 3 + numLines, keyvalue, 20, &dns2result, 0); + newtEntrySetFilter(dns2entry, filterip, NULL); + newtFormAddComponent(networkform, dns2label); + newtFormAddComponent(networkform, dns2entry); - /* Gateway */ - gatewaylabel = newtTextbox(2, 4+numLines, 18, 1, 0); - newtTextboxSetText(gatewaylabel, gettext("TR_DEFAULT_GATEWAY")); - strcpy(keyvalue, ""); - find_kv_default(eth_kv, "DEFAULT_GATEWAY", keyvalue); - gatewayentry = newtEntry(20, 4+numLines, keyvalue, 20, &gatewayresult, 0); - newtEntrySetFilter(gatewayentry, filter_ip, NULL); - newtFormAddComponent(networkform, gatewaylabel); - newtFormAddComponent(networkform, gatewayentry); + /* Gateway */ + gatewaylabel = newtTextbox(2, 4 + numLines, 18, 1, 0); + newtTextboxSetText(gatewaylabel, gettext("TR_DEFAULT_GATEWAY")); + strcpy(keyvalue, ""); + find_kv_default(eth_kv, "DEFAULT_GATEWAY", keyvalue); + gatewayentry = newtEntry(20, 4 + numLines, keyvalue, 20, &gatewayresult, 0); + newtEntrySetFilter(gatewayentry, filterip, NULL); + newtFormAddComponent(networkform, gatewaylabel); + newtFormAddComponent(networkform, gatewayentry); - ok = newtButton(8, 6+numLines, gettext("TR_OK")); - cancel = newtButton(26, 6+numLines, gettext("TR_CANCEL")); - newtFormAddComponents(networkform, ok, cancel, NULL); + ok = newtButton(8, 6 + numLines, gettext("TR_OK")); + cancel = newtButton(26, 6 + numLines, gettext("TR_CANCEL")); + newtFormAddComponents(networkform, ok, cancel, NULL); - newtRefresh(); - newtDrawForm(networkform); + newtRefresh(); + newtDrawForm(networkform); - do - { - error = 0; - newtFormRun(networkform, &exitstruct); + do { + error = 0; + newtFormRun(networkform, &exitstruct); - if ( exitstruct.u.co == ok ) - { - strcpy(message, gettext("TR_INVALID_FIELDS")); - if ( strlen(dns1result) && (inet_addr(dns1result) == INADDR_NONE) ) - { - strcat(message, gettext("TR_PRIMARY_DNS_CR")); - error = 1; - } - if ( strlen(dns2result) && (inet_addr(dns2result) == INADDR_NONE) ) - { - strcat(message, gettext("TR_SECONDARY_DNS_CR")); - error = 1; - } - if ( strlen(gatewayresult) && (inet_addr(gatewayresult) == INADDR_NONE) ) - { - strcat(message, gettext("TR_DEFAULT_GATEWAY_CR")); - error = 1; - } - - if ( error ) - { - errorbox(message); - } - else - { - update_kv(ð_kv, "DNS1", (char *)dns1result); - update_kv(ð_kv, "DNS2", (char *)dns2result); - update_kv(ð_kv, "DEFAULT_GATEWAY", (char *)gatewayresult); + if (exitstruct.u.co == ok) { + strcpy(message, gettext("TR_INVALID_FIELDS")); + if (strlen(dns1result) && (inet_addr(dns1result) == INADDR_NONE)) { + strcat(message, gettext("TR_PRIMARY_DNS_CR")); + error = 1; + } + if (strlen(dns2result) && (inet_addr(dns2result) == INADDR_NONE)) { + strcat(message, gettext("TR_SECONDARY_DNS_CR")); + error = 1; + } + if (strlen(gatewayresult) && (inet_addr(gatewayresult) == INADDR_NONE)) { + strcat(message, gettext("TR_DEFAULT_GATEWAY_CR")); + error = 1; + } - changed_config = 1; - changed_dnsgateway = 1; - } + if (error) { + errorbox(message); + } + else { + update_kv(ð_kv, "DNS1", (char *) dns1result); + update_kv(ð_kv, "DNS2", (char *) dns2result); + update_kv(ð_kv, "DEFAULT_GATEWAY", (char *) gatewayresult); + + changed_config = 1; + changed_dnsgateway = 1; + } + } } - } - while ( error ); + while (error); - newtFormDestroy(networkform); - newtPopWindow(); + newtFormDestroy(networkform); + newtPopWindow(); } -/* - Open a window with network config menus or simply go through them 1 by 1 (installer). -*/ +/* Open a window with network config menus or simply go through them 1 by 1 (installer). */ int handlenetworking(void) { - int rc; - int choice; - char *menuchoices[10]; - char keyvalue[STRING_SIZE]; + int rc; + int choice; + char *menuchoices[10]; + char keyvalue[STRING_SIZE]; - menuchoices[0] = gettext("TR_RED_CONFIGURATION_TYPE"); - menuchoices[1] = gettext("TR_DRIVERS_AND_CARD_ASSIGNMENTS"); - menuchoices[2] = gettext("TR_ADDRESS_SETTINGS"); - menuchoices[3] = gettext("TR_DNS_AND_GATEWAY_SETTINGS"); - menuchoices[4] = gettext("TR_DHCP_SERVER_CONFIGURATION"); + menuchoices[0] = gettext("TR_RED_CONFIGURATION_TYPE"); + menuchoices[1] = gettext("TR_DRIVERS_AND_CARD_ASSIGNMENTS"); + menuchoices[2] = gettext("TR_ADDRESS_SETTINGS"); + menuchoices[3] = gettext("TR_DNS_AND_GATEWAY_SETTINGS"); + menuchoices[4] = gettext("TR_DHCP_SERVER_CONFIGURATION"); - menuchoices[5] = NULL; - - changed_config = 0; - changed_type = 0; - changed_hostname = 0; - changed_green = 0; - changed_red = 0; - changed_dnsgateway = 0; + menuchoices[5] = NULL; - if ( !(read_kv_from_file(ð_kv, "/var/ipcop/ethernet/settings")) ) - { - free_kv(ð_kv); - errorbox(gettext("TR_UNABLE_TO_OPEN_SETTINGS_FILE")); - return 0; - } + changed_config = 0; + changed_type = 0; + changed_hostname = 0; + changed_green = 0; + changed_red = 0; + changed_dnsgateway = 0; - strcpy(kv_red_type, ""); - find_kv_default(eth_kv, "RED_1_TYPE", kv_red_type); + if (!(read_kv_from_file(ð_kv, "/var/ipcop/ethernet/settings"))) { + free_kv(ð_kv); + errorbox(gettext("TR_UNABLE_TO_OPEN_SETTINGS_FILE")); + return FAILURE; + } - if ( flag_installer ) - { - /* When installing we run (some) configwindows in sequence */ - NODEKV *kv_dhcp_params = NULL; + readisanics(); - read_kv_from_file(&kv_dhcp_params, "/tmp/dhcp-eth0.params"); - find_kv_default(kv_dhcp_params, "IP", default_ip); - find_kv_default(kv_dhcp_params, "NETMASK", default_netmask); - free_kv(&kv_dhcp_params); + strcpy(kv_red_type, ""); + find_kv_default(eth_kv, "RED_1_TYPE", kv_red_type); - /* make sure these are always present */ - update_kv(ð_kv, "GREEN_COUNT", "0"); - update_kv(ð_kv, "RED_COUNT", "0"); - update_kv(ð_kv, "BLUE_COUNT", "0"); - update_kv(ð_kv, "ORANGE_COUNT", "0"); + if (flag_installer) { + /* When installing we run (some) configwindows in sequence */ + NODEKV *kv_dhcp_params = NULL; - redconfigtype(); - /* RED_TYPE is now set, even if cancel was pressed */ - cardlist(); + read_kv_from_file(&kv_dhcp_params, "/tmp/dhcp-eth0.params"); + find_kv_default(kv_dhcp_params, "IP", default_ip); + find_kv_default(kv_dhcp_params, "NETMASK", default_netmask); + free_kv(&kv_dhcp_params); - changeaddress("GREEN", &changed_green); + /* make sure these are always present */ + update_kv(ð_kv, "GREEN_COUNT", "0"); + update_kv(ð_kv, "RED_COUNT", "0"); + update_kv(ð_kv, "BLUE_COUNT", "0"); + update_kv(ð_kv, "ORANGE_COUNT", "0"); - if ( !strcmp(kv_red_type, "PPPOE") ) - { - /* default to 1.1.1.1 */ - update_kv(ð_kv, "RED_1_ADDRESS", "1.1.1.1"); - /* do we want to be able to change this ? */ + redconfigtype(); + /* RED_TYPE is now set, even if cancel was pressed */ + cardlist(); - changeaddress("RED", &changed_red); - } - else if ( !strcmp(kv_red_type, "PPTP") ) - { - changeaddress("RED", &changed_red); - } - else if ( !strcmp(kv_red_type, "STATIC") ) - { - changeaddress("RED", &changed_red); - changednsgateway(); - } - else if ( !strcmp(kv_red_type, "DHCP") ) - { - changehostname(); - changednsgateway(); - } + changeaddress("GREEN", &changed_green); - find_kv_default(eth_kv, "BLUE_COUNT", keyvalue); - if ( keyvalue[0] != '0' ) - { - changeaddress("BLUE", &changed_blue); - } + if (!strcmp(kv_red_type, "PPPOE")) { + /* default to 1.1.1.1 */ + update_kv(ð_kv, "RED_1_ADDRESS", "1.1.1.1"); + /* do we want to be able to change this ? */ - find_kv_default(eth_kv, "ORANGE_COUNT", keyvalue); - if ( keyvalue[0] != '0' ) - { - changeaddress("ORANGE", &chan... [truncated message content] |
From: <ow...@us...> - 2008-08-12 16:10:30
|
Revision: 1691 http://ipcop.svn.sourceforge.net/ipcop/?rev=1691&view=rev Author: owes Date: 2008-08-12 16:10:31 +0000 (Tue, 12 Aug 2008) Log Message: ----------- Add windows for manually adding NICs Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2008-08-12 15:34:27 UTC (rev 1690) +++ ipcop/trunk/src/installer/networking.c 2008-08-12 16:10:31 UTC (rev 1691) @@ -176,7 +176,7 @@ /* Modprobe some module, then look for new net device */ -static void probecard(char *module, char *options) +static int probecard(char *module, char *options, int error) { char command[STRING_SIZE]; struct dirent **scndir; @@ -184,13 +184,19 @@ int i, j; /* owes: ToDo test if module already loaded ? */ + /* errorbox(gettext("TR_THIS_DRIVER_MODULE_IS_ALREADY_LOADED")); */ snprintf(command, STRING_SIZE, "/sbin/modprobe %s %s", module, options); if (mysystem(command)) { - /* errorbox ? */ - return; + if (error) { + errorbox(gettext("TR_UNABLE_TO_LOAD_DRIVER_MODULE")); + } + return FAILURE; } + + /* owes: this needs some more thinking and testing, give me some time to try and test imaginable combinations */ + /* new card found ? */ newcards = scandir("/sys/class/net", &scndir, filternet, alphasort); if (newcards) { @@ -210,7 +216,12 @@ if (j < newcards) { fprintf(flog, " some stray modprobe?\n"); } + return SUCCESS; } + + /* no new card found, but modprobe did not report an error ? */ + + return FAILURE; } @@ -280,7 +291,7 @@ for (i = 0; i < numnetwork; i++) { if (!networks[i].device[0]) { - probecard(networks[i].module, ""); + probecard(networks[i].module, "", 0); } } } @@ -491,8 +502,47 @@ } +/* window with field for module and options */ +static void addmanual(void) +{ + char *values[] = { NULL, NULL }; /* pointers for the values. */ + struct newtWinEntry entries[] = + { { "", &values[0], 0,}, { NULL, NULL, 0 } }; + int rc; + int done; + + done = 0; + + while (done == 0) { + rc = newtWinEntries(gettext("TR_SELECT_NETWORK_DRIVER"), + gettext("TR_MODULE_PARAMETERS"), 50, 5, 5, 40, entries, + gettext("TR_OK"), gettext("TR_CANCEL"), NULL); + if (rc == 0 || rc == 1) { + char *ptr; + + if (strlen(values[0]) == 0) { + errorbox(gettext("TR_MODULE_NAME_CANNOT_BE_BLANK")); + continue; + } + + if ((ptr = strchr(values[0], ' ')) != NULL) { + *ptr = 0; + done = (probecard(values[0], ptr+1, 1) == SUCCESS); + } + else + { + done = (probecard(values[0], "", 1) == SUCCESS); + } + } + else { + done = 1; /* canceled by user */ + } + } +} + + /* Add a card manually from the ISA nic list */ -static void addcardmanual(void) +static void manuallist(void) { int done; int rc; @@ -502,23 +552,19 @@ done = 0; while (done == 0) { rc = newtWinMenu(gettext("TR_SELECT_NETWORK_DRIVER"), - gettext("TR_SELECT_NETWORK_DRIVER_LONG"), 65, 5, 5, 11, + gettext("TR_SELECT_NETWORK_DRIVER_LONG"), 65, 5, 5, 6, isa_nics_description, &choice, gettext("TR_OK"), gettext("TR_CANCEL"), NULL); if ((rc == 0) || (rc == 1)) { if (choice == 0) { - newtWinMessage(gettext("TR_CARD_ASSIGNMENT"), gettext("TR_OK"), "Sorry, not implemented yet."); + addmanual(); } else { - /* - OWES: modprobe module here, add to list of cards in case of success - probably want to return in case of success - continue with the list in case of failure - */ + done = (probecard(isa_nics_module[choice], "", 1) == SUCCESS); } } else { - done = 1; + done = 1; /* canceled by user */ } } } @@ -561,7 +607,7 @@ cardconfig(choice); break; case 2: - addcardmanual(); + manuallist(); break; case 3: /* owes: ToDo test if we have green and possibly red here */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2008-08-17 20:45:23
|
Revision: 1705 http://ipcop.svn.sourceforge.net/ipcop/?rev=1705&view=rev Author: owes Date: 2008-08-17 20:45:32 +0000 (Sun, 17 Aug 2008) Log Message: ----------- Fast exit when used during installation. Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2008-08-17 20:42:19 UTC (rev 1704) +++ ipcop/trunk/src/installer/networking.c 2008-08-17 20:45:32 UTC (rev 1705) @@ -1052,40 +1052,52 @@ changeaddress("ORANGE", &changed_orange); } + write_kv_to_file(ð_kv, "/var/ipcop/ethernet/settings"); + free_kv(ð_kv); + + /* TODO: other settings / services we need to trigger ? */ + /* Last but not least, optionally confgure DHCP server for GREEN */ changedhcpserver(); + + return SUCCESS; } - else { - choice = 0; - for (;;) { + /* Non-Installer section + * + */ - rc = newtWinMenu(gettext("TR_NETWORK_CONFIGURATION_MENU"), - gettext("TR_SELECT_THE_ITEM"), 65, 5, 5, 11, - menuchoices, &choice, gettext("TR_OK"), gettext("TR_QUIT"), NULL); + choice = 0; - if (rc == 2) - break; + for (;;) { - switch (choice) { - case 0: - redconfigtype(); - break; - case 1: - cardlist(); - break; - case 2: - selectchangeaddress(); - break; - case 3: - changednsgateway(); - break; - case 4: - changedhcpserver(); - break; - default: - break; - } + rc = newtWinMenu(gettext("TR_NETWORK_CONFIGURATION_MENU"), + gettext("TR_SELECT_THE_ITEM"), 65, 5, 5, 11, + menuchoices, &choice, gettext("TR_OK"), gettext("TR_QUIT"), NULL); + + if (rc == 2) + break; + + switch (choice) { + case 0: + redconfigtype(); + break; + case 1: + cardlist(); + break; + case 2: + selectchangeaddress(); + break; + case 3: + changednsgateway(); + break; + case 4: + /* DHCP server needs settings file */ + write_kv_to_file(ð_kv, "/var/ipcop/ethernet/settings"); + changedhcpserver(); + break; + default: + break; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2008-08-29 21:29:00
|
Revision: 1746 http://ipcop.svn.sourceforge.net/ipcop/?rev=1746&view=rev Author: owes Date: 2008-08-29 21:29:11 +0000 (Fri, 29 Aug 2008) Log Message: ----------- rebuildhosts (re)creates /etc/hosts, which is needed for several things so better be valid/correct. Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2008-08-29 12:20:44 UTC (rev 1745) +++ ipcop/trunk/src/installer/networking.c 2008-08-29 21:29:11 UTC (rev 1746) @@ -1054,6 +1054,7 @@ write_kv_to_file(ð_kv, "/var/ipcop/ethernet/settings"); free_kv(ð_kv); + mysystem("/usr/local/bin/rebuildhosts"); /* TODO: other settings / services we need to trigger ? */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2008-11-15 22:42:07
|
Revision: 2067 http://ipcop.svn.sourceforge.net/ipcop/?rev=2067&view=rev Author: owes Date: 2008-11-15 22:42:01 +0000 (Sat, 15 Nov 2008) Log Message: ----------- Get rid of the old ethernet/settings stuff Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2008-11-15 10:53:57 UTC (rev 2066) +++ ipcop/trunk/src/installer/networking.c 2008-11-15 22:42:01 UTC (rev 2067) @@ -328,8 +328,6 @@ strcpy(keyvalue, "PPPOE"); if (find_kv_default(eth_kv, "RED_1_TYPE", keyvalue) == FAILURE) { update_kv(ð_kv, "RED_1_TYPE", "PPPOE"); - /* keep RED_TYPE for now */ - update_kv(ð_kv, "RED_TYPE", "PPPOE"); changed_config = 1; } /* build radio buttons and add to window */ @@ -356,21 +354,13 @@ /* config type has changed, update cfg file and set flag */ update_kv(ð_kv, "RED_1_TYPE", ipcop_red_text[i]); strcpy(kv_red_type, ipcop_red_text[i]); - /* keep RED_TYPE for now */ - update_kv(ð_kv, "RED_TYPE", ipcop_red_text[i]); if (!strcmp(ipcop_red_text[i], "ANALOG") || !strcmp(ipcop_red_text[i], "ISDN")) { update_kv(ð_kv, "RED_1_DEV", ""); update_kv(ð_kv, "RED_COUNT", "0"); - - /* keep CONFIG_TYPE for now */ - update_kv(ð_kv, "CONFIG_TYPE", "0"); } else { update_kv(ð_kv, "RED_COUNT", "1"); - - /* keep CONFIG_TYPE for now */ - update_kv(ð_kv, "CONFIG_TYPE", "2"); } changed_config = 1; changed_type = 1; @@ -399,12 +389,6 @@ update_kv(ð_kv, key, ""); snprintf(key, STRING_SIZE, "%s_COUNT", colour); update_kv(ð_kv, key, "0"); - - /* owes: old format keep until change completed */ - snprintf(key, STRING_SIZE, "%s_DEV", colour); - update_kv(ð_kv, key, ""); - snprintf(key, STRING_SIZE, "%s_DRIVER", colour); - update_kv(ð_kv, key, ""); } else { snprintf(key, STRING_SIZE, "%s_1_DEV", colour); @@ -413,12 +397,6 @@ update_kv(ð_kv, key, networks[n].module); snprintf(key, STRING_SIZE, "%s_COUNT", colour); update_kv(ð_kv, key, "1"); - - /* owes: old format keep until change completed */ - snprintf(key, STRING_SIZE, "%s_DEV", colour); - update_kv(ð_kv, key, networks[n].device); - snprintf(key, STRING_SIZE, "%s_DRIVER", colour); - update_kv(ð_kv, key, networks[n].module); } } @@ -696,23 +674,12 @@ int error; int numLines; - char old_addresskey[STRING_SIZE]; - char old_netmaskkey[STRING_SIZE]; - char old_netaddresskey[STRING_SIZE]; - char old_broadcastkey[STRING_SIZE]; - /* Build some key strings. */ sprintf(addresskey, "%s_1_ADDRESS", colour); sprintf(netmaskkey, "%s_1_NETMASK", colour); sprintf(netaddresskey, "%s_1_NETADDRESS", colour); sprintf(broadcastkey, "%s_1_BROADCAST", colour); - /* owes: old format keep until change completed */ - sprintf(old_addresskey, "%s_ADDRESS", colour); - sprintf(old_netmaskkey, "%s_NETMASK", colour); - sprintf(old_netaddresskey, "%s_NETADDRESS", colour); - sprintf(old_broadcastkey, "%s_BROADCAST", colour); - snprintf(message, STRING_SIZE, gettext("TR_ENTER_THE_IP_ADDRESS_INFORMATION"), colour); text = newtTextboxReflowed(1, 1, message, 68, 0, 0, 0); numLines = newtTextboxGetNumLines(text); @@ -785,9 +752,7 @@ char *broadcast; update_kv(ð_kv, addresskey, (char *) addressresult); - update_kv(ð_kv, old_addresskey, (char *) addressresult); update_kv(ð_kv, netmaskkey, (char *) netmaskresult); - update_kv(ð_kv, old_netmaskkey, (char *) netmaskresult); /* calculate netaddress */ intaddress = inet_addr(addressresult); intnetmask = inet_addr(netmaskresult); @@ -796,13 +761,11 @@ i_addr.s_addr = intnetaddress; netaddress = inet_ntoa(i_addr); update_kv(ð_kv, netaddresskey, (char *) netaddress); - update_kv(ð_kv, old_netaddresskey, (char *) netaddress); intbroadcast = intnetaddress | ~intnetmask; i_addr.s_addr = intbroadcast; broadcast = inet_ntoa(i_addr); update_kv(ð_kv, broadcastkey, (char *) broadcast); - update_kv(ð_kv, old_broadcastkey, (char *) broadcast); changed_config = 1; *changed_flag = 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2008-11-27 15:56:31
|
Revision: 2111 http://ipcop.svn.sourceforge.net/ipcop/?rev=2111&view=rev Author: owes Date: 2008-11-27 15:56:21 +0000 (Thu, 27 Nov 2008) Log Message: ----------- When installing the network cards (or at least some) are autoloaded by udev. So we need some magic to match eth* interfaces to kernel modules and description for our selection list. Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2008-11-26 17:13:15 UTC (rev 2110) +++ ipcop/trunk/src/installer/networking.c 2008-11-27 15:56:21 UTC (rev 2111) @@ -74,6 +74,7 @@ static char default_netmask[STRING_SIZE] = "255.255.255.0"; static char mac_buffer[STRING_SIZE]; +static char module_buffer[STRING_SIZE]; /* Read list of ISA network cards */ @@ -150,6 +151,49 @@ } +/* Get kernel module for device using udevinfo. + This looks like a hack (and it is), suggestions as to how to do this differently are welcome. +*/ +static char *getkernelmodule(char *device) +{ + char command[STRING_SIZE]; + char line[STRING_SIZE]; + FILE *f; + char *ptr; + + strcpy(module_buffer, ""); + + /* Ask udevinfo about the device, use grep to limit the output for easier interpretation. + We expect one line with something like ' DRIVERS=="e100"' + */ + snprintf(command, STRING_SIZE, "/sbin/udevadm info -a -p /sys/class/net/%s | /bin/grep -m 1 \"DRIVERS==\"", device); + + f = popen(command, "r"); + if (fgets(line, STRING_SIZE, f) != NULL) { + stripnl(line); + if ((ptr = strchr(line, '"')) != NULL) { + /* ptr now points to "e100" */ + ptr++; + if (*ptr != '"') { + /* got a driver, remove trailing " */ + char *t = strchr(ptr, '"'); + + if (t != NULL) { + *t = 0; + } + + /* temporarily store it */ + strcpy(module_buffer, ptr); + } + } + } + + pclose(f); + + return module_buffer; +} + + /* Filter function for scanning directory /sys/class/net Used by scandir in probe_card function. @@ -176,53 +220,83 @@ } -/* Modprobe some module, then look for new net device */ +/* Modprobe some module, then look for new network device(s) + or look for already present network device(s) without modprobing +*/ static int probecard(char *module, char *options, int error) { char command[STRING_SIZE]; struct dirent **scndir; int newcards; - int i, j; + int i, j, k; - /* owes: ToDo test if module already loaded ? */ - /* errorbox(gettext("TR_THIS_DRIVER_MODULE_IS_ALREADY_LOADED")); */ + if (module != NULL) { + /* owes: ToDo test if module already loaded ? */ + /* errorbox(gettext("TR_THIS_DRIVER_MODULE_IS_ALREADY_LOADED")); */ - snprintf(command, STRING_SIZE, "/sbin/modprobe %s %s", module, options); - if (mysystem(command)) { - if (error) { - errorbox(gettext("TR_UNABLE_TO_LOAD_DRIVER_MODULE")); + snprintf(command, STRING_SIZE, "/sbin/modprobe %s %s", module, options); + if (mysystem(command)) { + if (error) { + errorbox(gettext("TR_UNABLE_TO_LOAD_DRIVER_MODULE")); + } + return FAILURE; } - return FAILURE; } /* owes: this needs some more thinking and testing, give me some time to try and test imaginable combinations */ - /* new card found ? */ newcards = scandir("/sys/class/net", &scndir, filternet, alphasort); - if (newcards) { - fprintf(flog, "probed %s, found %d\n", module, newcards); + if (!newcards) { + /* no new card found, but modprobe did not report an error ? */ + return FAILURE; + } + if (module == NULL) { + fprintf(flog, "nothing probed, found %d new network cards\n", newcards); + + /* walk thru all interfaces and try to match to our information list */ + for (i = 0, j = 0; (i < newcards); i++) { + char *kernelmodule = getkernelmodule(scndir[i]->d_name); + + if (!kernelmodule[0]) { + fprintf(flog, " no kernel module found for device %s\n", scndir[i]->d_name); + continue; + } + + for (k = 0; (k < numnetwork); k++) { + if (!networks[k].device[0] && !strcmp(kernelmodule, networks[k].module)) { + free(networks[k].device); + networks[k].device = strdup(scndir[i]->d_name); + networks[k].address = strdup(getmac(networks[k].device)); + fprintf(flog, " hwlist %s device %s MAC %s\n", + networks[k].module, networks[k].device, networks[k].address); + j++; + break; + } + } + } + } + else { + fprintf(flog, "probed kernel module %s, found %d new network cards\n", module, newcards); + + /* walk thru our information list and try to match kernel modules */ for (i = 0, j = 0; (i < numnetwork) && (j < newcards); i++) { if (!networks[i].device[0] && !strcmp(module, networks[i].module)) { free(networks[i].device); networks[i].device = strdup(scndir[j]->d_name); /* get and store MAC address */ - networks[i].address = getmac(networks[i].device); + networks[i].address = strdup(getmac(networks[i].device)); j++; fprintf(flog, " hwlist %s device %s MAC %s\n", module, networks[i].device, networks[i].address); } } + } - if (j < newcards) { - fprintf(flog, " some stray modprobe?\n"); - } - return SUCCESS; + if (j < newcards) { + fprintf(flog, " some stray modprobe?\n"); } - - /* no new card found, but modprobe did not report an error ? */ - - return FAILURE; + return SUCCESS; } @@ -290,6 +364,9 @@ } } + /* scan for any network interfaces already present (autoloaded by udev magic) */ + probecard(NULL, "", 0); + for (i = 0; i < numnetwork; i++) { if (!networks[i].device[0]) { probecard(networks[i].module, "", 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2008-11-28 11:01:54
|
Revision: 2120 http://ipcop.svn.sourceforge.net/ipcop/?rev=2120&view=rev Author: owes Date: 2008-11-28 11:01:51 +0000 (Fri, 28 Nov 2008) Log Message: ----------- Do not use udevadm info but info from /sys/class/net/eth* Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2008-11-28 09:36:57 UTC (rev 2119) +++ ipcop/trunk/src/installer/networking.c 2008-11-28 11:01:51 UTC (rev 2120) @@ -151,8 +151,7 @@ } -/* Get kernel module for device using udevinfo. - This looks like a hack (and it is), suggestions as to how to do this differently are welcome. +/* Get kernel module for device using /sys/class/net/interface/device/driver/module. */ static char *getkernelmodule(char *device) { @@ -163,26 +162,16 @@ strcpy(module_buffer, ""); - /* Ask udevinfo about the device, use grep to limit the output for easier interpretation. - We expect one line with something like ' DRIVERS=="e100"' - */ - snprintf(command, STRING_SIZE, "/sbin/udevadm info -a -p /sys/class/net/%s | /bin/grep -m 1 \"DRIVERS==\"", device); + snprintf(command, STRING_SIZE, "ls -l /sys/class/net/%s/device/driver/module", device); f = popen(command, "r"); if (fgets(line, STRING_SIZE, f) != NULL) { stripnl(line); - if ((ptr = strchr(line, '"')) != NULL) { - /* ptr now points to "e100" */ + if ((ptr = strrchr(line, '/')) != NULL) { + /* ptr now points to /e100 */ ptr++; - if (*ptr != '"') { - /* got a driver, remove trailing " */ - char *t = strchr(ptr, '"'); - - if (t != NULL) { - *t = 0; - } - - /* temporarily store it */ + if (*ptr) { + /* temporarily store driver */ strcpy(module_buffer, ptr); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2008-11-28 11:14:04
|
Revision: 2121 http://ipcop.svn.sourceforge.net/ipcop/?rev=2121&view=rev Author: owes Date: 2008-11-28 11:14:01 +0000 (Fri, 28 Nov 2008) Log Message: ----------- Get default value for DHCP clientname Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2008-11-28 11:01:51 UTC (rev 2120) +++ ipcop/trunk/src/installer/networking.c 2008-11-28 11:14:01 UTC (rev 2121) @@ -677,7 +677,7 @@ dhcphostnamelabel = newtTextbox(2, 2 + numLines, 18, 1, 0); newtTextboxSetText(dhcphostnamelabel, gettext("TR_DHCP_HOSTNAME")); strcpy(keyvalue, ""); - if (find_kv_default(eth_kv, "RED_DHCP_HOSTNAME", keyvalue) == 0) { + if (find_kv_default(eth_kv, "RED_DHCP_HOSTNAME", keyvalue) == FAILURE) { NODEKV *main_kv = NULL; if (read_kv_from_file(&main_kv, "/var/ipcop/main/settings") == SUCCESS) { find_kv_default(main_kv, "HOSTNAME", keyvalue); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2008-11-28 18:28:20
|
Revision: 2126 http://ipcop.svn.sourceforge.net/ipcop/?rev=2126&view=rev Author: owes Date: 2008-11-28 18:28:09 +0000 (Fri, 28 Nov 2008) Log Message: ----------- Make setup more robust against removing network cards. Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2008-11-28 18:27:06 UTC (rev 2125) +++ ipcop/trunk/src/installer/networking.c 2008-11-28 18:28:09 UTC (rev 2126) @@ -333,6 +333,12 @@ c = atoi(find_kv(eth_kv, key)); for (j = 1; j <= c; j++) { + /* Test if the configured device is still present */ + snprintf(key, STRING_SIZE, "%s_%d_DEV", ipcop_colours_text[i], j); + if (exist_ethernet_device(find_kv(eth_kv, key)) == FAILURE) { + continue; + } + snprintf(key, STRING_SIZE, "%s_%d_DRIVER", ipcop_colours_text[i], j); for (n = 0; n < numnetwork; n++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2008-11-30 21:16:29
|
Revision: 2146 http://ipcop.svn.sourceforge.net/ipcop/?rev=2146&view=rev Author: owes Date: 2008-11-30 21:16:23 +0000 (Sun, 30 Nov 2008) Log Message: ----------- Hack udev persistent rules to rename network interfaces. Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2008-11-30 18:58:44 UTC (rev 2145) +++ ipcop/trunk/src/installer/networking.c 2008-11-30 21:16:23 UTC (rev 2146) @@ -459,6 +459,8 @@ update_kv(ð_kv, key, ""); snprintf(key, STRING_SIZE, "%s_1_DRIVER", colour); update_kv(ð_kv, key, ""); + snprintf(key, STRING_SIZE, "%s_1_MAC", colour); + update_kv(ð_kv, key, ""); snprintf(key, STRING_SIZE, "%s_COUNT", colour); update_kv(ð_kv, key, "0"); } @@ -467,6 +469,8 @@ update_kv(ð_kv, key, networks[n].device); snprintf(key, STRING_SIZE, "%s_1_DRIVER", colour); update_kv(ð_kv, key, networks[n].module); + snprintf(key, STRING_SIZE, "%s_1_MAC", colour); + update_kv(ð_kv, key, networks[n].address); snprintf(key, STRING_SIZE, "%s_COUNT", colour); update_kv(ð_kv, key, "1"); } @@ -541,6 +545,47 @@ } +/* Hack udev persistent-net-rules and ethernet/settings. +*/ +static void udevconfig(void) +{ + int i; + int counter = 1; + char command[STRING_SIZE]; + char device[STRING_SIZE]; + + /* set the device names with the help of udev */ + for (i = 0; i < numnetwork; i++) { + if (networks[i].address[0]) { + if (!strcmp(networks[i].colour, ipcop_colours_text[NONE])) { + snprintf(device, STRING_SIZE, "unused_%d", counter++); + } + else if (!strcmp(networks[i].colour, ipcop_colours_text[GREEN])) { + strcpy(device, "lan_1"); + update_kv(ð_kv, "GREEN_1_DEV", "lan_1"); + } + else if (!strcmp(networks[i].colour, ipcop_colours_text[RED])) { + strcpy(device, "wan_1"); + update_kv(ð_kv, "RED_1_DEV", "wan_1"); + } + else if (!strcmp(networks[i].colour, ipcop_colours_text[BLUE])) { + strcpy(device, "wlan_1"); + update_kv(ð_kv, "BLUE_1_DEV", "wlan_1"); + } + else if (!strcmp(networks[i].colour, ipcop_colours_text[ORANGE])) { + strcpy(device, "dmz_1"); + update_kv(ð_kv, "ORANGE_1_DEV", "dmz_1"); + } + + snprintf(command, STRING_SIZE, "/bin/sed -i -e 's#\\(%s\\)\\(.*\\)NAME=\".*\"#\\1\\2NAME=\"%s\"#g' %s", + networks[i].address, device, + "/etc/udev/rules.d/70-persistent-net.rules"); + mysystem(command); + } + } +} + + /* window with field for module and options */ static void addmanual(void) { @@ -650,6 +695,10 @@ break; case 3: /* owes: ToDo test if we have green and possibly red here */ + + if (changed_config) { + udevconfig(); + } return; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2009-01-23 22:38:27
|
Revision: 2368 http://ipcop.svn.sourceforge.net/ipcop/?rev=2368&view=rev Author: owes Date: 2009-01-23 22:38:24 +0000 (Fri, 23 Jan 2009) Log Message: ----------- Use numeric enum values in internal structure. Change eth alias names to lan-1, wan-1 etc. instead of lan_1, wan_1. I find that easier to type. We probably need some kind of vote for a final decision on eth alias names one day. Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2009-01-23 22:34:28 UTC (rev 2367) +++ ipcop/trunk/src/installer/networking.c 2009-01-23 22:38:24 UTC (rev 2368) @@ -44,7 +44,7 @@ char *options; /* modprobe parameters */ char *device; /* eth0, eth1 etc. */ char *description; - char colour[10]; /* GREEN, RED, BLUE, ORANGE, ---- */ + ipcop_colours colour; /* GREEN, RED, BLUE, ORANGE, ---- */ char *address; /* MAC address */ }; @@ -311,7 +311,7 @@ networks[numnetwork].options = strdup(""); networks[numnetwork].device = strdup(""); networks[numnetwork].description = hardwares[i].description; - strcpy(networks[numnetwork].colour, "----"); + networks[numnetwork].colour = NONE; networks[numnetwork].address = strdup(""); numnetwork++; @@ -345,7 +345,7 @@ if (!networks[n].device[0] && (find_kv(eth_kv, key) != NULL) && !strcmp(networks[n].module, find_kv(eth_kv, key))) { /* 3,2,1 meins */ - strcpy(networks[n].colour, ipcop_colours_text[i]); + networks[n].colour = i; snprintf(key, STRING_SIZE, "%s_%d_DEV", ipcop_colours_text[i], j); networks[n].device = strdup(find_kv(eth_kv, key)); @@ -488,20 +488,20 @@ /* owes: ToDo could do with some fancy text here */ snprintf(info, STRING_SIZE_LARGE, "%s\nMAC Address: %s Device: %s\nCurrently assigned to: %s", - networks[n].description, networks[n].address, networks[n].device, networks[n].colour); + networks[n].description, networks[n].address, networks[n].device, ipcop_colours_text[networks[n].colour]); for (choice = 0, i = 0; i < CFG_COLOURS_COUNT - 1; i++) { int used = 0; /* skip RED if type is ANALOG or ISDN */ - if (!strcmp(ipcop_colours_text[i], "RED") && (!strcmp(kv_red_type, "ANALOG") || !strcmp(kv_red_type, "ISDN"))) { + if ((i == RED) && (!strcmp(kv_red_type, "ANALOG") || !strcmp(kv_red_type, "ISDN"))) { continue; } /* test for already used colours here */ for (j = 0; j < numnetwork && !used; j++) { - if (!strcmp(ipcop_colours_text[i], networks[j].colour)) { + if (i == networks[j].colour) { used = 1; } } @@ -526,17 +526,23 @@ if ((rc == 0) || (rc == 1)) { changed_config = 1; if (!strcmp(colourchoices[choice], gettext("TR_NOT_USED"))) { - if (strcmp(networks[n].colour, ipcop_colours_text[CFG_COLOURS_COUNT - 1])) { - updatesettings(networks[n].colour, -1); + if (networks[n].colour != NONE) { + updatesettings(ipcop_colours_text[networks[n].colour], -1); } - strcpy(networks[n].colour, ipcop_colours_text[CFG_COLOURS_COUNT - 1]); + networks[n].colour = NONE; } else { - if (strcmp(networks[n].colour, ipcop_colours_text[CFG_COLOURS_COUNT - 1])) { - updatesettings(networks[n].colour, -1); + if (networks[n].colour != NONE) { + updatesettings(ipcop_colours_text[networks[n].colour], -1); } - strcpy(networks[n].colour, colourchoices[choice]); - updatesettings(networks[n].colour, n); + + /* since choices is a selected list of colours, we cannot directly correlate numeric choice to a colour */ + for (i = 0; i < CFG_COLOURS_COUNT - 1; i++) { + if (!strcmp(ipcop_colours_text[i], colourchoices[choice])) { + networks[n].colour = i; + updatesettings(ipcop_colours_text[networks[n].colour], n); + } + } } } @@ -556,6 +562,7 @@ int counter = 1; char command[STRING_SIZE]; char device[STRING_SIZE]; + char key[STRING_SIZE]; FILE *fscript = NULL; if (flag_installer) { @@ -570,25 +577,14 @@ /* set the device names with the help of udev */ for (i = 0; i < numnetwork; i++) { if (networks[i].address[0]) { - if (!strcmp(networks[i].colour, ipcop_colours_text[NONE])) { - snprintf(device, STRING_SIZE, "unused_%d", counter++); + if (networks[i].colour == NONE) { + snprintf(device, STRING_SIZE, "%s-%d", ipcop_aliases_text[NONE], counter++); } - else if (!strcmp(networks[i].colour, ipcop_colours_text[GREEN])) { - strcpy(device, "lan_1"); - update_kv(ð_kv, "GREEN_1_DEV", "lan_1"); + else { + snprintf(device, STRING_SIZE, "%s-%d", ipcop_aliases_text[networks[i].colour], 1); + snprintf(key, STRING_SIZE, "%s_%d_DEV", ipcop_colours_text[networks[i].colour], 1); + update_kv(ð_kv, key, device); } - else if (!strcmp(networks[i].colour, ipcop_colours_text[RED])) { - strcpy(device, "wan_1"); - update_kv(ð_kv, "RED_1_DEV", "wan_1"); - } - else if (!strcmp(networks[i].colour, ipcop_colours_text[BLUE])) { - strcpy(device, "wlan_1"); - update_kv(ð_kv, "BLUE_1_DEV", "wlan_1"); - } - else if (!strcmp(networks[i].colour, ipcop_colours_text[ORANGE])) { - strcpy(device, "dmz_1"); - update_kv(ð_kv, "ORANGE_1_DEV", "dmz_1"); - } snprintf(command, STRING_SIZE, "/bin/sed -i -e 's#\\(%s\\)\\(.*\\)NAME=\".*\"#\\1\\2NAME=\"%s\"#g' %s", networks[i].address, device, @@ -614,7 +610,7 @@ { char *values[] = { NULL, NULL }; /* pointers for the values. */ struct newtWinEntry entries[] = - { { "", &values[0], 0,}, { NULL, NULL, 0 } }; + { { "", (const char **) &values[0], 0,}, { NULL, NULL, 0 } }; int rc; int done; @@ -692,10 +688,10 @@ char line[STRING_SIZE]; /* set first unused card as default choice */ - if ((choice == -1) && !strcmp(networks[i].colour, "----")) { + if ((choice == -1) && (networks[i].colour == NONE)) { choice = count; } - snprintf(line, STRING_SIZE, "%-60.60s (%s)", networks[i].description, networks[i].colour); + snprintf(line, STRING_SIZE, "%-60.60s (%s)", networks[i].description, ipcop_colours_text[networks[i].colour]); cardchoices[count++] = strdup(line); } cardchoices[count] = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2009-01-25 15:08:51
|
Revision: 2382 http://ipcop.svn.sourceforge.net/ipcop/?rev=2382&view=rev Author: owes Date: 2009-01-25 15:08:44 +0000 (Sun, 25 Jan 2009) Log Message: ----------- Add a notice (to myself) Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2009-01-25 14:41:41 UTC (rev 2381) +++ ipcop/trunk/src/installer/networking.c 2009-01-25 15:08:44 UTC (rev 2382) @@ -879,6 +879,8 @@ error = 1; } + // TODO: additional network mask validation + if (error) { errorbox(message); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2009-02-12 17:08:18
|
Revision: 2466 http://ipcop.svn.sourceforge.net/ipcop/?rev=2466&view=rev Author: owes Date: 2009-02-12 17:08:10 +0000 (Thu, 12 Feb 2009) Log Message: ----------- Add test for green/red in networking config Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2009-02-12 10:51:36 UTC (rev 2465) +++ ipcop/trunk/src/installer/networking.c 2009-02-12 17:08:10 UTC (rev 2466) @@ -696,6 +696,7 @@ } cardchoices[count] = NULL; + /* TODO: we probably need an option to bail out, without changing anything here */ rc = newtWinMenu(gettext("TR_CARD_ASSIGNMENT"), gettext("TR_CARD_ASSIGNMENT_LONG"), 65, 5, 5, 11, cardchoices, &choice, gettext("TR_OK"), gettext("TR_MANUAL"), gettext("TR_QUIT"), NULL); @@ -713,8 +714,30 @@ manuallist(); break; case 3: - /* owes: ToDo test if we have green and possibly red here */ + /* Do we have GREEN ? */ + for (i = 0, count = 0; i < numnetwork && !count; i++) { + if (networks[i].colour == GREEN) { + count++; + } + } + if (!count) { + errorbox(gettext("TR_NO_GREEN_INTERFACE")); + break; + } + if (strcmp(kv_red_type, "ANALOG") && strcmp(kv_red_type, "ISDN")) { + /* Do we have RED ? */ + for (i = 0, count = 0; i < numnetwork && !count; i++) { + if (networks[i].colour == RED) { + count++; + } + } + if (!count) { + errorbox(gettext("TR_NO_RED_INTERFACE")); + break; + } + } + if (changed_config) { udevconfig(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2009-02-21 22:56:02
|
Revision: 2515 http://ipcop.svn.sourceforge.net/ipcop/?rev=2515&view=rev Author: owes Date: 2009-02-21 22:01:46 +0000 (Sat, 21 Feb 2009) Log Message: ----------- Choose some better text for buttons when assigning colour to card. Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2009-02-21 21:59:44 UTC (rev 2514) +++ ipcop/trunk/src/installer/networking.c 2009-02-21 22:01:46 UTC (rev 2515) @@ -17,7 +17,7 @@ * along with IPCop; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * (c) 2007-2008, the IPCop team + * (c) 2007-2009, the IPCop team * * $Id$ * @@ -521,7 +521,7 @@ choice = 0; rc = newtWinMenu(gettext("TR_CARD_ASSIGNMENT"), - info, 65, 5, 5, 11, colourchoices, &choice, gettext("TR_OK"), gettext("TR_QUIT"), NULL); + info, 65, 5, 5, 11, colourchoices, &choice, gettext("TR_OK"), gettext("TR_CANCEL"), NULL); if ((rc == 0) || (rc == 1)) { changed_config = 1; @@ -699,7 +699,7 @@ /* TODO: we probably need an option to bail out, without changing anything here */ rc = newtWinMenu(gettext("TR_CARD_ASSIGNMENT"), gettext("TR_CARD_ASSIGNMENT_LONG"), 65, 5, 5, 11, - cardchoices, &choice, gettext("TR_OK"), gettext("TR_MANUAL"), gettext("TR_QUIT"), NULL); + cardchoices, &choice, gettext("TR_ASSIGN"), gettext("TR_MANUAL"), gettext("TR_QUIT"), NULL); for (i = 0; i < numnetwork; i++) { free(cardchoices[i]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2009-03-01 22:11:07
|
Revision: 2543 http://ipcop.svn.sourceforge.net/ipcop/?rev=2543&view=rev Author: owes Date: 2009-03-01 22:10:53 +0000 (Sun, 01 Mar 2009) Log Message: ----------- There is little point in trying to configure DHCP server in setup. Just keep DHCP server configuration for use during installation, to get a minimal config up and running if so required. Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2009-03-01 21:41:21 UTC (rev 2542) +++ ipcop/trunk/src/installer/networking.c 2009-03-01 22:10:53 UTC (rev 2543) @@ -1109,9 +1109,8 @@ menuchoices[1] = gettext("TR_DRIVERS_AND_CARD_ASSIGNMENTS"); menuchoices[2] = gettext("TR_ADDRESS_SETTINGS"); menuchoices[3] = gettext("TR_DNS_AND_GATEWAY_SETTINGS"); - menuchoices[4] = gettext("TR_DHCP_SERVER_CONFIGURATION"); - menuchoices[5] = NULL; + menuchoices[4] = NULL; changed_config = 0; changed_type = 0; @@ -1222,11 +1221,6 @@ case 3: changednsgateway(); break; - case 4: - /* DHCP server needs settings file */ - write_kv_to_file(ð_kv, "/var/ipcop/ethernet/settings"); - changedhcpserver(); - break; default: break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ges...@us...> - 2009-04-04 10:07:57
|
Revision: 2664 http://ipcop.svn.sourceforge.net/ipcop/?rev=2664&view=rev Author: gespinasse Date: 2009-04-04 10:07:55 +0000 (Sat, 04 Apr 2009) Log Message: ----------- Fix for the incorrect gcc workaround was missing there Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2009-04-04 07:24:51 UTC (rev 2663) +++ ipcop/trunk/src/installer/networking.c 2009-04-04 10:07:55 UTC (rev 2664) @@ -772,7 +772,7 @@ numLines = newtTextboxGetNumLines(text); /* workaround gcc warning, there is really 1 %s there */ - snprintf(tmpstring, STRING_SIZE, gettext("TR_INTERFACE")); + tmpstring = strdup(gettext("TR_INTERFACE")); snprintf(message, STRING_SIZE, tmpstring, "RED"); newtCenteredWindow(72, 9 + numLines, message); networkform = newtForm(NULL, NULL, 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ges...@us...> - 2009-04-04 15:14:03
|
Revision: 2665 http://ipcop.svn.sourceforge.net/ipcop/?rev=2665&view=rev Author: gespinasse Date: 2009-04-04 15:13:57 +0000 (Sat, 04 Apr 2009) Log Message: ----------- Fix the compilation error and free the pointer after usage Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2009-04-04 10:07:55 UTC (rev 2664) +++ ipcop/trunk/src/installer/networking.c 2009-04-04 15:13:57 UTC (rev 2665) @@ -390,10 +390,10 @@ /* workaround gcc warning, there is really 1 %s there */ tmpstring = strdup(gettext("TR_INTERFACE")); snprintf(message, STRING_SIZE, tmpstring, "RED"); + free(tmpstring); newtCenteredWindow(72, 14 + numLines, message); networkform = newtForm(NULL, NULL, 0); newtFormAddComponent(networkform, text); - free(tmpstring); /* No point in translating all */ char *radio_text[CFG_RED_COUNT] = @@ -765,7 +765,7 @@ const char *dhcphostnameresult; int error; int numLines; - char tmpstring[STRING_SIZE]; + char *tmpstring; snprintf(message, STRING_SIZE_LARGE, gettext("TR_DHCP_HOSTNAME_LONG")); text = newtTextboxReflowed(1, 1, message, 68, 0, 0, 0); @@ -774,6 +774,7 @@ /* workaround gcc warning, there is really 1 %s there */ tmpstring = strdup(gettext("TR_INTERFACE")); snprintf(message, STRING_SIZE, tmpstring, "RED"); + free(tmpstring); newtCenteredWindow(72, 9 + numLines, message); networkform = newtForm(NULL, NULL, 0); newtFormAddComponent(networkform, text); @@ -857,15 +858,14 @@ snprintf(message, STRING_SIZE, tmpstring, colour); text = newtTextboxReflowed(1, 1, message, 68, 0, 0, 0); numLines = newtTextboxGetNumLines(text); - free(tmpstring); /* workaround gcc warning, there is really 1 %s there */ tmpstring = strdup(gettext("TR_INTERFACE")); snprintf(message, STRING_SIZE, tmpstring, colour); + free(tmpstring); newtCenteredWindow(72, 10 + numLines, message); networkform = newtForm(NULL, NULL, 0); newtFormAddComponent(networkform, text); - free(tmpstring); /* Address */ addresslabel = newtTextbox(2, 2 + numLines, 18, 1, 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2009-04-28 18:45:10
|
Revision: 2752 http://ipcop.svn.sourceforge.net/ipcop/?rev=2752&view=rev Author: owes Date: 2009-04-28 18:45:09 +0000 (Tue, 28 Apr 2009) Log Message: ----------- Add a small sleep to avoid crash when configuring onboard NIC on Netvista Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2009-04-28 13:16:21 UTC (rev 2751) +++ ipcop/trunk/src/installer/networking.c 2009-04-28 18:45:09 UTC (rev 2752) @@ -31,6 +31,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include <netinet/in.h> #include <arpa/inet.h> #include "common.h" @@ -449,6 +450,10 @@ /* make the card blink during selection if supported */ snprintf(command, STRING_SIZE, "/sbin/ifconfig %s up", networks[n].device); mysystem(command); + /* On a Netvista with onboard NIC (8086:103b, e100 driver) network setup crashes (as in stuck, nothing working) + if we do not give some time here. Do not know why, but I guess it does not hurt to do a little sleep here. + With 1.4.20 we do not need this sleep, but things are different now. */ + sleep(1); snprintf(command, STRING_SIZE, "/usr/sbin/ethtool -p %s &", networks[n].device); mysystem(command); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2009-06-04 18:07:33
|
Revision: 2971 http://ipcop.svn.sourceforge.net/ipcop/?rev=2971&view=rev Author: owes Date: 2009-06-04 18:07:24 +0000 (Thu, 04 Jun 2009) Log Message: ----------- Only allow RED IP address config when RED is static Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2009-06-04 18:06:22 UTC (rev 2970) +++ ipcop/trunk/src/installer/networking.c 2009-06-04 18:07:24 UTC (rev 2971) @@ -799,6 +799,10 @@ choice = 0; for (i = 0; i < CFG_COLOURS_COUNT; i++) { + if ((i == RED) && strcmp(kv_red_type, "STATIC")) { + /* Skip RED if it is not set to STATIC */ + continue; + } snprintf(key, STRING_SIZE, "%s_1_DEV", ipcop_colours_text[i]); strcpy(keyvalue, ""); find_kv_default(eth_kv, key, keyvalue); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2009-06-06 21:48:56
|
Revision: 2985 http://ipcop.svn.sourceforge.net/ipcop/?rev=2985&view=rev Author: owes Date: 2009-06-06 21:48:26 +0000 (Sat, 06 Jun 2009) Log Message: ----------- This should fix installation of ISA NICs. ISA NICs can be selected from a list, but after a successful modprobe the result would be ignored as the ISA NIC (obviously) does not appear in our HW detected list. This is not tested, as my test box with ISA slots is having timing problems while booting :-/ Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2009-06-06 21:37:38 UTC (rev 2984) +++ ipcop/trunk/src/installer/networking.c 2009-06-06 21:48:26 UTC (rev 2985) @@ -142,7 +142,7 @@ /* Modprobe some module, then look for new network device(s) or look for already present network device(s) without modprobing */ -static int probecard(char *module, char *options, int error) +static int probecard(char *module, char *description, char *options, int error) { char command[STRING_SIZE]; struct dirent **scndir; @@ -210,6 +210,23 @@ fprintf(flog, " hwlist %s device %s MAC %s\n", module, networks[i].device, networks[i].address); } } + + /* After modprobe and scanning through our list of detected HW, we are still left with a NIC + This can be ISA NIC or manually modprobed (multiple NICS possible?) */ + while ((j < newcards) && (description != NULL)) { + + networks = realloc(networks, sizeof(struct network_s) * (numnetwork + 1)); + networks[numnetwork].module = strdup(module); + networks[numnetwork].options = strdup(options); + networks[numnetwork].device = strdup(scndir[j]->d_name); + networks[numnetwork].description = strdup(description); + networks[numnetwork].colour = NONE; + networks[numnetwork].address = strdup(getmac(networks[i].device)); + fprintf(flog, " hwlist (ISA/manual) %s device %s MAC %s\n", module, networks[numnetwork].device, networks[numnetwork].address); + + numnetwork++; + j++; + } } if (j < newcards) { @@ -290,11 +307,12 @@ } /* scan for any network interfaces already present (autoloaded by udev magic) */ - probecard(NULL, "", 0); + probecard(NULL, NULL, "", 0); + /* modprobe cards found by hardware detection */ for (i = 0; i < numnetwork; i++) { if (!networks[i].device[0]) { - probecard(networks[i].module, "", 0); + probecard(networks[i].module, NULL, "", 0); } } } @@ -574,11 +592,11 @@ if ((ptr = strchr(values[0], ' ')) != NULL) { *ptr = 0; - done = (probecard(values[0], ptr+1, 1) == SUCCESS); + done = (probecard(values[0], "Unknown card", ptr+1, 1) == SUCCESS); } else { - done = (probecard(values[0], "", 1) == SUCCESS); + done = (probecard(values[0], "Unknown card", "", 1) == SUCCESS); } } else { @@ -607,7 +625,7 @@ addmanual(); } else { - done = (probecard(isa_nics_module[choice], "", 1) == SUCCESS); + done = (probecard(isa_nics_module[choice], isa_nics_description[choice], "", 1) == SUCCESS); } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2009-06-07 21:38:21
|
Revision: 2999 http://ipcop.svn.sourceforge.net/ipcop/?rev=2999&view=rev Author: owes Date: 2009-06-07 21:38:17 +0000 (Sun, 07 Jun 2009) Log Message: ----------- Fix a typo and handle ISA/manual slightly better. I can add 3c509 and ne more or less successfully. There is one problem left with ISA <-> udev. ISA cards do not seem to completely propagate through the udev rules, so there is no entry in 70-persistent-net and also our interface renaming is not possible. Will have to ask udev upstream about ISA cards ... Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2009-06-07 18:14:13 UTC (rev 2998) +++ ipcop/trunk/src/installer/networking.c 2009-06-07 21:38:17 UTC (rev 2999) @@ -221,7 +221,7 @@ networks[numnetwork].device = strdup(scndir[j]->d_name); networks[numnetwork].description = strdup(description); networks[numnetwork].colour = NONE; - networks[numnetwork].address = strdup(getmac(networks[i].device)); + networks[numnetwork].address = strdup(getmac(networks[numnetwork].device)); fprintf(flog, " hwlist (ISA/manual) %s device %s MAC %s\n", module, networks[numnetwork].device, networks[numnetwork].address); numnetwork++; @@ -231,6 +231,8 @@ if (j < newcards) { fprintf(flog, " some stray modprobe?\n"); + + /* Should remember these, because a next probecard() might assign this stray one to a wrong driver */ } return SUCCESS; } @@ -567,8 +569,10 @@ } -/* window with field for module and options */ -static void addmanual(void) +/* Window with field for module and options + Return SUCCESS if we modprobe'd a module and have an additional interface +*/ +static int addmanual(void) { char *values[] = { NULL, NULL }; /* pointers for the values. */ struct newtWinEntry entries[] = @@ -576,9 +580,9 @@ int rc; int done; - done = 0; + done = FAILURE; - while (done == 0) { + while (done == FAILURE) { rc = newtWinEntries(gettext("TR_SELECT_NETWORK_DRIVER"), gettext("TR_MODULE_PARAMETERS"), 50, 5, 5, 40, entries, gettext("TR_OK"), gettext("TR_GO_BACK"), NULL); @@ -591,16 +595,27 @@ } if ((ptr = strchr(values[0], ' ')) != NULL) { + /* module and option, copy first so we can reuse the edit field (values[0]) in case of error */ + char *modulewithoption = strdup(values[0]); + ptr = strchr(modulewithoption, ' '); *ptr = 0; - done = (probecard(values[0], "Unknown card", ptr+1, 1) == SUCCESS); + done = probecard(modulewithoption, "Unknown card", ptr+1, 1); + free(modulewithoption); + if (done == SUCCESS) { + return SUCCESS; + } } else { - done = (probecard(values[0], "Unknown card", "", 1) == SUCCESS); + done = probecard(values[0], "Unknown card", "", 1); + if (done) { + return SUCCESS; + } } } else { - done = 1; /* canceled by user */ + done = 1; + return FAILURE; /* canceled by user */ } } } @@ -622,7 +637,8 @@ if ((rc == 0) || (rc == 1)) { if (choice == 0) { - addmanual(); + /* If manual addition succeeded, return directly to the list of interfaces */ + done = (addmanual() == SUCCESS); } else { done = (probecard(isa_nics_module[choice], isa_nics_description[choice], "", 1) == SUCCESS); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2009-06-23 22:35:52
|
Revision: 3112 http://ipcop.svn.sourceforge.net/ipcop/?rev=3112&view=rev Author: owes Date: 2009-06-23 11:18:20 +0000 (Tue, 23 Jun 2009) Log Message: ----------- Change one 'OK' button into 'Done' Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2009-06-23 06:51:36 UTC (rev 3111) +++ ipcop/trunk/src/installer/networking.c 2009-06-23 11:18:20 UTC (rev 3112) @@ -680,7 +680,7 @@ /* TODO: we probably need an option to bail out, without changing anything here */ rc = newtWinMenu(gettext("TR_CARD_ASSIGNMENT"), gettext("TR_CARD_ASSIGNMENT_LONG"), 65, 5, 5, 11, - cardchoices, &choice, gettext("TR_SELECT"), gettext("TR_MANUAL"), gettext("TR_OK"), NULL); + cardchoices, &choice, gettext("TR_SELECT"), gettext("TR_MANUAL"), gettext("TR_DONE"), NULL); for (i = 0; i < numnetwork; i++) { free(cardchoices[i]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2009-06-27 11:57:54
|
Revision: 3135 http://ipcop.svn.sourceforge.net/ipcop/?rev=3135&view=rev Author: owes Date: 2009-06-27 11:57:51 +0000 (Sat, 27 Jun 2009) Log Message: ----------- In case there are multiple, slightly different cards using the same kernelmodule, the NIC list can show wrong descriptions, which can confuse the user. Use the vendor and device ID, when available, to fix that. Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2009-06-27 11:31:44 UTC (rev 3134) +++ ipcop/trunk/src/installer/networking.c 2009-06-27 11:57:51 UTC (rev 3135) @@ -176,14 +176,33 @@ /* walk thru all interfaces and try to match to our information list */ for (i = 0, j = 0; (i < newcards); i++) { + int found = 0; char *kernelmodule = getkernelmodule(scndir[i]->d_name); + /* First match on Vendor and Device ID (if present) */ + fprintf(flog, " %s %s %s %s\n", scndir[i]->d_name, kernelmodule, vendorid_buffer, deviceid_buffer); + if ((strlen(vendorid_buffer) > 0) && (strlen(deviceid_buffer) > 0)) { + for (k = 0; !found && (k < numnetwork); k++) { + if (!networks[k].device[0] && + (strlen(networks[k].vendorid) > 0) && !strcmp(networks[k].vendorid, vendorid_buffer) && + (strlen(networks[k].modelid) > 0) && !strcmp(networks[k].modelid, deviceid_buffer)) { + free(networks[k].device); + networks[k].device = strdup(scndir[i]->d_name); + networks[k].address = strdup(getmac(networks[k].device)); + fprintf(flog, " hwlist %s device %s MAC %s\n", + networks[k].module, networks[k].device, networks[k].address); + found = 1; + j++; + } + } + } + if (!kernelmodule[0]) { fprintf(flog, " no kernel module found for device %s\n", scndir[i]->d_name); continue; } - for (k = 0; (k < numnetwork); k++) { + for (k = 0; !found && (k < numnetwork); k++) { if (!networks[k].device[0] && !strcmp(kernelmodule, networks[k].module)) { free(networks[k].device); networks[k].device = strdup(scndir[i]->d_name); @@ -262,6 +281,8 @@ networks[numnetwork].description = hardwares[i].description; networks[numnetwork].colour = NONE; networks[numnetwork].address = strdup(""); + networks[numnetwork].vendorid = hardwares[i].vendorid; + networks[numnetwork].modelid = hardwares[i].modelid; numnetwork++; } @@ -282,15 +303,37 @@ c = atoi(find_kv(eth_kv, key)); for (j = 1; j <= c; j++) { + int found = 0; + /* Test if the configured device is still present */ snprintf(key, STRING_SIZE, "%s_%d_DEV", ipcop_colours_text[i], j); if (exist_ethernet_device(find_kv(eth_kv, key)) == FAILURE) { continue; } + /* Check for Vendor / Device ID first */ + getkernelmodule(find_kv(eth_kv, key)); + if ((strlen(vendorid_buffer) > 0) && (strlen(deviceid_buffer) > 0)) { + for (n = 0; !found && (n < numnetwork); n++) { + if (!networks[n].device[0] && + (strlen(networks[n].vendorid) > 0) && !strcmp(networks[n].vendorid, vendorid_buffer) && + (strlen(networks[n].modelid) > 0) && !strcmp(networks[n].modelid, deviceid_buffer)) { + /* 6,5,4,3,2,1 meins */ + networks[n].colour = i; + snprintf(key, STRING_SIZE, "%s_%d_DEV", ipcop_colours_text[i], j); + networks[n].device = strdup(find_kv(eth_kv, key)); + + /* owes: copy driver options here */ + + /* find MAC address */ + networks[n].address = strdup(getmac(networks[n].device)); + found = 1; + } + } + } + snprintf(key, STRING_SIZE, "%s_%d_DRIVER", ipcop_colours_text[i], j); - - for (n = 0; n < numnetwork; n++) { + for (n = 0; !found && (n < numnetwork); n++) { if (!networks[n].device[0] && (find_kv(eth_kv, key) != NULL) && !strcmp(networks[n].module, find_kv(eth_kv, key))) { /* 3,2,1 meins */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2009-07-29 15:10:21
|
Revision: 3351 http://ipcop.svn.sourceforge.net/ipcop/?rev=3351&view=rev Author: owes Date: 2009-07-29 15:10:11 +0000 (Wed, 29 Jul 2009) Log Message: ----------- Minor change in the Add Card Manually logic Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2009-07-29 15:06:44 UTC (rev 3350) +++ ipcop/trunk/src/installer/networking.c 2009-07-29 15:10:11 UTC (rev 3351) @@ -621,11 +621,8 @@ struct newtWinEntry entries[] = { { "", (const char **) &values[0], 0,}, { NULL, NULL, 0 } }; int rc; - int done; - done = FAILURE; - - while (done == FAILURE) { + while (1) { rc = newtWinEntries(gettext("TR_SELECT_NETWORK_DRIVER"), gettext("TR_MODULE_PARAMETERS"), 50, 5, 5, 40, entries, gettext("TR_OK"), gettext("TR_GO_BACK"), NULL); @@ -642,22 +639,21 @@ char *modulewithoption = strdup(values[0]); ptr = strchr(modulewithoption, ' '); *ptr = 0; - done = probecard(modulewithoption, "Unknown card", ptr+1, 1); + rc = probecard(modulewithoption, "Unknown card", ptr+1, 1); free(modulewithoption); - if (done == SUCCESS) { + if (rc == SUCCESS) { return SUCCESS; } } else { - done = probecard(values[0], "Unknown card", "", 1); - if (done) { + rc = probecard(values[0], "Unknown card", "", 1); + if (rc) { return SUCCESS; } } } else { - done = 1; return FAILURE; /* canceled by user */ } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ow...@us...> - 2009-08-01 18:24:46
|
Revision: 3385 http://ipcop.svn.sourceforge.net/ipcop/?rev=3385&view=rev Author: owes Date: 2009-08-01 18:24:31 +0000 (Sat, 01 Aug 2009) Log Message: ----------- Add a TODO comment. If we remove a card with another, we end up with double references in udev persistent-net. This can be become a problem if we re-add the removed card later. To handle that we will need to tweak persistent-net for the removed card(s). Modified Paths: -------------- ipcop/trunk/src/installer/networking.c Modified: ipcop/trunk/src/installer/networking.c =================================================================== --- ipcop/trunk/src/installer/networking.c 2009-08-01 18:21:50 UTC (rev 3384) +++ ipcop/trunk/src/installer/networking.c 2009-08-01 18:24:31 UTC (rev 3385) @@ -634,6 +634,11 @@ } else { mysystem(command); + + /* + TODO: Hunt for other cards that have a udev entry for this device. + This applies to cards that were present at on stage but have now been removed from the box + */ } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |