From Krishnamurthy Mayya:

Enhancement to support MPLS-TP FM and LI payloads as per RFC 6427 and RFC 6435

Fixed some errors found by checkapi, changed filter names to use
proto abbr.

svn path=/trunk/; revision=46084
This commit is contained in:
Anders Broman 2012-11-19 20:13:57 +00:00
parent 28474fe8ef
commit 1c22a075a8
6 changed files with 377 additions and 14 deletions

View File

@ -887,6 +887,7 @@ set(DISSECTOR_SRC
dissectors/packet-mpls-echo.c
dissectors/packet-mpls-pm.c
dissectors/packet-mpls-psc.c
dissectors/packet-mplstp-oam.c
dissectors/packet-mpls-y1711.c
dissectors/packet-mpls.c
dissectors/packet-mq-pcf.c

View File

@ -807,6 +807,7 @@ DISSECTOR_SRC = \
packet-mpls-echo.c \
packet-mpls-pm.c \
packet-mpls-psc.c \
packet-mplstp-oam.c \
packet-mpls-y1711.c \
packet-mpls.c \
packet-mq-pcf.c \

View File

@ -578,25 +578,41 @@ dissect_bfd_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
As per RFC 6428 : http://tools.ietf.org/html/rfc6428
sections - 3.5.1, 3.5.2, 3.5.3 */
void
dissect_bfd_mep (tvbuff_t *tvb, proto_tree *tree)
dissect_bfd_mep (tvbuff_t *tvb, proto_tree *tree, const int hfindex)
{
proto_item *ti;
proto_tree *bfd_tree;
gint offset;
gint mep_type;
gint mep_len;
gint mep_agi_len;
proto_item *ti = NULL;
proto_tree *bfd_tree = NULL;
gint offset = 0;
gint mep_type = 0;
gint mep_len = 0;
gint mep_agi_len = 0;
if (!tree)
return;
/* Fetch the BFD control message length and move the offset
to point to the data portion after the control message */
offset = tvb_get_guint8(tvb, 3);
mep_type = tvb_get_ntohs (tvb, offset);
mep_len = tvb_get_ntohs (tvb, (offset + 2));
ti = proto_tree_add_protocol_format (tree, proto_bfd, tvb, offset, (mep_len + 4),
"MPLS-TP SOURCE MEP-ID TLV");
/* The parameter hfindex is used for determining the tree under which MEP-ID TLV
has to be determined. Since according to RFC 6428, MEP-ID TLV can be used by any
OAM function, if hfindex is 0, as per this function the MEP-TLV is a part of
BFD-CV payload. If a non-zero hfindex comes, then tht TLV info will be displayed
under a particular protocol-tree. */
if (!hfindex)
{
offset = tvb_get_guint8(tvb, 3);
mep_type = tvb_get_ntohs (tvb, offset);
mep_len = tvb_get_ntohs (tvb, (offset + 2));
ti = proto_tree_add_protocol_format (tree, proto_bfd, tvb, offset, (mep_len + 4),
"MPLS-TP SOURCE MEP-ID TLV");
}
else
{
mep_type = tvb_get_ntohs (tvb, offset);
mep_len = tvb_get_ntohs (tvb, (offset + 2));
ti = proto_tree_add_protocol_format (tree, hfindex, tvb, offset, (mep_len + 4),
"MPLS-TP SOURCE MEP-ID TLV");
}
switch (mep_type) {
case TLV_TYPE_MPLSTP_SECTION_MEP:

View File

@ -24,6 +24,6 @@
#ifndef PACKET_BFD_H
#define PACKET_BFD_H
void dissect_bfd_mep (tvbuff_t *tvb, proto_tree *tree);
void dissect_bfd_mep (tvbuff_t *tvb, proto_tree *tree, const int hfindex);
#endif

View File

@ -23,6 +23,8 @@
* Nikitha Malgi <malgi.nikitha@ipinfusion.com>
* - Identification of BFD CC, BFD CV and ON-Demand CV ACH types as per RFC 6428, RFC 6426
* respectively and the corresponding decoding of messages
* - Decoding support for MPLS-TP Lock Instruct as per RFC 6435
* - Decoding support for MPLS-TP Fault-Management as per RFC 6427
*
* (c) Copyright 2012, Aditya Ambadkar and Diana Chris <arambadk,dvchris@ncsu.edu>
* - Added preference to select BOS label as flowlabel as per RFC 6391
@ -98,6 +100,8 @@ static dissector_handle_t dissector_mpls_pm_dm;
static dissector_handle_t dissector_mpls_pm_dlm_dm;
static dissector_handle_t dissector_mpls_pm_ilm_dm;
static dissector_handle_t dissector_mpls_psc;
static dissector_handle_t dissector_mplstp_lock;
static dissector_handle_t dissector_mplstp_fm;
static dissector_handle_t dissector_pw_eth_heuristic;
static dissector_handle_t dissector_pw_fr;
static dissector_handle_t dissector_pw_hdlc_nocw_fr;
@ -384,7 +388,7 @@ dissect_pw_ach(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
case ACH_TYPE_BFD_CV:
call_dissector(dissector_bfd, next_tvb, pinfo, tree); /* bfd_control() */
dissect_bfd_mep(next_tvb, tree);
dissect_bfd_mep(next_tvb, tree, 0);
break;
case ACH_TYPE_ONDEMAND_CV:
@ -427,6 +431,14 @@ dissect_pw_ach(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
call_dissector(dissector_mpls_psc, next_tvb, pinfo, tree);
break;
case 0x0026: /* KM: MPLSTP LOCK, RFC 6435 */
call_dissector(dissector_mplstp_lock, next_tvb, pinfo, tree);
break;
case 0x0058: /* KM: MPLSTP FM, RFC 6427 */
call_dissector(dissector_mplstp_fm, next_tvb, pinfo, tree);
break;
default:
call_dissector(dissector_data, next_tvb, pinfo, tree);
break;
@ -797,6 +809,8 @@ proto_reg_handoff_mpls(void)
dissector_mpls_pm_dlm_dm = find_dissector("mpls_pm_dlm_dm");
dissector_mpls_pm_ilm_dm = find_dissector("mpls_pm_ilm_dm");
dissector_mpls_psc = find_dissector("mpls_psc");
dissector_mplstp_lock = find_dissector("mplstp_lock");
dissector_mplstp_fm = find_dissector("mplstp_fm");
dissector_pw_eth_heuristic = find_dissector("pw_eth_heuristic");
dissector_pw_fr = find_dissector("pw_fr");
dissector_pw_hdlc_nocw_fr = find_dissector("pw_hdlc_nocw_fr");

View File

@ -0,0 +1,331 @@
/* packet-mplstp-oam.c
*
* $Id$
* Routines for MPLS-TP Lock Instruct Protocol : RFC 6435
* MPLS-TP Fault-Management Protocol : RFC 6427
*
* Authors:
* Krishnamurthy Mayya <krishnamurthymayya@gmail.com>
* Nikitha Malgi <nikitha01@gmail.com>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include <glib.h>
#include <epan/packet.h>
#include <packet-ip.h>
#include <epan/dissectors/packet-bfd.h>
/* MPLS-TP FM protocol specific variables */
static gint proto_mplstp_fm = -1;
static gint ett_mplstp_fm = -1;
static gint ett_mplstp_fm_flags = -1;
static gint ett_mplstp_fm_tlv_tree = -1;
static int hf_mplstp_fm_version = -1;
static int hf_mplstp_fm_reserved = -1;
static int hf_mplstp_fm_msg_type = -1;
static int hf_mplstp_fm_flags = -1;
static int hf_mplstp_fm_flags_l = -1;
static int hf_mplstp_fm_flags_r = -1;
static int hf_mplstp_fm_refresh_timer = -1;
static int hf_mplstp_fm_total_tlv_len = -1;
static int hf_mplstp_fm_if_tlv_type = -1;
static int hf_mplstp_fm_global_tlv_type = -1;
static int hf_mplstp_fm_tlv_len = -1;
static int hf_mplstp_fm_node_id = -1;
static int hf_mplstp_fm_if_num = -1;
static int hf_mplstp_fm_global_id = -1;
static const value_string fm_msg_type[] = {
{0, "No Return Code"},
{1, "Alarm-Indication Signal(A)"},
{2, "Lock-Report(L)"},
{0, NULL}
};
/* MPLS-TP Lock protocol specific variables */
static gint proto_mplstp_lock = -1;
static gint ett_mplstp_lock = -1;
static int hf_mplstp_lock_version = -1;
static int hf_mplstp_lock_reserved = -1;
static int hf_mplstp_lock_refresh_timer = -1;
void
dissect_mplstp_fm_tlv (tvbuff_t *tvb, proto_tree *tree)
{
proto_item *ti = NULL;
proto_tree *fm_tlv_tree = NULL;
guint offset = 0;
ti = proto_tree_add_protocol_format (tree, proto_mplstp_fm, tvb, offset, 16,
"Fault-Management TLVs");
if (!tree)
return;
fm_tlv_tree = proto_item_add_subtree (ti, ett_mplstp_fm_tlv_tree);
proto_tree_add_item (fm_tlv_tree, hf_mplstp_fm_if_tlv_type , tvb, offset,
1, ENC_BIG_ENDIAN);
offset = offset + 1;
proto_tree_add_item (fm_tlv_tree, hf_mplstp_fm_tlv_len, tvb, offset,
1, ENC_BIG_ENDIAN);
offset = offset + 1;
proto_tree_add_item (fm_tlv_tree, hf_mplstp_fm_node_id, tvb, offset,
4, ENC_BIG_ENDIAN);
offset = offset + 4;
proto_tree_add_item (fm_tlv_tree, hf_mplstp_fm_if_num, tvb, offset,
4, ENC_BIG_ENDIAN);
offset = offset + 4;
proto_tree_add_item (fm_tlv_tree, hf_mplstp_fm_global_tlv_type , tvb, offset,
1, ENC_BIG_ENDIAN);
offset = offset + 1;
proto_tree_add_item (fm_tlv_tree, hf_mplstp_fm_tlv_len, tvb, offset,
1, ENC_BIG_ENDIAN);
offset = offset + 1;
proto_tree_add_item (fm_tlv_tree, hf_mplstp_fm_global_id, tvb, offset,
4, ENC_BIG_ENDIAN);
offset = offset + 4;
return ;
}
/* Dissector for MPLS-TP LI protocol: RFC 6435 */
static void
dissect_mplstp_lock(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *ti = NULL;
proto_tree *lock_tree = NULL;
tvbuff_t *next_tvb = NULL;
guint8 offset = 0;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "MPLS-TP LI");
col_clear(pinfo->cinfo, COL_INFO);
if (!tree)
return;
ti = proto_tree_add_item(tree, proto_mplstp_lock, tvb, 0, -1, ENC_NA);
lock_tree = proto_item_add_subtree (ti, ett_mplstp_lock);
/* Version field */
proto_tree_add_item (lock_tree, hf_mplstp_lock_version , tvb, offset,
1, ENC_BIG_ENDIAN);
/* Reserved field */
proto_tree_add_item (lock_tree, hf_mplstp_lock_reserved, tvb, offset,
3, ENC_BIG_ENDIAN);
offset = offset + 3;
/* Refresh-Timer field */
proto_tree_add_item (lock_tree, hf_mplstp_lock_refresh_timer, tvb, offset,
1, ENC_BIG_ENDIAN);
offset = offset + 1;
/*Source-MEP TLVs */
next_tvb = tvb_new_subset_remaining (tvb, offset);
dissect_bfd_mep (next_tvb, tree, proto_mplstp_lock);
return;
}
/* Dissector for MPLS-TP FM protocol: RFC 6427 */
static void
dissect_mplstp_fm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *ti = NULL, *ti_flags = NULL;
proto_tree *fm_tree = NULL, *fm_flags = NULL;
tvbuff_t *next_tvb = NULL;
guint8 offset = 0;
guint8 tlv_len = 0;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "MPLS-TP FM");
col_clear(pinfo->cinfo, COL_INFO);
tlv_len = tvb_get_guint8 (tvb, (offset + 4));
if (!tree)
return;
ti = proto_tree_add_item(tree, proto_mplstp_fm, tvb, 0, (tlv_len + 5), ENC_NA);
fm_tree = proto_item_add_subtree (ti, ett_mplstp_fm);
/* Version and Reserved fields */
proto_tree_add_item (fm_tree, hf_mplstp_fm_version , tvb, offset,
1, ENC_BIG_ENDIAN);
proto_tree_add_item (fm_tree, hf_mplstp_fm_reserved, tvb, offset,
1, ENC_BIG_ENDIAN);
offset = offset + 1;
/* FM-Message type field */
proto_tree_add_item (fm_tree, hf_mplstp_fm_msg_type, tvb, offset,
1,ENC_BIG_ENDIAN);
offset = offset + 1;
/* Flags field */
ti_flags = proto_tree_add_item (fm_tree, hf_mplstp_fm_flags, tvb,
offset, 1, ENC_BIG_ENDIAN);
fm_flags = proto_item_add_subtree(ti_flags, ett_mplstp_fm_flags);
proto_tree_add_item (fm_flags, hf_mplstp_fm_flags_l, tvb, offset, 1, FALSE);
proto_tree_add_item (fm_flags, hf_mplstp_fm_flags_r, tvb, offset, 1, FALSE);
offset = offset + 1;
/* Refresh-Timer field */
proto_tree_add_item (fm_tree, hf_mplstp_fm_refresh_timer, tvb, offset,
1, ENC_BIG_ENDIAN);
offset = offset + 1;
/* FM-TLV Length field*/
proto_tree_add_item (fm_tree, hf_mplstp_fm_total_tlv_len, tvb, offset,
1, ENC_BIG_ENDIAN);
offset = offset + 1;
if (tlv_len != 0)
{
/* FM TLVs*/
next_tvb = tvb_new_subset_remaining (tvb, offset);
dissect_mplstp_fm_tlv (next_tvb, tree);
}
return;
}
void
proto_register_mplstp_lock(void)
{
static hf_register_info hf[] = {
{&hf_mplstp_lock_version,
{"Version", "mplstp_lock.version", FT_UINT8,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_lock_reserved,
{"Reserved", "mplstp_lock.reserved", FT_UINT24,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_lock_refresh_timer,
{"Refresh-timer value", "mplstp_lock.refresh-timer", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
};
static gint *ett[] = {
&ett_mplstp_lock,
};
proto_mplstp_lock =
proto_register_protocol("MPLS-TP Lock-Instruct", "MPLS[-TP] Lock-Instruct "
"Lock-Instruct (LI) Protocol",
"mplstp_lock");
proto_register_field_array(proto_mplstp_lock, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_dissector("mplstp_lock", dissect_mplstp_lock, proto_mplstp_lock);
}
void
proto_register_mplstp_fm(void)
{
static hf_register_info hf[] = {
{&hf_mplstp_fm_version,
{"Version", "mplstp_oam.version", FT_UINT8,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_reserved,
{"Reserved", "mplstp_oam.reserved", FT_UINT8,
BASE_HEX, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_refresh_timer,
{"Refresh-timer value", "mplstp_oam.refresh.timer", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_total_tlv_len,
{"FM TLV Length", "mplstp_oam.total.tlv.len", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_if_tlv_type,
{"Type : IF-ID TLV", "mplstp_oam.if_id_tlv_type", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_global_tlv_type,
{"Type : GLOBAL-ID TLV", "mplstp_oam.global_id_tlv_type", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_tlv_len,
{"Length", "mplstp_oam.tlv_len", FT_UINT8,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_node_id,
{"Node id", "mplstp_oam.node_id", FT_IPv4,
BASE_NONE, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_if_num,
{"Interface Number", "mplstp_oam.if_num", FT_UINT32,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_global_id,
{"Global id", "mplstp_oam.global_id", FT_UINT32,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
{&hf_mplstp_fm_msg_type,
{"Message Type", "mplstp_oam.message.type", FT_UINT8,
BASE_DEC, VALS(fm_msg_type), 0x0, "MPLS-TP FM Message Type", HFILL }},
{ &hf_mplstp_fm_flags,
{ "FM Flags", "mplstp_oam.flags",
FT_UINT8, BASE_HEX, NULL, 0x0000, "MPLS-TP FM Flags", HFILL}
},
{ &hf_mplstp_fm_flags_l,
{ "Link Down Indication", "mplstp_oam.flag_l",
FT_BOOLEAN, 8, NULL, 0x0002, NULL, HFILL}
},
{ &hf_mplstp_fm_flags_r,
{ "FM Condition Cleared", "mplstp_oam.flag_r",
FT_BOOLEAN, 8, NULL, 0x0001, "Fault Condition Cleared", HFILL}
},
};
static gint *ett[] = {
&ett_mplstp_fm,
&ett_mplstp_fm_tlv_tree,
&ett_mplstp_fm_flags,
};
proto_mplstp_fm =
proto_register_protocol("MPLS-TP Fault-Management", "MPLS[-TP] Fault-Management "
"Fault-Management (FM) Protocol",
"mplstp_fm");
proto_register_field_array(proto_mplstp_fm, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_dissector("mplstp_fm", dissect_mplstp_fm, proto_mplstp_fm);
}