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