diff options
-rw-r--r-- | axconfig.c | 148 | ||||
-rw-r--r-- | axutils.c | 2 | ||||
-rw-r--r-- | nrconfig.c | 152 | ||||
-rw-r--r-- | rsconfig.c | 144 |
4 files changed, 223 insertions, 223 deletions
@@ -237,13 +237,13 @@ static int ax25_config_init_port(int fd, int lineno, char *line, const char **if found = 0; char *cp; if ((cp = strstr(call, "-0")) != NULL) - *cp = '\0'; + *cp = '\0'; for (;ifcalls && *ifcalls; ++ifcalls, ++ifdevs) { - if (strcmp(call, *ifcalls) == 0) { - found = 1; - dev = *ifdevs; - break; - } + if (strcmp(call, *ifcalls) == 0) { + found = 1; + dev = *ifdevs; + break; + } } if (!found) { @@ -294,83 +294,83 @@ int ax25_config_load_ports(void) if ((fd = socket(PF_FILE, SOCK_DGRAM, 0)) < 0) { - fprintf(stderr, "axconfig: unable to open socket (%s)\n", strerror(errno)); - goto cleanup; + fprintf(stderr, "axconfig: unable to open socket (%s)\n", strerror(errno)); + goto cleanup; } if ((fp = fopen("/proc/net/dev", "r"))) { - /* Two header lines.. */ - s = fgets(buffer, sizeof(buffer), fp); - s = fgets(buffer, sizeof(buffer), fp); - /* .. then network interface names */ - while (!feof(fp)) { - if (!fgets(buffer, sizeof(buffer), fp)) - break; - s = strchr(buffer, ':'); - if (s) *s = 0; - s = buffer; - while (isspace(*s & 0xff)) ++s; - - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, s, IFNAMSIZ-1); - ifr.ifr_name[IFNAMSIZ-1] = 0; - - if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) { - fprintf(stderr, "axconfig: SIOCGIFHWADDR: %s\n", strerror(errno)); - return FALSE; - } - - if (ifr.ifr_hwaddr.sa_family != ARPHRD_AX25) - continue; - - /* store found interface callsigns */ - /* ax25_ntoa() returns pointer to static buffer */ - s = ax25_ntoa((void*)ifr.ifr_hwaddr.sa_data); - - if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) { - fprintf(stderr, "axconfig: SIOCGIFFLAGS: %s\n", strerror(errno)); - return FALSE; - } - - if (!(ifr.ifr_flags & IFF_UP)) - continue; - - if ((pp = realloc(calllist, sizeof(char *) * (callcount+2))) == 0) - break; - calllist = pp; - if ((pp = realloc(devlist, sizeof(char *) * (callcount+2))) == 0) - break; - devlist = pp; - if ((calllist[callcount] = strdup(s)) != NULL) { - if ((devlist[callcount] = strdup(ifr.ifr_name)) != NULL) { - ++callcount; - calllist[callcount] = NULL; - devlist [callcount] = NULL; - } else { - free((void*)calllist[callcount]); - calllist[callcount] = NULL; - } - } - } - fclose(fp); - fp = NULL; + /* Two header lines.. */ + s = fgets(buffer, sizeof(buffer), fp); + s = fgets(buffer, sizeof(buffer), fp); + /* .. then network interface names */ + while (!feof(fp)) { + if (!fgets(buffer, sizeof(buffer), fp)) + break; + s = strchr(buffer, ':'); + if (s) *s = 0; + s = buffer; + while (isspace(*s & 0xff)) ++s; + + memset(&ifr, 0, sizeof(ifr)); + strncpy(ifr.ifr_name, s, IFNAMSIZ-1); + ifr.ifr_name[IFNAMSIZ-1] = 0; + + if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) { + fprintf(stderr, "axconfig: SIOCGIFHWADDR: %s\n", strerror(errno)); + return FALSE; + } + + if (ifr.ifr_hwaddr.sa_family != ARPHRD_AX25) + continue; + + /* store found interface callsigns */ + /* ax25_ntoa() returns pointer to static buffer */ + s = ax25_ntoa((void*)ifr.ifr_hwaddr.sa_data); + + if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) { + fprintf(stderr, "axconfig: SIOCGIFFLAGS: %s\n", strerror(errno)); + return FALSE; + } + + if (!(ifr.ifr_flags & IFF_UP)) + continue; + + if ((pp = realloc(calllist, sizeof(char *) * (callcount+2))) == 0) + break; + calllist = pp; + if ((pp = realloc(devlist, sizeof(char *) * (callcount+2))) == 0) + break; + devlist = pp; + if ((calllist[callcount] = strdup(s)) != NULL) { + if ((devlist[callcount] = strdup(ifr.ifr_name)) != NULL) { + ++callcount; + calllist[callcount] = NULL; + devlist [callcount] = NULL; + } else { + free((void*)calllist[callcount]); + calllist[callcount] = NULL; + } + } + } + fclose(fp); + fp = NULL; } if ((fp = fopen(CONF_AXPORTS_FILE, "r")) == NULL) { - fprintf(stderr, "axconfig: unable to open axports file %s (%s)\n", CONF_AXPORTS_FILE, strerror(errno)); - goto cleanup; + fprintf(stderr, "axconfig: unable to open axports file %s (%s)\n", CONF_AXPORTS_FILE, strerror(errno)); + goto cleanup; } while (fp && fgets(buffer, 255, fp)) { - if ((s = strchr(buffer, '\n'))) - *s = '\0'; + if ((s = strchr(buffer, '\n'))) + *s = '\0'; - if (strlen(buffer) > 0 && *buffer != '#') - if (ax25_config_init_port(fd, lineno, buffer, calllist, devlist)) - n++; + if (strlen(buffer) > 0 && *buffer != '#') + if (ax25_config_init_port(fd, lineno, buffer, calllist, devlist)) + n++; - lineno++; + lineno++; } cleanup:; @@ -378,9 +378,9 @@ int ax25_config_load_ports(void) if (fp) fclose(fp); for (i = 0; calllist && calllist[i]; ++i) { - free((void*)calllist[i]); - if (devlist[i] != NULL) - free((void*)devlist[i]); + free((void*)calllist[i]); + if (devlist[i] != NULL) + free((void*)devlist[i]); } if (calllist) free(calllist); if (devlist) free(devlist); @@ -201,7 +201,7 @@ char *ax25_ntoa(const ax25_address *a) /* Convention is: -0 suffixes are NOT printed */ if (a->ax25_call[6] & 0x1E) { - *s++ = '-'; + *s++ = '-'; if ((n = ((a->ax25_call[6] >> 1) & 0x0F)) > 9) { *s++ = '1'; @@ -215,15 +215,15 @@ static int nr_config_init_port(int fd, int lineno, char *line, const char **ifca char *cp; if ((cp = strstr(call, "-0")) != NULL) - *cp = 0; + *cp = 0; found = 0; for (;ifcalls && *ifcalls; ++ifcalls, ++ifdevs) { - if (strcmp(call, *ifcalls) == 0) { - found = 1; - dev = *ifdevs; - break; - } + if (strcmp(call, *ifcalls) == 0) { + found = 1; + dev = *ifdevs; + break; + } } if (!found) { @@ -273,85 +273,85 @@ int nr_config_load_ports(void) if ((fd = socket(PF_FILE, SOCK_DGRAM, 0)) < 0) { - fprintf(stderr, "nrconfig: unable to open socket (%s)\n", strerror(errno)); - goto cleanup; + fprintf(stderr, "nrconfig: unable to open socket (%s)\n", strerror(errno)); + goto cleanup; } if ((fp = fopen("/proc/net/dev", "r"))) { - /* Two header lines.. */ - s = fgets(buffer, sizeof(buffer), fp); - s = fgets(buffer, sizeof(buffer), fp); - /* .. then network interface names */ - while (!feof(fp)) { - if (!fgets(buffer, sizeof(buffer), fp)) - break; - s = strchr(buffer, ':'); - if (s) *s = 0; - s = buffer; - while (isspace(*s & 0xff)) ++s; - - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, s, IFNAMSIZ-1); - ifr.ifr_name[IFNAMSIZ-1] = 0; - - if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) { - fprintf(stderr, "nrconfig: SIOCGIFHWADDR: %s\n", strerror(errno)); - return FALSE; - } - - if (ifr.ifr_hwaddr.sa_family != ARPHRD_NETROM) - continue; - - /* store found interface callsigns */ - /* ax25_ntoa() returns pointer to static buffer */ - s = ax25_ntoa((void*)ifr.ifr_hwaddr.sa_data); - - if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) { - fprintf(stderr, "nrconfig: SIOCGIFFLAGS: %s\n", strerror(errno)); - return FALSE; - } - - if (!(ifr.ifr_flags & IFF_UP)) - continue; - - - if ((pp = realloc(calllist, sizeof(char *) * (callcount+2))) == 0) - break; - calllist = pp; - if ((pp = realloc(devlist, sizeof(char *) * (callcount+2))) == 0) - break; - devlist = pp; - if ((calllist[callcount] = strdup(s)) != NULL) { - if ((devlist[callcount] = strdup(ifr.ifr_name)) != NULL) { - ++callcount; - calllist[callcount] = NULL; - devlist [callcount] = NULL; - } else { - free((void*)calllist[callcount]); - calllist[callcount] = NULL; - devlist[callcount] = NULL; - } - } - } - fclose(fp); - fp = NULL; + /* Two header lines.. */ + s = fgets(buffer, sizeof(buffer), fp); + s = fgets(buffer, sizeof(buffer), fp); + /* .. then network interface names */ + while (!feof(fp)) { + if (!fgets(buffer, sizeof(buffer), fp)) + break; + s = strchr(buffer, ':'); + if (s) *s = 0; + s = buffer; + while (isspace(*s & 0xff)) ++s; + + memset(&ifr, 0, sizeof(ifr)); + strncpy(ifr.ifr_name, s, IFNAMSIZ-1); + ifr.ifr_name[IFNAMSIZ-1] = 0; + + if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) { + fprintf(stderr, "nrconfig: SIOCGIFHWADDR: %s\n", strerror(errno)); + return FALSE; + } + + if (ifr.ifr_hwaddr.sa_family != ARPHRD_NETROM) + continue; + + /* store found interface callsigns */ + /* ax25_ntoa() returns pointer to static buffer */ + s = ax25_ntoa((void*)ifr.ifr_hwaddr.sa_data); + + if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) { + fprintf(stderr, "nrconfig: SIOCGIFFLAGS: %s\n", strerror(errno)); + return FALSE; + } + + if (!(ifr.ifr_flags & IFF_UP)) + continue; + + + if ((pp = realloc(calllist, sizeof(char *) * (callcount+2))) == 0) + break; + calllist = pp; + if ((pp = realloc(devlist, sizeof(char *) * (callcount+2))) == 0) + break; + devlist = pp; + if ((calllist[callcount] = strdup(s)) != NULL) { + if ((devlist[callcount] = strdup(ifr.ifr_name)) != NULL) { + ++callcount; + calllist[callcount] = NULL; + devlist [callcount] = NULL; + } else { + free((void*)calllist[callcount]); + calllist[callcount] = NULL; + devlist[callcount] = NULL; + } + } + } + fclose(fp); + fp = NULL; } if ((fp = fopen(CONF_NRPORTS_FILE, "r")) == NULL) { - fprintf(stderr, "nrconfig: unable to open nrports file %s (%s)\n", CONF_NRPORTS_FILE, strerror(errno)); - goto cleanup; + fprintf(stderr, "nrconfig: unable to open nrports file %s (%s)\n", CONF_NRPORTS_FILE, strerror(errno)); + goto cleanup; } while (fp && fgets(buffer, 255, fp)) { - if ((s = strchr(buffer, '\n'))) - *s = '\0'; + if ((s = strchr(buffer, '\n'))) + *s = '\0'; - if (strlen(buffer) > 0 && *buffer != '#') - if (nr_config_init_port(fd, lineno, buffer, calllist, devlist)) - n++; + if (strlen(buffer) > 0 && *buffer != '#') + if (nr_config_init_port(fd, lineno, buffer, calllist, devlist)) + n++; - lineno++; + lineno++; } cleanup:; @@ -359,9 +359,9 @@ int nr_config_load_ports(void) if (fp) fclose(fp); for (i = 0; calllist && calllist[i]; ++i) { - free((void*)calllist[i]); - if (devlist[i] != NULL) - free((void*)devlist[i]); + free((void*)calllist[i]); + if (devlist[i] != NULL) + free((void*)devlist[i]); } if (calllist) free(calllist); if (devlist) free(devlist); @@ -167,11 +167,11 @@ static int rs_config_init_port(int fd, int lineno, char *line, const char **ifca found = 0; for (;ifcalls && *ifcalls; ++ifcalls, ++ifdevs) { - if (strcmp(addr,*ifcalls) == 0) { - found = 1; - dev = *ifdevs; - break; - } + if (strcmp(addr,*ifcalls) == 0) { + found = 1; + dev = *ifdevs; + break; + } } if (!found) { @@ -219,83 +219,83 @@ int rs_config_load_ports(void) if ((fd = socket(PF_FILE, SOCK_DGRAM, 0)) < 0) { - fprintf(stderr, "rsconfig: unable to open socket (%s)\n", strerror(errno)); - goto cleanup; + fprintf(stderr, "rsconfig: unable to open socket (%s)\n", strerror(errno)); + goto cleanup; } if ((fp = fopen("/proc/net/dev", "r"))) { - /* Two header lines.. */ - s = fgets(buffer, sizeof(buffer), fp); - s = fgets(buffer, sizeof(buffer), fp); - /* .. then network interface names */ - while (!feof(fp)) { - if (!fgets(buffer, sizeof(buffer), fp)) - break; - s = strchr(buffer, ':'); - if (s) *s = 0; - s = buffer; - while (isspace(*s & 0xff)) ++s; - - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, s, IFNAMSIZ-1); - ifr.ifr_name[IFNAMSIZ-1] = 0; - - if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) { - fprintf(stderr, "rsconfig: SIOCGIFHWADDR: %s\n", strerror(errno)); - return FALSE; - } - - if (ifr.ifr_hwaddr.sa_family != ARPHRD_ROSE) - continue; - - /* store found interface callsigns */ - /* rose_ntoa() returns pointer to static buffer */ - s = rose_ntoa((void*)ifr.ifr_hwaddr.sa_data); - - if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) { - fprintf(stderr, "rsconfig: SIOCGIFFLAGS: %s\n", strerror(errno)); - return FALSE; - } - - if (!(ifr.ifr_flags & IFF_UP)) - continue; - - - if ((pp = realloc(calllist, sizeof(char *) * (callcount+2))) == 0) - break; - calllist = pp; - if ((pp = realloc(devlist, sizeof(char *) * (callcount+2))) == 0) - break; - devlist = pp; - if ((calllist[callcount] = strdup(s)) != NULL) { - if ((devlist[callcount] = strdup(ifr.ifr_name)) != NULL) { - ++callcount; - calllist[callcount] = NULL; - devlist [callcount] = NULL; - } else { - free((void*)calllist[callcount]); - } - } - } - fclose(fp); - fp = NULL; + /* Two header lines.. */ + s = fgets(buffer, sizeof(buffer), fp); + s = fgets(buffer, sizeof(buffer), fp); + /* .. then network interface names */ + while (!feof(fp)) { + if (!fgets(buffer, sizeof(buffer), fp)) + break; + s = strchr(buffer, ':'); + if (s) *s = 0; + s = buffer; + while (isspace(*s & 0xff)) ++s; + + memset(&ifr, 0, sizeof(ifr)); + strncpy(ifr.ifr_name, s, IFNAMSIZ-1); + ifr.ifr_name[IFNAMSIZ-1] = 0; + + if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) { + fprintf(stderr, "rsconfig: SIOCGIFHWADDR: %s\n", strerror(errno)); + return FALSE; + } + + if (ifr.ifr_hwaddr.sa_family != ARPHRD_ROSE) + continue; + + /* store found interface callsigns */ + /* rose_ntoa() returns pointer to static buffer */ + s = rose_ntoa((void*)ifr.ifr_hwaddr.sa_data); + + if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) { + fprintf(stderr, "rsconfig: SIOCGIFFLAGS: %s\n", strerror(errno)); + return FALSE; + } + + if (!(ifr.ifr_flags & IFF_UP)) + continue; + + + if ((pp = realloc(calllist, sizeof(char *) * (callcount+2))) == 0) + break; + calllist = pp; + if ((pp = realloc(devlist, sizeof(char *) * (callcount+2))) == 0) + break; + devlist = pp; + if ((calllist[callcount] = strdup(s)) != NULL) { + if ((devlist[callcount] = strdup(ifr.ifr_name)) != NULL) { + ++callcount; + calllist[callcount] = NULL; + devlist [callcount] = NULL; + } else { + free((void*)calllist[callcount]); + } + } + } + fclose(fp); + fp = NULL; } if ((fp = fopen(CONF_RSPORTS_FILE, "r")) == NULL) { - fprintf(stderr, "rsconfig: unable to open axports file %s (%s)\n", CONF_RSPORTS_FILE, strerror(errno)); - goto cleanup; + fprintf(stderr, "rsconfig: unable to open axports file %s (%s)\n", CONF_RSPORTS_FILE, strerror(errno)); + goto cleanup; } while (fp && fgets(buffer, 255, fp)) { - if ((s = strchr(buffer, '\n'))) - *s = '\0'; + if ((s = strchr(buffer, '\n'))) + *s = '\0'; - if (strlen(buffer) > 0 && *buffer != '#') - if (rs_config_init_port(fd, lineno, buffer, calllist, devlist)) - n++; + if (strlen(buffer) > 0 && *buffer != '#') + if (rs_config_init_port(fd, lineno, buffer, calllist, devlist)) + n++; - lineno++; + lineno++; } cleanup:; @@ -303,8 +303,8 @@ int rs_config_load_ports(void) if (fp) fclose(fp); for (i = 0; calllist && calllist[i]; ++i) { - free((void*)calllist[i]); - if (devlist[i] != NULL) + free((void*)calllist[i]); + if (devlist[i] != NULL) free((void*)devlist[i]); } if (calllist) free(calllist); |