]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/install+setup/setup/networking.c
Setup weiter ausgebaut.
[people/pmueller/ipfire-2.x.git] / src / install+setup / setup / networking.c
index 18f01d37d9dc7b89b81eab376de49406aff85052..6a2bb128fc3b8f43115456f91d60fbdbe838fb03 100644 (file)
@@ -6,8 +6,6 @@
  * (c) Lawrence Manning, 2001
  * The big one: networking. 
  * 
- * $Id: networking.c,v 1.5.2.6 2006/02/06 22:00:13 gespinasse Exp $
- * 
  */
  
 #include "setup.h"
@@ -24,23 +22,29 @@ extern char **ctr;
 
 extern int automode;
 
-#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)
+#define HAS_GREEN 1
+#define HAS_RED (configtype == 1 || configtype == 2 || configtype == 3 || configtype == 4)
+#define HAS_ORANGE (configtype == 2 || configtype == 4)
+#define HAS_BLUE (configtype == 3 || configtype == 4)
+#define RED_IS_NOT_ETH (configtype == 0)
 
 extern struct nic nics[];
+extern struct knic knics[];
 
-char *configtypenames[] = { 
-       "GREEN (RED is modem/ISDN)", 
-       "GREEN + ORANGE (RED is modem/ISDN)", 
+char *configtypenames[] = {
        "GREEN + RED",
-       "GREEN + ORANGE + RED", 
-       "GREEN + BLUE (RED is modem/ISDN) ",
-       "GREEN + ORANGE + BLUE (RED is modem/ISDN)",
-       "GREEN + BLUE + RED",
-       "GREEN + ORANGE + BLUE + RED",
+       "GREEN + RED + ORANGE",
+       "GREEN + RED + BLUE",
+       "GREEN + RED + ORANGE + BLUE",
        NULL };
+int configtypecards[] = {
+       2,      // "GREEN + RED",
+       3,      // "GREEN + RED + ORANGE",
+       3,      // "GREEN + RED + BLUE",
+       4         // "GREEN + RED + ORANGE + BLUE",
+};
+
+
 int netaddresschange;
 
 int oktoleave(char *errormessage);
@@ -56,10 +60,14 @@ int handlenetworking(void)
 {
        int done;
        int choice;
+       int found;
        char errormessage[STRING_SIZE];
        
        netaddresschange = 0;
 
+       found = scan_network_cards();
+       found = init_knics();
+
        done = 0;
        while (!done)
        {
@@ -102,12 +110,14 @@ int handlenetworking(void)
                {
                        runcommandwithstatus("/etc/rc.d/init.d/network stop",
                                ctr[TR_PUSHING_NETWORK_DOWN]);
+
+                       rename_nics();
+
                        runcommandwithstatus("/etc/rc.d/init.d/network start",
                                ctr[TR_PULLING_NETWORK_UP]);
-//                     mysystem("/etc/rc.d/rc.pcmcia start");
                }
        }
-       
+       create_udev();
        return 1;
 }
 
@@ -124,20 +134,34 @@ int oktoleave(char *errormessage)
                return 0;
        }       
 
-       strcpy(temp, "0"); findkey(kv, "CONFIG_TYPE", temp); configtype = atol(temp);
-       if (configtype < 0 || configtype > 7) configtype = 0;
+       strcpy(temp, "1"); findkey(kv, "CONFIG_TYPE", temp); configtype = atol(temp);
+       if (configtype < 1 || configtype > 4) configtype = 1;
 
-       if (HAS_BLUE)
+       if (HAS_GREEN)
        {
-               strcpy(temp, ""); findkey(kv, "BLUE_DEV", temp);
+               strcpy(temp, ""); findkey(kv, "GREEN_DEV", temp);
                if (!(strlen(temp)))
                {
-                       strcpy(errormessage, ctr[TR_NO_BLUE_INTERFACE]);
+                       strcpy(errormessage, ctr[TR_NO_GREEN_INTERFACE]);
                        goto EXIT;
                }
-               if (!(interfacecheck(kv, "BLUE")))
+               if (!(interfacecheck(kv, "GREEN")))
                {
-                       strcpy(errormessage, ctr[TR_MISSING_BLUE_IP]);
+                       strcpy(errormessage, ctr[TR_MISSING_GREEN_IP]);
+                       goto EXIT;
+               }
+       }
+       if (HAS_RED)
+       {
+               strcpy(temp, ""); findkey(kv, "RED_DEV", temp);
+               if (!(strlen(temp)))
+               {
+                       strcpy(errormessage, ctr[TR_NO_RED_INTERFACE]);
+                       goto EXIT;
+               }
+               if (!(interfacecheck(kv, "RED")))
+               {
+                       strcpy(errormessage, ctr[TR_MISSING_RED_IP]);
                        goto EXIT;
                }
        }
@@ -155,17 +179,32 @@ int oktoleave(char *errormessage)
                        goto EXIT;
                }
        }
-       if (HAS_RED)
+       if (HAS_BLUE)
        {
-               strcpy(temp, ""); findkey(kv, "RED_DEV", temp);
+               strcpy(temp, ""); findkey(kv, "BLUE_DEV", temp);
                if (!(strlen(temp)))
                {
-                       strcpy(errormessage, ctr[TR_NO_RED_INTERFACE]);
+                       strcpy(errormessage, ctr[TR_NO_BLUE_INTERFACE]);
                        goto EXIT;
                }
-               if (!(interfacecheck(kv, "RED")))
+               if (!(interfacecheck(kv, "BLUE")))
                {
-                       strcpy(errormessage, ctr[TR_MISSING_RED_IP]);
+                       strcpy(errormessage, ctr[TR_MISSING_BLUE_IP]);
+                       goto EXIT;
+               }
+       }
+       if (configtype == 0)
+       {
+               strcpy(temp, ""); findkey(kv, "DNS1", temp);
+               if (!(strlen(temp)))
+               {
+                       strcpy(errormessage, ctr[TR_MISSING_DNS]);
+                       goto EXIT;
+               }
+               strcpy(temp, ""); findkey(kv, "DEFAULT_GATEWAY", temp);
+               if (!(strlen(temp)))
+               {
+                       strcpy(errormessage, ctr[TR_MISSING_DEFAULT]);
                        goto EXIT;
                }
        }
@@ -191,7 +230,7 @@ int firstmenu(void)
        static int choice = 0;
        struct keyvalue *kv = initkeyvalues();
        char message[1000];
-       char temp[STRING_SIZE];
+       char temp[STRING_SIZE] = "1";
        int x;
        int result;
        char networkrestart[STRING_SIZE] = "";
@@ -206,8 +245,10 @@ int firstmenu(void)
        if (netaddresschange) 
                strcpy(networkrestart, ctr[TR_RESTART_REQUIRED]);
 
-       strcpy(temp, ""); findkey(kv, "CONFIG_TYPE", temp); x = atol(temp);
-       if (x < 0 || x > 7) x = 0;
+       strcpy(temp, ""); findkey(kv, "CONFIG_TYPE", temp); 
+       x = atol(temp);
+       x--;
+       if (x < 0 || x > 4) x = 0;
        /* Format heading bit. */
        snprintf(message, 1000, ctr[TR_CURRENT_CONFIG], configtypenames[x],
                networkrestart);
@@ -226,10 +267,10 @@ int firstmenu(void)
 int configtypemenu(void)
 {
        struct keyvalue *kv = initkeyvalues();
-       char temp[STRING_SIZE] = "0";
+       char temp[STRING_SIZE] = "1";
        char message[1000];
-       int choice;
-       int rc;
+       int choise, found;
+       int rc, configtype;
 
        if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
        {
@@ -237,30 +278,40 @@ int configtypemenu(void)
                errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
                return 0;
        }
+
+       found = scan_network_cards();
        
-       findkey(kv, "CONFIG_TYPE", temp); choice = atol(temp);
-       sprintf(message, ctr[TR_NETWORK_CONFIGURATION_TYPE_LONG], NAME);
-       rc = newtWinMenu(ctr[TR_NETWORK_CONFIGURATION_TYPE], message, 50, 5, 5,
-               6, configtypenames, &choice, ctr[TR_OK], ctr[TR_CANCEL], NULL);
+       findkey(kv, "CONFIG_TYPE", temp); choise = atol(temp);
+       choise--;
+
+       do
+       {
+               sprintf(message, ctr[TR_NETWORK_CONFIGURATION_TYPE_LONG], NAME);
+               rc = newtWinMenu(ctr[TR_NETWORK_CONFIGURATION_TYPE], message, 50, 5, 5,
+                       6, configtypenames, &choise, ctr[TR_OK], ctr[TR_CANCEL], NULL);
+               if ( configtypecards[choise] > found ) {
+                       sprintf(message, ctr[TR_NOT_ENOUGH_INTERFACES] , configtypecards[choise], found);
+                       errorbox(message);
+               }
+       }
+       while ( configtypecards[choise] > found);
 
        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",
-                       ctr[TR_PUSHING_NON_LOCAL_NETWORK_DOWN]);
-       
-               sprintf(temp, "%d", choice);
+               choise++;
+               sprintf(temp, "%d", choise);
                replacekeyvalue(kv, "CONFIG_TYPE", temp);
-               replacekeyvalue(kv, "ORANGE_DEV", "");
-               replacekeyvalue(kv, "BLUE_DEV", "");
-               replacekeyvalue(kv, "RED_DEV", "");
+               configtype = atol(temp);
+               if (!HAS_RED)
+                       clear_card_entry(_RED_CARD_);
+               if (!HAS_ORANGE)
+                       clear_card_entry(_ORANGE_CARD_);
+               if (!HAS_BLUE)
+                       clear_card_entry(_BLUE_CARD_);
+
                writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
                netaddresschange = 1;
        }
-       
        freekeyvalues(kv);
        
        return 0;
@@ -270,11 +321,11 @@ int configtypemenu(void)
 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] = "1";
+
        int configtype;
-       int rc;
+       int i, rc, kcount = 0, neednics;
 
        if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
        {
@@ -283,273 +334,188 @@ int drivermenu(void)
                return 0;
        }
 
-       strcpy(temp, "0"); findkey(kv, "CONFIG_TYPE", temp);
+       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;
-       }
-
        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);
+
+       kcount = 0;
+       neednics = 0;
+       if (HAS_GREEN) {
+               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) {
+               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) {
+               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],
-               ctr[TR_CANCEL], message);
-       if (rc == 0 || rc == 1)
+       if (HAS_BLUE) {
+               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++;
+       }
+
+       for ( i=0 ; i<4; i++)
+               if (strcmp(knics[i].macaddr, ""))
+                       kcount++;
+
+       if (neednics = kcount)
        {
-               /* Shit, got to do something.. */
+               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)
+               {
+                       changedrivers();
+               }
+       } else {
                changedrivers();
        }
-       
        freekeyvalues(kv);
 
        return 1;
 }
 
+int set_menu_entry_for(int *nr, int *card)
+{
+
+}
+
 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;
        }
+       if (automode == 0)
+               runcommandwithstatus("/etc/rc.d/init.d/network stop red blue orange",
+                       ctr[TR_PUSHING_NON_LOCAL_NETWORK_DOWN]);
 
-       strcpy(temp, "0"); findkey(kv, "CONFIG_TYPE", temp);
-       configtype = atol(temp);
+       findkey(kv, "CONFIG_TYPE", temp); configtype = atol(temp);
+       if (configtype == 1)
+               { green = 1; red = 1; }
+       else if (configtype == 2)
+               { green = 1; red = 1; orange = 1; }
+       else if (configtype == 3)
+               { green = 1; red = 1; blue = 1; }
+       else if (configtype == 4)
+               { green = 1; red=1; orange=1; blue = 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",
-               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)
+       do
        {
-               if (strcmp(nics[c].modulename, driver) != 0)
-               {
-                       if (checkformodule(nics[c].modulename))
-                       {
-                               sprintf(temp, "/sbin/rmmod %s", nics[c].modulename);
-                               mysystem(temp);
+               count = 0;
+               strcpy(message, ctr[TR_INTERFACE_CHANGE]);
+
+               if (green) {
+                       strcpy(MenuInhalt[count], "GREEN");
+                       pMenuInhalt[count] = MenuInhalt[count];
+                       NicEntry[_GREEN_CARD_] = count;
+                       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);
                        }
+                       count++;
                }
-               c++;
-       }
-       
-       /* Blank them so the rc.netaddress.up does not get confused. */
-       replacekeyvalue(kv, "ORANGE_DEV", "");
-       replacekeyvalue(kv, "BLUE_DEV", "");
-       replacekeyvalue(kv, "RED_DEV", "");
-       
-       if (configtype == 0)
-               needcards = 1;
-       else if (configtype == 1 || configtype == 2 || configtype == 4)
-               needcards = 2;
-       else if (configtype == 7)
-               needcards = 4;
-       else
-               needcards = 3;
 
-       /* This is the green card. */           
-       sofarallocated = 1;
-
-       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)
-       {
-               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++;
-                       }
-                       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, "");
-                               }
+               if (red) {
+                       strcpy(MenuInhalt[count], "RED");
+                       pMenuInhalt[count] = MenuInhalt[count];
+                       NicEntry[_RED_CARD_] = count;
+                       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;
+                       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;
+                       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( ctr[TR_NETCARD_COLOR], message, 70, 5, 5, 6, pMenuInhalt, &choise, ctr[TR_SELECT], ctr[TR_REMOVE], ctr[TR_DONE], NULL);
+                       
+               if ( rc == 0 || rc == 1) {
+                       if ((green) && ( choise == NicEntry[0])) nicmenu(_GREEN_CARD_);
+                       if ((red) && ( choise == NicEntry[1])) nicmenu(_RED_CARD_);
+                       if ((orange) && ( choise == NicEntry[2])) nicmenu(_ORANGE_CARD_);
+                       if ((blue) && ( choise == NicEntry[3])) nicmenu(_BLUE_CARD_);
+                       netaddresschange = 1;
+               } else if (rc == 2) {
+                       if ((green) && ( choise == NicEntry[0])) ask_clear_card_entry(_GREEN_CARD_);
+                       if ((red) && ( choise == NicEntry[1])) ask_clear_card_entry(_RED_CARD_);
+                       if ((orange) && ( choise == NicEntry[2])) ask_clear_card_entry(_ORANGE_CARD_);
+                       if ((blue) && ( choise == NicEntry[3])) ask_clear_card_entry(_BLUE_CARD_);
+                       netaddresschange = 1;
+               }
        }
-       else
-               errorbox(ctr[TR_NOT_ENOUGH_CARDS_WERE_ALLOCATED]);
-               
-       writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
+       while ( rc <= 2);
 
        freekeyvalues(kv);
-
-       netaddresschange = 1;
-       
        return 1;
 }
 
-/* Let user change GREEN address. */
+// Let user change GREEN address.
 int greenaddressmenu(void)
 {
        struct keyvalue *kv = initkeyvalues();
@@ -581,7 +547,7 @@ int greenaddressmenu(void)
        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();
@@ -719,16 +685,6 @@ int dnsgatewaymenu(void)
                return 0;
        }
 
-       strcpy(temp, "0"); findkey(kv, "CONFIG_TYPE", temp);
-       configtype = atol(temp);
-       
-       if (RED_IS_NOT_ETH)
-       {
-               freekeyvalues(kv);
-               errorbox(ctr[TR_DNS_GATEWAY_WITH_GREEN]);
-               return 0;
-       }
-
        entries[DNS1].text = ctr[TR_PRIMARY_DNS];
        strcpy(temp, ""); findkey(kv, "DNS1", temp);
        values[DNS1] = strdup(temp);