Neue Netzwerkdialoge sind zum ersten Test verfuegbar.
authorcasemaster <casemaster@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Wed, 2 May 2007 22:32:02 +0000 (22:32 +0000)
committercasemaster <casemaster@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Wed, 2 May 2007 22:32:02 +0000 (22:32 +0000)
git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@515 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8

langs/de/install/lang_de.c
langs/en/install/lang_en.c
src/install+setup/install/main.c
src/install+setup/install/nic.c
src/install+setup/install/probenic.sh
src/install+setup/libsmooth/libsmooth.h
src/install+setup/libsmooth/netstuff.c
src/install+setup/setup/main.c
src/install+setup/setup/networking.c
src/install+setup/setup/setup.h

index 19e169c100bee0cd5a834f215548093f269768c4..acb8b0b92bdfc0c196a19c74443f79a66ff4f159 100644 (file)
@@ -513,5 +513,11 @@ char *de_tr[] = {
 "Willkommen zum %s Installationsprogramm. Wenn Sie auf irgendeiner der folgenden Seiten 'Abbrechen' auswählen, wird der Computer neu gestartet.",
 /* TR_YOUR_CONFIGURATION_IS_SINGLE_GREEN_ALREADY_HAS_DRIVER */
 "Ihre Konfiguration ist für eine einzelne GRÜNE Schnittstelle eingestellt, der bereits ein Treiber zugewiesen ist.",
+/* TR_YES */
+"Ja",
+/* TR_NO */
+"Nein",
+/* TR_AS */
+"als",
 }; 
   
index 236afc3d27e2cc741fa9efbed5ae72c90a849bc7..fdbac6baaf91c8a11d56d0947a68d219f00bc8b0 100644 (file)
@@ -509,5 +509,11 @@ char *en_tr[] = {
 "Welcome to the %s installation program. Selecting Cancel on any of the following screens will reboot the computer.",
 /* TR_YOUR_CONFIGURATION_IS_SINGLE_GREEN_ALREADY_HAS_DRIVER */
 "Your configuration is set for a single GREEN interface, which already has a driver assigned.",
+/* TR_YES */
+"Yes",
+/* TR_NO */
+"No",
+/* TR_AS */
+"as",
 }; 
   
index 7e5c681b60cad26942d134f4e0e80f7d3e47e3b1..5dc53bbc20ebeeff0f5b48f3db8c45d8b395f9fe 100644 (file)
@@ -25,6 +25,9 @@ char **ctr;
 
 extern char url[STRING_SIZE];
 
+struct  nic  nics[20] = { { "" , "" } }; // only defined for compile
+struct knic knics[20] = { { "" , "" , "" } }; // only defined for compile
+
 extern char *en_tr[];
 extern char *de_tr[];
 
@@ -83,7 +86,8 @@ int main(int argc, char *argv[])
        long memory = 0;
        long system_partition, boot_partition, root_partition, swap_file;
        int scsi_disk = 0;
-       char *yesnoharddisk[] = { "NO", "YES", NULL };
+       char *yesnoharddisk[3]; //      char *yesnoharddisk = { "NO", "YES", NULL };
+               
        int unattended = 0;
        struct keyvalue *unattendedkv = initkeyvalues();
        int hardyn = 0;
@@ -300,6 +304,11 @@ int main(int argc, char *argv[])
        if (unattended) {
            hardyn = 1;
        }
+
+       yesnoharddisk[0] = ctr[TR_NO];
+       yesnoharddisk[1] = ctr[TR_YES];
+       yesnoharddisk[2] = NULL;
+
        while (! hardyn) {
                rc = newtWinMenu(title, message,
                                 50, 5, 5, 6, yesnoharddisk,
@@ -559,8 +568,8 @@ int main(int argc, char *argv[])
        mysystem("/bin/installbootsplash.sh");
 
        mysystem("ln -s grub.conf /harddisk/boot/grub/menu.lst");
-       mysystem("umount /harddisk/proc");
-       mysystem("umount /harddisk/dev");
+//     mysystem("umount /harddisk/proc");
+//     mysystem("umount /harddisk/dev");
 
        if (!unattended) {
                sprintf(message, ctr[TR_CONGRATULATIONS_LONG],
@@ -573,6 +582,8 @@ int main(int argc, char *argv[])
 EXIT:
        fprintf(flog, "Install program ended.\n");      
 
+
+
        if (!(allok))
                newtWinMessage(title, ctr[TR_OK], ctr[TR_PRESS_OK_TO_REBOOT]);  
        
@@ -582,10 +593,10 @@ EXIT:
        {
                /* /proc is needed by the module checker.  We have to mount it
                 * so it can be seen by setup, which is run chrooted. */
-               if (system("/bin/mount proc -t proc /harddisk/proc"))
-                       printf("Unable to mount proc in /harddisk.");
-               else
-               {
+//             if (system("/bin/mount proc -t proc /harddisk/proc"))
+//                     printf("Unable to mount proc in /harddisk.");
+//             else
+//             {
                        if (unattended) {
                            fprintf(flog, "Entering unattended setup\n");
                            if (unattended_setup(unattendedkv)) {
@@ -597,9 +608,9 @@ EXIT:
                            }
                        }
 
-                       newtFinished();
                        fflush(flog);
                        fclose(flog);
+                       newtFinished();
 
                        if (!unattended) {
                                        // Copy our scanned nics to the disk and lock because scan doesn't work in chroot
@@ -612,8 +623,13 @@ EXIT:
 
                        if (system("/bin/umount /harddisk/proc"))
                                printf("Unable to umount /harddisk/proc.\n"); 
-               }
+//             }
+       } else {
+               fflush(flog);
+               fclose(flog);
+               newtFinished();
        }
+
        fcloseall();
 
        if (swap_file) {
@@ -622,6 +638,9 @@ EXIT:
 
        newtFinished();
 
+       system("/bin/umount /harddisk/proc");
+       system("/bin/umount /harddisk/dev");
+
        system("/bin/umount /harddisk/var");
        system("/bin/umount /harddisk/boot");
        system("/bin/umount /harddisk");
index 0eea833f0303ff2370be213cf7a15efab7d2e4fd..966f7c84c0c165823f9179b85d12f44fadefa58a 100644 (file)
@@ -20,7 +20,8 @@ extern char *mylog;
 
 extern char **ctr;
 
-extern struct nic nics[];
+//extern struct nic nics[];
+//extern struct knic knics[];
 
 int networkmenu(struct keyvalue *ethernetkv)
 {
index e3de8e6586edf33fa9ff31aeb7f27bd3d525804d..38ad71c7b1aeb32c723a41cd8c608a95f0f33834 100644 (file)
@@ -2,16 +2,16 @@
 
 case "$1" in
        install)
-               hwinfo --netcard | egrep "Model|HW Address" | \
-                       awk -F": " '{ print $2 }' | sed -e '/..:..:..:..:..:../a\\' | sed -e "s/$/\;/g" | \
-                       tr "\n" "XX" | sed -e "s/XX/\n/g" | sed -e "s/\;X/\;/g" | \
-                       sort > /tmp/scanned_nics 2>/dev/null
+               kudzu -qps -c NETWORK | egrep "desc|network.hwaddr" | \
+                               awk -F": " '{ print $2";" }' | sed -e '/..:..:..:..:..:..;/a\X' | \
+                               tr "\n" "X" | sed -e 's/XXX/\n/g' -e 's/;X/;/g' | \
+                               sort > /tmp/scanned_nics 2>/dev/null
                        ;;
        "")
                if [ ! -e /var/ipfire/ethernet/scan_lock ]; then
-                       hwinfo --netcard | egrep "Model|HW Address" | \
-                               awk -F": " '{ print $2 }' | sed -e '/..:..:..:..:..:../a\\' -e "s/$/\;/g" | \
-                               tr "\n" "XX" | sed -e "s/XX/\n/g" -e "s/\;X/\;/g" | \
+                       kudzu -qps -c NETWORK | egrep "desc|network.hwaddr" | \
+                               awk -F": " '{ print $2";" }' | sed -e '/..:..:..:..:..:..;/a\X' | \
+                               tr "\n" "X" | sed -e "s/XXX/\n/g" -e 's/;X/;/g' | \
                                sort > /var/ipfire/ethernet/scanned_nics 2>/dev/null
                fi
                        ;;
index 3e4cb48c91b03d6e72252d662155f82be607008a..e48db18366a6ef164e8be194244d20be64f103d6 100644 (file)
 #define KNOWN_NICS   "/var/ipfire/ethernet/known_nics"
 #define SCANNED_NICS "/var/ipfire/ethernet/scanned_nics"
 
+#define _GREEN_CARD_ 0
+#define _RED_CARD_ 1
+#define _ORANGE_CARD_ 2
+#define _BLUE_CARD_ 3
+
 struct keyvalue
 {
        char key[STRING_SIZE];
@@ -57,12 +62,15 @@ struct nic
        char description[256];
        char macaddr[20];
 };
+
 struct knic
 {
        char description[256];
        char macaddr[20];
+       char colour[20];
 };
 
+
 /* libsmooth.c */
 void reboot(void);
 void stripnl(char *s);
@@ -84,7 +92,9 @@ int gettype(char *type);
 int setnetaddress(struct keyvalue *kv, char *colour);
 void networkdialogcallbacktype(newtComponent cm, void *data);
 int interfacecheck(struct keyvalue *kv, char *colour);
+int scan_network_cards(void);
 int nicmenu(char *colour);
+int remove_nic_entry(char *colour);
 int manualdriver(char *driver, char *driveroptions);
          
 /* data.c */
index 6e0897c21a2ca07d895256317b1d3a125ea817e8..8f9b48914f9cbf5e129ef951ab94dd5ef7a88171 100644 (file)
@@ -16,6 +16,11 @@ extern char *mylog;
 
 extern char **ctr;
 
+extern struct nic nics[];
+extern struct knic knics[];
+
+int scanned_nics_read_done = 0;
+
 newtComponent networkform;
 newtComponent addressentry;
 newtComponent netmaskentry;
@@ -327,26 +332,58 @@ int probecards(char *driver, char *driveroptions)
        return 0;
 }
 
+/* ### alter strupper ###
 char *strupper(char *s)
 {
  int n;
  for (n=0;s[n];n++) s[n]=toupper(s[n]);
  return s;
 }
+*/
 
+/* neuer StringUpper, wird zur Zeit nicht benutzt da UTF-8 nicht geht.
+void strupper(unsigned char *string)
+{
+       unsigned char *str;
+       for (str = string; *str != '\0'; str++)
+               if (!(*str & 0x80) && islower(*str)) 
+                       *str = toupper(*str);
+}
+*/
 
 int write_configs_netudev(char *description, char *macaddr, char *colour)
 {      
        #define UDEV_NET_CONF "/etc/udev/rules.d/30-persistent-network.rules"
-       
        FILE *fp;
        char commandstring[STRING_SIZE];
        struct keyvalue *kv = initkeyvalues();
        char temp1[STRING_SIZE], temp2[STRING_SIZE], temp3[STRING_SIZE];
        char ucolour[STRING_SIZE];
-       
-       sprintf(ucolour, colour);
-       strupper(ucolour);
+
+//     sprintf(ucolour, colour);       
+//     strupper(ucolour);
+
+       switch (*colour)
+       {
+               case 'g':       sprintf(ucolour, "GREEN");
+                               strcpy(knics[_GREEN_CARD_].description, description);
+                               strcpy(knics[_GREEN_CARD_].macaddr, macaddr);
+                               break;
+               case 'r':       sprintf(ucolour, "RED");
+                               strcpy(knics[_RED_CARD_].description, description);
+                               strcpy(knics[_RED_CARD_].macaddr, macaddr);
+                               break;
+               case 'o':       sprintf(ucolour, "ORANGE");
+                               strcpy(knics[_ORANGE_CARD_].description, description);
+                               strcpy(knics[_ORANGE_CARD_].macaddr, macaddr);
+                               break;
+               case 'b':       sprintf(ucolour, "BLUE");
+                               strcpy(knics[_BLUE_CARD_].description, description);
+                               strcpy(knics[_BLUE_CARD_].macaddr, macaddr);
+                               break;
+               default:        sprintf(ucolour, "DUMMY");
+                               break;
+       }
 
        if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
        {
@@ -360,24 +397,20 @@ int write_configs_netudev(char *description, char *macaddr, char *colour)
        sprintf(temp3, "%s0", colour);
        replacekeyvalue(kv, temp1, temp3);
        replacekeyvalue(kv, temp2, macaddr);
+       sprintf(temp1, "%s_DESCRIPTION", ucolour);
+       replacekeyvalue(kv, temp1, description);
 
        writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
        freekeyvalues(kv);
        
-       if( (fp = fopen(KNOWN_NICS, "a")) == NULL )
-       {
-               fprintf(stderr,"Couldn't open "KNOWN_NICS);
-               return 1;
-       }
-       fprintf(fp,"%s;%s;\n", description, macaddr);
-       fclose(fp);
-
        // Make sure that there is no conflict
        snprintf(commandstring, STRING_SIZE, "/usr/bin/touch "UDEV_NET_CONF" >/dev/null 2>&1");
-  system(commandstring);
-  snprintf(commandstring, STRING_SIZE, "/bin/cat "UDEV_NET_CONF" | /bin/grep -v \"%s\" > "UDEV_NET_CONF" 2>/dev/null", macaddr);
-  system(commandstring);
-  snprintf(commandstring, STRING_SIZE, "/bin/cat "UDEV_NET_CONF" | /bin/grep -v \"%s\" > "UDEV_NET_CONF" 2>/dev/null", colour);
+       system(commandstring);
+       
+       snprintf(commandstring, STRING_SIZE, "/bin/cat "UDEV_NET_CONF" | /bin/grep -v \"%s\" > "UDEV_NET_CONF" 2>/dev/null", macaddr);
+       system(commandstring);
+
+       snprintf(commandstring, STRING_SIZE, "/bin/cat "UDEV_NET_CONF" | /bin/grep -v \"%s\" > "UDEV_NET_CONF" 2>/dev/null", colour);
        system(commandstring);
 
        if( (fp = fopen(UDEV_NET_CONF, "a")) == NULL )
@@ -391,112 +424,173 @@ int write_configs_netudev(char *description, char *macaddr, char *colour)
        return 0;
 }
 
-int nicmenu(char *colour)
+int scan_network_cards(void)
 {
-                       FILE *fp;
-                       char temp_line[STRING_SIZE];
-                       struct nic nics[20], *pnics;
-                       pnics = nics;
-                       struct knic knics[20], *pknics;
-                       pknics = knics;
-                       int rc, choise, count = 0, kcount = 0, i, found;
-                       char macaddr[STRING_SIZE], description[STRING_SIZE];
-                       char message[STRING_SIZE];
-
-                       char MenuInhalt[20][80];
-                       char *pMenuInhalt[20];
-                       
-                       mysystem("/bin/probenic.sh");
-                       
-                       // Read the nics we already use
-                       if((fp = fopen(KNOWN_NICS, "r")) == NULL)
-                       {
-                               fprintf(flog,"Couldn't open " KNOWN_NICS);
-                               return 1;
-                       }
-                       while (fgets(temp_line, STRING_SIZE, fp) != NULL)
-                       {
-                               strcpy(knics[kcount].description, strtok(temp_line,";"));
-                               strcpy(knics[kcount].macaddr , strtok(NULL,";"));
-                               if (strlen(knics[kcount].macaddr) > 5 ) kcount++;
+       FILE *fp;
+       char description[STRING_SIZE], macaddr[STRING_SIZE], temp_line[STRING_SIZE];
+       int count = 0;
+       
+       if (!(scanned_nics_read_done))
+       {
+               fprintf(flog,"Enter scan_network_cards\n"); // #### Debug ####
+               mysystem("/bin/probenic.sh");
+               // Read our scanned nics
+               if( (fp = fopen(SCANNED_NICS, "r")) == NULL )
+               {
+                       fprintf(stderr,"Couldn't open "SCANNED_NICS);
+                       return 1;
+               }
+               while (fgets(temp_line, STRING_SIZE, fp) != NULL)
+               {
+                       strcpy(description, strtok(temp_line,";"));
+                       strcpy(macaddr,     strtok(NULL,";"));
+                       if ( strlen(macaddr) ) {
+                               strcpy(nics[count].description , description );
+                               strcpy(nics[count].macaddr , macaddr );
+                               count++;
                        }
-                       fclose(fp);
+               }
+               fclose(fp);
+       }
+       scanned_nics_read_done = 1;
+       return count;
+}
 
-                       // Read our scanned nics
-                       if( (fp = fopen(SCANNED_NICS, "r")) == NULL )
-                       {
-                               fprintf(stderr,"Couldn't open "SCANNED_NICS);
-                               return 1;
-                       }
-                       while (fgets(temp_line, STRING_SIZE, fp) != NULL)
-                       {
-                               strcpy(description, strtok(temp_line,";"));
-                               strcpy(macaddr,     strtok(NULL,";"));
-                               found = 0;
-                               if (strlen(macaddr) > 5 ) {
-                                       for (i=0; i < kcount; i++)
-                                       {
-                                               // Check if the nic is already in use
-                                               if (strcmp(pknics[i].macaddr, macaddr) == NULL )
-                                               {
-                                                       found = 1;
-                                               }
-                                       }
-                                       if (!found)
-                                       {
-                                               strcpy( pnics[count].description , description );
-                                               strcpy( pnics[count].macaddr , macaddr );
-                                               count++;
-                                       }
+
+
+int nicmenu(char *colour)
+{
+       int rc, choise = 0, count = 0, kcount = 0, mcount = 0, i, j, nic_in_use;
+       int found_NIC_as_Card[4];
+       char message[STRING_SIZE];
+
+       char cMenuInhalt[STRING_SIZE];
+       char MenuInhalt[20][180];
+       char *pMenuInhalt[20];
+       
+//     strcpy( message , pnics[count].macaddr);
+//     while (strcmp(message, "")) {
+//             count++;
+//             strcpy( message , pnics[count].macaddr);
+//     }
+
+       while (strcmp(nics[count].macaddr, "")) count++;                        // 2 find how many nics in system
+       for ( i=0 ; i<4;i++) if (strcmp(knics[i].macaddr, "")) kcount++;        // loop to find all knowing nics
+       fprintf(flog, "Enter NicMenu\n");                                       // #### Debug ####
+       fprintf(flog, "count nics %i\ncount knics %i\n", count, kcount);        // #### Debug ####
+
+       // If new nics are found...
+       if (count > kcount) {
+               for (i=0 ; i < count ; i++)
+               {
+                       nic_in_use = 0;
+                       for (j=0 ; j <= kcount ; j++) {
+                               if (strcmp(nics[ i ].macaddr, knics[ j ].macaddr) == 0 ) {
+                                       nic_in_use = 1;
+                                       fprintf(flog,"NIC \"%s\" is in use.\n", nics[ i ].macaddr); // #### Debug ####
+                                       break;
                                }
                        }
-                       fclose(fp);
-                       
-                       // If new nics are found...
-                       if (count > 0) {
-                               char cMenuInhalt[STRING_SIZE];
-                               for (i=0 ; i < count ; i++)
-                               {
-                                       if ( strlen(nics[i].description) < 52 )
-                                               strncpy(MenuInhalt[i], nics[i].description + 1, strlen(nics[i].description)- 2);
-                                       else
-                                       {
-                                               strncpy(cMenuInhalt, nics[i].description + 1, 50);
-                                               strncpy(MenuInhalt[i], cMenuInhalt,(strrchr(cMenuInhalt,' ') - cMenuInhalt));
-                                               strcat (MenuInhalt[i], "...");
-                                       }
-                                       while ( strlen(MenuInhalt[i]) < 50)
-                                               // Fill with space.
-                                               strcat( MenuInhalt[i], " ");
-       
-                                       strcat(MenuInhalt[i], " (");
-                                       strcat(MenuInhalt[i], nics[i].macaddr);
-                                       strcat(MenuInhalt[i], ")");
-                                       pMenuInhalt[i] = MenuInhalt[i];
+                       if (!(nic_in_use)) {
+                               fprintf(flog,"NIC \"%s\" is free.\n", nics[ i ].macaddr); // #### Debug ####
+                               if ( strlen(nics[i].description) < 55 ) 
+                                       sprintf(MenuInhalt[mcount], "%.*s",  strlen(nics[i].description)-2, nics[i].description+1);
+                               else {
+                                       sprintf(cMenuInhalt, "%.50s", nics[i].description + 1);
+                                       strncpy(MenuInhalt[mcount], cMenuInhalt,(strrchr(cMenuInhalt,' ') - cMenuInhalt));
+                                       strcat (MenuInhalt[mcount], "...");
                                }
-                               
-                               sprintf(message, "Es wurde(n) %d freie Netzwerkkarte(n) in Ihrem System gefunden.\nBitte waehlen Sie im naechsten Dialog eine davon aus.\n", count);
-                               
-                               newtWinMessage("NetcardMenu", ctr[TR_OK], message);
 
-                               sprintf(message, "Bitte waehlen Sie eine der untenstehenden Netzwerkkarten fuer die Schnittstelle \"%s\" aus.\n", colour);
-               
-                               rc = newtWinMenu("NetcardMenu", message, 50, 5, 5, 6, pMenuInhalt, &choise, ctr[TR_OK], ctr[TR_SELECT], ctr[TR_CANCEL], NULL);
-                               
-                               if ( rc == 0 || rc == 1) {
-                                       write_configs_netudev(pnics[choise].description, pnics[choise].macaddr, colour);
-                               } else if (rc == 2) {
-                                       manualdriver("pcnet32","");
-             } else {
-               errorbox("Sie haben keine Netzwerkkarte ausgewaehlt.\n");
-                                       return 1;
-                               }
-                               return 0;
-               } else {
-                       // We have to add here that you can manually add a device
-                       errorbox("Es wurden leider keine freien Netzwerkkarten fuer die Schnittstelle in ihrem System gefunden.");
-                       return 1;
+                               while ( strlen(MenuInhalt[mcount]) < 50) strcat(MenuInhalt[mcount], " "); // Fill with space.
+
+                               strcat(MenuInhalt[mcount], " (");
+                               strcat(MenuInhalt[mcount], nics[i].macaddr);
+                               strcat(MenuInhalt[mcount], ")");
+                               pMenuInhalt[mcount] = MenuInhalt[mcount];
+                               found_NIC_as_Card[mcount]=i;
+                               mcount++;
+                       }
                }
+
+               pMenuInhalt[mcount] = NULL;
+
+//             sprintf(message, "Es wurde(n) %d freie Netzwerkkarte(n) in Ihrem System gefunden.\nBitte waehlen Sie im naechsten Dialog eine davon aus.\n", count);
+//             newtWinMessage("NetcardMenu", ctr[TR_OK], message);
+
+               sprintf(message, "(TR) Bitte waehlen Sie eine der untenstehenden Netzwerkkarten fuer die Schnittstelle \"%s\" aus.\n", colour);
+               rc = newtWinMenu("(TR) NetcardMenu2", message, 50, 5, 5, 6, pMenuInhalt, &choise, ctr[TR_OK], ctr[TR_SELECT], ctr[TR_CANCEL], NULL);
+                               
+               if ( rc == 0 || rc == 1) {
+                       write_configs_netudev(nics[choise].description, nics[found_NIC_as_Card[choise]].macaddr, colour);
+               } else if (rc == 2) {
+//                     manualdriver("pcnet32","");
+               }
+               return 0;
+       } else {
+               // We have to add here that you can manually add a device
+               errorbox("(TR) Es wurden leider keine freien Netzwerkkarten fuer die Schnittstelle in ihrem System gefunden.");
+               return 1;
+       }
+}
+
+int remove_nic_entry(char *colour)
+{
+       struct keyvalue *kv = initkeyvalues();
+       char message[STRING_SIZE];
+       char temp1[STRING_SIZE], temp2[STRING_SIZE];
+       char ucolour[STRING_SIZE];
+       int rc;
+
+       
+       if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
+       {
+               freekeyvalues(kv);
+               errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
+               return 0;
+       }
+
+       switch (*colour)
+       {
+               case 'g':       sprintf(ucolour, "GREEN");
+                               strcpy(knics[_GREEN_CARD_].description, ctr[TR_UNSET]);
+                               strcpy(knics[_GREEN_CARD_].macaddr, "");
+                               strcpy(knics[_GREEN_CARD_].colour, "");
+                               break;
+               case 'r':       sprintf(ucolour, "RED");
+                               strcpy(knics[_RED_CARD_].description, ctr[TR_UNSET]);
+                               strcpy(knics[_RED_CARD_].macaddr, "");
+                               strcpy(knics[_RED_CARD_].colour, "");
+                               break;
+               case 'o':       sprintf(ucolour, "ORANGE");
+                               strcpy(knics[_ORANGE_CARD_].description, ctr[TR_UNSET]);
+                               strcpy(knics[_ORANGE_CARD_].macaddr, "");
+                               strcpy(knics[_ORANGE_CARD_].colour, "");
+                               break;
+               case 'b':       sprintf(ucolour, "BLUE");
+                               strcpy(knics[_BLUE_CARD_].description, ctr[TR_UNSET]);
+                               strcpy(knics[_BLUE_CARD_].macaddr, "");
+                               strcpy(knics[_BLUE_CARD_].colour, "");
+                               break;
+               default:        sprintf(ucolour, "DUMMY");
+                               break;
+       }
+
+       sprintf(message, "(TR) Soll die Netzwerkkarte \"%s\" entfernt werden ?\n", colour);
+       rc = newtWinChoice(ctr[TR_WARNING], ctr[TR_OK], ctr[TR_CANCEL], message);                               
+
+       if ( rc = 0 || rc == 1) {
+               sprintf(temp1, "%s_DEV", ucolour);
+               sprintf(temp2, "%s_MACADDR", ucolour);
+               replacekeyvalue(kv, temp1, "");
+               replacekeyvalue(kv, temp2, "");
+               sprintf(temp1, "%s_DESCRIPTION", ucolour);
+               replacekeyvalue(kv, temp1, "");
+
+               writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
+       } else return 1;
+
+       freekeyvalues(kv);
+       return 0;
 }
 
 /* Manual entry for gurus. */
index f168220e10183055f9a70ef91e19cb1cb044bc59..5111153d7081e8a82f25f6dd0674e0be7da6639d 100644 (file)
@@ -21,6 +21,9 @@ char **ctr = NULL;
 
 int automode = 0;
 
+struct  nic  nics[20] = { { "" , "" } };
+struct knic knics[20] = { { "" , "" , "" } };
+
 extern char *en_tr[];
 extern char *de_tr[];
 
index ef5deb2c73704d416a2301546fdb39dd80df017c..a86cf9532682af17df2ed3f581f20c19b4c2bd96 100644 (file)
@@ -24,12 +24,14 @@ extern char **ctr;
 
 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)", 
@@ -264,15 +266,18 @@ int configtypemenu(void)
 /* Driver menu.  Choose drivers.. */
 int drivermenu(void)
 {
-       FILE *fp;
        struct keyvalue *kv = initkeyvalues();
-       char message[1000], macaddr[STRING_SIZE];
-       char temp_line[STRING_SIZE];
-       char temp[STRING_SIZE], temp1[STRING_SIZE];
-       struct knic knics[20], *pknics;
-       pknics = knics;
+       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, i = 0, kcount = 0;
+       int rc, kcount = 0, found, neednics; //i = 0, count = 0,
+       
+       fprintf(flog,"enter drivermenu\n"); // #### Debug ####
 
        if (!(readkeyvalues(kv, CONFIG_ROOT "/ethernet/settings")))
        {
@@ -284,80 +289,113 @@ int drivermenu(void)
        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]);
-       
-       if( (fp = fopen(KNOWN_NICS, "r")) == NULL )
-       {
-               fprintf(flog,"Couldn't open " KNOWN_NICS);
-               return 1;
-       }
-       while (fgets(temp_line, STRING_SIZE, fp) != NULL)
-       {
-               strcpy(knics[kcount].description, strtok(temp_line,";"));
-               strcpy(knics[kcount].macaddr , strtok(NULL,";"));
-               if (strlen(knics[kcount].macaddr) > 5 ) kcount++;
-       }
-       fclose(fp);
-       
-       strcpy(macaddr, ctr[TR_UNSET]);
-       findkey(kv, "GREEN_MACADDR", macaddr);
-       for (i=0; i < kcount; i++)
-       {       // Check if the nic is already in use
-               if (strcmp(pknics[i].macaddr, macaddr) == NULL )
-                       break;
+
+       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++;
        }
-       sprintf(temp1, "GREEN: %s (%s / green0)\n", pknics[i].description, pknics[i].macaddr);
-       strcat(message, temp1);
-       
-       if (HAS_BLUE) {
-               strcpy(macaddr, ctr[TR_UNSET]);
-               findkey(kv, "BLUE_MACADDR", macaddr);
-               for (i=0; i < kcount; i++)
-               {       // Check if the nic is already in use
-                       if (strcmp(pknics[i].macaddr, macaddr) == NULL )
-                               break;
+       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);
                }
-               sprintf(temp1, "BLUE: %s (%s / blue0)\n", pknics[i].description, pknics[i].macaddr);
-               strcat(message, temp1);
+               neednics++;
        }
        if (HAS_ORANGE) {
-               strcpy(macaddr, ctr[TR_UNSET]);
-               findkey(kv, "ORANGE_MACADDR", macaddr);
-               for (i=0; i < kcount; i++)
-               {       // Check if the nic is already in use
-                       if (strcmp(pknics[i].macaddr, macaddr) == NULL )
-                               break;
+               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);
                }
-               sprintf(temp1, "ORANGE: %s (%s / orange0)\n", pknics[i].description, pknics[i].macaddr);
-               strcat(message, temp1);
+               neednics++;
        }
-       if (HAS_RED) {
-               strcpy(macaddr, ctr[TR_UNSET]);
-               findkey(kv, "RED_MACADDR", macaddr);
-               for (i=0; i < kcount; i++)
-               {       // Check if the nic is already in use
-                       if (strcmp(pknics[i].macaddr, macaddr) == NULL )
-                               break;
+       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);
                }
-               sprintf(temp1, "RED: %s (%s / red0)\n", pknics[i].description, pknics[i].macaddr);
-               strcat(message, temp1);
+               neednics++;
        }
-       strcat(message, ctr[TR_DO_YOU_WISH_TO_CHANGE_THESE_SETTINGS]);
-       rc = newtWinChoice(ctr[TR_DRIVERS_AND_CARD_ASSIGNMENTS], ctr[TR_OK],
+
+       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;
@@ -366,6 +404,7 @@ int drivermenu(void)
 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;
@@ -376,9 +415,13 @@ int cardassigned(char *colour)
 int changedrivers(void)
 {
        struct keyvalue *kv = initkeyvalues();
-       char temp[STRING_SIZE];
+       char temp[STRING_SIZE], message[STRING_SIZE];
        int configtype;
        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")))
        {
@@ -386,10 +429,11 @@ int changedrivers(void)
                errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
                return 0;
        }
-       
+       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]);
 
+       findkey(kv, "CONFIG_TYPE", temp); configtype = atol(temp);
        if (configtype == 0)
                { green = 1; }
        else if (configtype == 1)
@@ -406,15 +450,92 @@ int changedrivers(void)
                { green = 1; red = 1; blue = 1; }
        else if (configtype == 7)
                { green = 1; red = 1; blue = 1; orange = 1; }
-       
-       if (green && !cardassigned("green"))
-               nicmenu("green");
-       if (red && !cardassigned("red"))
-               nicmenu("red");
-       if (blue && !cardassigned("blue"))
-               nicmenu("blue");
-       if (orange && !cardassigned("orange"))
-               nicmenu("orange");
+
+       fprintf(flog,"found: g=%d r=%d o=%d b=%d\n",green, red, orange, blue); // #### Debug ####
+
+       do
+       {
+               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);
+                       }
+                       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);
+                       }
+                       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++;
+               }
+
+               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++;
+               }
+               pMenuInhalt[count] = NULL;
+
+               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;
+//             }
+       }
+       while ( rc <= 2);
        
        // writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
 
index 92e56b10aa9ed5ec931a64ebe83659a08a761b24..064ebff88a56b869b5f336081d4da1b92d78997d 100644 (file)
@@ -1,42 +1,42 @@
-/* SmoothWall setup program.\r
- *\r
- * This program is distributed under the terms of the GNU General Public\r
- * Licence.  See the file COPYING for details.\r
- *\r
- * (c) Lawrence Manning, 2001\r
- * Main include file.\r
- * \r
- * $Id: setup.h,v 1.4 2003/12/11 11:25:54 riddles Exp $\r
- * \r
- */\r
-\r
-#include "../libsmooth/libsmooth.h"\r
-\r
-/* hostname.c */\r
-int handlehostname(void);\r
-\r
-/* domainname.c */\r
-int handledomainname(void);\r
-\r
-/* isdn.c */\r
-int handleisdn(void);\r
-\r
-/* networking.c */\r
-int handlenetworking(void);\r
-\r
-/* dhcp.c */\r
-int handledhcp(void);\r
-\r
-/* passwords.c */\r
-int handlerootpassword(void);\r
-int handlesetuppassword(void);\r
-int handleadminpassword(void);\r
-\r
-/* misc.c */\r
-int writehostsfiles(void);\r
-\r
-/* keymap.c */\r
-int handlekeymap(void);\r
-\r
-/* timezone.c */\r
-int handletimezone(void);\r
+/* SmoothWall setup program.
+ *
+ * This program is distributed under the terms of the GNU General Public
+ * Licence.  See the file COPYING for details.
+ *
+ * (c) Lawrence Manning, 2001
+ * Main include file.
+ * 
+ * $Id: setup.h,v 1.4 2003/12/11 11:25:54 riddles Exp $
+ * 
+ */
+
+#include "../libsmooth/libsmooth.h"
+
+/* hostname.c */
+int handlehostname(void);
+
+/* domainname.c */
+int handledomainname(void);
+
+/* isdn.c */
+int handleisdn(void);
+
+/* networking.c */
+int handlenetworking(void);
+
+/* dhcp.c */
+int handledhcp(void);
+
+/* passwords.c */
+int handlerootpassword(void);
+int handlesetuppassword(void);
+int handleadminpassword(void);
+
+/* misc.c */
+int writehostsfiles(void);
+
+/* keymap.c */
+int handlekeymap(void);
+
+/* timezone.c */
+int handletimezone(void);