2010-04-27 00:06:35 +00:00
|
|
|
/* packet-trill.c
|
|
|
|
* Routines for TRILL (TRansparent Interconnection of Lots of Links) dissection
|
|
|
|
* Copyright 2010, David Bond <mokon@mokon.net>
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* 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-1335 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See: http://tools.ietf.org/html/draft-ietf-trill-rbridge-protocol-16
|
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2010-04-27 00:06:35 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <epan/packet.h>
|
2010-06-02 19:29:14 +00:00
|
|
|
#include <epan/etypes.h>
|
2010-04-27 00:06:35 +00:00
|
|
|
|
|
|
|
static int proto_trill = -1 ;
|
|
|
|
static gint ett_trill = -1 ;
|
|
|
|
|
|
|
|
static int hf_trill_version = -1 ;
|
|
|
|
static int hf_trill_reserved = -1 ;
|
|
|
|
static int hf_trill_multi_dst = -1 ;
|
|
|
|
static int hf_trill_op_len = -1 ;
|
|
|
|
static int hf_trill_hop_cnt = -1 ;
|
|
|
|
static int hf_trill_egress_nick = -1 ;
|
|
|
|
static int hf_trill_ingress_nick = -1 ;
|
|
|
|
/* TODO For now we will just add all the options into a byte field.
|
|
|
|
Later this should be parsed out into a sub-tree with all the option
|
|
|
|
details. */
|
2011-10-21 02:10:19 +00:00
|
|
|
static int hf_trill_options= -1 ;
|
2010-04-27 00:06:35 +00:00
|
|
|
|
|
|
|
static dissector_handle_t eth_dissector ;
|
|
|
|
|
2012-03-06 16:58:09 +00:00
|
|
|
#define TRILL_VERSION_MASK 0xC000
|
|
|
|
#define TRILL_RESERVED_MASK 0x3000
|
2010-04-27 00:06:35 +00:00
|
|
|
#define TRILL_MULTI_DST_MASK 0x0800
|
2012-03-06 16:58:09 +00:00
|
|
|
#define TRILL_OP_LEN_MASK 0x07C0
|
|
|
|
#define TRILL_HOP_CNT_MASK 0x003F
|
2010-04-27 00:06:35 +00:00
|
|
|
|
|
|
|
#define TRILL_PROTO_COL_NAME "TRILL"
|
|
|
|
#define TRILL_PROTO_COL_INFO "TRILL Encapsulated Frame"
|
|
|
|
|
2012-03-06 16:58:09 +00:00
|
|
|
#define TRILL_MIN_FRAME_LENGTH 6
|
|
|
|
#define TRILL_BIT_FIELDS_LEN 2
|
|
|
|
#define TRILL_NICKNAME_LEN 2
|
2010-04-27 00:06:35 +00:00
|
|
|
#define TRILL_OP_LENGTH_BYTE_UNITS 0x4
|
|
|
|
|
|
|
|
static const true_false_string multi_dst_strings = {
|
|
|
|
"Multi-Destination TRILL Frame",
|
|
|
|
"Known Unicast TRILL Frame"
|
|
|
|
} ;
|
|
|
|
|
|
|
|
static const range_string version_strings[] = {
|
|
|
|
{ 0, 0, "draft-ietf-trill-rbridge-protocol-16 Version" },
|
|
|
|
{ 1, 3, "Unallocated Version" },
|
|
|
|
{ 0, 0, NULL }
|
|
|
|
} ;
|
|
|
|
|
|
|
|
static const range_string reserved_strings[] = {
|
|
|
|
{ 0, 0, "Legal Value" },
|
|
|
|
{ 1, 3, "Illegal Value" },
|
|
|
|
{ 0, 0, NULL }
|
|
|
|
} ;
|
|
|
|
|
|
|
|
static const range_string nickname_strings[] = {
|
|
|
|
{ 0x0000, 0x0000, "Nickname Not Specified" },
|
|
|
|
{ 0x0001, 0xFFBF, "Valid Nickname" },
|
|
|
|
{ 0xFFC0, 0xFFFE, "Reserved for Future Specification" },
|
|
|
|
{ 0xFFFF, 0xFFFF, "Permanently Reserved" },
|
|
|
|
{ 0, 0, NULL }
|
|
|
|
} ;
|
|
|
|
|
|
|
|
/* Trill Dissector */
|
|
|
|
static int
|
2012-09-10 21:40:21 +00:00
|
|
|
dissect_trill( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ )
|
2010-04-27 00:06:35 +00:00
|
|
|
{
|
|
|
|
proto_item *ti ;
|
|
|
|
proto_tree *trill_tree ;
|
2012-03-06 16:58:09 +00:00
|
|
|
guint32 op_len ;
|
|
|
|
tvbuff_t *next_tvb ;
|
|
|
|
int offset = 0 ;
|
2010-04-27 00:06:35 +00:00
|
|
|
|
|
|
|
col_set_str( pinfo->cinfo, COL_PROTOCOL, TRILL_PROTO_COL_NAME ) ;
|
|
|
|
col_set_str( pinfo->cinfo, COL_INFO, TRILL_PROTO_COL_INFO ) ;
|
|
|
|
|
2011-10-24 19:57:53 +00:00
|
|
|
op_len = tvb_get_bits( tvb, 5, 5, ENC_BIG_ENDIAN ) * TRILL_OP_LENGTH_BYTE_UNITS ;
|
2010-04-27 00:06:35 +00:00
|
|
|
if (tree) {
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item( tree, proto_trill, tvb, 0, -1, ENC_NA ) ;
|
2010-04-27 00:06:35 +00:00
|
|
|
trill_tree = proto_item_add_subtree( ti, ett_trill ) ;
|
|
|
|
|
|
|
|
/* Parse the bit fields, i.e. V, R, M, Op-Length, Hop Count. */
|
|
|
|
proto_tree_add_item( trill_tree, hf_trill_version, tvb, offset,
|
2011-10-06 03:35:44 +00:00
|
|
|
TRILL_BIT_FIELDS_LEN, ENC_BIG_ENDIAN ) ;
|
2010-04-27 00:06:35 +00:00
|
|
|
proto_tree_add_item( trill_tree, hf_trill_reserved, tvb, offset,
|
2011-10-06 03:35:44 +00:00
|
|
|
TRILL_BIT_FIELDS_LEN, ENC_BIG_ENDIAN ) ;
|
2010-04-27 00:06:35 +00:00
|
|
|
proto_tree_add_item( trill_tree, hf_trill_multi_dst, tvb, offset,
|
2011-10-10 00:39:31 +00:00
|
|
|
TRILL_BIT_FIELDS_LEN, ENC_BIG_ENDIAN ) ;
|
2010-04-27 00:06:35 +00:00
|
|
|
proto_tree_add_item( trill_tree, hf_trill_op_len, tvb, offset,
|
2011-10-21 02:10:19 +00:00
|
|
|
TRILL_BIT_FIELDS_LEN, ENC_BIG_ENDIAN ) ;
|
2010-04-27 00:06:35 +00:00
|
|
|
proto_tree_add_item( trill_tree, hf_trill_hop_cnt, tvb, offset,
|
2011-10-06 03:35:44 +00:00
|
|
|
TRILL_BIT_FIELDS_LEN, ENC_BIG_ENDIAN ) ;
|
2010-04-27 00:06:35 +00:00
|
|
|
|
|
|
|
/* Parse the egress nickname. */
|
|
|
|
offset += TRILL_BIT_FIELDS_LEN ;
|
|
|
|
proto_tree_add_item( trill_tree, hf_trill_egress_nick, tvb, offset,
|
2011-10-06 03:35:44 +00:00
|
|
|
TRILL_NICKNAME_LEN, ENC_BIG_ENDIAN ) ;
|
2010-04-27 00:06:35 +00:00
|
|
|
|
|
|
|
/* Parse the ingress nickname. */
|
|
|
|
offset += TRILL_NICKNAME_LEN ;
|
|
|
|
proto_tree_add_item( trill_tree, hf_trill_ingress_nick, tvb, offset,
|
2011-10-06 03:35:44 +00:00
|
|
|
TRILL_NICKNAME_LEN , ENC_BIG_ENDIAN ) ;
|
2010-04-27 00:06:35 +00:00
|
|
|
|
|
|
|
/* Parse the options field. */
|
|
|
|
offset += TRILL_NICKNAME_LEN ;
|
2011-10-21 02:10:19 +00:00
|
|
|
if( op_len != 0 ) {
|
2010-04-27 00:06:35 +00:00
|
|
|
proto_tree_add_item( trill_tree, hf_trill_options, tvb,
|
2011-10-04 22:44:31 +00:00
|
|
|
offset, op_len, ENC_NA ) ;
|
2010-04-27 00:06:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* call the eth dissector */
|
2012-03-06 16:58:09 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining( tvb, TRILL_MIN_FRAME_LENGTH + op_len ) ;
|
2010-04-27 00:06:35 +00:00
|
|
|
call_dissector( eth_dissector, next_tvb, pinfo, tree ) ;
|
|
|
|
|
|
|
|
return tvb_length( tvb ) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Register the protocol with Wireshark */
|
|
|
|
void
|
|
|
|
proto_register_trill(void)
|
2011-10-21 02:10:19 +00:00
|
|
|
{
|
2010-04-27 00:06:35 +00:00
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_trill_version,
|
|
|
|
{ "Version", "trill.version",
|
|
|
|
FT_UINT16, BASE_DEC_HEX|BASE_RANGE_STRING, RVALS(version_strings),
|
|
|
|
TRILL_VERSION_MASK, "The TRILL version number.", HFILL }},
|
|
|
|
{ &hf_trill_reserved,
|
|
|
|
{ "Reserved", "trill.reserved",
|
|
|
|
FT_UINT16, BASE_DEC_HEX|BASE_RANGE_STRING, RVALS(reserved_strings),
|
|
|
|
TRILL_RESERVED_MASK, "Bits reserved for future specification.", HFILL }},
|
|
|
|
{ &hf_trill_multi_dst,
|
|
|
|
{ "Multi Destination", "trill.multi_dst",
|
|
|
|
FT_BOOLEAN, 16, TFS(&multi_dst_strings), TRILL_MULTI_DST_MASK,
|
|
|
|
"A boolean specifying if this is a multi-destination frame.", HFILL }},
|
|
|
|
{ &hf_trill_op_len,
|
|
|
|
{ "Option Length", "trill.op_len",
|
|
|
|
FT_UINT16, BASE_DEC_HEX, NULL, TRILL_OP_LEN_MASK,
|
|
|
|
"The length of the options field of this frame.", HFILL }},
|
|
|
|
{ &hf_trill_hop_cnt,
|
|
|
|
{ "Hop Count", "trill.hop_cnt",
|
|
|
|
FT_UINT16, BASE_DEC_HEX, NULL, TRILL_HOP_CNT_MASK,
|
|
|
|
"The remaining hop count for this frame.", HFILL }},
|
|
|
|
{ &hf_trill_egress_nick,
|
|
|
|
{ "Egress/Root RBridge Nickname", "trill.egress_nick",
|
|
|
|
FT_UINT16, BASE_DEC_HEX|BASE_RANGE_STRING, RVALS(nickname_strings), 0x0,
|
|
|
|
"The Egress or Distribution Tree Root RBridge Nickname.", HFILL }},
|
|
|
|
{ &hf_trill_ingress_nick,
|
|
|
|
{ "Ingress RBridge Nickname", "trill.ingress_nick",
|
|
|
|
FT_UINT16, BASE_DEC_HEX|BASE_RANGE_STRING, RVALS(nickname_strings), 0x0,
|
|
|
|
"The Ingress RBridge Nickname.", HFILL }},
|
|
|
|
{ &hf_trill_options,
|
|
|
|
{ "Options", "trill.options",
|
|
|
|
FT_BYTES, BASE_NONE, NULL, 0x0,
|
|
|
|
"The TRILL Options field.", HFILL }}
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_trill
|
|
|
|
};
|
|
|
|
|
|
|
|
proto_trill = proto_register_protocol("TRILL", "TRILL", "trill");
|
|
|
|
proto_register_field_array(proto_trill, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_trill(void)
|
|
|
|
{
|
|
|
|
dissector_handle_t trill_handle;
|
|
|
|
|
|
|
|
trill_handle = new_create_dissector_handle(dissect_trill, proto_trill);
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("ethertype", ETHERTYPE_TRILL, trill_handle);
|
2010-04-27 00:06:35 +00:00
|
|
|
|
|
|
|
eth_dissector = find_dissector( "eth" ) ;
|
|
|
|
}
|
|
|
|
|