Disregard TEST, UA and XID not addressed to iface

This commit is contained in:
XANTRONIX Development 2020-08-22 15:33:12 -05:00 committed by XANTRONIX Industrial
parent 222e51100e
commit bdbab9c5e7
3 changed files with 40 additions and 0 deletions

View file

@ -90,6 +90,9 @@ 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);
int patty_ax25_if_addr_match(patty_ax25_if *iface,
const patty_ax25_addr *addr);
int patty_ax25_if_promisc_add(patty_ax25_if *iface,
int fd);

View file

@ -269,6 +269,31 @@ error_ntop:
return -1;
}
int patty_ax25_if_addr_match(patty_ax25_if *iface,
const patty_ax25_addr *addr) {
patty_list_item *item;
if (memcmp(&iface->addr.callsign,
&addr->callsign,
sizeof(addr->callsign)) == 0) {
return 1;
}
item = iface->aliases->first;
while ((item = item->next) != NULL) {
patty_ax25_addr *alias = item->value;
if (memcmp(&alias->callsign,
&addr->callsign,
sizeof(addr->callsign)) == 0) {
return 1;
}
}
return 0;
}
int patty_ax25_if_promisc_add(patty_ax25_if *iface,
int fd) {
if (patty_dict_get(iface->promisc_fds, (uint32_t)fd)) {

View file

@ -1417,6 +1417,10 @@ error_client_by_sock:
static int handle_test(patty_ax25_server *server,
patty_ax25_if *iface,
patty_ax25_frame *frame) {
if (!patty_ax25_if_addr_match(iface, &frame->dest)) {
return 0;
}
return reply_test(iface, frame);
}
@ -1426,6 +1430,10 @@ static int handle_ua(patty_ax25_server *server,
patty_ax25_frame *frame) {
int client;
if (!patty_ax25_if_addr_match(iface, &frame->dest)) {
return 0;
}
if (sock == NULL) {
return reply_dm(iface, frame, PATTY_AX25_FRAME_FINAL);
}
@ -1783,6 +1791,10 @@ static int handle_xid(patty_ax25_server *server,
int ret;
if (!patty_ax25_if_addr_match(iface, &frame->dest)) {
return 0;
}
if (patty_ax25_frame_decode_xid(&params, buf, offset, len) < 0) {
goto error_io;
}