1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

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.
This commit is contained in:
Benjamin Valentin 2021-12-03 10:41:20 +01:00 committed by Benjamin Valentin
parent 4d96c1f8e0
commit 5ef70dbee9

View File

@ -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;