Pass tvb and offset into print_nsap_net() and print_area() to "hide" the tvb_get_ptr call that dissectors are using.

Change-Id: Ibc5a51be462d431b85b34cac7a358d736ec7b9db
Reviewed-on: https://code.wireshark.org/review/7422
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Michael Mann 2015-02-24 14:16:48 -05:00 committed by Anders Broman
parent 64c06785ea
commit 14697b8aee
7 changed files with 19 additions and 23 deletions

View File

@ -225,7 +225,6 @@ dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
cksum_status_t cksum_status;
int offset;
guchar src_len, dst_len, nsel, opt_len = 0;
const guint8 *dst_addr, *src_addr;
guint next_length;
proto_tree *discpdu_tree;
gboolean save_in_error_pkt;
@ -389,14 +388,13 @@ dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
FIXED_PART_LEN + 1 + dst_len);
return;
}
dst_addr = tvb_get_ptr(tvb, offset, dst_len);
nsel = tvb_get_guint8(tvb, offset + dst_len - 1);
TVB_SET_ADDRESS(&pinfo->net_dst, get_osi_address_type(), tvb, offset, dst_len);
TVB_SET_ADDRESS(&pinfo->dst, get_osi_address_type(), tvb, offset, dst_len);
proto_tree_add_bytes_format_value(clnp_tree, hf_clnp_dest, tvb, offset, dst_len,
NULL,
"%s",
print_nsap_net(dst_addr, dst_len));
print_nsap_net(tvb, offset, dst_len));
offset += dst_len;
opt_len -= dst_len;
@ -427,14 +425,13 @@ dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
FIXED_PART_LEN + 1 + dst_len + 1 + src_len);
return;
}
src_addr = tvb_get_ptr(tvb, offset, src_len);
TVB_SET_ADDRESS(&pinfo->net_src, get_osi_address_type(), tvb, offset, src_len);
TVB_SET_ADDRESS(&pinfo->src, get_osi_address_type(), tvb, offset, src_len);
proto_tree_add_bytes_format_value(clnp_tree, hf_clnp_src, tvb,
offset, src_len,
NULL,
"%s",
print_nsap_net(src_addr, src_len));
print_nsap_net(tvb, offset, src_len));
offset += src_len;
opt_len -= src_len;

View File

@ -152,7 +152,7 @@ esis_dissect_esh_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree) {
offset++;
proto_tree_add_text(esis_area_tree, tvb, offset, sal,
" SA: %s",
print_nsap_net( tvb_get_ptr(tvb, offset, sal), sal ) );
print_nsap_net(tvb, offset, sal ) );
offset += sal;
len -= ( sal + 1 );
}
@ -173,7 +173,7 @@ esis_dissect_ish_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree) {
proto_tree_add_text( tree, tvb, offset, netl + 1,
"### Network Entity Title Section ###");
proto_tree_add_uint_format_value(tree, hf_esis_netl, tvb, offset++, 1, netl, "%2u Octets", netl);
proto_tree_add_string( tree, hf_esis_net, tvb, offset, netl, print_nsap_net( tvb_get_ptr(tvb, offset, netl), netl ) );
proto_tree_add_string( tree, hf_esis_net, tvb, offset, netl, print_nsap_net( tvb, offset, netl ) );
offset += netl;
len -= ( netl + 1 );
@ -195,7 +195,7 @@ esis_dissect_redirect_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree) {
"### Destination Address Section ###" );
proto_tree_add_uint_format_value(tree, hf_esis_dal, tvb, offset++, 1, tmpl, "%2u Octets", tmpl);
proto_tree_add_string( tree, hf_esis_da, tvb, offset, tmpl,
print_nsap_net( tvb_get_ptr(tvb, offset, tmpl), tmpl ) );
print_nsap_net( tvb, offset, tmpl ) );
offset += tmpl;
len -= ( tmpl + 1 );
tmpl = (int) tvb_get_guint8(tvb, offset);
@ -219,7 +219,7 @@ esis_dissect_redirect_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree) {
"### Network Entity Title Section ###" );
proto_tree_add_uint_format_value(tree, hf_esis_netl, tvb, offset++, 1, tmpl, "%2u Octets", tmpl );
proto_tree_add_string( tree, hf_esis_net, tvb, offset, tmpl,
print_nsap_net( tvb_get_ptr(tvb, offset, tmpl), tmpl ) );
print_nsap_net( tvb, offset, tmpl ) );
offset += tmpl;
len -= ( tmpl + 1 );
}

View File

@ -2774,7 +2774,7 @@ dissect_lsp_prefix_neighbors_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *
* Lets turn the area address into "standard" 0000.0000.etc
* format string.
*/
sbuf = print_area( tvb_get_ptr(tvb, offset+1, mylen), mylen );
sbuf = print_area( tvb, offset+1, mylen );
/* and spit it out */
if ( tree ) {
proto_tree_add_text ( tree, tvb, offset, mylen + 1,

View File

@ -351,7 +351,7 @@ dissect_option_route(guchar parm_type, int offset, guchar parm_len,
netl = tvb_get_guint8(tvb, this_hop);
proto_tree_add_text(osi_route_tree, tvb, this_hop, netl + 1,
"Hop #%3u NETL: %2u, NET: %s", cnt_hops++, netl,
print_nsap_net(tvb_get_ptr(tvb, this_hop + 1, netl), netl));
print_nsap_net(tvb, this_hop + 1, netl));
this_hop += 1 + netl;
}
}
@ -549,8 +549,7 @@ dissect_osi_options(guchar opt_len, tvbuff_t *tvb, int offset, proto_tree *tree)
case OSI_OPT_ADDRESS_MASK:
proto_tree_add_bytes_format_value(osi_option_tree, hf_osi_options_address_mask, tvb, offset, parm_len,
tvb_get_ptr(tvb, offset, parm_len), "%s",
print_area(tvb_get_ptr(tvb, offset, parm_len),
parm_len));
print_area(tvb, offset, parm_len));
break;
case OSI_OPT_SNPA_MASK:

View File

@ -2770,7 +2770,7 @@ dissect_rsvp_ifid_tlv(proto_tree *ti, packet_info* pinfo, proto_tree *rsvp_objec
"%sISIS-Area TLV - Invalid Length field", tlv_name);
break;
}
ip_str = print_nsap_net(tvb_get_ptr(tvb, offset+tlv_off+5, isis_len), isis_len);
ip_str = print_nsap_net(tvb, offset+tlv_off+5, isis_len);
rsvp_ifid_subtree = proto_tree_add_subtree_format(rsvp_object_tree, tvb,
offset+tlv_off, tlv_len,
subtree_type, NULL, "%sISIS-Area TLV - %s", tlv_name,
@ -5844,10 +5844,10 @@ dissect_rsvp_gen_uni(proto_tree *ti, packet_info* pinfo, proto_tree *rsvp_object
proto_tree_add_text(rsvp_gen_uni_subtree, tvb, offset2+l+5,
sobj_len-4,
"NSAP address: %s",
print_nsap_net(tvb_get_ptr(tvb, offset2+l+5, nsap_len), nsap_len));
print_nsap_net(tvb, offset2+l+5, nsap_len));
if (i < 4) {
proto_item_append_text(ti, "%s NSAP TNA: %s", c,
print_nsap_net(tvb_get_ptr(tvb, offset2+l+5, nsap_len), nsap_len));
print_nsap_net(tvb, offset2+l+5, nsap_len));
}
break;
@ -6099,7 +6099,7 @@ dissect_rsvp_call_id(proto_tree *ti, proto_tree *rsvp_object_tree,
case 3:
offset4 = offset3 + 20;
str = print_nsap_net(tvb_get_ptr(tvb, offset3, 20), 20);
str = print_nsap_net(tvb, offset3, 20);
proto_tree_add_text(rsvp_object_tree, tvb, offset3, 20,
"Source Transport Network addr: %s", str);
break;

View File

@ -41,12 +41,12 @@
* "dissect_nsap()" in epan/dissectors/packet-isup.c.
*/
gchar *
print_nsap_net( const guint8 *ad, int length )
print_nsap_net( tvbuff_t *tvb, const gint offset, int length )
{
gchar *cur;
cur = (gchar *)wmem_alloc(wmem_packet_scope(), MAX_NSAP_LEN * 3 + 50);
print_nsap_net_buf( ad, length, cur, MAX_NSAP_LEN * 3 + 50);
print_nsap_net_buf( tvb_get_ptr(tvb, offset, length), length, cur, MAX_NSAP_LEN * 3 + 50);
return( cur );
}
@ -141,12 +141,12 @@ print_system_id_buf( const guint8 *ad, int length, gchar *buf, int buf_len)
}
gchar *
print_area(const guint8 *ad, int length)
print_area(tvbuff_t *tvb, const gint offset, int length)
{
gchar *cur;
cur = (gchar *)wmem_alloc(wmem_packet_scope(), MAX_AREA_LEN * 3 + 20);
print_area_buf(ad, length, cur, MAX_AREA_LEN * 3 + 20);
print_area_buf(tvb_get_ptr(tvb, offset, length), length, cur, MAX_AREA_LEN * 3 + 20);
return cur;
}

View File

@ -45,9 +45,9 @@
#define NSAP_IDI_ISODCC 0x39
#define NSAP_IDI_GOSIP2 0x47
gchar* print_nsap_net ( const guint8 *, int );
gchar* print_nsap_net ( tvbuff_t *, const gint, int );
void print_nsap_net_buf( const guint8 *, int, gchar *, int);
gchar* print_area ( const guint8 *, int );
gchar* print_area ( tvbuff_t *, const gint, int );
void print_area_buf ( const guint8 *, int, gchar *, int);
gchar* print_system_id(wmem_allocator_t *, const guint8 *, int );
gchar* tvb_print_system_id( tvbuff_t *, const gint, int );