2005-01-31 03:03:02 +00:00
|
|
|
/* packet-redback.c
|
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2005-01-31 03:03:02 +00:00
|
|
|
*
|
2014-07-23 14:42:07 +00:00
|
|
|
* Ericsson SmartEdge tcpdump trace disassembly
|
|
|
|
* Copyright 2005-2014 Florian Lohoff <f@zz.de>
|
2005-01-31 03:03:02 +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.
|
|
|
|
*
|
|
|
|
* 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 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-01-31 03:03:02 +00:00
|
|
|
*/
|
|
|
|
|
2013-10-18 21:11:11 +00:00
|
|
|
#define NEW_PROTO_TREE_API
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2005-01-31 03:03:02 +00:00
|
|
|
|
|
|
|
#include <epan/packet.h>
|
2014-09-06 12:44:23 +00:00
|
|
|
#include <epan/expert.h>
|
2013-11-29 20:53:00 +00:00
|
|
|
#include <wiretap/wtap.h>
|
|
|
|
|
2005-01-31 03:03:02 +00:00
|
|
|
|
2013-12-12 19:52:14 +00:00
|
|
|
void proto_register_redback(void);
|
|
|
|
void proto_reg_handoff_redback(void);
|
|
|
|
|
2013-10-18 21:11:11 +00:00
|
|
|
static dissector_handle_t redback_handle;
|
|
|
|
|
2005-01-31 03:03:02 +00:00
|
|
|
static gint ett_redback = -1;
|
|
|
|
|
2013-09-12 20:34:19 +00:00
|
|
|
static dissector_table_t osinl_incl_subdissector_table;
|
2008-10-14 19:16:28 +00:00
|
|
|
static dissector_table_t osinl_excl_subdissector_table;
|
|
|
|
|
2005-01-31 03:03:02 +00:00
|
|
|
static dissector_handle_t ipv4_handle;
|
2014-07-23 14:41:43 +00:00
|
|
|
static dissector_handle_t ipv6_handle;
|
2008-10-14 19:16:28 +00:00
|
|
|
static dissector_handle_t ethnofcs_handle;
|
2005-01-31 03:03:02 +00:00
|
|
|
static dissector_handle_t clnp_handle;
|
|
|
|
static dissector_handle_t arp_handle;
|
2007-05-31 19:29:29 +00:00
|
|
|
static dissector_handle_t ppp_handle;
|
2008-10-14 19:16:28 +00:00
|
|
|
static dissector_handle_t ppphdlc_handle;
|
|
|
|
static dissector_handle_t data_handle;
|
|
|
|
|
2013-10-18 21:11:11 +00:00
|
|
|
static header_field_info *hfi_redback = NULL;
|
|
|
|
|
|
|
|
#define REDBACK_HFI_INIT HFI_INIT(proto_redback)
|
|
|
|
|
|
|
|
static header_field_info hfi_redback_context REDBACK_HFI_INIT =
|
|
|
|
{ "Context", "redback.context", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL };
|
|
|
|
|
|
|
|
static header_field_info hfi_redback_flags REDBACK_HFI_INIT =
|
|
|
|
{ "Flags", "redback.flags", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL };
|
|
|
|
|
|
|
|
static header_field_info hfi_redback_circuit REDBACK_HFI_INIT =
|
|
|
|
{ "Circuit", "redback.circuit", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL };
|
|
|
|
|
|
|
|
static header_field_info hfi_redback_length REDBACK_HFI_INIT =
|
|
|
|
{ "Length", "redback.length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL };
|
|
|
|
|
|
|
|
static header_field_info hfi_redback_protocol REDBACK_HFI_INIT =
|
|
|
|
{ "Protocol", "redback.protocol", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL };
|
|
|
|
|
|
|
|
static header_field_info hfi_redback_l3offset REDBACK_HFI_INIT =
|
|
|
|
{ "Layer 3 Offset", "redback.l3offset", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL };
|
|
|
|
|
|
|
|
static header_field_info hfi_redback_dataoffset REDBACK_HFI_INIT =
|
|
|
|
{ "Data Offset", "redback.dataoffset", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL };
|
|
|
|
|
|
|
|
static header_field_info hfi_redback_padding REDBACK_HFI_INIT =
|
|
|
|
{ "Padding", "redback.padding", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL };
|
|
|
|
|
|
|
|
static header_field_info hfi_redback_unknown REDBACK_HFI_INIT =
|
|
|
|
{ "Unknown", "redback.unknown", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL };
|
2005-01-31 03:03:02 +00:00
|
|
|
|
2014-09-06 12:44:23 +00:00
|
|
|
static expert_field ei_redback_protocol = EI_INIT;
|
|
|
|
|
2005-01-31 03:03:02 +00:00
|
|
|
static void
|
|
|
|
dissect_redback(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2008-10-14 19:16:28 +00:00
|
|
|
guint16 l3off, dataoff, proto;
|
2014-09-06 12:44:23 +00:00
|
|
|
proto_item *ti, *protocol_item;
|
2008-10-14 19:16:28 +00:00
|
|
|
proto_tree *rbtree = NULL;
|
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
|
2010-01-13 20:32:01 +00:00
|
|
|
col_set_str(pinfo->cinfo,COL_PROTOCOL,"RBN");
|
2008-10-14 19:16:28 +00:00
|
|
|
|
|
|
|
dataoff = tvb_get_ntohs(tvb, 20);
|
|
|
|
l3off = tvb_get_ntohs(tvb, 22);
|
|
|
|
|
2014-09-06 12:44:23 +00:00
|
|
|
ti = proto_tree_add_item(tree, hfi_redback, tvb, 0, -1, ENC_NA);
|
|
|
|
rbtree = proto_item_add_subtree(ti, ett_redback);
|
2008-10-14 19:16:28 +00:00
|
|
|
|
2014-09-06 12:44:23 +00:00
|
|
|
proto_tree_add_item(rbtree, &hfi_redback_context, tvb, 0, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(rbtree, &hfi_redback_flags, tvb, 4, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(rbtree, &hfi_redback_circuit, tvb, 8, 8, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(rbtree, &hfi_redback_length, tvb, 16, 2, ENC_BIG_ENDIAN);
|
|
|
|
protocol_item = proto_tree_add_item(rbtree, &hfi_redback_protocol, tvb, 18, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(rbtree, &hfi_redback_dataoffset, tvb, 20, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(rbtree, &hfi_redback_l3offset, tvb, 22, 2, ENC_BIG_ENDIAN);
|
2008-10-14 19:16:28 +00:00
|
|
|
|
2014-09-06 12:44:23 +00:00
|
|
|
if (dataoff > 24) {
|
|
|
|
proto_tree_add_item(rbtree, &hfi_redback_padding, tvb, 24, dataoff-24, ENC_NA);
|
2008-10-14 19:16:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
proto = tvb_get_ntohs(tvb, 18);
|
|
|
|
switch(proto) {
|
|
|
|
case 0x01:
|
|
|
|
/*
|
|
|
|
* IP on Ethernet - Incoming data points to an ethernet header
|
|
|
|
* outgoing we have a pure IPv4 Packet
|
|
|
|
*/
|
2009-08-16 12:36:22 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, dataoff);
|
2008-10-14 19:16:28 +00:00
|
|
|
if (dataoff == l3off)
|
|
|
|
call_dissector(ipv4_handle, next_tvb, pinfo, tree);
|
|
|
|
else if (dataoff+2 == l3off)
|
|
|
|
call_dissector(ppp_handle, next_tvb, pinfo, tree);
|
|
|
|
else if (dataoff+4 == l3off)
|
|
|
|
call_dissector(ppphdlc_handle, next_tvb, pinfo, tree);
|
|
|
|
else
|
|
|
|
call_dissector(ethnofcs_handle, next_tvb, pinfo, tree);
|
|
|
|
break;
|
|
|
|
case 0x02:
|
|
|
|
/*
|
|
|
|
* This is ISIS - Either incoming with ethernet FCS
|
2011-10-21 02:10:19 +00:00
|
|
|
* and CLNP - passed to the eth dissector or in case
|
2013-02-26 01:06:19 +00:00
|
|
|
* of outgoing it's pure ISIS and the linecard attaches
|
2008-10-14 19:16:28 +00:00
|
|
|
* the ethernet and CLNP headers ...
|
|
|
|
*
|
|
|
|
*/
|
2009-08-16 12:36:22 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, dataoff);
|
2008-10-14 19:16:28 +00:00
|
|
|
if (l3off > dataoff) {
|
|
|
|
call_dissector(ethnofcs_handle, next_tvb, pinfo, tree);
|
|
|
|
} else {
|
|
|
|
guint8 nlpid = tvb_get_guint8(tvb, dataoff);
|
2013-09-12 20:34:19 +00:00
|
|
|
if(dissector_try_uint(osinl_incl_subdissector_table, nlpid, next_tvb, pinfo, tree))
|
2008-10-14 19:16:28 +00:00
|
|
|
break;
|
2009-08-16 12:36:22 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, dataoff+1);
|
2010-12-20 05:35:29 +00:00
|
|
|
if(dissector_try_uint(osinl_excl_subdissector_table, nlpid, next_tvb, pinfo, tree))
|
2008-10-14 19:16:28 +00:00
|
|
|
break;
|
2009-08-16 12:36:22 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, dataoff);
|
2008-10-14 19:16:28 +00:00
|
|
|
call_dissector(data_handle, next_tvb, pinfo, tree);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x06: {
|
|
|
|
/*
|
|
|
|
* PPP Messages e.g. LCP, IPCP etc - possibly on ethernet in case of PPPoE.
|
|
|
|
* PPPoE messages are Protocol 8 ...
|
|
|
|
*/
|
|
|
|
guint32 flags;
|
|
|
|
flags = tvb_get_ntohl(tvb, 4);
|
|
|
|
|
2014-07-23 14:41:14 +00:00
|
|
|
if (flags & 0x04000000) {
|
2009-08-16 12:36:22 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, dataoff);
|
2008-10-14 19:16:28 +00:00
|
|
|
} else {
|
|
|
|
if (tree)
|
2013-10-18 21:11:11 +00:00
|
|
|
proto_tree_add_item(rbtree, &hfi_redback_unknown, tvb, dataoff, 4, ENC_NA);
|
2009-08-16 12:36:22 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, dataoff+4);
|
2008-10-14 19:16:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (l3off == dataoff) {
|
|
|
|
call_dissector(ppp_handle, next_tvb, pinfo, tree);
|
|
|
|
} else {
|
|
|
|
call_dissector(ethnofcs_handle, next_tvb, pinfo, tree);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 0x03: /* Unicast Ethernet tx - Seen with PPPoE PADO */
|
|
|
|
case 0x04: /* Unicast Ethernet rx - Seen with ARP */
|
|
|
|
case 0x08: /* Broadcast Ethernet rx - Seen with PPPoE PADI */
|
2009-08-16 12:36:22 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, dataoff);
|
2008-10-14 19:16:28 +00:00
|
|
|
call_dissector(ethnofcs_handle, next_tvb, pinfo, tree);
|
|
|
|
break;
|
2014-07-23 14:41:43 +00:00
|
|
|
case 0x09: /* IPv6 either encapsulated as ethernet or native ip */
|
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, dataoff);
|
|
|
|
if (dataoff == l3off)
|
|
|
|
call_dissector(ipv6_handle, next_tvb, pinfo, tree);
|
|
|
|
else
|
|
|
|
call_dissector(ethnofcs_handle, next_tvb, pinfo, tree);
|
|
|
|
break;
|
2008-10-14 19:16:28 +00:00
|
|
|
default:
|
2014-09-06 12:44:23 +00:00
|
|
|
expert_add_info(pinfo, protocol_item, &ei_redback_protocol);
|
2008-10-14 19:16:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
2005-01-31 03:03:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_redback(void)
|
|
|
|
{
|
2013-11-07 20:14:18 +00:00
|
|
|
#ifndef HAVE_HFI_SECTION_INIT
|
2013-10-18 21:11:11 +00:00
|
|
|
static header_field_info *hfi[] = {
|
|
|
|
&hfi_redback_context,
|
|
|
|
&hfi_redback_flags,
|
|
|
|
&hfi_redback_circuit,
|
|
|
|
&hfi_redback_length,
|
|
|
|
&hfi_redback_protocol,
|
|
|
|
&hfi_redback_l3offset,
|
|
|
|
&hfi_redback_dataoffset,
|
|
|
|
&hfi_redback_padding,
|
|
|
|
&hfi_redback_unknown,
|
2008-10-14 19:16:28 +00:00
|
|
|
};
|
2013-11-07 20:14:18 +00:00
|
|
|
#endif
|
2008-10-14 19:16:28 +00:00
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_redback
|
|
|
|
};
|
|
|
|
|
2014-09-06 12:44:23 +00:00
|
|
|
static ei_register_info ei[] = {
|
|
|
|
{ &ei_redback_protocol, { "redback.protocol.unknown", PI_PROTOCOL, PI_WARN, "Unknown Protocol Data", EXPFILL }},
|
|
|
|
};
|
|
|
|
|
|
|
|
expert_module_t* expert_redback;
|
2013-10-18 21:11:11 +00:00
|
|
|
int proto_redback;
|
|
|
|
|
2008-10-14 19:16:28 +00:00
|
|
|
proto_redback = proto_register_protocol("Redback", "Redback", "redback");
|
2013-10-18 21:11:11 +00:00
|
|
|
hfi_redback = proto_registrar_get_nth(proto_redback);
|
|
|
|
|
|
|
|
proto_register_fields(proto_redback, hfi, array_length(hfi));
|
2008-10-14 19:16:28 +00:00
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2014-09-06 12:44:23 +00:00
|
|
|
expert_redback = expert_register_protocol(proto_redback);
|
|
|
|
expert_register_field_array(expert_redback, ei, array_length(ei));
|
2013-10-18 21:11:11 +00:00
|
|
|
|
|
|
|
redback_handle = create_dissector_handle(dissect_redback, proto_redback);
|
2005-01-31 03:03:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_redback(void)
|
|
|
|
{
|
2013-09-12 20:34:19 +00:00
|
|
|
osinl_incl_subdissector_table = find_dissector_table("osinl.incl");
|
2008-10-14 19:16:28 +00:00
|
|
|
osinl_excl_subdissector_table = find_dissector_table("osinl.excl");
|
2005-01-31 03:03:02 +00:00
|
|
|
|
2008-10-14 19:16:28 +00:00
|
|
|
ipv4_handle = find_dissector("ip");
|
2014-07-23 14:41:43 +00:00
|
|
|
ipv6_handle = find_dissector("ipv6");
|
2008-10-14 19:16:28 +00:00
|
|
|
data_handle = find_dissector("data");
|
|
|
|
ethnofcs_handle = find_dissector("eth_withoutfcs");
|
|
|
|
clnp_handle = find_dissector("clnp");
|
|
|
|
arp_handle = find_dissector("arp");
|
|
|
|
ppp_handle = find_dissector("ppp");
|
|
|
|
ppphdlc_handle = find_dissector("ppp_hdlc");
|
2005-01-31 03:03:02 +00:00
|
|
|
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("wtap_encap", WTAP_ENCAP_REDBACK, redback_handle);
|
2005-01-31 03:03:02 +00:00
|
|
|
}
|
|
|
|
|
2014-09-30 20:59:17 +00:00
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
*/
|