2006-04-14 13:12:13 +00:00
|
|
|
/* packet-catapult-dct2000.c
|
|
|
|
* Routines for Catapult DCT2000 packet stub header disassembly
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2006-04-14 13:12:13 +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.
|
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/emem.h>
|
|
|
|
#include <epan/proto.h>
|
|
|
|
#include <epan/prefs.h>
|
|
|
|
|
2006-06-20 18:30:54 +00:00
|
|
|
#include <wiretap/catapult_dct2000.h>
|
2006-04-14 13:12:13 +00:00
|
|
|
|
|
|
|
/* Protocol and registered fields. */
|
|
|
|
static int proto_catapult_dct2000 = -1;
|
|
|
|
|
|
|
|
static int hf_catapult_dct2000_context = -1;
|
|
|
|
static int hf_catapult_dct2000_port_number = -1;
|
|
|
|
static int hf_catapult_dct2000_timestamp = -1;
|
|
|
|
static int hf_catapult_dct2000_protocol = -1;
|
2006-05-23 05:48:00 +00:00
|
|
|
static int hf_catapult_dct2000_variant = -1;
|
2006-08-02 09:30:28 +00:00
|
|
|
static int hf_catapult_dct2000_outhdr = -1;
|
2006-04-14 13:12:13 +00:00
|
|
|
static int hf_catapult_dct2000_direction = -1;
|
|
|
|
static int hf_catapult_dct2000_encap = -1;
|
|
|
|
static int hf_catapult_dct2000_unparsed_data = -1;
|
|
|
|
|
2006-05-23 05:48:00 +00:00
|
|
|
/* Variables used for preferences */
|
|
|
|
gboolean catapult_dct2000_try_ipprim_heuristic = TRUE;
|
2006-08-02 09:30:28 +00:00
|
|
|
gboolean catapult_dct2000_try_sctpprim_heuristic = TRUE;
|
2006-04-14 13:12:13 +00:00
|
|
|
|
|
|
|
/* Protocol subtree. */
|
|
|
|
static int ett_catapult_dct2000 = -1;
|
|
|
|
|
|
|
|
static const value_string direction_vals[] = {
|
2006-08-02 09:30:28 +00:00
|
|
|
{ 0, "Sent" },
|
|
|
|
{ 1, "Received" },
|
2006-04-14 13:12:13 +00:00
|
|
|
{ 0, NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string encap_vals[] = {
|
|
|
|
{ WTAP_ENCAP_RAW_IP, "Raw IP" },
|
|
|
|
{ WTAP_ENCAP_ETHERNET, "Ethernet" },
|
|
|
|
{ WTAP_ENCAP_ISDN, "LAPD" },
|
|
|
|
{ WTAP_ENCAP_ATM_PDUS_UNTRUNCATED, "ATM (PDUs untruncated)" },
|
|
|
|
{ WTAP_ENCAP_PPP, "PPP" },
|
|
|
|
{ DCT2000_ENCAP_SSCOP, "SSCOP" },
|
|
|
|
{ WTAP_ENCAP_FRELAY, "Frame Relay" },
|
|
|
|
{ WTAP_ENCAP_MTP2, "MTP2" },
|
|
|
|
{ DCT2000_ENCAP_UNHANDLED, "Unhandled Protocol" },
|
|
|
|
{ 0, NULL },
|
|
|
|
};
|
|
|
|
|
2006-08-02 09:30:28 +00:00
|
|
|
|
|
|
|
void proto_reg_handoff_catapult_dct2000(void);
|
|
|
|
void proto_register_catapult_dct2000(void);
|
|
|
|
|
|
|
|
|
2006-05-23 05:48:00 +00:00
|
|
|
/* Look for the protocol data within an ipprim packet.
|
|
|
|
Only set *data_offset if data field found. */
|
2006-06-08 14:36:17 +00:00
|
|
|
static gboolean find_ipprim_data_offset(tvbuff_t *tvb, int *data_offset)
|
2006-05-23 05:48:00 +00:00
|
|
|
{
|
|
|
|
guint8 length;
|
|
|
|
int offset = *data_offset;
|
|
|
|
gboolean is_udp;
|
|
|
|
|
|
|
|
/* Get the ipprim command code. */
|
|
|
|
guint8 tag = tvb_get_guint8(tvb, offset++);
|
|
|
|
|
|
|
|
/* Only accept UDP or TCP data request or indication */
|
|
|
|
switch (tag)
|
|
|
|
{
|
|
|
|
case 0x23: /* UDP data request */
|
|
|
|
case 0x24: /* UDP data indication */
|
|
|
|
is_udp = TRUE;
|
|
|
|
break;
|
|
|
|
case 0x45: /* TCP data request */
|
|
|
|
case 0x46: /* TCP data indication */
|
|
|
|
is_udp = FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Skip any other TLC fields before reach payload */
|
|
|
|
while (tvb_length_remaining(tvb, offset) > 2)
|
|
|
|
{
|
|
|
|
/* Look at next tag */
|
|
|
|
tag = tvb_get_guint8(tvb, offset++);
|
|
|
|
|
|
|
|
/* Is this the data payload we're expecting? */
|
|
|
|
if ((tag == 0x34 && is_udp) || (tag == 0x48 && !is_udp))
|
|
|
|
{
|
|
|
|
*data_offset = offset;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Read length in next byte */
|
|
|
|
length = tvb_get_guint8(tvb, offset++);
|
|
|
|
/* Skip the following value */
|
|
|
|
offset += length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No data found... */
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-04-14 13:12:13 +00:00
|
|
|
|
2006-08-02 09:30:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Look for the protocol data within an sctpprim (variant 1 or 2...) packet.
|
|
|
|
Only set *data_offset if data field found. */
|
|
|
|
static gboolean find_sctpprim_variant1_data_offset(tvbuff_t *tvb, int *data_offset)
|
|
|
|
{
|
|
|
|
guint8 length;
|
|
|
|
int offset = *data_offset;
|
|
|
|
|
|
|
|
/* Get the sctpprim command code. */
|
|
|
|
guint8 tag = tvb_get_guint8(tvb, offset++);
|
|
|
|
|
|
|
|
/* Only accept interested in data requests or indications */
|
|
|
|
switch (tag)
|
|
|
|
{
|
|
|
|
case 0x04: /* data request */
|
|
|
|
case 0x62: /* data indication */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Length field. msb set indicates 2 bytes */
|
|
|
|
if (tvb_get_guint8(tvb, offset) & 0x80)
|
|
|
|
{
|
|
|
|
offset += 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
offset++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Skip any other TLC fields before reach payload */
|
|
|
|
while (tvb_length_remaining(tvb, offset) > 2)
|
|
|
|
{
|
|
|
|
/* Look at next tag */
|
|
|
|
tag = tvb_get_guint8(tvb, offset++);
|
|
|
|
|
|
|
|
/* Is this the data payload we're expecting? */
|
|
|
|
if (tag == 0x19)
|
|
|
|
{
|
|
|
|
*data_offset = offset;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Read length in next byte */
|
|
|
|
length = tvb_get_guint8(tvb, offset++);
|
|
|
|
/* Skip the following value */
|
|
|
|
offset += length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No data found... */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look for the protocol data within an sctpprim (variant 3) packet.
|
|
|
|
Only set *data_offset if data field found. */
|
|
|
|
static gboolean find_sctpprim_variant3_data_offset(tvbuff_t *tvb, int *data_offset)
|
|
|
|
{
|
|
|
|
int offset = *data_offset;
|
|
|
|
|
|
|
|
/* Get the sctpprim (2 byte) command code. */
|
|
|
|
guint16 top_tag = (tvb_get_guint8(tvb, offset) << 8) | tvb_get_guint8(tvb, offset+1);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
/* Only interested in data requests or indications */
|
|
|
|
switch (top_tag)
|
|
|
|
{
|
|
|
|
case 0x0400: /* SendDataReq */
|
|
|
|
case 0x6200: /* DataInd */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Overall length field is next 2 bytes */
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
/* DataInd messages have 32 bits fixed here */
|
|
|
|
if (top_tag == 0x6200)
|
|
|
|
{
|
|
|
|
/* Associate-Id + destination port */
|
|
|
|
offset += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Skip any other known fields before reach payload */
|
|
|
|
while (tvb_length_remaining(tvb, offset) > 4)
|
|
|
|
{
|
|
|
|
/* Get the next tag */
|
|
|
|
guint16 tag = (tvb_get_guint8(tvb, offset) << 8) | tvb_get_guint8(tvb, offset+1);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
/* Is this the data (i) payload we're expecting? */
|
|
|
|
if (tag == 0x1900)
|
|
|
|
{
|
|
|
|
/* 2-byte length field */
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
/* Data is here!!! */
|
|
|
|
*data_offset = offset;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
guint8 length;
|
|
|
|
|
|
|
|
/* Deal with non-data tags */
|
|
|
|
switch (tag)
|
|
|
|
{
|
|
|
|
/* These tags take a fixed-length, 16-bit payload */
|
|
|
|
case 0x2400: /* AssociateId */
|
|
|
|
case 0x3200: /* Delivery Option */
|
|
|
|
offset += 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* These tags take a 2-byte length field */
|
|
|
|
case 0x0d00: /* Stream num */
|
|
|
|
case 0x0900: /* IPv4 address */
|
|
|
|
case 0x0b00: /* Options */
|
|
|
|
case 0x0c00: /* Payload type */
|
|
|
|
length = (tvb_get_guint8(tvb, offset) << 8) | tvb_get_guint8(tvb, offset+1);
|
|
|
|
if (top_tag == 0x0400)
|
|
|
|
{
|
|
|
|
/* Weird... */
|
|
|
|
length = length/2;
|
|
|
|
}
|
|
|
|
offset += (2+length);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x0008:
|
|
|
|
/* 4 bytes of data (IP address) */
|
|
|
|
offset += 4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Unexpected tag - abort */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Indications always have these fields */
|
|
|
|
if (top_tag == 0x6200 && tag == 0x0900)
|
|
|
|
{
|
|
|
|
/* StrSeqNum + StreamNum + PayloadType */
|
|
|
|
offset += 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No data found... */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Look up dissector by protocol name. Fix up known name mis-matches. */
|
|
|
|
dissector_handle_t look_for_dissector(char *protocol_name)
|
|
|
|
{
|
|
|
|
/* Use known aliases... */
|
|
|
|
if (strcmp(protocol_name, "tbcp") == 0)
|
|
|
|
{
|
|
|
|
return find_dissector("rtcp");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (strcmp(protocol_name, "diameter_r6") == 0)
|
|
|
|
{
|
|
|
|
return find_dissector("diameter");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if ((strcmp(protocol_name, "xcap_caps") == 0) ||
|
|
|
|
(strcmp(protocol_name, "mm1") == 0) ||
|
|
|
|
(strcmp(protocol_name, "mm7") == 0))
|
|
|
|
{
|
|
|
|
return find_dissector("http");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try for an exact match */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return find_dissector(protocol_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-14 13:12:13 +00:00
|
|
|
/*****************************************/
|
|
|
|
/* Main dissection function. */
|
|
|
|
/*****************************************/
|
|
|
|
static void
|
|
|
|
dissect_catapult_dct2000(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
proto_tree *dct2000_tree;
|
|
|
|
proto_item *ti;
|
|
|
|
gint offset = 0;
|
|
|
|
gint context_length;
|
|
|
|
guint8 port_number;
|
|
|
|
gint protocol_start;
|
|
|
|
gint protocol_length;
|
|
|
|
gint timestamp_start;
|
|
|
|
gint timestamp_length;
|
2006-06-11 08:26:55 +00:00
|
|
|
gint variant_start;
|
|
|
|
gint variant_length;
|
2006-08-02 09:30:28 +00:00
|
|
|
gint outhdr_start;
|
|
|
|
gint outhdr_length;
|
2006-04-14 13:12:13 +00:00
|
|
|
guint8 direction;
|
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
int encap;
|
|
|
|
dissector_handle_t protocol_handle = 0;
|
2006-08-02 09:30:28 +00:00
|
|
|
dissector_handle_t heur_protocol_handle = 0;
|
2006-04-14 13:12:13 +00:00
|
|
|
int sub_dissector_result = 0;
|
|
|
|
|
|
|
|
/* Protocol name */
|
|
|
|
if (check_col(pinfo->cinfo, COL_PROTOCOL))
|
|
|
|
{
|
|
|
|
col_add_str(pinfo->cinfo, COL_PROTOCOL, "DCT2000");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Info column */
|
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
{
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create protocol tree. */
|
|
|
|
ti = proto_tree_add_item(tree, proto_catapult_dct2000, tvb, offset, -1, FALSE);
|
|
|
|
dct2000_tree = proto_item_add_subtree(ti, ett_catapult_dct2000);
|
|
|
|
|
|
|
|
/* Context Name */
|
|
|
|
context_length = tvb_strsize(tvb, offset);
|
|
|
|
proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_context, tvb,
|
|
|
|
offset, context_length, FALSE);
|
|
|
|
offset += context_length;
|
|
|
|
|
|
|
|
/* Context port number */
|
|
|
|
proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_port_number, tvb,
|
|
|
|
offset, 1, FALSE);
|
|
|
|
port_number = tvb_get_guint8(tvb, offset);
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
/* Timestamp in file */
|
|
|
|
timestamp_start = offset;
|
|
|
|
timestamp_length = tvb_strsize(tvb, offset);
|
|
|
|
proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_timestamp, tvb,
|
|
|
|
offset, timestamp_length, FALSE);
|
|
|
|
offset += timestamp_length;
|
|
|
|
|
|
|
|
|
|
|
|
/* Original protocol name */
|
|
|
|
protocol_start = offset;
|
|
|
|
protocol_length = tvb_strsize(tvb, offset);
|
|
|
|
proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_protocol, tvb,
|
|
|
|
offset, protocol_length, FALSE);
|
|
|
|
offset += protocol_length;
|
|
|
|
|
2006-05-23 05:48:00 +00:00
|
|
|
/* Variant */
|
2006-06-11 08:26:55 +00:00
|
|
|
variant_start = offset;
|
|
|
|
variant_length = tvb_strsize(tvb, offset);
|
2006-05-23 05:48:00 +00:00
|
|
|
proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_variant, tvb,
|
2006-06-11 08:26:55 +00:00
|
|
|
offset, variant_length, FALSE);
|
|
|
|
offset += variant_length;
|
2006-05-23 05:48:00 +00:00
|
|
|
|
2006-08-02 09:30:28 +00:00
|
|
|
/* Outhdr */
|
|
|
|
outhdr_start = offset;
|
|
|
|
outhdr_length = tvb_strsize(tvb, offset);
|
|
|
|
if (outhdr_length > 1)
|
|
|
|
{
|
|
|
|
proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_outhdr, tvb,
|
|
|
|
offset, outhdr_length, FALSE);
|
|
|
|
}
|
|
|
|
offset += outhdr_length;
|
|
|
|
|
|
|
|
|
2006-04-14 13:12:13 +00:00
|
|
|
/* Direction */
|
|
|
|
direction = tvb_get_guint8(tvb, offset);
|
|
|
|
proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_direction, tvb,
|
|
|
|
offset, 1, FALSE);
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
/* Read file encap */
|
|
|
|
proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_encap, tvb, offset, 1, FALSE);
|
|
|
|
encap = tvb_get_guint8(tvb, offset);
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
/* Set selection length of dct2000 tree */
|
|
|
|
proto_item_set_len(dct2000_tree, offset);
|
|
|
|
|
|
|
|
/* Add useful details to protocol tree label */
|
2006-06-11 08:26:55 +00:00
|
|
|
proto_item_append_text(ti, " context=%s.%u t=%s %c prot=%s (v=%s)",
|
2006-04-14 13:12:13 +00:00
|
|
|
tvb_get_ephemeral_string(tvb, 0, context_length),
|
|
|
|
port_number,
|
|
|
|
tvb_get_ephemeral_string(tvb, timestamp_start, timestamp_length),
|
|
|
|
(direction == 0) ? 'S' : 'R',
|
2006-05-23 05:48:00 +00:00
|
|
|
tvb_get_ephemeral_string(tvb, protocol_start, protocol_length),
|
2006-06-11 08:26:55 +00:00
|
|
|
tvb_get_ephemeral_string(tvb, variant_start, variant_length));
|
2006-04-14 13:12:13 +00:00
|
|
|
|
|
|
|
|
2006-04-17 18:46:14 +00:00
|
|
|
/* Note that the first item of pinfo->pseudo_header->dct2000 will contain
|
2006-05-21 04:49:01 +00:00
|
|
|
the pseudo-header needed (in some cases) by the wireshark dissector */
|
2006-04-14 13:12:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* Now hand off to the dissector of intended packet encapsulation type */
|
|
|
|
|
|
|
|
/* Get protocol handle, and set p2p_dir where necessary.
|
|
|
|
(packet-frame.c won't copy it from pseudo-header because it doesn't
|
|
|
|
know about Catapult DCT2000 encap type...)
|
|
|
|
*/
|
|
|
|
switch (encap)
|
|
|
|
{
|
|
|
|
case WTAP_ENCAP_RAW_IP:
|
|
|
|
protocol_handle = find_dissector("ip");
|
|
|
|
break;
|
|
|
|
case WTAP_ENCAP_ETHERNET:
|
|
|
|
protocol_handle = find_dissector("eth_withoutfcs");
|
|
|
|
break;
|
|
|
|
case WTAP_ENCAP_ISDN:
|
|
|
|
protocol_handle = find_dissector("lapd");
|
|
|
|
pinfo->p2p_dir = pinfo->pseudo_header->isdn.uton;
|
|
|
|
break;
|
|
|
|
case WTAP_ENCAP_ATM_PDUS_UNTRUNCATED:
|
|
|
|
protocol_handle = find_dissector("atm_untruncated");
|
|
|
|
break;
|
|
|
|
case WTAP_ENCAP_PPP:
|
|
|
|
protocol_handle = find_dissector("ppp_hdlc");
|
|
|
|
pinfo->p2p_dir = pinfo->pseudo_header->p2p.sent;
|
|
|
|
break;
|
|
|
|
case DCT2000_ENCAP_SSCOP:
|
|
|
|
protocol_handle = find_dissector("sscop");
|
|
|
|
break;
|
|
|
|
case WTAP_ENCAP_FRELAY:
|
|
|
|
protocol_handle = find_dissector("fr");
|
|
|
|
break;
|
|
|
|
case DCT2000_ENCAP_MTP2:
|
|
|
|
protocol_handle = find_dissector("mtp2");
|
|
|
|
break;
|
|
|
|
case DCT2000_ENCAP_UNHANDLED:
|
2006-05-23 05:48:00 +00:00
|
|
|
/* Many DCT2000 protocols have at least one IPPrim variant. If the
|
|
|
|
protocol names match, try to find the UDP/TCP data inside them and
|
|
|
|
pass that offset to dissector
|
|
|
|
*/
|
2006-04-14 13:12:13 +00:00
|
|
|
protocol_handle = 0;
|
2006-05-23 05:48:00 +00:00
|
|
|
|
|
|
|
/* Try IP Prim heuristic if configured to */
|
|
|
|
if (catapult_dct2000_try_ipprim_heuristic)
|
|
|
|
{
|
2006-08-02 09:30:28 +00:00
|
|
|
heur_protocol_handle =
|
|
|
|
look_for_dissector((char*)tvb_get_ephemeral_string(tvb, protocol_start,
|
|
|
|
protocol_length));
|
|
|
|
if ((heur_protocol_handle != 0) &&
|
2006-05-23 05:48:00 +00:00
|
|
|
find_ipprim_data_offset(tvb, &offset))
|
|
|
|
{
|
2006-08-02 09:30:28 +00:00
|
|
|
protocol_handle = heur_protocol_handle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try SCTP Prim heuristic if configured to */
|
|
|
|
if (!protocol_handle && catapult_dct2000_try_sctpprim_heuristic)
|
|
|
|
{
|
|
|
|
heur_protocol_handle =
|
|
|
|
look_for_dissector(tvb_get_ephemeral_string(tvb, protocol_start,
|
|
|
|
protocol_length));
|
|
|
|
if ((heur_protocol_handle != 0) &&
|
|
|
|
(find_sctpprim_variant1_data_offset(tvb, &offset) ||
|
|
|
|
find_sctpprim_variant3_data_offset(tvb, &offset)))
|
|
|
|
{
|
|
|
|
protocol_handle = heur_protocol_handle;
|
2006-05-23 05:48:00 +00:00
|
|
|
}
|
|
|
|
}
|
2006-08-02 09:30:28 +00:00
|
|
|
|
2006-04-14 13:12:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* !! If get here, there is a mismatch between
|
|
|
|
this dissector and the wiretap module catapult_dct2000.c !!
|
|
|
|
*/
|
|
|
|
DISSECTOR_ASSERT_NOT_REACHED();
|
2006-05-23 05:48:00 +00:00
|
|
|
return;
|
2006-04-14 13:12:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Try appropriate dissector, if selected */
|
|
|
|
if (protocol_handle != 0)
|
|
|
|
{
|
|
|
|
/* Dissect the remainder of the frame using chosen protocol handle */
|
|
|
|
next_tvb = tvb_new_subset(tvb, offset, -1, tvb_reported_length(tvb)-offset);
|
|
|
|
sub_dissector_result = call_dissector_only(protocol_handle, next_tvb, pinfo, tree);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (protocol_handle == 0 || sub_dissector_result == 0)
|
|
|
|
{
|
|
|
|
/* Could get here because:
|
|
|
|
- encap is DCT2000_ENCAP_UNHANDLED, OR
|
|
|
|
- desired protocol is unavailable (probably disabled), OR
|
|
|
|
- protocol rejected our data
|
|
|
|
Show remaining bytes as unparsed data */
|
|
|
|
proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_unparsed_data,
|
|
|
|
tvb, offset, -1, FALSE);
|
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
{
|
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO,
|
2006-06-11 08:26:55 +00:00
|
|
|
"Unparsed protocol data (context=%s.%u t=%s %c prot=%s (v=%s))",
|
2006-04-14 13:12:13 +00:00
|
|
|
tvb_get_ephemeral_string(tvb, 0, context_length),
|
|
|
|
port_number,
|
|
|
|
tvb_get_ephemeral_string(tvb, timestamp_start, timestamp_length),
|
|
|
|
(direction == 0) ? 'S' : 'R',
|
2006-05-23 05:48:00 +00:00
|
|
|
tvb_get_ephemeral_string(tvb, protocol_start, protocol_length),
|
2006-06-11 08:26:55 +00:00
|
|
|
tvb_get_ephemeral_string(tvb, variant_start, variant_length));
|
2006-04-14 13:12:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/* Associate this protocol with the Catapult DCT2000 file encapsulation type. */
|
|
|
|
/******************************************************************************/
|
|
|
|
void proto_reg_handoff_catapult_dct2000(void)
|
|
|
|
{
|
|
|
|
dissector_handle_t catapult_dct2000_handle = find_dissector("dct2000");
|
|
|
|
dissector_add("wtap_encap", WTAP_ENCAP_CATAPULT_DCT2000,
|
|
|
|
catapult_dct2000_handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************/
|
|
|
|
/* Register the protocol */
|
|
|
|
/****************************************/
|
|
|
|
void proto_register_catapult_dct2000(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] =
|
|
|
|
{
|
|
|
|
{ &hf_catapult_dct2000_context,
|
|
|
|
{ "Context",
|
|
|
|
"dct2000.context", FT_STRING, BASE_NONE, NULL, 0x0,
|
|
|
|
"Context name", HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ &hf_catapult_dct2000_port_number,
|
|
|
|
{ "Context Port number",
|
|
|
|
"dct2000.context_port", FT_UINT8, BASE_DEC, NULL, 0x0,
|
|
|
|
"Context port number", HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ &hf_catapult_dct2000_timestamp,
|
|
|
|
{ "Timestamp",
|
|
|
|
"dct2000.timestamp", FT_STRING, BASE_NONE, NULL, 0x0,
|
|
|
|
"File timestamp", HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ &hf_catapult_dct2000_protocol,
|
|
|
|
{ "DCT2000 protocol",
|
|
|
|
"dct2000.protocol", FT_STRING, BASE_NONE, NULL, 0x0,
|
|
|
|
"Original (DCT2000) protocol name", HFILL
|
|
|
|
}
|
|
|
|
},
|
2006-05-23 05:48:00 +00:00
|
|
|
{ &hf_catapult_dct2000_variant,
|
|
|
|
{ "Protocol variant",
|
2006-06-11 08:26:55 +00:00
|
|
|
"dct2000.variant", FT_STRING, BASE_NONE, NULL, 0x0,
|
2006-05-23 05:48:00 +00:00
|
|
|
"DCT2000 protocol variant", HFILL
|
|
|
|
}
|
|
|
|
},
|
2006-08-02 09:30:28 +00:00
|
|
|
{ &hf_catapult_dct2000_outhdr,
|
|
|
|
{ "Out-header",
|
|
|
|
"dct2000.outhdr", FT_STRING, BASE_NONE, NULL, 0x0,
|
|
|
|
"DCT2000 protocol outhdr", HFILL
|
|
|
|
}
|
|
|
|
},
|
2006-04-14 13:12:13 +00:00
|
|
|
{ &hf_catapult_dct2000_direction,
|
|
|
|
{ "Direction",
|
|
|
|
"dct2000.direction", FT_UINT8, BASE_DEC, VALS(direction_vals), 0x0,
|
|
|
|
"Frame direction (Sent or Received)", HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ &hf_catapult_dct2000_encap,
|
2006-05-21 04:49:01 +00:00
|
|
|
{ "Wireshark encapsulation",
|
2006-04-14 13:12:13 +00:00
|
|
|
"dct2000.encapsulation", FT_UINT8, BASE_DEC, VALS(encap_vals), 0x0,
|
2006-05-21 04:49:01 +00:00
|
|
|
"Wireshark encapsulation used", HFILL
|
2006-04-14 13:12:13 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{ &hf_catapult_dct2000_unparsed_data,
|
|
|
|
{ "Unparsed protocol data",
|
|
|
|
"dct2000.unparsed_data", FT_BYTES, BASE_NONE, NULL, 0x0,
|
|
|
|
"Unparsed DCT2000 protocol data", HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] =
|
|
|
|
{
|
|
|
|
&ett_catapult_dct2000
|
|
|
|
};
|
|
|
|
|
|
|
|
module_t *catapult_dct2000_module;
|
|
|
|
|
|
|
|
/* Register protocol. */
|
|
|
|
proto_catapult_dct2000 = proto_register_protocol("DCT2000", "DCT2000", "dct2000");
|
|
|
|
proto_register_field_array(proto_catapult_dct2000, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
|
|
|
|
/* Allow dissector to find be found by name. */
|
|
|
|
register_dissector("dct2000", dissect_catapult_dct2000, proto_catapult_dct2000);
|
|
|
|
|
|
|
|
/* Preferences */
|
2006-04-17 18:46:14 +00:00
|
|
|
catapult_dct2000_module = prefs_register_protocol(proto_catapult_dct2000,
|
|
|
|
proto_reg_handoff_catapult_dct2000);
|
2006-04-14 13:12:13 +00:00
|
|
|
|
2006-08-02 09:30:28 +00:00
|
|
|
/* This preference no longer supported (introduces linkage dependency between
|
|
|
|
dissectors and wiretap */
|
|
|
|
prefs_register_obsolete_preference(catapult_dct2000_module, "board_ports_only");
|
2006-05-23 05:48:00 +00:00
|
|
|
|
|
|
|
/* Determines whether for not-handled protocols we should try to parse it if:
|
|
|
|
- it looks like its embedded in an ipprim message, AND
|
2006-05-28 19:49:07 +00:00
|
|
|
- the DCT2000 protocol name matches an wireshark dissector name */
|
2006-05-23 05:48:00 +00:00
|
|
|
prefs_register_bool_preference(catapult_dct2000_module, "ipprim_heuristic",
|
|
|
|
"Use IP Primitive heuristic",
|
|
|
|
"If a payload looks like its embedded in an "
|
2006-08-02 09:30:28 +00:00
|
|
|
"IP primitive message, and there is an wireshark "
|
2006-05-23 05:48:00 +00:00
|
|
|
"dissector matching the DCT2000 protocol name, "
|
|
|
|
"try parsing the payload using that dissector",
|
|
|
|
&catapult_dct2000_try_ipprim_heuristic);
|
2006-08-02 09:30:28 +00:00
|
|
|
|
|
|
|
/* Determines whether for not-handled protocols we should try to parse it if:
|
|
|
|
- it looks like its embedded in an sctpprim message, AND
|
|
|
|
- the DCT2000 protocol name matches an wireshark dissector name */
|
|
|
|
prefs_register_bool_preference(catapult_dct2000_module, "sctpprim_heuristic",
|
|
|
|
"Use SCTP Primitive heuristic",
|
|
|
|
"If a payload looks like its embedded in an "
|
|
|
|
"SCTP primitive message, and there is an wireshark "
|
|
|
|
"dissector matching the DCT2000 protocol name, "
|
|
|
|
"try parsing the payload using that dissector",
|
|
|
|
&catapult_dct2000_try_sctpprim_heuristic);
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-14 13:12:13 +00:00
|
|
|
}
|
|
|
|
|