summaryrefslogtreecommitdiff
path: root/packet-q2931.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-05-29 08:57:42 +0000
committerGuy Harris <guy@alum.mit.edu>2000-05-29 08:57:42 +0000
commit10ea13ed18be32c74c42ac023ae1258f79c6406e (patch)
tree4fd5ee67a918eb9d9180274b1f82b44be2ae7470 /packet-q2931.c
parentcb5b6c4719439cc777a78ae0b3c98088ac114d92 (diff)
downloadwireshark-10ea13ed18be32c74c42ac023ae1258f79c6406e.tar.gz
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
Diffstat (limited to 'packet-q2931.c')
-rw-r--r--packet-q2931.c632
1 files changed, 311 insertions, 321 deletions
diff --git a/packet-q2931.c b/packet-q2931.c
index 92361aa137..9f55c6a8e1 100644
--- a/packet-q2931.c
+++ b/packet-q2931.c
@@ -2,7 +2,7 @@
* Routines for Q.2931 frame disassembly
* Guy Harris <guy@alum.mit.edu>
*
- * $Id: packet-q2931.c,v 1.8 2000/05/11 08:15:36 gram Exp $
+ * $Id: packet-q2931.c,v 1.9 2000/05/29 08:57:37 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -67,7 +67,7 @@ static gint ett_q2931_ie = -1;
static gint ett_q2931_ie_ext = -1;
static gint ett_q2931_nsap = -1;
-static void dissect_q2931_ie(const u_char *pd, int offset, int len,
+static void dissect_q2931_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree, guint8 info_element, guint8 info_element_ext);
/*
@@ -251,15 +251,15 @@ static const value_string q2931_codeset_vals[] = {
};
static void
-dissect_q2931_shift_ie(const u_char *pd, int offset, int len,
+dissect_q2931_shift_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree, guint8 info_element)
{
gboolean non_locking_shift;
guint8 codeset;
non_locking_shift = (info_element == Q2931_IE_BBAND_NLOCKING_SHIFT);
- codeset = pd[offset] & 0x07;
- proto_tree_add_text(tree, NullTVB, offset, 1, "%s shift to codeset %u: %s",
+ codeset = tvb_get_guint8(tvb, offset) & 0x07;
+ proto_tree_add_text(tree, tvb, offset, 1, "%s shift to codeset %u: %s",
(non_locking_shift ? "Non-locking" : "Locking"),
codeset,
val_to_str(codeset, q2931_codeset_vals, "Unknown (0x%02X)"));
@@ -336,7 +336,7 @@ static const value_string q2931_sscs_type_vals[] = {
};
static void
-dissect_q2931_aal_parameters_ie(const u_char *pd, int offset, int len,
+dissect_q2931_aal_parameters_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 aal_type;
@@ -346,8 +346,8 @@ dissect_q2931_aal_parameters_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- aal_type = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1, "AAL type: %s",
+ aal_type = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1, "AAL type: %s",
val_to_str(aal_type, q9231_aal_type_vals, "Unknown (0x%02X)"));
offset += 1;
len -= 1;
@@ -361,21 +361,21 @@ dissect_q2931_aal_parameters_ie(const u_char *pd, int offset, int len,
*/
if (len > 4)
len = 4;
- proto_tree_add_text(tree, NullTVB, offset, len,
+ proto_tree_add_text(tree, tvb, offset, len,
"User defined AAL information: %s",
- bytes_to_str(&pd[offset], len));
+ bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
return;
}
while (len != 0) {
- identifier = pd[offset];
+ identifier = tvb_get_guint8(tvb, offset);
switch (identifier) {
case 0x85: /* Subtype identifier for AAL1 */
if (len < 2)
return;
- value = pd[offset + 1];
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ value = tvb_get_guint8(tvb, offset + 1);
+ proto_tree_add_text(tree, tvb, offset, 2,
"Subtype: %s",
val_to_str(value, q9231_aal1_subtype_vals,
"Unknown (0x%02X)"));
@@ -386,8 +386,8 @@ dissect_q2931_aal_parameters_ie(const u_char *pd, int offset, int len,
case 0x86: /* CBR identifier for AAL1 */
if (len < 2)
return;
- value = pd[offset + 1];
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ value = tvb_get_guint8(tvb, offset + 1);
+ proto_tree_add_text(tree, tvb, offset, 2,
"CBR rate: %s",
val_to_str(value, q9231_aal1_cbr_rate_vals,
"Unknown (0x%02X)"));
@@ -398,8 +398,8 @@ dissect_q2931_aal_parameters_ie(const u_char *pd, int offset, int len,
case 0x87: /* Multiplier identifier for AAL1 */
if (len < 3)
return;
- value = pntohs(&pd[offset + 1]);
- proto_tree_add_text(tree, NullTVB, offset, 3,
+ value = tvb_get_ntohs(tvb, offset + 1);
+ proto_tree_add_text(tree, tvb, offset, 3,
"Multiplier: %u", value);
offset += 3;
len -= 3;
@@ -408,8 +408,8 @@ dissect_q2931_aal_parameters_ie(const u_char *pd, int offset, int len,
case 0x88: /* Source clock frequency recovery method identifier for AAL1 */
if (len < 2)
return;
- value = pd[offset + 1];
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ value = tvb_get_guint8(tvb, offset + 1);
+ proto_tree_add_text(tree, tvb, offset, 2,
"Source clock frequency recovery method: %s",
val_to_str(value, q2931_aal1_src_clk_rec_meth_vals,
"Unknown (0x%02X)"));
@@ -420,8 +420,8 @@ dissect_q2931_aal_parameters_ie(const u_char *pd, int offset, int len,
case 0x89: /* Error correction method identifier for AAL1 */
if (len < 2)
return;
- value = pd[offset + 1];
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ value = tvb_get_guint8(tvb, offset + 1);
+ proto_tree_add_text(tree, tvb, offset, 2,
"Error correction method: %s",
val_to_str(value, q2931_aal1_err_correction_method_vals,
"Unknown (0x%02X)"));
@@ -432,8 +432,8 @@ dissect_q2931_aal_parameters_ie(const u_char *pd, int offset, int len,
case 0x8A: /* Structured data transfer block size identifier for AAL1 */
if (len < 3)
return;
- value = pntohs(&pd[offset + 1]);
- proto_tree_add_text(tree, NullTVB, offset, 3,
+ value = tvb_get_ntohs(tvb, offset + 1);
+ proto_tree_add_text(tree, tvb, offset, 3,
"Structured data transfer block size: %u", value);
offset += 3;
len -= 3;
@@ -442,8 +442,8 @@ dissect_q2931_aal_parameters_ie(const u_char *pd, int offset, int len,
case 0x8B: /* Partially filled cells identifier for AAL1 */
if (len < 2)
return;
- value = pd[offset + 1];
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ value = tvb_get_guint8(tvb, offset + 1);
+ proto_tree_add_text(tree, tvb, offset, 2,
"Partially filled cells method: %u octets", value);
offset += 2;
len -= 2;
@@ -452,8 +452,8 @@ dissect_q2931_aal_parameters_ie(const u_char *pd, int offset, int len,
case 0x8C: /* Forward maximum CPCS-SDU size identifier for AAL3/4 and AAL5 */
if (len < 3)
return;
- value = pntohs(&pd[offset + 1]);
- proto_tree_add_text(tree, NullTVB, offset, 3,
+ value = tvb_get_ntohs(tvb, offset + 1);
+ proto_tree_add_text(tree, tvb, offset, 3,
"Forward maximum CPCS-SDU size: %u", value);
offset += 3;
len -= 3;
@@ -462,8 +462,8 @@ dissect_q2931_aal_parameters_ie(const u_char *pd, int offset, int len,
case 0x81: /* Backward maximum CPCS-SDU size identifier for AAL3/4 and AAL5 */
if (len < 3)
return;
- value = pntohs(&pd[offset + 1]);
- proto_tree_add_text(tree, NullTVB, offset, 3,
+ value = tvb_get_ntohs(tvb, offset + 1);
+ proto_tree_add_text(tree, tvb, offset, 3,
"Backward maximum CPCS-SDU size: %u", value);
offset += 3;
len -= 3;
@@ -472,9 +472,9 @@ dissect_q2931_aal_parameters_ie(const u_char *pd, int offset, int len,
case 0x82: /* MID range identifier for AAL3/4 */
if (len < 5)
return;
- low_mid = pntohs(&pd[offset + 1]);
- high_mid = pntohs(&pd[offset + 3]);
- proto_tree_add_text(tree, NullTVB, offset, 3,
+ low_mid = tvb_get_ntohs(tvb, offset + 1);
+ high_mid = tvb_get_ntohs(tvb, offset + 3);
+ proto_tree_add_text(tree, tvb, offset, 3,
"MID range: %u - %u", low_mid, high_mid);
offset += 5;
len -= 5;
@@ -483,8 +483,8 @@ dissect_q2931_aal_parameters_ie(const u_char *pd, int offset, int len,
case 0x84: /* SSCS type identifier for AAL3/4 and AAL5 */
if (len < 2)
return;
- value = pd[offset + 1];
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ value = tvb_get_guint8(tvb, offset + 1);
+ proto_tree_add_text(tree, tvb, offset, 2,
"SSCS type: %s",
val_to_str(value, q2931_sscs_type_vals,
"Unknown (0x%02X)"));
@@ -493,7 +493,7 @@ dissect_q2931_aal_parameters_ie(const u_char *pd, int offset, int len,
break;
default: /* unknown AAL parameter */
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Unknown AAL parameter (0x%02X)",
identifier);
return; /* give up */
@@ -538,14 +538,14 @@ static const value_string q2931_atm_td_subfield_vals[] = {
};
static void
-dissect_q2931_atm_cell_rate_ie(const u_char *pd, int offset, int len,
+dissect_q2931_atm_cell_rate_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 identifier;
guint32 value;
while (len != 0) {
- identifier = pd[offset];
+ identifier = tvb_get_guint8(tvb, offset);
switch (identifier) {
case Q2931_ATM_CR_FW_PEAK_CLP_0:
@@ -562,10 +562,8 @@ dissect_q2931_atm_cell_rate_ie(const u_char *pd, int offset, int len,
case Q2931_ATM_CR_BW_MAXB_CLP_0_1:
if (len < 4)
return;
- value = (pd[offset + 1] << 16)
- | (pd[offset + 2] << 8)
- | (pd[offset + 3] << 0);
- proto_tree_add_text(tree, NullTVB, offset, 4,
+ value = tvb_get_ntoh24(tvb, offset + 1);
+ proto_tree_add_text(tree, tvb, offset, 4,
"%s: %u cell%s/s",
val_to_str(identifier, q2931_atm_td_subfield_vals,
NULL),
@@ -576,7 +574,7 @@ dissect_q2931_atm_cell_rate_ie(const u_char *pd, int offset, int len,
case Q2931_ATM_CR_BEST_EFFORT_IND:
/* Yes, its value *IS* 0xBE.... */
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"%s",
val_to_str(identifier, q2931_atm_td_subfield_vals,
NULL));
@@ -587,21 +585,21 @@ dissect_q2931_atm_cell_rate_ie(const u_char *pd, int offset, int len,
case Q2931_ATM_CR_TRAFFIC_MGMT_OPT:
if (len < 2)
return;
- value = pd[offset + 1];
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ value = tvb_get_guint8(tvb, offset + 1);
+ proto_tree_add_text(tree, tvb, offset, 2,
"%s",
val_to_str(identifier, q2931_atm_td_subfield_vals,
NULL));
- proto_tree_add_text(tree, NullTVB, offset + 1, 1,
+ proto_tree_add_text(tree, tvb, offset + 1, 1,
"%s allowed in forward direction",
(value & 0x80) ? "Frame discard" : "No frame discard");
- proto_tree_add_text(tree, NullTVB, offset + 1, 1,
+ proto_tree_add_text(tree, tvb, offset + 1, 1,
"%s allowed in backward direction",
(value & 0x40) ? "Frame discard" : "No frame discard");
- proto_tree_add_text(tree, NullTVB, offset + 1, 1,
+ proto_tree_add_text(tree, tvb, offset + 1, 1,
"Tagging %srequested in backward direction",
(value & 0x02) ? "" : "not ");
- proto_tree_add_text(tree, NullTVB, offset + 1, 1,
+ proto_tree_add_text(tree, tvb, offset + 1, 1,
"Tagging %srequested in forward direction",
(value & 0x01) ? "" : "not ");
offset += 2;
@@ -609,7 +607,7 @@ dissect_q2931_atm_cell_rate_ie(const u_char *pd, int offset, int len,
break;
default: /* unknown ATM traffic descriptor element */
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Unknown ATM traffic descriptor element (0x%02X)",
identifier);
return; /* give up */
@@ -657,15 +655,15 @@ static const value_string q2931_up_conn_config_vals[] = {
};
void
-dissect_q2931_bband_bearer_cap_ie(const u_char *pd, int offset, int len,
+dissect_q2931_bband_bearer_cap_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Bearer class: %s",
val_to_str(octet & 0x1F, q2931_bearer_class_vals,
"Unknown (0x%02X)"));
@@ -675,8 +673,8 @@ dissect_q2931_bband_bearer_cap_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
if (!(octet & Q2931_IE_EXTENSION)) {
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"ATM Transfer Capability: %s",
val_to_str(octet & 0x1F, q2931_transfer_capability_vals,
"Unknown (0x%02X)"));
@@ -686,12 +684,12 @@ dissect_q2931_bband_bearer_cap_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Susceptibility to clipping: %s",
val_to_str(octet & 0x60, q2931_susc_clip_vals,
"Unknown (0x%02X)"));
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"User-plane connection configuration: %s",
val_to_str(octet & 0x03, q2931_up_conn_config_vals,
"Unknown (0x%02X)"));
@@ -709,15 +707,15 @@ static const value_string q2931_hi_layer_info_type_vals[] = {
};
void
-dissect_q2931_bband_hi_layer_info_ie(const u_char *pd, int offset, int len,
+dissect_q2931_bband_hi_layer_info_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"High layer information type: %s",
val_to_str(octet & 0x7F, q2931_hi_layer_info_type_vals,
"Unknown (0x%02X)"));
@@ -783,7 +781,7 @@ static const value_string lane_pid_vals[] = {
* Dissect a broadband low layer information information element.
*/
void
-dissect_q2931_bband_low_layer_info_ie(const u_char *pd, int offset, int len,
+dissect_q2931_bband_low_layer_info_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
@@ -795,12 +793,12 @@ dissect_q2931_bband_low_layer_info_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
if ((octet & 0x60) == 0x20) {
/*
* Layer 1 information.
*/
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"User information layer 1 protocol: 0x%02X",
octet & 0x1F);
offset += 1;
@@ -809,13 +807,13 @@ dissect_q2931_bband_low_layer_info_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
if ((octet & 0x60) == 0x40) {
/*
* Layer 2 information.
*/
uil2_protocol = octet & 0x1F;
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"User information layer 2 protocol: %s",
val_to_str(uil2_protocol, q2931_uil2_vals,
"Unknown (0x%02X)"));
@@ -826,13 +824,13 @@ dissect_q2931_bband_low_layer_info_ie(const u_char *pd, int offset, int len,
goto l2_done;
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
if (uil2_protocol == Q2931_UIL2_USER_SPEC) {
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"User-specified layer 2 protocol information: 0x%02X",
octet & 0x7F);
} else {
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Mode: %s",
val_to_str(octet & 0x60, q2931_mode_vals,
"Unknown (0x%02X)"));
@@ -844,8 +842,8 @@ dissect_q2931_bband_low_layer_info_ie(const u_char *pd, int offset, int len,
goto l2_done;
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Window size: %u k", octet & 0x7F);
offset += 1;
len -= 1;
@@ -855,13 +853,13 @@ l2_done:
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
if ((octet & 0x60) == 0x60) {
/*
* Layer 3 information.
*/
uil3_protocol = octet & 0x1F;
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"User information layer 3 protocol: %s",
val_to_str(uil3_protocol, q2931_uil3_vals,
"Unknown (0x%02X)"));
@@ -876,13 +874,13 @@ l2_done:
goto l3_done;
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
switch (uil3_protocol) {
case Q2931_UIL3_X25_PL:
case Q2931_UIL3_ISO_8208:
case Q2931_UIL3_X223:
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Mode: %s",
val_to_str(octet & 0x60, q2931_mode_vals,
"Unknown (0x%02X)"));
@@ -893,8 +891,8 @@ l2_done:
goto l3_done;
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Default packet size: %u", octet & 0x0F);
offset += 1;
len -= 1;
@@ -903,15 +901,15 @@ l2_done:
goto l3_done;
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Packet window size: %u", octet & 0x7F);
offset += 1;
len -= 1;
break;
case Q2931_UIL3_USER_SPEC:
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Default packet size: %u octets",
1 << (octet & 0x0F));
offset += 1;
@@ -924,8 +922,8 @@ l2_done:
goto l3_done;
if (len < 2)
return;
- add_l3_info |= (pd[offset + 1] & 0x40) >> 6;
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ add_l3_info |= (tvb_get_guint8(tvb, offset + 1) & 0x40) >> 6;
+ proto_tree_add_text(tree, tvb, offset, 2,
"Additional layer 3 protocol information: %s",
val_to_str(add_l3_info, nlpid_vals,
"Unknown (0x%02X)"));
@@ -936,9 +934,8 @@ l2_done:
return;
offset += 1;
len -= 1;
- organization_code =
- pd[offset] << 16 | pd[offset+1] << 8 | pd[offset+2];
- proto_tree_add_text(tree, NullTVB, offset, 3,
+ organization_code = tvb_get_ntoh24(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 3,
"Organization Code: 0x%06X (%s)",
organization_code,
val_to_str(organization_code, oui_vals,
@@ -948,25 +945,25 @@ l2_done:
if (len < 2)
return;
- pid = pntohs(&pd[offset]);
+ pid = tvb_get_ntohs(tvb, offset);
switch (organization_code) {
case OUI_ENCAP_ETHER:
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ proto_tree_add_text(tree, tvb, offset, 2,
"Ethernet type: %s",
val_to_str(pid, etype_vals,
"Unknown (0x%04X)"));
break;
case OUI_ATM_FORUM:
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ proto_tree_add_text(tree, tvb, offset, 2,
"LANE Protocol ID: %s",
val_to_str(pid, lane_pid_vals,
"Unknown (0x%04X)"));
break;
default:
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ proto_tree_add_text(tree, tvb, offset, 2,
"Protocol ID: 0x%04X", pid);
break;
}
@@ -1085,7 +1082,7 @@ static const value_string q2931_rejection_reason_vals[] = {
};
static void
-dissect_q2931_cause_ie(const u_char *pd, int offset, int len,
+dissect_q2931_cause_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
@@ -1097,8 +1094,8 @@ dissect_q2931_cause_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Location: %s",
val_to_str(octet & 0x0F, q2931_cause_location_vals,
"Unknown (0x%X)"));
@@ -1107,9 +1104,9 @@ dissect_q2931_cause_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
cause_value = octet & 0x7F;
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Cause value: %s",
val_to_str(cause_value, q2931_cause_code_vals,
"Unknown (0x%X)"));
@@ -1123,14 +1120,14 @@ dissect_q2931_cause_ie(const u_char *pd, int offset, int len,
case Q2931_CAUSE_UNALLOC_NUMBER:
case Q2931_CAUSE_NO_ROUTE_TO_DEST:
case Q2931_CAUSE_QOS_UNAVAILABLE:
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Network service: %s",
(octet & 0x80) ? "User" : "Provider");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"%s",
(octet & 0x40) ? "Abnormal" : "Normal");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Condition: %s",
val_to_str(octet & 0x03, q2931_cause_condition_vals,
"Unknown (0x%X)"));
@@ -1138,11 +1135,11 @@ dissect_q2931_cause_ie(const u_char *pd, int offset, int len,
case Q2931_CAUSE_CALL_REJECTED:
rejection_reason = octet & 0x7C;
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Rejection reason: %s",
val_to_str(octet & 0x7C, q2931_cause_condition_vals,
"Unknown (0x%X)"));
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Condition: %s",
val_to_str(octet & 0x03, q2931_cause_condition_vals,
"Unknown (0x%X)"));
@@ -1154,29 +1151,29 @@ dissect_q2931_cause_ie(const u_char *pd, int offset, int len,
switch (rejection_reason) {
case Q2931_REJ_USER_SPECIFIC:
- proto_tree_add_text(tree, NullTVB, offset, len,
+ proto_tree_add_text(tree, tvb, offset, len,
"User specific diagnostic: %s",
- bytes_to_str(&pd[offset], len));
+ bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
break;
case Q2931_REJ_IE_MISSING:
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Missing information element: %s",
- val_to_str(pd[offset], q2931_info_element_vals,
+ val_to_str(tvb_get_guint8(tvb, offset), q2931_info_element_vals,
"Unknown (0x%02X)"));
break;
case Q2931_REJ_IE_INSUFFICIENT:
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Insufficient information element: %s",
- val_to_str(pd[offset], q2931_info_element_vals,
+ val_to_str(tvb_get_guint8(tvb, offset), q2931_info_element_vals,
"Unknown (0x%02X)"));
break;
default:
- proto_tree_add_text(tree, NullTVB, offset, len,
+ proto_tree_add_text(tree, tvb, offset, len,
"Diagnostic: %s",
- bytes_to_str(&pd[offset], len));
+ bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
break;
}
break;
@@ -1187,16 +1184,10 @@ dissect_q2931_cause_ie(const u_char *pd, int offset, int len,
* number information element, including information
* element identifier.
*/
- info_element = pd[offset];
- if (!BYTES_ARE_IN_FRAME(offset + 1, 1))
- break; /* ran past end of frame */
- info_element_ext = pd[offset + 1];
- if (!BYTES_ARE_IN_FRAME(offset + 2, 2))
- break; /* ran past end of frame */
- info_element_len = pntohs(&pd[offset + 2]);
- if (!BYTES_ARE_IN_FRAME(offset + 4, info_element_len))
- break; /* ran past end of frame */
- dissect_q2931_ie(pd, offset, info_element_len, tree,
+ info_element = tvb_get_guint8(tvb, offset);
+ info_element_ext = tvb_get_guint8(tvb, offset + 1);
+ info_element_len = tvb_get_ntohs(tvb, offset + 2);
+ dissect_q2931_ie(tvb, offset, info_element_len, tree,
info_element, info_element_ext);
break;
@@ -1206,9 +1197,9 @@ dissect_q2931_cause_ie(const u_char *pd, int offset, int len,
case Q2931_CAUSE_IE_NONEX_OR_UNIMPL:
case Q2931_CAUSE_INVALID_IE_CONTENTS:
do {
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Information element: %s",
- val_to_str(pd[offset], q2931_info_element_vals,
+ val_to_str(tvb_get_guint8(tvb, offset), q2931_info_element_vals,
"Unknown (0x%02X)"));
offset += 1;
len -= 1;
@@ -1217,9 +1208,9 @@ dissect_q2931_cause_ie(const u_char *pd, int offset, int len,
case Q2931_CAUSE_CELL_RATE_UNAVAIL:
do {
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Cell rate subfield identifier: %s",
- val_to_str(pd[offset], q2931_atm_td_subfield_vals,
+ val_to_str(tvb_get_guint8(tvb, offset), q2931_atm_td_subfield_vals,
"Unknown (0x%02X)"));
offset += 1;
len -= 1;
@@ -1229,36 +1220,36 @@ dissect_q2931_cause_ie(const u_char *pd, int offset, int len,
case Q2931_CAUSE_CHAN_NONEXISTENT:
if (len < 2)
return;
- proto_tree_add_text(tree, NullTVB, offset, 2,
- "VPCI: %u", pntohs(&pd[offset]));
+ proto_tree_add_text(tree, tvb, offset, 2,
+ "VPCI: %u", tvb_get_ntohs(tvb, offset));
offset += 2;
len -= 2;
if (len < 2)
return;
- proto_tree_add_text(tree, NullTVB, offset, 2,
- "VCI: %u", pntohs(&pd[offset]));
+ proto_tree_add_text(tree, tvb, offset, 2,
+ "VCI: %u", tvb_get_ntohs(tvb, offset));
break;
case Q2931_CAUSE_MT_NONEX_OR_UNIMPL:
case Q2931_CAUSE_MSG_INCOMPAT_W_CS:
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Message type: %s",
- val_to_str(pd[offset], q2931_message_type_vals,
+ val_to_str(tvb_get_guint8(tvb, offset), q2931_message_type_vals,
"Unknown (0x%02X)"));
break;
case Q2931_CAUSE_REC_TIMER_EXP:
if (len < 3)
return;
- proto_tree_add_text(tree, NullTVB, offset, 3,
- "Timer: %.3s", &pd[offset]);
+ proto_tree_add_text(tree, tvb, offset, 3,
+ "Timer: %.3s", tvb_get_ptr(tvb, offset, 3));
break;
default:
- proto_tree_add_text(tree, NullTVB, offset, len,
+ proto_tree_add_text(tree, tvb, offset, len,
"Diagnostics: %s",
- bytes_to_str(&pd[offset], len));
+ bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
}
}
@@ -1288,15 +1279,15 @@ static const value_string q2931_call_state_vals[] = {
};
static void
-dissect_q2931_call_state_ie(const u_char *pd, int offset, int len,
+dissect_q2931_call_state_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Call state: %s",
val_to_str(octet & 0x3F, q2931_call_state_vals,
"Unknown (0x%02X)"));
@@ -1342,7 +1333,7 @@ static const value_string q2931_screening_indicator_vals[] = {
};
static void
-dissect_q2931_number_ie(const u_char *pd, int offset, int len,
+dissect_q2931_number_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
@@ -1352,13 +1343,13 @@ dissect_q2931_number_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Type of number: %s",
val_to_str(octet & 0x70, q2931_number_type_vals,
"Unknown (0x%02X)"));
numbering_plan = octet & 0x0F;
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Numbering plan: %s",
val_to_str(numbering_plan, q2931_numbering_plan_vals,
"Unknown (0x%02X)"));
@@ -1368,12 +1359,12 @@ dissect_q2931_number_ie(const u_char *pd, int offset, int len,
if (!(octet & Q2931_IE_EXTENSION)) {
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Presentation indicator: %s",
val_to_str(octet & 0x60, q2931_presentation_indicator_vals,
"Unknown (0x%X)"));
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Screening indicator: %s",
val_to_str(octet & 0x03, q2931_screening_indicator_vals,
"Unknown (0x%X)"));
@@ -1386,25 +1377,25 @@ dissect_q2931_number_ie(const u_char *pd, int offset, int len,
switch (numbering_plan) {
case Q2931_ISDN_NUMBERING:
- proto_tree_add_text(tree, NullTVB, offset, len, "Number: %.*s",
- len, &pd[offset]);
+ proto_tree_add_text(tree, tvb, offset, len, "Number: %.*s",
+ len, tvb_get_ptr(tvb, offset, len));
break;
case Q2931_NSAP_ADDRESSING:
if (len < 20) {
- proto_tree_add_text(tree, NullTVB, offset, len,
+ proto_tree_add_text(tree, tvb, offset, len,
"Number (too short): %s",
- bytes_to_str(&pd[offset], len));
+ bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
return;
}
- ti = proto_tree_add_text(tree, NullTVB, offset, len, "Number");
+ ti = proto_tree_add_text(tree, tvb, offset, len, "Number");
nsap_tree = proto_item_add_subtree(ti, ett_q2931_nsap);
- dissect_atm_nsap(pd, offset, len, nsap_tree);
+ dissect_atm_nsap(tvb_get_ptr(tvb, 0, -1), offset, len, nsap_tree);
break;
default:
- proto_tree_add_text(tree, NullTVB, offset, len, "Number: %s",
- bytes_to_str(&pd[offset], len));
+ proto_tree_add_text(tree, tvb, offset, len, "Number: %s",
+ bytes_to_str(tvb_get_ptr(tvb, 0, -1), len));
break;
}
}
@@ -1426,19 +1417,19 @@ static const value_string q2931_odd_even_indicator_vals[] = {
};
static void
-dissect_q2931_party_subaddr_ie(const u_char *pd, int offset, int len,
+dissect_q2931_party_subaddr_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Type of subaddress: %s",
val_to_str(octet & 0x70, q2931_subaddress_type_vals,
"Unknown (0x%02X)"));
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Odd/even indicator: %s",
val_to_str(octet & 0x10, q2931_odd_even_indicator_vals,
NULL));
@@ -1447,8 +1438,8 @@ dissect_q2931_party_subaddr_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- proto_tree_add_text(tree, NullTVB, offset, len, "Subaddress: %s",
- bytes_to_str(&pd[offset], len));
+ proto_tree_add_text(tree, tvb, offset, len, "Subaddress: %s",
+ bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
}
/*
@@ -1468,19 +1459,19 @@ static const value_string q2931_preferred_exclusive_vals[] = {
};
static void
-dissect_q2931_connection_identifier_ie(const u_char *pd, int offset, int len,
+dissect_q2931_connection_identifier_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"VP-associated signalling: %s",
val_to_str(octet & 0x18, q2931_vp_associated_signalling_vals,
"Unknown (0x%02X)"));
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Preferred/exclusive: %s",
val_to_str(octet & 0x07, q2931_preferred_exclusive_vals,
"Unknown (0x%02X)"));
@@ -1489,50 +1480,50 @@ dissect_q2931_connection_identifier_ie(const u_char *pd, int offset, int len,
if (len < 2)
return;
- proto_tree_add_text(tree, NullTVB, offset, 2, "VPCI: %u",
- pntohs(&pd[offset]));
+ proto_tree_add_text(tree, tvb, offset, 2, "VPCI: %u",
+ tvb_get_ntohs(tvb, offset));
offset += 2;
len -= 2;
if (len < 2)
return;
- proto_tree_add_text(tree, NullTVB, offset, 2, "VCI: %u",
- pntohs(&pd[offset]));
+ proto_tree_add_text(tree, tvb, offset, 2, "VCI: %u",
+ tvb_get_ntohs(tvb, offset));
}
/*
* Dissect an End-to-end transit delay information element.
*/
static void
-dissect_q2931_e2e_transit_delay_ie(const u_char *pd, int offset, int len,
+dissect_q2931_e2e_transit_delay_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 identifier;
guint16 value;
while (len >= 3) {
- identifier = pd[offset];
- value = pntohs(&pd[offset + 1]);
+ identifier = tvb_get_guint8(tvb, offset);
+ value = tvb_get_ntohs(tvb, offset + 1);
switch (identifier) {
case 0x01: /* Cumulative transit delay identifier */
- proto_tree_add_text(tree, NullTVB, offset, 3,
+ proto_tree_add_text(tree, tvb, offset, 3,
"Cumulative transit delay: %u ms", value);
break;
case 0x03: /* Maximum transit delay identifier */
if (value == 0xFFFF) {
- proto_tree_add_text(tree, NullTVB, offset, 3,
+ proto_tree_add_text(tree, tvb, offset, 3,
"Any end-to-end transit delay value acceptable");
} else {
- proto_tree_add_text(tree, NullTVB, offset, 3,
+ proto_tree_add_text(tree, tvb, offset, 3,
"Maximum end-to-end transit delay: %u ms",
value);
}
break;
default: /* Unknown transit delay identifier */
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Unknown transit delay identifier (0x%02X)",
identifier);
return; /* give up */
@@ -1549,15 +1540,15 @@ static const value_string q2931_qos_parameter_vals[] = {
};
static void
-dissect_q2931_qos_parameter_ie(const u_char *pd, int offset, int len,
+dissect_q2931_qos_parameter_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"QOS class forward: %s",
val_to_str(octet, q2931_qos_parameter_vals,
"Unknown (0x%02X)"));
@@ -1566,8 +1557,8 @@ dissect_q2931_qos_parameter_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"QOS class backward: %s",
val_to_str(octet, q2931_qos_parameter_vals,
"Unknown (0x%02X)"));
@@ -1582,15 +1573,15 @@ static const value_string q2931_bband_rpt_indicator_vals[] = {
};
static void
-dissect_q2931_bband_rpt_indicator(const u_char *pd, int offset, int len,
+dissect_q2931_bband_rpt_indicator(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Broadband repeat indicator: %s",
val_to_str(octet & 0x0F, q2931_bband_rpt_indicator_vals,
"Unknown (0x%02X)"));
@@ -1607,15 +1598,15 @@ static const value_string q2931_class_vals[] = {
};
static void
-dissect_q2931_restart_indicator(const u_char *pd, int offset, int len,
+dissect_q2931_restart_indicator(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Restart indicator: %s",
val_to_str(octet & 0x07, q2931_class_vals,
"Unknown (0x%02X)"));
@@ -1625,24 +1616,24 @@ dissect_q2931_restart_indicator(const u_char *pd, int offset, int len,
* Dissect an broadband sending complete information element.
*/
static void
-dissect_q2931_bband_sending_compl_ie(const u_char *pd, int offset, int len,
+dissect_q2931_bband_sending_compl_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 identifier;
while (len != 0) {
- identifier = pd[offset];
+ identifier = tvb_get_guint8(tvb, offset);
switch (identifier) {
case 0xA1: /* Sending complete indication */
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Broadband sending complete indication");
offset += 1;
len -= 1;
break;
default: /* unknown broadband sending complete element */
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Unknown broadband sending complete element (0x%02X)",
identifier);
return; /* give up */
@@ -1668,19 +1659,19 @@ static const value_string q2931_netid_plan_vals[] = {
};
static void
-dissect_q2931_transit_network_sel_ie(const u_char *pd, int offset, int len,
+dissect_q2931_transit_network_sel_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Type of network identification: %s",
val_to_str(octet & 0x70, q2931_netid_type_vals,
"Unknown (0x%02X)"));
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Network identification plan: %s",
val_to_str(octet & 0x0F, q2931_netid_plan_vals,
"Unknown (0x%02X)"));
@@ -1689,8 +1680,8 @@ dissect_q2931_transit_network_sel_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- proto_tree_add_text(tree, NullTVB, offset, len,
- "Network identification: %.*s", len, &pd[offset]);
+ proto_tree_add_text(tree, tvb, offset, len,
+ "Network identification: %.*s", len, tvb_get_ptr(tvb, offset, len));
}
/*
@@ -1723,22 +1714,22 @@ static const value_string q2931_bwd_e2e_oam_f5_flow_indicator_vals[] = {
};
static void
-dissect_q2931_oam_traffic_descriptor_ie(const u_char *pd, int offset, int len,
+dissect_q2931_oam_traffic_descriptor_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Shaping indicator: %s",
val_to_str(octet & 0x60, q2931_shaping_indicator_vals,
"Unknown (0x%02X)"));
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Use of end-to-end OAM F5 flow is %s",
(octet & 0x10) ? "mandatory" : "optional");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"User-Network fault management indicator: %s",
val_to_str(octet & 0x07, q2931_user_net_fault_mgmt_vals,
"Unknown (0x%02X)"));
@@ -1747,12 +1738,12 @@ dissect_q2931_oam_traffic_descriptor_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Forward end-to-end OAM F5 flow indicator: %s",
val_to_str(octet & 0x70, q2931_fwd_e2e_oam_f5_flow_indicator_vals,
"Unknown (0x%02X)"));
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Backward end-to-end OAM F5 flow indicator: %s",
val_to_str(octet & 0x07, q2931_bwd_e2e_oam_f5_flow_indicator_vals,
"Unknown (0x%02X)"));
@@ -1767,7 +1758,7 @@ static const value_string q2931_endpoint_reference_type_vals[] = {
};
static void
-dissect_q2931_endpoint_reference_ie(const u_char *pd, int offset, int len,
+dissect_q2931_endpoint_reference_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
@@ -1775,8 +1766,8 @@ dissect_q2931_endpoint_reference_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Endpoint reference type: %s",
val_to_str(octet, q2931_endpoint_reference_type_vals,
"Unknown (0x%02X)"));
@@ -1785,12 +1776,12 @@ dissect_q2931_endpoint_reference_ie(const u_char *pd, int offset, int len,
if (len < 2)
return;
- value = pntohs(&pd[offset]);
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ value = tvb_get_ntohs(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 2,
"Endpoint reference flag: %s",
(value & 0x8000) ? "Message sent to side that originates the endpoint reference" :
"Message sent from side that originates the endpoint reference");
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ proto_tree_add_text(tree, tvb, offset, 2,
"Endpoint reference identifier value: %u",
value & 0x7FFF);
}
@@ -1809,178 +1800,180 @@ static const value_string q2931_endpoint_reference_party_state_vals[] = {
};
static void
-dissect_q2931_endpoint_state_ie(const u_char *pd, int offset, int len,
+dissect_q2931_endpoint_state_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
if (len == 0)
return;
- octet = pd[offset];
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ octet = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1,
"Endpoint reference party-state: %s",
val_to_str(octet & 0x3F, q2931_endpoint_reference_party_state_vals,
"Unknown (0x%02X)"));
}
static void
-dissect_q2931_ie_contents(const u_char *pd, int offset, int len,
+dissect_q2931_ie_contents(tvbuff_t *tvb, int offset, int len,
proto_tree *tree, guint8 info_element)
{
switch (info_element) {
case Q2931_IE_BBAND_LOCKING_SHIFT:
case Q2931_IE_BBAND_NLOCKING_SHIFT:
- dissect_q2931_shift_ie(pd, offset, len, tree, info_element);
+ dissect_q2931_shift_ie(tvb, offset, len, tree, info_element);
break;
case Q2931_IE_NBAND_BEARER_CAP:
case Q2931_IE_NBAND_LOW_LAYER_COMPAT:
- dissect_q931_bearer_capability_ie(pd, offset, len, tree);
+ dissect_q931_bearer_capability_ie(tvb, offset, len, tree);
break;
case Q2931_IE_NBAND_HIGH_LAYER_COMPAT:
- dissect_q931_high_layer_compat_ie(pd, offset, len, tree);
+ dissect_q931_high_layer_compat_ie(tvb, offset, len, tree);
break;
case Q2931_IE_PROGRESS_INDICATOR:
- dissect_q931_progress_indicator_ie(pd, offset, len, tree);
+ dissect_q931_progress_indicator_ie(tvb, offset, len, tree);
break;
case Q2931_IE_AAL_PARAMETERS:
- dissect_q2931_aal_parameters_ie(pd, offset, len, tree);
+ dissect_q2931_aal_parameters_ie(tvb, offset, len, tree);
break;
case Q2931_IE_ATM_USER_CELL_RATE:
- dissect_q2931_atm_cell_rate_ie(pd, offset, len, tree);
+ dissect_q2931_atm_cell_rate_ie(tvb, offset, len, tree);
break;
case Q2931_IE_BBAND_BEARER_CAP:
- dissect_q2931_bband_bearer_cap_ie(pd, offset, len, tree);
+ dissect_q2931_bband_bearer_cap_ie(tvb, offset, len, tree);
break;
case Q2931_IE_BBAND_HI_LAYER_INFO:
- dissect_q2931_bband_hi_layer_info_ie(pd, offset, len, tree);
+ dissect_q2931_bband_hi_layer_info_ie(tvb, offset, len, tree);
break;
case Q2931_IE_BBAND_LOW_LAYER_INFO:
- dissect_q2931_bband_low_layer_info_ie(pd, offset, len, tree);
+ dissect_q2931_bband_low_layer_info_ie(tvb, offset, len, tree);
break;
case Q2931_IE_CALL_STATE:
- dissect_q2931_call_state_ie(pd, offset, len, tree);
+ dissect_q2931_call_state_ie(tvb, offset, len, tree);
break;
case Q2931_IE_CALLED_PARTY_NUMBER:
case Q2931_IE_CALLING_PARTY_NUMBER:
- dissect_q2931_number_ie(pd, offset, len, tree);
+ dissect_q2931_number_ie(tvb, offset, len, tree);
break;
case Q2931_IE_CALLED_PARTY_SUBADDR:
case Q2931_IE_CALLING_PARTY_SUBADDR:
- dissect_q2931_party_subaddr_ie(pd, offset, len, tree);
+ dissect_q2931_party_subaddr_ie(tvb, offset, len, tree);
break;
case Q2931_IE_CAUSE:
- dissect_q2931_cause_ie(pd, offset, len, tree);
+ dissect_q2931_cause_ie(tvb, offset, len, tree);
break;
case Q2931_IE_CONNECTION_IDENTIFIER:
- dissect_q2931_connection_identifier_ie(pd, offset, len, tree);
+ dissect_q2931_connection_identifier_ie(tvb, offset, len, tree);
break;
case Q2931_IE_E2E_TRANSIT_DELAY:
- dissect_q2931_e2e_transit_delay_ie(pd, offset, len, tree);
+ dissect_q2931_e2e_transit_delay_ie(tvb, offset, len, tree);
break;
case Q2931_IE_QOS_PARAMETER:
- dissect_q2931_qos_parameter_ie(pd, offset, len, tree);
+ dissect_q2931_qos_parameter_ie(tvb, offset, len, tree);
break;
case Q2931_IE_BBAND_RPT_INDICATOR:
- dissect_q2931_bband_rpt_indicator(pd, offset, len, tree);
+ dissect_q2931_bband_rpt_indicator(tvb, offset, len, tree);
break;
case Q2931_IE_RESTART_INDICATOR:
- dissect_q2931_restart_indicator(pd, offset, len, tree);
+ dissect_q2931_restart_indicator(tvb, offset, len, tree);
break;
case Q2931_IE_BBAND_SENDING_COMPL:
- dissect_q2931_bband_sending_compl_ie(pd, offset, len, tree);
+ dissect_q2931_bband_sending_compl_ie(tvb, offset, len, tree);
break;
case Q2931_IE_TRANSIT_NETWORK_SEL:
- dissect_q2931_transit_network_sel_ie(pd, offset, len, tree);
+ dissect_q2931_transit_network_sel_ie(tvb, offset, len, tree);
break;
case Q2931_IE_OAM_TRAFFIC_DESCRIPTOR:
- dissect_q2931_oam_traffic_descriptor_ie(pd, offset, len, tree);
+ dissect_q2931_oam_traffic_descriptor_ie(tvb, offset, len, tree);
break;
case Q2931_IE_ENDPOINT_REFERENCE:
- dissect_q2931_endpoint_reference_ie(pd, offset, len, tree);
+ dissect_q2931_endpoint_reference_ie(tvb, offset, len, tree);
break;
case Q2931_IE_ENDPOINT_STATE:
- dissect_q2931_endpoint_state_ie(pd, offset, len, tree);
+ dissect_q2931_endpoint_state_ie(tvb, offset, len, tree);
break;
}
}
static void
-dissect_q2931_ie(const u_char *pd, int offset, int len, proto_tree *tree,
+dissect_q2931_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree,
guint8 info_element, guint8 info_element_ext)
{
proto_item *ti;
proto_tree *ie_tree;
proto_tree *ie_ext_tree;
- ti = proto_tree_add_text(tree, NullTVB, offset, 1+1+2+len, "%s",
+ ti = proto_tree_add_text(tree, tvb, offset, 1+1+2+len, "%s",
val_to_str(info_element, q2931_info_element_vals,
"Unknown information element (0x%02X)"));
ie_tree = proto_item_add_subtree(ti, ett_q2931_ie);
- proto_tree_add_text(ie_tree, NullTVB, offset, 1, "Information element: %s",
+ proto_tree_add_text(ie_tree, tvb, offset, 1, "Information element: %s",
val_to_str(info_element, q2931_info_element_vals,
"Unknown (0x%02X)"));
- ti = proto_tree_add_text(ie_tree, NullTVB, offset + 1, 1,
+ ti = proto_tree_add_text(ie_tree, tvb, offset + 1, 1,
"Information element extension: 0x%02x",
info_element_ext);
ie_ext_tree = proto_item_add_subtree(ti, ett_q2931_ie_ext);
- proto_tree_add_text(ie_ext_tree, NullTVB, offset + 1, 1,
+ proto_tree_add_text(ie_ext_tree, tvb, offset + 1, 1,
decode_enumerated_bitfield(info_element_ext,
Q2931_IE_COMPAT_CODING_STD, 8,
coding_std_vals, "Coding standard: %s"));
- proto_tree_add_text(ie_ext_tree, NullTVB, offset + 1, 1,
+ proto_tree_add_text(ie_ext_tree, tvb, offset + 1, 1,
decode_boolean_bitfield(info_element_ext,
Q2931_IE_COMPAT_FOLLOW_INST, 8,
"Follow explicit error handling instructions",
"Regular error handling procedures apply"));
if (info_element_ext & Q2931_IE_COMPAT_FOLLOW_INST) {
- proto_tree_add_text(ie_ext_tree, NullTVB, offset + 1, 1,
+ proto_tree_add_text(ie_ext_tree, tvb, offset + 1, 1,
decode_enumerated_bitfield(info_element_ext,
Q2931_IE_COMPAT_ACTION_IND, 8,
ie_action_ind_vals,
"Action indicator: %s"));
}
- proto_tree_add_text(ie_tree, NullTVB, offset + 2, 2, "Length: %u", len);
+ proto_tree_add_text(ie_tree, tvb, offset + 2, 2, "Length: %u", len);
if ((info_element_ext & Q2931_IE_COMPAT_CODING_STD)
== Q2931_ITU_STANDARDIZED_CODING) {
- dissect_q2931_ie_contents(pd, offset + 4,
+ dissect_q2931_ie_contents(tvb, offset + 4,
len, ie_tree, info_element);
} else {
/*
* We don't know how it's encoded, so just
* dump it as data and be done with it.
*/
- proto_tree_add_text(ie_tree, NullTVB, offset + 4, len,
- "Data: %s", bytes_to_str(&pd[offset + 4], len));
+ proto_tree_add_text(ie_tree, tvb, offset + 4, len,
+ "Data: %s", bytes_to_str(tvb_get_ptr(tvb, offset + 4, len), len));
}
}
void
-dissect_q2931(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+dissect_q2931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
+ int offset = 0;
+ guint reported_length;
proto_tree *q2931_tree = NULL;
proto_item *ti;
proto_tree *ext_tree;
@@ -1995,55 +1988,57 @@ dissect_q2931(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
int codeset;
gboolean non_locking_shift;
- if (check_col(fd, COL_PROTOCOL))
- col_add_str(fd, COL_PROTOCOL, "Q.2931");
+ pinfo->current_proto = "Q.2931";
+
+ if (check_col(pinfo->fd, COL_PROTOCOL))
+ col_add_str(pinfo->fd, COL_PROTOCOL, "Q.2931");
if (tree) {
- ti = proto_tree_add_item(tree, proto_q2931, NullTVB, offset,
- END_OF_FRAME, NULL);
+ ti = proto_tree_add_item(tree, proto_q2931, tvb, offset,
+ tvb_length(tvb), NULL);
q2931_tree = proto_item_add_subtree(ti, ett_q2931);
- proto_tree_add_item(q2931_tree, hf_q2931_discriminator, NullTVB, offset, 1, pd[offset]);
+ proto_tree_add_item(q2931_tree, hf_q2931_discriminator, tvb, offset, 1, tvb_get_guint8(tvb, offset));
}
offset += 1;
- call_ref_len = pd[offset] & 0xF; /* XXX - do as a bit field? */
+ call_ref_len = tvb_get_guint8(tvb, offset) & 0xF; /* XXX - do as a bit field? */
if (q2931_tree != NULL)
- proto_tree_add_item(q2931_tree, hf_q2931_call_ref_len, NullTVB, offset, 1, call_ref_len);
+ proto_tree_add_item(q2931_tree, hf_q2931_call_ref_len, tvb, offset, 1, call_ref_len);
offset += 1;
if (call_ref_len != 0) {
/* XXX - split this into flag and value */
- memcpy(call_ref, &pd[offset], call_ref_len);
+ tvb_memcpy(tvb, call_ref, offset, call_ref_len);
if (q2931_tree != NULL)
- proto_tree_add_item(q2931_tree, hf_q2931_call_ref, NullTVB, offset, call_ref_len, call_ref);
+ proto_tree_add_item(q2931_tree, hf_q2931_call_ref, tvb, offset, call_ref_len, call_ref);
offset += call_ref_len;
}
- message_type = pd[offset];
- if (check_col(fd, COL_INFO)) {
- col_add_str(fd, COL_INFO,
+ message_type = tvb_get_guint8(tvb, offset);
+ if (check_col(pinfo->fd, COL_INFO)) {
+ col_add_str(pinfo->fd, COL_INFO,
val_to_str(message_type, q2931_message_type_vals,
"Unknown message type (0x%02X)"));
}
if (q2931_tree != NULL)
- proto_tree_add_item(q2931_tree, hf_q2931_message_type, NullTVB, offset, 1, message_type);
+ proto_tree_add_item(q2931_tree, hf_q2931_message_type, tvb, offset, 1, message_type);
offset += 1;
- message_type_ext = pd[offset];
+ message_type_ext = tvb_get_guint8(tvb, offset);
if (q2931_tree != NULL) {
- ti = proto_tree_add_item(q2931_tree, hf_q2931_message_type_ext, NullTVB,
+ ti = proto_tree_add_item(q2931_tree, hf_q2931_message_type_ext, tvb,
offset, 1, message_type_ext);
ext_tree = proto_item_add_subtree(ti, ett_q2931_ext);
- proto_tree_add_item(ext_tree, hf_q2931_message_flag, NullTVB,
+ proto_tree_add_item(ext_tree, hf_q2931_message_flag, tvb,
offset, 1, message_type_ext);
if (message_type_ext & Q2931_MSG_TYPE_EXT_FOLLOW_INST) {
- proto_tree_add_item(ext_tree, hf_q2931_message_action_indicator, NullTVB,
+ proto_tree_add_item(ext_tree, hf_q2931_message_action_indicator, tvb,
offset, 1, message_type_ext);
}
}
offset += 1;
- message_len = pntohs(&pd[offset]);
+ message_len = tvb_get_ntohs(tvb, offset);
if (q2931_tree != NULL)
- proto_tree_add_item(q2931_tree, hf_q2931_message_len, NullTVB, offset, 2, message_len);
+ proto_tree_add_item(q2931_tree, hf_q2931_message_len, tvb, offset, 2, message_len);
offset += 2;
/*
@@ -2051,18 +2046,13 @@ dissect_q2931(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
*/
codeset = 0; /* start out in codeset 0 */
non_locking_shift = TRUE;
- while (IS_DATA_IN_FRAME(offset)) {
- info_element = pd[offset];
- if (!BYTES_ARE_IN_FRAME(offset + 1, 1))
- break; /* ran past end of frame */
- info_element_ext = pd[offset + 1];
- if (!BYTES_ARE_IN_FRAME(offset + 2, 2))
- break; /* ran past end of frame */
- info_element_len = pntohs(&pd[offset + 2]);
- if (!BYTES_ARE_IN_FRAME(offset + 4, info_element_len))
- break; /* ran past end of frame */
+ reported_length = tvb_reported_length(tvb);
+ while (offset < reported_length) {
+ info_element = tvb_get_guint8(tvb, offset);
+ info_element_ext = tvb_get_guint8(tvb, offset + 1);
+ info_element_len = tvb_get_ntohs(tvb, offset + 2);
if (q2931_tree != NULL) {
- dissect_q2931_ie(pd, offset, info_element_len,
+ dissect_q2931_ie(tvb, offset, info_element_len,
q2931_tree, info_element, info_element_ext);
}
if (non_locking_shift)
@@ -2076,14 +2066,14 @@ dissect_q2931(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case Q2931_IE_BBAND_LOCKING_SHIFT:
if (info_element_len >= 1) {
non_locking_shift = FALSE;
- codeset = pd[offset + 4] & 0x07;
+ codeset = tvb_get_guint8(tvb, offset + 4) & 0x07;
}
break;
case Q2931_IE_BBAND_NLOCKING_SHIFT:
if (info_element_len >= 1) {
non_locking_shift = TRUE;
- codeset = pd[offset + 4] & 0x07;
+ codeset = tvb_get_guint8(tvb, offset + 4) & 0x07;
}
break;
}
@@ -2094,49 +2084,49 @@ dissect_q2931(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
void
proto_register_q2931(void)
{
- static hf_register_info hf[] = {
- { &hf_q2931_discriminator,
- { "Protocol discriminator", "q2931.disc", FT_UINT8, BASE_HEX, NULL, 0x0,
- "" }},
-
- { &hf_q2931_call_ref_len,
- { "Call reference value length", "q2931.call_ref_len", FT_UINT8, BASE_DEC, NULL, 0x0,
- "" }},
-
- { &hf_q2931_call_ref,
- { "Call reference value", "q2931.call_ref", FT_BYTES, BASE_HEX, NULL, 0x0,
- "" }},
-
- { &hf_q2931_message_type,
- { "Message type", "q2931.message_type", FT_UINT8, BASE_HEX, VALS(q2931_message_type_vals), 0x0,
- "" }},
-
- { &hf_q2931_message_type_ext,
- { "Message type extension", "q2931.message_type_ext", FT_UINT8, BASE_HEX, NULL, 0x0,
- "" }},
-
- { &hf_q2931_message_flag,
- { "Flag", "q2931.message_flag", FT_BOOLEAN, 8, TFS(&tos_msg_flag), Q2931_MSG_TYPE_EXT_FOLLOW_INST,
- "" }},
-
- { &hf_q2931_message_action_indicator,
- { "Action indicator", "q2931.message_action_indicator", FT_UINT8, BASE_DEC, VALS(msg_action_ind_vals), Q2931_MSG_TYPE_EXT_ACTION_IND,
- "" }},
-
- { &hf_q2931_message_len,
- { "Message length", "q2931.message_len", FT_UINT16, BASE_DEC, NULL, 0x0,
- "" }},
-
- };
- static gint *ett[] = {
- &ett_q2931,
- &ett_q2931_ext,
- &ett_q2931_ie,
- &ett_q2931_ie_ext,
- &ett_q2931_nsap,
- };
-
- proto_q2931 = proto_register_protocol ("Q.2931", "q2931");
- proto_register_field_array (proto_q2931, hf, array_length(hf));
- proto_register_subtree_array(ett, array_length(ett));
+ static hf_register_info hf[] = {
+ { &hf_q2931_discriminator,
+ { "Protocol discriminator", "q2931.disc", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
+
+ { &hf_q2931_call_ref_len,
+ { "Call reference value length", "q2931.call_ref_len", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
+ { &hf_q2931_call_ref,
+ { "Call reference value", "q2931.call_ref", FT_BYTES, BASE_HEX, NULL, 0x0,
+ "" }},
+
+ { &hf_q2931_message_type,
+ { "Message type", "q2931.message_type", FT_UINT8, BASE_HEX, VALS(q2931_message_type_vals), 0x0,
+ "" }},
+
+ { &hf_q2931_message_type_ext,
+ { "Message type extension", "q2931.message_type_ext", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
+
+ { &hf_q2931_message_flag,
+ { "Flag", "q2931.message_flag", FT_BOOLEAN, 8, TFS(&tos_msg_flag), Q2931_MSG_TYPE_EXT_FOLLOW_INST,
+ "" }},
+
+ { &hf_q2931_message_action_indicator,
+ { "Action indicator", "q2931.message_action_indicator", FT_UINT8, BASE_DEC, VALS(msg_action_ind_vals), Q2931_MSG_TYPE_EXT_ACTION_IND,
+ "" }},
+
+ { &hf_q2931_message_len,
+ { "Message length", "q2931.message_len", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
+
+ };
+ static gint *ett[] = {
+ &ett_q2931,
+ &ett_q2931_ext,
+ &ett_q2931_ie,
+ &ett_q2931_ie_ext,
+ &ett_q2931_nsap,
+ };
+
+ proto_q2931 = proto_register_protocol ("Q.2931", "q2931");
+ proto_register_field_array (proto_q2931, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
}