3 * Routines for Virtual eXtensible Local Area Network (VXLAN) packet dissection
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * http://tools.ietf.org/html/draft-mahalingam-dutt-dcops-vxlan-00
32 #include <epan/packet.h>
36 static int proto_vxlan
= -1;
38 static int hf_vxlan_flags
= -1;
39 static int hf_vxlan_flag_b7
= -1;
40 static int hf_vxlan_flag_b6
= -1;
41 static int hf_vxlan_flag_b5
= -1;
42 static int hf_vxlan_flag_b4
= -1;
43 static int hf_vxlan_flag_i
= -1;
44 static int hf_vxlan_flag_b2
= -1;
45 static int hf_vxlan_flag_b1
= -1;
46 static int hf_vxlan_flag_b0
= -1;
47 static int hf_vxlan_reserved_24
= -1;
48 static int hf_vxlan_vni
= -1;
49 static int hf_vxlan_reserved_8
= -1;
52 static int ett_vxlan
= -1;
53 static int ett_vxlan_flgs
= -1;
56 static dissector_handle_t eth_handle
;
59 dissect_vxlan(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
61 proto_tree
*vxlan_tree
, *flg_tree
;
62 proto_item
*ti
, *flg_item
;
66 /* Make entry in Protocol column on summary display */
67 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "VxLAN");
69 col_clear(pinfo
->cinfo
, COL_INFO
);
71 ti
= proto_tree_add_item(tree
, proto_vxlan
, tvb
, offset
, -1, ENC_NA
);
72 vxlan_tree
= proto_item_add_subtree(ti
, ett_vxlan
);
76 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
78 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
79 |R|R|R|R|I|R|R|R| Reserved |
80 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
81 | VXLAN Network Identifier (VNI) | Reserved |
82 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
84 /* Flags (8 bits) where the I flag MUST be set to 1 for a valid
85 * VXLAN Network ID (VNI). The remaining 7 bits (designated "R") are
86 * reserved fields and MUST be set to zero.
88 flg_item
= proto_tree_add_item(vxlan_tree
, hf_vxlan_flags
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
89 flg_tree
= proto_item_add_subtree(flg_item
, ett_vxlan_flgs
);
91 proto_tree_add_item(flg_tree
, hf_vxlan_flag_b7
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
92 proto_tree_add_item(flg_tree
, hf_vxlan_flag_b6
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
93 proto_tree_add_item(flg_tree
, hf_vxlan_flag_b5
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
94 proto_tree_add_item(flg_tree
, hf_vxlan_flag_b4
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
96 proto_tree_add_item(flg_tree
, hf_vxlan_flag_i
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
97 proto_tree_add_item(flg_tree
, hf_vxlan_flag_b2
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
98 proto_tree_add_item(flg_tree
, hf_vxlan_flag_b1
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
99 proto_tree_add_item(flg_tree
, hf_vxlan_flag_b0
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
102 proto_tree_add_item(vxlan_tree
, hf_vxlan_reserved_24
, tvb
, offset
, 3, ENC_BIG_ENDIAN
);
105 proto_tree_add_item(vxlan_tree
, hf_vxlan_vni
, tvb
, offset
, 3, ENC_BIG_ENDIAN
);
109 proto_tree_add_item(vxlan_tree
, hf_vxlan_reserved_8
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
112 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
113 call_dissector(eth_handle
, next_tvb
, pinfo
, tree
);
118 /* Register VxLAN with Wireshark */
120 proto_register_vxlan(void)
122 static hf_register_info hf
[] = {
124 { "Flags", "vxlan.flags",
125 FT_UINT8
, BASE_HEX
, NULL
, 0x00,
130 { "Reserved(R)", "vxlan.flag_b7",
131 FT_BOOLEAN
, 8, NULL
, 0x80,
136 { "Reserved(R)", "vxlan.flag_b6",
137 FT_BOOLEAN
, 8, NULL
, 0x40,
142 { "Reserved(R)", "vxlan.flag_b5",
143 FT_BOOLEAN
, 8, NULL
, 0x20,
148 { "Reserved(R)", "vxlan.flag_b4",
149 FT_BOOLEAN
, 8, NULL
, 0x10,
154 { "VXLAN Network ID(VNI)", "vxlan.flag_i",
155 FT_BOOLEAN
, 8, TFS(&tfs_present_not_present
), 0x08,
160 { "Reserved(R)", "vxlan.flag_b2",
161 FT_BOOLEAN
, 8, NULL
, 0x10,
166 { "Reserved(R)", "vxlan.flag_b1",
167 FT_BOOLEAN
, 8, NULL
, 0x10,
172 { "Reserved(R)", "vxlan.flag_b0",
173 FT_BOOLEAN
, 8, NULL
, 0x10,
177 { &hf_vxlan_reserved_24
,
178 { "Reserved", "vxlan.reserved24",
179 FT_UINT24
, BASE_HEX
, NULL
, 0x00,
184 { "VXLAN Network Identifier (VNI)", "vxlan.vni",
185 FT_UINT24
, BASE_DEC
, NULL
, 0x00,
189 { &hf_vxlan_reserved_8
,
190 { "Reserved", "vxlan.reserved8",
191 FT_UINT8
, BASE_DEC
, NULL
, 0x00,
197 /* Setup protocol subtree array */
198 static gint
*ett
[] = {
203 /* Register the protocol name and description */
204 proto_vxlan
= proto_register_protocol("Virtual eXtensible Local Area Network",
207 /* Required function calls to register the header fields and subtrees used */
208 proto_register_field_array(proto_vxlan
, hf
, array_length(hf
));
209 proto_register_subtree_array(ett
, array_length(ett
));
215 proto_reg_handoff_vxlan(void)
217 dissector_handle_t vxlan_handle
;
219 eth_handle
= find_dissector("eth");
221 vxlan_handle
= create_dissector_handle(dissect_vxlan
, proto_vxlan
);
222 dissector_add_handle("udp.port", vxlan_handle
); /* For 'Decode As' */
226 * Editor modelines - http://www.wireshark.org/tools/modelines.html
231 * indent-tabs-mode: nil
234 * vi: set shiftwidth=4 tabstop=8 expandtab:
235 * :indentSize=4:tabSize=8:noTabs=true: