From 59a65c3d24289661dc444e3c303fbd880de5b6e0 Mon Sep 17 00:00:00 2001 From: rpm-build Date: Tue, 15 Aug 2017 09:59:02 +0200 Subject: [PATCH] Add support for AF_VSOCK Backported from here: https://github.com/the-tcpdump-group/libpcap/commit/8fe43bb140f1b5dd193a76b89e379a27847a9391 and extended with DLT_VSOCK definition from upstream pcap/dlt.h file. --- pcap-linux.c | 6 ++++++ pcap.c | 1 + pcap/bpf.h | 10 +++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pcap-linux.c b/pcap-linux.c index d7149d5..0bfc77a 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -2995,6 +2995,12 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok) /* handlep->cooked = 1; */ break; +#ifndef ARPHRD_VSOCKMON +#define ARPHRD_VSOCKMON 826 +#endif + case ARPHRD_VSOCKMON: + handle->linktype = DLT_VSOCK; + break; default: handle->linktype = -1; diff --git a/pcap.c b/pcap.c index 7b834af..ce5ade8 100644 --- a/pcap.c +++ b/pcap.c @@ -1210,6 +1210,7 @@ static struct dlt_choice dlt_choices[] = { DLT_CHOICE(DLT_IPOIB, "RFC 4391 IP-over-Infiniband"), DLT_CHOICE(DLT_DBUS, "D-Bus"), DLT_CHOICE(DLT_NETLINK, "Linux netlink"), + DLT_CHOICE(DLT_VSOCK, "Linux vsock"), DLT_CHOICE_SENTINEL }; diff --git a/pcap/bpf.h b/pcap/bpf.h index 29efd7e..22bff1e 100644 --- a/pcap/bpf.h +++ b/pcap/bpf.h @@ -1232,7 +1232,15 @@ struct bpf_program { */ #define DLT_NETLINK 253 -#define DLT_MATCHING_MAX 253 /* highest value in the "matching" range */ +#define DLT_MATCHING_MAX 271 /* highest value in the "matching" range */ + +/* + * per: Stefanha at gmail.com for + * http://lists.sandelman.ca/pipermail/tcpdump-workers/2017-May/000772.html + * and: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/vsockmon.h + * for: http://qemu-project.org/Features/VirtioVsock + */ +#define DLT_VSOCK 271 /* * DLT and savefile link type values are split into a class and -- 2.13.5