Change some `wmem_packet_scope()` to `pinfo->pool`

As requested [here][1] by @eapache, help with removing calls to
`wmem_packet_scope()` in favour of references to `pinfo->pool`.

* Plugins chosen semi-randomly.
* When a calling function already has a `pinfo` argument, use that.
    * Remove `_U_` from its signature if it was there.
* If a function seems narrowly focused on getting and (possibly)
  returning memory, change the function signature to take a
  `wmem_allocator_t *`.
* If it seems more focused on packet-based operations, pass in a
  `packet_info *` instead and use `pinfo->pool` within.
    * If there are several functions defined with the same call
      signature, add `pinfo _U_` to the argument list of similar
      functions in order to maintain clarity/symmetry.

[1]: https://www.wireshark.org/lists/wireshark-dev/202107/msg00052.html
master
David Perry 1 month ago committed by John Thacker
parent 39aa3cb58a
commit 1f59c18769

@ -361,20 +361,20 @@ static const value_string atmop_vals[] = {
(((ar_pro) == ETHERTYPE_IP || (ar_pro) == AX25_P_IP) && (ar_pln) == 4)
const gchar *
tvb_arphrdaddr_to_str(tvbuff_t *tvb, gint offset, int ad_len, guint16 type)
tvb_arphrdaddr_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, int ad_len, guint16 type)
{
if (ad_len == 0)
return "<No address>";
if (ARP_HW_IS_ETHER(type, ad_len)) {
/* Ethernet address (or IEEE 802.x address, which is the same type of
address). */
return tvb_ether_to_str(wmem_packet_scope(), tvb, offset);
return tvb_ether_to_str(scope, tvb, offset);
}
return tvb_bytes_to_str(wmem_packet_scope(), tvb, offset, ad_len);
return tvb_bytes_to_str(scope, tvb, offset, ad_len);
}
static const gchar *
arpproaddr_to_str(const guint8 *ad, int ad_len, guint16 type)
arpproaddr_to_str(wmem_allocator_t *scope, const guint8 *ad, int ad_len, guint16 type)
{
address addr;
@ -384,27 +384,28 @@ arpproaddr_to_str(const guint8 *ad, int ad_len, guint16 type)
/* IPv4 address. */
set_address(&addr, AT_IPv4, 4, ad);
return address_to_str(wmem_packet_scope(), &addr);
return address_to_str(scope, &addr);
}
if (ARP_HW_IS_AX25(type, ad_len)) {
{
/* AX.25 address */
set_address(&addr, AT_AX25, AX25_ADDR_LEN, ad);
return address_to_str(wmem_packet_scope(), &addr);
return address_to_str(scope, &addr);
}
}
return bytes_to_str(wmem_packet_scope(), ad, ad_len);
return bytes_to_str(scope, ad, ad_len);
}
static const gchar *
tvb_arpproaddr_to_str(tvbuff_t *tvb, gint offset, int ad_len, guint16 type)
tvb_arpproaddr_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, int ad_len, guint16 type)
{
return arpproaddr_to_str(tvb_get_ptr(tvb, offset, ad_len), ad_len, type);
const guint8 *ad = tvb_memdup(scope, tvb, offset, ad_len);
return arpproaddr_to_str(scope, ad, ad_len, type);
}
static const gchar *
atmarpnum_to_str(tvbuff_t *tvb, int offset, int ad_tl)
atmarpnum_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, int offset, int ad_tl)
{
int ad_len = ad_tl & ATMARP_LEN_MASK;
@ -415,19 +416,19 @@ atmarpnum_to_str(tvbuff_t *tvb, int offset, int ad_tl)
/*
* I'm assuming this means it's an ASCII (IA5) string.
*/
return (gchar *) tvb_get_string_enc(wmem_packet_scope(), tvb, offset, ad_len, ENC_ASCII|ENC_NA);
return (gchar *) tvb_get_string_enc(scope, tvb, offset, ad_len, ENC_ASCII|ENC_NA);
} else {
/*
* NSAP.
*
* XXX - break down into subcomponents.
*/
return tvb_bytes_to_str(wmem_packet_scope(), tvb, offset, ad_len);
return tvb_bytes_to_str(scope, tvb, offset, ad_len);
}
}
static const gchar *
atmarpsubaddr_to_str(tvbuff_t *tvb, int offset, int ad_tl)
atmarpsubaddr_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, int offset, int ad_tl)
{
int ad_len = ad_tl & ATMARP_LEN_MASK;
@ -443,7 +444,7 @@ atmarpsubaddr_to_str(tvbuff_t *tvb, int offset, int ad_tl)
*
* XXX - break down into subcomponents?
*/
return tvb_bytes_to_str(wmem_packet_scope(), tvb, offset, ad_len);
return tvb_bytes_to_str(scope, tvb, offset, ad_len);
}
const value_string arp_hrd_vals[] = {
@ -746,9 +747,9 @@ check_for_duplicate_addresses(packet_info *pinfo, proto_tree *tree,
/* Create subtree */
duplicate_tree = proto_tree_add_subtree_format(tree, tvb, 0, 0, ett_arp_duplicate_address, &ti,
"Duplicate IP address detected for %s (%s) - also in use by %s (frame %u)",
arpproaddr_to_str((guint8*)&ip, 4, ETHERTYPE_IP),
address_to_str(wmem_packet_scope(), &mac_addr),
address_to_str(wmem_packet_scope(), &result_mac_addr),
arpproaddr_to_str(pinfo->pool, (guint8*)&ip, 4, ETHERTYPE_IP),
address_to_str(pinfo->pool, &mac_addr),
address_to_str(pinfo->pool, &result_mac_addr),
result->frame_num);
proto_item_set_generated(ti);
@ -759,7 +760,7 @@ check_for_duplicate_addresses(packet_info *pinfo, proto_tree *tree,
expert_add_info_format(pinfo, ti,
&ei_seq_arp_dup_ip,
"Duplicate IP address configured (%s)",
arpproaddr_to_str((guint8*)&ip, 4, ETHERTYPE_IP));
arpproaddr_to_str(pinfo->pool, (guint8*)&ip, 4, ETHERTYPE_IP));
/* Time since that frame was seen */
ti = proto_tree_add_uint(duplicate_tree,
@ -897,30 +898,30 @@ dissect_atmarp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _
/* Extract the addresses. */
sha_offset = MIN_ATMARP_HEADER_SIZE;
sha_str = atmarpnum_to_str(tvb, sha_offset, ar_shtl);
sha_str = atmarpnum_to_str(pinfo->pool, tvb, sha_offset, ar_shtl);
ssa_offset = sha_offset + ar_shl;
if (ar_ssl != 0) {
ssa_str = atmarpsubaddr_to_str(tvb, ssa_offset, ar_sstl);
ssa_str = atmarpsubaddr_to_str(pinfo->pool, tvb, ssa_offset, ar_sstl);
} else {
ssa_str = NULL;
}
spa_offset = ssa_offset + ar_ssl;
spa_str = tvb_arpproaddr_to_str(tvb, spa_offset, ar_spln, ar_pro);
spa_str = tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_spln, ar_pro);
tha_offset = spa_offset + ar_spln;
tha_str = atmarpnum_to_str(tvb, tha_offset, ar_thtl);
tha_str = atmarpnum_to_str(pinfo->pool, tvb, tha_offset, ar_thtl);
tsa_offset = tha_offset + ar_thl;
if (ar_tsl != 0) {
tsa_str = atmarpsubaddr_to_str(tvb, tsa_offset, ar_tstl);
tsa_str = atmarpsubaddr_to_str(pinfo->pool, tvb, tsa_offset, ar_tstl);
} else {
tsa_str = NULL;
}
tpa_offset = tsa_offset + ar_tsl;
tpa_str = tvb_arpproaddr_to_str(tvb, tpa_offset, ar_tpln, ar_pro);
tpa_str = tvb_arpproaddr_to_str(pinfo->pool, tvb, tpa_offset, ar_tpln, ar_pro);
switch (ar_op) {
@ -1278,8 +1279,8 @@ dissect_ax25arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
/* Target Protocol Address */
tpa_offset = tha_offset + ar_hln;
spa_str = tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro);
tpa_str = tvb_arpproaddr_to_str(tvb, tpa_offset, ar_pln, ar_pro);
spa_str = tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro);
tpa_str = tvb_arpproaddr_to_str(pinfo->pool, tvb, tpa_offset, ar_pln, ar_pro);
/* ARP requests/replies with the same sender and target protocol
address are flagged as "gratuitous ARPs", i.e. ARPs sent out as,
@ -1306,22 +1307,22 @@ dissect_ax25arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
else
col_add_fstr(pinfo->cinfo, COL_INFO, "%s is at %s",
spa_str,
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd));
break;
case ARPOP_RREQUEST:
case ARPOP_IREQUEST:
col_add_fstr(pinfo->cinfo, COL_INFO, "Who is %s? Tell %s",
tvb_arphrdaddr_to_str(tvb, tha_offset, ar_hln, ar_hrd),
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, tha_offset, ar_hln, ar_hrd),
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd));
break;
case ARPOP_RREPLY:
col_add_fstr(pinfo->cinfo, COL_INFO, "%s is at %s",
tvb_arphrdaddr_to_str(tvb, tha_offset, ar_hln, ar_hrd),
tvb_arphrdaddr_to_str(pinfo->pool, tvb, tha_offset, ar_hln, ar_hrd),
tpa_str);
break;
case ARPOP_IREPLY:
col_add_fstr(pinfo->cinfo, COL_INFO, "%s is at %s",
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd),
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd),
spa_str);
break;
default:
@ -1515,7 +1516,7 @@ dissect_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
multicast address nor an all-zero address and if sender IP address
isn't all zeroes. */
ip = tvb_get_ipv4(tvb, spa_offset);
mac = (const guint8*)tvb_memdup(wmem_packet_scope(), tvb, sha_offset, 6);
mac = (const guint8*)tvb_memdup(pinfo->pool, tvb, sha_offset, 6);
if ((mac[0] & 0x01) == 0 && memcmp(mac, mac_allzero, 6) != 0 && ip != 0)
{
if (global_arp_register_network_address_binding)
@ -1539,7 +1540,7 @@ dissect_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
ip = tvb_get_ipv4(tvb, tpa_offset);
mac = (const guint8*)tvb_memdup(wmem_packet_scope(), tvb, tha_offset, 6);
mac = (const guint8*)tvb_memdup(pinfo->pool, tvb, tha_offset, 6);
if ((mac[0] & 0x01) == 0 && memcmp(mac, mac_allzero, 6) != 0 && ip != 0
&& ar_op != ARPOP_REQUEST)
{
@ -1582,42 +1583,42 @@ dissect_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
if (is_gratuitous) {
if (is_announcement) {
col_add_fstr(pinfo->cinfo, COL_INFO, "ARP Announcement for %s",
tvb_arpproaddr_to_str(tvb, tpa_offset, ar_pln, ar_pro));
tvb_arpproaddr_to_str(pinfo->pool, tvb, tpa_offset, ar_pln, ar_pro));
} else {
col_add_fstr(pinfo->cinfo, COL_INFO, "Gratuitous ARP for %s (Request)",
tvb_arpproaddr_to_str(tvb, tpa_offset, ar_pln, ar_pro));
tvb_arpproaddr_to_str(pinfo->pool, tvb, tpa_offset, ar_pln, ar_pro));
}
}
else if (is_probe) {
col_add_fstr(pinfo->cinfo, COL_INFO, "Who has %s? (ARP Probe)",
tvb_arpproaddr_to_str(tvb, tpa_offset, ar_pln, ar_pro));
tvb_arpproaddr_to_str(pinfo->pool, tvb, tpa_offset, ar_pln, ar_pro));
} else {
col_add_fstr(pinfo->cinfo, COL_INFO, "Who has %s? Tell %s",
tvb_arpproaddr_to_str(tvb, tpa_offset, ar_pln, ar_pro),
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro));
tvb_arpproaddr_to_str(pinfo->pool, tvb, tpa_offset, ar_pln, ar_pro),
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro));
}
break;
case ARPOP_REPLY:
if (is_gratuitous)
col_add_fstr(pinfo->cinfo, COL_INFO, "Gratuitous ARP for %s (Reply)",
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro));
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro));
else
col_add_fstr(pinfo->cinfo, COL_INFO, "%s is at %s",
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro),
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd));
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro),
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd));
break;
case ARPOP_RREQUEST:
case ARPOP_IREQUEST:
case ARPOP_DRARPREQUEST:
col_add_fstr(pinfo->cinfo, COL_INFO, "Who is %s? Tell %s",
tvb_arphrdaddr_to_str(tvb, tha_offset, ar_hln, ar_hrd),
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, tha_offset, ar_hln, ar_hrd),
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd));
break;
case ARPOP_RREPLY:
case ARPOP_DRARPREPLY:
col_add_fstr(pinfo->cinfo, COL_INFO, "%s is at %s",
tvb_arphrdaddr_to_str(tvb, tha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(tvb, tpa_offset, ar_pln, ar_pro));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, tha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(pinfo->pool, tvb, tpa_offset, ar_pln, ar_pro));
break;
case ARPOP_DRARPERROR:
@ -1626,8 +1627,8 @@ dissect_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
case ARPOP_IREPLY:
col_add_fstr(pinfo->cinfo, COL_INFO, "%s is at %s",
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro));
break;
case ATMARPOP_NAK:
@ -1636,80 +1637,80 @@ dissect_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
case ARPOP_MARS_REQUEST:
col_add_fstr(pinfo->cinfo, COL_INFO, "MARS request from %s at %s",
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro));
break;
case ARPOP_MARS_MULTI:
col_add_fstr(pinfo->cinfo, COL_INFO, "MARS MULTI request from %s at %s",
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro));
break;
case ARPOP_MARS_MSERV:
col_add_fstr(pinfo->cinfo, COL_INFO, "MARS MSERV request from %s at %s",
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro));
break;
case ARPOP_MARS_JOIN:
col_add_fstr(pinfo->cinfo, COL_INFO, "MARS JOIN request from %s at %s",
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro));
break;
case ARPOP_MARS_LEAVE:
col_add_fstr(pinfo->cinfo, COL_INFO, "MARS LEAVE from %s at %s",
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro));
break;
case ARPOP_MARS_NAK:
col_add_fstr(pinfo->cinfo, COL_INFO, "MARS NAK from %s at %s",
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro));
break;
case ARPOP_MARS_UNSERV:
col_add_fstr(pinfo->cinfo, COL_INFO, "MARS UNSERV request from %s at %s",
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro));
break;
case ARPOP_MARS_SJOIN:
col_add_fstr(pinfo->cinfo, COL_INFO, "MARS SJOIN request from %s at %s",
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro));
break;
case ARPOP_MARS_SLEAVE:
col_add_fstr(pinfo->cinfo, COL_INFO, "MARS SLEAVE from %s at %s",
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro));
break;
case ARPOP_MARS_GROUPLIST_REQUEST:
col_add_fstr(pinfo->cinfo, COL_INFO, "MARS grouplist request from %s at %s",
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro));
break;
case ARPOP_MARS_GROUPLIST_REPLY:
col_add_fstr(pinfo->cinfo, COL_INFO, "MARS grouplist reply from %s at %s",
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro));
break;
case ARPOP_MARS_REDIRECT_MAP:
col_add_fstr(pinfo->cinfo, COL_INFO, "MARS redirect map from %s at %s",
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro));
break;
case ARPOP_MAPOS_UNARP:
col_add_fstr(pinfo->cinfo, COL_INFO, "MAPOS UNARP request from %s at %s",
tvb_arphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, sha_offset, ar_hln, ar_hrd),
tvb_arpproaddr_to_str(pinfo->pool, tvb, spa_offset, ar_pln, ar_pro));
break;
case ARPOP_EXP1:
@ -1800,7 +1801,7 @@ dissect_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
/* Also indicate in info column */
col_append_fstr(pinfo->cinfo, COL_INFO, " (duplicate use of %s detected!)",
arpproaddr_to_str((guint8*)&duplicate_ip, 4, ETHERTYPE_IP));
arpproaddr_to_str(pinfo->pool, (guint8*)&duplicate_ip, 4, ETHERTYPE_IP));
}
return tvb_captured_length(tvb);
}

@ -12,7 +12,7 @@
#ifndef __PACKET_ARP_H__
#define __PACKET_ARP_H__
const gchar *tvb_arphrdaddr_to_str(tvbuff_t *tvb, gint offset, int ad_len, guint16 type);
const gchar *tvb_arphrdaddr_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, int ad_len, guint16 type);
void dissect_atm_nsap(tvbuff_t *tvb, packet_info* pinfo, int offset, int len, proto_tree *tree);

@ -700,7 +700,7 @@ awdl_tag_service_params(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
}
static int
awdl_tag_channel_sequence(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_) {
awdl_tag_channel_sequence(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) {
proto_item *chanlist_item, *channel_item;
proto_tree *chanlist_tree, *channel_tree;
guint channels, chan_number;
@ -730,7 +730,7 @@ awdl_tag_channel_sequence(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre
offset += 2;
/* make sufficient space for channel decodings: 5 chars/channel (3-digit number + ', ') */
strbuf = wmem_strbuf_new_sized(wmem_packet_scope(), 5 * channels);
strbuf = wmem_strbuf_new_sized(pinfo->pool, 5 * channels);
switch (seq_enc) {
case AWDL_CHANSEQ_ENC_CHANNELNUMBER:
@ -1133,13 +1133,13 @@ awdl_tag_ht_capabilities(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree
*/
static int
add_awdl_dns_name(proto_tree *tree, int hfindex_regular, int hfindex_compressed,
tvbuff_t *tvb, int offset, int len, const gchar **name) {
tvbuff_t *tvb, int offset, int len, wmem_allocator_t *scope, const gchar **name) {
int start_offset = offset;
guint8 component_len;
const guchar *component;
wmem_strbuf_t *strbuf;
strbuf = wmem_strbuf_new_sized(wmem_packet_scope(), MAX_DNAME_LEN);
strbuf = wmem_strbuf_new_sized(scope, MAX_DNAME_LEN);
while (offset < (len + start_offset)) {
component_len = tvb_get_guint8(tvb, offset);
@ -1157,7 +1157,7 @@ add_awdl_dns_name(proto_tree *tree, int hfindex_regular, int hfindex_compressed,
} else {
/* regular label */
guint label_len;
proto_tree_add_item_ret_string_and_length(tree, hfindex_regular, tvb, offset, 1, ENC_ASCII, wmem_packet_scope(), &component, &label_len);
proto_tree_add_item_ret_string_and_length(tree, hfindex_regular, tvb, offset, 1, ENC_ASCII, scope, &component, &label_len);
offset += label_len;
}
if (component) {
@ -1174,7 +1174,7 @@ add_awdl_dns_name(proto_tree *tree, int hfindex_regular, int hfindex_compressed,
}
static int
add_awdl_dns_entry(proto_tree *tree, gint ett,
add_awdl_dns_entry(packet_info *pinfo, proto_tree *tree, gint ett,
int hfindex_entry, int hfindex_regular, int hfindex_compressed,
tvbuff_t *tvb, int offset, int len, const gchar **name) {
int start_offset = offset;
@ -1184,7 +1184,7 @@ add_awdl_dns_entry(proto_tree *tree, gint ett,
entry_item = proto_tree_add_item(tree, hfindex_entry, tvb, offset, 0, ENC_NA);
entry_tree = proto_item_add_subtree(entry_item, ett);
offset += add_awdl_dns_name(entry_tree, hfindex_regular, hfindex_compressed, tvb, offset, len, &n);
offset += add_awdl_dns_name(entry_tree, hfindex_regular, hfindex_compressed, tvb, offset, len, pinfo->pool, &n);
proto_item_set_end(entry_item, tvb, offset);
proto_item_append_text(entry_item, ": %s", n);
@ -1195,20 +1195,20 @@ add_awdl_dns_entry(proto_tree *tree, gint ett,
}
static int
awdl_tag_arpa(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_) {
awdl_tag_arpa(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) {
int offset = 0;
int tag_len = tvb_reported_length(tvb);
proto_tree_add_item(tree, hf_awdl_arpa_flags, tvb, offset, 1, ENC_NA);
offset += 1;
offset += add_awdl_dns_entry(tree, ett_awdl_dns_name, hf_awdl_arpa, hf_awdl_arpa_name,
offset += add_awdl_dns_entry(pinfo, tree, ett_awdl_dns_name, hf_awdl_arpa, hf_awdl_arpa_name,
hf_awdl_arpa_short, tvb, offset, tag_len - offset, NULL);
return offset;
}
static int
awdl_tag_service_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_) {
awdl_tag_service_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) {
proto_item *rr_item;
proto_tree *rr_tree, *data_len;
const gchar *name;
@ -1223,7 +1223,7 @@ awdl_tag_service_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre
// len field includes the following type value
len -= 1;
offset += add_awdl_dns_entry(rr_tree, ett_awdl_dns_name, hf_awdl_dns_name, hf_awdl_dns_name_label,
offset += add_awdl_dns_entry(pinfo, rr_tree, ett_awdl_dns_name, hf_awdl_dns_name, hf_awdl_dns_name_label,
hf_awdl_dns_name_short, tvb, offset, len, &name);
proto_tree_add_item_ret_uint(rr_tree, hf_awdl_dns_type, tvb, offset, 1, ENC_LITTLE_ENDIAN, &type);
@ -1243,7 +1243,7 @@ awdl_tag_service_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre
const guchar *txt;
gint label_len;
proto_tree_add_item_ret_string_and_length(rr_tree, hf_awdl_dns_txt, tvb, offset, 1, ENC_ASCII,
wmem_packet_scope(), &txt, &label_len);
pinfo->pool, &txt, &label_len);
offset += label_len;
proto_item_append_text(rr_item, ", %s", txt);
if (label_len > (gint) len) {
@ -1263,12 +1263,12 @@ awdl_tag_service_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre
offset += 2;
// length field includes above fields
len -= 6;
offset += add_awdl_dns_entry(rr_tree, ett_awdl_dns_name, hf_awdl_dns_target, hf_awdl_dns_target_label,
offset += add_awdl_dns_entry(pinfo, rr_tree, ett_awdl_dns_name, hf_awdl_dns_target, hf_awdl_dns_target_label,
hf_awdl_dns_target_short, tvb, offset, len, &name);
proto_item_append_text(rr_item, ", priority %u, weight %u, port %u, target %s", prio, weight, port, name);
break;
case T_PTR:
offset += add_awdl_dns_entry(rr_tree, ett_awdl_dns_name, hf_awdl_dns_ptr, hf_awdl_dns_ptr_label,
offset += add_awdl_dns_entry(pinfo, rr_tree, ett_awdl_dns_name, hf_awdl_dns_ptr, hf_awdl_dns_ptr_label,
hf_awdl_dns_ptr_short, tvb, offset, len, &name);
proto_item_append_text(rr_item, ", %s", name);
break;

@ -2132,7 +2132,7 @@ static void dissect_batadv_icmp_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree
}
static void
dissect_batadv_icmp_rr(proto_tree *batadv_icmp_tree, tvbuff_t *tvb, int offset)
dissect_batadv_icmp_rr(packet_info *pinfo, proto_tree *batadv_icmp_tree, tvbuff_t *tvb, int offset)
{
proto_tree *field_tree;
int ptr, i;
@ -2149,7 +2149,7 @@ dissect_batadv_icmp_rr(proto_tree *batadv_icmp_tree, tvbuff_t *tvb, int offset)
offset++;
for (i = 0; i < BAT_RR_LEN; i++) {
proto_tree_add_ether_format(field_tree, hf_batadv_icmp_rr_ether, tvb, offset, 6, tvb_get_ptr(tvb, offset, 6),
"%s%s", (i > ptr) ? "-" : tvb_ether_to_str(wmem_packet_scope(), tvb, offset),
"%s%s", (i > ptr) ? "-" : tvb_ether_to_str(pinfo->pool, tvb, offset),
(i == ptr) ? " <- (current)" : "");
offset += 6;
@ -2157,7 +2157,7 @@ dissect_batadv_icmp_rr(proto_tree *batadv_icmp_tree, tvbuff_t *tvb, int offset)
}
static void
dissect_batadv_icmp_rr_v15(proto_tree *batadv_icmp_tree, tvbuff_t *tvb,
dissect_batadv_icmp_rr_v15(packet_info *pinfo, proto_tree *batadv_icmp_tree, tvbuff_t *tvb,
int offset, int ptr)
{
proto_tree *field_tree;
@ -2174,7 +2174,7 @@ dissect_batadv_icmp_rr_v15(proto_tree *batadv_icmp_tree, tvbuff_t *tvb,
tvb, offset, 6,
tvb_get_ptr(tvb, offset, 6),
"%s%s",
(i > ptr) ? "-" : tvb_ether_to_str(wmem_packet_scope(), tvb, offset),
(i > ptr) ? "-" : tvb_ether_to_str(pinfo->pool, tvb, offset),
(i == ptr) ? " <- (current)" : "");
offset += 6;
@ -2248,7 +2248,7 @@ static void dissect_batadv_icmp_v7(tvbuff_t *tvb, packet_info *pinfo, proto_tree
/* rr data available? */
length_remaining = tvb_reported_length_remaining(tvb, offset);
if (length_remaining >= 1 + BAT_RR_LEN * 6) {
dissect_batadv_icmp_rr(batadv_icmp_tree, tvb, offset);
dissect_batadv_icmp_rr(pinfo, batadv_icmp_tree, tvb, offset);
offset += 1 + BAT_RR_LEN * 6;
}
@ -2332,7 +2332,7 @@ static void dissect_batadv_icmp_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tre
/* rr data available? */
length_remaining = tvb_reported_length_remaining(tvb, offset);
if (length_remaining >= 1 + BAT_RR_LEN * 6) {
dissect_batadv_icmp_rr(batadv_icmp_tree, tvb, offset);
dissect_batadv_icmp_rr(pinfo, batadv_icmp_tree, tvb, offset);
offset += 1 + BAT_RR_LEN * 6;
}
@ -2534,7 +2534,7 @@ static void dissect_batadv_icmp_simple_v15(tvbuff_t *tvb, packet_info *pinfo,
/* rr data available? */
length_remaining = tvb_reported_length_remaining(tvb, offset);
if (length_remaining >= BAT_RR_LEN * 6) {
dissect_batadv_icmp_rr_v15(batadv_icmp_tree, tvb, offset,
dissect_batadv_icmp_rr_v15(pinfo, batadv_icmp_tree, tvb, offset,
icmp_packeth->rr_ptr);
offset += BAT_RR_LEN * 6;
}

@ -159,7 +159,7 @@ static const value_string bcp_cmds[] = {
* return: nothing
*/
static void
dissect_bcp_connect_data(proto_tree *bcp_tree, tvbuff_t *tvb, gint flags)
dissect_bcp_connect_data(packet_info *pinfo, proto_tree *bcp_tree, tvbuff_t *tvb, gint flags)
{
proto_tree *bcp_subtree = NULL;
guint offset = 0;
@ -170,8 +170,8 @@ dissect_bcp_connect_data(proto_tree *bcp_tree, tvbuff_t *tvb, gint flags)
{
bcp_subtree = proto_tree_add_subtree_format(bcp_tree, tvb, offset, len, ett_bcp_data, NULL,
"BCP Connect Request: Name=%s IpAddr=%s",
tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 16, BCP_NAME_LEN, ENC_ASCII),
tvb_ip_to_str(wmem_packet_scope(), tvb, offset + 12));
tvb_get_string_enc(pinfo->pool, tvb, offset + 16, BCP_NAME_LEN, ENC_ASCII),
tvb_ip_to_str(pinfo->pool, tvb, offset + 12));
proto_tree_add_item(bcp_subtree, hf_bcp_connectreq_lenin, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
@ -215,7 +215,7 @@ dissect_bcp_connect_data(proto_tree *bcp_tree, tvbuff_t *tvb, gint flags)
* return: nothing
*/
static void
dissect_bcp_search_data(proto_tree *bcp_tree, tvbuff_t *tvb, gint flags)
dissect_bcp_search_data(packet_info *pinfo, proto_tree *bcp_tree, tvbuff_t *tvb, gint flags)
{
proto_tree *bcp_subtree = NULL;
guint type = 0;
@ -231,15 +231,15 @@ dissect_bcp_search_data(proto_tree *bcp_tree, tvbuff_t *tvb, gint flags)
case BCP_SEARCH_IPADDR:
bcp_subtree = proto_tree_add_subtree_format(bcp_tree, tvb, offset, len, ett_bcp_data, NULL,
"BCP Search Request: IpAddrFirst=%s, IpAddrLast=%s",
tvb_ip_to_str(wmem_packet_scope(), tvb, offset + 8),
tvb_ip_to_str(wmem_packet_scope(), tvb, offset + 12)
tvb_ip_to_str(pinfo->pool, tvb, offset + 8),
tvb_ip_to_str(pinfo->pool, tvb, offset + 12)
);
break;
case BCP_SEARCH_NAME:
bcp_subtree = proto_tree_add_subtree_format(bcp_tree, tvb, offset, len, ett_bcp_data, NULL,
"BCP Search Request: Name=%s",
tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 8, BCP_NAME_LEN, ENC_ASCII)
tvb_get_string_enc(pinfo->pool, tvb, offset + 8, BCP_NAME_LEN, ENC_ASCII)
);
break;
@ -277,8 +277,8 @@ dissect_bcp_search_data(proto_tree *bcp_tree, tvbuff_t *tvb, gint flags)
{
bcp_subtree = proto_tree_add_subtree_format(bcp_tree, tvb, offset, len, ett_bcp_data, NULL,
"BCP Search Response: Name=%s, IpAddr=%s Error=%d",
tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 16, BCP_NAME_LEN, ENC_ASCII),
tvb_ip_to_str(wmem_packet_scope(), tvb, offset + 12),
tvb_get_string_enc(pinfo->pool, tvb, offset + 16, BCP_NAME_LEN, ENC_ASCII),
tvb_ip_to_str(pinfo->pool, tvb, offset + 12),
tvb_get_letohl(tvb, offset)
);
@ -310,7 +310,7 @@ dissect_bcp_search_data(proto_tree *bcp_tree, tvbuff_t *tvb, gint flags)
* return: nothing
*/
static void
dissect_bcp_identify_data(proto_tree *bcp_tree, tvbuff_t *tvb)
dissect_bcp_identify_data(packet_info *pinfo, proto_tree *bcp_tree, tvbuff_t *tvb)
{
proto_tree *bcp_subtree = NULL;
guint offset = 0;
@ -319,8 +319,8 @@ dissect_bcp_identify_data(proto_tree *bcp_tree, tvbuff_t *tvb)
bcp_subtree = proto_tree_add_subtree_format(bcp_tree, tvb, offset, len, ett_bcp_data, NULL,
"BCP Identify Request: Name=%s, IpAddr=%s",
tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 12, BCP_NAME_LEN, ENC_ASCII),
tvb_ip_to_str(wmem_packet_scope(), tvb, offset + 8)
tvb_get_string_enc(pinfo->pool, tvb, offset + 12, BCP_NAME_LEN, ENC_ASCII),
tvb_ip_to_str(pinfo->pool, tvb, offset + 8)
);
proto_tree_add_item(bcp_subtree, hf_bcp_identify_error, tvb, offset, 4, ENC_BIG_ENDIAN);
@ -536,17 +536,17 @@ static int dissect_bluecom(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
break;
case BCP_BLK_CMD_IDENTIFY:
dissect_bcp_identify_data(bcp_tree, block_tvb);
dissect_bcp_identify_data(pinfo, bcp_tree, block_tvb);
break;
case BCP_BLK_CMD_SEARCH:
col_append_str(pinfo->cinfo, COL_INFO, REQRSP(flags));
dissect_bcp_search_data(bcp_tree, block_tvb, flags);
dissect_bcp_search_data(pinfo, bcp_tree, block_tvb, flags);
break;
case BCP_BLK_CMD_CONNECT:
col_append_str(pinfo->cinfo, COL_INFO, REQRSP(flags));
dissect_bcp_connect_data(bcp_tree, block_tvb, flags);
dissect_bcp_connect_data(pinfo, bcp_tree, block_tvb, flags);
break;
case BCP_BLK_CMD_DATA:

@ -1970,11 +1970,11 @@ dissect_bundle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
}
}
wscbor_chunk_t *frame = wscbor_chunk_read(wmem_packet_scope(), tvb, &offset);
wscbor_chunk_t *frame = wscbor_chunk_read(pinfo->pool, tvb, &offset);
if (frame->type_major == CBOR_TYPE_ARRAY) {
wscbor_chunk_t *primary = wscbor_chunk_read(wmem_packet_scope(), tvb, &offset);
wscbor_chunk_t *primary = wscbor_chunk_read(pinfo->pool, tvb, &offset);
if (primary->type_major == CBOR_TYPE_ARRAY) {
wscbor_chunk_t *version = wscbor_chunk_read(wmem_packet_scope(), tvb, &offset);
wscbor_chunk_t *version = wscbor_chunk_read(pinfo->pool, tvb, &offset);
if (version->type_major == CBOR_TYPE_UINT) {
guint64 vers_val = version->head_value;
if (vers_val == 7) {

@ -156,7 +156,7 @@ dissect_nrgyz_tlv(tvbuff_t *tvb, packet_info* pinfo, int offset, guint16 length,
static void
dissect_spare_poe_tlv(tvbuff_t *tvb, int offset, int length, proto_tree *tree);
static void
add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start,
add_multi_line_string_to_tree(wmem_allocator_t *scope, proto_tree *tree, tvbuff_t *tvb, gint start,
gint len, int hf);
#define TYPE_DEVICE_ID 0x0001
@ -452,7 +452,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
length, ett_cdp_tlv, NULL, "Software Version");
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
add_multi_line_string_to_tree(tlv_tree, tvb, offset + 4,
add_multi_line_string_to_tree(pinfo->pool, tlv_tree, tvb, offset + 4,
length - 4, hf_cdp_software_version);
}
offset += length;
@ -1279,7 +1279,7 @@ dissect_spare_poe_tlv(tvbuff_t *tvb, int offset, int length,
}
static void
add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start,
add_multi_line_string_to_tree(wmem_allocator_t *scope, proto_tree *tree, tvbuff_t *tvb, gint start,
gint len, int hf)
{
gint next;
@ -1289,7 +1289,7 @@ add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start,
while (len > 0) {
line_len = tvb_find_line_end(tvb, start, len, &next, FALSE);
data_len = next - start;
proto_tree_add_string(tree, hf, tvb, start, data_len, tvb_format_stringzpad(wmem_packet_scope(), tvb, start, line_len));
proto_tree_add_string(tree, hf, tvb, start, data_len, tvb_format_stringzpad(scope, tvb, start, line_len));
start += data_len;
len -= data_len;
}

@ -512,7 +512,7 @@ dissect_dhcpfo_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* da
break;
}
htype = tvb_get_guint8(tvb, offset);
htype_str = tvb_arphrdaddr_to_str(tvb, offset+1, option_length-1,
htype_str = tvb_arphrdaddr_to_str(pinfo->pool, tvb, offset+1, option_length-1,
htype);
proto_item_append_text(oi, ", %s, %s", htype_str,

@ -1133,7 +1133,7 @@ static const enum_val_t pkt_ccc_protocol_versions[] = {
static gint pkt_ccc_protocol_version = PACKETCABLE_CCC_RFC_3495;
static guint pkt_ccc_option = 122;
static void dissect_docsis_cm_cap(proto_tree *v_tree, tvbuff_t *tvb,
static void dissect_docsis_cm_cap(packet_info *pinfo, proto_tree *v_tree, tvbuff_t *tvb,
int voff, int len, gboolean opt125);
#define ARUBA_INSTANT_AP "ArubaInstantAP"
@ -2051,7 +2051,7 @@ dhcp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, int voff,
case 60:
*vendor_class_id_p =
tvb_get_string_enc(wmem_packet_scope(),
tvb_get_string_enc(pinfo->pool,
tvb, voff+2, consumed-2, ENC_ASCII);
break;
case 119:
@ -2295,7 +2295,7 @@ dissect_dhcpopt_client_identifier(tvbuff_t *tvb, packet_info *pinfo, proto_tree
proto_tree_add_item(tree, hf_dhcp_hw_ether_addr, tvb, offset+1, 6, ENC_NA);
else
proto_tree_add_string(tree, hf_dhcp_client_hardware_address, tvb, offset+1, 6,
tvb_arphrdaddr_to_str(tvb, offset+1, 6, byte));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, offset+1, 6, byte));
} else if (length == 17 && byte == 0) {
/* Identifier is a UUID */
proto_tree_add_item(tree, hf_dhcp_client_identifier_uuid, tvb, offset + 1, 16, dhcp_uuid_endian);
@ -2311,7 +2311,7 @@ dissect_dhcpopt_client_identifier(tvbuff_t *tvb, packet_info *pinfo, proto_tree
/* The type field is immediately followed by the IAID, which is
an opaque 32-bit quantity */
proto_tree_add_string(tree, hf_dhcp_client_id_iaid, tvb, offset+1, 4,
tvb_arphrdaddr_to_str(tvb, offset+1, 4, byte));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, offset+1, 4, byte));
offset += 5;
duidtype = tvb_get_ntohs(tvb, offset);
proto_tree_add_item(tree, hf_dhcp_client_id_duid_type, tvb, offset, 2, ENC_BIG_ENDIAN);
@ -2329,7 +2329,7 @@ dissect_dhcpopt_client_identifier(tvbuff_t *tvb, packet_info *pinfo, proto_tree
proto_tree_add_item(tree, hf_dhcp_client_identifier_time, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
if (length > 8) {
proto_tree_add_string(tree, hf_dhcp_client_identifier_link_layer_address, tvb, offset + 8,
length - 13, tvb_arphrdaddr_to_str(tvb, offset+8, length-13, hwtype));
length - 13, tvb_arphrdaddr_to_str(pinfo->pool, tvb, offset+8, length-13, hwtype));
}
break;
case DUID_EN:
@ -2353,7 +2353,7 @@ dissect_dhcpopt_client_identifier(tvbuff_t *tvb, packet_info *pinfo, proto_tree
if (length > 4) {
proto_tree_add_string(tree, hf_dhcp_client_identifier_link_layer_address, tvb, offset + 4,
length - 9, tvb_arphrdaddr_to_str(tvb, offset+4, length-9, hwtype));
length - 9, tvb_arphrdaddr_to_str(pinfo->pool, tvb, offset+4, length-9, hwtype));
}
break;
}
@ -2504,7 +2504,7 @@ dissect_dhcpopt_client_full_domain_name(tvbuff_t *tvb, packet_info *pinfo, proto
if (fqdn_flags & F_FQDN_E) {
get_dns_name(tvb, offset+3, length-3, offset+3, (const char **)&dns_name, &dns_name_len);
proto_tree_add_string(tree, hf_dhcp_fqdn_name,
tvb, offset+3, length-3, format_text(wmem_packet_scope(), dns_name, dns_name_len));
tvb, offset+3, length-3, format_text(pinfo->pool, dns_name, dns_name_len));
} else {
proto_tree_add_item(tree, hf_dhcp_fqdn_asciiname, tvb, offset+3, length-3, ENC_ASCII);
}
@ -2685,7 +2685,7 @@ dissect_dhcpopt_client_network_interface_id(tvbuff_t *tvb, packet_info *pinfo _U
}
static int
dissect_dhcpopt_client_identifier_uuid(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
dissect_dhcpopt_client_identifier_uuid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
int offset = 0, length = tvb_reported_length(tvb);
guint8 byte;
@ -2710,7 +2710,7 @@ dissect_dhcpopt_client_identifier_uuid(tvbuff_t *tvb, packet_info *pinfo _U_, pr
proto_tree_add_item(tree, hf_dhcp_hw_ether_addr, tvb, offset+1, 6, ENC_NA);
else
proto_tree_add_string(tree, hf_dhcp_client_hardware_address, tvb, offset+1, 6,
tvb_arphrdaddr_to_str(tvb, offset+1, 6, byte));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, offset+1, 6, byte));
} else if (length == 17 && byte == 0) {
/* Identifier is a UUID */
proto_tree_add_item(tree, hf_dhcp_client_identifier_uuid, tvb, offset + 1, 16, dhcp_uuid_endian);
@ -2805,7 +2805,7 @@ dissect_dhcpopt_name_server_search(tvbuff_t *tvb, packet_info *pinfo, proto_tree
}
static int
dissect_dhcpopt_dhcp_domain_search(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
dissect_dhcpopt_dhcp_domain_search(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
int length = tvb_reported_length(tvb);
gchar *name_out;
@ -2817,10 +2817,10 @@ dissect_dhcpopt_dhcp_domain_search(tvbuff_t *tvb, packet_info *pinfo _U_, proto_
rfc3396_dns_domain_search_list.index_current_block++;
if (rfc3396_dns_domain_search_list.total_number_of_block > 1) {
proto_tree_add_string(tree, hf_dhcp_option_dhcp_dns_domain_search_list_rfc_3396_detected, tvb, 0, length,
wmem_strdup_printf(wmem_packet_scope(), "%u/%u", rfc3396_dns_domain_search_list.index_current_block, rfc3396_dns_domain_search_list.total_number_of_block));
wmem_strdup_printf(pinfo->pool, "%u/%u", rfc3396_dns_domain_search_list.index_current_block, rfc3396_dns_domain_search_list.total_number_of_block));
if (rfc3396_dns_domain_search_list.index_current_block != rfc3396_dns_domain_search_list.total_number_of_block) {
proto_tree_add_string(tree, hf_dhcp_option_dhcp_dns_domain_search_list_refer_last_option, tvb, 0, length,
wmem_strdup_printf(wmem_packet_scope(), "%u/%u", rfc3396_dns_domain_search_list.total_number_of_block, rfc3396_dns_domain_search_list.total_number_of_block));
wmem_strdup_printf(pinfo->pool, "%u/%u", rfc3396_dns_domain_search_list.total_number_of_block, rfc3396_dns_domain_search_list.total_number_of_block));
}
}
@ -2845,7 +2845,7 @@ dissect_dhcpopt_dhcp_domain_search(tvbuff_t *tvb, packet_info *pinfo _U_, proto_
/* use the get_dns_name method that manages all techniques of RFC 1035 (compression pointer and so on) */
consumedx = get_dns_name(rfc3396_dns_domain_search_list.tvb_composite, composite_offset,
tvb_reported_length(rfc3396_dns_domain_search_list.tvb_composite), 0, (const gchar **)&dns_name, &dns_name_len);
name_out = format_text(wmem_packet_scope(), dns_name, dns_name_len);
name_out = format_text(pinfo->pool, dns_name, dns_name_len);
if (rfc3396_dns_domain_search_list.total_number_of_block == 1) {
/* RFC 3396 is not used, so we can easily link the fqdn with v_tree. */
proto_tree_add_string(tree, hf_dhcp_option_dhcp_dns_domain_search_list_fqdn, tvb, composite_offset, consumedx, name_out);
@ -2874,10 +2874,10 @@ dissect_dhcpopt_sip_servers(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
rfc3396_sip_server.index_current_block++;
if (rfc3396_sip_server.total_number_of_block > 1) {
proto_tree_add_string(tree, hf_dhcp_option_sip_server_rfc_3396_detected, tvb, 0, length,
wmem_strdup_printf(wmem_packet_scope(), "%u/%u", rfc3396_sip_server.index_current_block, rfc3396_sip_server.total_number_of_block));
wmem_strdup_printf(pinfo->pool, "%u/%u", rfc3396_sip_server.index_current_block, rfc3396_sip_server.total_number_of_block));
if (rfc3396_sip_server.index_current_block != rfc3396_sip_server.total_number_of_block) {
proto_tree_add_string(tree, hf_dhcp_option_sip_server_refer_last_option, tvb, 0, length,
wmem_strdup_printf(wmem_packet_scope(), "%u/%u", rfc3396_sip_server.total_number_of_block, rfc3396_sip_server.total_number_of_block));
wmem_strdup_printf(pinfo->pool, "%u/%u", rfc3396_sip_server.total_number_of_block, rfc3396_sip_server.total_number_of_block));
}
}
@ -2919,7 +2919,7 @@ dissect_dhcpopt_sip_servers(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* use the get_dns_name method that manages all techniques of RFC 1035 (compression pointer and so on) */
consumedx = get_dns_name(rfc3396_sip_server.tvb_composite, composite_offset, tvb_reported_length(rfc3396_sip_server.tvb_composite),
1 /* ignore enc */, (const gchar **)&dns_name, &dns_name_len);
name_out = format_text(wmem_packet_scope(), dns_name, dns_name_len);
name_out = format_text(pinfo->pool, dns_name, dns_name_len);
if (rfc3396_sip_server.total_number_of_block == 1) {
/* RFC 3396 is not used, so we can easily link the fqdn with v_tree. */
@ -3137,7 +3137,7 @@ dissect_dhcpopt_rdnss(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
get_dns_name(tvb, offset, tvb_reported_length_remaining(tvb,offset), offset, (const gchar **)&dns_name, &dns_name_len);
proto_tree_add_string(tree, hf_dhcp_option_rdnss_domain, tvb, offset,
tvb_reported_length_remaining(tvb,offset), format_text(wmem_packet_scope(), dns_name, dns_name_len));
tvb_reported_length_remaining(tvb,offset), format_text(pinfo->pool, dns_name, dns_name_len));
return tvb_captured_length(tvb);
}
@ -3292,10 +3292,10 @@ dissect_dhcpopt_avaya_ip_telephone(tvbuff_t *tvb, packet_info *pinfo, proto_tree
expert_add_info_format(pinfo, tree, &ei_dhcp_bad_length, "Avaya IP Telephone option length isn't >= 5");
return 1;
}
avaya_ti = proto_tree_add_item_ret_string(tree, hf_dhcp_option242_avaya, tvb, offset, tvb_reported_length(tvb), ENC_ASCII|ENC_NA, wmem_packet_scope(), (const guint8 **)&avaya_option);
avaya_ti = proto_tree_add_item_ret_string(tree, hf_dhcp_option242_avaya, tvb, offset, tvb_reported_length(tvb), ENC_ASCII|ENC_NA, pinfo->pool, (const guint8 **)&avaya_option);
o242avaya_v_tree = proto_item_add_subtree(avaya_ti, ett_dhcp_option242_suboption);
avaya_param_buf = wmem_strbuf_new(wmem_packet_scope(), "");
gchar **fields = wmem_strsplit(wmem_packet_scope(), avaya_option, ",", -1);
avaya_param_buf = wmem_strbuf_new(pinfo->pool, "");
gchar **fields = wmem_strsplit(pinfo->pool, avaya_option, ",", -1);
for (int i = 0; fields[i]; i++) {
const gchar *field = fields[i];
if (!strchr(field, '=')) {
@ -5404,7 +5404,7 @@ dissect_vendor_tr111_suboption(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr
}
else if (o125_tr111_opt[subopt].ftype == oui) {
/* Get hex string. Expecting 6 characters. */
const gchar *oui_string = (gchar *)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, subopt_len, ENC_ASCII);
const gchar *oui_string = (gchar *)tvb_get_string_enc(pinfo->pool, tvb, offset, subopt_len, ENC_ASCII);
/* Convert to OUI number. Only 3 bytes so no data lost in downcast. */
guint32 oui_number = (guint32)strtol(oui_string, NULL, 16);
/* Add item using oui_vals */
@ -5501,7 +5501,7 @@ dissect_vendor_cl_suboption(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
proto_tree_add_item(o125_v_tree, hf_dhcp_option125_value, tvb, offset, subopt_len, ENC_NA);
switch(subopt){
case 5: /* Modem Capabilities */
dissect_docsis_cm_cap(o125_v_tree, tvb, offset-2, subopt_len+2, TRUE);
dissect_docsis_cm_cap(pinfo, o125_v_tree, tvb, offset-2, subopt_len+2, TRUE);
break;
}
break;
@ -5938,7 +5938,7 @@ dissect_packetcable_mta_vendor_id_heur( tvbuff_t *tvb, packet_info *pinfo, proto
return FALSE;
}
vendor_id = tvb_get_string_enc(wmem_packet_scope(), tvb, 0, 8, ENC_ASCII|ENC_NA);
vendor_id = tvb_get_string_enc(pinfo->pool, tvb, 0, 8, ENC_ASCII|ENC_NA);
if ((strcmp((const char*)vendor_id, PACKETCABLE_MTA_CAP10) == 0) ||
(strcmp((const char*)vendor_id, PACKETCABLE_MTA_CAP15) == 0) ||
(strcmp((const char*)vendor_id, PACKETCABLE_MTA_CAP20) == 0)) {
@ -6179,22 +6179,22 @@ display_uint_with_range_checking(proto_item *ti, guint8 val_byte, guint16 val_ui
}
}
static void get_opt125_tlv(tvbuff_t *tvb, guint off, guint8 *tlvtype, guint8 *tlvlen, guint8 **value)
static void get_opt125_tlv(wmem_allocator_t *scope, tvbuff_t *tvb, guint off, guint8 *tlvtype, guint8 *tlvlen, guint8 **value)
{
/* Type */
*tlvtype = tvb_get_guint8(tvb, off);
/* Length */
*tlvlen = tvb_get_guint8(tvb, off+1);
/* Value */
*value = (guint8 *)tvb_memdup(wmem_packet_scope(), tvb, off + 2, *tlvlen);
*value = (guint8 *)tvb_memdup(scope, tvb, off + 2, *tlvlen);
}
static void get_opt60_tlv(tvbuff_t *tvb, guint off, guint8 *tlvtype, guint8 *tlvlen, guint8 **value)
static void get_opt60_tlv(wmem_allocator_t *scope, tvbuff_t *tvb, guint off, guint8 *tlvtype, guint8 *tlvlen, guint8 **value)
{
guint i;
guint8 *val_asc;
val_asc = (guint8 *)wmem_alloc0(wmem_packet_scope(), 4);
val_asc = (guint8 *)wmem_alloc0(scope, 4);
/* Type */
tvb_memcpy(tvb, val_asc, off, 2);
*tlvtype = (guint8)strtoul((gchar*)val_asc, NULL, 16);
@ -6202,7 +6202,7 @@ static void get_opt60_tlv(tvbuff_t *tvb, guint off, guint8 *tlvtype, guint8 *tlv
tvb_memcpy(tvb, val_asc, off + 2, 2);
*tlvlen = (guint8)strtoul((gchar*)val_asc, NULL, 16);
/* Value */
*value = (guint8 *)wmem_alloc0(wmem_packet_scope(), *tlvlen);
*value = (guint8 *)wmem_alloc0(scope, *tlvlen);
for (i=0; i<*tlvlen; i++)
{
memset(val_asc, 0, 4);
@ -6212,7 +6212,7 @@ static void get_opt60_tlv(tvbuff_t *tvb, guint off, guint8 *tlvtype, guint8 *tlv
}
static void
dissect_docsis_cm_cap(proto_tree *v_tree, tvbuff_t *tvb, int voff, int len, gboolean opt125)
dissect_docsis_cm_cap(packet_info *pinfo, proto_tree *v_tree, tvbuff_t *tvb, int voff, int len, gboolean opt125)
{
guint8 *asc_val;
proto_item *ti;
@ -6259,7 +6259,7 @@ dissect_docsis_cm_cap(proto_tree *v_tree, tvbuff_t *tvb, int voff, int len, gboo
if (opt125)
{
get_opt125_tlv(tvb, off, &tlv_type, &tlv_len, &val_other);
get_opt125_tlv(pinfo->pool, tvb, off, &tlv_type, &tlv_len, &val_other);
ti = proto_tree_add_uint_format(v_tree, hf_dhcp_docsis_cm_cap_type, tvb, off,
tlv_len + 2,
tlv_type,
@ -6272,7 +6272,7 @@ dissect_docsis_cm_cap(proto_tree *v_tree, tvbuff_t *tvb, int voff, int len, gboo
/* Option 60 is formatted as an ASCII string. Since the capabilities
are the same for both options I am converting the Option 60 values
from ASCII to uint8s to allow the same parser to work for both */
get_opt60_tlv(tvb, off, &tlv_type, &tlv_len, &val_other);
get_opt60_tlv(pinfo->pool, tvb, off, &tlv_type, &tlv_len, &val_other);
ti = proto_tree_add_uint_format(v_tree, hf_dhcp_docsis_cm_cap_type, tvb, off,
(tlv_len * 2) + 4,
tlv_type,
@ -6541,7 +6541,7 @@ dissect_docsis_cm_cap(proto_tree *v_tree, tvbuff_t *tvb, int voff, int len, gboo
}
static gboolean
dissect_packetcable_cm_vendor_id_heur( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_ )
dissect_packetcable_cm_vendor_id_heur( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ )
{
guint8* vendor_id;
@ -6549,10 +6549,10 @@ dissect_packetcable_cm_vendor_id_heur( tvbuff_t *tvb, packet_info *pinfo _U_, pr
return FALSE;
}
vendor_id = tvb_get_string_enc(wmem_packet_scope(), tvb, 0, 10, ENC_ASCII|ENC_NA);
vendor_id = tvb_get_string_enc(pinfo->pool, tvb, 0, 10, ENC_ASCII|ENC_NA);
if ((strcmp((const char*)vendor_id, PACKETCABLE_CM_CAP11) == 0) ||
(strcmp((const char*)vendor_id, PACKETCABLE_CM_CAP20) == 0)) {
dissect_docsis_cm_cap(tree, tvb, 0, tvb_reported_length(tvb), FALSE);
dissect_docsis_cm_cap(pinfo, tree, tvb, 0, tvb_reported_length(tvb), FALSE);
return TRUE;
}
@ -6824,7 +6824,7 @@ dissect_packetcable_ietf_ccc(packet_info *pinfo, proto_item *v_ti, proto_tree *v
case 0:
get_dns_name(tvb, suboptoff, subopt_len, suboptoff, (const char **)&dns_name, &dns_name_len);
proto_item_append_text(vti, "%s (%u byte%s)", format_text(wmem_packet_scope(), dns_name, dns_name_len),
proto_item_append_text(vti, "%s (%u byte%s)", format_text(pinfo->pool, dns_name, dns_name_len),
subopt_len - 1, plurality(subopt_len, "", "s") );
break;
@ -6882,7 +6882,7 @@ dissect_packetcable_ietf_ccc(packet_info *pinfo, proto_item *v_ti, proto_tree *v
case PKT_CCC_KRB_REALM: /* String values */
get_dns_name(tvb, suboptoff, subopt_len, suboptoff, (const gchar **)&dns_name, &dns_name_len);
proto_item_append_text(vti, "%s (%u byte%s)", format_text(wmem_packet_scope(), dns_name, dns_name_len),
proto_item_append_text(vti, "%s (%u byte%s)", format_text(pinfo->pool, dns_name, dns_name_len),
subopt_len, plurality(subopt_len, "", "s") );
suboptoff += subopt_len;
break;
@ -7029,12 +7029,12 @@ dissect_dhcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
if ((htype == ARPHRD_ETHER || htype == ARPHRD_IEEE802)
&& hlen == 6) {
col_add_fstr(pinfo->cinfo, COL_INFO, "Boot Request from %s (%s)",
tvb_arphrdaddr_to_str(tvb, 28, hlen, htype),
tvb_arphrdaddr_to_str(pinfo->pool, tvb, 28, hlen, htype),
tvb_get_ether_name(tvb, 28));
}
else {
col_add_fstr(pinfo->cinfo, COL_INFO, "Boot Request from %s",
tvb_arphrdaddr_to_str(tvb, 28, hlen, htype));
tvb_arphrdaddr_to_str(pinfo->pool, tvb, 28, hlen, htype));
}
break;
@ -7147,7 +7147,7 @@ dissect_dhcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
/* The chaddr element is 16 bytes in length,
although only the first hlen bytes are used */
proto_tree_add_bytes_format_value(bp_tree, hf_dhcp_hw_addr, tvb, 28, 16,
NULL, "%s", tvb_arphrdaddr_to_str(tvb, 28, hlen, htype));
NULL, "%s", tvb_arphrdaddr_to_str(pinfo->pool, tvb, 28, hlen, htype));
if ((16 - hlen) > 0)
proto_tree_add_item(bp_tree, hf_dhcp_hw_addr_padding, tvb, 28+hlen, 16-hlen, ENC_NA);
} else {

@ -1894,7 +1894,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
if (optlen > 8) {
hwtype = tvb_get_ntohs(tvb, off + 2);
proto_tree_add_string(subtree, hf_duidllt_link_layer_addr, tvb, off + 8,
optlen - 8, tvb_arphrdaddr_to_str(tvb, off+8, optlen-8, hwtype));
optlen - 8, tvb_arphrdaddr_to_str(pinfo->pool, tvb, off+8, optlen-8, hwtype));
}
}
break;
@ -1917,7 +1917,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
if (optlen > 4) {
hwtype = tvb_get_ntohs(tvb, off + 2);
proto_tree_add_string(subtree, hf_duidll_link_layer_addr, tvb, off + 4,
optlen - 4, tvb_arphrdaddr_to_str(tvb, off+4, optlen-4, hwtype));
optlen - 4, tvb_arphrdaddr_to_str(pinfo->pool, tvb, off+4, optlen-4, hwtype));
}
break;
case DUID_UUID:
@ -2142,7 +2142,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
break;
}
proto_tree_add_string(subtree, hf_iaid, tvb, off,
4, tvb_arphrdaddr_to_str(tvb, off, 4, opttype)); /* XXX: IAID is opaque ? review ... */
4, tvb_arphrdaddr_to_str(pinfo->pool, tvb, off, 4, opttype)); /* XXX: IAID is opaque ? review ... */
if (tvb_get_ntohl(tvb, off+4) == DHCPV6_LEASEDURATION_INFINITY) {
proto_tree_add_uint_format_value(subtree, hf_iaid_t1, tvb, off+4,
4, DHCPV6_LEASEDURATION_INFINITY, "infinity");
@ -2175,7 +2175,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
break;
}
proto_tree_add_string(subtree, hf_iata, tvb, off,
4, tvb_arphrdaddr_to_str(tvb, off, 4, opttype)); /* XXX: IAID is opaque ? review ... */
4, tvb_arphrdaddr_to_str(pinfo->pool, tvb, off, 4, opttype)); /* XXX: IAID is opaque ? review ... */
temp_optlen = 4;
while ((optlen - temp_optlen) > 0) {
temp_optlen += dhcpv6_option(tvb, pinfo, subtree,
@ -2343,7 +2343,7 @@ dhcpv6_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree,
temp_optlen = optlen - namelen;
off += namelen;
if (temp_optlen >= 6)
proto_tree_add_string(subtree, hf_cablelabs_interface_id_link_address, tvb, off, temp_optlen, tvb_arphrdaddr_to_str(tvb, off, 6, ARPHRD_ETHER));
proto_tree_add_string(subtree, hf_cablelabs_interface_id_link_address, tvb, off, temp_optlen, tvb_arphrdaddr_to_str(pinfo->pool, tvb, off, 6, ARPHRD_ETHER));