2009-03-03 20:07:38 +00:00
|
|
|
/* packet-pw-hdlc.c
|
|
|
|
* Routines for HDLC PW dissection as per RFC4618.
|
|
|
|
* Copyright 2009, Dmitry Trebich, Artem Tamazov <artem.tamazov@tellabs.com>
|
|
|
|
*
|
|
|
|
* $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
|
2012-06-28 23:18:38 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2009-03-03 20:07:38 +00:00
|
|
|
*
|
|
|
|
* History:
|
|
|
|
* ---------------------------------
|
|
|
|
* 02.03.2009 Initial implementation, supports:
|
|
|
|
* - HDLC mode (rfc4618 5.1), no CW, payload is PPP (PPP in HDLC-like Framing (rfc1662)).
|
2011-10-21 02:10:19 +00:00
|
|
|
* - FR port mode (rfc4618 5.2), no CW.
|
2009-03-03 20:07:38 +00:00
|
|
|
*
|
|
|
|
* [informative: Not supported yet:
|
|
|
|
* - All kinds of HDLC PW with CW.
|
|
|
|
* - PPP mode (rfc4618 5.3).
|
|
|
|
* - For HDLC mode, decoding payloads other than PPP.]
|
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2009-03-03 20:07:38 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
2012-05-15 19:23:35 +00:00
|
|
|
|
2009-03-03 20:07:38 +00:00
|
|
|
#include <epan/packet.h>
|
|
|
|
|
|
|
|
#include "packet-mpls.h"
|
|
|
|
|
2009-03-05 04:04:38 +00:00
|
|
|
static dissector_handle_t ppp_handle;
|
|
|
|
static dissector_handle_t fr_handle;
|
|
|
|
|
2009-03-03 20:07:38 +00:00
|
|
|
static gint proto_pw_hdlc_nocw_fr = -1;
|
|
|
|
static gint proto_pw_hdlc_nocw_hdlc_ppp = -1;
|
|
|
|
|
|
|
|
static gint ett_pw_hdlc = -1;
|
|
|
|
|
2013-01-26 18:54:53 +00:00
|
|
|
/* static int hf_pw_hdlc = -1; */
|
2009-03-03 20:07:38 +00:00
|
|
|
static int hf_pw_hdlc_address_field = -1;
|
|
|
|
static int hf_pw_hdlc_address = -1;
|
|
|
|
static int hf_pw_hdlc_cr_bit = -1;
|
|
|
|
static int hf_pw_hdlc_control_field = -1;
|
|
|
|
static int hf_pw_hdlc_pf_bit = -1;
|
|
|
|
|
|
|
|
static void dissect_pw_hdlc_nocw_fr( tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree )
|
|
|
|
{
|
2009-03-05 04:04:38 +00:00
|
|
|
call_dissector( fr_handle, tvb, pinfo, tree );
|
2009-03-03 20:07:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void dissect_pw_hdlc_nocw_hdlc_ppp( tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree )
|
|
|
|
{
|
|
|
|
if (tvb_reported_length_remaining(tvb, 0) < 2)
|
|
|
|
{
|
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
proto_tree_add_text(tree, tvb, 0, -1, "Error processing message");
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
proto_tree *tr;
|
|
|
|
proto_item *item;
|
|
|
|
proto_item *item_address;
|
|
|
|
proto_item *item_control;
|
2010-01-19 00:37:39 +00:00
|
|
|
guint8 addr;
|
2009-03-03 20:07:38 +00:00
|
|
|
guint8 control;
|
|
|
|
|
2010-01-19 00:37:39 +00:00
|
|
|
addr = tvb_get_guint8(tvb, 0);
|
2009-03-03 20:07:38 +00:00
|
|
|
control = tvb_get_guint8(tvb, 1);
|
|
|
|
|
2011-10-21 02:10:19 +00:00
|
|
|
item = proto_tree_add_item( tree, proto_pw_hdlc_nocw_hdlc_ppp, tvb, 0, 2, ENC_NA );
|
2009-03-03 20:07:38 +00:00
|
|
|
|
|
|
|
tr = proto_item_add_subtree( item, ett_pw_hdlc );
|
|
|
|
|
2010-01-19 00:37:39 +00:00
|
|
|
item_address = proto_tree_add_uint( tr, hf_pw_hdlc_address_field, tvb, 0, 1, addr );
|
2009-03-03 20:07:38 +00:00
|
|
|
item_control = proto_tree_add_uint_format( tr, hf_pw_hdlc_control_field, tvb, 1, 1, control, "Control field: 0x%x", control );
|
|
|
|
|
|
|
|
tr = proto_item_add_subtree( item_address, ett_pw_hdlc );
|
|
|
|
|
2010-01-19 00:37:39 +00:00
|
|
|
if ( 0x3F == (( addr & 0xFC ) >> 2 ))
|
2009-03-03 20:07:38 +00:00
|
|
|
proto_tree_add_uint_format( tr, hf_pw_hdlc_address, tvb, 0, 1, 0xFC, "Address: 0x%x (All stations)", 0x3F );
|
|
|
|
else
|
2010-01-19 00:37:39 +00:00
|
|
|
proto_tree_add_uint( tr, hf_pw_hdlc_address, tvb, 0, 1, ( addr & 0xFC ) >> 2 );
|
2009-03-03 20:07:38 +00:00
|
|
|
|
2010-01-19 00:37:39 +00:00
|
|
|
proto_tree_add_uint( tr, hf_pw_hdlc_cr_bit, tvb, 0, 1, ( addr & 2 ) >> 1 );
|
2009-03-03 20:07:38 +00:00
|
|
|
|
|
|
|
tr = proto_item_add_subtree( item_control, ett_pw_hdlc );
|
|
|
|
|
|
|
|
if ( control & 1 )
|
|
|
|
{
|
|
|
|
if ( control & 2 )
|
|
|
|
{
|
|
|
|
guint8 modifier2;
|
|
|
|
guint8 modifier3;
|
|
|
|
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1, "U frame" );
|
|
|
|
|
|
|
|
proto_tree_add_uint( tr, hf_pw_hdlc_pf_bit, tvb, 1, 1, ( control & 0x10 ) >> 4 );
|
|
|
|
|
|
|
|
modifier2 = (( control & 0xC ) >> 2 );
|
|
|
|
modifier3 = (( control & 0xE0 ) >> 5 );
|
|
|
|
|
|
|
|
/**/ if ( modifier2 == 0 && modifier3 == 0 )
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1,
|
|
|
|
"Modifier: UI - Unnumbered information" );
|
|
|
|
else if ( modifier2 == 0 && modifier3 == 1 )
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1,
|
|
|
|
"Modifier: UP - Unnumbered poll" );
|
|
|
|
else if ( modifier2 == 0 && modifier3 == 2 )
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1,
|
|
|
|
"Modifier: DISC/RD - Disconnect/Request disconnect" );
|
|
|
|
else if ( modifier2 == 0 && modifier3 == 3 )
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1,
|
|
|
|
"Modifier: UA - Unnumbered acknowledgment" );
|
|
|
|
else if ( modifier2 == 0 && modifier3 == 4 )
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1,
|
|
|
|
"Modifier: SNRM - Set normal response mode" );
|
|
|
|
else if ( modifier2 == 0 && modifier3 == 7 )
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1,
|
|
|
|
"Modifier: TEST - Test" );
|
|
|
|
else if ( modifier2 == 1 && modifier3 == 0 )
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1,
|
|
|
|
"Modifier: SIM/RIM"
|
|
|
|
" - Set initialization mode/Request initialization mode" );
|
|
|
|
else if ( modifier2 == 1 && modifier3 == 4 )
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1,
|
|
|
|
"Modifier: FRMR - Frame reject" );
|
|
|
|
else if ( modifier2 == 3 && modifier3 == 0 )
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1,
|
|
|
|
"Modifier: SARM/DM"
|
|
|
|
" - Set asynchronous response mode/Disconnect mode" );
|
|
|
|
else if ( modifier2 == 3 && modifier3 == 1 )
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1,
|
|
|
|
"Modifier: SABM - Set asynchronous balanced mode" );
|
|
|
|
else if ( modifier2 == 3 && modifier3 == 2 )
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1,
|
|
|
|
"Modifier: SARME - Set asynchronous response extended mode" );
|
|
|
|
else if ( modifier2 == 3 && modifier3 == 3 )
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1,
|
|
|
|
"Modifier: SABME - Set asynchronous balanced extended mode" );
|
|
|
|
else if ( modifier2 == 3 && modifier3 == 4 )
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1,
|
|
|
|
"Modifier: RSET - Reset" );
|
|
|
|
else if ( modifier2 == 3 && modifier3 == 5 )
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1,
|
|
|
|
"Modifier: XID - Exchange identification" );
|
|
|
|
else if ( modifier2 == 3 && modifier3 == 6 )
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1,
|
|
|
|
"Modifier: SNRME - Set normal response extended mode" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1, "S frame" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
proto_tree_add_text( tr, tvb, 1, 1, "I frame" );
|
|
|
|
}
|
|
|
|
}
|
2009-08-16 12:36:22 +00:00
|
|
|
call_dissector( ppp_handle, tvb_new_subset_remaining(tvb, 2), pinfo, tree );
|
2009-03-03 20:07:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void proto_register_pw_hdlc(void)
|
|
|
|
{
|
2009-03-05 04:04:38 +00:00
|
|
|
static hf_register_info hf[] = {
|
2013-01-31 18:31:28 +00:00
|
|
|
#if 0
|
2009-03-05 04:04:38 +00:00
|
|
|
{
|
|
|
|
&hf_pw_hdlc,
|
|
|
|
{
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
"PW HDLC", "pw_hdlc", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL
|
2009-03-05 04:04:38 +00:00
|
|
|
}
|
|
|
|
},
|
2013-01-31 18:31:28 +00:00
|
|
|
#endif
|
2009-03-05 04:04:38 +00:00
|
|
|
{
|
|
|
|
&hf_pw_hdlc_address_field,
|
|
|
|
{
|
|
|
|
"Address field", "pw_hdlc.address_field",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_pw_hdlc_address,
|
|
|
|
{
|
|
|
|
"Address", "pw_hdlc.address",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_pw_hdlc_cr_bit,
|
|
|
|
{
|
|
|
|
"C/R bit", "pw_hdlc.cr_bit",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_pw_hdlc_control_field,
|
|
|
|
{
|
|
|
|
"Control field", "pw_hdlc.control_field",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
&hf_pw_hdlc_pf_bit,
|
|
|
|
{
|
|
|
|
"Poll/Final bit", "pw_hdlc.pf_bit",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_pw_hdlc
|
|
|
|
};
|
|
|
|
|
2009-03-03 20:07:38 +00:00
|
|
|
proto_pw_hdlc_nocw_fr = proto_register_protocol("HDLC PW, FR port mode (no CW)", /*not displayed*/
|
|
|
|
"HDLC PW, FR port mode (no CW)",
|
|
|
|
"pw_hdlc_nocw_fr" );
|
|
|
|
proto_pw_hdlc_nocw_hdlc_ppp = proto_register_protocol("HDLC-like framing for PPP",
|
|
|
|
"HDLC PW with PPP payload (no CW)",
|
|
|
|
"pw_hdlc_nocw_hdlc_ppp" );
|
|
|
|
|
|
|
|
proto_register_field_array(proto_pw_hdlc_nocw_fr, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
|
|
|
|
register_dissector("pw_hdlc_nocw_fr", dissect_pw_hdlc_nocw_fr, proto_pw_hdlc_nocw_fr );
|
|
|
|
register_dissector("pw_hdlc_nocw_hdlc_ppp", dissect_pw_hdlc_nocw_hdlc_ppp, proto_pw_hdlc_nocw_hdlc_ppp );
|
|
|
|
}
|
|
|
|
|
|
|
|
void proto_reg_handoff_pw_hdlc(void)
|
|
|
|
{
|
2009-03-05 04:04:38 +00:00
|
|
|
dissector_handle_t handle;
|
2009-03-03 20:07:38 +00:00
|
|
|
|
2009-03-05 04:04:38 +00:00
|
|
|
handle = find_dissector("pw_hdlc_nocw_fr");
|
2012-09-28 19:50:49 +00:00
|
|
|
dissector_add_uint( "mpls.label", MPLS_LABEL_INVALID, handle );
|
2009-03-03 20:07:38 +00:00
|
|
|
|
2009-03-05 04:04:38 +00:00
|
|
|
handle = find_dissector("pw_hdlc_nocw_hdlc_ppp");
|
2012-09-28 19:50:49 +00:00
|
|
|
dissector_add_uint( "mpls.label", MPLS_LABEL_INVALID, handle );
|
2009-03-03 20:07:38 +00:00
|
|
|
|
2009-03-05 04:04:38 +00:00
|
|
|
ppp_handle = find_dissector( "ppp" );
|
|
|
|
fr_handle = find_dissector( "fr" );
|
2009-03-03 20:55:38 +00:00
|
|
|
}
|