Don't bind SSID to interface addresses
Changes: * Remove ssid arguments from functions in src/if.c
This commit is contained in:
parent
e95994bf19
commit
305653e19b
2 changed files with 18 additions and 27 deletions
|
@ -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);
|
||||
|
|
37
src/if.c
37
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue