Index is displayed always, name only if available.
Warn about possible wrong interfaces when in reading mode
(pcap file can be displayed on a different host then where
was captured) [1].
See: GH the-tcpdump-group/libpcap#127
[1] https://lists.sandelman.ca/pipermail/tcpdump-workers/2018-July/001019.html
Signed-off-by: Petr Vorel <[email protected]>
Suggested-by: Guy Harris <[email protected]>
Reviewed-by: Denis Ovsienko <[email protected]>
Reviewed-by: Guy Harris <[email protected]>
#
check_include_file(fcntl.h HAVE_FCNTL_H)
check_include_file(rpc/rpc.h HAVE_RPC_RPC_H)
+check_include_file(net/if.h HAVE_NET_IF_H)
if(HAVE_RPC_RPC_H)
check_include_files("rpc/rpc.h;rpc/rpcent.h" HAVE_RPC_RPCENT_H)
endif(HAVE_RPC_RPC_H)
/* Define to 1 if you have the <netdnet/dn.h> header file. */
#cmakedefine HAVE_NETDNET_DN_H 1
+/* Define to 1 if you have the <net/if.h> header file. */
+#cmakedefine HAVE_NET_IF_H 1
+
/* Define to 1 if you have the <net/if_pflog.h> header file. */
#cmakedefine HAVE_NET_IF_PFLOG_H 1
/* Define to 1 if you have the <netdnet/dn.h> header file. */
#undef HAVE_NETDNET_DN_H
+/* Define to 1 if you have the <net/if.h> header file. */
+#undef HAVE_NET_IF_H
+
/* Define to 1 if you have the <net/if_pflog.h> header file. */
#undef HAVE_NET_IF_PFLOG_H
done
-for ac_header in fcntl.h rpc/rpc.h rpc/rpcent.h
+for ac_header in fcntl.h rpc/rpc.h rpc/rpcent.h net/if.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
AC_LBL_C_INIT(V_CCOPT, V_INCLS)
AC_LBL_C_INLINE
-AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h)
+AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h net/if.h)
AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>])
#include <config.h>
#endif
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
+
#include "netdissect-stdinc.h"
#include "netdissect.h"
u_short ether_type;
int llc_hdrlen;
u_int hdrlen;
+#ifdef HAVE_NET_IF_H
+ char ifname[IF_NAMESIZE];
+#endif
ndo->ndo_protocol = "sll2_if";
if (caplen < SLL2_HDR_LEN) {
}
sllp = (const struct sll2_header *)p;
+#ifdef HAVE_NET_IF_H
+ uint32_t index = EXTRACT_BE_U_4(sllp->sll2_if_index);
+ if (if_indextoname(index, ifname))
+ ND_PRINT("ifindex %u (%s) ", index, ifname);
+ else
+ ND_PRINT("ifindex %u ", index);
+#endif
if (ndo->ndo_eflag)
sll2_print(ndo, sllp, length);
RFileName, dlt_name,
pcap_datalink_val_to_description(dlt));
}
+#ifdef DLT_LINUX_SLL2
+ if (dlt == DLT_LINUX_SLL2)
+ fprintf(stderr, "Warning: interface names might be incorrect\n");
+#endif
} else {
/*
* We're doing a live capture.