From: ms Date: Thu, 29 Mar 2007 20:10:53 +0000 (+0000) Subject: Netzwerkbeta-Bugfixes... X-Git-Tag: v2.3-beta1~782 X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=commitdiff_plain;h=f4a208fee9134eddfe6bc53a093fcd4fc6ed94fe;hp=7654ad59f97c23c0eedc6ba85785dd6d7d633f72 Netzwerkbeta-Bugfixes... git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@473 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8 --- diff --git a/tmp/nic.c b/tmp/nic.c index 31602e0bcc..38d4d66946 100644 --- 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; -}