1999-11-19 07:28:16 +00:00
|
|
|
/* packet-sscop.c
|
|
|
|
* Routines for SSCOP (Q.2110, Q.SAAL) frame disassembly
|
|
|
|
* Guy Harris <guy@alum.mit.edu>
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
1999-11-19 07:28:16 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
1999-11-19 07:28:16 +00:00
|
|
|
* Copyright 1998
|
|
|
|
*
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-11-19 07:28:16 +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
|
|
|
*
|
1999-11-19 07:28:16 +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
|
|
|
*
|
1999-11-19 07:28:16 +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.
|
1999-11-19 07:28:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib.h>
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
2004-11-24 02:59:49 +00:00
|
|
|
#include <prefs.h>
|
2005-06-03 13:50:30 +00:00
|
|
|
#include "packet-sscop.h"
|
1999-11-19 07:28:16 +00:00
|
|
|
|
2007-01-28 01:41:58 +00:00
|
|
|
int proto_sscop = -1;
|
1999-11-19 07:28:16 +00:00
|
|
|
|
2005-06-03 13:50:30 +00:00
|
|
|
static int hf_sscop_type = -1;
|
|
|
|
static int hf_sscop_sq = -1;
|
|
|
|
static int hf_sscop_mr = -1;
|
|
|
|
static int hf_sscop_s = -1;
|
|
|
|
static int hf_sscop_ps = -1;
|
|
|
|
static int hf_sscop_r = -1;
|
|
|
|
static int hf_sscop_stat_s = -1;
|
2005-06-17 17:37:10 +00:00
|
|
|
static int hf_sscop_stat_count = -1;
|
2005-06-03 13:50:30 +00:00
|
|
|
|
1999-11-19 07:28:16 +00:00
|
|
|
static gint ett_sscop = -1;
|
2005-06-03 13:50:30 +00:00
|
|
|
static gint ett_stat = -1;
|
1999-11-19 07:28:16 +00:00
|
|
|
|
2001-05-27 07:15:26 +00:00
|
|
|
static dissector_handle_t q2931_handle;
|
2001-11-25 22:19:25 +00:00
|
|
|
static dissector_handle_t data_handle;
|
2004-11-24 02:59:49 +00:00
|
|
|
static dissector_handle_t sscf_nni_handle;
|
2007-01-28 01:41:58 +00:00
|
|
|
static dissector_handle_t alcap_handle;
|
|
|
|
static dissector_handle_t nbap_handle;
|
2004-11-24 02:59:49 +00:00
|
|
|
|
|
|
|
static module_t *sscop_module;
|
|
|
|
|
|
|
|
static range_t *global_udp_port_range;
|
|
|
|
|
|
|
|
static dissector_handle_t sscop_handle;
|
|
|
|
|
|
|
|
|
|
|
|
static enum_val_t sscop_payload_dissector_options[] = {
|
|
|
|
{ "data", "Data (no further dissection)", DATA_DISSECTOR },
|
2007-01-28 01:41:58 +00:00
|
|
|
{ "Q.2931", "Q.2931", Q2931_DISSECTOR },
|
2004-11-24 02:59:49 +00:00
|
|
|
{ "SSCF-NNI", "SSCF-NNI (MTP3-b)", SSCF_NNI_DISSECTOR },
|
2007-01-28 01:41:58 +00:00
|
|
|
{ "ALCAP", "ALCAP", ALCAP_DISSECTOR },
|
|
|
|
{ "NBAP", "NBAP", NBAP_DISSECTOR },
|
2004-11-24 02:59:49 +00:00
|
|
|
{ NULL, NULL, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint sscop_payload_dissector = Q2931_DISSECTOR;
|
2005-06-03 13:50:30 +00:00
|
|
|
static dissector_handle_t default_handle;
|
2001-05-27 07:15:26 +00:00
|
|
|
|
2005-06-17 17:37:10 +00:00
|
|
|
static sscop_info_t sscop_info;
|
1999-11-19 07:28:16 +00:00
|
|
|
/*
|
|
|
|
* See
|
|
|
|
*
|
|
|
|
* http://www.protocols.com/pbook/atmsig.htm
|
|
|
|
*
|
|
|
|
* for some information on SSCOP, although, alas, not the actual PDU
|
|
|
|
* type values - those I got from the FreeBSD 3.2 ATM code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SSCOP PDU types.
|
|
|
|
*/
|
|
|
|
#define SSCOP_TYPE_MASK 0x0f
|
|
|
|
|
|
|
|
#define SSCOP_BGN 0x01 /* Begin */
|
|
|
|
#define SSCOP_BGAK 0x02 /* Begin Acknowledge */
|
|
|
|
#define SSCOP_BGREJ 0x07 /* Begin Reject */
|
|
|
|
#define SSCOP_END 0x03 /* End */
|
|
|
|
#define SSCOP_ENDAK 0x04 /* End Acknowledge */
|
|
|
|
#define SSCOP_RS 0x05 /* Resynchronization */
|
|
|
|
#define SSCOP_RSAK 0x06 /* Resynchronization Acknowledge */
|
|
|
|
#define SSCOP_SD 0x08 /* Sequenced Data */
|
|
|
|
#define SSCOP_SDP 0x09 /* Sequenced Data with Poll */
|
|
|
|
#define SSCOP_POLL 0x0a /* Status Request */
|
|
|
|
#define SSCOP_STAT 0x0b /* Solicited Status Response */
|
|
|
|
#define SSCOP_USTAT 0x0c /* Unsolicited Status Response */
|
|
|
|
#define SSCOP_UD 0x0d /* Unnumbered Data */
|
|
|
|
#define SSCOP_MD 0x0e /* Management Data */
|
|
|
|
#define SSCOP_ER 0x09 /* Error Recovery */
|
|
|
|
#define SSCOP_ERAK 0x0f /* Error Acknowledge */
|
|
|
|
|
1999-11-23 07:19:14 +00:00
|
|
|
#define SSCOP_S 0x10 /* Source bit in End PDU */
|
|
|
|
|
1999-11-19 07:28:16 +00:00
|
|
|
/*
|
|
|
|
* XXX - how to distinguish SDP from ER?
|
|
|
|
*/
|
|
|
|
static const value_string sscop_type_vals[] = {
|
|
|
|
{ SSCOP_BGN, "Begin" },
|
|
|
|
{ SSCOP_BGAK, "Begin Acknowledge" },
|
|
|
|
{ SSCOP_BGREJ, "Begin Reject" },
|
|
|
|
{ SSCOP_END, "End" },
|
|
|
|
{ SSCOP_ENDAK, "End Acknowledge" },
|
|
|
|
{ SSCOP_RS, "Resynchronization" },
|
|
|
|
{ SSCOP_RSAK, "Resynchronization Acknowledge" },
|
|
|
|
{ SSCOP_SD, "Sequenced Data" },
|
|
|
|
#if 0
|
|
|
|
{ SSCOP_SDP, "Sequenced Data with Poll" },
|
|
|
|
#endif
|
|
|
|
{ SSCOP_POLL, "Status Request" },
|
|
|
|
{ SSCOP_STAT, "Solicited Status Response" },
|
|
|
|
{ SSCOP_USTAT, "Unsolicited Status Response" },
|
|
|
|
{ SSCOP_UD, "Unnumbered Data" },
|
|
|
|
{ SSCOP_MD, "Management Data" },
|
|
|
|
{ SSCOP_ER, "Error Recovery" },
|
|
|
|
{ SSCOP_ERAK, "Error Acknowledge" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The SSCOP "header" is a trailer, so the "offsets" are computed based
|
|
|
|
* on the length of the packet.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PDU type.
|
|
|
|
*/
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
#define SSCOP_PDU_TYPE (reported_length - 4) /* single byte */
|
1999-11-19 07:28:16 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Begin PDU, Begin Acknowledge PDU (no N(SQ) in it), Resynchronization
|
|
|
|
* PDU, Resynchronization Acknowledge PDU (no N(SQ) in it in Q.SAAL),
|
|
|
|
* Error Recovery PDU, Error Recovery Acknoledge PDU (no N(SQ) in it).
|
|
|
|
*/
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
#define SSCOP_N_SQ (reported_length - 5) /* One byte */
|
|
|
|
#define SSCOP_N_MR (reported_length - 4) /* lower 3 bytes thereof */
|
1999-11-19 07:28:16 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sequenced Data PDU (no N(PS) in it), Sequenced Data with Poll PDU,
|
|
|
|
* Poll PDU.
|
|
|
|
*/
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
#define SSCOP_N_PS (reported_length - 8) /* lower 3 bytes thereof */
|
|
|
|
#define SSCOP_N_S (reported_length - 4) /* lower 3 bytes thereof */
|
1999-11-19 07:28:16 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Solicited Status PDU, Unsolicited Status PDU (no N(PS) in it).
|
|
|
|
*/
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
#define SSCOP_SS_N_PS (reported_length - 12) /* lower 3 bytes thereof */
|
|
|
|
#define SSCOP_SS_N_MR (reported_length - 8) /* lower 3 bytes thereof */
|
|
|
|
#define SSCOP_SS_N_R (reported_length - 4) /* lower 3 bytes thereof */
|
1999-11-19 07:28:16 +00:00
|
|
|
|
2005-08-02 08:30:33 +00:00
|
|
|
static void dissect_stat_list(proto_tree *tree, tvbuff_t *tvb,guint h) {
|
2005-06-06 18:52:54 +00:00
|
|
|
gint n,i;
|
|
|
|
proto_item* pi;
|
|
|
|
|
2005-06-17 17:37:10 +00:00
|
|
|
if ((n = (tvb_reported_length(tvb))/4 - h)) {
|
|
|
|
pi = proto_tree_add_text(tree,tvb,0,n*4,"SD List");
|
|
|
|
tree = proto_item_add_subtree(pi,ett_stat);
|
2005-06-03 13:50:30 +00:00
|
|
|
|
2005-06-17 17:37:10 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(tree, hf_sscop_stat_s, tvb, i*4 + 1,3,ENC_BIG_ENDIAN);
|
2005-06-17 17:37:10 +00:00
|
|
|
}
|
2005-06-03 13:50:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extern void
|
|
|
|
dissect_sscop_and_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, dissector_handle_t payload_handle)
|
1999-11-19 07:28:16 +00:00
|
|
|
{
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
guint reported_length;
|
1999-11-19 07:28:16 +00:00
|
|
|
proto_item *ti;
|
1999-11-19 09:10:22 +00:00
|
|
|
proto_tree *sscop_tree = NULL;
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
guint8 sscop_pdu_type;
|
1999-11-19 07:28:16 +00:00
|
|
|
int pdu_len;
|
|
|
|
int pad_len;
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
tvbuff_t *next_tvb;
|
1999-11-19 07:28:16 +00:00
|
|
|
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
reported_length = tvb_reported_length(tvb); /* frame length */
|
|
|
|
sscop_pdu_type = tvb_get_guint8(tvb, SSCOP_PDU_TYPE);
|
2005-06-17 17:37:10 +00:00
|
|
|
sscop_info.type = sscop_pdu_type & SSCOP_TYPE_MASK;
|
2008-03-01 16:29:18 +00:00
|
|
|
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SSCOP");
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
2005-06-17 17:37:10 +00:00
|
|
|
col_add_str(pinfo->cinfo, COL_INFO, val_to_str(sscop_info.type, sscop_type_vals,
|
1999-11-19 07:28:16 +00:00
|
|
|
"Unknown PDU type (0x%02x)"));
|
|
|
|
|
1999-11-19 09:10:22 +00:00
|
|
|
/*
|
|
|
|
* Find the length of the PDU and, if there's any payload and
|
|
|
|
* padding, the length of the padding.
|
|
|
|
*/
|
2005-06-17 17:37:10 +00:00
|
|
|
switch (sscop_info.type) {
|
1999-11-19 07:28:16 +00:00
|
|
|
|
1999-11-19 09:10:22 +00:00
|
|
|
case SSCOP_SD:
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
pad_len = (sscop_pdu_type >> 6) & 0x03;
|
1999-11-19 09:10:22 +00:00
|
|
|
pdu_len = 4;
|
|
|
|
break;
|
1999-11-19 07:28:16 +00:00
|
|
|
|
1999-11-23 07:19:14 +00:00
|
|
|
case SSCOP_BGN:
|
|
|
|
case SSCOP_BGAK:
|
|
|
|
case SSCOP_BGREJ:
|
|
|
|
case SSCOP_END:
|
|
|
|
case SSCOP_RS:
|
1999-11-19 07:28:16 +00:00
|
|
|
#if 0
|
1999-11-19 09:10:22 +00:00
|
|
|
case SSCOP_SDP:
|
1999-11-23 07:19:14 +00:00
|
|
|
#endif
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
pad_len = (sscop_pdu_type >> 6) & 0x03;
|
2005-06-17 17:37:10 +00:00
|
|
|
sscop_info.payload_len = pdu_len = 8;
|
1999-11-19 09:10:22 +00:00
|
|
|
break;
|
1999-11-19 07:28:16 +00:00
|
|
|
|
1999-11-19 09:10:22 +00:00
|
|
|
case SSCOP_UD:
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
pad_len = (sscop_pdu_type >> 6) & 0x03;
|
2005-06-17 17:37:10 +00:00
|
|
|
sscop_info.payload_len = pdu_len = 4;
|
1999-11-19 09:10:22 +00:00
|
|
|
break;
|
1999-11-19 07:28:16 +00:00
|
|
|
|
1999-11-19 09:10:22 +00:00
|
|
|
default:
|
|
|
|
pad_len = 0;
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
pdu_len = reported_length; /* No payload, just SSCOP */
|
2005-06-17 17:37:10 +00:00
|
|
|
sscop_info.payload_len = 0;
|
1999-11-19 09:10:22 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-03-01 16:29:18 +00:00
|
|
|
|
1999-11-19 09:10:22 +00:00
|
|
|
if (tree) {
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
ti = proto_tree_add_protocol_format(tree, proto_sscop, tvb,
|
|
|
|
reported_length - pdu_len,
|
2000-03-12 04:48:32 +00:00
|
|
|
pdu_len, "SSCOP");
|
1999-11-19 07:28:16 +00:00
|
|
|
sscop_tree = proto_item_add_subtree(ti, ett_sscop);
|
1999-11-23 07:19:14 +00:00
|
|
|
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(sscop_tree, hf_sscop_type, tvb, SSCOP_PDU_TYPE, 1,ENC_BIG_ENDIAN);
|
1999-11-23 07:19:14 +00:00
|
|
|
|
2005-06-17 17:37:10 +00:00
|
|
|
switch (sscop_info.type) {
|
1999-11-19 07:28:16 +00:00
|
|
|
|
|
|
|
case SSCOP_BGN:
|
|
|
|
case SSCOP_RS:
|
|
|
|
case SSCOP_ER:
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(sscop_tree, hf_sscop_sq, tvb, SSCOP_N_SQ, 1,ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(sscop_tree, hf_sscop_mr, tvb, SSCOP_N_MR + 1, 3, ENC_BIG_ENDIAN);
|
1999-11-19 07:28:16 +00:00
|
|
|
break;
|
|
|
|
|
1999-11-23 07:19:14 +00:00
|
|
|
case SSCOP_END:
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
proto_tree_add_text(sscop_tree, tvb, SSCOP_PDU_TYPE, 1,
|
|
|
|
"Source: %s", (sscop_pdu_type & SSCOP_S) ? "SSCOP" : "User");
|
1999-11-23 07:19:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SSCOP_BGAK:
|
1999-11-19 07:28:16 +00:00
|
|
|
case SSCOP_RSAK:
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(sscop_tree, hf_sscop_mr, tvb, SSCOP_N_MR + 1, 3, ENC_BIG_ENDIAN);
|
1999-11-19 07:28:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SSCOP_ERAK:
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(sscop_tree, hf_sscop_mr, tvb, SSCOP_N_MR + 1, 3, ENC_BIG_ENDIAN);
|
1999-11-19 07:28:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SSCOP_SD:
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(sscop_tree, hf_sscop_s, tvb, SSCOP_N_S + 1, 3, ENC_BIG_ENDIAN);
|
1999-11-19 07:28:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
case SSCOP_SDP:
|
|
|
|
#endif
|
|
|
|
case SSCOP_POLL:
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(sscop_tree, hf_sscop_ps, tvb, SSCOP_N_PS + 1, 3,ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(sscop_tree, hf_sscop_s, tvb, SSCOP_N_S + 1, 3,ENC_BIG_ENDIAN);
|
1999-11-19 07:28:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SSCOP_STAT:
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(sscop_tree, hf_sscop_ps, tvb, SSCOP_SS_N_PS + 1, 3,ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(sscop_tree, hf_sscop_mr, tvb, SSCOP_SS_N_MR + 1, 3, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(sscop_tree, hf_sscop_r, tvb, SSCOP_SS_N_R + 1, 3,ENC_BIG_ENDIAN);
|
2005-06-06 18:52:54 +00:00
|
|
|
dissect_stat_list(sscop_tree,tvb,3);
|
1999-11-19 07:28:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SSCOP_USTAT:
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(sscop_tree, hf_sscop_mr, tvb, SSCOP_SS_N_MR + 1, 3, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(sscop_tree, hf_sscop_r, tvb, SSCOP_SS_N_R + 1, 3,ENC_BIG_ENDIAN);
|
2005-06-06 18:52:54 +00:00
|
|
|
dissect_stat_list(sscop_tree,tvb,2);
|
1999-11-19 07:28:16 +00:00
|
|
|
break;
|
|
|
|
}
|
1999-11-19 09:10:22 +00:00
|
|
|
}
|
1999-11-19 07:28:16 +00:00
|
|
|
|
1999-11-19 09:10:22 +00:00
|
|
|
/*
|
|
|
|
* Dissect the payload, if any.
|
|
|
|
*
|
|
|
|
* XXX - what about a Management Data PDU?
|
|
|
|
*/
|
2005-06-17 17:37:10 +00:00
|
|
|
switch (sscop_info.type) {
|
1999-11-19 09:10:22 +00:00
|
|
|
|
|
|
|
case SSCOP_SD:
|
|
|
|
case SSCOP_UD:
|
1999-11-23 07:19:14 +00:00
|
|
|
case SSCOP_BGN:
|
|
|
|
case SSCOP_BGAK:
|
|
|
|
case SSCOP_BGREJ:
|
|
|
|
case SSCOP_END:
|
|
|
|
case SSCOP_RS:
|
|
|
|
#if 0
|
|
|
|
case SSCOP_SDP:
|
|
|
|
#endif
|
1999-11-19 09:10:22 +00:00
|
|
|
if (tree) {
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
proto_tree_add_text(sscop_tree, tvb, SSCOP_PDU_TYPE, 1,
|
1999-11-19 07:28:16 +00:00
|
|
|
"Pad length: %u", pad_len);
|
|
|
|
}
|
1999-11-19 09:10:22 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Compute length of data in PDU - subtract the trailer length
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
* and the pad length from the reported length.
|
1999-11-19 09:10:22 +00:00
|
|
|
*/
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
reported_length -= (pdu_len + pad_len);
|
1999-11-19 09:55:38 +00:00
|
|
|
|
Add "tvb_reported_length()" to get the "reported length" of a tvbuff
(i.e., the amount of data that was in the packet, even if not all of it
was captured), for use when dissecting packets containing data that
fills the packet (we want the dissector to try to dissect all of it; if
it runs past the end of the captured data, we want it to throw an
exception so that we'll put a "Short Frame" note in the protocol tree).
This means we always want a tvbuff to have a real reported length value,
so we make it an unsigned integer, and don't bother checking it for -1,
as it should never be -1.
If the reported length passed in to "tvb_set_subset()" is -1, set the
reported length to the reported length of the tvbuff of which the new
tvbuff will be a subset minus the offset in that tvbuff of the subset,
so that "-1" means "what's left of the packet after we chop off the
header". This is necessary in order to ensure that all tvbuffs have a
real reported length value.
Have "dissect_packet()" set the reported length of the top-level tvbuff
to the reported length of the frame, so that we start out with a tvbuff
with a real reported length value.
Have "tvb_offset_exists()" return FALSE if the offset is past the end of
the tvbuff.
If the offset passed to it is postitive, have "compute_offset_length()"
check for that it's not more than one byte past the end of the tvbuff -
if it's just past the end, we don't want the check to fail, as we don't
want attempts to create a subset tvbuff containing zero bytes to fail;
that would be done if a captured packet was all header and no payload,
and we'd want the dissector of the payload, not the dissector of the
header, to throw an exception, as the problem isn't with the protocol
for the header, it's with the protocol for the payload.
Convert the ATM dissector, the SSCOP dissector, the Q.2931 dissector,
and the Q.931 dissector to use tvbuffs.
Make the LAPD dissector set up a tvbuff for the Q.931 dissector (it's
not converted yet).
svn path=/trunk/; revision=2023
2000-05-29 08:57:42 +00:00
|
|
|
if (reported_length != 0) {
|
|
|
|
/*
|
|
|
|
* We know that we have all of the payload, because we know we have
|
|
|
|
* at least 4 bytes of data after the payload, i.e. the SSCOP trailer.
|
|
|
|
* Therefore, we know that the captured length of the payload is
|
|
|
|
* equal to the length of the payload.
|
|
|
|
*/
|
|
|
|
next_tvb = tvb_new_subset(tvb, 0, reported_length, reported_length);
|
2005-06-17 17:37:10 +00:00
|
|
|
if (sscop_info.type == SSCOP_SD)
|
2004-11-24 02:59:49 +00:00
|
|
|
{
|
2008-03-01 16:29:18 +00:00
|
|
|
call_dissector(payload_handle, next_tvb, pinfo, tree);
|
2005-06-03 13:50:30 +00:00
|
|
|
}
|
1999-11-19 09:10:22 +00:00
|
|
|
break;
|
1999-11-19 07:28:16 +00:00
|
|
|
}
|
|
|
|
}
|
2005-06-03 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
2005-08-02 08:30:33 +00:00
|
|
|
static void dissect_sscop(tvbuff_t* tvb, packet_info* pinfo,proto_tree* tree)
|
2005-06-03 13:50:30 +00:00
|
|
|
{
|
2007-01-28 01:41:58 +00:00
|
|
|
struct _sscop_payload_info *p_sscop_info;
|
|
|
|
dissector_handle_t subdissector;
|
2008-03-01 16:29:18 +00:00
|
|
|
|
2007-01-28 01:41:58 +00:00
|
|
|
/* Look for packet info for subdissector information */
|
|
|
|
p_sscop_info = p_get_proto_data(pinfo->fd, proto_sscop);
|
2008-03-01 16:29:18 +00:00
|
|
|
|
2007-01-28 01:41:58 +00:00
|
|
|
if ( p_sscop_info
|
|
|
|
&& ( subdissector = p_sscop_info->subdissector )
|
|
|
|
&& ( subdissector == data_handle
|
|
|
|
|| subdissector == q2931_handle
|
|
|
|
|| subdissector == sscf_nni_handle
|
|
|
|
|| subdissector == alcap_handle
|
|
|
|
|| subdissector == nbap_handle) )
|
|
|
|
dissect_sscop_and_payload(tvb,pinfo,tree,subdissector);
|
|
|
|
else
|
|
|
|
dissect_sscop_and_payload(tvb,pinfo,tree,default_handle);
|
2005-06-03 13:50:30 +00:00
|
|
|
}
|
|
|
|
|
1999-11-19 07:28:16 +00:00
|
|
|
|
2004-11-24 02:59:49 +00:00
|
|
|
static void range_delete_callback(guint32 port)
|
|
|
|
{
|
|
|
|
if (port) {
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_delete_uint("udp.port", port, sscop_handle);
|
2004-11-24 02:59:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void range_add_callback(guint32 port)
|
|
|
|
{
|
|
|
|
if (port) {
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("udp.port", port, sscop_handle);
|
2004-11-24 02:59:49 +00:00
|
|
|
}
|
|
|
|
}
|
2007-01-28 01:41:58 +00:00
|
|
|
|
|
|
|
/* Make sure handles for various protocols are initialized */
|
|
|
|
static void initialize_handles_once(void) {
|
|
|
|
static gboolean initialized = FALSE;
|
|
|
|
if (!initialized) {
|
|
|
|
sscop_handle = create_dissector_handle(dissect_sscop, proto_sscop);
|
|
|
|
|
|
|
|
q2931_handle = find_dissector("q2931");
|
|
|
|
data_handle = find_dissector("data");
|
|
|
|
sscf_nni_handle = find_dissector("sscf-nni");
|
|
|
|
alcap_handle = find_dissector("alcap");
|
|
|
|
nbap_handle = find_dissector("nbap");
|
|
|
|
|
|
|
|
initialized = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean sscop_allowed_subdissector(dissector_handle_t handle)
|
|
|
|
{
|
|
|
|
initialize_handles_once();
|
|
|
|
if (handle == q2931_handle || handle == data_handle
|
|
|
|
|| handle == sscf_nni_handle || handle == alcap_handle
|
|
|
|
|| handle == nbap_handle)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-11-24 02:59:49 +00:00
|
|
|
void
|
|
|
|
proto_reg_handoff_sscop(void)
|
|
|
|
{
|
2008-09-02 19:08:29 +00:00
|
|
|
static gboolean prefs_initialized = FALSE;
|
2008-09-23 15:03:39 +00:00
|
|
|
static range_t *udp_port_range;
|
2004-11-24 02:59:49 +00:00
|
|
|
|
|
|
|
if (!prefs_initialized) {
|
2007-01-28 01:41:58 +00:00
|
|
|
initialize_handles_once();
|
2004-11-24 02:59:49 +00:00
|
|
|
prefs_initialized = TRUE;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
range_foreach(udp_port_range, range_delete_callback);
|
2008-09-23 15:03:39 +00:00
|
|
|
g_free(udp_port_range);
|
2004-11-24 02:59:49 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
udp_port_range = range_copy(global_udp_port_range);
|
|
|
|
|
|
|
|
range_foreach(udp_port_range, range_add_callback);
|
|
|
|
|
2005-06-03 13:50:30 +00:00
|
|
|
switch(sscop_payload_dissector) {
|
|
|
|
case DATA_DISSECTOR: default_handle = data_handle; break;
|
|
|
|
case Q2931_DISSECTOR: default_handle = q2931_handle; break;
|
|
|
|
case SSCF_NNI_DISSECTOR: default_handle = sscf_nni_handle; break;
|
2007-01-28 01:41:58 +00:00
|
|
|
case ALCAP_DISSECTOR: default_handle = alcap_handle; break;
|
|
|
|
case NBAP_DISSECTOR: default_handle = nbap_handle; break;
|
2005-06-03 13:50:30 +00:00
|
|
|
}
|
2008-03-01 16:29:18 +00:00
|
|
|
|
2004-11-24 02:59:49 +00:00
|
|
|
}
|
|
|
|
|
1999-11-19 07:28:16 +00:00
|
|
|
void
|
|
|
|
proto_register_sscop(void)
|
|
|
|
{
|
2005-06-03 13:50:30 +00:00
|
|
|
static hf_register_info hf[] = {
|
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
|
|
|
{ &hf_sscop_type, { "PDU Type", "sscop.type", FT_UINT8, BASE_HEX, VALS(sscop_type_vals), SSCOP_TYPE_MASK, NULL, HFILL }},
|
|
|
|
{ &hf_sscop_sq, { "N(SQ)", "sscop.sq", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
|
|
|
{ &hf_sscop_mr, { "N(MR)", "sscop.mr", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
|
|
|
{ &hf_sscop_s, { "N(S)", "sscop.s", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
|
|
|
{ &hf_sscop_ps, { "N(PS)", "sscop.ps", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
|
|
|
{ &hf_sscop_r, { "N(R)", "sscop.r", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
|
|
|
{ &hf_sscop_stat_s, { "N(S)", "sscop.stat.s", FT_UINT24, BASE_DEC, NULL, 0x0,NULL, HFILL }},
|
|
|
|
{ &hf_sscop_stat_count, { "Number of NACKed pdus", "sscop.stat.count", FT_UINT32, BASE_DEC, NULL, 0x0,NULL, HFILL }}
|
2005-06-03 13:50:30 +00:00
|
|
|
};
|
2008-03-01 16:29:18 +00:00
|
|
|
|
2001-05-27 07:15:26 +00:00
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_sscop,
|
2005-06-03 13:50:30 +00:00
|
|
|
&ett_stat
|
2001-05-27 07:15:26 +00:00
|
|
|
};
|
2008-03-01 16:29:18 +00:00
|
|
|
|
2001-05-27 07:15:26 +00:00
|
|
|
proto_sscop = proto_register_protocol("SSCOP", "SSCOP", "sscop");
|
2005-06-03 13:50:30 +00:00
|
|
|
proto_register_field_array(proto_sscop, hf, array_length(hf));
|
2001-05-27 07:15:26 +00:00
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
register_dissector("sscop", dissect_sscop, proto_sscop);
|
|
|
|
|
2004-11-24 02:59:49 +00:00
|
|
|
sscop_module = prefs_register_protocol(proto_sscop, proto_reg_handoff_sscop);
|
|
|
|
|
|
|
|
global_udp_port_range = range_empty();
|
|
|
|
|
|
|
|
prefs_register_range_preference(sscop_module, "udp.ports",
|
|
|
|
"SSCOP UDP port range",
|
|
|
|
"Set the UDP port for SSCOP messages encapsulated in UDP (0 to disable)",
|
|
|
|
&global_udp_port_range, MAX_UDP_PORT);
|
|
|
|
|
|
|
|
prefs_register_enum_preference(sscop_module, "payload",
|
|
|
|
"SSCOP payload protocol",
|
|
|
|
"SSCOP payload (dissector to call on SSCOP payload)",
|
|
|
|
(gint *)&sscop_payload_dissector,
|
|
|
|
sscop_payload_dissector_options, FALSE);
|
1999-11-19 07:28:16 +00:00
|
|
|
}
|
2004-11-24 02:59:49 +00:00
|
|
|
|