From 5ef70dbee9a9e6b7137e4a72af4ae6073ef21120 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 3 Dec 2021 10:41:20 +0100 Subject: [PATCH] tools/zep_dispatch: replace sniffer instead of ignoring it There can only be a single sniffer, but instead of ignoring any subsequent sniffers, replace the existing one. This avoids the silly behaviour that you can't attach the sniffer anymore should you ever quit it. --- dist/tools/zep_dispatch/topology.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/tools/zep_dispatch/topology.c b/dist/tools/zep_dispatch/topology.c index 1cef2f322d..7f6a55de22 100644 --- a/dist/tools/zep_dispatch/topology.c +++ b/dist/tools/zep_dispatch/topology.c @@ -285,14 +285,14 @@ bool topology_add(topology_t *t, const uint8_t *mac, uint8_t mac_len, void topology_set_sniffer(topology_t *t, struct sockaddr_in6 *addr) { - if (t->has_sniffer) { - return; - } - char addr_str[INET6_ADDRSTRLEN]; getnameinfo((struct sockaddr*)addr, sizeof(*addr), addr_str, sizeof(addr_str), 0, 0, NI_NUMERICHOST); - printf("adding sniffer %s\n", addr_str); + if (t->has_sniffer) { + printf("replace sniffer with %s\n", addr_str); + } else { + printf("adding sniffer %s\n", addr_str); + } memcpy(&t->sniffer_addr, addr, sizeof(t->sniffer_addr)); t->has_sniffer = true;