Makefile.in | 8 ++++- aclocal.m4 | 3 +- bpf/net/bpf_filter.c | 13 +------- configure.in | 17 ++++++---- gencode.c | 1 + libpcap.map | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ optimize.c | 12 ++++---- pcap-linux.c | 51 +++++++++++++++++++++++++++++++++ pcap.3 | 8 +++-- 9 files changed, 160 insertions(+), 30 deletions(-) diff --git a/Makefile.in b/Makefile.in index 98396ec..9deb524 100644 --- a/Makefile.in +++ b/Makefile.in @@ -172,11 +172,13 @@ bpf_filter.c: $(srcdir)/bpf/net/bpf_filter.c bpf_filter.o: bpf_filter.c $(CC) $(CFLAGS) -c bpf_filter.c -install: libpcap.a +install-static: libpcap.a [ -d $(DESTDIR)$(libdir) ] || \ (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir)) $(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a $(RANLIB) $(DESTDIR)$(libdir)/libpcap.a + +install-include: [ -d $(DESTDIR)$(includedir) ] || \ (mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir)) $(INSTALL_DATA) $(srcdir)/pcap.h $(DESTDIR)$(includedir)/pcap.h @@ -184,11 +186,15 @@ install: libpcap.a $(DESTDIR)$(includedir)/pcap-bpf.h $(INSTALL_DATA) $(srcdir)/pcap-namedb.h \ $(DESTDIR)$(includedir)/pcap-namedb.h + +install-man: [ -d $(DESTDIR)$(mandir)/man3 ] || \ (mkdir -p $(DESTDIR)$(mandir)/man3; chmod 755 $(DESTDIR)$(mandir)/man3) $(INSTALL_DATA) $(srcdir)/pcap.3 \ $(DESTDIR)$(mandir)/man3/pcap.3 +install: install-static install-include install-man + install-shared: install-shared-$(DYEXT) install-shared-so: libpcap.so $(INSTALL_PROGRAM) libpcap.so.`cat VERSION` $(DESTDIR)$(libdir)/libpcap.so.`cat VERSION` diff --git a/aclocal.m4 b/aclocal.m4 index 1efb474..d84c52e 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -44,7 +44,7 @@ dnl LBL_CFLAGS dnl AC_DEFUN(AC_LBL_C_INIT, [AC_PREREQ(2.12) - AC_BEFORE([$0], [AC_PROG_CC]) + AC_REQUIRE([AC_PROG_CC]) AC_BEFORE([$0], [AC_LBL_FIXINCLUDES]) AC_BEFORE([$0], [AC_LBL_DEVEL]) AC_ARG_WITH(gcc, [ --without-gcc don't use gcc]) @@ -72,7 +72,6 @@ AC_DEFUN(AC_LBL_C_INIT, CC=cc export CC fi - AC_PROG_CC if test "$GCC" = yes ; then if test "$SHLICC2" = yes ; then ac_cv_lbl_gcc_vers=2 diff --git a/bpf/net/bpf_filter.c b/bpf/net/bpf_filter.c index 40df32a..fbc1a54 100644 --- a/bpf/net/bpf_filter.c +++ b/bpf/net/bpf_filter.c @@ -80,19 +80,10 @@ static const char rcsid[] _U_ = #define int32 bpf_int32 #define u_int32 bpf_u_int32 -#ifndef LBL_ALIGN -/* - * XXX - IA-64? If not, this probably won't work on Win64 IA-64 - * systems, unless LBL_ALIGN is defined elsewhere for them. - * XXX - SuperH? If not, this probably won't work on WinCE SuperH - * systems, unless LBL_ALIGN is defined elsewhere for them. - */ -#if defined(sparc) || defined(__sparc__) || defined(mips) || \ - defined(ibm032) || defined(__alpha) || defined(__hpux) || \ - defined(__arm__) +#if !defined(LBL_ALIGN) && \ + !defined(__i386__) && !defined(__x86_64__) && !defined(__vax__) #define LBL_ALIGN #endif -#endif #ifndef LBL_ALIGN #ifndef WIN32 diff --git a/configure.in b/configure.in index a9d2171..799cc92 100644 --- a/configure.in +++ b/configure.in @@ -16,6 +16,8 @@ AC_LBL_C_INIT(V_CCOPT, V_INCLS, V_LIBS) AC_LBL_C_INLINE AC_C___ATTRIBUTE__ +AC_SYS_LARGEFILE + AC_LBL_CHECK_TYPE(u_int8_t, u_char) AC_LBL_CHECK_TYPE(u_int16_t, u_short) AC_LBL_CHECK_TYPE(u_int32_t, u_int) @@ -385,16 +387,17 @@ null) esac -AC_MSG_CHECKING(whether we have /proc/net/dev) -if test -r /proc/net/dev ; then - ac_cv_lbl_proc_net_dev=yes -else - ac_cv_lbl_proc_net_dev=no -fi +AC_CACHE_CHECK([whether we have /proc/net/dev], [ac_cv_lbl_proc_net_dev], +[ + if test -r /proc/net/dev ; then + ac_cv_lbl_proc_net_dev=yes + else + ac_cv_lbl_proc_net_dev=no + fi +]) if test $ac_cv_lbl_proc_net_dev = yes; then AC_DEFINE(HAVE_PROC_NET_DEV, 1, [define if you have a /proc/net/dev]) fi -AC_MSG_RESULT($ac_cv_lbl_proc_net_dev) # Check for Endace DAG card support. AC_ARG_WITH([dag], [ --with-dag[[=DIR]] include Endace DAG support ("yes", "no" or DIR; default="yes" on BSD and Linux if present)], diff --git a/gencode.c b/gencode.c index 5067abc..4c46d95 100644 --- a/gencode.c +++ b/gencode.c @@ -6347,6 +6347,7 @@ gen_inbound(dir) */ switch (linktype) { case DLT_SLIP: + case DLT_PPP: b0 = gen_relation(BPF_JEQ, gen_load(Q_LINK, gen_loadi(0), 1), gen_loadi(0), diff --git a/libpcap.map b/libpcap.map new file mode 100644 index 0000000..caebb14 --- /dev/null +++ b/libpcap.map @@ -0,0 +1,77 @@ +# $Owl$ + +{ + global: + __pcap_atodn; + __pcap_atoin; + __pcap_nametodnaddr; + bpf_dump; + bpf_filter; + bpf_image; + bpf_validate; + eproto_db; + pcap_breakloop; + pcap_close; + pcap_compile; + pcap_compile_nopcap; + pcap_datalink; + pcap_datalink_name_to_val; + pcap_datalink_val_to_description; + pcap_datalink_val_to_name; + pcap_dispatch; + pcap_dump; + pcap_dump_close; + pcap_dump_file; + pcap_dump_flush; + pcap_dump_fopen; + pcap_dump_ftell; + pcap_dump_open; + pcap_ether_aton; + pcap_ether_hostton; + pcap_file; + pcap_fileno; + pcap_findalldevs; + pcap_fopen_offline; + pcap_freealldevs; + pcap_freecode; + pcap_get_selectable_fd; + pcap_geterr; + pcap_getnonblock; + pcap_inject; + pcap_is_swapped; + pcap_lib_version; + pcap_list_datalinks; + pcap_lookupdev; + pcap_lookupnet; + pcap_loop; + pcap_major_version; + pcap_minor_version; + pcap_nametoaddr; + pcap_nametoaddrinfo; + pcap_nametoeproto; + pcap_nametollc; + pcap_nametonetaddr; + pcap_nametoport; + pcap_nametoportrange; + pcap_nametoproto; + pcap_next; + pcap_next_etherent; + pcap_next_ex; + pcap_offline_read; + pcap_open_dead; + pcap_open_live; + pcap_open_offline; + pcap_perror; + pcap_read; + pcap_sendpacket; + pcap_set_datalink; + pcap_setdirection; + pcap_setfilter; + pcap_setnonblock; + pcap_snapshot; + pcap_stats; + pcap_strerror; + pcap_version; + local: + *; +}; diff --git a/optimize.c b/optimize.c index 1502ab1..d0c3ea2 100644 --- a/optimize.c +++ b/optimize.c @@ -146,7 +146,7 @@ static void opt_dump(struct block *); static int n_blocks; struct block **blocks; static int n_edges; -struct edge **edges; +static struct edge **edges; /* * A bit vector set representation of the dominators. @@ -154,8 +154,8 @@ struct edge **edges; */ static int nodewords; static int edgewords; -struct block **levels; -bpf_u_int32 *space; +static struct block **levels; +static bpf_u_int32 *space; #define BITS_PER_WORD (8*sizeof(bpf_u_int32)) /* * True if a is in uset {p} @@ -559,9 +559,9 @@ struct vmapinfo { bpf_int32 const_val; }; -struct vmapinfo *vmap; -struct valnode *vnode_base; -struct valnode *next_vnode; +static struct vmapinfo *vmap; +static struct valnode *vnode_base; +static struct valnode *next_vnode; static void init_val() diff --git a/pcap-linux.c b/pcap-linux.c index e9db010..b76879c 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -505,6 +505,57 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata) handle->break_loop = 0; return -2; } + + /* + * If the user specified a timeout in pcap_open_live(), + * we will honor the timeout and wait for specified time + * unless packets pending. + */ + if ((handle->fd >= 0) && (handle->md.timeout > 0)) { + fd_set readfs; + struct timeval tv; + int retval; + + FD_ZERO(&readfs); + FD_SET(handle->fd, &readfs); + + memset(&tv, 0, sizeof(tv)); + tv.tv_sec = handle->md.timeout / 1000; + tv.tv_usec = (handle->md.timeout % 1000) * 1000; + + while (!handle->break_loop) { + /* + * We can assume Linux select(2) behaviour: + * in case of error, readfs will be kept + * unchanged and tv will be updated. + */ + retval = select(handle->fd + 1, + &readfs, NULL, NULL, &tv); + if (retval > 0) + break; + if (retval == 0) + return 0; + if (EINTR == errno) + continue; + snprintf(handle->errbuf, sizeof(handle->errbuf), + "select: %s", pcap_strerror(errno)); + return -1; + } + + /* + * Has "pcap_breakloop()" been called? + */ + if (handle->break_loop) { + /* + * Yes - clear the flag that indicates that it + * has, and return -2 as an indication that we + * were told to break out of the loop. + */ + handle->break_loop = 0; + return -2; + } + } + fromlen = sizeof(from); packet_len = recvfrom( handle->fd, bp + offset, diff --git a/pcap.3 b/pcap.3 index 94b1f6a..c0199b0 100644 --- a/pcap.3 +++ b/pcap.3 @@ -215,7 +215,7 @@ is called to open a ``savefile'' for reading. .I fname specifies the name of the file to open. The file has the same format as those used by -.B tcpdump(1) +.B tcpdump(8) and .BR tcpslice(1) . The name "-" in a synonym for @@ -437,7 +437,9 @@ of \-1 processes all the packets received in one buffer when reading a live capture, or all the packets in the file when reading a ``savefile''. .I callback -specifies a routine to be called with three arguments: +specifies a +.I pcap_handler +routine to be called with three arguments: a .I u_char pointer which is passed in from @@ -1284,7 +1286,7 @@ is returned on error. closes the ``savefile.'' .PP .SH SEE ALSO -tcpdump(1), tcpslice(1) +tcpdump(8), tcpslice(1) .SH AUTHORS The original authors are: .LP