tcpdump mailing list archives
[RFC TCPDUMP PATCH 2/2] Add sll_ifindex into sll_header + use it to print ifname
From: Petr Vorel <pvorel () suse cz>
Date: Thu, 12 Jul 2018 20:33:41 +0200
From: Petr Vorel <petr.vorel () gmail com> Implements: GH the-tcpdump-group/libpcap#127 Signed-off-by: Petr Vorel <pvorel () suse cz> --- config.h.in | 4 ++++ configure | 20 ++++++++++++++++++++ configure.ac | 10 ++++++++++ missing/dlnames.c | 3 +++ print-sll.c | 27 +++++++++++++++++++++++++-- print.c | 5 ++++- 6 files changed, 66 insertions(+), 3 deletions(-) diff --git a/config.h.in b/config.h.in index 4fcbba77..ed85dd18 100644 --- a/config.h.in +++ b/config.h.in @@ -267,6 +267,10 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION +/* enable new LINKTYPE_LINUX_SLL2 capture support on Linux instead of legacy + LINKTYPE_LINUX_SLL */ +#undef PCAP_SUPPORT_SLL_V2 + /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS diff --git a/configure b/configure index 25dc6b65..fadc10c5 100755 --- a/configure +++ b/configure @@ -631,6 +631,7 @@ V_INCLS V_GROUP V_DEFS V_CCOPT +PCAP_SUPPORT_SLL_V2 MKDEP DEPENDENCY_CFLAG AR @@ -707,6 +708,7 @@ with_sandbox_capsicum with_system_libpcap with_crypto with_cap_ng +enable_sll_v2 ' ac_precious_vars='build_alias host_alias @@ -1333,6 +1335,9 @@ Optional Features: --disable-universal don't build universal on macOS --enable-smb enable possibly-buggy SMB printer default=yes --disable-smb disable possibly-buggy SMB printer + --enable-sll-v2 enable new LINKTYPE_LINUX_SLL2 capture support on + Linux instead of legacy LINKTYPE_LINUX_SLL + [default=yes] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -7684,6 +7689,21 @@ if test "$missing_includes" = "yes"; then V_INCLS="$V_INCLS -I$srcdir/missing" fi +# Check whether --enable-sll-v2 was given. +if test "${enable_sll_v2+set}" = set; then : + enableval=$enable_sll_v2; +else + enable_sll_v2=yes +fi + + +if test "x$enable_sll_v2" != "xno" ; then + +$as_echo "#define PCAP_SUPPORT_SLL_V2 1" >>confdefs.h + + +fi + diff --git a/configure.ac b/configure.ac index 32f48b60..e6dfa358 100644 --- a/configure.ac +++ b/configure.ac @@ -1010,6 +1010,16 @@ if test "$missing_includes" = "yes"; then V_INCLS="$V_INCLS -I$srcdir/missing" fi +AC_ARG_ENABLE([sll-v2], +[AC_HELP_STRING([--enable-sll-v2],[enable new LINKTYPE_LINUX_SLL2 capture support on Linux instead of legacy LINKTYPE_LINUX_SLL @<:@default=yes@:>@])], + [], + [enable_sll_v2=yes]) + +if test "x$enable_sll_v2" != "xno" ; then + AC_DEFINE(PCAP_SUPPORT_SLL_V2, 1, [enable new LINKTYPE_LINUX_SLL2 capture support on Linux instead of legacy LINKTYPE_LINUX_SLL]) + AC_SUBST(PCAP_SUPPORT_SLL_V2) +fi + AC_SUBST(V_CCOPT) AC_SUBST(V_DEFS) AC_SUBST(V_GROUP) diff --git a/missing/dlnames.c b/missing/dlnames.c index 61fa18c1..1676bf2d 100644 --- a/missing/dlnames.c +++ b/missing/dlnames.c @@ -95,6 +95,9 @@ static struct dlt_choice dlt_choices[] = { #ifdef DLT_LINUX_SLL DLT_CHOICE(DLT_LINUX_SLL, "Linux cooked"), #endif +#ifdef DLT_LINUX_SLL2 + DLT_CHOICE(DLT_LINUX_SLL2, "Linux cooked v2"), +#endif #ifdef DLT_LTALK DLT_CHOICE(DLT_LTALK, "Localtalk"), #endif diff --git a/print-sll.c b/print-sll.c index 571b7c5e..10c07664 100644 --- a/print-sll.c +++ b/print-sll.c @@ -26,6 +26,9 @@ #endif #include "netdissect-stdinc.h" +#ifdef PCAP_SUPPORT_SLL_V2 +#include <net/if.h> +#endif #include "netdissect.h" #include "addrtoname.h" @@ -71,17 +74,32 @@ */ /* - * A DLT_LINUX_SLL fake link-layer header. + * DLT_LINUX_SLL and DLT_LINUX_SLL2 fake link-layer header. */ -#define SLL_HDR_LEN 16 /* total header length */ +/* total header length */ +#ifdef PCAP_SUPPORT_SLL_V2 +#define SLL_HDR_LEN 24 +#else +#define SLL_HDR_LEN 16 +#endif #define SLL_ADDRLEN 8 /* length of address field */ struct sll_header { +#ifdef PCAP_SUPPORT_SLL_V2 + nd_uint16_t sll_protocol; /* protocol */ + nd_uint16_t reserved; /* reserved */ + nd_int32_t sll_ifindex; /* interface index, DLT_LINUX_SLL2 ONLY! */ + nd_uint16_t sll_hatype; /* link-layer address type */ + nd_uint16_t sll_halen; /* link-layer address length */ + nd_byte sll_addr[SLL_ADDRLEN]; /* link-layer address */ + nd_uint16_t sll_pkttype; /* packet type */ +#else nd_uint16_t sll_pkttype; /* packet type */ nd_uint16_t sll_hatype; /* link-layer address type */ nd_uint16_t sll_halen; /* link-layer address length */ nd_byte sll_addr[SLL_ADDRLEN]; /* link-layer address */ nd_uint16_t sll_protocol; /* protocol */ +#endif }; /* @@ -213,6 +231,11 @@ sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char } sllp = (const struct sll_header *)p; +#ifdef PCAP_SUPPORT_SLL_V2 + char ifname[IF_NAMESIZE]; + if (if_indextoname(EXTRACT_BE_U_6(sllp->sll_ifindex), ifname)) + ND_PRINT("IFNAME %s ", ifname); +#endif if (ndo->ndo_eflag) sll_print(ndo, sllp, length); diff --git a/print.c b/print.c index b9c92adc..ae4aaae6 100644 --- a/print.c +++ b/print.c @@ -123,9 +123,12 @@ static const struct printer printers[] = { #endif { token_if_print, DLT_IEEE802 }, { fddi_if_print, DLT_FDDI }, -#ifdef DLT_LINUX_SLL +#if defined(DLT_LINUX_SLL) && !defined(PCAP_SUPPORT_SLL_V2) { sll_if_print, DLT_LINUX_SLL }, #endif +#if defined(DLT_LINUX_SLL2) && defined(PCAP_SUPPORT_SLL_V2) + { sll_if_print, DLT_LINUX_SLL2 }, +#endif #ifdef DLT_FR { fr_if_print, DLT_FR }, #endif -- 2.18.0 _______________________________________________ tcpdump-workers mailing list tcpdump-workers () lists tcpdump org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
Current thread:
- [RFC TCPDUMP PATCH 0/2] LINKTYPE_LINUX_SLL2 implementation Petr Vorel (Jul 12)
- [RFC TCPDUMP PATCH 1/2] Update configure Petr Vorel (Jul 12)
- [RFC TCPDUMP PATCH 2/2] Add sll_ifindex into sll_header + use it to print ifname Petr Vorel (Jul 12)
- Re: [RFC TCPDUMP PATCH 2/2] Add sll_ifindex into sll_header + use it to print ifname Guy Harris (Jul 12)
- Re: [RFC TCPDUMP PATCH 2/2] Add sll_ifindex into sll_header + use it to print ifname Petr Vorel (Jul 12)
- Re: [RFC TCPDUMP PATCH 2/2] Add sll_ifindex into sll_header + use it to print ifname Denis Ovsienko (Jul 13)
- Re: [RFC TCPDUMP PATCH 2/2] Add sll_ifindex into sll_header + use it to print ifname Denis Ovsienko (Jul 17)
- Re: [RFC TCPDUMP PATCH 2/2] Add sll_ifindex into sll_header + use it to print ifname Petr Vorel (Jul 18)
- Re: [RFC TCPDUMP PATCH 2/2] Add sll_ifindex into sll_header + use it to print ifname Denis Ovsienko (Jul 31)
- Re: [RFC TCPDUMP PATCH 2/2] Add sll_ifindex into sll_header + use it to print ifname Guy Harris (Jul 12)
- Re: [RFC TCPDUMP PATCH 0/2] LINKTYPE_LINUX_SLL2 implementation Petr Vorel (Jul 12)