2002-07-31 19:27:57 +00:00
|
|
|
/* packet-cosine.c
|
|
|
|
* Routines for decoding CoSine IPNOS L2 debug output
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2002-07-31 19:27:57 +00:00
|
|
|
*
|
2011-04-18 02:16:36 +00:00
|
|
|
* Motonori Shindo <motonori@shin.do>
|
2002-07-31 19:27:57 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2002-07-31 19:27:57 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2002-07-31 19:27:57 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2002-07-31 19:27:57 +00:00
|
|
|
* 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 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2002-07-31 19:27:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX TODO:
|
|
|
|
* o PPoATM and PPoFR encapsulation needs more test.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2002-07-31 19:27:57 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
2013-11-29 20:53:00 +00:00
|
|
|
|
2002-07-31 19:27:57 +00:00
|
|
|
#include <epan/packet.h>
|
2013-11-29 20:53:00 +00:00
|
|
|
#include <wiretap/wtap.h>
|
2002-07-31 19:27:57 +00:00
|
|
|
|
2013-03-15 16:39:30 +00:00
|
|
|
void proto_register_cosine(void);
|
|
|
|
void proto_reg_handoff_cosine(void);
|
|
|
|
|
2002-07-31 19:27:57 +00:00
|
|
|
static int proto_cosine = -1;
|
|
|
|
static int hf_pro = -1;
|
|
|
|
static int hf_off = -1;
|
|
|
|
static int hf_pri = -1;
|
|
|
|
static int hf_rm = -1;
|
|
|
|
static int hf_err = -1;
|
|
|
|
|
|
|
|
static gint ett_raw = -1;
|
|
|
|
|
2004-11-24 09:13:52 +00:00
|
|
|
static dissector_handle_t eth_withoutfcs_handle;
|
2002-07-31 19:27:57 +00:00
|
|
|
static dissector_handle_t ppp_hdlc_handle;
|
|
|
|
static dissector_handle_t llc_handle;
|
|
|
|
static dissector_handle_t chdlc_handle;
|
|
|
|
static dissector_handle_t fr_handle;
|
|
|
|
static dissector_handle_t data_handle;
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_cosine(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2012-04-24 18:27:06 +00:00
|
|
|
proto_tree *fh_tree;
|
|
|
|
proto_item *ti;
|
|
|
|
union wtap_pseudo_header *pseudo_header = pinfo->pseudo_header;
|
2002-07-31 19:27:57 +00:00
|
|
|
|
|
|
|
/* load the top pane info. This should be overwritten by
|
|
|
|
the next protocol in the stack */
|
2009-08-09 07:14:16 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "N/A");
|
|
|
|
col_set_str(pinfo->cinfo, COL_RES_DL_DST, "N/A");
|
2009-08-09 06:47:24 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "N/A");
|
2009-08-09 07:01:26 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "CoSine IPNOS L2 debug output");
|
2002-07-31 19:27:57 +00:00
|
|
|
|
|
|
|
/* populate a tree in the second pane with the status of the link
|
|
|
|
layer (ie none) */
|
|
|
|
if(tree) {
|
2005-02-03 23:24:08 +00:00
|
|
|
ti = proto_tree_add_protocol_format(tree, proto_cosine, tvb, 0, 0,
|
2012-04-24 18:27:06 +00:00
|
|
|
"CoSine IPNOS L2 debug output (%s)",
|
|
|
|
pseudo_header->cosine.if_name);
|
2002-07-31 19:27:57 +00:00
|
|
|
fh_tree = proto_item_add_subtree(ti, ett_raw);
|
|
|
|
proto_tree_add_uint(fh_tree, hf_pro, tvb, 0, 0, pseudo_header->cosine.pro);
|
|
|
|
proto_tree_add_uint(fh_tree, hf_off, tvb, 0, 0, pseudo_header->cosine.off);
|
|
|
|
proto_tree_add_uint(fh_tree, hf_pri, tvb, 0, 0, pseudo_header->cosine.pri);
|
|
|
|
proto_tree_add_uint(fh_tree, hf_rm, tvb, 0, 0, pseudo_header->cosine.rm);
|
|
|
|
proto_tree_add_uint(fh_tree, hf_err, tvb, 0, 0, pseudo_header->cosine.err);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-07-31 19:27:57 +00:00
|
|
|
switch (pseudo_header->cosine.encap) {
|
2012-04-24 18:27:06 +00:00
|
|
|
case COSINE_ENCAP_ETH:
|
|
|
|
break;
|
|
|
|
case COSINE_ENCAP_ATM:
|
|
|
|
case COSINE_ENCAP_PPoATM:
|
|
|
|
proto_tree_add_text(fh_tree, tvb, 0, 16, "SAR header");
|
|
|
|
break;
|
|
|
|
case COSINE_ENCAP_PPP:
|
|
|
|
case COSINE_ENCAP_FR:
|
|
|
|
case COSINE_ENCAP_PPoFR:
|
|
|
|
proto_tree_add_text(fh_tree, tvb, 0, 4, "Channel handle ID");
|
|
|
|
break;
|
|
|
|
case COSINE_ENCAP_HDLC:
|
|
|
|
if (pseudo_header->cosine.direction == COSINE_DIR_TX) {
|
|
|
|
proto_tree_add_text(fh_tree, tvb, 0, 2,
|
|
|
|
"Channel handle ID");
|
|
|
|
} else if (pseudo_header->cosine.direction == COSINE_DIR_RX) {
|
|
|
|
proto_tree_add_text(fh_tree, tvb, 0, 4,
|
|
|
|
"Channel handle ID");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (pseudo_header->cosine.encap) {
|
2002-07-31 19:27:57 +00:00
|
|
|
case COSINE_ENCAP_ETH:
|
2012-04-24 18:27:06 +00:00
|
|
|
call_dissector(eth_withoutfcs_handle, tvb_new_subset_remaining(tvb, 0),
|
|
|
|
pinfo, tree);
|
|
|
|
break;
|
2002-07-31 19:27:57 +00:00
|
|
|
case COSINE_ENCAP_ATM:
|
|
|
|
case COSINE_ENCAP_PPoATM:
|
2012-04-24 18:27:06 +00:00
|
|
|
call_dissector(llc_handle, tvb_new_subset_remaining(tvb, 16),
|
|
|
|
pinfo, tree);
|
|
|
|
break;
|
2002-07-31 19:27:57 +00:00
|
|
|
case COSINE_ENCAP_PPP:
|
2012-04-24 18:27:06 +00:00
|
|
|
call_dissector(ppp_hdlc_handle, tvb_new_subset_remaining(tvb, 4),
|
|
|
|
pinfo, tree);
|
|
|
|
break;
|
|
|
|
case COSINE_ENCAP_HDLC:
|
|
|
|
if (pseudo_header->cosine.direction == COSINE_DIR_TX) {
|
|
|
|
call_dissector(chdlc_handle, tvb_new_subset_remaining(tvb, 2),
|
|
|
|
pinfo, tree);
|
|
|
|
} else if (pseudo_header->cosine.direction == COSINE_DIR_RX) {
|
|
|
|
call_dissector(chdlc_handle, tvb_new_subset_remaining(tvb, 4),
|
|
|
|
pinfo, tree);
|
|
|
|
}
|
|
|
|
break;
|
2002-07-31 19:27:57 +00:00
|
|
|
case COSINE_ENCAP_FR:
|
|
|
|
case COSINE_ENCAP_PPoFR:
|
2012-04-24 18:27:06 +00:00
|
|
|
call_dissector(fr_handle, tvb_new_subset_remaining(tvb, 4),
|
|
|
|
pinfo, tree);
|
|
|
|
break;
|
|
|
|
case COSINE_ENCAP_TEST:
|
|
|
|
case COSINE_ENCAP_UNKNOWN:
|
|
|
|
call_dissector(data_handle, tvb, pinfo, tree);
|
|
|
|
break;
|
2002-07-31 19:27:57 +00:00
|
|
|
default:
|
2012-04-24 18:27:06 +00:00
|
|
|
break;
|
2002-07-31 19:27:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_cosine(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
2002-08-28 21:04:11 +00:00
|
|
|
{ &hf_pro,
|
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
|
|
|
{ "Protocol", "cosine.pro", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
|
2002-08-28 21:04:11 +00:00
|
|
|
{ &hf_off,
|
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
|
|
|
{ "Offset", "cosine.off", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
|
2002-08-28 21:04:11 +00:00
|
|
|
{ &hf_pri,
|
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
|
|
|
{ "Priority", "cosine.pri", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
|
2002-08-28 21:04:11 +00:00
|
|
|
{ &hf_rm,
|
2012-04-24 18:27:06 +00:00
|
|
|
{ "Rate Marking", "cosine.rm", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
|
2002-08-28 21:04:11 +00:00
|
|
|
{ &hf_err,
|
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
|
|
|
{ "Error Code", "cosine.err", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
|
2002-07-31 19:27:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_raw,
|
|
|
|
};
|
|
|
|
|
|
|
|
proto_cosine = proto_register_protocol("CoSine IPNOS L2 debug output",
|
2012-04-24 18:27:06 +00:00
|
|
|
"CoSine", "cosine");
|
2002-07-31 19:27:57 +00:00
|
|
|
proto_register_field_array(proto_cosine, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_cosine(void)
|
|
|
|
{
|
|
|
|
dissector_handle_t cosine_handle;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get handles for dissectors.
|
|
|
|
*/
|
2004-11-24 09:13:52 +00:00
|
|
|
eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
|
2012-04-24 18:27:06 +00:00
|
|
|
ppp_hdlc_handle = find_dissector("ppp_hdlc");
|
|
|
|
llc_handle = find_dissector("llc");
|
|
|
|
chdlc_handle = find_dissector("chdlc");
|
|
|
|
fr_handle = find_dissector("fr");
|
|
|
|
data_handle = find_dissector("data");
|
2002-07-31 19:27:57 +00:00
|
|
|
|
|
|
|
cosine_handle = create_dissector_handle(dissect_cosine, proto_cosine);
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("wtap_encap", WTAP_ENCAP_COSINE, cosine_handle);
|
2002-07-31 19:27:57 +00:00
|
|
|
}
|