]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Check whether we have "pcap_breakloop()", and use it if we do - it's a
authorguy <guy>
Tue, 4 Nov 2003 07:29:15 +0000 (07:29 +0000)
committerguy <guy>
Tue, 4 Nov 2003 07:29:15 +0000 (07:29 +0000)
safer way to terminate "pcap_loop()" in a signal handler (it just sets a
flag, it doesn't muck with data structures that might have been in the
middle of being updated).

Have "setsignal()" not request SA_RESTART, so that if we call
"pcap_breakloop()" in a signal handler and then return, we don't restart
a call that was waiting for captured packets, we just make that call
EINTR out.

aclocal.m4
config.h.in
configure
setsignal.c
tcpdump.c

index 20d2effda60817d3f37c64e73a798ce263442494..fddb53b2d610f8617598d5054493d4e3ff4a6f22 100644 (file)
@@ -1,4 +1,4 @@
-dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.97 2003-05-02 08:41:01 guy Exp $ (LBL)
+dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.98 2003-11-04 07:29:15 guy Exp $ (LBL)
 dnl
 dnl Copyright (c) 1995, 1996, 1997, 1998
 dnl    The Regents of the University of California.  All rights reserved.
@@ -322,7 +322,8 @@ AC_DEFUN(AC_LBL_LIBPCAP,
 
     dnl
     dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()",
-    dnl and "pcap_datalink_name_to_val()".
+    dnl and "pcap_datalink_name_to_val()", and use substitute versions
+    dnl if they're not present
     dnl
     AC_CHECK_FUNC(pcap_list_datalinks,
        AC_DEFINE(HAVE_PCAP_LIST_DATALINKS),
@@ -332,6 +333,13 @@ AC_DEFUN(AC_LBL_LIBPCAP,
     AC_CHECK_FUNC(pcap_datalink_name_to_val,
        AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL),
        LIBOBJS="$LIBOBJS dlnames.o")
+
+    dnl
+    dnl Check for "pcap_breakloop()"; you can't substitute for it if
+    dnl it's absent (it has hooks into the live capture routines),
+    dnl so just define the HAVE_ value if it's there.
+    dnl
+    AC_CHECK_FUNCS(pcap_breakloop)
 ])
 
 dnl
index 6a3219728117afe3054de611aee0554ff9169ec6..bb522b939a46a5986a3fb5f922de336d0f5b7f8c 100644 (file)
 /* Define if you have the getnameinfo function.  */
 #undef HAVE_GETNAMEINFO
 
+/* Define if you have the pcap_breakloop function.  */
+#undef HAVE_PCAP_BREAKLOOP
+
 /* Define if you have the pcap_dump_flush function.  */
 #undef HAVE_PCAP_DUMP_FLUSH
 
index b30178005bfeaaff8d5eecf8b73b3204fa1295e1..2d3a8f9df699012eb3181edfa0feba0c2e95e502 100755 (executable)
--- a/configure
+++ b/configure
@@ -3742,7 +3742,7 @@ echo "configure:3731: checking for $pseexe" >&5
            ;;
     esac
 
-                    echo $ac_n "checking for pcap_list_datalinks""... $ac_c" 1>&6
+                        echo $ac_n "checking for pcap_list_datalinks""... $ac_c" 1>&6
 echo "configure:3747: checking for pcap_list_datalinks" >&5
 if eval "test \"`echo '$''{'ac_cv_func_pcap_list_datalinks'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3898,6 +3898,62 @@ LIBOBJS="$LIBOBJS dlnames.o"
 fi
 
 
+                        for ac_func in pcap_breakloop
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:3905: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 3910 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:3933: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+
 
 #
 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
@@ -3912,9 +3968,9 @@ fi
 # to rename it.
 #
 echo $ac_n "checking for inet_ntop""... $ac_c" 1>&6
-echo "configure:3916: checking for inet_ntop" >&5
+echo "configure:3972: checking for inet_ntop" >&5
 cat > conftest.$ac_ext <<EOF
-#line 3918 "configure"
+#line 3974 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -3925,7 +3981,7 @@ char src[4], dst[128];
 inet_ntop(AF_INET, src, dst, sizeof(dst));
 ; return 0; }
 EOF
-if { (eval echo configure:3929: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3985: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 else
@@ -3937,9 +3993,9 @@ else
 fi
 rm -f conftest*
 echo $ac_n "checking for inet_pton""... $ac_c" 1>&6
-echo "configure:3941: checking for inet_pton" >&5
+echo "configure:3997: checking for inet_pton" >&5
 cat > conftest.$ac_ext <<EOF
-#line 3943 "configure"
+#line 3999 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -3950,7 +4006,7 @@ char src[128], dst[4];
 inet_pton(AF_INET, src, dst);
 ; return 0; }
 EOF
-if { (eval echo configure:3954: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4010: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 else
@@ -3962,9 +4018,9 @@ else
 fi
 rm -f conftest*
 echo $ac_n "checking for inet_aton""... $ac_c" 1>&6
-echo "configure:3966: checking for inet_aton" >&5
+echo "configure:4022: checking for inet_aton" >&5
 cat > conftest.$ac_ext <<EOF
-#line 3968 "configure"
+#line 4024 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <netinet/in.h>
@@ -3975,7 +4031,7 @@ struct in_addr dst;
 inet_aton(src, &dst);
 ; return 0; }
 EOF
-if { (eval echo configure:3979: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4035: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 else
@@ -3989,12 +4045,12 @@ rm -f conftest*
 
 
        echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6
-echo "configure:3993: checking if sockaddr struct has sa_len member" >&5
+echo "configure:4049: checking if sockaddr struct has sa_len member" >&5
        if eval "test \"`echo '$''{'ac_cv_sockaddr_has_sa_len'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3998 "configure"
+#line 4054 "configure"
 #include "confdefs.h"
 
 #              include <sys/types.h>
@@ -4003,7 +4059,7 @@ int main() {
 u_int i = sizeof(((struct sockaddr *)0)->sa_len)
 ; return 0; }
 EOF
-if { (eval echo configure:4007: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4063: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_sockaddr_has_sa_len=yes
 else
@@ -4030,12 +4086,12 @@ fi
 for ac_func in pcap_findalldevs pcap_dump_flush pcap_lib_version
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4034: checking for $ac_func" >&5
+echo "configure:4090: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4039 "configure"
+#line 4095 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4058,7 +4114,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:4062: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4118: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4084,9 +4140,9 @@ done
 
 if test $ac_cv_func_pcap_lib_version = "no" ; then
     echo $ac_n "checking whether pcap_version is defined by libpcap""... $ac_c" 1>&6
-echo "configure:4088: checking whether pcap_version is defined by libpcap" >&5
+echo "configure:4144: checking whether pcap_version is defined by libpcap" >&5
     cat > conftest.$ac_ext <<EOF
-#line 4090 "configure"
+#line 4146 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -4101,7 +4157,7 @@ return_pcap_version(void)
        
 ; return 0; }
 EOF
-if { (eval echo configure:4105: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4161: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_lbl_cv_pcap_version_defined=yes
 else
@@ -4122,9 +4178,9 @@ EOF
     fi
 fi
 echo $ac_n "checking whether pcap_debug is defined by libpcap""... $ac_c" 1>&6
-echo "configure:4126: checking whether pcap_debug is defined by libpcap" >&5
+echo "configure:4182: checking whether pcap_debug is defined by libpcap" >&5
 cat > conftest.$ac_ext <<EOF
-#line 4128 "configure"
+#line 4184 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -4139,7 +4195,7 @@ return_pcap_debug(void)
    
 ; return 0; }
 EOF
-if { (eval echo configure:4143: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4199: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_lbl_cv_pcap_debug_defined=yes
 else
@@ -4161,9 +4217,9 @@ else
        # OK, what about "yydebug"?
        #
        echo $ac_n "checking whether yydebug is defined by libpcap""... $ac_c" 1>&6
-echo "configure:4165: checking whether yydebug is defined by libpcap" >&5
+echo "configure:4221: checking whether yydebug is defined by libpcap" >&5
        cat > conftest.$ac_ext <<EOF
-#line 4167 "configure"
+#line 4223 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -4178,7 +4234,7 @@ int main() {
           
 ; return 0; }
 EOF
-if { (eval echo configure:4182: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4238: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_lbl_cv_yydebug_defined=yes
 else
@@ -4201,12 +4257,12 @@ fi
 for ac_func in bpf_dump
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4205: checking for $ac_func" >&5
+echo "configure:4261: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4210 "configure"
+#line 4266 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4229,7 +4285,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:4233: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4286,12 +4342,12 @@ if test -f /dev/bpf0 ; then
 fi
 
 echo $ac_n "checking for int8_t using $CC""... $ac_c" 1>&6
-echo "configure:4290: checking for int8_t using $CC" >&5
+echo "configure:4346: checking for int8_t using $CC" >&5
     if eval "test \"`echo '$''{'ac_cv_lbl_have_int8_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4295 "configure"
+#line 4351 "configure"
 #include "confdefs.h"
 
 #      include "confdefs.h"
@@ -4304,7 +4360,7 @@ int main() {
 int8_t i
 ; return 0; }
 EOF
-if { (eval echo configure:4308: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4364: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_lbl_have_int8_t=yes
 else
@@ -4324,12 +4380,12 @@ EOF
 
     fi
 echo $ac_n "checking for u_int8_t using $CC""... $ac_c" 1>&6
-echo "configure:4328: checking for u_int8_t using $CC" >&5
+echo "configure:4384: checking for u_int8_t using $CC" >&5
     if eval "test \"`echo '$''{'ac_cv_lbl_have_u_int8_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4333 "configure"
+#line 4389 "configure"
 #include "confdefs.h"
 
 #      include "confdefs.h"
@@ -4342,7 +4398,7 @@ int main() {
 u_int8_t i
 ; return 0; }
 EOF
-if { (eval echo configure:4346: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4402: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_lbl_have_u_int8_t=yes
 else
@@ -4362,12 +4418,12 @@ EOF
 
     fi
 echo $ac_n "checking for int16_t using $CC""... $ac_c" 1>&6
-echo "configure:4366: checking for int16_t using $CC" >&5
+echo "configure:4422: checking for int16_t using $CC" >&5
     if eval "test \"`echo '$''{'ac_cv_lbl_have_int16_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4371 "configure"
+#line 4427 "configure"
 #include "confdefs.h"
 
 #      include "confdefs.h"
@@ -4380,7 +4436,7 @@ int main() {
 int16_t i
 ; return 0; }
 EOF
-if { (eval echo configure:4384: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4440: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_lbl_have_int16_t=yes
 else
@@ -4400,12 +4456,12 @@ EOF
 
     fi
 echo $ac_n "checking for u_int16_t using $CC""... $ac_c" 1>&6
-echo "configure:4404: checking for u_int16_t using $CC" >&5
+echo "configure:4460: checking for u_int16_t using $CC" >&5
     if eval "test \"`echo '$''{'ac_cv_lbl_have_u_int16_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4409 "configure"
+#line 4465 "configure"
 #include "confdefs.h"
 
 #      include "confdefs.h"
@@ -4418,7 +4474,7 @@ int main() {
 u_int16_t i
 ; return 0; }
 EOF
-if { (eval echo configure:4422: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4478: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_lbl_have_u_int16_t=yes
 else
@@ -4438,12 +4494,12 @@ EOF
 
     fi
 echo $ac_n "checking for int32_t using $CC""... $ac_c" 1>&6
-echo "configure:4442: checking for int32_t using $CC" >&5
+echo "configure:4498: checking for int32_t using $CC" >&5
     if eval "test \"`echo '$''{'ac_cv_lbl_have_int32_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4447 "configure"
+#line 4503 "configure"
 #include "confdefs.h"
 
 #      include "confdefs.h"
@@ -4456,7 +4512,7 @@ int main() {
 int32_t i
 ; return 0; }
 EOF
-if { (eval echo configure:4460: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4516: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_lbl_have_int32_t=yes
 else
@@ -4476,12 +4532,12 @@ EOF
 
     fi
 echo $ac_n "checking for u_int32_t using $CC""... $ac_c" 1>&6
-echo "configure:4480: checking for u_int32_t using $CC" >&5
+echo "configure:4536: checking for u_int32_t using $CC" >&5
     if eval "test \"`echo '$''{'ac_cv_lbl_have_u_int32_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4485 "configure"
+#line 4541 "configure"
 #include "confdefs.h"
 
 #      include "confdefs.h"
@@ -4494,7 +4550,7 @@ int main() {
 u_int32_t i
 ; return 0; }
 EOF
-if { (eval echo configure:4498: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4554: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_lbl_have_u_int32_t=yes
 else
@@ -4554,12 +4610,12 @@ EOF
     fi
 
 echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6
-echo "configure:4558: checking if sockaddr struct has sa_len member" >&5
+echo "configure:4614: checking if sockaddr struct has sa_len member" >&5
     if eval "test \"`echo '$''{'ac_cv_lbl_sockaddr_has_sa_len'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4563 "configure"
+#line 4619 "configure"
 #include "confdefs.h"
 
 #      include <sys/types.h>
@@ -4568,7 +4624,7 @@ int main() {
 u_int i = sizeof(((struct sockaddr *)0)->sa_len)
 ; return 0; }
 EOF
-if { (eval echo configure:4572: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4628: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_lbl_sockaddr_has_sa_len=yes
 else
@@ -4589,7 +4645,7 @@ EOF
     fi
 
 echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6
-echo "configure:4593: checking if unaligned accesses fail" >&5
+echo "configure:4649: checking if unaligned accesses fail" >&5
     if eval "test \"`echo '$''{'ac_cv_lbl_unaligned_fail'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4685,12 +4741,12 @@ EOF
 
 
        echo $ac_n "checking for h_errno""... $ac_c" 1>&6
-echo "configure:4689: checking for h_errno" >&5
+echo "configure:4745: checking for h_errno" >&5
        if eval "test \"`echo '$''{'ac_cv_var_h_errno'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4694 "configure"
+#line 4750 "configure"
 #include "confdefs.h"
 
 #              include <sys/types.h>
@@ -4699,7 +4755,7 @@ int main() {
 int foo = h_errno;
 ; return 0; }
 EOF
-if { (eval echo configure:4703: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4759: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_var_h_errno=yes
 else
@@ -4727,7 +4783,7 @@ if test "${with_crypto+set}" = set; then
 else
   
 echo $ac_n "checking for SSLeay""... $ac_c" 1>&6
-echo "configure:4731: checking for SSLeay" >&5
+echo "configure:4787: checking for SSLeay" >&5
 ac_cv_ssleay_path=no
 incdir=no
 for dir in /usr/${host_alias} /usr /usr/local /usr/local/ssl /usr/pkg; do
@@ -4768,7 +4824,7 @@ if test "$ac_cv_ssleay_path" != no; then
                LIBS="$LIBS -lrsaref"
        fi
        echo $ac_n "checking for des_cbc_encrypt in -lcrypto""... $ac_c" 1>&6
-echo "configure:4772: checking for des_cbc_encrypt in -lcrypto" >&5
+echo "configure:4828: checking for des_cbc_encrypt in -lcrypto" >&5
 ac_lib_var=`echo crypto'_'des_cbc_encrypt | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4776,7 +4832,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypto  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4780 "configure"
+#line 4836 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4787,7 +4843,7 @@ int main() {
 des_cbc_encrypt()
 ; return 0; }
 EOF
-if { (eval echo configure:4791: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4847: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4820,17 +4876,17 @@ fi
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4824: checking for $ac_hdr" >&5
+echo "configure:4880: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4829 "configure"
+#line 4885 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4834: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4890: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4879,7 +4935,7 @@ fi
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:4883: checking for a BSD compatible install" >&5
+echo "configure:4939: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
index 83c452efd071c646ef654cbd1f315680fad9a71e..1eeda639ead70fb072af446bf97a3c2cd6c6aad4 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/setsignal.c,v 1.8 2002-08-01 08:53:35 risso Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/setsignal.c,v 1.9 2003-11-04 07:29:16 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -42,15 +42,33 @@ static const char rcsid[] =
 #include "setsignal.h"
 
 /*
- * An os independent signal() with BSD semantics, e.g. the signal
- * catcher is restored following service of the signal.
+ * An OS-independent signal() with, whenever possible, partial BSD
+ * semantics, i.e. the signal handler is restored following service
+ * of the signal, but system calls are *not* restarted, so that if
+ * "pcap_breakloop()" is called in a signal handler in a live capture,
+ * the read/recvfrom/whatever in the live capture doesn't get restarted,
+ * it returns -1 and sets "errno" to EINTR, so we can break out of the
+ * live capture loop.
  *
- * When sigset() is available, signal() has SYSV semantics and sigset()
- * has BSD semantics and call interface. Unfortunately, Linux does not
- * have sigset() so we use the more complicated sigaction() interface
- * there.
+ * We use "sigaction()" if available.  We don't specify that the signal
+ * should restart system calls, so that should always do what we want.
  *
- * Did I mention that signals suck?
+ * Otherwise, if "sigset()" is available, it probably has BSD semantics
+ * while "signal()" has traditional semantics, so we use "sigset()"; it
+ * might cause system calls to be restarted for the signal, however.
+ * I don't know whether, in any systems where it did cause system calls to
+ * be restarted, there was a way to ask it not to do so; there may no
+ * longer be any interesting systems without "sigaction()", however,
+ * and, if there are, they might have "sigvec()" with SV_INTERRUPT
+ * (which I think first appeared in 4.3BSD).
+ *
+ * Otherwise, we use "signal()" - which means we might get traditional
+ * semantics, wherein system calls don't get restarted *but* the
+ * signal handler is reset to SIG_DFL and the signal is not blocked,
+ * so that a subsequent signal would kill the process immediately.
+ *
+ * Did I mention that signals suck?  At least in POSIX-compliant systems
+ * they suck far less, as those systems have "sigaction()".
  */
 RETSIGTYPE
 (*setsignal (int sig, RETSIGTYPE (*func)(int)))(int)
@@ -60,9 +78,6 @@ RETSIGTYPE
 
        memset(&new, 0, sizeof(new));
        new.sa_handler = func;
-#ifdef SA_RESTART
-       new.sa_flags |= SA_RESTART;
-#endif
        if (sigaction(sig, &new, &old) < 0)
                return (SIG_ERR);
        return (old.sa_handler);
index 3b744f4079f582ae4d839e9af308171e30d3f307..be01643100f4e911d502e97f9c8d8c44ba2a98ed 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -30,7 +30,7 @@ static const char copyright[] =
     "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
 The Regents of the University of California.  All rights reserved.\n";
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.215 2003-09-16 21:02:52 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.216 2003-11-04 07:29:16 guy Exp $ (LBL)";
 #endif
 
 /*
@@ -317,6 +317,7 @@ main(int argc, char **argv)
        pcap_if_t *devpointer;
        int devnum;
 #endif
+       int status;
 #ifdef WIN32
        u_int UserBufferSize = 1000000;
        if(wsockinit() != 0) return 1;
@@ -650,7 +651,7 @@ main(int argc, char **argv)
                fflush(stderr); 
 #endif /* WIN32 */
                *ebuf = '\0';
-               pd = pcap_open_live(device, snaplen, !pflag, 1000, ebuf);
+               pd = pcap_open_live(device, snaplen, !pflag, 10000, ebuf);
                if (pd == NULL)
                        error("%s", ebuf);
                else if (*ebuf)
@@ -776,32 +777,71 @@ main(int argc, char **argv)
                (void)fflush(stderr);
        }
 #endif /* WIN32 */
-       if (pcap_loop(pd, cnt, callback, pcap_userdata) < 0) {
+       status = pcap_loop(pd, cnt, callback, pcap_userdata);
+       if (WFileName == NULL) {
+               /*
+                * We're printing packets.  Flush the printed output,
+                * so it doesn't get intermingled with error output.
+                */
+               if (status == -2) {
+                       /*
+                        * We got interrupted, so perhaps we didn't
+                        * manage to finish a line we were printing.
+                        * Print an extra newline, just in case.
+                        */
+                       putchar('\n');
+               }
+               (void)fflush(stdout);
+       }
+       if (status == -1) {
+               /*
+                * Error.  Report it.
+                */
                (void)fprintf(stderr, "%s: pcap_loop: %s\n",
                    program_name, pcap_geterr(pd));
-               cleanup(0);
-               pcap_close(pd);
-               exit(1);
        }
-       if (RFileName == NULL)
+       if (RFileName == NULL) {
+               /*
+                * We're doing a live capture.  Report the capture
+                * statistics.
+                */
                info(1);
+       }
        pcap_close(pd);
-       exit(0);
+       exit(status == -1 ? 1 : 0);
 }
 
 /* make a clean exit on interrupts */
 static RETSIGTYPE
-cleanup(int signo)
+cleanup(int signo _U_)
 {
-
-       /* Can't print the summary if reading from a savefile */
+#ifdef HAVE_PCAP_BREAKLOOP
+       /*
+        * We have "pcap_breakloop()"; use it, so that we do as little
+        * as possible in the signal handler (it's probably not safe
+        * to do anything with standard I/O streams in a signal handler -
+        * the ANSI C standard doesn't say it is).
+        */
+       pcap_breakloop(pd);
+#else
+       /*
+        * We don't have "pcap_breakloop()"; this isn't safe, but
+        * it's the best we can do.  Print the summary if we're
+        * not reading from a savefile - i.e., if we're doing a
+        * live capture - and exit.
+        */
        if (pd != NULL && pcap_file(pd) == NULL) {
+               /*
+                * We got interrupted, so perhaps we didn't
+                * manage to finish a line we were printing.
+                * Print an extra newline, just in case.
+                */
+               putchar('\n');
                (void)fflush(stdout);
-               putc('\n', stderr);
                info(1);
        }
-       if (signo)
-               exit(0);
+       exit(0);
+#endif
 }
 
 static void