Netzwerkbeta-Bugfixes...
authorms <ms@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Thu, 29 Mar 2007 20:10:53 +0000 (20:10 +0000)
committerms <ms@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Thu, 29 Mar 2007 20:10:53 +0000 (20:10 +0000)
git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@473 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8

tmp/nic.c

index 31602e0..38d4d66 100644 (file)
--- a/tmp/nic.c
+++ b/tmp/nic.c
@@ -19,13 +19,48 @@ struct knic
        char macaddr[20];
 };
 
+int write_configs_netudev(char *macaddr, char *colour) {
+       
+       #define UDEV_NET_CONF "/etc/udev/rules.d/30-persistent-network.rules"
+       
+       FILE *fp;
+       char commandstring[STRING_SIZE];
+       
+       if( (fp = fopen(KNOWN_NICS, "a")) == NULL )
+       {
+               fprintf(stderr,"Couldn't open "KNOWN_NICS);
+               return 1;
+       }
+       fprintf(fp,"%s;\n", 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);
+
+       if( (fp = fopen(UDEV_NET_CONF, "a")) == NULL )
+       {
+               fprintf(stderr,"Couldn't open" UDEV_NET_CONF);
+               return 1;
+       }
+       fprintf(fp,"ACTION==\"add\", SUBSYSTEM==\"net\", SYSFS{address}==\"%s\", NAME=\"%s0\"\n", macaddr, colour);
+       fclose(fp);     
+       
+       return 0;
+}
+
 int main(void)
 {
                        FILE *fp;
                        char temp_line[STRING_SIZE];
                        struct nic nics[20], *pnics;
-                       struct knic knics[20];
                        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];
@@ -64,7 +99,7 @@ int main(void)
                                        for (i=0; i < kcount; i++)
                                        {
                                                // Check if the nic is already in use
-                                               if ( strcmp(knics[i].macaddr, macaddr) == NULL )
+                                               if (strcmp(pknics[i].macaddr, macaddr) == NULL )
                                                {
                                                        found = 1;
                                                }
@@ -126,37 +161,3 @@ int main(void)
                        return 1;
                }
 }
-
-int write_configs_netudev(char *macaddr, char *colour) {
-       
-       #define UDEV_NET_CONF "/etc/udev/rules.d/30-persistent-network.rules"
-       
-       FILE *fp;
-       char commandstring[STRING_SIZE];
-       
-       if( (fp = fopen(KNOWN_NICS, "a")) == NULL )
-       {
-               fprintf(stderr,"Couldn't open "KNOWN_NICS);
-               return 1;
-       }
-       fprintf(fp,"%s;\n", 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);
-
-       if( (fp = fopen(UDEV_NET_CONF, "a")) == NULL )
-       {
-               fprintf(stderr,"Couldn't open" UDEV_NET_CONF);
-               return 1;
-       }
-       fprintf(fp,"ACTION==\"add\", SUBSYSTEM==\"net\", SYSFS{address}==\"%s\", NAME=\"%s0\"\n", macaddr, colour);
-       fclose(fp);     
-       
-       return 0;
-}