2004-04-13 04:36:20 +00:00
|
|
|
/* packet-sndcp.c
|
|
|
|
* Routines for Subnetwork Dependent Convergence Protocol (SNDCP) dissection
|
|
|
|
* Copyright 2000, Christian Falckenberg <christian.falckenberg@nortelnetworks.com>
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2004-04-13 04:36:20 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2004-04-13 04:36:20 +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.
|
2011-02-07 18:49:29 +00:00
|
|
|
*
|
2004-04-13 04:36:20 +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.
|
2011-02-07 18:49:29 +00:00
|
|
|
*
|
2004-04-13 04:36:20 +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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
2005-02-09 23:38:00 +00:00
|
|
|
#include <epan/reassemble.h>
|
2004-04-13 04:36:20 +00:00
|
|
|
|
|
|
|
/* Bitmasks for the bits in the address field
|
|
|
|
*/
|
|
|
|
#define MASK_X 0x80
|
|
|
|
#define MASK_F 0x40
|
|
|
|
#define MASK_T 0x20
|
|
|
|
#define MASK_M 0x10
|
|
|
|
|
2011-02-07 18:49:29 +00:00
|
|
|
/* Initialize the protocol and registered fields
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
|
|
|
static int proto_sndcp = -1;
|
|
|
|
static int hf_sndcp_x = -1;
|
|
|
|
static int hf_sndcp_f = -1;
|
|
|
|
static int hf_sndcp_t = -1;
|
|
|
|
static int hf_sndcp_m = -1;
|
|
|
|
static int hf_sndcp_nsapi = -1;
|
|
|
|
static int hf_sndcp_nsapib = -1;
|
|
|
|
static int hf_sndcp_dcomp = -1;
|
|
|
|
static int hf_sndcp_pcomp = -1;
|
|
|
|
static int hf_sndcp_segment = -1;
|
|
|
|
static int hf_sndcp_npdu1 = -1;
|
|
|
|
static int hf_sndcp_npdu2 = -1;
|
|
|
|
|
2011-02-07 18:49:29 +00:00
|
|
|
/* These fields are used when reassembling N-PDU fragments
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
2011-02-07 18:49:29 +00:00
|
|
|
static int hf_npdu_fragments = -1;
|
|
|
|
static int hf_npdu_fragment = -1;
|
|
|
|
static int hf_npdu_fragment_overlap = -1;
|
|
|
|
static int hf_npdu_fragment_overlap_conflict = -1;
|
|
|
|
static int hf_npdu_fragment_multiple_tails = -1;
|
|
|
|
static int hf_npdu_fragment_too_long_fragment = -1;
|
|
|
|
static int hf_npdu_fragment_error = -1;
|
|
|
|
static int hf_npdu_fragment_count = -1;
|
|
|
|
static int hf_npdu_reassembled_in = -1;
|
|
|
|
static int hf_npdu_reassembled_length = -1;
|
|
|
|
|
|
|
|
/* Initialize the subtree pointers
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
|
|
|
static gint ett_sndcp = -1;
|
|
|
|
static gint ett_sndcp_address_field = -1;
|
|
|
|
static gint ett_sndcp_compression_field = -1;
|
|
|
|
static gint ett_sndcp_npdu_field = -1;
|
|
|
|
static gint ett_npdu_fragment = -1;
|
|
|
|
static gint ett_npdu_fragments = -1;
|
|
|
|
|
|
|
|
/* Structure needed for the fragmentation routines in reassemble.c
|
|
|
|
*/
|
|
|
|
static const fragment_items npdu_frag_items = {
|
|
|
|
&ett_npdu_fragment,
|
|
|
|
&ett_npdu_fragments,
|
|
|
|
&hf_npdu_fragments,
|
|
|
|
&hf_npdu_fragment,
|
|
|
|
&hf_npdu_fragment_overlap,
|
|
|
|
&hf_npdu_fragment_overlap_conflict,
|
|
|
|
&hf_npdu_fragment_multiple_tails,
|
|
|
|
&hf_npdu_fragment_too_long_fragment,
|
|
|
|
&hf_npdu_fragment_error,
|
2011-01-30 21:01:07 +00:00
|
|
|
&hf_npdu_fragment_count,
|
2004-04-13 04:36:20 +00:00
|
|
|
&hf_npdu_reassembled_in,
|
2010-02-02 16:01:52 +00:00
|
|
|
&hf_npdu_reassembled_length,
|
2004-04-13 04:36:20 +00:00
|
|
|
"fragments"
|
|
|
|
};
|
|
|
|
|
|
|
|
/* dissectors for the data portion of this protocol
|
|
|
|
*/
|
|
|
|
static dissector_handle_t data_handle;
|
|
|
|
static dissector_handle_t ip_handle;
|
|
|
|
|
|
|
|
/* reassembly of N-PDU
|
|
|
|
*/
|
2011-02-07 18:49:29 +00:00
|
|
|
static GHashTable *npdu_fragment_table = NULL;
|
|
|
|
static GHashTable *sndcp_reassembled_table = NULL;
|
2007-09-11 16:59:57 +00:00
|
|
|
|
2004-04-13 04:36:20 +00:00
|
|
|
static void
|
|
|
|
sndcp_defragment_init(void)
|
|
|
|
{
|
|
|
|
fragment_table_init(&npdu_fragment_table);
|
2007-09-11 16:59:57 +00:00
|
|
|
reassembled_table_init(&sndcp_reassembled_table);
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* value strings
|
|
|
|
*/
|
|
|
|
static const value_string nsapi_t[] = {
|
2011-02-07 18:49:29 +00:00
|
|
|
{ 0, "Escape mechanism for future extensions"},
|
|
|
|
{ 1, "Point-to-Multipoint (PTM-M) Information" },
|
|
|
|
{ 2, "Reserved for future use" },
|
|
|
|
{ 3, "Reserved for future use" },
|
|
|
|
{ 4, "Reserved for future use" },
|
|
|
|
{ 5, "Dynamically allocated"},
|
|
|
|
{ 6, "Dynamically allocated"},
|
|
|
|
{ 7, "Dynamically allocated"},
|
|
|
|
{ 8, "Dynamically allocated"},
|
|
|
|
{ 9, "Dynamically allocated"},
|
|
|
|
{ 10, "Dynamically allocated"},
|
|
|
|
{ 11, "Dynamically allocated"},
|
|
|
|
{ 12, "Dynamically allocated"},
|
|
|
|
{ 13, "Dynamically allocated"},
|
|
|
|
{ 14, "Dynamically allocated"},
|
|
|
|
{ 15, "Dynamically allocated"},
|
|
|
|
{ 0, NULL },
|
2004-04-13 04:36:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string nsapi_abrv[] = {
|
2011-02-07 18:49:29 +00:00
|
|
|
{ 0, "0"},
|
|
|
|
{ 1, "PTM-M" },
|
|
|
|
{ 2, "2" },
|
|
|
|
{ 3, "3"},
|
|
|
|
{ 4, "4" },
|
|
|
|
{ 5, "DYN5" },
|
|
|
|
{ 6, "DYN6" },
|
|
|
|
{ 7, "DYN7" },
|
|
|
|
{ 8, "DYN8" },
|
|
|
|
{ 9, "DYN9" },
|
|
|
|
{ 10, "DYN10" },
|
|
|
|
{ 11, "DYN11" },
|
|
|
|
{ 12, "DYN12" },
|
|
|
|
{ 13, "DYN13" },
|
|
|
|
{ 14, "DYN14" },
|
|
|
|
{ 15, "DYN15" },
|
|
|
|
{ 0, NULL },
|
2004-04-13 04:36:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string compression_vals[] = {
|
2011-02-07 18:49:29 +00:00
|
|
|
{ 0, "No compression"},
|
|
|
|
{ 1, "Pointer to selected protocol/data compression mechanism" },
|
|
|
|
{ 2, "Pointer to selected protocol/data compression mechanism" },
|
|
|
|
{ 3, "Pointer to selected protocol/data compression mechanism" },
|
|
|
|
{ 4, "Pointer to selected protocol/data compression mechanism" },
|
|
|
|
{ 5, "Pointer to selected protocol/data compression mechanism" },
|
|
|
|
{ 6, "Pointer to selected protocol/data compression mechanism" },
|
|
|
|
{ 7, "Pointer to selected protocol/data compression mechanism" },
|
|
|
|
{ 8, "Pointer to selected protocol/data compression mechanism" },
|
|
|
|
{ 9, "Pointer to selected protocol/data compression mechanism" },
|
|
|
|
{ 10, "Pointer to selected protocol/data compression mechanism" },
|
|
|
|
{ 11, "Pointer to selected protocol/data compression mechanism" },
|
|
|
|
{ 12, "Pointer to selected protocol/data compression mechanism" },
|
|
|
|
{ 13, "Pointer to selected protocol/data compression mechanism" },
|
|
|
|
{ 14, "Pointer to selected protocol/data compression mechanism" },
|
|
|
|
{ 15, "Pointer to selected protocol/data compression mechanism" },
|
|
|
|
{ 0, NULL },
|
2004-04-13 04:36:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const true_false_string x_bit = {
|
|
|
|
"Invalid",
|
|
|
|
"Set to 0 by transmitting SNDCP entity (ignored by receiver)"
|
|
|
|
};
|
|
|
|
static const true_false_string f_bit = {
|
|
|
|
"This SN-PDU is the first segment of an N-PDU",
|
|
|
|
"This SN-PDU is not the first segment of an N-PDU"
|
|
|
|
};
|
|
|
|
static const true_false_string t_bit = {
|
|
|
|
"SN-UNITDATA PDU",
|
|
|
|
"SN-DATA PDU"
|
|
|
|
};
|
|
|
|
static const true_false_string m_bit = {
|
|
|
|
"Not the last segment of N-PDU, more segments to follow",
|
|
|
|
"Last segment of N-PDU"
|
|
|
|
};
|
|
|
|
|
2011-02-07 18:49:29 +00:00
|
|
|
/* Code to actually dissect the packets
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
dissect_sndcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
guint8 addr_field, comp_field, npdu_field1, nsapi, dcomp=0, pcomp=0;
|
|
|
|
guint16 offset=0, npdu=0, segment=0, npdu_field2;
|
2011-02-07 18:49:29 +00:00
|
|
|
tvbuff_t *next_tvb, *npdu_tvb;
|
2006-03-08 09:43:06 +00:00
|
|
|
gint len;
|
2004-04-13 04:36:20 +00:00
|
|
|
gboolean first, more_frags, unack;
|
|
|
|
|
2011-02-07 18:49:29 +00:00
|
|
|
/* Set up structures needed to add the protocol subtree and manage it
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
|
|
|
proto_item *ti, *address_field_item, *compression_field_item, *npdu_field_item;
|
|
|
|
proto_tree *sndcp_tree = NULL, *address_field_tree, *compression_field_tree, *npdu_field_tree;
|
|
|
|
|
2011-02-07 18:49:29 +00:00
|
|
|
/* Make entries in Protocol column and clear Info column on summary display
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SNDCP");
|
2009-08-09 07:36:13 +00:00
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2011-02-07 18:49:29 +00:00
|
|
|
|
|
|
|
/* create display subtree for the protocol
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
|
|
|
if (tree) {
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_sndcp, tvb, 0, -1, ENC_NA);
|
2004-04-13 04:36:20 +00:00
|
|
|
sndcp_tree = proto_item_add_subtree(ti, ett_sndcp);
|
|
|
|
}
|
2011-02-07 18:49:29 +00:00
|
|
|
|
2004-04-13 04:36:20 +00:00
|
|
|
/* get address field from next byte
|
|
|
|
*/
|
|
|
|
addr_field = tvb_get_guint8(tvb,offset);
|
|
|
|
nsapi = addr_field & 0xF;
|
|
|
|
first = addr_field & MASK_F;
|
|
|
|
more_frags = addr_field & MASK_M;
|
|
|
|
unack = addr_field & MASK_T;
|
|
|
|
|
2011-02-07 18:49:29 +00:00
|
|
|
/* add subtree for the address field
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
|
|
|
if (tree) {
|
|
|
|
address_field_item = proto_tree_add_uint_format(sndcp_tree,hf_sndcp_nsapi,
|
2011-02-07 18:49:29 +00:00
|
|
|
tvb, offset,1, nsapi,
|
|
|
|
"Address field NSAPI: %d", nsapi );
|
2004-04-13 04:36:20 +00:00
|
|
|
address_field_tree = proto_item_add_subtree(address_field_item, ett_sndcp_address_field);
|
|
|
|
proto_tree_add_boolean(address_field_tree, hf_sndcp_x, tvb,offset,1, addr_field );
|
|
|
|
proto_tree_add_boolean(address_field_tree, hf_sndcp_f, tvb,offset,1, addr_field );
|
|
|
|
proto_tree_add_boolean(address_field_tree, hf_sndcp_t, tvb,offset,1, addr_field );
|
|
|
|
proto_tree_add_boolean(address_field_tree, hf_sndcp_m, tvb,offset,1, addr_field );
|
2011-02-07 18:49:29 +00:00
|
|
|
proto_tree_add_uint(address_field_tree, hf_sndcp_nsapib, tvb, offset, 1, addr_field );
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
/* get compression pointers from next byte if this is the first segment
|
|
|
|
*/
|
|
|
|
if (first) {
|
|
|
|
comp_field = tvb_get_guint8(tvb,offset);
|
|
|
|
dcomp = comp_field & 0xF0;
|
|
|
|
pcomp = comp_field & 0x0F;
|
2011-02-07 18:49:29 +00:00
|
|
|
|
|
|
|
/* add subtree for the compression field
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
|
|
|
if (tree) {
|
2011-02-07 18:49:29 +00:00
|
|
|
if (!pcomp) {
|
|
|
|
if (!dcomp) {
|
|
|
|
compression_field_item = proto_tree_add_text(sndcp_tree, tvb, offset,1, "No compression");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
compression_field_item = proto_tree_add_text(sndcp_tree, tvb, offset,1, "Data compression");
|
|
|
|
}
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
2011-02-07 18:49:29 +00:00
|
|
|
else {
|
|
|
|
if (!dcomp) {
|
|
|
|
compression_field_item = proto_tree_add_text(sndcp_tree, tvb, offset,1, "Protocol compression");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
compression_field_item = proto_tree_add_text(sndcp_tree, tvb, offset,1, "Data and Protocol compression");
|
|
|
|
}
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
compression_field_tree = proto_item_add_subtree(compression_field_item, ett_sndcp_compression_field);
|
|
|
|
proto_tree_add_uint(compression_field_tree, hf_sndcp_dcomp, tvb, offset, 1, comp_field );
|
|
|
|
proto_tree_add_uint(compression_field_tree, hf_sndcp_pcomp, tvb, offset, 1, comp_field );
|
|
|
|
}
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
/* get N-PDU number from next byte for acknowledged mode (only for first segment)
|
|
|
|
*/
|
|
|
|
if (!unack) {
|
|
|
|
npdu = npdu_field1 = tvb_get_guint8(tvb,offset);
|
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
2011-02-07 18:49:29 +00:00
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "SN-DATA N-PDU %d", npdu_field1);
|
2004-04-13 04:36:20 +00:00
|
|
|
if (tree) {
|
2011-02-07 18:49:29 +00:00
|
|
|
npdu_field_item = proto_tree_add_text(sndcp_tree, tvb, offset,1, "Acknowledged mode, N-PDU %d", npdu_field1 );
|
|
|
|
npdu_field_tree = proto_item_add_subtree(npdu_field_item, ett_sndcp_npdu_field);
|
|
|
|
proto_tree_add_uint(npdu_field_tree, hf_sndcp_npdu1, tvb, offset, 1, npdu_field1 );
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
2005-11-28 10:28:31 +00:00
|
|
|
offset++;
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-07 18:49:29 +00:00
|
|
|
/* get segment and N-PDU number from next two bytes for unacknowledged mode
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
|
|
|
if (unack) {
|
|
|
|
npdu_field2 = tvb_get_ntohs(tvb, offset);
|
|
|
|
segment = (npdu_field2 & 0xF000) >> 12;
|
|
|
|
npdu = (npdu_field2 & 0x0FFF);
|
2011-02-07 18:49:29 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
2004-04-13 04:36:20 +00:00
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "SN-UNITDATA N-PDU %d (segment %d)", npdu, segment);
|
|
|
|
if (tree) {
|
|
|
|
npdu_field_item = proto_tree_add_text(sndcp_tree, tvb, offset,2, "Unacknowledged mode, N-PDU %d (segment %d)", npdu, segment );
|
|
|
|
npdu_field_tree = proto_item_add_subtree(npdu_field_item, ett_sndcp_npdu_field);
|
|
|
|
proto_tree_add_uint(npdu_field_tree, hf_sndcp_segment, tvb, offset, 2, npdu_field2 );
|
|
|
|
proto_tree_add_uint(npdu_field_tree, hf_sndcp_npdu2, tvb, offset, 2, npdu_field2 );
|
|
|
|
}
|
|
|
|
offset += 2;
|
|
|
|
}
|
|
|
|
|
2011-02-07 18:49:29 +00:00
|
|
|
/* handle N-PDU data, reassemble if necessary
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
|
|
|
if (first && !more_frags) {
|
2009-08-16 12:36:22 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining (tvb, offset);
|
2011-02-07 18:49:29 +00:00
|
|
|
|
2004-04-13 04:36:20 +00:00
|
|
|
if (!dcomp && !pcomp) {
|
|
|
|
call_dissector(ip_handle, next_tvb, pinfo, tree);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
call_dissector(data_handle, next_tvb, pinfo, tree);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2011-02-07 18:49:29 +00:00
|
|
|
/* Try reassembling fragments
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
|
|
|
fragment_data *fd_npdu = NULL;
|
|
|
|
guint32 reassembled_in = 0;
|
|
|
|
gboolean save_fragmented = pinfo->fragmented;
|
2011-02-07 18:49:29 +00:00
|
|
|
|
2004-04-13 04:36:20 +00:00
|
|
|
len = tvb_length_remaining(tvb, offset);
|
2006-03-08 09:43:06 +00:00
|
|
|
if(len<=0){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-04-13 04:36:20 +00:00
|
|
|
pinfo->fragmented = TRUE;
|
|
|
|
|
2011-02-07 18:49:29 +00:00
|
|
|
if (unack)
|
2007-09-11 16:59:57 +00:00
|
|
|
fd_npdu = fragment_add_seq_check(tvb, offset, pinfo, npdu,
|
2011-02-07 18:49:29 +00:00
|
|
|
npdu_fragment_table, sndcp_reassembled_table, segment, len, more_frags);
|
2004-04-13 04:36:20 +00:00
|
|
|
else
|
|
|
|
fd_npdu = fragment_add(tvb, offset, pinfo, npdu,
|
2011-02-07 18:49:29 +00:00
|
|
|
npdu_fragment_table, offset, len, more_frags);
|
2004-04-13 04:36:20 +00:00
|
|
|
|
|
|
|
npdu_tvb = process_reassembled_data(tvb, offset, pinfo,
|
2011-02-07 18:49:29 +00:00
|
|
|
"Reassembled N-PDU", fd_npdu, &npdu_frag_items,
|
|
|
|
NULL, sndcp_tree);
|
2004-04-13 04:36:20 +00:00
|
|
|
if (fd_npdu) {
|
2011-02-07 18:49:29 +00:00
|
|
|
/* Reassembled
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
|
|
|
reassembled_in = fd_npdu->reassembled_in;
|
|
|
|
if (pinfo->fd->num == reassembled_in) {
|
2011-02-07 18:49:29 +00:00
|
|
|
/* Reassembled in this very packet:
|
|
|
|
* We can safely hand the tvb to the IP dissector
|
|
|
|
*/
|
|
|
|
call_dissector(ip_handle, npdu_tvb, pinfo, tree);
|
|
|
|
}
|
2004-04-13 04:36:20 +00:00
|
|
|
else {
|
2011-02-07 18:49:29 +00:00
|
|
|
/* Not reassembled in this packet
|
|
|
|
*/
|
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)) {
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO,
|
|
|
|
" (N-PDU payload reassembled in packet %u)",
|
|
|
|
fd_npdu->reassembled_in);
|
|
|
|
}
|
|
|
|
if (tree) {
|
|
|
|
proto_tree_add_text(sndcp_tree, tvb, offset, -1, "Payload");
|
|
|
|
}
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
} else {
|
2011-02-07 18:49:29 +00:00
|
|
|
/* Not reassembled yet, or not reassembled at all
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)) {
|
2011-02-07 18:49:29 +00:00
|
|
|
if (unack)
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, " (Unreassembled fragment %u)", segment);
|
|
|
|
else
|
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, " (Unreassembled fragment)");
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
if (tree) {
|
2011-02-07 18:49:29 +00:00
|
|
|
proto_tree_add_text(sndcp_tree, tvb, offset, -1, "Payload");
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-07 18:49:29 +00:00
|
|
|
/* Now reset fragmentation information in pinfo
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
|
|
|
pinfo->fragmented = save_fragmented;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-07 18:49:29 +00:00
|
|
|
/* Register the protocol with Wireshark
|
2004-04-13 04:36:20 +00:00
|
|
|
this format is required because a script is used to build the C function
|
|
|
|
that calls all the protocol registration.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_sndcp(void)
|
2011-02-07 18:49:29 +00:00
|
|
|
{
|
2004-04-13 04:36:20 +00:00
|
|
|
/* Setup list of header fields
|
|
|
|
*/
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_sndcp_nsapi,
|
2011-02-07 18:49:29 +00:00
|
|
|
{ "NSAPI",
|
|
|
|
"sndcp.nsapi",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(nsapi_abrv), 0x0,
|
|
|
|
"Network Layer Service Access Point Identifier", HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
2011-02-07 18:49:29 +00:00
|
|
|
{ &hf_sndcp_x,
|
2004-04-13 04:36:20 +00:00
|
|
|
{ "Spare bit",
|
2011-02-07 18:49:29 +00:00
|
|
|
"sndcp.x",
|
|
|
|
FT_BOOLEAN,8, TFS(&x_bit), MASK_X,
|
|
|
|
"Spare bit (should be 0)", HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
2011-02-07 18:49:29 +00:00
|
|
|
{ &hf_sndcp_f,
|
|
|
|
{ "First segment indicator bit",
|
|
|
|
"sndcp.f",
|
|
|
|
FT_BOOLEAN,8, TFS(&f_bit), MASK_F,
|
|
|
|
NULL, HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
2011-02-07 18:49:29 +00:00
|
|
|
{ &hf_sndcp_t,
|
|
|
|
{ "Type",
|
|
|
|
"sndcp.t",
|
|
|
|
FT_BOOLEAN,8, TFS(&t_bit), MASK_T,
|
|
|
|
"SN-PDU Type", HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
2011-02-07 18:49:29 +00:00
|
|
|
{ &hf_sndcp_m,
|
|
|
|
{ "More bit",
|
|
|
|
"sndcp.m",
|
|
|
|
FT_BOOLEAN,8, TFS(&m_bit), MASK_M,
|
|
|
|
NULL, HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
2011-02-07 18:49:29 +00:00
|
|
|
{ &hf_sndcp_dcomp,
|
|
|
|
{ "DCOMP",
|
|
|
|
"sndcp.dcomp",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(compression_vals), 0xF0,
|
|
|
|
"Data compression coding", HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
2011-02-07 18:49:29 +00:00
|
|
|
{ &hf_sndcp_pcomp,
|
|
|
|
{ "PCOMP",
|
|
|
|
"sndcp.pcomp",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(compression_vals), 0x0F,
|
|
|
|
"Protocol compression coding", HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{ &hf_sndcp_nsapib,
|
2011-02-07 18:49:29 +00:00
|
|
|
{ "NSAPI",
|
|
|
|
"sndcp.nsapib",
|
|
|
|
FT_UINT8, BASE_DEC , VALS(nsapi_t), 0xf,
|
|
|
|
"Network Layer Service Access Point Identifier",HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
2011-02-07 18:49:29 +00:00
|
|
|
},
|
|
|
|
{ &hf_sndcp_segment,
|
|
|
|
{ "Segment",
|
|
|
|
"sndcp.segment",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0xF000,
|
|
|
|
"Segment number", HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
2011-02-07 18:49:29 +00:00
|
|
|
{ &hf_sndcp_npdu1,
|
|
|
|
{ "N-PDU",
|
|
|
|
"sndcp.npdu",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0,
|
|
|
|
NULL, HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
2011-02-07 18:49:29 +00:00
|
|
|
{ &hf_sndcp_npdu2,
|
|
|
|
{ "N-PDU",
|
|
|
|
"sndcp.npdu",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0FFF,
|
|
|
|
NULL, HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-02-07 18:49:29 +00:00
|
|
|
/* Fragment fields
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
|
|
|
{ &hf_npdu_fragment_overlap,
|
2011-02-07 18:49:29 +00:00
|
|
|
{ "Fragment overlap",
|
|
|
|
"npdu.fragment.overlap",
|
|
|
|
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
|
|
|
|
"Fragment overlaps with other fragments", HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{ &hf_npdu_fragment_overlap_conflict,
|
2011-02-07 18:49:29 +00:00
|
|
|
{ "Conflicting data in fragment overlap",
|
|
|
|
"npdu.fragment.overlap.conflict",
|
|
|
|
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
|
|
|
|
"Overlapping fragments contained conflicting data", HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{ &hf_npdu_fragment_multiple_tails,
|
2011-02-07 18:49:29 +00:00
|
|
|
{ "Multiple tail fragments found",
|
|
|
|
"npdu.fragment.multipletails",
|
|
|
|
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
|
|
|
|
"Several tails were found when defragmenting the packet", HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{ &hf_npdu_fragment_too_long_fragment,
|
2011-02-07 18:49:29 +00:00
|
|
|
{ "Fragment too long",
|
|
|
|
"npdu.fragment.toolongfragment",
|
|
|
|
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
|
|
|
|
"Fragment contained data past end of packet", HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{ &hf_npdu_fragment_error,
|
2011-02-07 18:49:29 +00:00
|
|
|
{ "Defragmentation error",
|
|
|
|
"npdu.fragment.error",
|
|
|
|
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
|
|
|
|
"Defragmentation error due to illegal fragments", HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
2011-01-30 21:01:07 +00:00
|
|
|
{ &hf_npdu_fragment_count,
|
2011-02-07 18:49:29 +00:00
|
|
|
{ "Fragment count",
|
|
|
|
"npdu.fragment.count",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0,
|
|
|
|
NULL, HFILL
|
2011-01-30 21:01:07 +00:00
|
|
|
}
|
|
|
|
},
|
2004-04-13 04:36:20 +00:00
|
|
|
{ &hf_npdu_reassembled_in,
|
2011-02-07 18:49:29 +00:00
|
|
|
{ "Reassembled in",
|
|
|
|
"npdu.reassembled.in",
|
|
|
|
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
|
|
|
|
"N-PDU fragments are reassembled in the given packet", HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
2010-02-02 16:01:52 +00:00
|
|
|
{ &hf_npdu_reassembled_length,
|
2011-02-07 18:49:29 +00:00
|
|
|
{ "Reassembled N-PDU length",
|
|
|
|
"npdu.reassembled.length",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0,
|
|
|
|
"The total length of the reassembled payload", HFILL
|
2010-02-02 16:01:52 +00:00
|
|
|
}
|
|
|
|
},
|
2004-04-13 04:36:20 +00:00
|
|
|
{ &hf_npdu_fragment,
|
2011-02-07 18:49:29 +00:00
|
|
|
{ "N-PDU Fragment",
|
|
|
|
"npdu.fragment",
|
|
|
|
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
|
|
|
|
NULL, HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{ &hf_npdu_fragments,
|
2011-02-07 18:49:29 +00:00
|
|
|
{ "N-PDU Fragments",
|
|
|
|
"npdu.fragments",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
NULL, HFILL
|
2004-04-13 04:36:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2011-02-07 18:49:29 +00:00
|
|
|
|
2004-04-13 04:36:20 +00:00
|
|
|
/* Setup protocol subtree array */
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_sndcp ,
|
|
|
|
&ett_sndcp_address_field,
|
|
|
|
&ett_sndcp_compression_field,
|
|
|
|
&ett_sndcp_npdu_field,
|
|
|
|
&ett_npdu_fragment,
|
|
|
|
&ett_npdu_fragments,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Register the protocol name and description */
|
|
|
|
proto_sndcp = proto_register_protocol("Subnetwork Dependent Convergence Protocol",
|
2011-02-07 18:49:29 +00:00
|
|
|
"SNDCP", "sndcp");
|
2004-04-13 04:36:20 +00:00
|
|
|
|
|
|
|
/* Required function calls to register the header fields and subtrees used */
|
|
|
|
proto_register_field_array(proto_sndcp, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
register_dissector("sndcp", dissect_sndcp, proto_sndcp);
|
|
|
|
register_init_routine(sndcp_defragment_init);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If this dissector uses sub-dissector registration add a registration routine.
|
|
|
|
This format is required because a script is used to find these routines and
|
|
|
|
create the code that calls these routines.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
proto_reg_handoff_sndcp(void)
|
|
|
|
{
|
|
|
|
dissector_handle_t sndcp_handle;
|
|
|
|
|
2011-02-07 18:49:29 +00:00
|
|
|
sndcp_handle = find_dissector("sndcp");
|
2004-04-13 04:36:20 +00:00
|
|
|
|
2011-02-07 18:49:29 +00:00
|
|
|
/* Register SNDCP dissector with LLC layer for SAPI 3,5,9 and 11
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("llcgprs.sapi", 3, sndcp_handle);
|
|
|
|
dissector_add_uint("llcgprs.sapi", 5, sndcp_handle);
|
|
|
|
dissector_add_uint("llcgprs.sapi", 9, sndcp_handle);
|
|
|
|
dissector_add_uint("llcgprs.sapi", 11, sndcp_handle);
|
2004-04-13 04:36:20 +00:00
|
|
|
|
2011-02-07 18:49:29 +00:00
|
|
|
/* Find IP and data handle for upper layer dissectors
|
2004-04-13 04:36:20 +00:00
|
|
|
*/
|
2011-02-07 18:49:29 +00:00
|
|
|
ip_handle = find_dissector("ip");
|
2004-04-13 04:36:20 +00:00
|
|
|
data_handle = find_dissector("data");
|
|
|
|
}
|