extern int automode;
+#define HAS_GREEN 1
#define HAS_ORANGE (configtype == 1 || configtype == 3 || configtype == 5 || configtype == 7)
#define HAS_RED (configtype == 2 || configtype == 3 || configtype == 6 || configtype == 7)
#define HAS_BLUE (configtype == 4 || configtype == 5 || configtype == 6 || configtype == 7)
#define RED_IS_NOT_ETH (configtype == 0 || configtype == 1 || configtype == 4 || configtype == 5)
extern struct nic nics[];
+extern struct knic knics[];
char *configtypenames[] = {
"GREEN (RED is modem/ISDN)",
ctr[TR_PUSHING_NETWORK_DOWN]);
runcommandwithstatus("/etc/rc.d/init.d/network start",
ctr[TR_PULLING_NETWORK_UP]);
-// mysystem("/etc/rc.d/rc.pcmcia start");
}
}
if (rc == 0 || rc == 1)
{
- runcommandwithstatus("/etc/rc.d/init.d/network red down",
- ctr[TR_PUSHING_NON_LOCAL_NETWORK_DOWN]);
- runcommandwithstatus("/etc/rc.d/init.d/network blue down",
- ctr[TR_PUSHING_NON_LOCAL_NETWORK_DOWN]);
- runcommandwithstatus("/etc/rc.d/init.d/network orange down",
+ runcommandwithstatus("/etc/rc.d/init.d/network stop red blue orange",
ctr[TR_PUSHING_NON_LOCAL_NETWORK_DOWN]);
sprintf(temp, "%d", choice);
int drivermenu(void)
{
struct keyvalue *kv = initkeyvalues();
- char message[1000];
- char temp[STRING_SIZE], temp1[STRING_SIZE];
- char driver[STRING_SIZE], dev[STRING_SIZE];
+ char message[STRING_SIZE];
+ char temp[STRING_SIZE];
+// char description[STRING_SIZE], macaddr[STRING_SIZE];
+// struct nic *pnics = nics;
+// pnics = nics;
+// struct knic *pknics = knics;
+// pknics = knics;
int configtype;
- int rc;
+ int rc, kcount = 0, found, neednics; //i = 0, count = 0,
+
+ fprintf(flog,"enter drivermenu\n"); // #### Debug ####
if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
{
strcpy(temp, "0"); findkey(kv, "CONFIG_TYPE", temp);
configtype = atol(temp);
- if (configtype == 0)
- {
- freekeyvalues(kv);
- errorbox(ctr[TR_YOUR_CONFIGURATION_IS_SINGLE_GREEN_ALREADY_HAS_DRIVER]);
- return 0;
- }
+// if (configtype == 0)
+// {
+// freekeyvalues(kv);
+// errorbox(ctr[TR_YOUR_CONFIGURATION_IS_SINGLE_GREEN_ALREADY_HAS_DRIVER]);
+// return 0;
+// }
strcpy(message, ctr[TR_CONFIGURE_NETWORK_DRIVERS]);
-
- /* This horrible big formats the heading :( */
- strcpy(driver, ""); findkey(kv, "GREEN_DISPLAYDRIVER", driver);
- findnicdescription(driver, temp);
- strcpy(dev, ctr[TR_UNSET]); findkey(kv, "GREEN_DEV", dev);
- if (!strlen(dev)) strcpy(dev, ctr[TR_UNSET]);
- sprintf(temp1, "GREEN: %s (%s)\n", temp, dev);
- strcat(message, temp1);
- if (HAS_BLUE)
- {
- strcpy(driver, ""); findkey(kv, "BLUE_DISPLAYDRIVER", driver);
- findnicdescription(driver, temp);
- strcpy(dev, ctr[TR_UNSET]); findkey(kv, "BLUE_DEV", dev);
- if (!strlen(dev)) strcpy(dev, ctr[TR_UNSET]);
- sprintf(temp1, "BLUE: %s (%s)\n", temp, dev);
- strcat(message, temp1);
+
+ found = scan_network_cards();
+ fprintf(flog,"found %d Card\'s\n", found ); // #### Debug ####
+ kcount = 0; // counter to find knowing nics.
+ neednics = 0; // counter to use needing nics.
+ if (HAS_GREEN) {
+ strcpy(temp, ""); findkey(kv, "GREEN_MACADDR", temp);
+ if (strlen(temp)) {
+ strcpy(knics[_GREEN_CARD_].macaddr, temp);
+ strcpy(knics[_GREEN_CARD_].colour, "GREEN");
+ findkey(kv, "GREEN_DESCRIPTION", temp);
+ strcpy(knics[_GREEN_CARD_].description, temp);
+ kcount++;
+ } else {
+ strcpy(knics[_GREEN_CARD_].description, ctr[TR_UNSET]);
+ }
+ sprintf(temp, "GREEN: %s\n", knics[_GREEN_CARD_].description);
+ strcat(message, temp);
+ if (strlen(knics[_GREEN_CARD_].macaddr) ) {
+ sprintf(temp, "GREEN: (%s) %s green0\n", knics[_GREEN_CARD_].macaddr, ctr[TR_AS]);
+ strcat(message, temp);
+ }
+ neednics++;
}
- if (HAS_ORANGE)
- {
- strcpy(driver, ""); findkey(kv, "ORANGE_DISPLAYDRIVER", driver);
- findnicdescription(driver, temp);
- strcpy(dev, ctr[TR_UNSET]); findkey(kv, "ORANGE_DEV", dev);
- if (!strlen(dev)) strcpy(dev, ctr[TR_UNSET]);
- sprintf(temp1, "ORANGE: %s (%s)\n", temp, dev);
- strcat(message, temp1);
+ if (HAS_RED) {
+ strcpy(temp, ""); findkey(kv, "RED_MACADDR", temp);
+ if (strlen(temp)) {
+ strcpy(knics[_RED_CARD_].macaddr, temp);
+ strcpy(knics[_RED_CARD_].colour, "RED");
+ findkey(kv, "RED_DESCRIPTION", temp);
+ strcpy(knics[_RED_CARD_].description, temp);
+ kcount++;
+ } else {
+ strcpy(knics[_RED_CARD_].description, ctr[TR_UNSET]);
+ }
+ sprintf(temp, "RED: %s\n", knics[_RED_CARD_].description);
+ strcat(message, temp);
+ if (strlen(knics[_RED_CARD_].macaddr) ) {
+ sprintf(temp, "RED: (%s) %s red0\n", knics[_RED_CARD_].macaddr, ctr[TR_AS]);
+ strcat(message, temp);
+ }
+ neednics++;
}
- if (HAS_RED)
- {
- strcpy(driver, ""); findkey(kv, "RED_DISPLAYDRIVER", driver);
- findnicdescription(driver, temp);
- strcpy(dev, ctr[TR_UNSET]); findkey(kv, "RED_DEV", dev);
- if (!strlen(dev)) strcpy(dev, ctr[TR_UNSET]);
- sprintf(temp1, "RED: %s (%s)\n", temp, dev);
- strcat(message, temp1);
+ if (HAS_ORANGE) {
+ strcpy(temp, ""); findkey(kv, "ORANGE_MACADDR", temp);
+ if (strlen(temp)) {
+ strcpy(knics[_ORANGE_CARD_].macaddr, temp);
+ strcpy(knics[_ORANGE_CARD_].colour, "ORANGE");
+ findkey(kv, "ORANGE_DESCRIPTION", temp );
+ strcpy(knics[_ORANGE_CARD_].description, temp );
+ kcount++;
+ } else {
+ strcpy(knics[_ORANGE_CARD_].description, ctr[TR_UNSET]);
+ }
+ sprintf(temp, "ORANGE: %s\n", knics[_ORANGE_CARD_].description);
+ strcat(message, temp);
+ if ( strlen(knics[_ORANGE_CARD_].macaddr) ) {
+ sprintf(temp, "ORANGE: (%s) %s orange0\n", knics[_ORANGE_CARD_].macaddr, ctr[TR_AS]);
+ strcat(message, temp);
+ }
+ neednics++;
}
- strcat(message, ctr[TR_DO_YOU_WISH_TO_CHANGE_THESE_SETTINGS]);
- rc = newtWinChoice(ctr[TR_DRIVERS_AND_CARD_ASSIGNMENTS], ctr[TR_OK],
+ if (HAS_BLUE) {
+ strcpy(temp, ""); findkey(kv, "BLUE_MACADDR", temp);
+ if (strlen(temp)) {
+ strcpy(knics[_BLUE_CARD_].macaddr, temp);
+ strcpy(knics[_BLUE_CARD_].colour, "BLUE");
+ findkey(kv, "BLUE_DESCRIPTION", temp );
+ strcpy(knics[_BLUE_CARD_].description, temp);
+ kcount++;
+ } else {
+ strcpy(knics[_BLUE_CARD_].description, ctr[TR_UNSET]);
+ }
+ sprintf(temp, "BLUE: %s\n", knics[_BLUE_CARD_].description);
+ strcat(message, temp);
+ if (strlen(knics[_BLUE_CARD_].macaddr)) {
+ sprintf(temp, "BLUE: (%s) %s blue0\n", knics[_BLUE_CARD_].macaddr, ctr[TR_AS]);
+ strcat(message, temp);
+ }
+ neednics++;
+ }
+
+ fprintf(flog,"found %d knowing Card\'s\n", kcount); // #### DEBUG ####
+
+ if (neednics = kcount) {
+ strcat(message, ctr[TR_DO_YOU_WISH_TO_CHANGE_THESE_SETTINGS]);
+ rc = newtWinChoice(ctr[TR_DRIVERS_AND_CARD_ASSIGNMENTS], ctr[TR_OK],
ctr[TR_CANCEL], message);
- if (rc == 0 || rc == 1)
- {
+ if (rc == 0 || rc == 1)
+ {
+ /* Shit, got to do something.. */
+ changedrivers();
+ }
+ } else {
+ strcat(message, "\nEs wurden noch nicht alle Netzwerkkarten konfiguriert.\n");
+ newtWinMessage(ctr[TR_DRIVERS_AND_CARD_ASSIGNMENTS], ctr[TR_OK], message);
/* Shit, got to do something.. */
changedrivers();
}
-
freekeyvalues(kv);
return 1;
}
+int cardassigned(char *colour)
+{
+ char command[STRING_SIZE];
+ fprintf(flog,"cardassigned - %s\n", colour);
+ sprintf(command, "grep -q %s < /etc/udev/rules.d/30-persistent-network.rules 2>/dev/null", colour);
+ if (system(command))
+ return 0;
+ else
+ return 1;
+}
+
int changedrivers(void)
{
struct keyvalue *kv = initkeyvalues();
- char message[1000];
- char temp[STRING_SIZE];
- char driver[STRING_SIZE];
+ char temp[STRING_SIZE], message[STRING_SIZE];
int configtype;
- int rc;
- int c;
- int needcards, sofarallocated, countofcards, toallocate;
- char *orange = "ORANGE";
- char *blue = "BLUE";
- char *red = "RED";
- char *sections[4];
- int choice;
- char nexteth[STRING_SIZE];
- int abort;
- char currentdriver[STRING_SIZE], currentdriveroptions[STRING_SIZE];
- char displaydriver[STRING_SIZE];
- struct stat st;
-
+ int green = 0, red = 0, blue = 0, orange = 0;
+ char MenuInhalt[10][180];
+ char *pMenuInhalt[10];
+ int count = 0, choise = 0, rc;
+ int NicEntry[10];
+
if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
{
freekeyvalues(kv);
errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
return 0;
}
-
- strcpy(temp, "0"); findkey(kv, "CONFIG_TYPE", temp);
- configtype = atol(temp);
-
- runcommandwithstatus("/etc/rc.d/init.d/network red down",
- ctr[TR_PUSHING_NON_LOCAL_NETWORK_DOWN]);
- runcommandwithstatus("/etc/rc.d/init.d/network blue down",
- ctr[TR_PUSHING_NON_LOCAL_NETWORK_DOWN]);
- runcommandwithstatus("/etc/rc.d/init.d/network orange down",
+ fprintf(flog,"stop network on red, blue and orange\n"); // #### Debug ####
+ runcommandwithstatus("/etc/rc.d/init.d/network stop red blue orange",
ctr[TR_PUSHING_NON_LOCAL_NETWORK_DOWN]);
-
- /* Remove all modules not needed for green networking. */
- c = 0;
- strcpy(driver, ""); findkey(kv, "GREEN_DRIVER", driver);
- if (strcmp(driver, "pcmcia") != 0) {
- stat("/proc/bus/pccard", &st);
- mysystem("/etc/rc.d/rc.pcmcia stop");
- if (S_ISDIR(st.st_mode)) {
- mysystem("/sbin/modprobe pcmcia_core");
- mysystem("/sbin/modprobe pcmcia-controller");
- mysystem("/sbin/modprobe ds");
- }
- }
- while (nics[c].modulename)
- {
- if (strcmp(nics[c].modulename, driver) != 0)
- {
- if (checkformodule(nics[c].modulename))
- {
- sprintf(temp, "/sbin/rmmod %s", nics[c].modulename);
- mysystem(temp);
- }
- }
- c++;
- }
-
- /* Blank them so the rc.netaddress.up does not get confused. */
- replacekeyvalue(kv, "ORANGE_DEV", "");
- replacekeyvalue(kv, "BLUE_DEV", "");
- replacekeyvalue(kv, "RED_DEV", "");
-
+
+ findkey(kv, "CONFIG_TYPE", temp); configtype = atol(temp);
if (configtype == 0)
- needcards = 1;
- else if (configtype == 1 || configtype == 2 || configtype == 4)
- needcards = 2;
+ { green = 1; }
+ else if (configtype == 1)
+ { green = 1; orange = 1; }
+ else if (configtype == 2)
+ { green = 1; red = 1; }
+ else if (configtype == 3)
+ { green = 1; red = 1; orange = 1; }
+ else if (configtype == 4)
+ { green = 1; blue = 1; }
+ else if (configtype == 5)
+ { green = 1; blue = 1; orange = 1; }
+ else if (configtype == 6)
+ { green = 1; red = 1; blue = 1; }
else if (configtype == 7)
- needcards = 4;
- else
- needcards = 3;
+ { green = 1; red = 1; blue = 1; orange = 1; }
- /* This is the green card. */
- sofarallocated = 1;
+ fprintf(flog,"found: g=%d r=%d o=%d b=%d\n",green, red, orange, blue); // #### Debug ####
- findkey(kv, "GREEN_DRIVER", currentdriver);
- findkey(kv, "GREEN_DRIVER_OPTIONS", currentdriveroptions);
- strcpy(displaydriver, currentdriver);
-
- if (countcards() > 1)
- strcpy(currentdriver, "");
-
- abort = 0;
- /* Keep going till all cards are got, or they give up. */
- while (sofarallocated < needcards && !abort)
+ do
{
- countofcards = countcards();
-
- /* This is how many cards were added by the last module. */
- toallocate = countofcards - sofarallocated;
- while (toallocate > 0 && sofarallocated < needcards)
- {
- findnicdescription(displaydriver, temp);
- sprintf(message, ctr[TR_UNCLAIMED_DRIVER], temp);
- c = 0; choice = 0;
- strcpy(temp, ""); findkey(kv, "BLUE_DEV", temp);
- if (HAS_BLUE && !strlen(temp))
- {
- sections[c] = blue;
- c++;
- }
- strcpy(temp, ""); findkey(kv, "ORANGE_DEV", temp);
- if (HAS_ORANGE && !strlen(temp))
- {
- sections[c] = orange;
- c++;
- }
- strcpy(temp, ""); findkey(kv, "RED_DEV", temp);
- if (HAS_RED && !strlen(temp))
- {
- sections[c] = red;
- c++;
+ count = 0;
+ strcpy(message, "(TR) Bitte wählen Sie das Interface aus das geaendert werden soll.\n\n");
+
+ if (green) {
+ strcpy(MenuInhalt[count], "GREEN");
+ pMenuInhalt[count] = MenuInhalt[count];
+ NicEntry[_GREEN_CARD_] = count;
+// fprintf(flog,"found: %s as entry %d\n", MenuInhalt[count], NicEntry[count]); // #### Debug ####
+ sprintf(temp, "GREEN: %s\n", knics[_GREEN_CARD_].description);
+ strcat(message, temp);
+ if ( strlen(knics[_GREEN_CARD_].macaddr) ) {
+ sprintf(temp, "GREEN: (%s) %s green0\n", knics[_GREEN_CARD_].macaddr, ctr[TR_AS]);
+ strcat(message, temp);
}
- sections[c] = NULL;
- rc = newtWinMenu(ctr[TR_CARD_ASSIGNMENT],
- message, 50, 5, 5, 6, sections, &choice, ctr[TR_OK],
- ctr[TR_CANCEL], NULL);
- if (rc == 0 || rc == 1)
- {
- /* Now we see which iface needs its settings changed. */
- sprintf(nexteth, "eth%d", sofarallocated);
- if (strcmp(sections[choice], blue) == 0)
- {
- replacekeyvalue(kv, "BLUE_DEV", nexteth);
- replacekeyvalue(kv, "BLUE_DRIVER", currentdriver);
- replacekeyvalue(kv, "BLUE_DRIVER_OPTIONS", currentdriveroptions);
- replacekeyvalue(kv, "BLUE_DISPLAYDRIVER", displaydriver);
- sofarallocated++;
- toallocate--;
- strcpy(currentdriver, "");
- strcpy(currentdriveroptions, "");
- }
- if (strcmp(sections[choice], orange) == 0)
- {
- replacekeyvalue(kv, "ORANGE_DEV", nexteth);
- replacekeyvalue(kv, "ORANGE_DRIVER", currentdriver);
- replacekeyvalue(kv, "ORANGE_DRIVER_OPTIONS", currentdriveroptions);
- replacekeyvalue(kv, "ORANGE_DISPLAYDRIVER", displaydriver);
- sofarallocated++;
- toallocate--;
- strcpy(currentdriver, "");
- strcpy(currentdriveroptions, "");
- }
- if (strcmp(sections[choice], red) == 0)
- {
- replacekeyvalue(kv, "RED_DEV", nexteth);
- replacekeyvalue(kv, "RED_DRIVER", currentdriver);
- replacekeyvalue(kv, "RED_DRIVER_OPTIONS", currentdriveroptions);
- replacekeyvalue(kv, "RED_DISPLAYDRIVER", displaydriver);
- sofarallocated++;
- toallocate--;
- strcpy(currentdriver, "");
- strcpy(currentdriveroptions, "");
- }
+ count++;
+ }
+
+ if (red) {
+ strcpy(MenuInhalt[count], "RED");
+ pMenuInhalt[count] = MenuInhalt[count];
+ NicEntry[_RED_CARD_] = count;
+// fprintf(flog,"found: %s as entry %d\n", MenuInhalt[count], NicEntry[count]); // #### Debug ####
+ sprintf(temp, "RED: %s\n", knics[_RED_CARD_].description);
+ strcat(message, temp);
+ if ( strlen(knics[_RED_CARD_].macaddr) ) {
+ sprintf(temp, "RED: (%s) %s red0\n", knics[_RED_CARD_].macaddr, ctr[TR_AS]);
+ strcat(message, temp);
}
- else
- {
- break;
+ count++;
+ }
+
+ if (orange) {
+ strcpy(MenuInhalt[count], "ORANGE");
+ pMenuInhalt[count] = MenuInhalt[count];
+ NicEntry[_ORANGE_CARD_] = count;
+// fprintf(flog,"found: %s as entry %d\n", MenuInhalt[count], NicEntry[count]); // #### Debug ####
+ sprintf(temp, "ORANGE: %s\n", knics[_ORANGE_CARD_].description);
+ strcat(message, temp);
+ if ( strlen(knics[_ORANGE_CARD_].macaddr) ) {
+ sprintf(temp, "ORANGE: (%s) %s orange0\n", knics[_ORANGE_CARD_].macaddr, ctr[TR_AS]);
+ strcat(message, temp);
}
+ count++;
}
-
- /* Need another module! The nitty gritty code is in libsmooth. */
- if (sofarallocated < needcards)
- {
- rc = newtWinTernary(ctr[TR_CARD_ASSIGNMENT], ctr[TR_PROBE],
- ctr[TR_SELECT], ctr[TR_CANCEL], ctr[TR_NO_UNALLOCATED_CARDS]);
-
- if (rc == 0 || rc == 1)
- {
- probecards(currentdriver, currentdriveroptions);
- if (!strlen(currentdriver))
- errorbox(ctr[TR_PROBE_FAILED]);
- }
- else if (rc == 2)
- choosecards(currentdriver, currentdriveroptions);
- else
- abort = 1;
-
- strcpy(displaydriver, currentdriver);
+
+ if (blue) {
+ strcpy(MenuInhalt[count], "BLUE");
+ pMenuInhalt[count] = MenuInhalt[count];
+ NicEntry[_BLUE_CARD_] = count;
+// fprintf(flog,"found: %s as entry %d\n", MenuInhalt[count], NicEntry[count]); // #### Debug ####
+ sprintf(temp, "BLUE: %s\n", knics[_BLUE_CARD_].description);
+ strcat(message, temp);
+ if ( strlen(knics[_BLUE_CARD_].macaddr) ) {
+ sprintf(temp, "BLUE: (%s) %s blue0\n", knics[_BLUE_CARD_].macaddr, ctr[TR_AS]);
+ strcat(message, temp);
+ }
+ count++;
}
- }
-
- countofcards = countcards();
+ pMenuInhalt[count] = NULL;
- if (countofcards >= needcards)
- {
- newtWinMessage(ctr[TR_CARD_ASSIGNMENT], ctr[TR_OK],
- ctr[TR_ALL_CARDS_SUCCESSFULLY_ALLOCATED]);
+ rc = newtWinMenu("(TR) Netcard Farbe", message, 70, 5, 5, 6, pMenuInhalt, &choise, ctr[TR_SELECT], "(TR) Entfernen" , ctr[TR_DONE], NULL);
+
+ if ( rc == 0 || rc == 1) {
+// write_configs_netudev(pnics[choise].description, pnics[choise].macaddr, colour);
+ // insert nic to colourcard
+ if ((green) && ( choise == NicEntry[0])) nicmenu("green");
+ if ((red) && ( choise == NicEntry[1])) nicmenu("red");
+ if ((orange) && ( choise == NicEntry[2])) nicmenu("orange");
+ if ((blue) && ( choise == NicEntry[3])) nicmenu("blue");
+ } else if (rc == 2) {
+ if ((green) && ( choise == NicEntry[0])) remove_nic_entry("green");
+ if ((red) && ( choise == NicEntry[1])) remove_nic_entry("red");
+ if ((orange) && ( choise == NicEntry[2])) remove_nic_entry("orange");
+ if ((blue) && ( choise == NicEntry[3])) remove_nic_entry("blue");
+ }
+// else {
+// errorbox("Sie haben keine Netzwerkkarte ausgewaehlt.\n");
+// return 1;
+// }
}
- else
- errorbox(ctr[TR_NOT_ENOUGH_CARDS_WERE_ALLOCATED]);
-
- writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
+ while ( rc <= 2);
+
+ // writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
freekeyvalues(kv);
-
- netaddresschange = 1;
-
return 1;
}
-/* Let user change GREEN address. */
+// Let user change GREEN address.
int greenaddressmenu(void)
{
struct keyvalue *kv = initkeyvalues();
return 0;
}
-/* They can change BLUE, ORANGE and GREEN too :) */
+// They can change BLUE, ORANGE and GREEN too :)
int addressesmenu(void)
{
struct keyvalue *kv = initkeyvalues();