diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2015-11-26 04:44:52 +0000 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2016-02-07 23:22:30 +0000 |
commit | 13ec77a9fc3af3b0b502820d0b55796c89997896 (patch) | |
tree | c5f5f72f090efd5471cf95095b00e13efa407959 /epan/packet.c | |
parent | d762a895ab570680e4e72142a348ad2b07c97d4f (diff) |
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 'epan/packet.c')
-rw-r--r-- | epan/packet.c | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/epan/packet.c b/epan/packet.c index 90f417006a..16614c4d9c 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -471,12 +471,12 @@ dissect_record(epan_dissect_t *edt, int file_type_subtype, edt->pi.fd = fd; edt->pi.phdr = phdr; edt->pi.pseudo_header = &phdr->pseudo_header; - edt->pi.dl_src.type = AT_NONE; - edt->pi.dl_dst.type = AT_NONE; - edt->pi.net_src.type = AT_NONE; - edt->pi.net_dst.type = AT_NONE; - edt->pi.src.type = AT_NONE; - edt->pi.dst.type = AT_NONE; + clear_address(&edt->pi.dl_src); + clear_address(&edt->pi.dl_dst); + clear_address(&edt->pi.net_src); + clear_address(&edt->pi.net_dst); + clear_address(&edt->pi.src); + clear_address(&edt->pi.dst); edt->pi.ctype = CT_NONE; edt->pi.noreassembly_reason = ""; edt->pi.ptype = PT_NONE; @@ -537,12 +537,12 @@ dissect_file(epan_dissect_t *edt, struct wtap_pkthdr *phdr, edt->pi.fd = fd; edt->pi.phdr = phdr; edt->pi.pseudo_header = &phdr->pseudo_header; - edt->pi.dl_src.type = AT_NONE; - edt->pi.dl_dst.type = AT_NONE; - edt->pi.net_src.type = AT_NONE; - edt->pi.net_dst.type = AT_NONE; - edt->pi.src.type = AT_NONE; - edt->pi.dst.type = AT_NONE; + clear_address(&edt->pi.dl_src); + clear_address(&edt->pi.dl_dst); + clear_address(&edt->pi.net_src); + clear_address(&edt->pi.net_dst); + clear_address(&edt->pi.src); + clear_address(&edt->pi.dst); edt->pi.ctype = CT_NONE; edt->pi.noreassembly_reason = ""; edt->pi.ptype = PT_NONE; @@ -754,12 +754,12 @@ call_dissector_work_error(dissector_handle_t handle, tvbuff_t *tvb, save_writable = col_get_writable(pinfo->cinfo); col_set_writable(pinfo->cinfo, FALSE); - save_dl_src = pinfo->dl_src; - save_dl_dst = pinfo->dl_dst; - save_net_src = pinfo->net_src; - save_net_dst = pinfo->net_dst; - save_src = pinfo->src; - save_dst = pinfo->dst; + copy_address_shallow(&save_dl_src, &pinfo->dl_src); + copy_address_shallow(&save_dl_dst, &pinfo->dl_dst); + copy_address_shallow(&save_net_src, &pinfo->net_src); + copy_address_shallow(&save_net_dst, &pinfo->net_dst); + copy_address_shallow(&save_src, &pinfo->src); + copy_address_shallow(&save_dst, &pinfo->dst); /* Dissect the contained packet. */ TRY { @@ -770,12 +770,12 @@ call_dissector_work_error(dissector_handle_t handle, tvbuff_t *tvb, * Restore the column writability and addresses. */ col_set_writable(pinfo->cinfo, save_writable); - pinfo->dl_src = save_dl_src; - pinfo->dl_dst = save_dl_dst; - pinfo->net_src = save_net_src; - pinfo->net_dst = save_net_dst; - pinfo->src = save_src; - pinfo->dst = save_dst; + copy_address_shallow(&pinfo->dl_src, &save_dl_src); + copy_address_shallow(&pinfo->dl_dst, &save_dl_dst); + copy_address_shallow(&pinfo->net_src, &save_net_src); + copy_address_shallow(&pinfo->net_dst, &save_net_dst); + copy_address_shallow(&pinfo->src, &save_src); + copy_address_shallow(&pinfo->dst, &save_dst); /* * Restore the current protocol, so any @@ -812,12 +812,12 @@ call_dissector_work_error(dissector_handle_t handle, tvbuff_t *tvb, ENDTRY; col_set_writable(pinfo->cinfo, save_writable); - pinfo->dl_src = save_dl_src; - pinfo->dl_dst = save_dl_dst; - pinfo->net_src = save_net_src; - pinfo->net_dst = save_net_dst; - pinfo->src = save_src; - pinfo->dst = save_dst; + copy_address_shallow(&pinfo->dl_src, &save_dl_src); + copy_address_shallow(&pinfo->dl_dst, &save_dl_dst); + copy_address_shallow(&pinfo->net_src, &save_net_src); + copy_address_shallow(&pinfo->net_dst, &save_net_dst); + copy_address_shallow(&pinfo->src, &save_src); + copy_address_shallow(&pinfo->dst, &save_dst); pinfo->want_pdu_tracking = 0; return len; } |