From ed11cf70be0935d8e5dd389e829aa2527ccf674f Mon Sep 17 00:00:00 2001 From: Thomas Osterried Date: Tue, 31 Jan 2012 23:18:37 +0000 Subject: Fixed Bug: libax25 cannot find interfaces with callsign's without SSID. In http://www.linux-ax25.org/cvsweb/libax25/ChangeLog we read: Revision 1.8: download - view: text, markup, annotated - select for diffs Thu Sep 10 16:53:28 2009 UTC (2 years, 4 months ago) by ralf Branches: MAIN CVS tags: HEAD Diff to: previous 1.7: preferred, colored Changes since revision 1.7: +5 -0 lines ax25_ntoa: Don't emit SSID suffix if the SSID is zero. From: Matti Aarnio OH2MQK In http://www.linux-ax25.org/cvsweb/libax25/axutils.c.diff?r1=1.4;r2=1.5 funtion char *ax25_ntoa(const ax25_address *a): - *s++ = '-'; + /* Convention is: -0 suffixes are NOT printed */ + if (a->ax25_call[6] & 0x1E) { + *s++ = '-'; - if ((n = ((a->ax25_call[6] >> 1) & 0x0F)) > 9) { - *s++ = '1'; - n -= 10; + if ((n = ((a->ax25_call[6] >> 1) & 0x0F)) > 9) { + *s++ = '1'; + n -= 10; + } + *s++ = n + '0'; } - - *s++ = n + '0'; + *s++ = '\0'; This is diametral to the previous situation, where ax25_ntoa always returned a call with SSID. Unfortunately, that patch broke a fixe introduced in April 2009; that patch fixed the same issue introduced by a patch in April 2008: http://www.linux-ax25.org/cvsweb/libax25/axconfig.c This is a fix for a bug introduced 2008-04-02, which caused interfaces containing CALL without SSID not being found anymore (user had to address CALL-0 instead of just CALL). http://www.linux-ax25.org/cvsweb/libax25/axconfig.c.diff?r1=1.7;r2=1.8 [..] + /* user may have configured "DL9SAU". But we compare to *ifcalls, + * which comes from ifr_hwaddr.sa_data and it always contains a SSID; + * in this case, "DL9SAU-0". This fixes a bug introduced 2008-04-02, + * which caused interfaces without SSID not being found anymore. :( + */ [..] It has been overseen that libax25 internaly uses ax25_ntoa, not just for user-presentation. The fix today resolves the problem, and cleans up helper routines like strip_zero_ssid() that are no longer needed. Affected files: axconfig.c, nrconfig.c and procutils.c. --- axconfig.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'axconfig.c') diff --git a/axconfig.c b/axconfig.c index ceb8490..e3505d3 100644 --- a/axconfig.c +++ b/axconfig.c @@ -195,7 +195,6 @@ static int ax25_config_init_port(int fd, int lineno, char *line, const char **if char *name, *call, *baud, *paclen, *window, *desc; const char *dev = NULL; int found; - char call_beautified[10]; /* DL9SAU-10\0 */ name = strtok(line, " \t"); call = strtok(NULL, " \t"); @@ -237,26 +236,18 @@ static int ax25_config_init_port(int fd, int lineno, char *line, const char **if } strupr(call); - /* user may have configured "DL9SAU". But we compare to *ifcalls, - * which comes from ifr_hwaddr.sa_data and it always contains a SSID; - * in this case, "DL9SAU-0". This fixes a bug introduced 2008-04-02, - * which caused interfaces without SSID not being found anymore. :( - */ - strncpy(call_beautified, call, sizeof(call_beautified)-1); - call_beautified[sizeof(call_beautified)-1] = 0; - if (strchr(call_beautified, '-') == NULL && strlen(call_beautified) < 7) - strcat(call_beautified, "-0"); - found = 0; + char *cp; + if ((cp = strstr(call, "-0")) != NULL) + *cp = '\0'; for (;ifcalls && *ifcalls; ++ifcalls, ++ifdevs) { - if (strcmp(call_beautified, *ifcalls) == 0) { + if (strcmp(call, *ifcalls) == 0) { found = 1; dev = *ifdevs; break; } } - if (!found) { #if 0 /* None of your business to complain about some port being down... */ fprintf(stderr, "axconfig: port with call '%s' is not active\n", call); @@ -270,7 +261,7 @@ static int ax25_config_init_port(int fd, int lineno, char *line, const char **if } p->Name = strdup(name); - p->Call = strdup(call_beautified); + p->Call = strdup(call); p->Device = strdup(dev); p->Baud = atoi(baud); p->Window = atoi(window); -- cgit v1.2.3