diff --git a/include/patty/ax25/if.h b/include/patty/ax25/if.h index 81dc9d9..757db38 100644 --- a/include/patty/ax25/if.h +++ b/include/patty/ax25/if.h @@ -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); diff --git a/src/if.c b/src/if.c index 68a10e9..755329f 100644 --- a/src/if.c +++ b/src/if.c @@ -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)) { diff --git a/src/server.c b/src/server.c index cf7ca38..b17e452 100644 --- a/src/server.c +++ b/src/server.c @@ -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(¶ms, buf, offset, len) < 0) { goto error_io; }