|
|
b1047b |
diff -u b/epan/dissectors/packet-vsock.c b/epan/dissectors/packet-vsock.c
|
|
|
b1047b |
--- b/epan/dissectors/packet-vsock.c
|
|
|
b1047b |
+++ b/epan/dissectors/packet-vsock.c
|
|
|
b1047b |
@@ -0,0 +1,339 @@
|
|
|
b1047b |
+/* packet-vsock.c
|
|
|
b1047b |
+ * Routines for AF_VSOCK dissection
|
|
|
b1047b |
+ * Copyright 2016, Gerard Garcia <ggarcia@deic.uab.cat>
|
|
|
b1047b |
+ *
|
|
|
b1047b |
+ * Header definition:
|
|
|
b1047b |
+ * https://github.com/GerardGarcia/linux/blob/vsockmon/include/uapi/linux/vsockmon.h
|
|
|
b1047b |
+ *
|
|
|
b1047b |
+ * Wireshark - Network traffic analyzer
|
|
|
b1047b |
+ * By Gerald Combs <gerald@wireshark.org>
|
|
|
b1047b |
+ * Copyright 1998 Gerald Combs
|
|
|
b1047b |
+ *
|
|
|
b1047b |
+ * This program is free software; you can redistribute it and/or modify
|
|
|
b1047b |
+ * it under the terms of the GNU General Public License as published by
|
|
|
b1047b |
+ * the Free Software Foundation; either version 2 of the License, or
|
|
|
b1047b |
+ * (at your option) any later version.
|
|
|
b1047b |
+ *
|
|
|
b1047b |
+ * This program is distributed in the hope that it will be useful,
|
|
|
b1047b |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
b1047b |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
b1047b |
+ * GNU General Public License for more details.
|
|
|
b1047b |
+ *
|
|
|
b1047b |
+ * You should have received a copy of the GNU General Public License along
|
|
|
b1047b |
+ * with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
b1047b |
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
b1047b |
+ */
|
|
|
b1047b |
+
|
|
|
b1047b |
+/*
|
|
|
b1047b |
+ * The AF_VSOCK socket allows zero-configuration communication between guests
|
|
|
b1047b |
+ * and hypervisors using the standard socket API.
|
|
|
b1047b |
+ */
|
|
|
b1047b |
+
|
|
|
b1047b |
+#include <config.h>
|
|
|
b1047b |
+#include <epan/packet.h>
|
|
|
b1047b |
+#include <epan/pint.h>
|
|
|
b1047b |
+#include <epan/address.h>
|
|
|
b1047b |
+#include <epan/tvbuff.h>
|
|
|
b1047b |
+
|
|
|
b1047b |
+void proto_register_vsock(void);
|
|
|
b1047b |
+
|
|
|
b1047b |
+static int proto_vsock = -1;
|
|
|
b1047b |
+static int vsock_address_type = -1;
|
|
|
b1047b |
+
|
|
|
b1047b |
+/* Generic header related fields */
|
|
|
b1047b |
+static int hf_vsock_src_cid = -1;
|
|
|
b1047b |
+static int hf_vsock_src_port = -1;
|
|
|
b1047b |
+static int hf_vsock_dst_cid = -1;
|
|
|
b1047b |
+static int hf_vsock_dst_port = -1;
|
|
|
b1047b |
+static int hf_vsock_op = -1;
|
|
|
b1047b |
+static int hf_vsock_t = -1;
|
|
|
b1047b |
+static int hf_vsock_t_len = -1;
|
|
|
b1047b |
+static int hf_vsock_reserved = -1;
|
|
|
b1047b |
+static int hf_vsock_payload = -1;
|
|
|
b1047b |
+
|
|
|
b1047b |
+/* Virtio related fields */
|
|
|
b1047b |
+static int hf_virtio_src_cid = -1;
|
|
|
b1047b |
+static int hf_virtio_dst_cid = -1;
|
|
|
b1047b |
+static int hf_virtio_src_port = -1;
|
|
|
b1047b |
+static int hf_virtio_dst_port = -1;
|
|
|
b1047b |
+static int hf_virtio_len = -1;
|
|
|
b1047b |
+static int hf_virtio_type = -1;
|
|
|
b1047b |
+static int hf_virtio_op = -1;
|
|
|
b1047b |
+static int hf_virtio_flags = -1;
|
|
|
b1047b |
+static int hf_virtio_buf_alloc = -1;
|
|
|
b1047b |
+static int hf_virtio_fwd_cnt = -1;
|
|
|
b1047b |
+
|
|
|
b1047b |
+static gint ett_vsock = -1;
|
|
|
b1047b |
+static gint ett_virtio = -1;
|
|
|
b1047b |
+
|
|
|
b1047b |
+static const value_string af_vsockmon_op_names[] = {
|
|
|
b1047b |
+ { 0, "Unknown" },
|
|
|
b1047b |
+ { 1, "Connect" },
|
|
|
b1047b |
+ { 2, "Disconnect" },
|
|
|
b1047b |
+ { 3, "Control" },
|
|
|
b1047b |
+ { 4, "Payload" },
|
|
|
b1047b |
+ { 0, NULL }
|
|
|
b1047b |
+};
|
|
|
b1047b |
+
|
|
|
b1047b |
+enum af_vsockmon_t {
|
|
|
b1047b |
+ AF_VSOCK_T_UNKNOWN = 0,
|
|
|
b1047b |
+ AF_VSOCK_T_NO_INFO = 1,
|
|
|
b1047b |
+ AF_VSOCK_T_VIRTIO = 2
|
|
|
b1047b |
+};
|
|
|
b1047b |
+
|
|
|
b1047b |
+static const value_string af_vsockmon_t_names[] = {
|
|
|
b1047b |
+ { 0, "Unknown" },
|
|
|
b1047b |
+ { 1, "No info" },
|
|
|
b1047b |
+ { 2, "Virtio" },
|
|
|
b1047b |
+ { 0 , NULL }
|
|
|
b1047b |
+};
|
|
|
b1047b |
+
|
|
|
b1047b |
+static const value_string virtio_vsock_type_names[] = {
|
|
|
b1047b |
+ { 1, "Stream"},
|
|
|
b1047b |
+ { 0, NULL }
|
|
|
b1047b |
+};
|
|
|
b1047b |
+
|
|
|
b1047b |
+static const value_string virtio_vsock_op_names[] = {
|
|
|
b1047b |
+ { 0, "Invalid" },
|
|
|
b1047b |
+ { 1, "Request" },
|
|
|
b1047b |
+ { 2, "Response" },
|
|
|
b1047b |
+ { 3, "Rst" },
|
|
|
b1047b |
+ { 4, "Shutdown" },
|
|
|
b1047b |
+ { 5, "RW" },
|
|
|
b1047b |
+ { 6, "Credit update" },
|
|
|
b1047b |
+ { 7, "Credit response" },
|
|
|
b1047b |
+ { 0 , NULL }
|
|
|
b1047b |
+};
|
|
|
b1047b |
+
|
|
|
b1047b |
+#define VSOCK_MIN_LENGTH 32
|
|
|
b1047b |
+
|
|
|
b1047b |
+static int vsock_addr_to_str(const address* addr, gchar *buf, int buf_len)
|
|
|
b1047b |
+{
|
|
|
b1047b |
+ const guint8 *addrp = (const guint8 *)addr->data;
|
|
|
b1047b |
+
|
|
|
b1047b |
+ if(pletoh64(&addrp[0])==2){
|
|
|
b1047b |
+ g_strlcpy(buf, "host", buf_len);
|
|
|
b1047b |
+ } else {
|
|
|
b1047b |
+ g_snprintf(buf, buf_len, "%" G_GINT64_MODIFIER "u", pletoh64(&addrp[0]));
|
|
|
b1047b |
+ }
|
|
|
b1047b |
+
|
|
|
b1047b |
+ return (int)(strlen(buf)+1);
|
|
|
b1047b |
+}
|
|
|
b1047b |
+
|
|
|
b1047b |
+static int vsock_addr_str_len(const address* addr _U_)
|
|
|
b1047b |
+{
|
|
|
b1047b |
+ /* 2^64 unsigned int len */
|
|
|
b1047b |
+ return 19;
|
|
|
b1047b |
+}
|
|
|
b1047b |
+
|
|
|
b1047b |
+static int
|
|
|
b1047b |
+dissect_vsock(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|
|
b1047b |
+ void *data _U_)
|
|
|
b1047b |
+{
|
|
|
b1047b |
+ proto_item *ti, *virtio_ti;
|
|
|
b1047b |
+ proto_tree *vsock_tree = NULL, *virtio_tree = NULL;
|
|
|
b1047b |
+
|
|
|
b1047b |
+ guint32 t_len, payload_len, virtio_buf_alloc, op, type,
|
|
|
b1047b |
+ virtio_fwd_cnt, virtio_op, virtio_type;
|
|
|
b1047b |
+ guint16 payload_offset = 0, offset = 0;
|
|
|
b1047b |
+
|
|
|
b1047b |
+ if (tvb_reported_length(tvb) < VSOCK_MIN_LENGTH)
|
|
|
b1047b |
+ return 0;
|
|
|
b1047b |
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "vSocket");
|
|
|
b1047b |
+ /* Clear column information before start parsing */
|
|
|
b1047b |
+ col_clear(pinfo->cinfo, COL_INFO);
|
|
|
b1047b |
+
|
|
|
b1047b |
+ /* Create top tree */
|
|
|
b1047b |
+ ti = proto_tree_add_item(tree, proto_vsock, tvb, 0, -1, ENC_NA);
|
|
|
b1047b |
+ vsock_tree = proto_item_add_subtree(ti, ett_vsock);
|
|
|
b1047b |
+
|
|
|
b1047b |
+ /* Parse generic header part */
|
|
|
b1047b |
+
|
|
|
b1047b |
+ proto_tree_add_item(vsock_tree, hf_vsock_src_cid, tvb, offset, 8, ENC_LITTLE_ENDIAN);
|
|
|
b1047b |
+ TVB_SET_ADDRESS(&pinfo->src, AT_VSOCK, tvb, offset, 8);
|
|
|
b1047b |
+ offset += 8;
|
|
|
b1047b |
+
|
|
|
b1047b |
+ proto_tree_add_item(vsock_tree, hf_vsock_dst_cid, tvb, offset, 8, ENC_LITTLE_ENDIAN);
|
|
|
b1047b |
+ TVB_SET_ADDRESS(&pinfo->dst, AT_VSOCK, tvb, offset, 8);
|
|
|
b1047b |
+ offset += 8;
|
|
|
b1047b |
+
|
|
|
b1047b |
+ proto_tree_add_item(vsock_tree, hf_vsock_src_port, tvb, offset, 4, ENC_LITTLE_ENDIAN);
|
|
|
b1047b |
+ offset += 4;
|
|
|
b1047b |
+
|
|
|
b1047b |
+ proto_tree_add_item(vsock_tree, hf_vsock_dst_port, tvb, offset, 4, ENC_LITTLE_ENDIAN);
|
|
|
b1047b |
+ offset += 4;
|
|
|
b1047b |
+
|
|
|
b1047b |
+ op = tvb_get_letohs(tvb, offset);
|
|
|
b1047b |
+ proto_tree_add_item(vsock_tree, hf_vsock_op, tvb, offset, 2, ENC_LITTLE_ENDIAN);
|
|
|
b1047b |
+ offset += 2;
|
|
|
b1047b |
+
|
|
|
b1047b |
+ type = tvb_get_letohs(tvb, offset);
|
|
|
b1047b |
+ proto_tree_add_item(vsock_tree, hf_vsock_t, tvb, offset, 2, ENC_LITTLE_ENDIAN);
|
|
|
b1047b |
+ offset += 2;
|
|
|
b1047b |
+
|
|
|
b1047b |
+ t_len = tvb_get_letohs(tvb, offset);
|
|
|
b1047b |
+ proto_tree_add_uint(vsock_tree, hf_vsock_t_len, tvb, offset, 2, t_len);
|
|
|
b1047b |
+ offset += 2;
|
|
|
b1047b |
+
|
|
|
b1047b |
+ proto_tree_add_item(vsock_tree, hf_vsock_reserved, tvb, offset, 2, ENC_NA);
|
|
|
b1047b |
+ offset += 2;
|
|
|
b1047b |
+
|
|
|
b1047b |
+ payload_offset = offset + t_len;
|
|
|
b1047b |
+
|
|
|
b1047b |
+
|
|
|
b1047b |
+ /* Append summary information to top tree */
|
|
|
b1047b |
+ proto_item_append_text(ti, ", Op: %s, Transport: %s",
|
|
|
b1047b |
+ val_to_str(op, af_vsockmon_op_names, "Unknown (%d)"),
|
|
|
b1047b |
+ val_to_str(type, af_vsockmon_t_names, "Unknown (%d)"));
|
|
|
b1047b |
+
|
|
|
b1047b |
+ /* Fill columns */
|
|
|
b1047b |
+ col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] %s",
|
|
|
b1047b |
+ val_to_str(op, af_vsockmon_op_names, "Unknown (%d)"),
|
|
|
b1047b |
+ val_to_str(type, af_vsockmon_t_names, "Unknown (%d)"));
|
|
|
b1047b |
+
|
|
|
b1047b |
+ /* Create subtree if there is transport information */
|
|
|
b1047b |
+ switch (type) {
|
|
|
b1047b |
+ case AF_VSOCK_T_UNKNOWN:
|
|
|
b1047b |
+ case AF_VSOCK_T_NO_INFO:
|
|
|
b1047b |
+ break;
|
|
|
b1047b |
+ case AF_VSOCK_T_VIRTIO:
|
|
|
b1047b |
+
|
|
|
b1047b |
+ virtio_ti = proto_tree_add_text(vsock_tree, tvb, offset, 44, "Virtio transport header");
|
|
|
b1047b |
+ virtio_tree = proto_item_add_subtree(virtio_ti, ett_vsock);
|
|
|
b1047b |
+
|
|
|
b1047b |
+ proto_tree_add_item(virtio_tree, hf_virtio_src_cid, tvb, offset, 8, ENC_LITTLE_ENDIAN);
|
|
|
b1047b |
+ offset += 8;
|
|
|
b1047b |
+ proto_tree_add_item(virtio_tree, hf_virtio_dst_cid, tvb, offset, 8, ENC_LITTLE_ENDIAN);
|
|
|
b1047b |
+ offset += 8;
|
|
|
b1047b |
+ proto_tree_add_item(virtio_tree, hf_virtio_src_port, tvb, offset, 4, ENC_LITTLE_ENDIAN);
|
|
|
b1047b |
+ offset += 4;
|
|
|
b1047b |
+ proto_tree_add_item(virtio_tree, hf_virtio_dst_port, tvb, offset, 4, ENC_LITTLE_ENDIAN);
|
|
|
b1047b |
+ offset += 4;
|
|
|
b1047b |
+ proto_tree_add_item(virtio_tree, hf_virtio_len, tvb, offset, 4, ENC_LITTLE_ENDIAN);
|
|
|
b1047b |
+ offset += 4;
|
|
|
b1047b |
+
|
|
|
b1047b |
+ virtio_type = tvb_get_letohs(tvb, offset);
|
|
|
b1047b |
+ proto_tree_add_item(virtio_tree, hf_virtio_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
|
|
|
b1047b |
+ offset += 2;
|
|
|
b1047b |
+
|
|
|
b1047b |
+ virtio_op = tvb_get_letohs(tvb, offset);
|
|
|
b1047b |
+ proto_tree_add_item(virtio_tree, hf_virtio_op, tvb, offset, 2, ENC_LITTLE_ENDIAN);
|
|
|
b1047b |
+ offset += 2;
|
|
|
b1047b |
+
|
|
|
b1047b |
+ proto_tree_add_item(virtio_tree, hf_virtio_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN);
|
|
|
b1047b |
+ offset += 4;
|
|
|
b1047b |
+
|
|
|
b1047b |
+ virtio_buf_alloc = tvb_get_letohl(tvb, offset);
|
|
|
b1047b |
+ proto_tree_add_item(virtio_tree, hf_virtio_buf_alloc, tvb, offset, 4, ENC_LITTLE_ENDIAN);
|
|
|
b1047b |
+ offset += 4;
|
|
|
b1047b |
+
|
|
|
b1047b |
+ virtio_fwd_cnt = tvb_get_letohl(tvb, offset);
|
|
|
b1047b |
+ proto_tree_add_item(virtio_tree, hf_virtio_fwd_cnt, tvb, offset, 4, ENC_LITTLE_ENDIAN);
|
|
|
b1047b |
+
|
|
|
b1047b |
+ /* Append virtio information */
|
|
|
b1047b |
+ col_append_fstr(pinfo->cinfo, COL_INFO, ": %s, Op: %s, Buf alloc: %u, Fwd cnt: %u",
|
|
|
b1047b |
+ val_to_str(virtio_type, virtio_vsock_type_names, "Unknown (%d)"),
|
|
|
b1047b |
+ val_to_str(virtio_op, virtio_vsock_op_names, "Unknown (%d)"),
|
|
|
b1047b |
+ virtio_buf_alloc, virtio_fwd_cnt);
|
|
|
b1047b |
+ break;
|
|
|
b1047b |
+ }
|
|
|
b1047b |
+
|
|
|
b1047b |
+
|
|
|
b1047b |
+ /* Append payload */
|
|
|
b1047b |
+ payload_len = tvb_reported_length_remaining(tvb, payload_offset);
|
|
|
b1047b |
+ if (payload_len)
|
|
|
b1047b |
+ proto_tree_add_bytes_format(vsock_tree, hf_vsock_payload, tvb, payload_offset, payload_len,
|
|
|
b1047b |
+ NULL, "Payload (%uB)", payload_len);
|
|
|
b1047b |
+
|
|
|
b1047b |
+ return tvb_reported_length(tvb);
|
|
|
b1047b |
+}
|
|
|
b1047b |
+
|
|
|
b1047b |
+void
|
|
|
b1047b |
+proto_register_vsock(void)
|
|
|
b1047b |
+{
|
|
|
b1047b |
+ static hf_register_info hf[] = {
|
|
|
b1047b |
+ { &hf_vsock_src_cid,
|
|
|
b1047b |
+ {"Source cid", "vsock.src_cid", FT_UINT64, BASE_DEC, NULL,
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_vsock_dst_cid,
|
|
|
b1047b |
+ {"Destination cid", "vsock.dst_cid", FT_UINT64, BASE_DEC, NULL,
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_vsock_src_port,
|
|
|
b1047b |
+ {"Source port", "vsock.src_port", FT_UINT32, BASE_DEC, NULL,
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_vsock_dst_port,
|
|
|
b1047b |
+ {"Destination port", "vsock.dst_port", FT_UINT32, BASE_DEC, NULL,
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_vsock_op,
|
|
|
b1047b |
+ {"Operation", "vsock.op", FT_UINT16, BASE_DEC, VALS(af_vsockmon_op_names),
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_vsock_t,
|
|
|
b1047b |
+ {"Transport", "vsock.trans", FT_UINT16, BASE_DEC, VALS(af_vsockmon_t_names),
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_vsock_reserved,
|
|
|
b1047b |
+ {"Reserved", "vsock.reserved", FT_BYTES, BASE_NONE, NULL,
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_vsock_t_len,
|
|
|
b1047b |
+ {"Transport length", "vsock.trans_len", FT_UINT16, BASE_DEC, NULL,
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_vsock_payload,
|
|
|
b1047b |
+ { "Payload", "vsock.payload", FT_BYTES, BASE_NONE, NULL,
|
|
|
b1047b |
+ 0x0, NULL, HFILL}},
|
|
|
b1047b |
+ { &hf_virtio_src_cid,
|
|
|
b1047b |
+ {"Source cid", "vsock.virtio.src_cid", FT_UINT64, BASE_DEC, NULL,
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_virtio_dst_cid,
|
|
|
b1047b |
+ {"Destination cid", "vsock.virtio.dst_cid", FT_UINT64, BASE_DEC, NULL,
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_virtio_src_port,
|
|
|
b1047b |
+ {"Source port", "vsock.virtio.src_prot", FT_UINT32, BASE_DEC, NULL,
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_virtio_dst_port,
|
|
|
b1047b |
+ {"Destination port", "vsock.virtio.dst_prot", FT_UINT32, BASE_DEC, NULL,
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_virtio_len,
|
|
|
b1047b |
+ {"Length", "vsock.virtio.len", FT_UINT32, BASE_DEC, NULL,
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_virtio_type,
|
|
|
b1047b |
+ {"Type", "vsock.virtio.type", FT_UINT16, BASE_DEC, VALS(virtio_vsock_type_names),
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_virtio_op,
|
|
|
b1047b |
+ {"Operation", "vsock.virtio.op", FT_UINT16, BASE_DEC, VALS(virtio_vsock_op_names),
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_virtio_flags,
|
|
|
b1047b |
+ {"Flags", "vsock.virtio.flags", FT_UINT32, BASE_HEX, NULL,
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_virtio_buf_alloc,
|
|
|
b1047b |
+ {"Buf alloc", "vsock.virtio.buf_alloc", FT_UINT32, BASE_DEC, NULL,
|
|
|
b1047b |
+ 0x0, NULL, HFILL }},
|
|
|
b1047b |
+ { &hf_virtio_fwd_cnt,
|
|
|
b1047b |
+ {"Fwd cnt", "vsock.virtio.fwd_cnt", FT_UINT32, BASE_DEC, NULL,
|
|
|
b1047b |
+ 0x0, NULL, HFILL }}
|
|
|
b1047b |
+ };
|
|
|
b1047b |
+ static gint *ett[] = {
|
|
|
b1047b |
+ &ett_vsock,
|
|
|
b1047b |
+ &ett_virtio
|
|
|
b1047b |
+ };
|
|
|
b1047b |
+
|
|
|
b1047b |
+ //vsock_address_type = address_type_dissector_register("AT_VSOCK", "vSocket Address",
|
|
|
b1047b |
+ // vsock_addr_to_str, vsock_addr_str_len, NULL, NULL, NULL, NULL, NULL);
|
|
|
b1047b |
+
|
|
|
b1047b |
+ proto_vsock = proto_register_protocol("vSocket", "vsock", "vsock");
|
|
|
b1047b |
+ proto_register_field_array(proto_vsock, hf, array_length(hf));
|
|
|
b1047b |
+ proto_register_subtree_array(ett, array_length(ett));
|
|
|
b1047b |
+
|
|
|
b1047b |
+ //register_dissector("vsock", dissect_vsock, proto_vsock);
|
|
|
b1047b |
+}
|
|
|
b1047b |
+
|
|
|
b1047b |
+/*
|
|
|
b1047b |
+ * Editor modelines - https://www.wireshark.org/tools/modelines.html
|
|
|
b1047b |
+ *
|
|
|
b1047b |
+ * Local variables:
|
|
|
b1047b |
+ * c-basic-offset: 4
|
|
|
b1047b |
+ * tab-width: 8
|
|
|
b1047b |
+ * indent-tabs-mode: nil
|
|
|
b1047b |
+ * End:
|
|
|
b1047b |
+ *
|
|
|
b1047b |
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
b1047b |
+ * :indentSize=4:tabSize=8:noTabs=true:
|
|
|
b1047b |
+ */
|
|
|
b1047b |
unchanged:
|
|
|
b1047b |
--- a/epan/dissectors/Makefile.common
|
|
|
b1047b |
+++ b/epan/dissectors/Makefile.common
|
|
|
b1047b |
@@ -2700,6 +2700,7 @@ DISSECTOR_SRC = \
|
|
|
b1047b |
packet-vrt.c \
|
|
|
b1047b |
packet-vssmonitoring.c \
|
|
|
b1047b |
packet-vtp.c \
|
|
|
b1047b |
+ packet-vsock.c \
|
|
|
b1047b |
packet-vuze-dht.c \
|
|
|
b1047b |
packet-vxi11.c \
|
|
|
b1047b |
packet-vxlan.c \
|
|
|
b1047b |
diff --git a/epan/dissectors/packet-vsock.c.old b/epan/dissectors/packet-vsock.c
|
|
|
b1047b |
index af8ce38..c13dfc0 100644
|
|
|
b1047b |
--- a/epan/dissectors/packet-vsock.c.old
|
|
|
b1047b |
+++ b/epan/dissectors/packet-vsock.c
|
|
|
b1047b |
@@ -33,11 +33,14 @@
|
|
|
b1047b |
#include <epan/pint.h>
|
|
|
b1047b |
#include <epan/address.h>
|
|
|
b1047b |
#include <epan/tvbuff.h>
|
|
|
b1047b |
+#include <wiretap/wtap.h>
|
|
|
b1047b |
|
|
|
b1047b |
void proto_register_vsock(void);
|
|
|
b1047b |
+void proto_reg_handoff_vsock(void);
|
|
|
b1047b |
|
|
|
b1047b |
static int proto_vsock = -1;
|
|
|
b1047b |
static int vsock_address_type = -1;
|
|
|
b1047b |
+static dissector_handle_t vsock_handle;
|
|
|
b1047b |
|
|
|
b1047b |
/* Generic header related fields */
|
|
|
b1047b |
static int hf_vsock_src_cid = -1;
|
|
|
b1047b |
@@ -310,6 +313,13 @@ proto_register_vsock(void)
|
|
|
b1047b |
//register_dissector("vsock", dissect_vsock, proto_vsock);
|
|
|
b1047b |
}
|
|
|
b1047b |
|
|
|
b1047b |
+void
|
|
|
b1047b |
+proto_reg_handoff_vsock(void)
|
|
|
b1047b |
+{
|
|
|
b1047b |
+ vsock_handle = create_dissector_handle(dissect_vsock, proto_vsock);
|
|
|
b1047b |
+ dissector_add_uint("wtap_encap", WTAP_ENCAP_VSOCK, vsock_handle);
|
|
|
b1047b |
+}
|
|
|
b1047b |
+
|
|
|
b1047b |
/*
|
|
|
b1047b |
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
|
|
b1047b |
*
|
|
|
b1047b |
diff --git a/wiretap/pcap-common.c.old b/wiretap/pcap-common.c
|
|
|
b1047b |
index 42caadc..87b845d 100644
|
|
|
b1047b |
--- a/wiretap/pcap-common.c.old
|
|
|
b1047b |
+++ b/wiretap/pcap-common.c
|
|
|
b1047b |
@@ -397,6 +397,8 @@ static const struct {
|
|
|
b1047b |
{ 248, WTAP_ENCAP_SCTP},
|
|
|
b1047b |
/* USBPcap */
|
|
|
b1047b |
{ 249, WTAP_ENCAP_USBPCAP},
|
|
|
b1047b |
+ /* Linux vsock */
|
|
|
b1047b |
+ { 271, WTAP_ENCAP_VSOCK },
|
|
|
b1047b |
|
|
|
b1047b |
/*
|
|
|
b1047b |
* To repeat:
|
|
|
b1047b |
diff --git a/wiretap/wtap.c.old b/wiretap/wtap.c
|
|
|
b1047b |
index 69803d6..5be2666 100644
|
|
|
b1047b |
--- a/wiretap/wtap.c.old
|
|
|
b1047b |
+++ b/wiretap/wtap.c
|
|
|
b1047b |
@@ -608,6 +608,9 @@ static struct encap_type_info encap_table_base[] = {
|
|
|
b1047b |
|
|
|
b1047b |
/* WTAP_ENCAP_USBPCAP */
|
|
|
b1047b |
{ "USB packets with USBPcap header", "usb-usbpcap" },
|
|
|
b1047b |
+
|
|
|
b1047b |
+ /* Linux vsock */
|
|
|
b1047b |
+ { "Linux vsock", "vsock" },
|
|
|
b1047b |
};
|
|
|
b1047b |
|
|
|
b1047b |
WS_DLL_LOCAL
|
|
|
b1047b |
diff --git a/wiretap/wtap.h.old b/wiretap/wtap.h
|
|
|
b1047b |
index b49c280..c42d49e 100644
|
|
|
b1047b |
--- a/wiretap/wtap.h.old
|
|
|
b1047b |
+++ b/wiretap/wtap.h
|
|
|
b1047b |
@@ -244,6 +244,7 @@ extern "C" {
|
|
|
b1047b |
#define WTAP_ENCAP_INFINIBAND 151
|
|
|
b1047b |
#define WTAP_ENCAP_JUNIPER_SVCS 152
|
|
|
b1047b |
#define WTAP_ENCAP_USBPCAP 153
|
|
|
b1047b |
+#define WTAP_ENCAP_VSOCK 154
|
|
|
b1047b |
|
|
|
b1047b |
#define WTAP_NUM_ENCAP_TYPES wtap_get_num_encap_types()
|
|
|
b1047b |
|
|
|
b1047b |
diff --git a/epan/address.h.old b/epan/address.h
|
|
|
b1047b |
index 5405075..8471289 100644
|
|
|
b1047b |
--- a/epan/address.h.old
|
|
|
b1047b |
+++ b/epan/address.h
|
|
|
b1047b |
@@ -58,8 +58,9 @@ typedef enum {
|
|
|
b1047b |
AT_USB, /* USB Device address
|
|
|
b1047b |
* (0xffffffff represents the host) */
|
|
|
b1047b |
AT_AX25, /* AX.25 */
|
|
|
b1047b |
- AT_IEEE_802_15_4_SHORT /* IEEE 802.15.4 16-bit short address */
|
|
|
b1047b |
+ AT_IEEE_802_15_4_SHORT,/* IEEE 802.15.4 16-bit short address */
|
|
|
b1047b |
/* (the long addresses are EUI-64's */
|
|
|
b1047b |
+ AT_VSOCK /* VSOCK */
|
|
|
b1047b |
} address_type;
|
|
|
b1047b |
|
|
|
b1047b |
typedef struct _address {
|
|
|
b1047b |
diff --git a/epan/address_to_str.c.old b/epan/address_to_str.c
|
|
|
b1047b |
index f360017..101d33e 100644
|
|
|
b1047b |
--- a/epan/address_to_str.c.old
|
|
|
b1047b |
+++ b/epan/address_to_str.c
|
|
|
b1047b |
@@ -623,6 +623,13 @@ address_to_str_buf(const address *addr, gchar *buf, int buf_len)
|
|
|
b1047b |
else
|
|
|
b1047b |
g_snprintf(buf, buf_len, "0x%04x", ieee_802_15_4_short_addr);
|
|
|
b1047b |
break;
|
|
|
b1047b |
+ case AT_VSOCK:
|
|
|
b1047b |
+ addrdata = (const guint8 *)addr->data;
|
|
|
b1047b |
+ if(pletoh64(&addrdata[0])==2)
|
|
|
b1047b |
+ g_strlcpy(buf, "host", buf_len);
|
|
|
b1047b |
+ else
|
|
|
b1047b |
+ g_snprintf(buf, buf_len, "%" G_GINT64_MODIFIER "u", pletoh64(&addrdata[0]));
|
|
|
b1047b |
+ break;
|
|
|
b1047b |
default:
|
|
|
b1047b |
g_assert_not_reached();
|
|
|
b1047b |
}
|