From 25e236493066c5f84675831aabb491fdcc299782 Mon Sep 17 00:00:00 2001 From: "Joseph C. Lehner" Date: Tue, 11 Oct 2022 18:21:14 +0200 Subject: [PATCH] Show pcap_inject errors with '-vv' on Windows --- ethsock.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ethsock.c b/ethsock.c index 6a8321e..d53826d 100644 --- a/ethsock.c +++ b/ethsock.c @@ -780,13 +780,16 @@ int ethsock_send(struct ethsock *sock, void *buf, size_t len) { if (pcap_inject(sock->pcap, buf, len) != len) { #ifdef NMRPFLASH_WINDOWS - // In recent Npcap versions, pcap_inject fails if the - // interface is unplugged. This doesn't happen on either - // Linux or macOS. + // Npcap's pcap_inject fails in many cases where neither + // Linux or macOS report an error. For now, we simply + // ignore errors if unplugged (and let all other through + // as well, just printing a debug line). - if (ethsock_is_unplugged(sock)) { - return 0; + if (!ethsock_is_unplugged(sock) && verbosity > 1) { + pcap_perror(sock->pcap, "pcap_inject"); } + + return 0; #endif pcap_perror(sock->pcap, "pcap_inject"); return -1;