diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2015-10-29 03:12:53 +0000 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2015-11-03 12:20:34 +0000 |
commit | 3df2333155abf8fdfdedc51aca0fe962499f10b5 (patch) | |
tree | f241cb1777aaf99492eeb12c8365c96e705cfe4e /epan/address.h | |
parent | 8571dbb908e13d63a80e6465ea19566162dad9c1 (diff) |
Remaining ADDRESS macro to address function conversions
Change-Id: I8bc9af431e70243b05f4f0ce8c2b8ee451383788
Reviewed-on: https://code.wireshark.org/review/11463
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/address.h')
-rw-r--r-- | epan/address.h | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/epan/address.h b/epan/address.h index 8e3c9b6019..f0a42c1eee 100644 --- a/epan/address.h +++ b/epan/address.h @@ -26,6 +26,9 @@ #include <string.h> /* for memcmp */ +#include "tvbuff.h" +#include "wmem/wmem.h" + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -72,7 +75,7 @@ typedef struct _address { * @param addr_data [in] Pointer to the address data. */ static inline void -set_address(address *addr, int addr_type, int addr_len, const void * addr_data) { +set_address(address *addr, int addr_type, int addr_len, const void *addr_data) { addr->data = addr_data; addr->type = addr_type; addr->len = addr_len; @@ -93,11 +96,13 @@ set_address(address *addr, int addr_type, int addr_len, const void * addr_data) * @param addr_len [in] The length in bytes of the address data. For example, 4 for * AT_IPv4 or sizeof(struct e_in6_addr) for AT_IPv6. */ -#define TVB_SET_ADDRESS(addr, addr_type, tvb, offset, addr_len) \ - do { \ - const void *TVB_SET_ADDRESS_data = (const void *)tvb_get_ptr(tvb, offset, addr_len); \ - set_address((addr), (addr_type), (addr_len), TVB_SET_ADDRESS_data); \ - } while (0) +static inline void +set_address_tvb(address *addr, int addr_type, int addr_len, tvbuff_t *tvb, int offset) { + const void *p; + + p = tvb_get_ptr(tvb, offset, addr_len); + set_address(addr, addr_type, addr_len, p); +} /** Compare two addresses. * @@ -198,16 +203,17 @@ copy_address_shallow(address *to, const address *from) { * @param to [in,out] The destination address. * @param from [in] The source address. */ -#define WMEM_COPY_ADDRESS(scope, to, from) \ - do { \ - void *WMEM_COPY_ADDRESS_data; \ - copy_address_shallow((to), (from)); \ - WMEM_COPY_ADDRESS_data = wmem_alloc(scope, (from)->len); \ - if ((from)->len != 0) \ - memcpy(WMEM_COPY_ADDRESS_data, (from)->data, (from)->len); \ - (to)->data = WMEM_COPY_ADDRESS_data; \ - } while (0) +static inline void +copy_address_wmem(wmem_allocator_t *scope, address *to, const address *from) { + void *to_data; + to->type = from->type; + to->len = from->len; + to_data = wmem_alloc(scope, from->len); + if (from->len != 0) + memcpy(to_data, from->data, from->len); + to->data = to_data; +} /** Hash an address into a hash value (which must already have been set). * |