]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Merge pull request #667 from slavashw/master
authorGuy Harris <[email protected]>
Tue, 3 Apr 2018 02:42:01 +0000 (19:42 -0700)
committerGitHub <[email protected]>
Tue, 3 Apr 2018 02:42:01 +0000 (19:42 -0700)
Fix fail to capture on RDMA device on FreeBSD

52 files changed:
CMakeLists.txt
print-arcnet.c
print-arp.c
print-bfd.c
print-bgp.c
print-bt.c
print-calm-fast.c
print-chdlc.c
print-cip.c
print-dtp.c
print-eap.c
print-enc.c
print-esp.c
print-ether.c
print-forces.c
print-fr.c
print-geonet.c
print-icmp.c
print-icmp6.c
print-ip.c
print-ipnet.c
print-isakmp.c
print-isoclns.c
print-juniper.c
print-ldp.c
print-llc.c
print-lldp.c
print-lmp.c
print-lspping.c
print-lwapp.c
print-medsa.c
print-mpcp.c
print-mpls.c
print-msdp.c
print-null.c
print-olsr.c
print-pflog.c
print-pim.c
print-pktap.c
print-ppi.c
print-ppp.c
print-rpki-rtr.c
print-sflow.c
print-stp.c
print-tcp.c
print-tipc.c
print-udld.c
print-udp.c
print-vtp.c
print.c
signature.c
tcpdump.c

index d015477489ec24bc00995f9b1cbd362934a6ccb9..704e48c130603bf99888d8167f588462b0d52186 100644 (file)
@@ -7,9 +7,64 @@ project(tcpdump)
 #
 # Try to enable as many C99 features as we can.
 # At minimum, we want C++/C99-style // comments.
-# (Sadly, this won't work with CMake prior to 3.1.)
 #
-set(CMAKE_C_STANDARD 99)
+# Newer versions of compilers might default to supporting C99, but older
+# versions may require a special flag.
+#
+# Prior to CMake 3.1, setting CMAKE_C_STANDARD will not have any effect,
+# so, unless and until we require CMake 3.1 or later, we have to do it
+# ourselves on pre-3.1 CMake, so we just do it ourselves on all versions
+# of CMake.
+#
+# Note: with CMake 3.1 through 3.5, the only compilers for which CMake
+# handles CMAKE_C_STANDARD are GCC and Clang.  3.6 adds support only
+# for Intel C; 3.9 adds support for PGI C, Sun C, and IBM XL C, and
+# 3.10 adds support for Cray C and IAR C, but no version of CMake has
+# support for HP C.  Therefore, even if we use CMAKE_C_STANDARD with
+# compilers for which CMake supports it, we may still have to do it
+# ourselves on other compilers.
+#
+# See the CMake documentation for the CMAKE_<LANG>_COMPILER_ID variables
+# for a list of compiler IDs.
+#
+# We don't worry about MSVC; it doesn't have such a flag - either it
+# doesn't support the C99 features we need at all, or it supports them
+# regardless of the compiler flag.
+#
+# XXX - this just tests whether the option works and adds it if it does.
+# We don't test whether it's necessary in order to get the C99 features
+# that we use; if we ever have a user who tries to compile with a compiler
+# that can't be made to support those features, we can add a test to make
+# sure we actually *have* C99 support.
+#
+include(CheckCCompilerFlag)
+macro(check_and_add_compiler_option _option)
+    message(STATUS "Checking C compiler flag ${_option}")
+    string(REPLACE "=" "-" _temp_option_variable ${_option})
+    string(REGEX REPLACE "^-" "" _option_variable ${_temp_option_variable})
+    check_c_compiler_flag("${_option}" ${_option_variable})
+    if(${${_option_variable}})
+        set(C_ADDITIONAL_FLAGS "${C_ADDITIONAL_FLAGS} ${_option}")
+    endif()
+endmacro()
+
+set(C_ADDITIONAL_FLAGS "")
+if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR
+   CMAKE_C_COMPILER_ID MATCHES "Clang")
+    check_and_add_compiler_option("-std=gnu99")
+elseif(CMAKE_C_COMPILER_ID MATCHES "XL")
+    #
+    # We want support for extensions picked up for GNU C compatibility,
+    # so we use -qlanglvl=extc99.
+    #
+    check_and_add_compiler_option("-qlanglvl=extc99")
+elseif(CMAKE_C_COMPILER_ID MATCHES "HP")
+    check_and_add_compiler_option("-AC99")
+elseif(CMAKE_C_COMPILER_ID MATCHES "Sun")
+    check_and_add_compiler_option("-xc99")
+elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
+    check_and_add_compiler_option("-c99")
+endif()
 
 set(LIBRARY_NAME netdissect)
 
@@ -645,6 +700,7 @@ set(TCPDUMP_LINK_LIBRARIES ${PCAP_LIBRARIES} ${TCPDUMP_LINK_LIBRARIES})
 #
 # Optional libraries.
 #
+
 #
 # libsmi.
 #
@@ -745,6 +801,94 @@ if(WITH_CAP_NG)
     endif(HAVE_LIBCAP_NG)
 endif(WITH_CAP_NG)
 
+###################################################################
+#   Warning options
+###################################################################
+
+#
+# Check and add warning options if we have a .devel file.
+#
+if(EXISTS ${CMAKE_SOURCE_DIR}/.devel OR EXISTS ${CMAKE_BINARY_DIR}/.devel)
+    #
+    # Warning options.
+    #
+    if(MSVC AND NOT ${CMAKE_C_COMPILER} MATCHES "clang*")
+        #
+        # MSVC, with Microsoft's front end and code generator.
+        # "MSVC" is also set for Microsoft's compiler with a Clang
+        # front end and their code generator ("Clang/C2"), so we
+        # check for clang.exe and treat that differently.
+        #
+        check_and_add_compiler_option(-Wall)
+        #
+        # Disable some pointless warnings that /Wall turns on.
+        #
+        # Unfortunately, MSVC does not appear to have an equivalent
+        # to "__attribute__((unused))" to mark a particular function
+        # parameter as being known to be unused, so that the compiler
+        # won't warn about it (for example, the function might have
+        # that parameter because a pointer to it is being used, and
+        # the signature of that function includes that parameter).
+        # C++ lets you give a parameter a type but no name, but C
+        # doesn't have that.
+        #
+        check_and_add_compiler_option(-wd4100)
+        #
+        # In theory, we care whether somebody uses f() rather than
+        # f(void) to declare a function with no arguments, but, in
+        # practice, there are places in the Windows header files
+        # that appear to do that, so we squelch that warning.
+        #
+        check_and_add_compiler_option(-wd4255)
+        #
+        # Windows FD_SET() generates this, so we suppress it.
+        #
+        check_and_add_compiler_option(-wd4548)
+        #
+        # Perhaps testing something #defined to be 0 with #ifdef is an
+        # error, and it should be tested with #if, but perhaps it's
+        # not, and Microsoft does that in its headers, so we squelch
+        # that warning.
+        #
+        check_and_add_compiler_option(-wd4574)
+        #
+        # The Windows headers also test not-defined values in #if, so
+        # we don't want warnings about that, either.
+        #
+        check_and_add_compiler_option(-wd4668)
+        #
+        # We do *not* care whether some function is, or isn't, going to be
+        # expanded inline.
+        #
+        check_and_add_compiler_option(-wd4710)
+        check_and_add_compiler_option(-wd4711)
+        #
+        # We do *not* care whether we're adding padding bytes after
+        # structure members.
+        #
+        check_and_add_compiler_option(-wd4820)
+    else()
+        #
+        # Other compilers, including MSVC with a Clang front end and
+        # Microsoft's code generator.  We currently treat them as if
+        # they might support GCC-style -W options.
+        #
+        check_and_add_compiler_option(-Wall)
+        check_and_add_compiler_option(-Wmissing-prototypes)
+        check_and_add_compiler_option(-Wstrict-prototypes)
+        check_and_add_compiler_option(-Wwrite-strings)
+        check_and_add_compiler_option(-Wpointer-arith)
+        check_and_add_compiler_option(-Wcast-qual)
+        check_and_add_compiler_option(-Wshadow)
+        check_and_add_compiler_option(-Wdeclaration-after-statement)
+        check_and_add_compiler_option(-Wpedantic)
+        check_and_add_compiler_option(-Wold-style-definition)
+        check_and_add_compiler_option(-Wused-but-marked-unused)
+        check_and_add_compiler_option(-W)
+        check_and_add_compiler_option(-Wassign-enum)
+    endif()
+endif()
+
 ######################################
 # Input files
 ######################################
@@ -945,6 +1089,9 @@ endif(NOT WIN32)
 add_library(netdissect STATIC
     ${NETDISSECT_SOURCE_LIST_C}
 )
+if(NOT C_ADDITIONAL_FLAGS STREQUAL "")
+    set_target_properties(netdissect PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS})
+endif()
 
 set(TCPDUMP_SOURCE_LIST_C tcpdump.c)
 
@@ -977,6 +1124,9 @@ source_group("Header Files" FILES ${PROJECT_SOURCE_LIST_H})
 ######################################
 
 add_executable(tcpdump ${TCPDUMP_SOURCE_LIST_C})
+if(NOT C_ADDITIONAL_FLAGS STREQUAL "")
+    set_target_properties(tcpdump PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS})
+endif()
 target_link_libraries(tcpdump netdissect ${TCPDUMP_LINK_LIBRARIES})
 
 ######################################
index f40201719f56557f88c41a0d1ce5f46c7373d483..18d90aa9acd57e42827f645223d25b92403866a9 100644 (file)
@@ -361,10 +361,3 @@ arcnet_encap_print(netdissect_options *ndo, u_char arctype, const u_char *p,
                return (0);
        }
 }
-
-/*
- * Local Variables:
- * c-style: bsd
- * End:
- */
-
index e026bd46789a0ba756e58f6484c7ac595b6cc3f8..af553b40ed7c851051e528e0ff1f660a49550c32 100644 (file)
@@ -471,10 +471,3 @@ arp_print(netdissect_options *ndo,
 trunc:
        ND_PRINT("%s", tstr);
 }
-
-/*
- * Local Variables:
- * c-style: bsd
- * End:
- */
-
index 0d1732cd763a9b2d7bed7b43f179ed7ee7cfa3b5..8daa56d6d7af467d28bd10dbb1a4c833f034f2db 100644 (file)
@@ -405,9 +405,3 @@ bfd_print(netdissect_options *ndo, const u_char *pptr,
 trunc:
         ND_PRINT("[|BFD]");
 }
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 2a3e765122c839739f909f6ba26b59359e6a0dbf..8a78ae9e881ee663944759dc7084f93671ff4a9f 100644 (file)
@@ -3121,10 +3121,3 @@ bgp_print(netdissect_options *ndo,
 trunc:
     ND_PRINT(" [|BGP]");
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 4
- * End:
- */
index 61eb7b23d8ed61206436a83520eabb5a4320bd07..96b3fa8f62da272544ff30163bb3ae5e6cb4077a 100644 (file)
@@ -66,11 +66,3 @@ trunc:
        return (BT_HDRLEN);
 }
 #endif
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index d516cdffbb71decc540ee32d7318fac209407d79..64f4b78026651fb636f88bdd588c468bbb7687c2 100644 (file)
@@ -67,11 +67,3 @@ trunc:
        ND_PRINT("[|calm fast]");
        return;
 }
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 8dc20ae41a5234129b4aeaf9f59c1ece5eb13317..8cd04af4adddd465dfa651319fd00adb31040b82 100644 (file)
@@ -203,11 +203,3 @@ chdlc_slarp_print(netdissect_options *ndo, const u_char *cp, u_int length)
 trunc:
        ND_PRINT("[|slarp]");
 }
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 468477a68b6f56404b3adba386b6fa56f466c546..15c15cd3fec7a4be8641a7dbbd5eab1115146520 100644 (file)
@@ -99,11 +99,3 @@ cip_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
 
        return (llc_hdrlen);
 }
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 5e76e2a2a417f26efb48aa58614507ff68be1b97..6bb89235c752a0c22410394010b29bf8e8feec8a 100644 (file)
@@ -120,10 +120,3 @@ dtp_print (netdissect_options *ndo, const u_char *pptr, u_int length)
  trunc:
     ND_PRINT("%s", tstr);
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 4
- * End:
- */
index a17a740ace3327cb2b5260a7c7d1f74594e07e9a..a94168228214ca4ee84d013091580a3ad60e489e 100644 (file)
@@ -298,9 +298,3 @@ eap_print(netdissect_options *ndo,
  trunc:
     ND_PRINT("\n\t[|EAP]");
 }
-
-/*
- * Local Variables:
- * c-basic-offset: 4
- * End:
- */
index fb9b708797feda2e13a13b64a9f5b1681da37ec4..36c353512a960efac7770aeae02ed7f8008c423e 100644 (file)
@@ -162,11 +162,3 @@ enc_if_print(netdissect_options *ndo,
 out:
        return (ENC_HDRLEN);
 }
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 53b6d243e7410c200a0fe8e6b356b84a8b7b6bba..04b1e25f60913baa0ff8085d1282161351ec18ca 100644 (file)
@@ -834,10 +834,3 @@ fail:
 #ifdef HAVE_LIBCRYPTO
 USES_APPLE_RST
 #endif
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 112c6e812ba22e82877da053d1537eacbc0cb55e..aed2bea88036b4042400367ccb10686fa3084e25 100644 (file)
@@ -476,12 +476,3 @@ ethertype_print(netdissect_options *ndo,
                return (0);
        }
 }
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
-
index be978f28849bdb04ffe033fd7c5de05d65ca0b35..19bb6193dbf5510a3954fb7ccfca54660ca98dca 100644 (file)
@@ -1775,9 +1775,3 @@ error:
 trunc:
        ND_PRINT("%s", tstr);
 }
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 88f7de179ea596ae029cebf1bbddb8ce55fb2664..9d39f0b280d045912cbf85003a407f23188aae8f 100644 (file)
@@ -1140,9 +1140,3 @@ fr_q933_print_ie_codeset_0_5(netdissect_options *ndo, u_int iecode,
 
         return 0;
 }
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 6558eacd47631468bbcd45bf62b792fbab9360aa..95bcad00ea294c005b17d20ffe1eca57d9042adf 100644 (file)
@@ -277,11 +277,3 @@ invalid:
 trunc:
        ND_PRINT("[|geonet]");
 }
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 7ad886d276c1f0ee63755d3e7bbdbe7c84d87892..8af1e288eef112cdf76c73c36f11dfcd1e5a9b8b 100644 (file)
@@ -699,9 +699,3 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
 trunc:
        ND_PRINT("[|icmp]");
 }
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 151a4db7b80b809fd54b9784cb8769b69f627499..890a903faa4a78baf35cf672704916c767df4f9d 100644 (file)
@@ -2116,10 +2116,3 @@ icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep)
 trunc:
        ND_PRINT("[|icmp6]");
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index b1a23db9219f251d1ef97392172c295728a3c63b..6593aa4ef84ccc7989a8e1bb17306e99dc6dc359 100644 (file)
@@ -735,12 +735,3 @@ trunc:
        ND_PRINT("%s", tstr);
        return;
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
-
-
index 627c9b945b4f33c3b160dc8f52a44ad0a4f852e3..9bb6c184ed6edf5f5d9d41921d1551b73d085a64 100644 (file)
@@ -118,12 +118,4 @@ ipnet_if_print(netdissect_options *ndo,
 
        return (sizeof(ipnet_hdr_t));
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
-
 #endif /* DLT_IPNET */
index d407e81049e076a48730386662325556b234d417..88bdd82f90e24ea45b112abaa8dea79193e01b9d 100644 (file)
@@ -3133,10 +3133,3 @@ trunc:
        ND_PRINT("[|isakmp]");
        return;
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index f79f240406f5cccf226551b0b30e30b53e5fc096..2b9d338dcc6a3b243d81eff7f5218f6bdf903fbc 100644 (file)
@@ -3263,10 +3263,3 @@ osi_print_cksum(netdissect_options *ndo, const uint8_t *pptr,
                 }
         }
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 28ce37f310c52550d43365e2e8450f50a23a55c7..56cb14d411e9525ea1a67d6733371e5567636b6e 100644 (file)
@@ -1518,11 +1518,3 @@ juniper_parse_header(netdissect_options *ndo,
     ND_PRINT("[|juniper_hdr], length %u", h->len);
     return 0;
 }
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 4
- * End:
- */
index 1fbc0567bd78afe8f28da85baf6005155a0e5166..9890e44f188635011dc306c5f244de7560b14a60 100644 (file)
@@ -693,10 +693,3 @@ trunc:
     ND_PRINT("%s", tstr);
     return 0;
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index bb18603c4c5c6b1b124ead652d039d7417ac2975..95668f92179a1cd881130c759b896d21e84cf1bb 100644 (file)
@@ -608,11 +608,3 @@ trunc:
        ND_PRINT("[|snap]");
        return (1);
 }
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index dab0a99b8470c70623e13e3bd68043c0b68e1392..b6af8735c0b5c8bafac9c29e9e96f69f0dc51dcc 100644 (file)
@@ -1665,10 +1665,3 @@ lldp_print(netdissect_options *ndo,
  trunc:
     ND_PRINT("\n\t[|LLDP]");
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 4
- * End:
- */
index 6c0f671d33ddc8e80ab41eb806fe87217206de40..381255ecbdb5dfce0b01ac568238e7ea7931ded4 100644 (file)
@@ -1136,9 +1136,3 @@ lmp_print(netdissect_options *ndo,
 trunc:
     ND_PRINT("%s", tstr);
 }
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index f20d9b75dff0ba336181ea2f2507bef38ca29095..02468d43893491d612e1d44088faa8e47ba30ead 100644 (file)
@@ -1091,9 +1091,3 @@ trunc:
     ND_PRINT("%s", tstr);
     return;
 }
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index a18459242400807d4b746c0f73e4e8304862febc..d53d8e9843d6890bb9937ad46488abac15597fd6 100644 (file)
@@ -367,10 +367,3 @@ lwapp_data_print(netdissect_options *ndo,
 trunc:
     ND_PRINT("%s", data_tstr);
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index dce2b4e8fefc32c1fe7fda1768a047b07dd053d5..b9eb2262b0f998f019c4d95f51506f2ddb2f289d 100644 (file)
@@ -191,10 +191,3 @@ medsa_print(netdissect_options *ndo,
 trunc:
        ND_PRINT("%s", tstr);
 }
-
-/*
- * Local Variables:
- * c-style: bsd
- * End:
- */
-
index 6535ad290cdf1621d7e0c118ca281cee23304f73..89c1e7b9cd29469cb5a6eb7b43967297b36e7a86 100644 (file)
@@ -249,9 +249,3 @@ mpcp_print(netdissect_options *ndo, const u_char *pptr, u_int length)
 trunc:
     ND_PRINT("\n\t[|MPCP]");
 }
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index db9be428fb784cf8e6d8086765e2440944114963..3d2a2645cfddff9a94139ce5992ef7247db8ce5d 100644 (file)
@@ -213,11 +213,3 @@ mpls_print(netdissect_options *ndo, const u_char *bp, u_int length)
 trunc:
        ND_PRINT("[|MPLS]");
 }
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index bb3b95b89446c6dff5ecdeb2c17185b59ad565f6..ea476cb58b7aab8a9b1caea3095e7fd0d0c4c7f7 100644 (file)
@@ -98,10 +98,3 @@ msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
 trunc:
        ND_PRINT(" [|msdp]");
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index f1f66930f480f31ec005d426e371df6e73f41ec9..64fdfa25aae87d3e5dd752e2a081edb6a3178fbd 100644 (file)
@@ -144,10 +144,3 @@ trunc:
        ND_PRINT("%s", tstr);
        return (NULL_HDRLEN);
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 09b6c74c5869b55acd39cb7d7626c4b8c3f8beee..ab8b30f7f85aa913da40a4daf038d7bd3e41ce81 100644 (file)
@@ -714,10 +714,3 @@ olsr_print(netdissect_options *ndo,
  trunc:
     ND_PRINT("[|olsr]");
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 4
- * End:
- */
index 0be4e8ae76c823b181eb0627079083aa71d4943b..a98a0fc1906d49b45265d6e92aba16371b2a91a7 100644 (file)
@@ -178,10 +178,3 @@ trunc:
        ND_PRINT("%s", tstr);
        return (hdrlen);
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 962f8772aa92a7e623723c8e259c1d0ecff27210..b3e9f90ad04ac4b9b9c0ce09b36b73342f62ba1c 100644 (file)
@@ -1200,10 +1200,3 @@ pimv2_print(netdissect_options *ndo,
 trunc:
        ND_PRINT("[|pim]");
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 6db3de503d64c1a3a4b95dbc15d79512963dca77..825851da05b9253d6505b51f633591a1286965e6 100644 (file)
@@ -109,7 +109,7 @@ pktap_if_print(netdissect_options *ndo,
        ndo->ndo_protocol = "pktap_if";
        if (caplen < sizeof(pktap_header_t) || length < sizeof(pktap_header_t)) {
                ND_PRINT("[|pktap]");
-               return (0);
+               return (caplen);
        }
        hdr = (const pktap_header_t *)p;
        dlt = EXTRACT_LE_U_4(hdr->pkt_dlt);
@@ -123,11 +123,11 @@ pktap_if_print(netdissect_options *ndo,
                 * be expanded in the future)?
                 */
                ND_PRINT("[|pktap]");
-               return (0);
+               return (caplen);
        }
        if (caplen < hdrlen || length < hdrlen) {
                ND_PRINT("[|pktap]");
-               return (hdrlen);
+               return (caplen);
        }
 
        if (ndo->ndo_eflag)
@@ -163,12 +163,4 @@ pktap_if_print(netdissect_options *ndo,
 
        return (hdrlen);
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
-
 #endif /* DLT_PKTAP */
index c58a3627b67d88a238685d13ad00d3884e2def40..4671b08a67c02fa5d54da172e0d200ae62085ee8 100644 (file)
@@ -126,12 +126,4 @@ ppi_if_print(netdissect_options *ndo,
        ndo->ndo_protocol = "ppi_if";
        return (ppi_print(ndo, h, p));
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
-
 #endif /* DLT_PPI */
index a5bf65df1067114ebeffbdfac2d3e88f61cbd94a..ceb053f56e69d115bf1088775761578ded240291 100644 (file)
@@ -1906,11 +1906,3 @@ printx:
 #endif /* __bsdi__ */
        return (hdrlength);
 }
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 8642377cd3041377112ae7cb49abee2f6945fc39..fa8ed9da47d11818671b089ac753763e45e53751 100644 (file)
@@ -399,10 +399,3 @@ rpki_rtr_print(netdissect_options *ndo, const u_char *pptr, u_int len)
        pptr += pdu_len;
     }
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 4
- * End:
- */
index 1da0e97b191b9c65410370fbf7cfec0bd56c62b3..5bef503213803c7a492113c7cef3bfbb93448151 100644 (file)
@@ -973,10 +973,3 @@ sflow_print(netdissect_options *ndo,
  trunc:
     ND_PRINT("[|SFLOW]");
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 4
- * End:
- */
index eb5c90f172b44dbb1d212c80e08ab6b3e708613e..548278b9795f2c0e69c4243fa675508384fd1e3a 100644 (file)
@@ -511,10 +511,3 @@ stp_print(netdissect_options *ndo, const u_char *p, u_int length)
 trunc:
     ND_PRINT("[|stp %u]", length);
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 4
- * End:
- */
index 3b81059b9ea0c9e42f50ce73effbfa585436226e..57fd83b67b7f6a7513aa74ab6a5ecc76c70db610 100644 (file)
@@ -936,10 +936,3 @@ tcp_verify_signature(netdissect_options *ndo,
 }
 USES_APPLE_RST
 #endif /* HAVE_LIBCRYPTO */
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 4596dd7ea5b41221a0a9f97540b0b421e949da1b..d837af65ebad5aba7dd4736934a3b4bf8108b0f8 100644 (file)
@@ -376,10 +376,3 @@ tipc_print(netdissect_options *ndo, const u_char *bp, u_int length _U_,
 trunc:
        ND_PRINT("%s", tstr);
 }
-
-/*
- * Local Variables:
- * c-style: bsd
- * End:
- */
-
index 4f444caaee1458f064bb0f095f1532f8f263e6d5..3b77dd511232d056baf962935069e41b455eec85 100644 (file)
@@ -190,10 +190,3 @@ invalid:
 trunc:
     ND_PRINT("%s", tstr);
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 4
- * End:
- */
index e56deb656c1d11dcf9f620f3184643c046426499..283726ce114a5b273bbff3338b258e6f71f41e67 100644 (file)
@@ -720,11 +720,3 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
 trunc:
        ND_PRINT("%s", udp_tstr);
 }
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 7abf368972615650fda11e928298dfaa2a33d4cd..5a10b25fc005319b7d4d7631819334fb97b3702c 100644 (file)
@@ -396,10 +396,3 @@ vtp_print (netdissect_options *ndo,
  trunc:
     ND_PRINT("[|vtp]");
 }
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 4
- * End:
- */
diff --git a/print.c b/print.c
index 4417a4fa2523b07597051ff150376bbf8d77cb85..92c1977bc23b925f196b4ac3c48ed8db63628b95 100644 (file)
--- a/print.c
+++ b/print.c
@@ -526,9 +526,3 @@ ndo_set_function_pointers(netdissect_options *ndo)
        ndo->ndo_error=ndo_error;
        ndo->ndo_warning=ndo_warning;
 }
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
index 6f624428bcee954ac1ac6a3e4de9d2520021436f..ca3aec9f45976100ee89a4eefac970d1831172e9 100644 (file)
@@ -205,10 +205,3 @@ signature_verify(netdissect_options *ndo _U_, const u_char *pptr _U_,
     return (CANT_CHECK_SIGNATURE);
 }
 #endif
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 4
- * End:
- */
index 8147a180b08a58be194d9ed93f4697e925f49e70..638ba596e8656770d8e0f8b4ca90ecfdea581da5 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -1012,9 +1012,35 @@ read_infile(char *fname)
 static long
 parse_interface_number(const char *device)
 {
+       const char *p;
        long devnum;
        char *end;
 
+       /*
+        * Search for a colon, terminating any scheme at the beginning
+        * of the device.
+        */
+       p = strchr(device, ':');
+       if (p != NULL) {
+               /*
+                * We found it.  Is it followed by "//"?
+                */
+               p++;    /* skip the : */
+               if (strncmp(p, "//", 2) == 0) {
+                       /*
+                        * Yes.  Search for the next /, at the end of the
+                        * authority part of the URL.
+                        */
+                       p += 2; /* skip the // */
+                       p = strchr(p, '/');
+                       if (p != NULL) {
+                               /*
+                                * OK, past the / is the path.
+                                */
+                               device = p + 1;
+                       }
+               }
+       }
        devnum = strtol(device, &end, 10);
        if (device != end && *end == '\0') {
                /*
@@ -1037,14 +1063,54 @@ parse_interface_number(const char *device)
 }
 
 static char *
-find_interface_by_number(long devnum)
+find_interface_by_number(const char *url, long devnum)
 {
        pcap_if_t *dev, *devlist;
        long i;
        char ebuf[PCAP_ERRBUF_SIZE];
        char *device;
+#ifdef HAVE_PCAP_FINDALLDEVS_EX
+       const char *endp;
+       char *host_url;
+#endif
+       int status;
 
-       if (pcap_findalldevs(&devlist, ebuf) < 0)
+#ifdef HAVE_PCAP_FINDALLDEVS_EX
+       /*
+        * Search for a colon, terminating any scheme at the beginning
+        * of the URL.
+        */
+       endp = strchr(url, ':');
+       if (endp != NULL) {
+               /*
+                * We found it.  Is it followed by "//"?
+                */
+               endp++; /* skip the : */
+               if (strncmp(endp, "//", 2) == 0) {
+                       /*
+                        * Yes.  Search for the next /, at the end of the
+                        * authority part of the URL.
+                        */
+                       endp += 2;      /* skip the // */
+                       endp = strchr(endp, '/');
+               } else
+                       endp = NULL;
+       }
+       if (endp != NULL) {
+               /*
+                * OK, everything from device to endp is a URL to hand
+                * to pcap_findalldevs_ex().
+                */
+               endp++; /* Include the trailing / in the URL; pcap_findalldevs_ex() requires it */
+               host_url = malloc(endp - url + 1);
+               memcpy(host_url, url, endp - url);
+               host_url[endp - url] = '\0';
+               status = pcap_findalldevs_ex(host_url, NULL, &devlist, ebuf);
+               free(host_url);
+       } else
+#endif
+       status = pcap_findalldevs(&devlist, ebuf);
+       if (status < 0)
                error("%s", ebuf);
        /*
         * Look for the devnum-th entry in the list of devices (1-based).
@@ -1085,18 +1151,19 @@ open_interface(const char *device, netdissect_options *ndo, char *ebuf)
                 * Yes.  Open it with pcap_open().
                 */
                *ebuf = '\0';
-fprintf(stderr, "Opening %s\n", device);
                pc = pcap_open(device, ndo->ndo_snaplen,
                    pflag ? 0 : PCAP_OPENFLAG_PROMISCUOUS, 1000, NULL,
                    ebuf);
                if (pc == NULL) {
                        /*
-                        * If this failed with "No such device", that means
+                        * If this failed with "No such device" or "The system
+                        * cannot find the device specified", that means
                         * the interface doesn't exist; return NULL, so that
                         * the caller can see whether the device name is
                         * actually an interface index.
                         */
-                       if (strstr(ebuf, "No such device") != NULL)
+                       if (strstr(ebuf, "No such device") != NULL ||
+                           strstr(ebuf, "The system cannot find the device specified") != NULL)
                                return (NULL);
                        error("%s", ebuf);
                }
@@ -1923,7 +1990,7 @@ main(int argc, char **argv)
                         * find_interface_by_number() exits if it
                         * couldn't be found.
                         */
-                       device = find_interface_by_number(devnum);
+                       device = find_interface_by_number(device, devnum);
                        pd = open_interface(device, ndo, ebuf);
                        if (pd == NULL)
                                error("%s", ebuf);
@@ -2933,9 +3000,3 @@ print_usage(void)
        (void)fprintf(stderr,
 "\t\t[ -z postrotate-command ] [ -Z user ] [ expression ]\n");
 }
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */