]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - tmp/nic.c
Netzwerkbeta-Bugfixes...
[people/pmueller/ipfire-2.x.git] / tmp / nic.c
index 31602e0bccab9df9fe902a47d572bdfcdf7a198b..38d4d66946462e3ebf06614b1e64f02783bdd8fa 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;
-}