aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-vxlan.c
diff options
context:
space:
mode:
authorAmine Kherbouche <amine.kherbouche@6wind.com>2015-07-07 10:46:34 +0200
committerMichael Mann <mmann78@netscape.net>2015-07-09 20:28:11 +0000
commit2a5a560a64e73832c6a91b4a3772ddbda0e7d5fb (patch)
tree4f2ad2d143821e22da4326dbf26d94f12b2174be /epan/dissectors/packet-vxlan.c
parentfdd07c4d3a5e7d83e235957dc731502770e709f1 (diff)
VXLAN: Add Group Based Policy dissector
According to some advices from my last commit,i made some changes, and i use proto_tree_add_bitmask for bits field. Editing VXLAN dissector for supporting GBP extension described in the following draft link : https://tools.ietf.org/html/draft-smith-vxlan-group-policy-00 This pach works fine with "old" version of VXLAN (no GBP support) The flags are now extended to 16 bits to support GBP extension, Group Policy Id is on 16 bits, VNI always on 24 bits and remaining bits are reserved. The following bits are defined in addition to the existing VXLAN fields: bit 0 : "G" Group Based Policy Extension bit bit 9 : "D" Don't Learn bit bit 12 : "A" Policy Applied bit the remaining bits are reserved Bug: 11348 Change-Id: I425ed63cf76f134eb3d1680a1753ed31f252dfa8 Signed-off-by: Amine Kherbouche <amine.kherbouche@6wind.com> Reviewed-on: https://code.wireshark.org/review/9537 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-vxlan.c')
-rw-r--r--epan/dissectors/packet-vxlan.c101
1 files changed, 41 insertions, 60 deletions
diff --git a/epan/dissectors/packet-vxlan.c b/epan/dissectors/packet-vxlan.c
index d7ea55691f..ddadf99a58 100644
--- a/epan/dissectors/packet-vxlan.c
+++ b/epan/dissectors/packet-vxlan.c
@@ -28,6 +28,7 @@
#include "config.h"
#include <epan/packet.h>
+#include <epan/tfs.h>
#define UDP_PORT_VXLAN 4789
@@ -37,15 +38,12 @@ void proto_reg_handoff_vxlan(void);
static int proto_vxlan = -1;
static int hf_vxlan_flags = -1;
-static int hf_vxlan_flag_b7 = -1;
-static int hf_vxlan_flag_b6 = -1;
-static int hf_vxlan_flag_b5 = -1;
-static int hf_vxlan_flag_b4 = -1;
+static int hf_vxlan_flags_reserved = -1;
+static int hf_vxlan_flag_a = -1;
+static int hf_vxlan_flag_d = -1;
static int hf_vxlan_flag_i = -1;
-static int hf_vxlan_flag_b2 = -1;
-static int hf_vxlan_flag_b1 = -1;
-static int hf_vxlan_flag_b0 = -1;
-static int hf_vxlan_reserved_24 = -1;
+static int hf_vxlan_flag_g = -1;
+static int hf_vxlan_gbp = -1;
static int hf_vxlan_vni = -1;
static int hf_vxlan_reserved_8 = -1;
@@ -53,6 +51,14 @@ static int hf_vxlan_reserved_8 = -1;
static int ett_vxlan = -1;
static int ett_vxlan_flgs = -1;
+static const int *flags_fields[] = {
+ &hf_vxlan_flag_g,
+ &hf_vxlan_flag_d,
+ &hf_vxlan_flag_i,
+ &hf_vxlan_flag_a,
+ &hf_vxlan_flags_reserved,
+ NULL
+ };
static dissector_handle_t eth_handle;
@@ -77,31 +83,24 @@ dissect_vxlan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
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
VXLAN Header:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |R|R|R|R|I|R|R|R| Reserved |
+ |G|R|R|R|I|R|R|R|R|D|R|R|A|R|R|R| Group Policy ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| VXLAN Network Identifier (VNI) | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
- /* Flags (8 bits) where the I flag MUST be set to 1 for a valid
- * VXLAN Network ID (VNI). The remaining 7 bits (designated "R") are
+ /* Flags (16 bits) where the I flag MUST be set to 1 for a valid
+ * VXLAN Network ID (VNI). The remaining 12 bits (designated "R") are
* reserved fields and MUST be set to zero.
*/
- flg_item = proto_tree_add_item(vxlan_tree, hf_vxlan_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
+ flg_item = proto_tree_add_item(vxlan_tree, hf_vxlan_flags, tvb, offset, 2, ENC_BIG_ENDIAN);
flg_tree = proto_item_add_subtree(flg_item, ett_vxlan_flgs);
- proto_tree_add_item(flg_tree, hf_vxlan_flag_b7, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(flg_tree, hf_vxlan_flag_b6, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(flg_tree, hf_vxlan_flag_b5, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(flg_tree, hf_vxlan_flag_b4, tvb, offset, 1, ENC_BIG_ENDIAN);
-
- proto_tree_add_item(flg_tree, hf_vxlan_flag_i, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(flg_tree, hf_vxlan_flag_b2, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(flg_tree, hf_vxlan_flag_b1, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(flg_tree, hf_vxlan_flag_b0, tvb, offset, 1, ENC_BIG_ENDIAN);
- offset++;
+ proto_tree_add_bitmask(flg_tree, tvb, offset, hf_vxlan_flags,
+ ett_vxlan_flgs, flags_fields, ENC_BIG_ENDIAN);
+ offset+=2;
- proto_tree_add_item(vxlan_tree, hf_vxlan_reserved_24, tvb, offset, 3, ENC_BIG_ENDIAN);
- offset+=3;
+ proto_tree_add_item(vxlan_tree, hf_vxlan_gbp, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset+=2;
proto_tree_add_item(vxlan_tree, hf_vxlan_vni, tvb, offset, 3, ENC_BIG_ENDIAN);
offset+=3;
@@ -123,61 +122,43 @@ proto_register_vxlan(void)
static hf_register_info hf[] = {
{ &hf_vxlan_flags,
{ "Flags", "vxlan.flags",
- FT_UINT8, BASE_HEX, NULL, 0x00,
+ FT_UINT16, BASE_HEX, NULL, 0x00,
NULL, HFILL
},
},
- { &hf_vxlan_flag_b7,
- { "Reserved(R)", "vxlan.flag_b7",
- FT_BOOLEAN, 8, NULL, 0x80,
- NULL, HFILL,
- },
- },
- { &hf_vxlan_flag_b6,
- { "Reserved(R)", "vxlan.flag_b6",
- FT_BOOLEAN, 8, NULL, 0x40,
+ { &hf_vxlan_flags_reserved,
+ { "Reserved(R)", "vxlan.flags_reserved",
+ FT_BOOLEAN, 16, NULL, 0x77b7,
NULL, HFILL,
},
},
- { &hf_vxlan_flag_b5,
- { "Reserved(R)", "vxlan.flag_b5",
- FT_BOOLEAN, 8, NULL, 0x20,
- NULL, HFILL,
- },
- },
- { &hf_vxlan_flag_b4,
- { "Reserved(R)", "vxlan.flag_b4",
- FT_BOOLEAN, 8, NULL, 0x10,
+ { &hf_vxlan_flag_g,
+ { "GBP Extension", "vxlan.flag_g",
+ FT_BOOLEAN, 16, TFS(&tfs_defined_not_defined), 0x8000,
NULL, HFILL,
},
},
{ &hf_vxlan_flag_i,
- { "VXLAN Network ID(VNI)", "vxlan.flag_i",
- FT_BOOLEAN, 8, TFS(&tfs_present_not_present), 0x08,
- NULL, HFILL,
- },
- },
- { &hf_vxlan_flag_b2,
- { "Reserved(R)", "vxlan.flag_b2",
- FT_BOOLEAN, 8, NULL, 0x04,
+ { "VXLAN Network ID (VNI)", "vxlan.flag_i",
+ FT_BOOLEAN, 16, NULL, 0x0800,
NULL, HFILL,
},
},
- { &hf_vxlan_flag_b1,
- { "Reserved(R)", "vxlan.flag_b1",
- FT_BOOLEAN, 8, NULL, 0x02,
+ { &hf_vxlan_flag_d,
+ { "Don't Learn", "vxlan.flag_d",
+ FT_BOOLEAN, 16, NULL, 0x0040,
NULL, HFILL,
},
},
- { &hf_vxlan_flag_b0,
- { "Reserved(R)", "vxlan.flag_b0",
- FT_BOOLEAN, 8, NULL, 0x01,
+ { &hf_vxlan_flag_a,
+ { "Policy Applied", "vxlan.flag_a",
+ FT_BOOLEAN, 16, NULL, 0x0008,
NULL, HFILL,
},
},
- { &hf_vxlan_reserved_24,
- { "Reserved", "vxlan.reserved24",
- FT_UINT24, BASE_HEX, NULL, 0x00,
+ { &hf_vxlan_gbp,
+ { "Group Policy ID", "vxlan.gbp",
+ FT_UINT16, BASE_DEC, NULL, 0x00,
NULL, HFILL
},
},