Remove pcap_set_immediate_mode backwards compatiblity
This commit is contained in:
parent
f66c937d12
commit
2658b1f9df
1 changed files with 2 additions and 52 deletions
54
ethsock.c
54
ethsock.c
|
|
@ -44,7 +44,6 @@
|
||||||
#include <linux/if_packet.h>
|
#include <linux/if_packet.h>
|
||||||
#include <netlink/route/addr.h>
|
#include <netlink/route/addr.h>
|
||||||
#include <netlink/route/neighbour.h>
|
#include <netlink/route/neighbour.h>
|
||||||
#include <dlfcn.h>
|
|
||||||
#else
|
#else
|
||||||
#define NMRPFLASH_AF_PACKET AF_LINK
|
#define NMRPFLASH_AF_PACKET AF_LINK
|
||||||
#include <net/if_types.h>
|
#include <net/if_types.h>
|
||||||
|
|
@ -93,48 +92,6 @@ static int x_pcap_findalldevs(pcap_if_t **devs)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// pcap_set_immediate_mode was introduced in libpcap-1.5.0,
|
|
||||||
// but we also want to support earlier versions
|
|
||||||
|
|
||||||
static int (*f_pcap_set_immediate_mode)(pcap_t*, int) = NULL;
|
|
||||||
|
|
||||||
static int x_pcap_set_immediate_mode(pcap_t *p, int immediate_mode)
|
|
||||||
{
|
|
||||||
#ifndef NMRPFLASH_WINDOWS
|
|
||||||
if (!f_pcap_set_immediate_mode) {
|
|
||||||
f_pcap_set_immediate_mode = dlsym(NULL, "pcap_set_immediate_mode");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (f_pcap_set_immediate_mode) {
|
|
||||||
return f_pcap_set_immediate_mode(p, immediate_mode);
|
|
||||||
} else {
|
|
||||||
if (verbosity > 2) {
|
|
||||||
fprintf(stderr, "Warning: pcap_set_immediate_mode is not available.\n");
|
|
||||||
}
|
|
||||||
// silently ignore
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// No workaround for Npcap
|
|
||||||
return pcap_set_immediate_mode(p, immediate_mode);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef NMRPFLASH_BSD
|
|
||||||
static int bsd_set_immediate_mode(pcap_t *p, int immediate_mode)
|
|
||||||
{
|
|
||||||
// if we have "pcap_set_immediate_mode", then there's no need to call this function. the
|
|
||||||
// reason for having both, is that this function must be called *after* activation, whereas
|
|
||||||
// pcap_set_immediate_mode must be called *before* activation!
|
|
||||||
|
|
||||||
if (f_pcap_set_immediate_mode) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ioctl(pcap_fileno(p), BIOCIMMEDIATE, 1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool intf_get_pcap_flags(const char *intf, bpf_u_int32 *flags)
|
static bool intf_get_pcap_flags(const char *intf, bpf_u_int32 *flags)
|
||||||
{
|
{
|
||||||
pcap_if_t *devs, *dev;
|
pcap_if_t *devs, *dev;
|
||||||
|
|
@ -694,7 +651,7 @@ struct ethsock *ethsock_create(const char *intf, uint16_t protocol)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = x_pcap_set_immediate_mode(sock->pcap, 1);
|
err = pcap_set_immediate_mode(sock->pcap, 1);
|
||||||
if (err) {
|
if (err) {
|
||||||
pcap_perror(sock->pcap, "pcap_set_immediate_mode");
|
pcap_perror(sock->pcap, "pcap_set_immediate_mode");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
@ -743,14 +700,7 @@ struct ethsock *ethsock_create(const char *intf, uint16_t protocol)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NMRPFLASH_BSD
|
#endif
|
||||||
err = bsd_set_immediate_mode(sock->pcap, 1);
|
|
||||||
if (err) {
|
|
||||||
fprintf(stderr, "Warning: setting immediate mode failed: %s.\n", strerror(errno));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
#endif // NMRPFLASH_BSD
|
|
||||||
#endif // NMRPFLASH_WINDOWS
|
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "ether proto 0x%04x and not ether src %s",
|
snprintf(buf, sizeof(buf), "ether proto 0x%04x and not ether src %s",
|
||||||
protocol, mac_to_str(sock->hwaddr));
|
protocol, mac_to_str(sock->hwaddr));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue