vsock: add WTAP_ENCAP_VSOCK constant

A linktype was recently assigned to Linux vsock in libpcap commit
cfdded36ddcf5d01e1ed9f5d4db596b744a6cda5 ("added DLT_VSOCK for
http://qemu-project.org/Features/VirtioVsock").

The Wireshark vsock dissector can now be automatically applied when
wtap_encap matches the new WTAP_ENCAP_VSOCK constant.

This patch makes Wireshark dissect vsock packet captures without
manually specifying the dissector.

Change-Id: If252071499a61554f624c9ce0ce45a0ccfa88d7a
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-on: https://code.wireshark.org/review/22611
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
This commit is contained in:
Stefan Hajnoczi 2017-07-13 13:33:30 +01:00 committed by Alexis La Goutte
parent ff6b43efde
commit 41415aa444
4 changed files with 17 additions and 1 deletions

View File

@ -33,11 +33,14 @@
#include <epan/packet.h>
#include <wsutil/pint.h>
#include <epan/address_types.h>
#include <wiretap/wtap.h>
void proto_register_vsock(void);
void proto_reg_handoff_vsock(void);
static int proto_vsock = -1;
static int vsock_address_type = -1;
static dissector_handle_t vsock_handle;
/* Generic header related fields */
static int hf_vsock_src_cid = -1;
@ -305,7 +308,13 @@ proto_register_vsock(void)
proto_register_field_array(proto_vsock, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_dissector("vsock", dissect_vsock, proto_vsock);
vsock_handle = register_dissector("vsock", dissect_vsock, proto_vsock);
}
void
proto_reg_handoff_vsock(void)
{
dissector_add_uint("wtap_encap", WTAP_ENCAP_VSOCK, vsock_handle);
}
/*

View File

@ -459,6 +459,9 @@ static const struct {
/* LoRaTap */
{ 270, WTAP_ENCAP_LORATAP },
/* Linux vsock */
{ 271, WTAP_ENCAP_VSOCK },
/*
* To repeat:
*

View File

@ -926,6 +926,9 @@ static struct encap_type_info encap_table_base[] = {
/* WTAP_ENCAP_3MB_ETHERNET */
{ "Xerox 3MB Ethernet", "xeth"},
/* Linux vsock */
{ "Linux vsock", "vsock" },
};
WS_DLL_LOCAL

View File

@ -272,6 +272,7 @@ extern "C" {
#define WTAP_ENCAP_USB_DARWIN 182
#define WTAP_ENCAP_LORATAP 183
#define WTAP_ENCAP_3MB_ETHERNET 184
#define WTAP_ENCAP_VSOCK 185
/* After adding new item here, please also add new item to encap_table_base array */
#define WTAP_NUM_ENCAP_TYPES wtap_get_num_encap_types()