From 305653e19b3121b43135184e5a26a61d53f2e916 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sat, 18 Jul 2020 16:11:01 -0400 Subject: [PATCH] Don't bind SSID to interface addresses Changes: * Remove ssid arguments from functions in src/if.c --- include/patty/ax25/if.h | 8 +++----- src/if.c | 37 +++++++++++++++---------------------- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/include/patty/ax25/if.h b/include/patty/ax25/if.h index e4f4592..d3c030b 100644 --- a/include/patty/ax25/if.h +++ b/include/patty/ax25/if.h @@ -79,13 +79,11 @@ patty_ax25_if *patty_ax25_if_new(int opts, patty_ax25_if_info *info); void patty_ax25_if_destroy(patty_ax25_if *iface); int patty_ax25_if_addr_each(patty_ax25_if *iface, - int (*callback)(char *, uint8_t, void *), void *ctx); + int (*callback)(char *, void *), void *ctx); -int patty_ax25_if_addr_add(patty_ax25_if *iface, - const char *callsign, uint8_t ssid); +int patty_ax25_if_addr_add(patty_ax25_if *iface, const char *callsign); -int patty_ax25_if_addr_delete(patty_ax25_if *iface, - const char *callsign, uint8_t ssid); +int patty_ax25_if_addr_delete(patty_ax25_if *iface, const char *callsign); int patty_ax25_if_promisc_add(patty_ax25_if *iface, int fd); diff --git a/src/if.c b/src/if.c index 8e63f9a..dee7f80 100644 --- a/src/if.c +++ b/src/if.c @@ -126,7 +126,7 @@ void patty_ax25_if_destroy(patty_ax25_if *iface) { } int patty_ax25_if_addr_each(patty_ax25_if *iface, - int (*callback)(char *, uint8_t, void *), void *ctx) { + int (*callback)(char *, void *), void *ctx) { patty_list_item *item = iface->aliases->first; char buf[7]; @@ -136,7 +136,7 @@ int patty_ax25_if_addr_each(patty_ax25_if *iface, goto error_ntop_addr; } - if (callback(buf, ssid, ctx) < 0) { + if (callback(buf, ctx) < 0) { goto error_callback_addr; } @@ -147,7 +147,7 @@ int patty_ax25_if_addr_each(patty_ax25_if *iface, goto error_ntop; } - if (callback(buf, ssid, ctx) < 0) { + if (callback(buf, ctx) < 0) { goto error_callback; } @@ -164,25 +164,24 @@ error_ntop_addr: } static patty_ax25_addr *find_addr(patty_ax25_if *iface, - const char *callsign, - uint8_t ssid) { + const char *callsign) { patty_list_item *item = iface->aliases->first; char buf[7]; - uint8_t addr_ssid; + uint8_t ssid; - if (patty_ax25_ntop(&iface->addr, buf, &addr_ssid, sizeof(buf)) < 0) { + if (patty_ax25_ntop(&iface->addr, buf, &ssid, sizeof(buf)) < 0) { goto error_ntop_addr; } - if (strncmp(buf, callsign, sizeof(buf)) == 0 && addr_ssid == ssid) { + if (strncmp(buf, callsign, sizeof(buf)) == 0) { return &iface->addr; } while (item) { patty_ax25_addr *addr = item->value; - if (patty_ax25_ntop(addr, buf, &addr_ssid, sizeof(buf)) < 0) { + if (patty_ax25_ntop(addr, buf, &ssid, sizeof(buf)) < 0) { goto error_ntop; } @@ -190,10 +189,6 @@ static patty_ax25_addr *find_addr(patty_ax25_if *iface, goto next; } - if (addr_ssid != ssid) { - goto next; - } - return addr; next: item = item->next; @@ -205,11 +200,10 @@ error_ntop_addr: } int patty_ax25_if_addr_add(patty_ax25_if *iface, - const char *callsign, - uint8_t ssid) { + const char *callsign) { patty_ax25_addr *addr; - if (find_addr(iface, callsign, ssid) != NULL) { + if (find_addr(iface, callsign) != NULL) { errno = EEXIST; goto error_exists; @@ -219,7 +213,7 @@ int patty_ax25_if_addr_add(patty_ax25_if *iface, goto error_malloc_addr; } - if (patty_ax25_pton(callsign, ssid, addr) < 0) { + if (patty_ax25_pton(callsign, 0, addr) < 0) { goto error_pton; } @@ -239,22 +233,21 @@ error_exists: } int patty_ax25_if_addr_delete(patty_ax25_if *iface, - const char *callsign, - uint8_t ssid) { + const char *callsign) { patty_list_item *item = iface->aliases->first; int i = 0; while (item) { char buf[7]; - uint8_t addr_ssid; + uint8_t ssid; patty_ax25_addr *addr = item->value; - if (patty_ax25_ntop(addr, buf, &addr_ssid, sizeof(buf)) < 0) { + if (patty_ax25_ntop(addr, buf, &ssid, sizeof(buf)) < 0) { goto error_ntop; } - if (strncmp(buf, callsign, sizeof(buf)) == 0 && addr_ssid == ssid) { + if (strncmp(buf, callsign, sizeof(buf)) == 0) { if (patty_list_splice(iface->aliases, i) == NULL) { goto error_list_splice; }