diff options
author | Thomas Habets <habets@google.com> | 2014-12-05 09:27:31 +0000 |
---|---|---|
committer | Thomas Habets <habets@google.com> | 2014-12-05 11:02:09 +0000 |
commit | 639719248c2b5d3a6c376631b3435eb820be89ef (patch) | |
tree | 8a647f643e269a9e07ba8db905229c9c0b29683f | |
parent | 995c5d9b93678267b5fcdaa93fd9022c58991f43 (diff) | |
download | arping-639719248c2b5d3a6c376631b3435eb820be89ef.tar.gz |
Use pcap_set_immediate_mode() to remove buffering delay.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/arping.c | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 8a1247c..a6b7b02 100644 --- a/configure.ac +++ b/configure.ac @@ -65,7 +65,7 @@ AC_FUNC_SELECT_ARGTYPES AC_FUNC_SETVBUF_REVERSED AC_TYPE_SIGNAL AC_CHECK_FUNCS([gettimeofday memset select strchr strdup strerror strstr \ -getifaddrs cap_init pcap_create]) +getifaddrs cap_init pcap_create pcap_set_immediate_mode]) if test x$ac_cv_func_getifaddrs = xyes; then AC_LIBOBJ([findif_getifaddrs]) diff --git a/src/arping.c b/src/arping.c index 9216fa7..937fef7 100644 --- a/src/arping.c +++ b/src/arping.c @@ -349,6 +349,17 @@ try_pcap_open_live(const char *device, int snaplen, goto err; } +#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE + // Without immediate mode some architectures (e.g. Linux with + // TPACKET_V3) will buffer replies and incorrectly upwards of + // hundreds of milliseconds of delay. + if ((rc = pcap_set_immediate_mode(pcap, 1))) { + if (verbose) { + fprintf(stderr, "arping: pcap_set_immediate_mode() failed: %s\n", pcap_statustostr(rc)); + } + } +#endif + // FIXME: pcap_set_tstamp_type if ((rc = pcap_activate(pcap))) { snprintf(errbuf, PCAP_ERRBUF_SIZE, "pcap_activate(): %s", pcap_statustostr(rc)); |