From bb9cccf476482fc36ae7568d6e679ccd754261f0 Mon Sep 17 00:00:00 2001 From: Thomas Osterried Date: Sat, 21 Oct 2006 10:22:36 +0000 Subject: logical error in my last patch: instead of coping the interface name of the corresponding axports line to axif, i compared axif->Name with the device name. This matched only interfaces which are configured as "ax0 ....." in axports, and was, indeed, not intended. --- axconfig.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'axconfig.c') diff --git a/axconfig.c b/axconfig.c index 756b8ef..8a2f8b2 100644 --- a/axconfig.c +++ b/axconfig.c @@ -225,6 +225,8 @@ static void free_ax25_ifaces() { static int test_and_add_ax25_iface(int fd, char *name, struct ifreq *ifr) { AX_Iface *axif; + if (fd == -1) + return 0; if (!name) return 0; if (!strcmp(name, "lo")) return 0; @@ -276,6 +278,7 @@ static int test_and_add_ax25_iface(int fd, char *name, struct ifreq *ifr) { return 1; } +#ifdef FIND_ALL_INTERFACES static char *proc_get_iface_name(char *line) { char *p; @@ -288,11 +291,14 @@ static char *proc_get_iface_name(char *line) { return 0; // should never hapen return line; } +#endif static int get_ax25_ifaces(void) { +#ifdef FIND_ALL_INTERFACES FILE *fp; +#endif struct ifreq ifr; - int fd; + int fd = -1; int ret = -1; free_ax25_ifaces(); @@ -343,7 +349,8 @@ static int get_ax25_ifaces(void) { } out: - close(fd); + if (fd != -1) + close(fd); return ret; } @@ -397,17 +404,22 @@ static int ax25_config_init_port(int lineno, char *line) strupr(call); for (axif = ax25_ifaces; axif; axif = axif->Next) { - if (!strcmp(axif->Name, name)) { - found = 1; + if (ax25_hw_cmp(call, axif->Call)) { + /* associate list of ifaces with the name from axports we just found */ + if (!strcmp(axif->Name, name)) { + free(axif->Name); + if (!(axif->Name = strdup(name))) { + fprintf(stderr, "axconfig: out of memory!\n"); + return -1; + } + } dev = axif->Device; - /* exact match */ - if (ax25_hw_cmp(call, axif->Call)) - found = 2; + found = 1; break; } } - if (found < 2) { + if (!found) { fprintf(stderr, "axconfig: port %s not active\n", name); return -1; } -- cgit v1.2.3