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>
This commit is contained in:
Amine Kherbouche 2015-07-07 10:46:34 +02:00 committed by Michael Mann
parent fdd07c4d3a
commit 2a5a560a64
4 changed files with 44 additions and 61 deletions

View File

@ -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_bitmask(flg_tree, tvb, offset, hf_vxlan_flags,
ett_vxlan_flgs, flags_fields, ENC_BIG_ENDIAN);
offset+=2;
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_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,
{ &hf_vxlan_flags_reserved,
{ "Reserved(R)", "vxlan.flags_reserved",
FT_BOOLEAN, 16, NULL, 0x77b7,
NULL, HFILL,
},
},
{ &hf_vxlan_flag_b6,
{ "Reserved(R)", "vxlan.flag_b6",
FT_BOOLEAN, 8, NULL, 0x40,
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,
{ "VXLAN Network ID (VNI)", "vxlan.flag_i",
FT_BOOLEAN, 16, NULL, 0x0800,
NULL, HFILL,
},
},
{ &hf_vxlan_flag_b2,
{ "Reserved(R)", "vxlan.flag_b2",
FT_BOOLEAN, 8, NULL, 0x04,
{ &hf_vxlan_flag_d,
{ "Don't Learn", "vxlan.flag_d",
FT_BOOLEAN, 16, NULL, 0x0040,
NULL, HFILL,
},
},
{ &hf_vxlan_flag_b1,
{ "Reserved(R)", "vxlan.flag_b1",
FT_BOOLEAN, 8, NULL, 0x02,
{ &hf_vxlan_flag_a,
{ "Policy Applied", "vxlan.flag_a",
FT_BOOLEAN, 16, NULL, 0x0008,
NULL, HFILL,
},
},
{ &hf_vxlan_flag_b0,
{ "Reserved(R)", "vxlan.flag_b0",
FT_BOOLEAN, 8, NULL, 0x01,
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
},
},

View File

@ -28,6 +28,7 @@
#include <epan/ipproto.h>
#include <epan/expert.h>
#include "packet-wccp.h"
#include <epan/tfs.h>
void proto_register_wccp(void);
void proto_reg_handoff_wccp(void);
@ -290,7 +291,6 @@ static const value_string wccp_version_val[] = {
{ 0, NULL}
};
const true_false_string tfs_defined_not_defined = { "Defined", "Not defined" };
const true_false_string tfs_src_dest_port = { "Source port", "Destination port" };
const true_false_string tfs_redirect_protocol0 = { "Redirect only protocol 0 (IP)", "Redirect all traffic" };
const true_false_string tfs_historical_current = { "Historical", "Current" };

View File

@ -86,4 +86,5 @@ const true_false_string tfs_protocol_sensative_bit_transparent = { "Protocol sen
const true_false_string tfs_full_half = { "Full", "Half" };
const true_false_string tfs_acknowledged_not_acknowledged = { "Acknowledged", "Not Acknowledged" };
const true_false_string tfs_response_request = { "Response", "Request" };
const true_false_string tfs_defined_not_defined = { "Defined", "Not defined" };

View File

@ -101,6 +101,7 @@ WS_DLL_PUBLIC const true_false_string tfs_protocol_sensative_bit_transparent;
WS_DLL_PUBLIC const true_false_string tfs_full_half;
WS_DLL_PUBLIC const true_false_string tfs_acknowledged_not_acknowledged;
WS_DLL_PUBLIC const true_false_string tfs_response_request;
WS_DLL_PUBLIC const true_false_string tfs_defined_not_defined;
#ifdef __cplusplus
}