From c07545f90f00cae5cf2f74ab7f7e654d88b49586 Mon Sep 17 00:00:00 2001 From: Thomas Habets Date: Fri, 30 Apr 2021 20:16:55 +0100 Subject: Try lo0 if lo doesn't work --- src/arping.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/arping.c') diff --git a/src/arping.c b/src/arping.c index d9a5037..b5ee405 100644 --- a/src/arping.c +++ b/src/arping.c @@ -629,6 +629,8 @@ strip_newline(char* s) { * If this function retries with different parameter it will preserve * the original error message and print that. * Call with recursive=0. + * + * This function may recurse to try more interfaces. */ void do_libnet_init(const char *ifname, int recursive) @@ -659,6 +661,14 @@ do_libnet_init(const char *ifname, int recursive) return; } } else if (recursive) { + switch (recursive) { + case 1: + do_libnet_init("lo0", recursive+1); + if (libnet != NULL) { + return; + } + break; + } /* Continue original execution to get that * error message. */ return; @@ -1667,7 +1677,7 @@ static libnet_t* make_temp_libnet() { char ebuf[LIBNET_ERRBUF_SIZE]; - libnet_t* l = libnet_init(LIBNET_LINK, "lo", ebuf); + libnet_t* l = libnet_init(LIBNET_LINK, NULL, ebuf); if (!l) { fprintf(stderr, "arping: libnet_init(LIBNET_LINK, lo): %s\n", ebuf); exit(EXIT_FAILURE); -- cgit v1.2.1