From: Joseph C. Lehner Date: Thu, 23 Feb 2017 17:38:15 +0000 (+0100) Subject: Use pcap_setdirection instead of filter X-Git-Tag: v0.9.11~7 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=590e7a079f097cabe19705aa8b22f486e1ca2d44;p=oweals%2Fnmrpflash.git Use pcap_setdirection instead of filter --- diff --git a/ethsock.c b/ethsock.c index 682b4b2..18774e0 100644 --- a/ethsock.c +++ b/ethsock.c @@ -345,7 +345,7 @@ inline uint8_t *ethsock_get_hwaddr(struct ethsock *sock) struct ethsock *ethsock_create(const char *intf, uint16_t protocol) { char buf[PCAP_ERRBUF_SIZE]; - struct bpf_program fp; + struct bpf_program bpf; struct ethsock *sock; bool is_bridge; int err; @@ -412,17 +412,22 @@ struct ethsock *ethsock_create(const char *intf, uint16_t protocol) } #endif - snprintf(buf, sizeof(buf), "ether proto 0x%04x and not ether src %s", - protocol, mac_to_str(sock->hwaddr)); + err = pcap_setdirection(sock->pcap, PCAP_D_IN); + if (err) { + pcap_perror(sock->pcap, "pcap_setdirection"); + goto cleanup; + } + + snprintf(buf, sizeof(buf), "ether proto 0x%04x", protocol); - err = pcap_compile(sock->pcap, &fp, buf, 0, 0); + err = pcap_compile(sock->pcap, &bpf, buf, 0, 0); if (err) { pcap_perror(sock->pcap, "pcap_compile"); goto cleanup; } - err = pcap_setfilter(sock->pcap, &fp); - pcap_freecode(&fp); + err = pcap_setfilter(sock->pcap, &bpf); + pcap_freecode(&bpf); if (err) { pcap_perror(sock->pcap, "pcap_setfilter");