aboutsummaryrefslogtreecommitdiffstats
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
parentcb5b6c4719439cc777a78ae0b3c98088ac114d92 (diff)
downloadwireshark-10ea13ed18be32c74c42ac023ae1258f79c6406e.tar.gz
wireshark-10ea13ed18be32c74c42ac023ae1258f79c6406e.tar.bz2
wireshark-10ea13ed18be32c74c42ac023ae1258f79c6406e.zip
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
-rw-r--r--packet-atm.c310
-rw-r--r--packet-atm.h5
-rw-r--r--packet-lapd.c10
-rw-r--r--packet-q2931.c632
-rw-r--r--packet-q2931.h5
-rw-r--r--packet-q931.c616
-rw-r--r--packet-q931.h10
-rw-r--r--packet-sscop.c133
-rw-r--r--packet-sscop.h5
-rw-r--r--packet.c6
-rw-r--r--tvbuff.c83
-rw-r--r--tvbuff.h7
12 files changed, 935 insertions, 887 deletions
diff --git a/packet-atm.c b/packet-atm.c
index 5a7bbcfb59..500c41a485 100644
--- a/packet-atm.c
+++ b/packet-atm.c
@@ -1,7 +1,7 @@
/* packet-atm.c
* Routines for ATM packet disassembly
*
- * $Id: packet-atm.c,v 1.20 2000/05/19 23:06:08 gram Exp $
+ * $Id: packet-atm.c,v 1.21 2000/05/29 08:57:36 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -148,22 +148,22 @@ static const value_string le_control_lan_type_vals[] = {
};
static void
-dissect_le_client(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+dissect_le_client(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *ti;
proto_tree *lane_tree;
if (tree) {
- ti = proto_tree_add_protocol_format(tree, proto_atm_lane, NullTVB, offset, 2, "ATM LANE");
+ ti = proto_tree_add_protocol_format(tree, proto_atm_lane, tvb, 0, 2, "ATM LANE");
lane_tree = proto_item_add_subtree(ti, ett_atm_lane);
- proto_tree_add_text(lane_tree, NullTVB, offset, 2, "LE Client: 0x%04X",
- pntohs(&pd[offset]));
+ proto_tree_add_text(lane_tree, tvb, 0, 2, "LE Client: 0x%04X",
+ tvb_get_ntohs(tvb, 0));
}
}
static void
-dissect_lan_destination(const u_char *pd, int offset, const char *type, proto_tree *tree)
+dissect_lan_destination(tvbuff_t *tvb, int offset, const char *type, proto_tree *tree)
{
proto_item *td;
proto_tree *dest_tree;
@@ -172,11 +172,11 @@ dissect_lan_destination(const u_char *pd, int offset, const char *type, proto_tr
proto_tree *rd_tree;
guint16 route_descriptor;
- td = proto_tree_add_text(tree, NullTVB, offset, 8, "%s LAN destination",
+ td = proto_tree_add_text(tree, tvb, offset, 8, "%s LAN destination",
type);
dest_tree = proto_item_add_subtree(td, ett_atm_lane_lc_lan_dest);
- tag = pntohs(&pd[offset]);
- proto_tree_add_text(dest_tree, NullTVB, offset, 2, "Tag: %s",
+ tag = tvb_get_ntohs(tvb, offset);
+ proto_tree_add_text(dest_tree, tvb, offset, 2, "Tag: %s",
val_to_str(tag, le_control_landest_tag_vals,
"Unknown (0x%04X)"));
offset += 2;
@@ -184,20 +184,20 @@ dissect_lan_destination(const u_char *pd, int offset, const char *type, proto_tr
switch (tag) {
case TAG_MAC_ADDRESS:
- proto_tree_add_text(dest_tree, NullTVB, offset, 6, "MAC address: %s",
- ether_to_str((u_char *)&pd[offset]));
+ proto_tree_add_text(dest_tree, tvb, offset, 6, "MAC address: %s",
+ ether_to_str(tvb_get_ptr(tvb, offset, 6)));
break;
case TAG_ROUTE_DESCRIPTOR:
offset += 4;
- route_descriptor = pntohs(&pd[offset]);
- trd = proto_tree_add_text(dest_tree, NullTVB, offset, 2, "Route descriptor: 0x%02X",
+ route_descriptor = tvb_get_ntohs(tvb, offset);
+ trd = proto_tree_add_text(dest_tree, tvb, offset, 2, "Route descriptor: 0x%02X",
route_descriptor);
rd_tree = proto_item_add_subtree(td, ett_atm_lane_lc_lan_dest_rd);
- proto_tree_add_text(rd_tree, NullTVB, offset, 2,
+ proto_tree_add_text(rd_tree, tvb, offset, 2,
decode_numeric_bitfield(route_descriptor, 0xFFF0, 2*8,
"LAN ID = %u"));
- proto_tree_add_text(rd_tree, NullTVB, offset, 2,
+ proto_tree_add_text(rd_tree, tvb, offset, 2,
decode_numeric_bitfield(route_descriptor, 0x000F, 2*8,
"Bridge number = %u"));
break;
@@ -245,10 +245,11 @@ static const value_string le_tlv_type_vals[] = {
};
static void
-dissect_le_control(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+dissect_le_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *ti;
proto_tree *lane_tree;
+ int offset = 0;
proto_item *tf;
proto_tree *flags_tree;
proto_item *ttlv;
@@ -259,27 +260,27 @@ dissect_le_control(const u_char *pd, int offset, frame_data *fd, proto_tree *tre
guint32 tlv_type;
guint8 tlv_length;
- if (check_col(fd, COL_INFO))
- col_add_str(fd, COL_INFO, "LE Control");
+ if (check_col(pinfo->fd, COL_INFO))
+ col_add_str(pinfo->fd, COL_INFO, "LE Control");
if (tree) {
- ti = proto_tree_add_protocol_format(tree, proto_atm_lane, NullTVB, offset, 108, "ATM LANE");
+ ti = proto_tree_add_protocol_format(tree, proto_atm_lane, tvb, offset, 108, "ATM LANE");
lane_tree = proto_item_add_subtree(ti, ett_atm_lane);
- proto_tree_add_text(lane_tree, NullTVB, offset, 2, "Marker: 0x%04X",
- pntohs(&pd[offset]));
+ proto_tree_add_text(lane_tree, tvb, offset, 2, "Marker: 0x%04X",
+ tvb_get_ntohs(tvb, offset));
offset += 2;
- proto_tree_add_text(lane_tree, NullTVB, offset, 1, "Protocol: 0x%02X",
- pd[offset]);
+ proto_tree_add_text(lane_tree, tvb, offset, 1, "Protocol: 0x%02X",
+ tvb_get_guint8(tvb, offset));
offset += 1;
- proto_tree_add_text(lane_tree, NullTVB, offset, 1, "Version: 0x%02X",
- pd[offset]);
+ proto_tree_add_text(lane_tree, tvb, offset, 1, "Version: 0x%02X",
+ tvb_get_guint8(tvb, offset));
offset += 1;
- opcode = pntohs(&pd[offset]);
- proto_tree_add_text(lane_tree, NullTVB, offset, 2, "Opcode: %s",
+ opcode = tvb_get_ntohs(tvb, offset);
+ proto_tree_add_text(lane_tree, tvb, offset, 2, "Opcode: %s",
val_to_str(opcode, le_control_opcode_vals,
"Unknown (0x%04X)"));
offset += 2;
@@ -291,80 +292,80 @@ dissect_le_control(const u_char *pd, int offset, frame_data *fd, proto_tree *tre
if (opcode & 0x0100) {
/* Response; decode status. */
- proto_tree_add_text(lane_tree, NullTVB, offset, 2, "Status: %s",
- val_to_str(pntohs(&pd[offset]), le_control_status_vals,
+ proto_tree_add_text(lane_tree, tvb, offset, 2, "Status: %s",
+ val_to_str(tvb_get_ntohs(tvb, offset), le_control_status_vals,
"Unknown (0x%04X)"));
}
offset += 2;
- proto_tree_add_text(lane_tree, NullTVB, offset, 4, "Transaction ID: 0x%08X",
- pntohl(&pd[offset]));
+ proto_tree_add_text(lane_tree, tvb, offset, 4, "Transaction ID: 0x%08X",
+ tvb_get_ntohl(tvb, offset));
offset += 4;
- proto_tree_add_text(lane_tree, NullTVB, offset, 2, "Requester LECID: 0x%04X",
- pntohs(&pd[offset]));
+ proto_tree_add_text(lane_tree, tvb, offset, 2, "Requester LECID: 0x%04X",
+ tvb_get_ntohs(tvb, offset));
offset += 2;
- flags = pntohs(&pd[offset]);
- tf = proto_tree_add_text(lane_tree, NullTVB, offset, 2, "Flags: 0x%04X",
- pntohs(&pd[offset]));
+ flags = tvb_get_ntohs(tvb, offset);
+ tf = proto_tree_add_text(lane_tree, tvb, offset, 2, "Flags: 0x%04X",
+ flags);
flags_tree = proto_item_add_subtree(tf, ett_atm_lane_lc_flags);
- proto_tree_add_text(flags_tree, NullTVB, offset, 2, "%s",
+ proto_tree_add_text(flags_tree, tvb, offset, 2, "%s",
decode_boolean_bitfield(flags, 0x0001, 8*2,
"Remote address", "Local address"));
- proto_tree_add_text(flags_tree, NullTVB, offset, 2, "%s",
+ proto_tree_add_text(flags_tree, tvb, offset, 2, "%s",
decode_boolean_bitfield(flags, 0x0080, 8*2,
"Proxy", "Not proxy"));
- proto_tree_add_text(flags_tree, NullTVB, offset, 2, "%s",
+ proto_tree_add_text(flags_tree, tvb, offset, 2, "%s",
decode_boolean_bitfield(flags, 0x0100, 8*2,
"Topology change", "No topology change"));
offset += 2;
- dissect_lan_destination(pd, offset, "Source", lane_tree);
+ dissect_lan_destination(tvb, offset, "Source", lane_tree);
offset += 8;
- dissect_lan_destination(pd, offset, "Target", lane_tree);
+ dissect_lan_destination(tvb, offset, "Target", lane_tree);
offset += 8;
- proto_tree_add_text(lane_tree, NullTVB, offset, 20, "Source ATM Address: %s",
- bytes_to_str(&pd[offset], 20));
+ proto_tree_add_text(lane_tree, tvb, offset, 20, "Source ATM Address: %s",
+ bytes_to_str(tvb_get_ptr(tvb, offset, 20), 20));
offset += 20;
- proto_tree_add_text(lane_tree, NullTVB, offset, 1, "LAN type: %s",
- val_to_str(pd[offset], le_control_lan_type_vals,
+ proto_tree_add_text(lane_tree, tvb, offset, 1, "LAN type: %s",
+ val_to_str(tvb_get_guint8(tvb, offset), le_control_lan_type_vals,
"Unknown (0x%02X)"));
offset += 1;
- proto_tree_add_text(lane_tree, NullTVB, offset, 1, "Maximum frame size: %u",
- pd[offset]);
+ proto_tree_add_text(lane_tree, tvb, offset, 1, "Maximum frame size: %u",
+ tvb_get_guint8(tvb, offset));
offset += 1;
- num_tlvs = pd[offset];
- proto_tree_add_text(lane_tree, NullTVB, offset, 1, "Number of TLVs: %u",
+ num_tlvs = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(lane_tree, tvb, offset, 1, "Number of TLVs: %u",
num_tlvs);
offset += 1;
- proto_tree_add_text(lane_tree, NullTVB, offset, 1, "ELAN name size: %u",
- pd[offset]);
+ proto_tree_add_text(lane_tree, tvb, offset, 1, "ELAN name size: %u",
+ tvb_get_guint8(tvb, offset));
offset += 1;
- proto_tree_add_text(lane_tree, NullTVB, offset, 20, "Target ATM Address: %s",
- bytes_to_str(&pd[offset], 20));
+ proto_tree_add_text(lane_tree, tvb, offset, 20, "Target ATM Address: %s",
+ bytes_to_str(tvb_get_ptr(tvb, offset, 20), 20));
offset += 20;
- proto_tree_add_text(lane_tree, NullTVB, offset, 32, "ELAN name: %s",
- bytes_to_str(&pd[offset], 32));
+ proto_tree_add_text(lane_tree, tvb, offset, 32, "ELAN name: %s",
+ bytes_to_str(tvb_get_ptr(tvb, offset, 32), 32));
offset += 32;
while (num_tlvs != 0) {
- tlv_type = pntohl(&pd[offset]);
- tlv_length = pd[offset+4];
- ttlv = proto_tree_add_text(lane_tree, NullTVB, offset, 5+tlv_length, "TLV type: %s",
+ tlv_type = tvb_get_ntohl(tvb, offset);
+ tlv_length = tvb_get_guint8(tvb, offset+4);
+ ttlv = proto_tree_add_text(lane_tree, tvb, offset, 5+tlv_length, "TLV type: %s",
val_to_str(tlv_type, le_tlv_type_vals, "Unknown (0x%08x)"));
tlv_tree = proto_item_add_subtree(ttlv, ett_atm_lane_lc_tlv);
- proto_tree_add_text(tlv_tree, NullTVB, offset, 4, "TLV Type: %s",
+ proto_tree_add_text(tlv_tree, tvb, offset, 4, "TLV Type: %s",
val_to_str(tlv_type, le_tlv_type_vals, "Unknown (0x%08x)"));
- proto_tree_add_text(tlv_tree, NullTVB, offset+4, 1, "TLV Length: %u", tlv_length);
+ proto_tree_add_text(tlv_tree, tvb, offset+4, 1, "TLV Length: %u", tlv_length);
offset += 5+tlv_length;
num_tlvs--;
}
@@ -372,47 +373,47 @@ dissect_le_control(const u_char *pd, int offset, frame_data *fd, proto_tree *tre
}
static void
-dissect_lane(const union wtap_pseudo_header *pseudo_header, const u_char *pd,
- int offset, frame_data *fd, proto_tree *tree)
+dissect_lane(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
tvbuff_t *next_tvb;
tvbuff_t *next_tvb_le_client;
+ pinfo->current_proto = "ATM LANE";
- if (check_col(fd, COL_PROTOCOL))
- col_add_str(fd, COL_PROTOCOL, "ATM LANE");
- if (check_col(fd, COL_INFO))
- col_add_str(fd, COL_INFO, "ATM LANE");
+ if (check_col(pinfo->fd, COL_PROTOCOL))
+ col_add_str(pinfo->fd, COL_PROTOCOL, "ATM LANE");
+ if (check_col(pinfo->fd, COL_INFO))
+ col_add_str(pinfo->fd, COL_INFO, "ATM LANE");
/* Is it LE Control, 802.3, 802.5, or "none of the above"? */
- switch (pseudo_header->ngsniffer_atm.AppHLType) {
+ switch (pinfo->pseudo_header->ngsniffer_atm.AppHLType) {
case AHLT_LANE_LE_CTRL:
- dissect_le_control(pd, offset, fd, tree);
+ dissect_le_control(tvb, pinfo, tree);
break;
case AHLT_LANE_802_3:
case AHLT_LANE_802_3_MC:
- dissect_le_client(pd, offset, fd, tree);
+ dissect_le_client(tvb, pinfo, tree);
/* Dissect as Ethernet */
- next_tvb_le_client = tvb_new_subset(pi.compat_top_tvb, offset+2, -1, -1);
- dissect_eth(next_tvb_le_client, &pi, tree);
+ next_tvb_le_client = tvb_new_subset(tvb, 2, -1, -1);
+ dissect_eth(next_tvb_le_client, pinfo, tree);
break;
case AHLT_LANE_802_5:
case AHLT_LANE_802_5_MC:
- dissect_le_client(pd, offset, fd, tree);
+ dissect_le_client(tvb, pinfo, tree);
/* Dissect as Token-Ring */
- next_tvb_le_client = tvb_new_subset(pi.compat_top_tvb, offset+2, -1, -1);
- dissect_tr(next_tvb_le_client, &pi, tree);
+ next_tvb_le_client = tvb_new_subset(tvb, 2, -1, -1);
+ dissect_tr(next_tvb_le_client, pinfo, tree);
break;
default:
/* Dump it as raw data. */
- next_tvb = tvb_new_subset(pi.compat_top_tvb, offset, -1, -1);
- dissect_data_tvb(next_tvb, &pi, tree);
+ next_tvb = tvb_new_subset(tvb, 0, -1, -1);
+ dissect_data_tvb(next_tvb, pinfo, tree);
break;
}
}
@@ -485,21 +486,22 @@ static const value_string ipsilon_type_vals[] = {
* We at least know it's AAL5....
*/
static void
-atm_guess_content(union wtap_pseudo_header *pseudo_header, const u_char *pd,
- frame_data *fd)
+atm_guess_content(tvbuff_t *tvb, packet_info *pinfo)
{
- if (pseudo_header->ngsniffer_atm.Vpi == 0) {
+ guint8 byte0, byte1, byte2;
+
+ if (pinfo->pseudo_header->ngsniffer_atm.Vpi == 0) {
/*
* Traffic on some PVCs with a VPI of 0 and certain
* VCIs is of particular types.
*/
- switch (pseudo_header->ngsniffer_atm.Vci) {
+ switch (pinfo->pseudo_header->ngsniffer_atm.Vci) {
case 5:
/*
* Signalling AAL.
*/
- pseudo_header->ngsniffer_atm.AppTrafType =
+ pinfo->pseudo_header->ngsniffer_atm.AppTrafType =
ATT_AAL_SIGNALLING;
return;
@@ -507,7 +509,7 @@ atm_guess_content(union wtap_pseudo_header *pseudo_header, const u_char *pd,
/*
* ILMI.
*/
- pseudo_header->ngsniffer_atm.AppTrafType |=
+ pinfo->pseudo_header->ngsniffer_atm.AppTrafType |=
ATT_HL_ILMI;
return;
}
@@ -517,22 +519,25 @@ atm_guess_content(union wtap_pseudo_header *pseudo_header, const u_char *pd,
* OK, we can't tell what it is based on the VPI/VCI; try
* guessing based on the contents.
*/
- if (pd[0] == 0xaa && pd[1] == 0xaa && pd[2] == 0x03) {
+ byte0 = tvb_get_guint8(tvb, 0);
+ byte1 = tvb_get_guint8(tvb, 1);
+ byte2 = tvb_get_guint8(tvb, 2);
+ if (byte0 == 0xaa && byte1 == 0xaa && byte2 == 0x03) {
/*
* Looks like a SNAP header; assume it's LLC multiplexed
* RFC 1483 traffic.
*/
- pseudo_header->ngsniffer_atm.AppTrafType |= ATT_HL_LLCMX;
+ pinfo->pseudo_header->ngsniffer_atm.AppTrafType |= ATT_HL_LLCMX;
} else {
/*
* Assume it's LANE.
*/
- pseudo_header->ngsniffer_atm.AppTrafType |= ATT_HL_LANE;
- if (pd[0] == 0xff && pd[1] == 0x00) {
+ pinfo->pseudo_header->ngsniffer_atm.AppTrafType |= ATT_HL_LANE;
+ if (byte0 == 0xff && byte1 == 0x00) {
/*
* Looks like LE Control traffic.
*/
- pseudo_header->ngsniffer_atm.AppHLType =
+ pinfo->pseudo_header->ngsniffer_atm.AppHLType =
AHLT_LANE_LE_CTRL;
} else {
/*
@@ -543,28 +548,29 @@ atm_guess_content(union wtap_pseudo_header *pseudo_header, const u_char *pd,
* still be situations where the user has to
* tell us.
*/
- pseudo_header->ngsniffer_atm.AppHLType =
+ pinfo->pseudo_header->ngsniffer_atm.AppHLType =
AHLT_LANE_802_3;
}
}
}
void
-dissect_atm(union wtap_pseudo_header *pseudo_header, const u_char *pd,
- frame_data *fd, proto_tree *tree)
+dissect_atm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
- int offset = 0;
- proto_tree *atm_tree;
- proto_item *ti;
- guint aal_type;
- guint hl_type;
- tvbuff_t* next_tvb;
+ proto_tree *atm_tree;
+ proto_item *ti;
+ guint aal_type;
+ guint hl_type;
+ const guint8 *pd;
+ int offset;
+
+ pinfo->current_proto = "ATM";
- aal_type = pseudo_header->ngsniffer_atm.AppTrafType & ATT_AALTYPE;
- hl_type = pseudo_header->ngsniffer_atm.AppTrafType & ATT_HLTYPE;
+ aal_type = pinfo->pseudo_header->ngsniffer_atm.AppTrafType & ATT_AALTYPE;
+ hl_type = pinfo->pseudo_header->ngsniffer_atm.AppTrafType & ATT_HLTYPE;
if (aal_type == ATT_AAL5) {
if (hl_type == ATT_HL_UNKNOWN ||
- pseudo_header->ngsniffer_atm.AppHLType == AHLT_UNKNOWN) {
+ pinfo->pseudo_header->ngsniffer_atm.AppHLType == AHLT_UNKNOWN) {
/*
* The joys of a connection-oriented link layer; the type of
* traffic may be implied by the connection on which it's
@@ -585,106 +591,106 @@ dissect_atm(union wtap_pseudo_header *pseudo_header, const u_char *pd,
* by which the user can specify what sort of traffic is on a
* particular circuit.
*/
- atm_guess_content(pseudo_header, pd, fd);
+ atm_guess_content(tvb, pinfo);
/*
* OK, now get the AAL type and high-layer type again.
*/
- aal_type = pseudo_header->ngsniffer_atm.AppTrafType & ATT_AALTYPE;
- hl_type = pseudo_header->ngsniffer_atm.AppTrafType & ATT_HLTYPE;
+ aal_type = pinfo->pseudo_header->ngsniffer_atm.AppTrafType & ATT_AALTYPE;
+ hl_type = pinfo->pseudo_header->ngsniffer_atm.AppTrafType & ATT_HLTYPE;
}
}
- if (check_col(fd, COL_PROTOCOL))
- col_add_str(fd, COL_PROTOCOL, "ATM");
+ if (check_col(pinfo->fd, COL_PROTOCOL))
+ col_add_str(pinfo->fd, COL_PROTOCOL, "ATM");
- switch (pseudo_header->ngsniffer_atm.channel) {
+ switch (pinfo->pseudo_header->ngsniffer_atm.channel) {
case 0:
/* Traffic from DCE to DTE. */
- if (check_col(fd, COL_RES_DL_DST))
- col_add_str(fd, COL_RES_DL_DST, "DTE");
- if (check_col(fd, COL_RES_DL_SRC))
- col_add_str(fd, COL_RES_DL_SRC, "DCE");
+ if (check_col(pinfo->fd, COL_RES_DL_DST))
+ col_add_str(pinfo->fd, COL_RES_DL_DST, "DTE");
+ if (check_col(pinfo->fd, COL_RES_DL_SRC))
+ col_add_str(pinfo->fd, COL_RES_DL_SRC, "DCE");
break;
case 1:
/* Traffic from DTE to DCE. */
- if (check_col(fd, COL_RES_DL_DST))
- col_add_str(fd, COL_RES_DL_DST, "DCE");
- if (check_col(fd, COL_RES_DL_SRC))
- col_add_str(fd, COL_RES_DL_SRC, "DTE");
+ if (check_col(pinfo->fd, COL_RES_DL_DST))
+ col_add_str(pinfo->fd, COL_RES_DL_DST, "DCE");
+ if (check_col(pinfo->fd, COL_RES_DL_SRC))
+ col_add_str(pinfo->fd, COL_RES_DL_SRC, "DTE");
break;
}
- if (check_col(fd, COL_INFO)) {
+ if (check_col(pinfo->fd, COL_INFO)) {
if (aal_type == ATT_AAL5) {
- col_add_fstr(fd, COL_INFO, "AAL5 %s",
+ col_add_fstr(pinfo->fd, COL_INFO, "AAL5 %s",
val_to_str(hl_type, aal5_hltype_vals,
"Unknown traffic type (%x)"));
} else {
- col_add_str(fd, COL_INFO,
+ col_add_str(pinfo->fd, COL_INFO,
val_to_str(aal_type, aal_vals, "Unknown AAL (%x)"));
}
}
if (tree) {
- ti = proto_tree_add_protocol_format(tree, proto_atm, NullTVB, 0, 0, "ATM");
+ ti = proto_tree_add_protocol_format(tree, proto_atm, tvb, 0, 0, "ATM");
atm_tree = proto_item_add_subtree(ti, ett_atm);
- proto_tree_add_text(atm_tree, NullTVB, 0, 0, "AAL: %s",
+ proto_tree_add_text(atm_tree, tvb, 0, 0, "AAL: %s",
val_to_str(aal_type, aal_vals, "Unknown AAL (%x)"));
if (aal_type == ATT_AAL5) {
- proto_tree_add_text(atm_tree, NullTVB, 0, 0, "Traffic type: %s",
+ proto_tree_add_text(atm_tree, tvb, 0, 0, "Traffic type: %s",
val_to_str(hl_type, aal5_hltype_vals, "Unknown AAL5 traffic type (%x)"));
switch (hl_type) {
case ATT_HL_LLCMX:
- proto_tree_add_text(atm_tree, NullTVB, 0, 0, "LLC multiplexed traffic");
+ proto_tree_add_text(atm_tree, tvb, 0, 0, "LLC multiplexed traffic");
break;
case ATT_HL_VCMX:
- proto_tree_add_text(atm_tree, NullTVB, 0, 0, "VC multiplexed traffic type: %s",
- val_to_str(pseudo_header->ngsniffer_atm.AppHLType,
+ proto_tree_add_text(atm_tree, tvb, 0, 0, "VC multiplexed traffic type: %s",
+ val_to_str(pinfo->pseudo_header->ngsniffer_atm.AppHLType,
vcmx_type_vals, "Unknown VCMX traffic type (%x)"));
break;
case ATT_HL_LANE:
- proto_tree_add_text(atm_tree, NullTVB, 0, 0, "LANE traffic type: %s",
- val_to_str(pseudo_header->ngsniffer_atm.AppHLType,
+ proto_tree_add_text(atm_tree, tvb, 0, 0, "LANE traffic type: %s",
+ val_to_str(pinfo->pseudo_header->ngsniffer_atm.AppHLType,
lane_type_vals, "Unknown LANE traffic type (%x)"));
break;
case ATT_HL_IPSILON:
- proto_tree_add_text(atm_tree, NullTVB, 0, 0, "Ipsilon traffic type: %s",
- val_to_str(pseudo_header->ngsniffer_atm.AppHLType,
+ proto_tree_add_text(atm_tree, tvb, 0, 0, "Ipsilon traffic type: %s",
+ val_to_str(pinfo->pseudo_header->ngsniffer_atm.AppHLType,
ipsilon_type_vals, "Unknown Ipsilon traffic type (%x)"));
break;
}
}
- proto_tree_add_item(atm_tree, hf_atm_vpi, NullTVB, 0, 0,
- pseudo_header->ngsniffer_atm.Vpi);
- proto_tree_add_item(atm_tree, hf_atm_vci, NullTVB, 0, 0,
- pseudo_header->ngsniffer_atm.Vci);
- switch (pseudo_header->ngsniffer_atm.channel) {
+ proto_tree_add_item(atm_tree, hf_atm_vpi, tvb, 0, 0,
+ pinfo->pseudo_header->ngsniffer_atm.Vpi);
+ proto_tree_add_item(atm_tree, hf_atm_vci, tvb, 0, 0,
+ pinfo->pseudo_header->ngsniffer_atm.Vci);
+ switch (pinfo->pseudo_header->ngsniffer_atm.channel) {
case 0:
/* Traffic from DCE to DTE. */
- proto_tree_add_text(atm_tree, NullTVB, 0, 0, "Channel: DCE->DTE");
+ proto_tree_add_text(atm_tree, tvb, 0, 0, "Channel: DCE->DTE");
break;
case 1:
/* Traffic from DTE to DCE. */
- proto_tree_add_text(atm_tree, NullTVB, 0, 0, "Channel: DTE->DCE");
+ proto_tree_add_text(atm_tree, tvb, 0, 0, "Channel: DTE->DCE");
break;
default:
/* Sniffers shouldn't provide anything other than 0 or 1. */
- proto_tree_add_text(atm_tree, NullTVB, 0, 0, "Channel: %u",
- pseudo_header->ngsniffer_atm.channel);
+ proto_tree_add_text(atm_tree, tvb, 0, 0, "Channel: %u",
+ pinfo->pseudo_header->ngsniffer_atm.channel);
break;
}
- if (pseudo_header->ngsniffer_atm.cells != 0) {
+ if (pinfo->pseudo_header->ngsniffer_atm.cells != 0) {
/*
* If the cell count is 0, assume it means we don't know how
* many cells it was.
@@ -696,15 +702,15 @@ dissect_atm(union wtap_pseudo_header *pseudo_header, const u_char *pd,
* some other way of indicating whether we have the AAL5 trailer
* information.
*/
- proto_tree_add_text(atm_tree, NullTVB, 0, 0, "Cells: %u",
- pseudo_header->ngsniffer_atm.cells);
+ proto_tree_add_text(atm_tree, tvb, 0, 0, "Cells: %u",
+ pinfo->pseudo_header->ngsniffer_atm.cells);
if (aal_type == ATT_AAL5) {
- proto_tree_add_text(atm_tree, NullTVB, 0, 0, "AAL5 U2U: %u",
- pseudo_header->ngsniffer_atm.aal5t_u2u);
- proto_tree_add_text(atm_tree, NullTVB, 0, 0, "AAL5 len: %u",
- pseudo_header->ngsniffer_atm.aal5t_len);
- proto_tree_add_text(atm_tree, NullTVB, 0, 0, "AAL5 checksum: 0x%08X",
- pseudo_header->ngsniffer_atm.aal5t_chksum);
+ proto_tree_add_text(atm_tree, tvb, 0, 0, "AAL5 U2U: %u",
+ pinfo->pseudo_header->ngsniffer_atm.aal5t_u2u);
+ proto_tree_add_text(atm_tree, tvb, 0, 0, "AAL5 len: %u",
+ pinfo->pseudo_header->ngsniffer_atm.aal5t_len);
+ proto_tree_add_text(atm_tree, tvb, 0, 0, "AAL5 checksum: 0x%08X",
+ pinfo->pseudo_header->ngsniffer_atm.aal5t_chksum);
}
}
}
@@ -712,7 +718,7 @@ dissect_atm(union wtap_pseudo_header *pseudo_header, const u_char *pd,
switch (aal_type) {
case ATT_AAL_SIGNALLING:
- dissect_sscop(pd, offset, fd, tree);
+ dissect_sscop(tvb, pinfo, tree);
break;
case ATT_AAL5:
@@ -720,24 +726,24 @@ dissect_atm(union wtap_pseudo_header *pseudo_header, const u_char *pd,
case ATT_HL_LLCMX:
/* Dissect as WTAP_ENCAP_ATM_RFC1483 */
- /* The ATM iptrace capture that we have hows LLC at this point,
+ /* The ATM iptrace capture that we have shows LLC at this point,
* so that's what I'm calling */
- next_tvb = tvb_new_subset(pi.compat_top_tvb, offset, -1, -1);
- dissect_llc(next_tvb, &pi, tree);
+ dissect_llc(tvb, &pi, tree);
break;
case ATT_HL_LANE:
- dissect_lane(pseudo_header, pd, offset, fd, tree);
+ dissect_lane(tvb, pinfo, tree);
break;
case ATT_HL_ILMI:
- dissect_snmp_pdu(pd, offset, fd, tree, "ILMI", proto_ilmi, ett_ilmi);
+ tvb_compat(tvb, &pd, &offset);
+ dissect_snmp_pdu(pd, offset, pinfo->fd, tree, "ILMI", proto_ilmi, ett_ilmi);
break;
default:
if (tree) {
/* Dump it as raw data. */
- dissect_data(pd, offset, fd, tree);
+ dissect_data_tvb(tvb, pinfo, tree);
break;
}
}
@@ -746,7 +752,7 @@ dissect_atm(union wtap_pseudo_header *pseudo_header, const u_char *pd,
default:
if (tree) {
/* Dump it as raw data. (Is this a single cell?) */
- dissect_data(pd, offset, fd, tree);
+ dissect_data_tvb(tvb, pinfo, tree);
}
break;
}
diff --git a/packet-atm.h b/packet-atm.h
index 440f62bc2e..5e1e5b5484 100644
--- a/packet-atm.h
+++ b/packet-atm.h
@@ -1,6 +1,6 @@
/* packet-atm.h
*
- * $Id: packet-atm.h,v 1.3 2000/05/19 23:06:08 gram Exp $
+ * $Id: packet-atm.h,v 1.4 2000/05/29 08:57:37 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -22,5 +22,4 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-void dissect_atm(union wtap_pseudo_header *, const u_char *, frame_data *,
- proto_tree *);
+void dissect_atm(tvbuff_t *, packet_info *, proto_tree *);
diff --git a/packet-lapd.c b/packet-lapd.c
index 51aa4b0599..bc6f973cc3 100644
--- a/packet-lapd.c
+++ b/packet-lapd.c
@@ -2,7 +2,7 @@
* Routines for LAPD frame disassembly
* Gilbert Ramirez <gram@xiexie.org>
*
- * $Id: packet-lapd.c,v 1.8 2000/05/19 23:06:09 gram Exp $
+ * $Id: packet-lapd.c,v 1.9 2000/05/29 08:57:37 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -91,6 +91,7 @@ dissect_lapd(const union wtap_pseudo_header *pseudo_header, const u_char *pd,
proto_item *ti;
guint16 control;
int lapd_header_len;
+ tvbuff_t *new_tvb;
guint16 address, cr, sapi;
@@ -141,20 +142,21 @@ dissect_lapd(const union wtap_pseudo_header *pseudo_header, const u_char *pd,
ett_lapd_control, is_response, TRUE);
lapd_header_len += XDLC_CONTROL_LEN(control, TRUE);
+ new_tvb = tvb_new_subset(pi.compat_top_tvb, lapd_header_len, -1, -1);
if (XDLC_IS_INFORMATION(control)) {
/* call next protocol */
switch (sapi) {
case LAPD_SAPI_Q931:
- dissect_q931(pd, lapd_header_len, fd, tree);
+ dissect_q931(new_tvb, &pi, tree);
break;
default:
- dissect_data(pd, lapd_header_len, fd, tree);
+ dissect_data_tvb(new_tvb, &pi, tree);
break;
}
} else
- dissect_data(pd, lapd_header_len, fd, tree);
+ dissect_data_tvb(new_tvb, &pi, tree);
}
void
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));
}
diff --git a/packet-q2931.h b/packet-q2931.h
index fcf949d2d8..a9b9ac863b 100644
--- a/packet-q2931.h
+++ b/packet-q2931.h
@@ -1,6 +1,6 @@
/* packet-q2931.h
*
- * $Id: packet-q2931.h,v 1.1 2000/02/15 21:02:56 gram Exp $
+ * $Id: packet-q2931.h,v 1.2 2000/05/29 08:57:38 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -22,5 +22,4 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-
-void dissect_q2931(const u_char *, int, frame_data *, proto_tree *);
+void dissect_q2931(tvbuff_t *, packet_info *, proto_tree *);
diff --git a/packet-q931.c b/packet-q931.c
index 001f33afb2..547c7361a8 100644
--- a/packet-q931.c
+++ b/packet-q931.c
@@ -2,7 +2,7 @@
* Routines for Q.931 frame disassembly
* Guy Harris <guy@alum.mit.edu>
*
- * $Id: packet-q931.c,v 1.14 2000/05/11 08:15:39 gram Exp $
+ * $Id: packet-q931.c,v 1.15 2000/05/29 08:57:38 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -310,25 +310,25 @@ static const value_string q931_repeat_indication_vals[] = {
* Dissect a Segmented message information element.
*/
static void
-dissect_q931_segmented_message_ie(const u_char *pd, int offset, int len,
+dissect_q931_segmented_message_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
if (len != 2) {
- proto_tree_add_text(tree, NullTVB, offset, len,
+ proto_tree_add_text(tree, tvb, offset, len,
"Segmented message: length is %d, should be 2\n", len);
return;
}
- if (pd[offset] & 0x80) {
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ if (tvb_get_guint8(tvb, offset) & 0x80) {
+ proto_tree_add_text(tree, tvb, offset, 1,
"First segment: %u segments remaining",
- pd[offset] & 0x7F);
+ tvb_get_guint8(tvb, offset) & 0x7F);
} else {
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Not first segment: %u segments remaining",
- pd[offset] & 0x7F);
+ tvb_get_guint8(tvb, offset) & 0x7F);
}
- proto_tree_add_text(tree, NullTVB, offset + 1, 1,
- "Segmented message type: %u\n", pd[offset + 1]);
+ proto_tree_add_text(tree, tvb, offset + 1, 1,
+ "Segmented message type: %u\n", tvb_get_guint8(tvb, offset + 1));
}
/*
@@ -507,7 +507,7 @@ static const value_string q931_uil3_vals[] = {
};
void
-dissect_q931_bearer_capability_ie(const u_char *pd, int offset, int len,
+dissect_q931_bearer_capability_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
@@ -520,9 +520,9 @@ dissect_q931_bearer_capability_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
coding_standard = octet & 0x60;
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Coding standard: %s",
val_to_str(coding_standard, q931_bc_coding_standard_vals, NULL));
if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
@@ -530,11 +530,12 @@ dissect_q931_bearer_capability_ie(const u_char *pd, int offset, int len,
* We don't know how the bearer capability is encoded,
* so just dump it as data and be done with it.
*/
- proto_tree_add_text(tree, NullTVB, offset,
- len, "Data: %s", bytes_to_str(&pd[offset], len));
+ proto_tree_add_text(tree, tvb, offset,
+ len, "Data: %s",
+ bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
return;
}
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Information transfer capability: %s",
val_to_str(octet & 0x1F, q931_information_transfer_capability_vals,
"Unknown (0x%02X)"));
@@ -547,8 +548,8 @@ dissect_q931_bearer_capability_ie(const u_char *pd, int offset, int len,
if (!(octet & Q931_IE_VL_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,
"Out-band negotiation %spossible",
(octet & 0x40) ? "" : "not ");
offset += 1;
@@ -557,13 +558,13 @@ dissect_q931_bearer_capability_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,
"Transfer mode: %s",
val_to_str(octet & 0x60, q931_transfer_mode_vals,
"Unknown (0x%02X)"));
it_rate = octet & 0x1F;
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Information transfer rate: %s",
val_to_str(it_rate, q931_information_transfer_rate_vals,
"Unknown (0x%02X)"));
@@ -573,19 +574,19 @@ dissect_q931_bearer_capability_ie(const u_char *pd, int offset, int len,
if (it_rate == Q931_IT_RATE_MULTIRATE) {
if (len == 0)
return;
- proto_tree_add_text(tree, NullTVB, offset, 1, "Rate multiplier: %u", pd[offset]);
+ proto_tree_add_text(tree, tvb, offset, 1, "Rate multiplier: %u", tvb_get_guint8(tvb, offset));
offset += 1;
len -= 1;
}
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: %s",
val_to_str(octet & 0x1F, q931_uil1_vals,
"Unknown (0x%02X)"));
@@ -596,14 +597,14 @@ dissect_q931_bearer_capability_ie(const u_char *pd, int offset, int len,
goto l1_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,
"Layer 1 is %s",
(octet & 0x40) ? "Asynchronous" : "Synchronous");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Layer 1 in-band negotiation is %spossible",
(octet & 0x20) ? "" : "not ");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"User rate: %s",
val_to_str(octet & 0x1F, q931_l1_user_rate_vals,
"Unknown (0x%02X)"));
@@ -614,21 +615,21 @@ dissect_q931_bearer_capability_ie(const u_char *pd, int offset, int len,
goto l1_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,
"Intermediate rate: %s",
val_to_str(octet & 0x60, q931_l1_intermediate_rate_vals,
"Unknown (0x%X)"));
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"%s to send data with network independent clock",
(octet & 0x10) ? "Required" : "Not required");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"%s accept data with network independent clock",
(octet & 0x08) ? "Can" : "Cannot");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"%s to send data with flow control mechanism",
(octet & 0x04) ? "Required" : "Not required");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"%s accept data with flow control mechanism",
(octet & 0x02) ? "Can" : "Cannot");
offset += 1;
@@ -638,23 +639,23 @@ dissect_q931_bearer_capability_ie(const u_char *pd, int offset, int len,
goto l1_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,
"Rate adaption header %sincluded",
(octet & 0x40) ? "" : "not ");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Multiple frame establishment %ssupported",
(octet & 0x20) ? "" : "not ");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"%s mode of operation",
(octet & 0x10) ? "Protocol sensitive" : "Bit transparent");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
(octet & 0x08) ?
"Full protocol negotiation" : "LLI = 256 only");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Message originator is %s",
(octet & 0x04) ? "Assignor only" : "Default assignee");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Negotiation is done %s",
(octet & 0x02) ? "in-band" : "out-of-band");
offset += 1;
@@ -664,16 +665,16 @@ dissect_q931_bearer_capability_ie(const u_char *pd, int offset, int len,
goto l1_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,
"Stop bits: %s",
val_to_str(octet & 0x60, q931_l1_stop_bits_vals,
"Unknown (0x%X)"));
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Data bits: %s",
val_to_str(octet & 0x18, q931_l1_data_bits_vals,
"Unknown (0x%X)"));
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Parity: %s",
val_to_str(octet & 0x08, q931_l1_parity_vals,
"Unknown (0x%X)"));
@@ -682,20 +683,20 @@ dissect_q931_bearer_capability_ie(const u_char *pd, int offset, int len,
goto l1_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,
"%s duplex",
(octet & 0x40) ? "Full" : "Half");
modem_type = octet & 0x3F;
if (modem_type <= 0x5 ||
(modem_type >= 0x20 && modem_type <= 0x2F)) {
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Modem type: National use 0x%02X", modem_type);
} else if (modem_type >= 0x30) {
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Modem type: User specified 0x%02X", modem_type);
} else {
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Modem type: %s",
val_to_str(modem_type, q931_l1_modem_type_vals,
NULL));
@@ -708,13 +709,13 @@ l1_done:
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, q931_uil2_vals,
"Unknown (0x%02X)"));
@@ -728,13 +729,13 @@ l1_done:
goto l2_done;
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
if (uil2_protocol == Q931_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, q931_mode_vals,
"Unknown (0x%02X)"));
@@ -746,8 +747,8 @@ l1_done:
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;
@@ -757,13 +758,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, q931_uil3_vals,
"Unknown (0x%02X)"));
@@ -778,13 +779,13 @@ l2_done:
goto l3_done;
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
switch (uil3_protocol) {
case Q931_UIL3_X25_PL:
case Q931_UIL3_ISO_8208:
case Q931_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, q931_mode_vals,
"Unknown (0x%02X)"));
@@ -795,8 +796,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;
@@ -805,15 +806,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 Q931_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;
@@ -826,9 +827,9 @@ l2_done:
goto l3_done;
if (len == 0)
return;
- octet = pd[offset + 1];
+ octet = tvb_get_guint8(tvb, offset + 1);
add_l3_info |= (octet & 0x0F);
- proto_tree_add_text(tree, NullTVB, offset, 2,
+ 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)"));
@@ -966,7 +967,7 @@ static const value_string q931_cause_code_vals[] = {
};
static void
-dissect_q931_cause_ie(const u_char *pd, int offset, int len,
+dissect_q931_cause_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
@@ -974,9 +975,9 @@ dissect_q931_cause_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
coding_standard = octet & 0x60;
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Coding standard: %s",
val_to_str(coding_standard, q931_cause_coding_standard_vals, NULL));
if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
@@ -984,11 +985,12 @@ dissect_q931_cause_ie(const u_char *pd, int offset, int len,
* We don't know how the cause is encoded,
* so just dump it as data and be done with it.
*/
- proto_tree_add_text(tree, NullTVB, offset,
- len, "Data: %s", bytes_to_str(&pd[offset], len));
+ proto_tree_add_text(tree, tvb, offset,
+ len, "Data: %s",
+ bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
return;
}
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Location: %s",
val_to_str(octet & 0x0F, q931_cause_location_vals,
"Unknown (0x%X)"));
@@ -998,8 +1000,8 @@ dissect_q931_cause_ie(const u_char *pd, int offset, int len,
if (!(octet & Q931_IE_VL_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,
"Recommendation: %s",
val_to_str(octet & 0x7F, q931_cause_recommendation_vals,
"Unknown (0x%X)"));
@@ -1009,8 +1011,8 @@ dissect_q931_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,
"Cause value: %s",
val_to_str(octet & 0x7F, q931_cause_code_vals,
"Unknown (0x%X)"));
@@ -1019,9 +1021,9 @@ dissect_q931_cause_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- 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));
}
/*
@@ -1058,7 +1060,7 @@ static const value_string q931_call_state_vals[] = {
};
static void
-dissect_q931_call_state_ie(const u_char *pd, int offset, int len,
+dissect_q931_call_state_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
@@ -1066,9 +1068,9 @@ dissect_q931_call_state_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
coding_standard = octet & 0x60;
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Coding standard: %s",
val_to_str(coding_standard, q931_coding_standard_vals, NULL));
if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
@@ -1076,11 +1078,12 @@ dissect_q931_call_state_ie(const u_char *pd, int offset, int len,
* We don't know how the call state is encoded,
* so just dump it as data and be done with it.
*/
- proto_tree_add_text(tree, NullTVB, offset,
- len, "Data: %s", bytes_to_str(&pd[offset], len));
+ proto_tree_add_text(tree, tvb, offset,
+ len, "Data: %s",
+ bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
return;
}
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Call state: %s",
val_to_str(octet & 0x3F, q931_call_state_vals,
"Unknown (0x%02X)"));
@@ -1118,7 +1121,7 @@ static const value_string q931_element_type_vals[] = {
};
static void
-dissect_q931_channel_identification_ie(const u_char *pd, int offset, int len,
+dissect_q931_channel_identification_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
@@ -1128,26 +1131,26 @@ dissect_q931_channel_identification_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,
"Interface %s identified",
(octet & Q931_INTERFACE_IDENTIFIED) ? "explicitly" : "implicitly");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"%s interface",
(octet & Q931_NOT_BASIC_CHANNEL) ? "Not basic" : "Basic");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Indicated channel is %s",
(octet & 0x08) ? "required" : "preferred");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Indicated channel is %sthe D-channel",
(octet & 0x04) ? "" : "not ");
if (octet & Q931_NOT_BASIC_CHANNEL) {
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Channel selection: %s",
val_to_str(octet & 0x03, q931_not_basic_channel_selection_vals,
NULL));
} else {
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Channel selection: %s",
val_to_str(octet & 0x03, q931_basic_channel_selection_vals,
NULL));
@@ -1161,7 +1164,7 @@ dissect_q931_channel_identification_ie(const u_char *pd, int offset, int len,
do {
if (len == 0)
break;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
offset += 1;
len -= 1;
identifier_len++;
@@ -1172,9 +1175,10 @@ dissect_q931_channel_identification_ie(const u_char *pd, int offset, int len,
* last octet of the interface identifier?
*/
if (identifier_len != 0) {
- proto_tree_add_text(tree, NullTVB, identifier_offset,
+ proto_tree_add_text(tree, tvb, identifier_offset,
identifier_len, "Interface identifier: %s",
- bytes_to_str(&pd[identifier_offset],
+ bytes_to_str(
+ tvb_get_ptr(tvb, identifier_offset, identifier_len),
identifier_len));
}
}
@@ -1182,9 +1186,9 @@ dissect_q931_channel_identification_ie(const u_char *pd, int offset, int len,
if (octet & Q931_NOT_BASIC_CHANNEL) {
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
coding_standard = octet & 0x60;
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Coding standard: %s",
val_to_str(coding_standard, q931_coding_standard_vals,
NULL));
@@ -1194,14 +1198,15 @@ dissect_q931_channel_identification_ie(const u_char *pd, int offset, int len,
* encoded, so just dump it as data and be done
* with it.
*/
- proto_tree_add_text(tree, NullTVB, offset,
- len, "Data: %s", bytes_to_str(&pd[offset], len));
+ proto_tree_add_text(tree, tvb, offset,
+ len, "Data: %s",
+ bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
return;
}
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Channel is indicated by %s",
(octet & Q931_IS_SLOT_MAP) ? "slot map" : "number");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"%s type: %s",
(octet & Q931_IS_SLOT_MAP) ? "Map element" : "Channel",
val_to_str(octet & 0x0F, q931_element_type_vals,
@@ -1227,7 +1232,7 @@ static const value_string q931_progress_description_vals[] = {
};
void
-dissect_q931_progress_indicator_ie(const u_char *pd, int offset, int len,
+dissect_q931_progress_indicator_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
@@ -1235,9 +1240,9 @@ dissect_q931_progress_indicator_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
coding_standard = octet & 0x60;
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Coding standard: %s",
val_to_str(coding_standard, q931_cause_coding_standard_vals, NULL));
if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
@@ -1245,11 +1250,12 @@ dissect_q931_progress_indicator_ie(const u_char *pd, int offset, int len,
* We don't know how the progress indicator is encoded,
* so just dump it as data and be done with it.
*/
- proto_tree_add_text(tree, NullTVB, offset,
- len, "Data: %s", bytes_to_str(&pd[offset], len));
+ proto_tree_add_text(tree, tvb, offset,
+ len, "Data: %s",
+ bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
return;
}
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Location: %s",
val_to_str(octet & 0x0F, q931_cause_location_vals,
"Unknown (0x%X)"));
@@ -1258,8 +1264,8 @@ dissect_q931_progress_indicator_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,
"Progress description: %s",
val_to_str(octet & 0x7F, q931_progress_description_vals,
"Unknown (0x%02X)"));
@@ -1284,7 +1290,7 @@ static const value_string q931_netid_plan_vals[] = {
};
static void
-dissect_q931_ns_facilities_ie(const u_char *pd, int offset, int len,
+dissect_q931_ns_facilities_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
@@ -1292,9 +1298,9 @@ dissect_q931_ns_facilities_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
netid_len = octet & 0x7F;
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Network identification length: %u",
netid_len);
offset += 1;
@@ -1302,12 +1308,12 @@ dissect_q931_ns_facilities_ie(const u_char *pd, int offset, int len,
if (netid_len != 0) {
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, q931_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, q931_netid_plan_vals,
"Unknown (0x%02X)"));
@@ -1320,9 +1326,10 @@ dissect_q931_ns_facilities_ie(const u_char *pd, int offset, int len,
if (netid_len > len)
netid_len = len;
if (netid_len != 0) {
- proto_tree_add_text(tree, NullTVB, offset, netid_len,
+ proto_tree_add_text(tree, tvb, offset, netid_len,
"Network identification: %.*s",
- netid_len, &pd[offset]);
+ netid_len,
+ tvb_get_ptr(tvb, offset, netid_len));
offset += netid_len;
len -= netid_len;
}
@@ -1334,9 +1341,9 @@ dissect_q931_ns_facilities_ie(const u_char *pd, int offset, int len,
*/
if (len == 0)
return;
- proto_tree_add_text(tree, NullTVB, offset,
+ proto_tree_add_text(tree, tvb, offset,
len, "Network-specific facility specification: %s",
- bytes_to_str(&pd[offset], len));
+ bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
}
/*
@@ -1350,15 +1357,15 @@ static const value_string q931_notification_description_vals[] = {
};
static void
-dissect_q931_notification_indicator_ie(const u_char *pd, int offset, int len,
+dissect_q931_notification_indicator_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,
"Notification description: %s",
val_to_str(octet & 0x7F, q931_notification_description_vals,
"Unknown (0x%02X)"));
@@ -1368,11 +1375,11 @@ dissect_q931_notification_indicator_ie(const u_char *pd, int offset, int len,
* Dissect a Date/time information element.
*/
static void
-dissect_q931_date_time_ie(const u_char *pd, int offset, int len,
+dissect_q931_date_time_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
if (len != 6) {
- proto_tree_add_text(tree, NullTVB, offset, len,
+ proto_tree_add_text(tree, tvb, offset, len,
"Date/time: length is %d, should be 6\n", len);
return;
}
@@ -1380,10 +1387,10 @@ dissect_q931_date_time_ie(const u_char *pd, int offset, int len,
* XXX - what is "year" relative to? Is "month" 0-origin or
* 1-origin? Q.931 doesn't say....
*/
- proto_tree_add_text(tree, NullTVB, offset, 6,
+ proto_tree_add_text(tree, tvb, offset, 6,
"Date/time: %02u-%02u-%02u %02u:%02u:%02u",
- pd[offset + 0], pd[offset + 1], pd[offset + 2],
- pd[offset + 3], pd[offset + 4], pd[offset + 5]);
+ tvb_get_guint8(tvb, offset + 0), tvb_get_guint8(tvb, offset + 1), tvb_get_guint8(tvb, offset + 2),
+ tvb_get_guint8(tvb, offset + 3), tvb_get_guint8(tvb, offset + 4), tvb_get_guint8(tvb, offset + 5));
}
/*
@@ -1414,17 +1421,17 @@ static const value_string q931_signal_vals[] = {
};
static void
-dissect_q931_signal_ie(const u_char *pd, int offset, int len,
+dissect_q931_signal_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
if (len != 1) {
- proto_tree_add_text(tree, NullTVB, offset, len,
+ proto_tree_add_text(tree, tvb, offset, len,
"Signal: length is %d, should be 1\n", len);
return;
}
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Signal: %s",
- val_to_str(pd[offset], q931_signal_vals, "Unknown (0x%02X)"));
+ val_to_str(tvb_get_guint8(tvb, offset), q931_signal_vals, "Unknown (0x%02X)"));
}
/*
@@ -1446,34 +1453,34 @@ static const value_string q931_throughput_class_vals[] = {
};
static void
-dissect_q931_information_rate_ie(const u_char *pd, int offset, int len,
+dissect_q931_information_rate_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
if (len != 4) {
- proto_tree_add_text(tree, NullTVB, offset, len,
+ proto_tree_add_text(tree, tvb, offset, len,
"Information rate: length is %d, should be 4\n", len);
return;
}
- proto_tree_add_text(tree, NullTVB, offset + 0, 1,
+ proto_tree_add_text(tree, tvb, offset + 0, 1,
"Incoming information rate: %s",
- val_to_str(pd[offset + 0] & 0x1F, q931_throughput_class_vals,
+ val_to_str(tvb_get_guint8(tvb, offset + 0) & 0x1F, q931_throughput_class_vals,
"Unknown (0x%02X)"));
- proto_tree_add_text(tree, NullTVB, offset + 1, 1,
+ proto_tree_add_text(tree, tvb, offset + 1, 1,
"Outgoing information rate: %s",
- val_to_str(pd[offset + 1] & 0x1F, q931_throughput_class_vals,
+ val_to_str(tvb_get_guint8(tvb, offset + 1) & 0x1F, q931_throughput_class_vals,
"Unknown (0x%02X)"));
- proto_tree_add_text(tree, NullTVB, offset + 2, 1,
+ proto_tree_add_text(tree, tvb, offset + 2, 1,
"Minimum incoming information rate: %s",
- val_to_str(pd[offset + 2] & 0x1F, q931_throughput_class_vals,
+ val_to_str(tvb_get_guint8(tvb, offset + 2) & 0x1F, q931_throughput_class_vals,
"Unknown (0x%02X)"));
- proto_tree_add_text(tree, NullTVB, offset + 3, 1,
+ proto_tree_add_text(tree, tvb, offset + 3, 1,
"Minimum outgoing information rate: %s",
- val_to_str(pd[offset + 3] & 0x1F, q931_throughput_class_vals,
+ val_to_str(tvb_get_guint8(tvb, offset + 3) & 0x1F, q931_throughput_class_vals,
"Unknown (0x%02X)"));
}
static int
-dissect_q931_guint16_value(const u_char *pd, int offset, int len,
+dissect_q931_guint16_value(tvbuff_t *tvb, int offset, int len,
proto_tree *tree, char *label)
{
guint8 octet;
@@ -1482,7 +1489,7 @@ dissect_q931_guint16_value(const u_char *pd, int offset, int len,
value_len = 0;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
if (octet & Q931_IE_VL_EXTENSION) {
/*
* Only one octet long - error.
@@ -1500,7 +1507,7 @@ dissect_q931_guint16_value(const u_char *pd, int offset, int len,
*/
goto past_end;
}
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
if (octet & Q931_IE_VL_EXTENSION) {
/*
* Only two octets long - error.
@@ -1518,7 +1525,7 @@ dissect_q931_guint16_value(const u_char *pd, int offset, int len,
*/
goto past_end;
}
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
if (!(octet & Q931_IE_VL_EXTENSION)) {
/*
* More than three octets long - error.
@@ -1530,17 +1537,17 @@ dissect_q931_guint16_value(const u_char *pd, int offset, int len,
len -= 1;
value_len++;
- proto_tree_add_text(tree, NullTVB, offset, value_len, "%s: %u ms", label,
+ proto_tree_add_text(tree, tvb, offset, value_len, "%s: %u ms", label,
value);
return value_len;
past_end:
- proto_tree_add_text(tree, NullTVB, offset, len,
+ proto_tree_add_text(tree, tvb, offset, len,
"%s goes past end of information element", label);
return -1;
bad_length:
- proto_tree_add_text(tree, NullTVB, offset, len, "%s isn't 3 octets long",
+ proto_tree_add_text(tree, tvb, offset, len, "%s isn't 3 octets long",
label);
return -1;
}
@@ -1549,14 +1556,14 @@ bad_length:
* Dissect an End-to-end transit delay information element.
*/
static void
-dissect_q931_e2e_transit_delay_ie(const u_char *pd, int offset, int len,
+dissect_q931_e2e_transit_delay_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
int value_len;
if (len == 0)
return;
- value_len = dissect_q931_guint16_value(pd, offset, len, tree,
+ value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
"Cumulative transit delay");
if (value_len < 0)
return; /* error */
@@ -1565,7 +1572,7 @@ dissect_q931_e2e_transit_delay_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- value_len = dissect_q931_guint16_value(pd, offset, len, tree,
+ value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
"Requested end-to-end transit delay");
if (value_len < 0)
return; /* error */
@@ -1574,7 +1581,7 @@ dissect_q931_e2e_transit_delay_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- value_len = dissect_q931_guint16_value(pd, offset, len, tree,
+ value_len = dissect_q931_guint16_value(tvb, offset, len, tree,
"Maximum end-to-end transit delay");
}
@@ -1582,12 +1589,12 @@ dissect_q931_e2e_transit_delay_ie(const u_char *pd, int offset, int len,
* Dissect a Transit delay selection and indication information element.
*/
static void
-dissect_q931_td_selection_and_int_ie(const u_char *pd, int offset, int len,
+dissect_q931_td_selection_and_int_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
if (len == 0)
return;
- dissect_q931_guint16_value(pd, offset, len, tree,
+ dissect_q931_guint16_value(tvb, offset, len, tree,
"Transit delay");
}
@@ -1603,26 +1610,26 @@ static const value_string q931_fast_selected_vals[] = {
};
static void
-dissect_q931_pl_binary_parameters_ie(const u_char *pd, int offset, int len,
+dissect_q931_pl_binary_parameters_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,
"Fast select: %s",
val_to_str(octet & 0x18, q931_fast_selected_vals,
NULL));
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"%s",
(octet & 0x04) ? "No request/request denied" :
"Request indicated/request accepted");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"%s confirmation",
(octet & 0x02) ? "Link-by-link" : "End-to-end");
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Modulus %u sequencing",
(octet & 0x01) ? 8 : 128);
}
@@ -1631,40 +1638,40 @@ dissect_q931_pl_binary_parameters_ie(const u_char *pd, int offset, int len,
* Dissect a Packet layer window size information element.
*/
static void
-dissect_q931_pl_window_size_ie(const u_char *pd, int offset, int len,
+dissect_q931_pl_window_size_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
if (len == 0)
return;
- proto_tree_add_text(tree, NullTVB, offset, 1,
- "Forward value: %u", pd[offset] & 0x7F);
+ proto_tree_add_text(tree, tvb, offset, 1,
+ "Forward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
offset += 1;
len -= 1;
if (len == 0)
return;
- proto_tree_add_text(tree, NullTVB, offset, 1,
- "Backward value: %u", pd[offset] & 0x7F);
+ proto_tree_add_text(tree, tvb, offset, 1,
+ "Backward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
}
/*
* Dissect a Packet size information element.
*/
static void
-dissect_q931_packet_size_ie(const u_char *pd, int offset, int len,
+dissect_q931_packet_size_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
if (len == 0)
return;
- proto_tree_add_text(tree, NullTVB, offset, 1,
- "Forward value: %u", pd[offset] & 0x7F);
+ proto_tree_add_text(tree, tvb, offset, 1,
+ "Forward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
offset += 1;
len -= 1;
if (len == 0)
return;
- proto_tree_add_text(tree, NullTVB, offset, 1,
- "Backward value: %u", pd[offset] & 0x7F);
+ proto_tree_add_text(tree, tvb, offset, 1,
+ "Backward value: %u", tvb_get_guint8(tvb, offset) & 0x7F);
}
/*
@@ -1677,21 +1684,21 @@ static const value_string q931_cug_indication_vals[] = {
};
static void
-dissect_q931_cug_ie(const u_char *pd, int offset, int len, proto_tree *tree)
+dissect_q931_cug_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree)
{
if (len == 0)
return;
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"CUG indication: %s",
- val_to_str(pd[offset] & 0x07, q931_cug_indication_vals,
+ val_to_str(tvb_get_guint8(tvb, offset) & 0x07, q931_cug_indication_vals,
"Unknown (0x%02X)"));
offset += 1;
len -= 1;
if (len == 0)
return;
- proto_tree_add_text(tree, NullTVB, offset, len, "CUG index code: %.*s", len,
- &pd[offset]);
+ proto_tree_add_text(tree, tvb, offset, len, "CUG index code: %.*s", len,
+ tvb_get_ptr(tvb, offset, len));
}
/*
@@ -1703,14 +1710,14 @@ static const value_string q931_reverse_charging_indication_vals[] = {
};
static void
-dissect_q931_reverse_charge_ind_ie(const u_char *pd, int offset, int len,
+dissect_q931_reverse_charge_ind_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
if (len == 0)
return;
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Reverse charging indication: %s",
- val_to_str(pd[offset] & 0x07, q931_reverse_charging_indication_vals,
+ val_to_str(tvb_get_guint8(tvb, offset) & 0x07, q931_reverse_charging_indication_vals,
"Unknown (0x%02X)"));
}
@@ -1764,19 +1771,19 @@ static const value_string q931_redirection_reason_vals[] = {
};
static void
-dissect_q931_number_ie(const u_char *pd, int offset, int len,
+dissect_q931_number_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 number: %s",
val_to_str(octet & 0x70, q931_number_type_vals,
"Unknown (0x%02X)"));
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Numbering plan: %s",
val_to_str(octet & 0x0F, q931_numbering_plan_vals,
"Unknown (0x%02X)"));
@@ -1786,12 +1793,12 @@ dissect_q931_number_ie(const u_char *pd, int offset, int len,
if (!(octet & Q931_IE_VL_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, q931_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, q931_screening_indicator_vals,
"Unknown (0x%X)"));
@@ -1805,8 +1812,8 @@ dissect_q931_number_ie(const u_char *pd, int offset, int len,
if (!(octet & Q931_IE_VL_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,
"Reason for redirection: %s",
val_to_str(octet & 0x0F, q931_redirection_reason_vals,
"Unknown (0x%X)"));
@@ -1816,8 +1823,8 @@ dissect_q931_number_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- 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));
}
/*
@@ -1836,19 +1843,19 @@ static const value_string q931_odd_even_indicator_vals[] = {
};
static void
-dissect_q931_party_subaddr_ie(const u_char *pd, int offset, int len,
+dissect_q931_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, q931_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, q931_odd_even_indicator_vals,
NULL));
@@ -1857,8 +1864,8 @@ dissect_q931_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));
}
/*
@@ -1872,17 +1879,17 @@ static const value_string q931_restart_indicator_class_vals[] = {
};
static void
-dissect_q931_restart_indicator_ie(const u_char *pd, int offset, int len,
+dissect_q931_restart_indicator_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
if (len != 1) {
- proto_tree_add_text(tree, NullTVB, offset, len,
+ proto_tree_add_text(tree, tvb, offset, len,
"Restart indicator: length is %d, should be 1\n", len);
return;
}
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Restart indicator: %s",
- val_to_str(pd[offset] & 0x07, q931_restart_indicator_class_vals,
+ val_to_str(tvb_get_guint8(tvb, offset) & 0x07, q931_restart_indicator_class_vals,
"Unknown (0x%02X)"));
}
@@ -1919,7 +1926,7 @@ static const value_string q931_audiovisual_characteristics_vals[] = {
};
void
-dissect_q931_high_layer_compat_ie(const u_char *pd, int offset, int len,
+dissect_q931_high_layer_compat_ie(tvbuff_t *tvb, int offset, int len,
proto_tree *tree)
{
guint8 octet;
@@ -1928,9 +1935,9 @@ dissect_q931_high_layer_compat_ie(const u_char *pd, int offset, int len,
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
coding_standard = octet & 0x60;
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Coding standard: %s",
val_to_str(coding_standard, q931_coding_standard_vals, NULL));
if (coding_standard != Q931_ITU_STANDARDIZED_CODING) {
@@ -1938,16 +1945,17 @@ dissect_q931_high_layer_compat_ie(const u_char *pd, int offset, int len,
* We don't know how the call state is encoded,
* so just dump it as data and be done with it.
*/
- proto_tree_add_text(tree, NullTVB, offset,
- len, "Data: %s", bytes_to_str(&pd[offset], len));
+ proto_tree_add_text(tree, tvb, offset,
+ len, "Data: %s",
+ bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
return;
}
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
characteristics = octet & 0x7F;
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"High layer characteristics identification: %s",
val_to_str(characteristics, q931_high_layer_characteristics_vals,
NULL));
@@ -1957,14 +1965,14 @@ dissect_q931_high_layer_compat_ie(const u_char *pd, int offset, int len,
if (!(octet & Q931_IE_VL_EXTENSION)) {
if (len == 0)
return;
- octet = pd[offset];
+ octet = tvb_get_guint8(tvb, offset);
if (characteristics == Q931_AUDIOVISUAL) {
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Extended audiovisual characteristics identification: %s",
val_to_str(octet & 0x7F, q931_audiovisual_characteristics_vals,
NULL));
} else {
- proto_tree_add_text(tree, NullTVB, offset, 1,
+ proto_tree_add_text(tree, tvb, offset, 1,
"Extended high layer characteristics identification: %s",
val_to_str(octet & 0x7F, q931_high_layer_characteristics_vals,
NULL));
@@ -1990,15 +1998,15 @@ static const value_string q931_protocol_discriminator_vals[] = {
};
static void
-dissect_q931_user_user_ie(const u_char *pd, int offset, int len,
+dissect_q931_user_user_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,
"Protocol discriminator: %s",
val_to_str(octet, q931_protocol_discriminator_vals,
"Unknown (0x%02x)"));
@@ -2010,13 +2018,13 @@ dissect_q931_user_user_ie(const u_char *pd, int offset, int len,
switch (octet) {
case Q931_PROTOCOL_DISCRIMINATOR_IA5:
- proto_tree_add_text(tree, NullTVB, offset, len, "User information: %.*s",
- len, &pd[offset]);
+ proto_tree_add_text(tree, tvb, offset, len, "User information: %.*s",
+ len, tvb_get_ptr(tvb, offset, len));
break;
default:
- proto_tree_add_text(tree, NullTVB, offset, len, "User information: %s",
- bytes_to_str(&pd[offset], len));
+ proto_tree_add_text(tree, tvb, offset, len, "User information: %s",
+ bytes_to_str(tvb_get_ptr(tvb, offset, len), len));
break;
}
}
@@ -2025,12 +2033,12 @@ dissect_q931_user_user_ie(const u_char *pd, int offset, int len,
* Dissect information elements consisting of ASCII^H^H^H^H^HIA5 text.
*/
static void
-dissect_q931_ia5_ie(const u_char *pd, int offset, int len, proto_tree *tree,
+dissect_q931_ia5_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree,
char *label)
{
if (len != 0) {
- proto_tree_add_text(tree, NullTVB, offset, len, "%s: %.*s", label, len,
- &pd[offset]);
+ proto_tree_add_text(tree, tvb, offset, len, "%s: %.*s", label, len,
+ tvb_get_ptr(tvb, offset, len));
}
}
@@ -2044,8 +2052,10 @@ static const value_string q931_codeset_vals[] = {
};
void
-dissect_q931(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+dissect_q931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
+ int offset = 0;
+ guint reported_length;
proto_tree *q931_tree = NULL;
proto_item *ti;
proto_tree *ie_tree;
@@ -2057,36 +2067,38 @@ dissect_q931(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.931");
+ pinfo->current_proto = "Q.931";
+
+ if (check_col(pinfo->fd, COL_PROTOCOL))
+ col_add_str(pinfo->fd, COL_PROTOCOL, "Q.931");
if (tree) {
- ti = proto_tree_add_item(tree, proto_q931, NullTVB, offset,
+ ti = proto_tree_add_item(tree, proto_q931, tvb, offset,
END_OF_FRAME, NULL);
q931_tree = proto_item_add_subtree(ti, ett_q931);
- proto_tree_add_item(q931_tree, hf_q931_discriminator, NullTVB, offset, 1, pd[offset]);
+ proto_tree_add_item(q931_tree, hf_q931_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 (q931_tree != NULL)
- proto_tree_add_item(q931_tree, hf_q931_call_ref_len, NullTVB, offset, 1, call_ref_len);
+ proto_tree_add_item(q931_tree, hf_q931_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 (q931_tree != NULL)
- proto_tree_add_item(q931_tree, hf_q931_call_ref, NullTVB, offset, call_ref_len, call_ref);
+ proto_tree_add_item(q931_tree, hf_q931_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, q931_message_type_vals,
"Unknown message type (0x%02X)"));
}
if (q931_tree != NULL)
- proto_tree_add_item(q931_tree, hf_q931_message_type, NullTVB, offset, 1, message_type);
+ proto_tree_add_item(q931_tree, hf_q931_message_type, tvb, offset, 1, message_type);
offset += 1;
/*
@@ -2094,8 +2106,9 @@ dissect_q931(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];
+ reported_length = tvb_reported_length(tvb);
+ while (offset < reported_length) {
+ info_element = tvb_get_guint8(tvb, offset);
/*
* Check for the single-octet IEs.
@@ -2107,7 +2120,7 @@ dissect_q931(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
!(info_element & Q931_IE_SHIFT_LOCKING);
codeset = info_element & Q931_IE_SHIFT_CODESET;
if (q931_tree != NULL) {
- proto_tree_add_text(q931_tree, NullTVB, offset, 1,
+ proto_tree_add_text(q931_tree, tvb, offset, 1,
"%s shift to codeset %u: %s",
(non_locking_shift ? "Non-locking" : "Locking"),
codeset,
@@ -2122,21 +2135,21 @@ dissect_q931(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case Q931_IE_MORE_DATA:
if (q931_tree != NULL) {
- proto_tree_add_text(q931_tree, NullTVB, offset, 1,
+ proto_tree_add_text(q931_tree, tvb, offset, 1,
"More data");
}
break;
case Q931_IE_SENDING_COMPLETE:
if (q931_tree != NULL) {
- proto_tree_add_text(q931_tree, NullTVB, offset, 1,
+ proto_tree_add_text(q931_tree, tvb, offset, 1,
"Sending complete");
}
break;
default:
if (q931_tree != NULL) {
- proto_tree_add_text(q931_tree, NullTVB, offset, 1,
+ proto_tree_add_text(q931_tree, tvb, offset, 1,
"Unknown information element (0x%02X",
info_element);
}
@@ -2149,7 +2162,7 @@ dissect_q931(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case Q931_IE_CONGESTION_LEVEL:
if (q931_tree != NULL) {
- proto_tree_add_text(q931_tree, NullTVB, offset, 1,
+ proto_tree_add_text(q931_tree, tvb, offset, 1,
"Congestion level: %s",
val_to_str(info_element & Q931_IE_SO_IE_MASK,
q931_congestion_level_vals,
@@ -2162,7 +2175,7 @@ dissect_q931(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case Q931_IE_REPEAT_INDICATOR:
if (q931_tree != NULL) {
- proto_tree_add_text(q931_tree, NullTVB, offset, 1,
+ proto_tree_add_text(q931_tree, tvb, offset, 1,
"Repeat indicator: %s",
val_to_str(info_element & Q931_IE_SO_IE_MASK,
q931_repeat_indication_vals,
@@ -2180,162 +2193,159 @@ dissect_q931(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
/*
* Variable-length IE.
*/
- if (!BYTES_ARE_IN_FRAME(offset + 1, 1))
- break; /* ran past end of frame */
- info_element_len = pd[offset + 1];
- if (!BYTES_ARE_IN_FRAME(offset + 2, info_element_len))
- break; /* ran past end of frame */
+ info_element_len = tvb_get_guint8(tvb, offset + 1);
if (q931_tree != NULL) {
- ti = proto_tree_add_text(q931_tree, NullTVB, offset,
+ ti = proto_tree_add_text(q931_tree, tvb, offset,
1+1+info_element_len, "%s",
val_to_str(info_element, q931_info_element_vals,
"Unknown information element (0x%02X)"));
ie_tree = proto_item_add_subtree(ti, ett_q931_ie);
- proto_tree_add_text(ie_tree, NullTVB, offset, 1,
+ proto_tree_add_text(ie_tree, tvb, offset, 1,
"Information element: %s",
val_to_str(info_element, q931_info_element_vals,
"Unknown (0x%02X)"));
- proto_tree_add_text(ie_tree, NullTVB, offset + 1, 1,
+ proto_tree_add_text(ie_tree, tvb, offset + 1, 1,
"Length: %u", info_element_len);
switch (info_element) {
case Q931_IE_SEGMENTED_MESSAGE:
- dissect_q931_segmented_message_ie(pd,
+ dissect_q931_segmented_message_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_BEARER_CAPABILITY:
case Q931_IE_LOW_LAYER_COMPAT:
- dissect_q931_bearer_capability_ie(pd,
+ dissect_q931_bearer_capability_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_CAUSE:
- dissect_q931_cause_ie(pd,
+ dissect_q931_cause_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_CALL_STATE:
- dissect_q931_call_state_ie(pd,
+ dissect_q931_call_state_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_CHANNEL_IDENTIFICATION:
- dissect_q931_channel_identification_ie(pd,
+ dissect_q931_channel_identification_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_PROGRESS_INDICATOR:
- dissect_q931_progress_indicator_ie(pd,
+ dissect_q931_progress_indicator_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_NETWORK_SPECIFIC_FACIL:
case Q931_IE_TRANSIT_NETWORK_SEL:
- dissect_q931_ns_facilities_ie(pd,
+ dissect_q931_ns_facilities_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_NOTIFICATION_INDICATOR:
- dissect_q931_notification_indicator_ie(pd,
+ dissect_q931_notification_indicator_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_DISPLAY:
- dissect_q931_ia5_ie(pd, offset + 2,
+ dissect_q931_ia5_ie(tvb, offset + 2,
info_element_len, ie_tree,
"Display information");
break;
case Q931_IE_DATE_TIME:
- dissect_q931_date_time_ie(pd,
+ dissect_q931_date_time_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_KEYPAD_FACILITY:
- dissect_q931_ia5_ie(pd, offset + 2,
+ dissect_q931_ia5_ie(tvb, offset + 2,
info_element_len, ie_tree,
"Keypad facility");
break;
case Q931_IE_SIGNAL:
- dissect_q931_signal_ie(pd,
+ dissect_q931_signal_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_INFORMATION_RATE:
- dissect_q931_information_rate_ie(pd,
+ dissect_q931_information_rate_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_E2E_TRANSIT_DELAY:
- dissect_q931_e2e_transit_delay_ie(pd,
+ dissect_q931_e2e_transit_delay_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_TD_SELECTION_AND_INT:
- dissect_q931_td_selection_and_int_ie(pd,
+ dissect_q931_td_selection_and_int_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_PL_BINARY_PARAMETERS:
- dissect_q931_pl_binary_parameters_ie(pd,
+ dissect_q931_pl_binary_parameters_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_PL_WINDOW_SIZE:
- dissect_q931_pl_window_size_ie(pd,
+ dissect_q931_pl_window_size_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_PACKET_SIZE:
- dissect_q931_packet_size_ie(pd,
+ dissect_q931_packet_size_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_CUG:
- dissect_q931_cug_ie(pd,
+ dissect_q931_cug_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_REVERSE_CHARGE_IND:
- dissect_q931_reverse_charge_ind_ie(pd,
+ dissect_q931_reverse_charge_ind_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_CALLING_PARTY_NUMBER:
case Q931_IE_CALLED_PARTY_NUMBER:
case Q931_IE_REDIRECTING_NUMBER:
- dissect_q931_number_ie(pd,
+ dissect_q931_number_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_CALLING_PARTY_SUBADDR:
case Q931_IE_CALLED_PARTY_SUBADDR:
- dissect_q931_party_subaddr_ie(pd,
+ dissect_q931_party_subaddr_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_RESTART_INDICATOR:
- dissect_q931_restart_indicator_ie(pd,
+ dissect_q931_restart_indicator_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_HIGH_LAYER_COMPAT:
- dissect_q931_high_layer_compat_ie(pd,
+ dissect_q931_high_layer_compat_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
case Q931_IE_USER_USER:
- dissect_q931_user_user_ie(pd,
+ dissect_q931_user_user_ie(tvb,
offset + 2, info_element_len, ie_tree);
break;
default:
- proto_tree_add_text(ie_tree, NullTVB, offset + 2,
+ proto_tree_add_text(ie_tree, tvb, offset + 2,
info_element_len, "Data: %s",
- bytes_to_str(&pd[offset + 2],
+ bytes_to_str(
+ tvb_get_ptr(tvb, offset + 2, info_element_len),
info_element_len));
break;
}
@@ -2349,30 +2359,30 @@ dissect_q931(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
void
proto_register_q931(void)
{
- static hf_register_info hf[] = {
- { &hf_q931_discriminator,
- { "Protocol discriminator", "q931.disc", FT_UINT8, BASE_HEX, NULL, 0x0,
- "" }},
-
- { &hf_q931_call_ref_len,
- { "Call reference value length", "q931.call_ref_len", FT_UINT8, BASE_DEC, NULL, 0x0,
- "" }},
-
- { &hf_q931_call_ref,
- { "Call reference value", "q931.call_ref", FT_BYTES, BASE_HEX, NULL, 0x0,
- "" }},
-
- { &hf_q931_message_type,
- { "Message type", "q931.message_type", FT_UINT8, BASE_HEX, VALS(q931_message_type_vals), 0x0,
- "" }},
-
- };
- static gint *ett[] = {
- &ett_q931,
- &ett_q931_ie,
- };
-
- proto_q931 = proto_register_protocol ("Q.931", "q931");
- proto_register_field_array (proto_q931, hf, array_length(hf));
- proto_register_subtree_array(ett, array_length(ett));
+ static hf_register_info hf[] = {
+ { &hf_q931_discriminator,
+ { "Protocol discriminator", "q931.disc", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
+
+ { &hf_q931_call_ref_len,
+ { "Call reference value length", "q931.call_ref_len", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
+ { &hf_q931_call_ref,
+ { "Call reference value", "q931.call_ref", FT_BYTES, BASE_HEX, NULL, 0x0,
+ "" }},
+
+ { &hf_q931_message_type,
+ { "Message type", "q931.message_type", FT_UINT8, BASE_HEX, VALS(q931_message_type_vals), 0x0,
+ "" }},
+
+ };
+ static gint *ett[] = {
+ &ett_q931,
+ &ett_q931_ie,
+ };
+
+ proto_q931 = proto_register_protocol ("Q.931", "q931");
+ proto_register_field_array (proto_q931, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
}
diff --git a/packet-q931.h b/packet-q931.h
index 3aa9b866ff..2e778ab085 100644
--- a/packet-q931.h
+++ b/packet-q931.h
@@ -2,7 +2,7 @@
* Declarations of exported routines for Q.931 and Q.2931 frame disassembly
* Guy Harris <guy@alum.mit.edu>
*
- * $Id: packet-q931.h,v 1.2 2000/02/15 21:02:56 gram Exp $
+ * $Id: packet-q931.h,v 1.3 2000/05/29 08:57:40 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -24,13 +24,13 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-void dissect_q931(const u_char *, int, frame_data *, proto_tree *);
+void dissect_q931(tvbuff_t *, packet_info *, proto_tree *);
-extern void dissect_q931_bearer_capability_ie(const u_char *, int, int,
+extern void dissect_q931_bearer_capability_ie(tvbuff_t *, int, int,
proto_tree *);
-extern void dissect_q931_high_layer_compat_ie(const u_char *, int, int,
+extern void dissect_q931_high_layer_compat_ie(tvbuff_t *, int, int,
proto_tree *);
-extern void dissect_q931_progress_indicator_ie(const u_char *, int, int,
+extern void dissect_q931_progress_indicator_ie(tvbuff_t *, int, int,
proto_tree *);
diff --git a/packet-sscop.c b/packet-sscop.c
index 58514c72e6..100a1e8d0d 100644
--- a/packet-sscop.c
+++ b/packet-sscop.c
@@ -2,7 +2,7 @@
* Routines for SSCOP (Q.2110, Q.SAAL) frame disassembly
* Guy Harris <guy@alum.mit.edu>
*
- * $Id: packet-sscop.c,v 1.7 2000/05/11 08:15:52 gram Exp $
+ * $Id: packet-sscop.c,v 1.8 2000/05/29 08:57:40 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -108,54 +108,51 @@ static const value_string sscop_type_vals[] = {
/*
* PDU type.
*/
-#define SSCOP_PDU_TYPE (pi.len - 4) /* single byte */
+#define SSCOP_PDU_TYPE (reported_length - 4) /* single byte */
/*
* 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).
*/
-#define SSCOP_N_SQ (pi.len - 5) /* One byte */
-#define SSCOP_N_MR (pi.len - 4) /* lower 3 bytes thereof */
+#define SSCOP_N_SQ (reported_length - 5) /* One byte */
+#define SSCOP_N_MR (reported_length - 4) /* lower 3 bytes thereof */
/*
* Sequenced Data PDU (no N(PS) in it), Sequenced Data with Poll PDU,
* Poll PDU.
*/
-#define SSCOP_N_PS (pi.len - 8) /* lower 3 bytes thereof */
-#define SSCOP_N_S (pi.len - 4) /* lower 3 bytes thereof */
+#define SSCOP_N_PS (reported_length - 8) /* lower 3 bytes thereof */
+#define SSCOP_N_S (reported_length - 4) /* lower 3 bytes thereof */
/*
* Solicited Status PDU, Unsolicited Status PDU (no N(PS) in it).
*/
-#define SSCOP_SS_N_PS (pi.len - 12) /* lower 3 bytes thereof */
-#define SSCOP_SS_N_MR (pi.len - 8) /* lower 3 bytes thereof */
-#define SSCOP_SS_N_R (pi.len - 4) /* lower 3 bytes thereof */
+#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 */
void
-dissect_sscop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+dissect_sscop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
+ guint reported_length;
proto_item *ti;
proto_tree *sscop_tree = NULL;
+ guint8 sscop_pdu_type;
guint8 pdu_type;
int pdu_len;
int pad_len;
+ tvbuff_t *next_tvb;
- /*
- * The SSCOP "header" is a trailer, and the PDU type is in the
- * last-minus-3 byte of the frame; if the captured length is less
- * than the actual length by 3 or more bytes, give up, as we don't
- * have the PDU type.
- */
- if ((pi.len - pi.captured_len) >= 3) {
- dissect_data(pd, offset, fd, tree);
- return;
- }
- pdu_type = pd[SSCOP_PDU_TYPE] & SSCOP_TYPE_MASK;
- if (check_col(fd, COL_PROTOCOL))
- col_add_str(fd, COL_PROTOCOL, "SSCOP");
- if (check_col(fd, COL_INFO))
- col_add_str(fd, COL_INFO, val_to_str(pdu_type, sscop_type_vals,
+ pinfo->current_proto = "SSCOP";
+
+ reported_length = tvb_reported_length(tvb); /* frame length */
+ sscop_pdu_type = tvb_get_guint8(tvb, SSCOP_PDU_TYPE);
+ pdu_type = sscop_pdu_type & SSCOP_TYPE_MASK;
+ if (check_col(pinfo->fd, COL_PROTOCOL))
+ col_add_str(pinfo->fd, COL_PROTOCOL, "SSCOP");
+ if (check_col(pinfo->fd, COL_INFO))
+ col_add_str(pinfo->fd, COL_INFO, val_to_str(pdu_type, sscop_type_vals,
"Unknown PDU type (0x%02x)"));
/*
@@ -165,7 +162,7 @@ dissect_sscop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
switch (pdu_type) {
case SSCOP_SD:
- pad_len = (pd[SSCOP_PDU_TYPE] >> 6) & 0x03;
+ pad_len = (sscop_pdu_type >> 6) & 0x03;
pdu_len = 4;
break;
@@ -177,26 +174,27 @@ dissect_sscop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
#if 0
case SSCOP_SDP:
#endif
- pad_len = (pd[SSCOP_PDU_TYPE] >> 6) & 0x03;
+ pad_len = (sscop_pdu_type >> 6) & 0x03;
pdu_len = 8;
break;
case SSCOP_UD:
- pad_len = (pd[SSCOP_PDU_TYPE] >> 6) & 0x03;
+ pad_len = (sscop_pdu_type >> 6) & 0x03;
pdu_len = 4;
break;
default:
pad_len = 0;
- pdu_len = pi.len; /* No payload, just SSCOP */
+ pdu_len = reported_length; /* No payload, just SSCOP */
break;
}
if (tree) {
- ti = proto_tree_add_protocol_format(tree, proto_sscop, NullTVB, pi.len - pdu_len,
+ ti = proto_tree_add_protocol_format(tree, proto_sscop, tvb,
+ reported_length - pdu_len,
pdu_len, "SSCOP");
sscop_tree = proto_item_add_subtree(ti, ett_sscop);
- proto_tree_add_text(sscop_tree, NullTVB, SSCOP_PDU_TYPE, 1,
+ proto_tree_add_text(sscop_tree, tvb, SSCOP_PDU_TYPE, 1,
"PDU Type: %s",
val_to_str(pdu_type, sscop_type_vals,
"Unknown (0x%02x)"));
@@ -206,63 +204,63 @@ dissect_sscop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case SSCOP_BGN:
case SSCOP_RS:
case SSCOP_ER:
- proto_tree_add_text(sscop_tree, NullTVB, SSCOP_N_SQ, 1,
- "N(SQ): %u", pd[SSCOP_N_SQ]);
- proto_tree_add_text(sscop_tree, NullTVB, SSCOP_N_MR + 1, 3,
- "N(MR): %u", pntohl(&pd[SSCOP_N_MR]) & 0xFFFFFF);
+ proto_tree_add_text(sscop_tree, tvb, SSCOP_N_SQ, 1,
+ "N(SQ): %u", tvb_get_guint8(tvb, SSCOP_N_SQ));
+ proto_tree_add_text(sscop_tree, tvb, SSCOP_N_MR + 1, 3,
+ "N(MR): %u", tvb_get_ntohl(tvb, SSCOP_N_MR) & 0xFFFFFF);
break;
case SSCOP_END:
- proto_tree_add_text(sscop_tree, NullTVB, SSCOP_PDU_TYPE, 1,
- "Source: %s", (pd[SSCOP_PDU_TYPE] & SSCOP_S) ? "SSCOP" : "User");
+ proto_tree_add_text(sscop_tree, tvb, SSCOP_PDU_TYPE, 1,
+ "Source: %s", (sscop_pdu_type & SSCOP_S) ? "SSCOP" : "User");
break;
case SSCOP_BGAK:
case SSCOP_RSAK:
- proto_tree_add_text(sscop_tree, NullTVB, SSCOP_N_MR + 1, 3,
- "N(MR): %u", pntohl(&pd[SSCOP_N_MR]) & 0xFFFFFF);
+ proto_tree_add_text(sscop_tree, tvb, SSCOP_N_MR + 1, 3,
+ "N(MR): %u", tvb_get_ntohl(tvb, SSCOP_N_MR) & 0xFFFFFF);
break;
case SSCOP_ERAK:
- proto_tree_add_text(sscop_tree, NullTVB, SSCOP_N_MR + 3, 3,
- "N(MR): %u", pntohl(&pd[SSCOP_N_MR]) & 0xFFFFFF);
+ proto_tree_add_text(sscop_tree, tvb, SSCOP_N_MR + 3, 3,
+ "N(MR): %u", tvb_get_ntohl(tvb, SSCOP_N_MR) & 0xFFFFFF);
break;
case SSCOP_SD:
- proto_tree_add_text(sscop_tree, NullTVB, SSCOP_N_S + 1, 3,
- "N(S): %u", pntohl(&pd[SSCOP_N_S]) & 0xFFFFFF);
+ proto_tree_add_text(sscop_tree, tvb, SSCOP_N_S + 1, 3,
+ "N(S): %u", tvb_get_ntohl(tvb, SSCOP_N_S) & 0xFFFFFF);
break;
#if 0
case SSCOP_SDP:
#endif
case SSCOP_POLL:
- proto_tree_add_text(sscop_tree, NullTVB, SSCOP_N_PS + 1, 3,
- "N(PS): %u", pntohl(&pd[SSCOP_N_PS]) & 0xFFFFFF);
- proto_tree_add_text(sscop_tree, NullTVB, SSCOP_N_S + 1, 3,
- "N(S): %u", pntohl(&pd[SSCOP_N_S]) & 0xFFFFFF);
+ proto_tree_add_text(sscop_tree, tvb, SSCOP_N_PS + 1, 3,
+ "N(PS): %u", tvb_get_ntohl(tvb, SSCOP_N_PS) & 0xFFFFFF);
+ proto_tree_add_text(sscop_tree, tvb, SSCOP_N_S + 1, 3,
+ "N(S): %u", tvb_get_ntohl(tvb, SSCOP_N_S) & 0xFFFFFF);
break;
case SSCOP_STAT:
/*
* XXX - dissect the list elements....
*/
- proto_tree_add_text(sscop_tree, NullTVB, SSCOP_SS_N_PS + 1, 3,
- "N(PS): %u", pntohl(&pd[SSCOP_SS_N_PS]) & 0xFFFFFF);
- proto_tree_add_text(sscop_tree, NullTVB, SSCOP_SS_N_MR + 1, 3,
- "N(MR): %u", pntohl(&pd[SSCOP_SS_N_MR]) & 0xFFFFFF);
- proto_tree_add_text(sscop_tree, NullTVB, SSCOP_SS_N_R + 1, 3,
- "N(R): %u", pntohl(&pd[SSCOP_SS_N_R]) & 0xFFFFFF);
+ proto_tree_add_text(sscop_tree, tvb, SSCOP_SS_N_PS + 1, 3,
+ "N(PS): %u", tvb_get_ntohl(tvb, SSCOP_SS_N_PS) & 0xFFFFFF);
+ proto_tree_add_text(sscop_tree, tvb, SSCOP_SS_N_MR + 1, 3,
+ "N(MR): %u", tvb_get_ntohl(tvb, SSCOP_SS_N_MR) & 0xFFFFFF);
+ proto_tree_add_text(sscop_tree, tvb, SSCOP_SS_N_R + 1, 3,
+ "N(R): %u", tvb_get_ntohl(tvb, SSCOP_SS_N_R) & 0xFFFFFF);
break;
case SSCOP_USTAT:
/*
* XXX - dissect the list elements....
*/
- proto_tree_add_text(sscop_tree, NullTVB, SSCOP_SS_N_MR + 1, 3,
- "N(MR): %u", pntohl(&pd[SSCOP_SS_N_MR]) & 0xFFFFFF);
- proto_tree_add_text(sscop_tree, NullTVB, SSCOP_SS_N_R + 1, 3,
- "N(R): %u", pntohl(&pd[SSCOP_SS_N_R]) & 0xFFFFFF);
+ proto_tree_add_text(sscop_tree, tvb, SSCOP_SS_N_MR + 1, 3,
+ "N(MR): %u", tvb_get_ntohl(tvb, SSCOP_SS_N_MR) & 0xFFFFFF);
+ proto_tree_add_text(sscop_tree, tvb, SSCOP_SS_N_R + 1, 3,
+ "N(R): %u", tvb_get_ntohl(tvb, SSCOP_SS_N_R) & 0xFFFFFF);
break;
}
}
@@ -285,27 +283,32 @@ dissect_sscop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
case SSCOP_SDP:
#endif
if (tree) {
- proto_tree_add_text(sscop_tree, NullTVB, SSCOP_PDU_TYPE, 1,
+ proto_tree_add_text(sscop_tree, tvb, SSCOP_PDU_TYPE, 1,
"Pad length: %u", pad_len);
}
/*
* Compute length of data in PDU - subtract the trailer length
- * and the pad length.
+ * and the pad length from the reported length.
*/
- pi.len -= (pdu_len + pad_len);
- if (pi.len < pi.captured_len)
- pi.captured_len = pi.len;
+ reported_length -= (pdu_len + pad_len);
/*
* XXX - if more than just Q.2931 uses SSCOP, we need to tell
* SSCOP what dissector to use here.
*/
- if (pi.len != 0) {
+ 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);
if (pdu_type == SSCOP_SD)
- dissect_q2931(pd, offset, fd, tree);
+ dissect_q2931(next_tvb, pinfo, tree);
else
- dissect_data(pd, offset, fd, tree);
+ dissect_data_tvb(next_tvb, pinfo, tree);
}
break;
}
diff --git a/packet-sscop.h b/packet-sscop.h
index 8545669584..2781ee400b 100644
--- a/packet-sscop.h
+++ b/packet-sscop.h
@@ -1,6 +1,6 @@
/* packet-sscop.h
*
- * $Id: packet-sscop.h,v 1.1 2000/02/15 21:03:13 gram Exp $
+ * $Id: packet-sscop.h,v 1.2 2000/05/29 08:57:40 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -22,5 +22,4 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-
-void dissect_sscop(const u_char *, int, frame_data *, proto_tree *);
+void dissect_sscop(tvbuff_t *, packet_info *, proto_tree *);
diff --git a/packet.c b/packet.c
index 8c760519f8..b22ee768b8 100644
--- a/packet.c
+++ b/packet.c
@@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
- * $Id: packet.c,v 1.91 2000/05/25 14:55:22 gram Exp $
+ * $Id: packet.c,v 1.92 2000/05/29 08:57:41 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -1168,7 +1168,7 @@ dissect_packet(union wtap_pseudo_header *pseudo_header, const u_char *pd,
pi.len = fd->pkt_len;
pi.captured_len = fd->cap_len;
- tvb = tvb_new_real_data(pd, fd->cap_len, -1);
+ tvb = tvb_new_real_data(pd, fd->cap_len, fd->pkt_len);
pi.fd = fd;
pi.compat_top_tvb = tvb;
pi.pseudo_header = pseudo_header;
@@ -1203,7 +1203,7 @@ dissect_packet(union wtap_pseudo_header *pseudo_header, const u_char *pd,
dissect_clip(tvb, &pi, tree);
break;
case WTAP_ENCAP_ATM_SNIFFER :
- dissect_atm(pseudo_header, pd, fd, tree);
+ dissect_atm(tvb, &pi, tree);
break;
case WTAP_ENCAP_ASCEND :
dissect_ascend(tvb, &pi, tree);
diff --git a/tvbuff.c b/tvbuff.c
index bb52c55308..95542d42c9 100644
--- a/tvbuff.c
+++ b/tvbuff.c
@@ -9,7 +9,7 @@
* the data of a backing tvbuff, or can be a composite of
* other tvbuffs.
*
- * $Id: tvbuff.c,v 1.3 2000/05/16 04:44:14 gram Exp $
+ * $Id: tvbuff.c,v 1.4 2000/05/29 08:57:42 guy Exp $
*
* Copyright (c) 2000 by Gilbert Ramirez <gram@xiexie.org>
*
@@ -122,7 +122,7 @@ struct tvbuff {
guint length;
/* Reported length. */
- gint reported_length;
+ guint reported_length;
/* Offset from beginning of first TVBUFF_REAL. */
gint raw_offset;
@@ -329,7 +329,15 @@ tvb_new_real_data(const guint8* data, guint length, gint reported_length)
* and a length that is possible -1 (which means "to the end of the data").
* Returns TRUE/FALSE indicating whether the offset is in bounds or
* not. The integer ptrs are modified with the new offset and length.
- * No exception is thrown. */
+ * No exception is thrown.
+ *
+ * XXX - we return TRUE, not FALSE, if the offset is positive and right
+ * after the end of the tvbuff (i.e., equal to the length). We do this
+ * so that a dissector constructing a subset tvbuff for the next protocol
+ * will get a zero-length tvbuff, not an exception, if there's no data
+ * left for the next protocol - we want the next protocol to be the one
+ * that gets an exception, so the error is reported as an error in that
+ * protocol rather than the containing protocol. */
static gboolean
compute_offset_length(tvbuff_t *tvb, gint offset, gint length,
guint *offset_ptr, guint *length_ptr, int *exception)
@@ -339,22 +347,40 @@ compute_offset_length(tvbuff_t *tvb, gint offset, gint length,
/* Compute the offset */
if (offset >= 0) {
- *offset_ptr = offset;
- }
- else if ((tvb->reported_length > -1) && -offset > tvb->reported_length) {
- if (exception) {
- *exception = ReportedBoundsError;
+ /* Positive offset - relative to the beginning of the packet. */
+ if (offset > tvb->reported_length) {
+ if (exception) {
+ *exception = ReportedBoundsError;
+ }
+ return FALSE;
}
- return FALSE;
- }
- else if (-offset > tvb->length) {
- if (exception) {
- *exception = BoundsError;
+ else if (offset > tvb->length) {
+ if (exception) {
+ *exception = BoundsError;
+ }
+ return FALSE;
+ }
+ else {
+ *offset_ptr = offset;
}
- return FALSE;
}
else {
- *offset_ptr = tvb->length + offset;
+ /* Negative offset - relative to the end of the packet. */
+ if (-offset > tvb->reported_length) {
+ if (exception) {
+ *exception = ReportedBoundsError;
+ }
+ return FALSE;
+ }
+ else if (-offset > tvb->length) {
+ if (exception) {
+ *exception = BoundsError;
+ }
+ return FALSE;
+ }
+ else {
+ *offset_ptr = tvb->length + offset;
+ }
}
/* Compute the length */
@@ -383,12 +409,6 @@ check_offset_length_no_exception(tvbuff_t *tvb, gint offset, gint length,
if (*offset_ptr + *length_ptr <= tvb->length) {
return TRUE;
}
- else if (tvb->reported_length == -1) {
- if (exception) {
- *exception = BoundsError;
- }
- return FALSE;
- }
else if (*offset_ptr + *length_ptr <= tvb->reported_length) {
if (exception) {
*exception = BoundsError;
@@ -441,7 +461,13 @@ tvb_set_subset(tvbuff_t *tvb, tvbuff_t *backing,
tvb_increment_usage_count(backing, 1);
tvb->tvbuffs.subset.tvb = backing;
tvb->length = tvb->tvbuffs.subset.length;
- tvb->reported_length = reported_length;
+ g_assert(reported_length >= -1);
+ if (reported_length == -1) {
+ tvb->reported_length = backing->reported_length - tvb->tvbuffs.subset.offset;
+ }
+ else {
+ tvb->reported_length = reported_length;
+ }
tvb->initialized = TRUE;
add_to_used_in_list(backing, tvb);
@@ -573,7 +599,10 @@ tvb_offset_exists(tvbuff_t *tvb, gint offset)
guint abs_offset, abs_length;
g_assert(tvb->initialized);
- if (compute_offset_length(tvb, offset, -1, &abs_offset, &abs_length, NULL)) {
+ if (!compute_offset_length(tvb, offset, -1, &abs_offset, &abs_length, NULL))
+ return FALSE;
+
+ if (abs_offset < tvb->length) {
return TRUE;
}
else {
@@ -581,6 +610,14 @@ tvb_offset_exists(tvbuff_t *tvb, gint offset)
}
}
+guint
+tvb_reported_length(tvbuff_t* tvb)
+{
+ g_assert(tvb->initialized);
+
+ return tvb->reported_length;
+}
+
diff --git a/tvbuff.h b/tvbuff.h
index 481200a122..95bb8c5684 100644
--- a/tvbuff.h
+++ b/tvbuff.h
@@ -9,7 +9,7 @@
* the data of a backing tvbuff, or can be a composite of
* other tvbuffs.
*
- * $Id: tvbuff.h,v 1.3 2000/05/16 04:44:14 gram Exp $
+ * $Id: tvbuff.h,v 1.4 2000/05/29 08:57:42 guy Exp $
*
* Copyright (c) 2000 by Gilbert Ramirez <gram@xiexie.org>
*
@@ -179,12 +179,15 @@ gboolean tvb_bytes_exist(tvbuff_t*, gint offset, gint length);
/* Checks (w/o throwing exception) that offset exists in buffer */
gboolean tvb_offset_exists(tvbuff_t*, gint offset);
+/* Get reported length of buffer */
+guint tvb_reported_length(tvbuff_t*);
+
/* Returns the offset from the first byte of real data. This is
* the same value as 'offset' in tvb_compat() */
gint tvb_raw_offset(tvbuff_t*);
/************** START OF ACCESSORS ****************/
-/* All accessors will throw BoundsError if appropriate */
+/* All accessors will throw BoundsError or ReportedBoundsError if appropriate */
guint8 tvb_get_guint8(tvbuff_t*, gint offset);