2005-01-14 11:17:35 +00:00
|
|
|
/* packet-rmt-alc.c
|
|
|
|
* Reliable Multicast Transport (RMT)
|
|
|
|
* ALC Protocol Instantiation dissector
|
|
|
|
* Copyright 2005, Stefano Pettini <spettini@users.sourceforge.net>
|
|
|
|
*
|
|
|
|
* Asynchronous Layered Coding (ALC):
|
|
|
|
* ----------------------------------
|
|
|
|
*
|
|
|
|
* A massively scalable reliable content delivery protocol.
|
|
|
|
* Asynchronous Layered Coding combines the Layered Coding Transport
|
|
|
|
* (LCT) building block, a multiple rate congestion control building
|
|
|
|
* block and the Forward Error Correction (FEC) building block to
|
|
|
|
* provide congestion controlled reliable asynchronous delivery of
|
|
|
|
* content to an unlimited number of concurrent receivers from a single
|
|
|
|
* sender.
|
|
|
|
*
|
|
|
|
* References:
|
|
|
|
* RFC 3450, Asynchronous Layered Coding protocol instantiation
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2005-01-14 11:17:35 +00:00
|
|
|
* 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.
|
2010-10-10 20:39:00 +00:00
|
|
|
*
|
2005-01-14 11:17:35 +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.
|
2010-10-10 20:39:00 +00:00
|
|
|
*
|
2005-01-14 11:17:35 +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 23:18:38 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-01-14 11:17:35 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2005-01-14 11:17:35 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/prefs.h>
|
2013-05-24 17:06:23 +00:00
|
|
|
#include <epan/expert.h>
|
2005-01-14 11:17:35 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
#include "packet-rmt-common.h"
|
2005-01-14 11:17:35 +00:00
|
|
|
|
|
|
|
/* Initialize the protocol and registered fields */
|
|
|
|
/* ============================================= */
|
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
static int proto_rmt_alc = -1;
|
2008-01-30 22:34:17 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
static int hf_version = -1;
|
|
|
|
static int hf_payload = -1;
|
2005-01-14 11:17:35 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
static int ett_main = -1;
|
2005-01-14 11:17:35 +00:00
|
|
|
|
2013-05-27 23:21:11 +00:00
|
|
|
static expert_field ei_version1_only = EI_INIT;
|
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
static dissector_handle_t xml_handle;
|
|
|
|
static dissector_handle_t rmt_lct_handle;
|
|
|
|
static dissector_handle_t rmt_fec_handle;
|
2005-01-14 11:17:35 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
static guint g_default_udp_port = 0; /* 4001 */
|
|
|
|
static gboolean g_codepoint_as_fec_encoding = TRUE;
|
|
|
|
static gint g_ext_192 = LCT_PREFS_EXT_192_FLUTE;
|
|
|
|
static gint g_ext_193 = LCT_PREFS_EXT_193_FLUTE;
|
2005-01-14 11:17:35 +00:00
|
|
|
|
|
|
|
/* Code to actually dissect the packets */
|
|
|
|
/* ==================================== */
|
2013-05-24 17:06:23 +00:00
|
|
|
static int
|
|
|
|
dissect_alc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
|
2005-01-14 11:17:35 +00:00
|
|
|
{
|
2013-05-24 17:06:23 +00:00
|
|
|
guint8 version;
|
|
|
|
lct_data_exchange_t lct;
|
|
|
|
fec_data_exchange_t fec;
|
|
|
|
int len;
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2005-01-14 11:17:35 +00:00
|
|
|
/* Offset for subpacket dissection */
|
2013-05-24 17:06:23 +00:00
|
|
|
guint offset = 0;
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2005-01-14 11:17:35 +00:00
|
|
|
/* Set up structures needed to add the protocol subtree and manage it */
|
|
|
|
proto_item *ti;
|
|
|
|
proto_tree *alc_tree;
|
2008-01-30 22:34:17 +00:00
|
|
|
|
|
|
|
tvbuff_t *new_tvb;
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2005-01-14 11:17:35 +00:00
|
|
|
/* Make entries in Protocol column and Info column on summary display */
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ALC");
|
2009-08-09 07:36:13 +00:00
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2005-01-14 11:17:35 +00:00
|
|
|
/* ALC header dissection */
|
|
|
|
/* --------------------- */
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
version = hi_nibble(tvb_get_guint8(tvb, offset));
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
/* Create subtree for the ALC protocol */
|
|
|
|
ti = proto_tree_add_item(tree, proto_rmt_alc, tvb, offset, -1, ENC_NA);
|
|
|
|
alc_tree = proto_item_add_subtree(ti, ett_main);
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
/* Fill the ALC subtree */
|
|
|
|
ti = proto_tree_add_uint(alc_tree, hf_version, tvb, offset, 1, version);
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2005-01-14 11:17:35 +00:00
|
|
|
/* This dissector supports only ALCv1 packets.
|
2013-05-24 17:06:23 +00:00
|
|
|
* If version > 1 print only version field and quit.
|
2005-01-14 11:17:35 +00:00
|
|
|
*/
|
2013-05-24 17:06:23 +00:00
|
|
|
if (version != 1) {
|
2013-05-27 23:21:11 +00:00
|
|
|
expert_add_info(pinfo, ti, &ei_version1_only);
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2005-01-14 11:17:35 +00:00
|
|
|
/* Complete entry in Info column on summary display */
|
2013-05-24 17:06:23 +00:00
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "Version: %u (not supported)", version);
|
|
|
|
return 0;
|
|
|
|
}
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
/* LCT header dissection */
|
|
|
|
/* --------------------- */
|
|
|
|
new_tvb = tvb_new_subset_remaining(tvb,offset);
|
|
|
|
|
|
|
|
lct.ext_192 = g_ext_192;
|
|
|
|
lct.ext_193 = g_ext_193;
|
|
|
|
lct.codepoint = 0;
|
|
|
|
lct.is_flute = FALSE;
|
|
|
|
len = call_dissector_with_data(rmt_lct_handle, new_tvb, pinfo, alc_tree, &lct);
|
|
|
|
if (len < 0)
|
|
|
|
return offset;
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
offset += len;
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
/* FEC header dissection */
|
|
|
|
/* --------------------- */
|
2005-01-14 11:17:35 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
/* Only if LCT dissector has determined FEC Encoding ID */
|
|
|
|
/* FEC dissector needs to be called with encoding_id filled */
|
|
|
|
if (g_codepoint_as_fec_encoding && tvb_reported_length(tvb) > offset)
|
|
|
|
{
|
|
|
|
fec.encoding_id = lct.codepoint;
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
new_tvb = tvb_new_subset_remaining(tvb,offset);
|
|
|
|
len = call_dissector_with_data(rmt_fec_handle, new_tvb, pinfo, alc_tree, &fec);
|
|
|
|
if (len < 0)
|
|
|
|
return offset;
|
|
|
|
|
|
|
|
offset += len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add the Payload item */
|
|
|
|
if (tvb_reported_length(tvb) > offset){
|
|
|
|
if(lct.is_flute){
|
|
|
|
new_tvb = tvb_new_subset_remaining(tvb,offset);
|
|
|
|
call_dissector(xml_handle, new_tvb, pinfo, alc_tree);
|
|
|
|
}else{
|
|
|
|
proto_tree_add_item(alc_tree, hf_payload, tvb, offset, -1, ENC_NA);
|
|
|
|
}
|
2005-01-14 11:17:35 +00:00
|
|
|
}
|
2013-05-24 17:06:23 +00:00
|
|
|
|
|
|
|
return tvb_reported_length(tvb);
|
2005-01-14 11:17:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void proto_reg_handoff_alc(void)
|
|
|
|
{
|
|
|
|
static dissector_handle_t handle;
|
2008-10-29 19:16:29 +00:00
|
|
|
static gboolean preferences_initialized = FALSE;
|
2013-05-24 17:06:23 +00:00
|
|
|
static guint old_udp_port = 0;
|
2005-01-14 11:17:35 +00:00
|
|
|
|
|
|
|
if (!preferences_initialized)
|
|
|
|
{
|
2010-10-10 20:39:00 +00:00
|
|
|
preferences_initialized = TRUE;
|
2013-05-24 17:06:23 +00:00
|
|
|
handle = new_create_dissector_handle(dissect_alc, proto_rmt_alc);
|
2005-01-14 11:17:35 +00:00
|
|
|
dissector_add_handle("udp.port", handle);
|
2008-10-29 19:16:29 +00:00
|
|
|
xml_handle = find_dissector("xml");
|
2013-05-24 17:06:23 +00:00
|
|
|
rmt_lct_handle = find_dissector("rmt-lct");
|
|
|
|
rmt_fec_handle = find_dissector("rmt-fec");
|
2013-10-13 19:56:52 +00:00
|
|
|
}
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
/* Register UDP port for dissection */
|
|
|
|
if(old_udp_port != 0 && old_udp_port != g_default_udp_port){
|
|
|
|
dissector_delete_uint("udp.port", old_udp_port, handle);
|
2005-01-14 11:17:35 +00:00
|
|
|
}
|
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
if(g_default_udp_port != 0 && old_udp_port != g_default_udp_port) {
|
|
|
|
dissector_add_uint("udp.port", g_default_udp_port, handle);
|
|
|
|
}
|
2008-01-30 22:34:17 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
old_udp_port = g_default_udp_port;
|
2005-01-14 11:17:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void proto_register_alc(void)
|
2010-10-10 20:39:00 +00:00
|
|
|
{
|
2005-01-14 11:17:35 +00:00
|
|
|
/* Setup ALC header fields */
|
|
|
|
static hf_register_info hf_ptr[] = {
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
{ &hf_version,
|
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
|
|
|
{ "Version", "alc.version", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
{ &hf_payload,
|
|
|
|
{ "Payload", "alc.payload", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}
|
2005-01-14 11:17:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Setup protocol subtree array */
|
|
|
|
static gint *ett_ptr[] = {
|
2013-05-24 17:06:23 +00:00
|
|
|
&ett_main,
|
2005-01-14 11:17:35 +00:00
|
|
|
};
|
|
|
|
|
2013-05-27 23:21:11 +00:00
|
|
|
static ei_register_info ei[] = {
|
|
|
|
{ &ei_version1_only, { "alc.version1_only", PI_PROTOCOL, PI_WARN, "Sorry, this dissector supports ALC version 1 only", EXPFILL }},
|
|
|
|
};
|
|
|
|
|
2005-01-14 11:17:35 +00:00
|
|
|
module_t *module;
|
2013-05-27 23:21:11 +00:00
|
|
|
expert_module_t* expert_rmt_alc;
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2005-01-14 11:17:35 +00:00
|
|
|
/* Register the protocol name and description */
|
2013-05-24 17:06:23 +00:00
|
|
|
proto_rmt_alc = proto_register_protocol("Asynchronous Layered Coding", "ALC", "alc");
|
|
|
|
new_register_dissector("alc", dissect_alc, proto_rmt_alc);
|
2005-01-14 11:17:35 +00:00
|
|
|
|
|
|
|
/* Register the header fields and subtrees used */
|
2013-05-24 17:06:23 +00:00
|
|
|
proto_register_field_array(proto_rmt_alc, hf_ptr, array_length(hf_ptr));
|
2005-01-14 11:17:35 +00:00
|
|
|
proto_register_subtree_array(ett_ptr, array_length(ett_ptr));
|
2013-05-27 23:21:11 +00:00
|
|
|
expert_rmt_alc = expert_register_protocol(proto_rmt_alc);
|
|
|
|
expert_register_field_array(expert_rmt_alc, ei, array_length(ei));
|
2010-10-10 20:39:00 +00:00
|
|
|
|
2005-01-14 11:17:35 +00:00
|
|
|
/* Register preferences */
|
2013-05-24 17:06:23 +00:00
|
|
|
module = prefs_register_protocol(proto_rmt_alc, proto_reg_handoff_alc);
|
2008-01-30 22:34:17 +00:00
|
|
|
|
2013-05-24 17:06:23 +00:00
|
|
|
prefs_register_obsolete_preference(module, "default.udp_port.enabled");
|
|
|
|
|
|
|
|
prefs_register_uint_preference(module,
|
|
|
|
"default.udp_port",
|
|
|
|
"UDP destination port",
|
|
|
|
"Specifies the UDP destination port for automatic dissection of ALC packets",
|
|
|
|
10, &g_default_udp_port);
|
|
|
|
|
|
|
|
prefs_register_bool_preference(module,
|
|
|
|
"lct.codepoint_as_fec_id",
|
|
|
|
"LCT Codepoint as FEC Encoding ID",
|
|
|
|
"Whether the LCT header Codepoint field should be considered the FEC Encoding ID of carried object",
|
|
|
|
&g_codepoint_as_fec_encoding);
|
|
|
|
|
|
|
|
prefs_register_enum_preference(module,
|
|
|
|
"lct.ext.192",
|
|
|
|
"LCT header extension 192",
|
|
|
|
"How to decode LCT header extension 192",
|
|
|
|
&g_ext_192,
|
|
|
|
enum_lct_ext_192,
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
prefs_register_enum_preference(module,
|
|
|
|
"lct.ext.193",
|
|
|
|
"LCT header extension 193",
|
|
|
|
"How to decode LCT header extension 193",
|
|
|
|
&g_ext_193,
|
|
|
|
enum_lct_ext_193,
|
|
|
|
FALSE);
|
2005-01-14 11:17:35 +00:00
|
|
|
}
|
2013-05-24 17:06:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|