summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2015-11-26 04:44:52 +0000
committerJoão Valverde <j@v6e.pt>2016-02-07 23:22:30 +0000
commit13ec77a9fc3af3b0b502820d0b55796c89997896 (patch)
treec5f5f72f090efd5471cf95095b00e13efa407959 /plugins
parentd762a895ab570680e4e72142a348ad2b07c97d4f (diff)
downloadwireshark-13ec77a9fc3af3b0b502820d0b55796c89997896.tar.gz
Add free_address_wmem() and other extensions to address API
Try to improve 'address' API (to be easier/safer) and also avoid some constness warnings by not overloading the 'data' pointer to store malloc'ed buffers (use private pointer for that instead). Change-Id: I7456516b12c67620ceadac447907c12f5905bd49 Reviewed-on: https://code.wireshark.org/review/13463 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/irda/packet-irda.c35
-rw-r--r--plugins/unistim/packet-unistim.c4
-rw-r--r--plugins/wimax/mac_hd_generic_decoder.c12
-rw-r--r--plugins/wimax/packet-wmx.c2
4 files changed, 18 insertions, 35 deletions
diff --git a/plugins/irda/packet-irda.c b/plugins/irda/packet-irda.c
index 1e2d070ee6..7975d1cbec 100644
--- a/plugins/irda/packet-irda.c
+++ b/plugins/irda/packet-irda.c
@@ -529,13 +529,9 @@ static void dissect_iap_request(tvbuff_t* tvb, packet_info* pinfo, proto_tree* r
/* create conversation entry */
src = circuit_id ^ CMD_FRAME;
- srcaddr.type = AT_NONE;
- srcaddr.len = 1;
- srcaddr.data = (guint8*)&src;
+ set_address(&srcaddr, AT_NONE, 1, &src);
- destaddr.type = AT_NONE;
- destaddr.len = 1;
- destaddr.data = (guint8*)&circuit_id;
+ set_address(&destaddr, AT_NONE, 1, &circuit_id);
conv = find_conversation(pinfo->num, &srcaddr, &destaddr, PT_NONE, pinfo->srcport, pinfo->destport, 0);
if (conv)
@@ -682,13 +678,9 @@ static void dissect_iap_result(tvbuff_t* tvb, packet_info* pinfo, proto_tree* ro
retcode = tvb_get_guint8(tvb, offset + 1);
src = circuit_id ^ CMD_FRAME;
- srcaddr.type = AT_NONE;
- srcaddr.len = 1;
- srcaddr.data = (guint8*)&src;
+ set_address(&srcaddr, AT_NONE, 1, &src);
- destaddr.type = AT_NONE;
- destaddr.len = 1;
- destaddr.data = (guint8*)&circuit_id;
+ set_address(&destaddr, AT_NONE, 1, &circuit_id);
/* Find result value dissector */
conv = find_conversation(pinfo->num, &srcaddr, &destaddr, PT_NONE, pinfo->srcport, pinfo->destport, 0);
@@ -967,13 +959,9 @@ static void dissect_appl_proto(tvbuff_t* tvb, packet_info* pinfo, proto_tree* ro
src = circuit_id ^ CMD_FRAME;
- srcaddr.type = AT_NONE;
- srcaddr.len = 1;
- srcaddr.data = (guint8*)&src;
+ set_address(&srcaddr, AT_NONE, 1, &src);
- destaddr.type = AT_NONE;
- destaddr.len = 1;
- destaddr.data = (guint8*)&circuit_id;
+ set_address(&destaddr, AT_NONE, 1, &circuit_id);
/* Find result value dissector */
conv = find_conversation(pinfo->num, &srcaddr, &destaddr, PT_NONE, pinfo->srcport, pinfo->destport, 0);
@@ -1200,14 +1188,9 @@ void add_lmp_conversation(packet_info* pinfo, guint8 dlsap, gboolean ttp, dissec
/*g_message("%d: add_lmp_conversation(%p, %d, %d, %p) = ", pinfo->num, pinfo, dlsap, ttp, proto_dissector); */
- srcaddr.type = AT_NONE;
- srcaddr.len = 1;
- srcaddr.data = (guint8*)&circuit_id;
-
- dest = circuit_id ^ CMD_FRAME;
- destaddr.type = AT_NONE;
- destaddr.len = 1;
- destaddr.data = (guint8*)&dest;
+ set_address(&srcaddr, AT_NONE, 1, &circuit_id);
+
+ set_address(&destaddr, AT_NONE, 1, &dest);
conv = find_conversation(pinfo->num, &destaddr, &srcaddr, PT_NONE, dlsap, 0, NO_PORT_B);
if (conv)
diff --git a/plugins/unistim/packet-unistim.c b/plugins/unistim/packet-unistim.c
index 78e99c9bba..c5f867136c 100644
--- a/plugins/unistim/packet-unistim.c
+++ b/plugins/unistim/packet-unistim.c
@@ -231,8 +231,8 @@ dissect_unistim(tvbuff_t *tvb,packet_info *pinfo,proto_tree *tree,void *data _U_
uinfo->set_termid = -1;
uinfo->string_data = NULL;
uinfo->key_buffer = NULL;
- set_address(&uinfo->it_ip, AT_NONE, 0, NULL);
- set_address(&uinfo->ni_ip, AT_NONE, 0, NULL);
+ clear_address(&uinfo->it_ip);
+ clear_address(&uinfo->ni_ip);
uinfo->it_port = 0;
offset+=4;
diff --git a/plugins/wimax/mac_hd_generic_decoder.c b/plugins/wimax/mac_hd_generic_decoder.c
index d2d644d94d..b5fc149827 100644
--- a/plugins/wimax/mac_hd_generic_decoder.c
+++ b/plugins/wimax/mac_hd_generic_decoder.c
@@ -1069,15 +1069,15 @@ static int dissect_mac_header_generic_decoder(tvbuff_t *tvb, packet_info *pinfo,
first_gmh = FALSE;
cid = cid_base + cid_adjust[cid_index] + cid_vernier[cid_index];
/* Save address pointers. */
- save_src = pinfo->src;
- save_dst = pinfo->dst;
+ copy_address_shallow(&save_src, &pinfo->src);
+ copy_address_shallow(&save_dst, &pinfo->dst);
/* Use dl_src and dl_dst in defragmentation. */
- pinfo->src = pinfo->dl_src;
- pinfo->dst = pinfo->dl_dst;
+ copy_address_shallow(&pinfo->src, &pinfo->dl_src);
+ copy_address_shallow(&pinfo->dst, &pinfo->dl_dst);
payload_frag = fragment_add_seq(&payload_reassembly_table, tvb, offset, pinfo, cid, NULL, frag_number[cid_index], frag_len, ((frag_type==LAST_FRAG)?0:1), 0);
/* Restore address pointers. */
- pinfo->src = save_src;
- pinfo->dst = save_dst;
+ copy_address_shallow(&pinfo->src, &save_src);
+ copy_address_shallow(&pinfo->dst, &save_dst);
if (frag_type == LAST_FRAG)
{
/* Make sure fragment_add_seq() sees next one as a new frame. */
diff --git a/plugins/wimax/packet-wmx.c b/plugins/wimax/packet-wmx.c
index 533257caa1..c71dafc718 100644
--- a/plugins/wimax/packet-wmx.c
+++ b/plugins/wimax/packet-wmx.c
@@ -45,7 +45,7 @@ gint mac_sdu_length = 49; /* default SDU size is 49 bytes (11.13.16) */
extern guint global_cid_max_basic;
extern gboolean include_cor2_changes;
-address bs_address = {AT_NONE, 0, NULL};
+address bs_address = ADDRESS_INIT_NONE;
static int hf_tlv_type = -1;