From 1f44007dd349dfc2c6f9feba5a340a292faeb6a2 Mon Sep 17 00:00:00 2001 From: Gabor Vaszkun Date: Thu, 29 Jun 2017 14:51:26 +0200 Subject: Added General Notification Message opcode to CFM Change-Id: Ieeb3f9ae6b9b261bb68917005d15822197e37b4e Reviewed-on: https://code.wireshark.org/review/22462 Petri-Dish: Anders Broman Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/dissectors/packet-cfm.c | 105 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/epan/dissectors/packet-cfm.c b/epan/dissectors/packet-cfm.c index 52d1019597..122ddcf963 100644 --- a/epan/dissectors/packet-cfm.c +++ b/epan/dissectors/packet-cfm.c @@ -50,6 +50,7 @@ #define LTR 0x04 #define LTM 0X05 +#define GNM 0x20 #define AIS 0x21 #define LCK 0x23 #define TST 0x25 @@ -77,9 +78,16 @@ #define REPLY_EGR_TLV 0x06 #define LTM_EGR_ID_TLV 0x07 #define LTR_EGR_ID_TLV 0x08 +#define GNM_TLV 0x0D #define ORG_SPEC_TLV 0x1F #define TEST_TLV 0x20 +/* Sub-OpCode for GNM */ +#define BNM 0x01 + +/* Offset for GNM Sub-OpCode*/ +#define CFM_GNM_SUBOPCODE 2 + /* Offsets of fields within CFM PDU */ #define CFM_VERSION 0 #define CFM_OPCODE 1 @@ -98,6 +106,7 @@ static const value_string opcodetypenames[] = { { LBM, "Loopback Message (LBM)" }, { LTR, "Linktrace Reply (LTR)" }, { LTM, "Linktrace Message (LTM)" }, + { GNM, "Generic Notification Message (GNM)" }, { AIS, "Alarm Indication Signal (AIS)" }, { LCK, "Lock Signal (LCK)" }, { TST, "Test Signal (TST)" }, @@ -172,6 +181,7 @@ static const value_string tlvtypefieldvalues[] = { { REPLY_EGR_TLV , "Reply Egress TLV" }, { LTM_EGR_ID_TLV , "LTM Egress Identifier TLV" }, { LTR_EGR_ID_TLV , "LTR Egress Identifier TLV" }, + { GNM_TLV , "Generic Notification Message TLV" }, { ORG_SPEC_TLV , "Organizational-Specific TLV" }, { TEST_TLV , "Test TLV" }, { 0 , NULL } @@ -286,6 +296,10 @@ static const true_false_string rapsbprvalues = { "Ring link 1", "Ring link 0" }; +static const value_string gnmsubopcodetypenames[] = { + { BNM, "Bandwidth Notification Message" }, + { 0, NULL } +}; static int hf_cfm_md_level = -1; @@ -338,6 +352,14 @@ static int hf_cfm_ltm_targ_addr = -1; static int hf_cfm_ltr_pdu = -1; static int hf_cfm_ltr_relay_action = -1; +static int hf_cfm_gnm_pdu = -1; +static int hf_cfm_gnm_subopcode = -1; + +static int hf_cfm_gnm_bnm_pdu = -1; +static int hf_cfm_gnm_bnm_nominal_bw = -1; +static int hf_cfm_gnm_bnm_current_bw = -1; +static int hf_cfm_gnm_bnm_port_id = -1; + static int hf_cfm_ais_pdu = -1; static int hf_cfm_flags_ais_lck_Reserved = -1; static int hf_cfm_flags_ais_lck_Period = -1; @@ -648,6 +670,58 @@ static int dissect_cfm_ltr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr return offset; } + +static int dissect_cfm_gnm_bnm(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset) +{ + proto_item *ti; + proto_tree *cfm_pdu_tree; + + ti = proto_tree_add_item(tree, hf_cfm_gnm_bnm_pdu, tvb, offset, -1, ENC_NA); + cfm_pdu_tree = proto_item_add_subtree(ti, ett_cfm_pdu); + + proto_tree_add_item(cfm_pdu_tree, hf_cfm_gnm_bnm_nominal_bw, tvb, offset, 4, ENC_BIG_ENDIAN); + offset += 4; + proto_tree_add_item(cfm_pdu_tree, hf_cfm_gnm_bnm_current_bw, tvb, offset, 4, ENC_BIG_ENDIAN); + offset += 4; + proto_tree_add_item(cfm_pdu_tree, hf_cfm_gnm_bnm_port_id, tvb, offset, 4, ENC_BIG_ENDIAN); + offset += 4; + + return offset; +} + +static int dissect_cfm_gnm(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset) +{ + proto_item *ti; + proto_item *fi; + proto_tree *cfm_pdu_tree; + proto_tree *cfm_flag_tree; + guint8 cfm_gnm_pdu_type; + + ti = proto_tree_add_item(tree, hf_cfm_gnm_pdu, tvb, offset, -1, ENC_NA); + cfm_pdu_tree = proto_item_add_subtree(ti, ett_cfm_pdu); + + fi = proto_tree_add_item(cfm_pdu_tree, hf_cfm_flags, tvb, offset, 1, ENC_BIG_ENDIAN); + cfm_flag_tree = proto_item_add_subtree(fi, ett_cfm_flags); + proto_tree_add_item(cfm_flag_tree, hf_cfm_flags_ais_lck_Reserved, tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(cfm_flag_tree, hf_cfm_flags_ais_lck_Period, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; + + proto_tree_add_item(cfm_pdu_tree, hf_cfm_first_tlv_offset, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; + + proto_tree_add_item(cfm_pdu_tree, hf_cfm_gnm_subopcode, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; + + cfm_gnm_pdu_type = tvb_get_guint8(tvb, offset -1); + switch(cfm_gnm_pdu_type) { + case BNM: + offset = dissect_cfm_gnm_bnm(tvb, pinfo, tree, offset); + break; + } + + return offset; +} + static int dissect_cfm_ais(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset) { proto_item *ti; @@ -1274,6 +1348,9 @@ static int dissect_cfm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void case LTR: offset = dissect_cfm_ltr(tvb, pinfo, tree, offset); break; + case GNM: + offset = dissect_cfm_gnm(tvb, pinfo, tree, offset); + break; case AIS: offset = dissect_cfm_ais(tvb, pinfo, tree, offset); break; @@ -1767,6 +1844,34 @@ void proto_register_cfm(void) BASE_DEC, VALS(aislckperiodtypes), 0x07, NULL, HFILL } }, + /* CFM GNM */ + { &hf_cfm_gnm_pdu, + { "CFM GNM PDU", "cfm.gnm.pdu", FT_NONE, + BASE_NONE, NULL, 0x0, NULL, HFILL } + }, + { &hf_cfm_gnm_subopcode, + { "Sub-OpCode", "cfm.gnm.subopcode", FT_UINT8, + BASE_HEX, VALS(gnmsubopcodetypenames), 0x0, NULL, HFILL } + }, + + /* CFM GNM BNM*/ + { &hf_cfm_gnm_bnm_pdu, + { "CFM GNM BNM PDU", "cfm.gnm.bnm.pdu", FT_NONE, + BASE_NONE, NULL, 0x0, NULL, HFILL } + }, + { &hf_cfm_gnm_bnm_nominal_bw, + { "Nominal Bandwidth", "cfm.gnm.bnm.nominal.bw", FT_UINT32, + BASE_DEC, NULL, 0x0, NULL, HFILL } + }, + { &hf_cfm_gnm_bnm_current_bw, + { "Current Bandwidth", "cfm.gnm.bnm.current.bw", FT_UINT32, + BASE_DEC, NULL, 0x0, NULL, HFILL } + }, + { &hf_cfm_gnm_bnm_port_id, + { "Port ID", "cfm.gnm.bnm.port.id", FT_UINT32, + BASE_DEC, NULL, 0x0, NULL, HFILL } + }, + /* CFM LCK */ { &hf_cfm_lck_pdu, { "CFM LCK PDU", "cfm.lck.pdu", FT_NONE, -- cgit v1.2.1