Add free_address_wmem(), fix warnings [-Wcast-qual]

Try to improve address API and also fix some constness warnings
by not overloading the 'data' pointer to store malloc'ed buffers
(use private pointer for that instead).

Second try, now passing test suite.

Change-Id: Idc101cd866b6d4f13500c9d59da5c7a38847fb7f
Reviewed-on: https://code.wireshark.org/review/13946
Petri-Dish: João Valverde <j@v6e.pt>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
This commit is contained in:
João Valverde 2015-11-26 04:44:52 +00:00 committed by João Valverde
parent 9253791648
commit e4c059f67f
56 changed files with 398 additions and 397 deletions

View File

@ -740,7 +740,7 @@ transportFormatSet_type = NBAP_CPCH;
{
return offset;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
@ -833,7 +833,7 @@ num_items = 1;
{
return offset;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
@ -942,7 +942,7 @@ transportFormatSet_type = NBAP_CPCH;
{
return offset;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
@ -1148,7 +1148,7 @@ dch_id = 0xFFFFFFFF;
return offset;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
@ -1256,7 +1256,7 @@ BindingID_port = 0;
{
return offset;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
@ -1365,7 +1365,7 @@ guint32 no_ddi_entries, i;
}
/* Check if we have conversation info */
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
p_conv = find_conversation(actx->pinfo->num, &nbap_edch_channel_info[e_dch_macdflow_id].crnc_address, &null_addr,
PT_UDP,
nbap_edch_channel_info[e_dch_macdflow_id].crnc_port, 0, NO_ADDR_B);
@ -1425,7 +1425,7 @@ BindingID_port = 0;
* Basically the idea here is that we create a new converation (Which is ok? maybe?)
* And then hijack the old conversation and let lower tree items configure that hijacked data.
* */
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
@ -1547,7 +1547,7 @@ num_items = 1;
/*Do the configurations*/
/* Check if we have conversation info */
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
p_conv = find_conversation(actx->pinfo->num, &nbap_edch_channel_info[e_dch_macdflow_id].crnc_address, &null_addr,
PT_UDP,
nbap_edch_channel_info[e_dch_macdflow_id].crnc_port, 0, NO_ADDR_B);
@ -1783,7 +1783,7 @@ nbap_edch_channel_info[e_dch_macdflow_id].no_ddi_entries = num_items;
}
/* Set port to zero use that as an indication of whether we have data or not */
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
for (i = 0; i < maxNrOfMACdFlows; i++) {
if (nbap_hsdsch_channel_info[i].crnc_port != 0){
nbap_debug("Frame %%u HSDSCH-MACdFlows-Information:hsdsch_macdflow_id %%u Look for conv on IP %%s Port %%u",
@ -1896,7 +1896,7 @@ nbap_edch_channel_info[e_dch_macdflow_id].no_ddi_entries = num_items;
}
/* Set port to zero use that as an indication of whether we have data or not */
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
nbap_debug("Frame %%u HSDSCH-MACdFlows-Information Start",
actx->pinfo->num);
@ -2030,7 +2030,7 @@ int i;
return offset;
}
/* Set port to zero use that as an indication of whether we have data or not */
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
for (i = 0; i < maxNrOfCommonMACFlows; i++) {
if (nbap_common_channel_info[i].crnc_port != 0){
@ -2125,7 +2125,7 @@ int i;
}
/*Find the conversations assoicated with the HS-DSCH flows in this packet and set proper H-RNTI*/
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
for (i = 0; i < maxNrOfMACdFlows; i++) {
if (nbap_hsdsch_channel_info[i].crnc_port != 0){
conversation = find_conversation(actx->pinfo->num, &(nbap_hsdsch_channel_info[i].crnc_address), &null_addr,

View File

@ -368,7 +368,7 @@ static void add_hsdsch_bind(packet_info *pinfo){
}
/* Set port to zero use that as an indication of whether we have data or not */
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
for (i = 0; i < maxNrOfMACdFlows; i++) {
if (nbap_hsdsch_channel_info[i].crnc_port != 0){
conversation = find_conversation(pinfo->num, &(nbap_hsdsch_channel_info[i].crnc_address), &null_addr,

View File

@ -229,7 +229,7 @@ void t38_add_address(packet_info *pinfo,
return;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
/*
* Check if the ip address and port combination is not

View File

@ -63,9 +63,24 @@ typedef enum {
typedef struct _address {
int type; /* type of address */
int len; /* length of address, in bytes */
const void *data; /* pointer to address data */
const void *data; /* pointer to address data */
/* private */
void *priv;
} address;
#define ADDRESS_INIT(type, len, data) {type, len, data, NULL}
#define ADDRESS_INIT_NONE ADDRESS_INIT(AT_NONE, 0, NULL)
static inline void
clear_address(address *addr)
{
addr->type = AT_NONE;
addr->len = 0;
addr->data = NULL;
addr->priv = NULL;
}
/** Initialize an address with the given values.
*
* @param addr [in,out] The address to initialize.
@ -76,9 +91,10 @@ typedef struct _address {
*/
static inline void
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;
addr->data = addr_data;
addr->priv = NULL;
}
/** Initialize an address from TVB data.
@ -104,6 +120,52 @@ set_address_tvb(address *addr, int addr_type, int addr_len, tvbuff_t *tvb, int o
set_address(addr, addr_type, addr_len, p);
}
/** Initialize an address with the given values, allocating a new buffer
* for the address data using wmem-scoped memory.
*
* @param scope [in] The lifetime of the allocated memory, e.g., wmem_packet_scope()
* @param addr [in,out] The address to initialize.
* @param addr_type [in] Address type.
* @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.
* @param addr_data [in] Pointer to the address data.
*/
static inline void
alloc_address_wmem(wmem_allocator_t *scope, address *addr,
int addr_type, int addr_len, const void *addr_data) {
if (addr == NULL)
return;
addr->type = addr_type;
addr->len = addr_len;
if (addr_type == AT_NONE || addr->len <= 0) {
addr->data = addr->priv = NULL;
return;
}
addr->priv = wmem_memdup(scope, addr_data, addr->len);
addr->data = addr->priv;
}
/** Allocate an address from TVB data.
*
* Same as alloc_address_wmem but it takes a TVB and an offset.
*
* @param scope [in] The lifetime of the allocated memory, e.g., wmem_packet_scope()
* @param addr [in,out] The address to initialize.
* @param addr_type [in] Address type.
* @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.
* @param tvb [in] Pointer to the TVB.
* @param offset [in] Offset within the TVB.
*/
static inline void
alloc_address_tvb(wmem_allocator_t *scope, address *addr,
int addr_type, int addr_len, tvbuff_t *tvb, int offset) {
const void *p;
p = tvb_get_ptr(tvb, offset, addr_len);
alloc_address_wmem(scope, addr, addr_type, addr_len, p);
}
/** Compare two addresses.
*
* @param addr1 [in] The first address to compare.
@ -163,6 +225,32 @@ addresses_data_equal(const address *addr1, const address *addr2) {
return FALSE;
}
/** Perform a shallow copy of the address (both addresses point to the same
* memory location).
*
* @param to [in,out] The destination address.
* @param from [in] The source address.
*
* \warning Make sure 'from' memory stays valid for the lifetime of this object.
* Also it's strongly recommended to use this function instead of copy-assign.
*/
static inline void
copy_address_shallow(address *to, const address *from) {
set_address(to, from->type, from->len, from->data);
}
/** Copy an address, allocating a new buffer for the address data
* using wmem-scoped memory.
*
* @param scope [in] The lifetime of the allocated memory, e.g., wmem_packet_scope()
* @param to [in,out] The destination address.
* @param from [in] The source address.
*/
static inline void
copy_address_wmem(wmem_allocator_t *scope, address *to, const address *from) {
alloc_address_wmem(scope, to, from->type, from->len, from->data);
}
/** Copy an address, allocating a new buffer for the address data.
*
* @param to [in,out] The destination address.
@ -170,49 +258,33 @@ addresses_data_equal(const address *addr1, const address *addr2) {
*/
static inline void
copy_address(address *to, const address *from) {
guint8 *to_data;
to->type = from->type;
to->len = from->len;
to_data = (guint8 *)g_malloc(from->len);
if (from->len != 0)
memcpy(to_data, from->data, from->len);
to->data = to_data;
copy_address_wmem(NULL, to, from);
}
/** Perform a shallow copy of the address (both addresses point to the same
* memory location).
/** Free an address allocated with wmem-scoped memory.
*
* @param to [in,out] The destination address.
* @param from [in] The source address.
* @param scope [in] The lifetime of the allocated memory, e.g., wmem_packet_scope()
* @param addr [in,out] The address whose data to free.
*/
static inline void
copy_address_shallow(address *to, const address *from) {
memcpy(to, from, sizeof(address));
/*
to->type = from->type;
to->len = from->len;
to->data = from->data;
*/
free_address_wmem(wmem_allocator_t *scope, address *addr) {
/* Because many dissectors set 'type = AT_NONE' to mean clear we check for that */
if (addr->type != AT_NONE && addr->len > 0 && addr->priv != NULL) {
/* Make sure API use is correct */
/* if priv is not null then data == priv */
g_assert(addr->data == addr->priv);
wmem_free(scope, addr->priv);
}
clear_address(addr);
}
/** Copy an address, allocating a new buffer for the address data
* using wmem-scoped memory.
/** Free an address.
*
* @param scope [in] The lifetime of the allocated memory, wmem_packet_scope()
* @param to [in,out] The destination address.
* @param from [in] The source address.
* @param addr [in,out] The address whose data to free.
*/
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;
free_address(address *addr) {
free_address_wmem(NULL, addr);
}
/** Hash an address into a hash value (which must already have been set).

View File

@ -285,8 +285,8 @@ reset_conversation_table_data(conv_hash_t *ch)
guint i;
for(i = 0; i < ch->conv_array->len; i++){
conv_item_t *conv = &g_array_index(ch->conv_array, conv_item_t, i);
g_free((gpointer)conv->src_address.data);
g_free((gpointer)conv->dst_address.data);
free_address(&conv->src_address);
free_address(&conv->dst_address);
}
g_array_free(ch->conv_array, TRUE);
@ -310,7 +310,7 @@ void reset_hostlist_table_data(conv_hash_t *ch)
guint i;
for(i = 0; i < ch->conv_array->len; i++){
hostlist_talker_t *host = &g_array_index(ch->conv_array, hostlist_talker_t, i);
g_free((gpointer)host->myaddress.data);
free_address(&host->myaddress);
}
g_array_free(ch->conv_array, TRUE);
@ -769,7 +769,7 @@ add_hostlist_table_data(conv_hash_t *ch, const address *addr, guint32 port, gboo
host_key_t existing_key;
gpointer talker_idx_hash_val;
existing_key.myaddress = *addr;
copy_address_shallow(&existing_key.myaddress, addr);
existing_key.port = port;
if (g_hash_table_lookup_extended(ch->hashtable, &existing_key, NULL, &talker_idx_hash_val)) {

View File

@ -797,8 +797,8 @@ decode_dcerpc_binding_free(void *binding_in)
{
decode_dcerpc_bind_values_t *binding = (decode_dcerpc_bind_values_t *)binding_in;
g_free((void *) binding->addr_a.data);
g_free((void *) binding->addr_b.data);
free_address(&binding->addr_a);
free_address(&binding->addr_b);
if (binding->ifname)
g_string_free(binding->ifname, TRUE);
g_free(binding);
@ -962,8 +962,8 @@ decode_dcerpc_binding_reset(const char *name _U_, gconstpointer pattern)
decode_dcerpc_bindings = g_slist_remove(decode_dcerpc_bindings, le->data);
g_free((void *) old_binding->addr_a.data);
g_free((void *) old_binding->addr_b.data);
free_address(&old_binding->addr_a);
free_address(&old_binding->addr_b);
g_string_free(old_binding->ifname, TRUE);
g_free(old_binding);
return FALSE;
@ -1082,8 +1082,8 @@ dcerpc_fragment_temporary_key(const packet_info *pinfo, const guint32 id,
dcerpc_fragment_key *key = g_slice_new(dcerpc_fragment_key);
const e_dce_dg_common_hdr_t *hdr = (const e_dce_dg_common_hdr_t *)data;
key->src = pinfo->src;
key->dst = pinfo->dst;
copy_address_shallow(&key->src, &pinfo->src);
copy_address_shallow(&key->dst, &pinfo->dst);
key->id = id;
key->act_id = hdr->act_id;
@ -1124,8 +1124,8 @@ dcerpc_fragment_free_persistent_key(gpointer ptr)
/*
* Free up the copies of the addresses from the old key.
*/
g_free((gpointer)key->src.data);
g_free((gpointer)key->dst.data);
free_address(&key->src);
free_address(&key->dst);
g_slice_free(dcerpc_fragment_key, key);
}

View File

@ -2192,7 +2192,7 @@ static void dcom_cleanup(void) {
objects->data = NULL; /* for good measure */
}
g_list_free(machine->objects);
g_free((void*)machine->ip.data);
free_address(&machine->ip);
machine->objects = NULL; /* for good measure */
}

View File

@ -1676,8 +1676,8 @@ guint8
dvbci_get_evt_from_addrs(packet_info *pinfo)
{
/* this should be working from C89 on */
static const address a_cam = { AT_STRINGZ, sizeof(ADDR_CAM), ADDR_CAM };
static const address a_host = { AT_STRINGZ, sizeof(ADDR_HOST), ADDR_HOST };
static const address a_cam = ADDRESS_INIT(AT_STRINGZ, sizeof(ADDR_CAM), ADDR_CAM);
static const address a_host = ADDRESS_INIT(AT_STRINGZ, sizeof(ADDR_HOST), ADDR_HOST);
if ( addresses_equal(&(pinfo->src), &a_cam) &&
addresses_equal(&(pinfo->dst), &a_host) ) {

View File

@ -1105,14 +1105,14 @@ enip_open_cip_connection( packet_info *pinfo, cip_conn_info_t* connInfo)
((connInfo->O2T.ipaddress.type == AT_IPv4) && ((*(const guint32*)connInfo->O2T.ipaddress.data)) == 0) ||
((connInfo->O2T.ipaddress.type == AT_IPv6) && (memcmp(connInfo->O2T.ipaddress.data, &ipv6_zero, sizeof(ipv6_zero)) == 0)) ||
(connInfo->O2T.type != CONN_TYPE_MULTICAST))
connInfo->O2T.ipaddress = pinfo->src;
copy_address_shallow(&connInfo->O2T.ipaddress, &pinfo->src);
if ((connInfo->T2O.port == 0) || (connInfo->T2O.type == CONN_TYPE_MULTICAST))
connInfo->T2O.port = ENIP_IO_PORT;
if ((connInfo->T2O.ipaddress.type == AT_NONE) ||
((connInfo->T2O.ipaddress.type == AT_IPv4) && ((*(const guint32*)connInfo->T2O.ipaddress.data)) == 0) ||
((connInfo->T2O.ipaddress.type == AT_IPv6) && (memcmp(connInfo->T2O.ipaddress.data, &ipv6_zero, sizeof(ipv6_zero)) == 0)) ||
(connInfo->T2O.type != CONN_TYPE_MULTICAST))
connInfo->T2O.ipaddress = pinfo->dst;
copy_address_shallow(&connInfo->T2O.ipaddress, &pinfo->dst);
if (connInfo->O2T.ipaddress.type == AT_IPv6)
{
@ -2537,24 +2537,17 @@ dissect_cpf(enip_request_key_t *request_key, int command, tvbuff_t *tvb,
request_info = (enip_request_info_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_enip, ENIP_REQUEST_INFO);
if (request_info != NULL)
{
guint16 port;
guint32 *datap;
port = tvb_get_ntohs(tvb, offset+8);
datap = (guint32 *)wmem_alloc(wmem_file_scope(), sizeof(guint32));
*datap = tvb_get_ipv4(tvb, offset+10);
if (item == SOCK_ADR_INFO_OT)
{
request_info->cip_info->connInfo->O2T.port = port;
set_address(&request_info->cip_info->connInfo->O2T.ipaddress,
AT_IPv4, sizeof(guint32), datap);
request_info->cip_info->connInfo->O2T.port = tvb_get_ntohs(tvb, offset+8);
alloc_address_tvb(wmem_file_scope(), &request_info->cip_info->connInfo->O2T.ipaddress,
AT_IPv4, sizeof(guint32), tvb, offset+10);
}
else
{
request_info->cip_info->connInfo->T2O.port = port;
set_address(&request_info->cip_info->connInfo->T2O.ipaddress,
AT_IPv4, sizeof(guint32), datap);
request_info->cip_info->connInfo->T2O.port = tvb_get_ntohs(tvb, offset+8);
alloc_address_tvb(wmem_file_scope(), &request_info->cip_info->connInfo->T2O.ipaddress,
AT_IPv4, sizeof(guint32), tvb, offset+10);
}
}
}

View File

@ -411,10 +411,13 @@ dissect_redirecttlv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint of
gint start_offset;
gint length_meta, length_ilv, length_redirect;
proto_item *ti;
address src_addr = pinfo->src,
src_net_addr = pinfo->net_src,
dst_addr = pinfo->dst,
dst_net_addr = pinfo->net_dst;
address src_addr, src_net_addr;
address dst_addr, dst_net_addr;
copy_address_shallow(&src_addr, &pinfo->src);
copy_address_shallow(&src_net_addr, &pinfo->net_src);
copy_address_shallow(&dst_addr, &pinfo->dst);
copy_address_shallow(&dst_net_addr, &pinfo->net_dst);
meta_data_tree = proto_tree_add_subtree(tree, tvb, offset, TLV_TL_LENGTH,
ett_forces_redirect_tlv_meta_data_tlv, &ti, "Meta Data TLV");
@ -476,10 +479,10 @@ dissect_redirecttlv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint of
call_dissector(ip_handle, next_tvb, pinfo, redirect_data_tree);
/* Restore IP info */
memcpy(&(pinfo->src), &src_addr, sizeof(address));
memcpy(&(pinfo->net_src), &src_net_addr, sizeof(address));
memcpy(&(pinfo->dst), &dst_addr, sizeof(address));
memcpy(&(pinfo->net_dst), &dst_net_addr, sizeof(address));
copy_address_shallow(&pinfo->src, &src_addr);
copy_address_shallow(&pinfo->net_src, &src_net_addr);
copy_address_shallow(&pinfo->dst, &dst_addr);
copy_address_shallow(&pinfo->net_dst, &dst_net_addr);
}
}
}

View File

@ -545,7 +545,7 @@ dissect_ftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
gboolean ftp_nat;
conversation_t *conversation;
ftp_ip_address = pinfo->src;
copy_address_shallow(&ftp_ip_address, &pinfo->src);
if (pinfo->match_uint == pinfo->destport)
is_request = TRUE;

View File

@ -811,12 +811,12 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g
* ADDRESSING FIELDS
*/
/* Clear out the addressing strings. */
set_address(&pinfo->net_dst, AT_NONE, 0, NULL);
copy_address_shallow(&pinfo->dl_dst, &pinfo->net_dst);
copy_address_shallow(&pinfo->dst, &pinfo->net_dst);
set_address(&pinfo->net_src, AT_NONE, 0, NULL);
copy_address_shallow(&pinfo->dl_src, &pinfo->net_src);
copy_address_shallow(&pinfo->src, &pinfo->net_src);
clear_address(&pinfo->net_dst);
clear_address(&pinfo->dl_dst);
clear_address(&pinfo->dst);
clear_address(&pinfo->net_src);
clear_address(&pinfo->dl_src);
clear_address(&pinfo->src);
if (packet->dst_addr_mode == IEEE802154_FCF_ADDR_RESERVED) {
/* Invalid Destination Address Mode. Abort Dissection. */

View File

@ -2878,7 +2878,7 @@ dissect_isakmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
#ifdef HAVE_LIBGCRYPT
if (isakmp_version == 1) {
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
tvb_memcpy(tvb, i_cookie, offset, COOKIE_SIZE);
decr = (decrypt_data_t*) g_hash_table_lookup(isakmp_hash, i_cookie);
@ -2888,7 +2888,7 @@ dissect_isakmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
decr = (decrypt_data_t *)g_slice_alloc(sizeof(decrypt_data_t));
memcpy(ic_key, i_cookie, COOKIE_SIZE);
memset(decr, 0, sizeof(decrypt_data_t));
set_address(&decr->initiator, AT_NONE, 0, NULL);
clear_address(&decr->initiator);
g_hash_table_insert(isakmp_hash, ic_key, decr);
}

View File

@ -692,9 +692,9 @@ static int dissect_jxta_stream(tvbuff_t * tvb, packet_info * pinfo, proto_tree *
/* g_message("%d From initiator : %s -> %s ", pinfo->num,
address_to_str(wmem_packet_scope(), &tpt_conv_data->initiator_address),
address_to_str(wmem_packet_scope(), &tpt_conv_data->receiver_address)); */
pinfo->src = tpt_conv_data->initiator_address;
copy_address_shallow(&pinfo->src, &tpt_conv_data->initiator_address);
pinfo->srcport = 0;
pinfo->dst = tpt_conv_data->receiver_address;
copy_address_shallow(&pinfo->dst, &tpt_conv_data->receiver_address);
pinfo->destport = 0;
pinfo->ptype = PT_NONE;
} else if (addresses_equal(&pinfo->src, &tpt_conv_data->receiver_tpt_address) &&
@ -702,9 +702,9 @@ static int dissect_jxta_stream(tvbuff_t * tvb, packet_info * pinfo, proto_tree *
/* g_message("%d From receiver : %s -> %s ", pinfo->num,
address_to_str(wmem_packet_scope(), &tpt_conv_data->receiver_address),
address_to_str(wmem_packet_scope(), &tpt_conv_data->initiator_address)); */
pinfo->src = tpt_conv_data->receiver_address;
copy_address_shallow(&pinfo->src, &tpt_conv_data->receiver_address);
pinfo->srcport = 0;
pinfo->dst = tpt_conv_data->initiator_address;
copy_address_shallow(&pinfo->dst, &tpt_conv_data->initiator_address);
pinfo->destport = 0;
pinfo->ptype = PT_NONE;
} else {
@ -768,16 +768,12 @@ static jxta_stream_conversation_data *get_tpt_conversation(packet_info * pinfo)
copy_address_wmem(wmem_file_scope(), &tpt_conv_data->initiator_tpt_address, &pinfo->src);
tpt_conv_data->initiator_tpt_port = pinfo->srcport;
tpt_conv_data->initiator_welcome_frame = 0;
tpt_conv_data->initiator_address.type = AT_NONE;
tpt_conv_data->initiator_address.len = 0;
tpt_conv_data->initiator_address.data = NULL;
clear_address(&tpt_conv_data->initiator_address);
copy_address_wmem(wmem_file_scope(), &tpt_conv_data->receiver_tpt_address, &pinfo->dst);
tpt_conv_data->receiver_tpt_port = pinfo->destport;
tpt_conv_data->receiver_welcome_frame = 0;
tpt_conv_data->receiver_address.type = AT_NONE;
tpt_conv_data->receiver_address.len = 0;
tpt_conv_data->receiver_address.data = NULL;
clear_address(&tpt_conv_data->receiver_address);
conversation_add_proto_data(tpt_conversation, proto_jxta, tpt_conv_data);
}
@ -1332,8 +1328,8 @@ static int dissect_jxta_message(tvbuff_t * tvb, packet_info * pinfo, proto_tree
if ((uri_address_type == pinfo->src.type) && (uri_address_type == pinfo->dst.type)) {
jxta_tap_header *tap_header = wmem_new(wmem_file_scope(), jxta_tap_header);
tap_header->src_address = pinfo->src;
tap_header->dest_address = pinfo->dst;
copy_address_shallow(&tap_header->src_address, &pinfo->src);
copy_address_shallow(&tap_header->dest_address, &pinfo->dst);
tap_header->size = offset - message_start_offset ;
tap_queue_packet(jxta_tap, pinfo, tap_header);

View File

@ -52,7 +52,7 @@ static int lbtrm_tap_handle = -1;
/* LBT-RM transport management. */
/*----------------------------------------------------------------------------*/
static const address lbtrm_null_address = { AT_NONE, 0, NULL };
static const address lbtrm_null_address = ADDRESS_INIT_NONE;
static lbtrm_transport_t * lbtrm_transport_unicast_find(const address * source_address, guint16 source_port, guint32 session_id, guint32 frame)
{

View File

@ -49,7 +49,7 @@ static int lbtru_tap_handle = -1;
/* LBT-RU transport management. */
/*----------------------------------------------------------------------------*/
static const address lbtru_null_address = { AT_NONE, 0, NULL };
static const address lbtru_null_address = ADDRESS_INIT_NONE;
static lbtru_transport_t * lbtru_transport_find(const address * source_address, guint16 source_port, guint32 session_id, guint32 frame)
{

View File

@ -51,7 +51,7 @@ typedef struct
wmem_tree_t * session_tree;
} lbttcp_transport_conv_data_t;
static const address lbttcp_null_address = { AT_NONE, 0, NULL };
static const address lbttcp_null_address = ADDRESS_INIT_NONE;
lbttcp_transport_t * lbttcp_transport_find(const address * source_address, guint16 source_port, guint32 session_id, guint32 frame)
{

View File

@ -127,7 +127,7 @@ static const value_string reg_flags_vals[] = {
};
static const guint8 dst_addr[] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x01};
static const address macctrl_dst_address = { AT_ETHER, 6, dst_addr};
static const address macctrl_dst_address = ADDRESS_INIT(AT_ETHER, 6, dst_addr);
static int
dissect_macctrl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)

View File

@ -1127,7 +1127,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree
const gchar *verb_description = "";
char code_with_verb[64] = ""; /* To fit "<4-letter-code> (<longest-verb>)" */
static address null_address = { AT_NONE, 0, NULL };
static address null_address = ADDRESS_INIT_NONE;
tvb_previous_offset = 0;
tvb_len = tvb_reported_length(tvb);
tvb_current_offset = tvb_previous_offset;

View File

@ -1127,7 +1127,7 @@ static void msmms_data_add_address(packet_info *pinfo, address *addr, port_type
return;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
/* Check if the ip address and port combination is not
* already registered as a conversation. */

View File

@ -167,7 +167,7 @@ msrp_add_address( packet_info *pinfo,
return;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
/*
* Check if the ip address and port combination is not

View File

@ -10315,7 +10315,7 @@ int i;
}
/*Find the conversations assoicated with the HS-DSCH flows in this packet and set proper H-RNTI*/
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
for (i = 0; i < maxNrOfMACdFlows; i++) {
if (nbap_hsdsch_channel_info[i].crnc_port != 0){
conversation = find_conversation(actx->pinfo->num, &(nbap_hsdsch_channel_info[i].crnc_address), &null_addr,
@ -18247,7 +18247,7 @@ guint32 no_ddi_entries, i;
}
/* Check if we have conversation info */
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
p_conv = find_conversation(actx->pinfo->num, &nbap_edch_channel_info[e_dch_macdflow_id].crnc_address, &null_addr,
PT_UDP,
nbap_edch_channel_info[e_dch_macdflow_id].crnc_port, 0, NO_ADDR_B);
@ -18542,7 +18542,7 @@ num_items = 1;
/*Do the configurations*/
/* Check if we have conversation info */
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
p_conv = find_conversation(actx->pinfo->num, &nbap_edch_channel_info[e_dch_macdflow_id].crnc_address, &null_addr,
PT_UDP,
nbap_edch_channel_info[e_dch_macdflow_id].crnc_port, 0, NO_ADDR_B);
@ -18654,7 +18654,7 @@ BindingID_port = 0;
* Basically the idea here is that we create a new converation (Which is ok? maybe?)
* And then hijack the old conversation and let lower tree items configure that hijacked data.
* */
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
@ -23362,7 +23362,7 @@ int i;
return offset;
}
/* Set port to zero use that as an indication of whether we have data or not */
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
for (i = 0; i < maxNrOfCommonMACFlows; i++) {
if (nbap_common_channel_info[i].crnc_port != 0){
@ -23807,7 +23807,7 @@ dissect_nbap_HSDSCH_FDD_Information(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_
}
/* Set port to zero use that as an indication of whether we have data or not */
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
for (i = 0; i < maxNrOfMACdFlows; i++) {
if (nbap_hsdsch_channel_info[i].crnc_port != 0){
nbap_debug("Frame %u HSDSCH-MACdFlows-Information:hsdsch_macdflow_id %u Look for conv on IP %s Port %u",
@ -24141,7 +24141,7 @@ dissect_nbap_HSDSCH_Information_to_Modify(tvbuff_t *tvb _U_, int offset _U_, asn
}
/* Set port to zero use that as an indication of whether we have data or not */
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
nbap_debug("Frame %u HSDSCH-MACdFlows-Information Start",
actx->pinfo->num);
@ -28682,7 +28682,7 @@ dch_id = 0xFFFFFFFF;
return offset;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
@ -28820,7 +28820,7 @@ BindingID_port = 0;
{
return offset;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
@ -32389,7 +32389,7 @@ transportFormatSet_type = NBAP_CPCH;
{
return offset;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
@ -32554,7 +32554,7 @@ num_items = 1;
{
return offset;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
@ -32697,7 +32697,7 @@ transportFormatSet_type = NBAP_CPCH;
{
return offset;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
@ -55227,7 +55227,7 @@ static void add_hsdsch_bind(packet_info *pinfo){
}
/* Set port to zero use that as an indication of whether we have data or not */
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
for (i = 0; i < maxNrOfMACdFlows; i++) {
if (nbap_hsdsch_channel_info[i].crnc_port != 0){
conversation = find_conversation(pinfo->num, &(nbap_hsdsch_channel_info[i].crnc_address), &null_addr,

View File

@ -1820,12 +1820,12 @@ dissect_openflow_packet_in_v4(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
/* save some state */
save_writable = col_get_writable(pinfo->cinfo);
save_in_error_pkt = pinfo->flags.in_error_pkt;
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 data */
col_set_writable(pinfo->cinfo, FALSE);
@ -1835,12 +1835,12 @@ dissect_openflow_packet_in_v4(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
/* restore saved state */
col_set_writable(pinfo->cinfo, save_writable);
pinfo->flags.in_error_pkt = save_in_error_pkt;
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);
}
}
@ -2407,12 +2407,12 @@ dissect_openflow_packet_out_v4(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
/* save some state */
save_writable = col_get_writable(pinfo->cinfo);
save_in_error_pkt = pinfo->flags.in_error_pkt;
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 data */
col_set_writable(pinfo->cinfo, FALSE);
@ -2422,12 +2422,12 @@ dissect_openflow_packet_out_v4(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
/* restore saved state */
col_set_writable(pinfo->cinfo, save_writable);
pinfo->flags.in_error_pkt = save_in_error_pkt;
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);
}
}

View File

@ -2050,12 +2050,12 @@ dissect_openflow_packet_in_v5(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
/* save some state */
save_writable = col_get_writable(pinfo->cinfo);
save_in_error_pkt = pinfo->flags.in_error_pkt;
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 data */
col_set_writable(pinfo->cinfo, FALSE);
@ -2065,12 +2065,12 @@ dissect_openflow_packet_in_v5(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
/* restore saved state */
col_set_writable(pinfo->cinfo, save_writable);
pinfo->flags.in_error_pkt = save_in_error_pkt;
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);
}
}
@ -2789,12 +2789,12 @@ dissect_openflow_packet_out_v5(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
/* save some state */
save_writable = col_get_writable(pinfo->cinfo);
save_in_error_pkt = pinfo->flags.in_error_pkt;
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 data */
col_set_writable(pinfo->cinfo, FALSE);
@ -2804,12 +2804,12 @@ dissect_openflow_packet_out_v5(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
/* restore saved state */
col_set_writable(pinfo->cinfo, save_writable);
pinfo->flags.in_error_pkt = save_in_error_pkt;
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);
}
}

View File

@ -1695,7 +1695,7 @@ dissect_radius(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
radius_call_info_key radius_call_key;
radius_call_info_key *new_radius_call_key;
radius_call_t *radius_call = NULL;
static address null_address = { AT_NONE, 0, NULL };
static address null_address = ADDRESS_INIT_NONE;
/* does this look like radius ? */
if(!is_radius(tvb)){

View File

@ -242,7 +242,7 @@ void rdt_add_address(packet_info *pinfo,
return;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
/* Check if the ip address and port combination is not already registered
as a conversation. */

View File

@ -1632,7 +1632,7 @@ dissect_rpc_authgss_priv_data(tvbuff_t *tvb, proto_tree *tree, int offset,
return offset;
}
static address null_address = { AT_NONE, 0, NULL };
static address null_address = ADDRESS_INIT_NONE;
/*
* Attempt to find a conversation for a call and, if we don't find one,

View File

@ -744,7 +744,7 @@ void srtcp_add_address( packet_info *pinfo,
return;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
/*
* Check if the ip address and port combination is not

View File

@ -1154,7 +1154,7 @@ bluetooth_add_address(packet_info *pinfo, address *addr, guint32 stream_number,
return;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
/*
* Check if the ip address and port combination is not
@ -1243,7 +1243,7 @@ srtp_add_address(packet_info *pinfo, address *addr, int port, int other_port,
other_port, setup_method, setup_frame_number));
DINDENT();
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
/*
* Check if the ip address and port combination is not

View File

@ -1856,22 +1856,24 @@ convert_disposable_media(transport_info_t* transport_info, disposable_media_info
if ((media_info->connection_address != NULL) &&
(media_info->connection_type != NULL)) {
if (strcmp(media_info->connection_type, "IP4") == 0) {
transport_info->src_addr[transport_index].data = wmem_alloc(wmem_file_scope(), 4);
if (str_to_ip(media_info->connection_address, (void*)transport_info->src_addr[transport_index].data)) {
guint32 ip4_addr;
if (str_to_ip(media_info->connection_address, &ip4_addr)) {
/* connection_address could be converted to a valid ipv4 address*/
transport_info->proto_bitmask[transport_index] |= SDP_IPv4;
transport_info->src_addr[transport_index].type = AT_IPv4;
transport_info->src_addr[transport_index].len = 4;
alloc_address_wmem(wmem_file_scope(), &transport_info->src_addr[transport_index],
AT_IPv4, 4, &ip4_addr);
DPRINT(("set SDP_IPv4 bitmask=%x, for transport_index=%d",
transport_info->proto_bitmask[transport_index], transport_index));
}
} else if (strcmp(media_info->connection_type, "IP6") == 0) {
transport_info->src_addr[transport_index].data = wmem_alloc(wmem_file_scope(), 16);
if (str_to_ip6(media_info->connection_address, (void*)transport_info->src_addr[transport_index].data)) {
struct e_in6_addr ip6_addr;
if (str_to_ip6(media_info->connection_address, &ip6_addr)) {
/* connection_address could be converted to a valid ipv6 address*/
transport_info->proto_bitmask[transport_index] |= SDP_IPv6;
transport_info->src_addr[transport_index].type = AT_IPv6;
transport_info->src_addr[transport_index].len = 16;
alloc_address_wmem(wmem_file_scope(), &transport_info->src_addr[transport_index],
AT_IPv6, 16, &ip6_addr);
DPRINT(("set SDP_IPv6 bitmask=%x, for transport_index=%d",
transport_info->proto_bitmask[transport_index], transport_index));
}

View File

@ -706,12 +706,12 @@ dissect_sflow_245_sampled_header(tvbuff_t *tvb, packet_info *pinfo,
}
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);
TRY
{
@ -729,13 +729,12 @@ dissect_sflow_245_sampled_header(tvbuff_t *tvb, packet_info *pinfo,
/* restore saved state */
col_set_writable(pinfo->cinfo, save_writable);
pinfo->flags.in_error_pkt = save_in_error_pkt;
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);
offset += header_length;
return offset;

View File

@ -782,7 +782,7 @@ void sprt_add_address(packet_info *pinfo,
return;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
/*
* Check if the ip address and port combination is not

View File

@ -4063,7 +4063,7 @@ ssl_get_session(conversation_t *conversation, dissector_handle_t ssl_handle)
/* Initialize parameters which are not necessary specific to decryption. */
ssl_session->session.version = SSL_VER_UNKNOWN;
set_address(&ssl_session->session.srv_addr, AT_NONE, 0, NULL);
clear_address(&ssl_session->session.srv_addr);
ssl_session->session.srv_ptype = PT_NONE;
ssl_session->session.srv_port = 0;

View File

@ -274,7 +274,7 @@ void t38_add_address(packet_info *pinfo,
return;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
/*
* Check if the ip address and port combination is not

View File

@ -735,7 +735,7 @@ static int dissect_ts2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
switch(type) {
case TS2T_LOGINREQUEST:
conversation_data->server_port=pinfo->destport;
conversation_data->server_addr=pinfo->dst;
copy_address_shallow(&conversation_data->server_addr, &pinfo->dst);
break;
}
break;
@ -783,7 +783,7 @@ static int dissect_ts2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
proto_tree_add_item(ts2_tree, hf_ts2_nick, tvb, 150, 1, ENC_ASCII|ENC_BIG_ENDIAN);
conversation_data->server_port=pinfo->destport;
conversation_data->server_addr=pinfo->dst;
copy_address_shallow(&conversation_data->server_addr, &pinfo->dst);
break;
case TS2T_LOGINREPLY:

View File

@ -1479,7 +1479,7 @@ dissect_uma_IE(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
break;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &GPRS_user_data_ipv4_address);
@ -1511,7 +1511,7 @@ dissect_uma_IE(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
break;
}
set_address(&null_addr, AT_NONE, 0, NULL);
clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &unc_ipv4_address);
@ -1541,7 +1541,7 @@ dissect_uma_IE(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
set_address(&src_addr, AT_IPv4, 4, &unc_ipv4_address);
}else{
/* Set Source IP = own IP */
src_addr = pinfo->src;
copy_address_shallow(&src_addr, &pinfo->src);
}
if((!pinfo->fd->flags.visited) && RTP_UDP_port!=0){

View File

@ -346,7 +346,7 @@ dissect_vuze_dht_address(tvbuff_t *tvb, packet_info _U_*pinfo, proto_tree *tree,
set_address_tvb( &addr, AT_IPv6, ip_length, tvb, offset);
break;
default:
addr.type = AT_NONE;
clear_address(&addr);
break;
}
offset += ip_length;

View File

@ -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;
}

View File

@ -97,8 +97,8 @@ fragment_addresses_temporary_key(const packet_info *pinfo, const guint32 id,
/*
* Do a shallow copy of the addresses.
*/
key->src = pinfo->src;
key->dst = pinfo->dst;
copy_address_shallow(&key->src, &pinfo->src);
copy_address_shallow(&key->dst, &pinfo->dst);
key->id = id;
return (gpointer)key;
@ -142,8 +142,8 @@ fragment_addresses_free_persistent_key(gpointer ptr)
/*
* Free up the copies of the addresses from the old key.
*/
g_free((gpointer)key->src.data);
g_free((gpointer)key->dst.data);
free_address(&key->src);
free_address(&key->dst);
g_slice_free(fragment_addresses_key, key);
}
@ -231,8 +231,8 @@ fragment_addresses_ports_temporary_key(const packet_info *pinfo, const guint32 i
/*
* Do a shallow copy of the addresses.
*/
key->src_addr = pinfo->src;
key->dst_addr = pinfo->dst;
copy_address_shallow(&key->src_addr, &pinfo->src);
copy_address_shallow(&key->dst_addr, &pinfo->dst);
key->src_port = pinfo->srcport;
key->dst_port = pinfo->destport;
key->id = id;
@ -280,8 +280,8 @@ fragment_addresses_ports_free_persistent_key(gpointer ptr)
/*
* Free up the copies of the addresses from the old key.
*/
g_free((gpointer)key->src_addr.data);
g_free((gpointer)key->dst_addr.data);
free_address(&key->src_addr);
free_address(&key->dst_addr);
g_slice_free(fragment_addresses_ports_key, key);
}

View File

@ -43,14 +43,14 @@ WSLUA_CONSTRUCTOR Address_ip(lua_State* L) {
#define WSLUA_ARG_Address_ip_HOSTNAME 1 /* The address or name of the IP host. */
Address addr = (Address)g_malloc(sizeof(address));
guint32* ip_addr = (guint32 *)g_malloc(sizeof(guint32));
guint32 ip_addr;
const gchar* name = luaL_checkstring(L,WSLUA_ARG_Address_ip_HOSTNAME);
if (! get_host_ipaddr(name, (guint32*)ip_addr)) {
*ip_addr = 0;
if (! get_host_ipaddr(name, &ip_addr)) {
ip_addr = 0;
}
set_address(addr, AT_IPv4, 4, ip_addr);
alloc_address_wmem(NULL, addr, AT_IPv4, 4, &ip_addr);
pushAddress(L,addr);
WSLUA_RETURN(1); /* The Address object. */
}
@ -60,7 +60,7 @@ WSLUA_CONSTRUCTOR Address_ip(lua_State* L) {
static int Address_ipv6(lua_State* L) {
Address addr = g_malloc(sizeof(address));
set_address(addr, AT_NONE, 4, g_malloc(4));
/* alloc_address() */
pushAddress(L,addr);
return 1;
@ -68,7 +68,7 @@ static int Address_ipv6(lua_State* L) {
static int Address_ss7(lua_State* L) {
Address addr = g_malloc(sizeof(address));
set_address(addr, AT_NONE, 4, g_malloc(4));
/* alloc_address() */
pushAddress(L,addr);
return 1;
@ -76,7 +76,7 @@ static int Address_ss7(lua_State* L) {
static int Address_eth(lua_State* L) {
Address addr = g_malloc(sizeof(address));
set_address(addr, AT_NONE, 4, g_malloc(4));
/* alloc_address() */
pushAddress(L,addr);
return 1;
@ -84,7 +84,7 @@ static int Address_eth(lua_State* L) {
static int Address_sna(lua_State* L) {
Address addr = g_malloc(sizeof(address));
set_address(addr, AT_NONE, 4, g_malloc(4));
/* alloc_address() */
pushAddress(L,addr);
return 1;
@ -92,7 +92,7 @@ static int Address_sna(lua_State* L) {
static int Address_atalk(lua_State* L) {
Address addr = g_malloc(sizeof(address));
set_address(addr, AT_NONE, 4, g_malloc(4));
/* alloc_address() */
pushAddress(L,addr);
return 1;
@ -100,7 +100,7 @@ static int Address_atalk(lua_State* L) {
static int Address_vines(lua_State* L) {
Address addr = g_malloc(sizeof(address));
set_address(addr, AT_NONE, 4, g_malloc(4));
/* alloc_address() */
pushAddress(L,addr);
return 1;
@ -108,7 +108,7 @@ static int Address_vines(lua_State* L) {
static int Address_osi(lua_State* L) {
Address addr = g_malloc(sizeof(address));
set_address(addr, AT_NONE, 4, g_malloc(4));
/* alloc_address() */
pushAddress(L,addr);
return 1;
@ -116,7 +116,7 @@ static int Address_osi(lua_State* L) {
static int Address_arcnet(lua_State* L) {
Address addr = g_malloc(sizeof(address));
set_address(addr, AT_NONE, 4, g_malloc(4));
/* alloc_address() */
pushAddress(L,addr);
return 1;
@ -124,7 +124,7 @@ static int Address_arcnet(lua_State* L) {
static int Address_fc(lua_State* L) {
Address addr = g_malloc(sizeof(address));
set_address(addr, AT_NONE, 4, g_malloc(4));
/* alloc_address() */
pushAddress(L,addr);
return 1;
@ -132,7 +132,7 @@ static int Address_fc(lua_State* L) {
static int Address_string(lua_State* L) {
Address addr = g_malloc(sizeof(address));
set_address(addr, AT_NONE, 4, g_malloc(4));
/* alloc_address() */
pushAddress(L,addr);
return 1;
@ -140,7 +140,7 @@ static int Address_string(lua_State* L) {
static int Address_eui64(lua_State* L) {
Address addr = g_malloc(sizeof(address));
set_address(addr, AT_NONE, 4, g_malloc(4));
/* alloc_address() */
pushAddress(L,addr);
return 1;
@ -148,7 +148,7 @@ static int Address_eui64(lua_State* L) {
static int Address_uri(lua_State* L) {
Address addr = g_malloc(sizeof(address));
set_address(addr, AT_NONE, 4, g_malloc(4));
/* alloc_address() */
pushAddress(L,addr);
return 1;
@ -156,7 +156,7 @@ static int Address_uri(lua_State* L) {
static int Address_tipc(lua_State* L) {
Address addr = g_malloc(sizeof(address));
set_address(addr, AT_NONE, 4, g_malloc(4));
/* alloc_address() */
pushAddress(L,addr);
return 1;
@ -186,11 +186,11 @@ WSLUA_METHODS Address_methods[] = {
WSLUA_METAMETHOD Address__tostring(lua_State* L) {
Address addr = checkAddress(L,1);
const gchar *str = address_to_display(NULL, addr);
gchar *str = address_to_display(NULL, addr);
lua_pushstring(L, str);
wmem_free(NULL, (void*) str);
wmem_free(NULL, str);
WSLUA_RETURN(1); /* The string representing the address. */
}
@ -200,8 +200,8 @@ static int Address__gc(lua_State* L) {
Address addr = toAddress(L,1);
if (addr) {
g_free((void*)(addr->data));
g_free((void*)(addr));
free_address(addr);
g_free(addr);
}
return 0;

View File

@ -124,41 +124,31 @@ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) {
}
case FT_ETHER: {
Address eth = (Address)g_malloc(sizeof(address));
eth->type = AT_ETHER;
eth->len = fi->ws_fi->length;
eth->data = tvb_memdup(NULL,fi->ws_fi->ds_tvb,fi->ws_fi->start,fi->ws_fi->length);
alloc_address_tvb(NULL,eth,AT_ETHER,fi->ws_fi->length,fi->ws_fi->ds_tvb,fi->ws_fi->start);
pushAddress(L,eth);
return 1;
}
case FT_IPv4:{
Address ipv4 = (Address)g_malloc(sizeof(address));
ipv4->type = AT_IPv4;
ipv4->len = fi->ws_fi->length;
ipv4->data = tvb_memdup(NULL,fi->ws_fi->ds_tvb,fi->ws_fi->start,fi->ws_fi->length);
alloc_address_tvb(NULL,ipv4,AT_IPv4,fi->ws_fi->length,fi->ws_fi->ds_tvb,fi->ws_fi->start);
pushAddress(L,ipv4);
return 1;
}
case FT_IPv6: {
Address ipv6 = (Address)g_malloc(sizeof(address));
ipv6->type = AT_IPv6;
ipv6->len = fi->ws_fi->length;
ipv6->data = tvb_memdup(NULL,fi->ws_fi->ds_tvb,fi->ws_fi->start,fi->ws_fi->length);
alloc_address_tvb(NULL,ipv6,AT_IPv6,fi->ws_fi->length,fi->ws_fi->ds_tvb,fi->ws_fi->start);
pushAddress(L,ipv6);
return 1;
}
case FT_FCWWN: {
Address fcwwn = (Address)g_malloc(sizeof(address));
fcwwn->type = AT_FCWWN;
fcwwn->len = fi->ws_fi->length;
fcwwn->data = tvb_memdup(NULL,fi->ws_fi->ds_tvb,fi->ws_fi->start,fi->ws_fi->length);
alloc_address_tvb(NULL,fcwwn,AT_FCWWN,fi->ws_fi->length,fi->ws_fi->ds_tvb,fi->ws_fi->start);
pushAddress(L,fcwwn);
return 1;
}
case FT_IPXNET:{
Address ipx = (Address)g_malloc(sizeof(address));
ipx->type = AT_IPX;
ipx->len = fi->ws_fi->length;
ipx->data = tvb_memdup(NULL,fi->ws_fi->ds_tvb,fi->ws_fi->start,fi->ws_fi->length);
alloc_address_tvb(NULL,ipx,AT_IPX,fi->ws_fi->length,fi->ws_fi->ds_tvb,fi->ws_fi->start);
pushAddress(L,ipx);
return 1;
}

View File

@ -751,7 +751,6 @@ WSLUA_METHOD TvbRange_ipv4(lua_State* L) {
/* Get an IPv4 Address from a `TvbRange`, as an `Address` object. */
TvbRange tvbr = checkTvbRange(L,1);
Address addr;
guint32* ip_addr;
if ( !(tvbr && tvbr->tvb)) return 0;
if (tvbr->tvb->expired) {
@ -764,12 +763,8 @@ WSLUA_METHOD TvbRange_ipv4(lua_State* L) {
return 0;
}
addr = (address *)g_malloc(sizeof(address));
ip_addr = (guint32 *)g_malloc(sizeof(guint32));
*ip_addr = tvb_get_ipv4(tvbr->tvb->ws_tvb,tvbr->offset);
set_address(addr, AT_IPv4, 4, ip_addr);
addr = g_new(address,1);
alloc_address_tvb(NULL,addr,AT_IPv4,sizeof(guint32),tvbr->tvb->ws_tvb,tvbr->offset);
pushAddress(L,addr);
WSLUA_RETURN(1); /* The IPv4 `Address` object. */
@ -779,7 +774,7 @@ WSLUA_METHOD TvbRange_le_ipv4(lua_State* L) {
/* Get an Little Endian IPv4 Address from a `TvbRange`, as an `Address` object. */
TvbRange tvbr = checkTvbRange(L,1);
Address addr;
guint32* ip_addr;
guint32 ip_addr;
if ( !(tvbr && tvbr->tvb)) return 0;
if (tvbr->tvb->expired) {
@ -792,13 +787,9 @@ WSLUA_METHOD TvbRange_le_ipv4(lua_State* L) {
return 0;
}
addr = (address *)g_malloc(sizeof(address));
ip_addr = (guint32 *)g_malloc(sizeof(guint32));
*ip_addr = tvb_get_ipv4(tvbr->tvb->ws_tvb,tvbr->offset);
*((guint32 *)ip_addr) = GUINT32_SWAP_LE_BE(*((guint32 *)ip_addr));
set_address(addr, AT_IPv4, 4, ip_addr);
addr = g_new(address,1);
ip_addr = GUINT32_SWAP_LE_BE(tvb_get_ipv4(tvbr->tvb->ws_tvb,tvbr->offset));
alloc_address_wmem(NULL, addr, AT_IPv4, sizeof(ip_addr), &ip_addr);
pushAddress(L,addr);
WSLUA_RETURN(1); /* The IPv4 `Address` object. */
@ -808,7 +799,6 @@ WSLUA_METHOD TvbRange_ether(lua_State* L) {
/* Get an Ethernet Address from a `TvbRange`, as an `Address` object. */
TvbRange tvbr = checkTvbRange(L,1);
Address addr;
guint8* buff;
if ( !(tvbr && tvbr->tvb)) return 0;
if (tvbr->tvb->expired) {
@ -822,10 +812,7 @@ WSLUA_METHOD TvbRange_ether(lua_State* L) {
}
addr = g_new(address,1);
buff = (guint8 *)tvb_memdup(NULL,tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len);
set_address(addr, AT_ETHER, 6, buff);
alloc_address_tvb(NULL,addr,AT_ETHER,6,tvbr->tvb->ws_tvb,tvbr->offset);
pushAddress(L,addr);
WSLUA_RETURN(1); /* The Ethernet `Address` object. */

View File

@ -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;
set_address(&srcaddr, AT_NONE, 1, &circuit_id);
dest = circuit_id ^ CMD_FRAME;
destaddr.type = AT_NONE;
destaddr.len = 1;
destaddr.data = (guint8*)&dest;
set_address(&destaddr, AT_NONE, 1, &dest);
conv = find_conversation(pinfo->num, &destaddr, &srcaddr, PT_NONE, dlsap, 0, NO_PORT_B);
if (conv)

View File

@ -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;

View File

@ -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. */

View File

@ -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;

View File

@ -119,8 +119,8 @@ comparestat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const
/* so this get filled, usually with the first frame */
if (cs->eth_dst.len == 0) {
cs->eth_dst = pinfo->dl_dst;
cs->eth_src = pinfo->dl_src;
copy_address_shallow(&cs->eth_dst, &pinfo->dl_dst);
copy_address_shallow(&cs->eth_src, &pinfo->dl_src);
}
/* Set up the fields of the pseudo-header and create checksum */
@ -145,7 +145,7 @@ comparestat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const
fInfo->num = pinfo->num;
fInfo->id = ci->ip_id;
fInfo->ip_ttl = ci->ip_ttl;
fInfo->dl_dst = pinfo->dl_dst;
copy_address_shallow(&fInfo->dl_dst, &pinfo->dl_dst);
fInfo->abs_ts = pinfo->abs_ts;
/* clean memory */
nstime_set_zero(&fInfo->zebra_time);

View File

@ -180,8 +180,8 @@ comparestat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const
/* so this get filled, usually with the first frame */
if(cs->eth_dst.len==0) {
cs->eth_dst=pinfo->dl_dst;
cs->eth_src=pinfo->dl_src;
copy_address_shallow(&cs->eth_dst, &pinfo->dl_dst);
copy_address_shallow(&cs->eth_src, &pinfo->dl_src);
}
/* Set up the fields of the pseudo-header and create checksum */
@ -212,7 +212,7 @@ comparestat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const
fInfo->num=pinfo->num;
fInfo->id=ci->ip_id;
fInfo->ip_ttl=ci->ip_ttl;
fInfo->dl_dst=pinfo->dl_dst;
copy_address_shallow(&fInfo->dl_dst, &pinfo->dl_dst);
fInfo->abs_ts=pinfo->abs_ts;
/* clean memory */
nstime_set_zero(&fInfo->zebra_time);

View File

@ -1055,7 +1055,7 @@ follow_destroy_cb(GtkWidget *w, gpointer data _U_)
g_list_free(follow_info->payload);
g_free(follow_info->filter_out_filter);
g_free((gpointer)follow_info->client_ip.data);
free_address(&follow_info->client_ip);
forget_follow_info(follow_info);
g_free(gtk_follow_info);
g_free(follow_info);

View File

@ -86,10 +86,7 @@ static void graph_analysis_reset(graph_analysis_data_t *user_data)
user_data->graph_info->num_nodes = 0;
user_data->num_items = 0;
for (i=0; i<MAX_NUM_NODES; i++) {
user_data->graph_info->nodes[i].type = AT_NONE;
user_data->graph_info->nodes[i].len = 0;
g_free((void *)user_data->graph_info->nodes[i].data);
user_data->graph_info->nodes[i].data = NULL;
free_address(&user_data->graph_info->nodes[i]);
}
user_data->dlg.first_node = 0;
@ -157,10 +154,7 @@ static void on_destroy(GtkWidget *win _U_, graph_analysis_data_t *user_data)
int i;
for (i=0; i<MAX_NUM_NODES; i++) {
user_data->graph_info->nodes[i].type = AT_NONE;
user_data->graph_info->nodes[i].len = 0;
g_free((void *)user_data->graph_info->nodes[i].data);
user_data->graph_info->nodes[i].data = NULL;
free_address(&user_data->graph_info->nodes[i]);
}
user_data->dlg.window = NULL;
g_free(user_data->dlg.title);

View File

@ -254,8 +254,8 @@ rtp_stream_value_destroy(gpointer rsi_arg)
rtp_packet_list = g_list_next(rtp_packet_list);
}
g_free((void *)(rsi->src_addr.data));
g_free((void *)(rsi->dest_addr.data));
free_address(&rsi->src_addr);
free_address(&rsi->dest_addr);
g_free(rsi);
rsi = NULL;
}

View File

@ -516,10 +516,10 @@ rtpstream_on_analyse(GtkButton *button _U_, gpointer user_data _U_)
return;
}
set_address(&src_fwd,AT_NONE,0,NULL);
set_address(&dst_fwd,AT_NONE,0,NULL);
set_address(&src_rev,AT_NONE,0,NULL);
set_address(&dst_rev,AT_NONE,0,NULL);
clear_address(&src_fwd);
clear_address(&dst_fwd);
clear_address(&src_rev);
clear_address(&dst_rev);
if (selected_stream_fwd) {
copy_address(&(src_fwd), &(selected_stream_fwd->src_addr));

View File

@ -146,7 +146,7 @@ dealloc_wlan_details_ep (wlan_details_ep_t *details)
while (details) {
tmp = details;
details = details->next;
g_free ((void*)tmp->addr.data);
free_address(&tmp->addr);
g_free (tmp);
}
}
@ -206,7 +206,7 @@ wlanstat_reset (void *phs)
tmp = list;
dealloc_wlan_details_ep(tmp->details);
list = tmp->next;
g_free((void*)tmp->bssid.data);
free_address(&tmp->bssid);
g_free(tmp);
}
@ -462,7 +462,7 @@ wlanstat_packet (void *phs, packet_info *pinfo, epan_dissect_t *edt _U_, const v
if (tmp->iter_valid) {
gtk_list_store_remove(store, &tmp->iter);
}
g_free((void*)tmp->bssid.data);
free_address(&tmp->bssid);
g_free(tmp);
break;
}

View File

@ -548,23 +548,17 @@ packet(void *tapdata _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const voi
info->arwnd1 = tvb_get_ntohl(sctp_info->tvb[0], INIT_CHUNK_ADV_REC_WINDOW_CREDIT_OFFSET);
for (chunk_number = 1; chunk_number < sctp_info->number_of_tvbs; chunk_number++)
{
type = tvb_get_ntohs(sctp_info->tvb[chunk_number],0);
type = tvb_get_ntohs(sctp_info->tvb[chunk_number],0);
if (type == IPV4ADDRESS_PARAMETER_ID)
{
store = (address *)g_malloc(sizeof (address));
store->type = AT_IPv4;
store->len = 4;
store->data = g_malloc(4);
tvb_memcpy(sctp_info->tvb[chunk_number], (void *)store->data,IPV4_ADDRESS_OFFSET, 4);
alloc_address_tvb(NULL, store, AT_IPv4, 4, sctp_info->tvb[chunk_number], IPV4_ADDRESS_OFFSET);
info = add_address(store, info, 1);
}
else if (type == IPV6ADDRESS_PARAMETER_ID)
{
store = (address *)g_malloc(sizeof (address));
store->type = AT_IPv6;
store->len = 16;
store->data = g_malloc(16);
tvb_memcpy(sctp_info->tvb[chunk_number], (guint8 *)(store->data),IPV6_ADDRESS_OFFSET, IPV6_ADDRESS_LENGTH);
alloc_address_tvb(NULL, store, AT_IPv6, 16, sctp_info->tvb[chunk_number], IPV6_ADDRESS_OFFSET);
info = add_address(store, info, 1);
}
}
@ -923,19 +917,13 @@ packet(void *tapdata _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const voi
if (type == IPV4ADDRESS_PARAMETER_ID)
{
store = (address *)g_malloc(sizeof (address));
store->type = AT_IPv4;
store->len = 4;
store->data = g_malloc(4);
tvb_memcpy(sctp_info->tvb[chunk_number], (guint8 *)(store->data),IPV4_ADDRESS_OFFSET, 4);
alloc_address_tvb(NULL, store, AT_IPv4, 4, sctp_info->tvb[chunk_number], IPV4_ADDRESS_OFFSET);
info = add_address(store, info, info->direction);
}
else if (type == IPV6ADDRESS_PARAMETER_ID)
{
store = (address *)g_malloc(sizeof (address));
store->type = AT_IPv6;
store->len = 16;
store->data = g_malloc(16);
tvb_memcpy(sctp_info->tvb[chunk_number], (guint8 *)(store->data),IPV6_ADDRESS_OFFSET, IPV6_ADDRESS_LENGTH);
alloc_address_tvb(NULL, store, AT_IPv6, 16, sctp_info->tvb[chunk_number], IPV6_ADDRESS_OFFSET);
info = add_address(store, info, info->direction);
}
}

View File

@ -299,8 +299,8 @@ static void sequence_analysis_item_free(gpointer data)
g_free(seq_item->time_str);
g_free(seq_item->comment);
g_free(seq_item->protocol);
g_free((void *)seq_item->src_addr.data);
g_free((void *)seq_item->dst_addr.data);
free_address(&seq_item->src_addr);
free_address(&seq_item->dst_addr);
g_free(data);
}
@ -360,10 +360,7 @@ sequence_analysis_list_free(seq_analysis_info_t *sainfo)
sainfo->nconv = 0;
for (i=0; i<MAX_NUM_NODES; i++) {
sainfo->nodes[i].type = AT_NONE;
sainfo->nodes[i].len = 0;
g_free((void *)sainfo->nodes[i].data);
sainfo->nodes[i].data = NULL;
free_address(&sainfo->nodes[i]);
}
sainfo->num_nodes = 0;
}

View File

@ -280,7 +280,7 @@ voip_calls_reset_all_taps(voip_calls_tapinfo_t *tapinfo)
g_free(callsinfo->call_id);
g_free(callsinfo->from_identity);
g_free(callsinfo->to_identity);
g_free((void *)(callsinfo->initial_speaker.data));
free_address(&callsinfo->initial_speaker);
g_free(callsinfo->protocol_name);
g_free(callsinfo->call_comment);
@ -1227,8 +1227,8 @@ TODO: is useful but not perfect, what is appended is truncated when displayed in
add_to_graph(tapinfo, pinfo, edt, frame_label, comment, callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1);
g_free(comment);
g_free(frame_label);
g_free((void *)tmp_src.data);
g_free((void *)tmp_dst.data);
free_address(&tmp_src);
free_address(&tmp_dst);
/* add SDP info if apply */
if ( (tapinfo->sdp_summary != NULL) && (tapinfo->sdp_frame_num == pinfo->num) ) {
@ -1663,7 +1663,7 @@ q931_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt,
while (list2)
{
h245_add=(h245_address_t *)list2->data;
g_free((void *)h245_add->h245_address.data);
free_address(&h245_add->h245_address);
g_free(list2->data);
list2 = g_list_next(list2);
}
@ -1822,7 +1822,7 @@ q931_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt,
wmem_free(NULL, tmp_str);
g_free(comment);
g_free((char *)pstn_add.data);
free_address(&pstn_add);
}
tapinfo->redraw |= REDRAW_Q931;
@ -1895,7 +1895,7 @@ free_h225_info(gpointer p) {
while (list2)
{
h245_address_t *h245_add=(h245_address_t *)list2->data;
g_free((void *)h245_add->h245_address.data);
free_address(&h245_add->h245_address);
g_free(list2->data);
list2 = g_list_next(list2);
}
@ -2026,10 +2026,7 @@ h225_calls_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt,
/* this is still IPv4 only, because the dissector is */
if (pi->is_h245 == TRUE) {
h245_add = (h245_address_t *)g_malloc(sizeof (h245_address_t));
h245_add->h245_address.type=AT_IPv4;
h245_add->h245_address.len=4;
h245_add->h245_address.data = g_malloc(sizeof(pi->h245_address));
memcpy((void *)(h245_add->h245_address.data), &(pi->h245_address), 4);
alloc_address_wmem(NULL, &h245_add->h245_address, AT_IPv4, 4, &pi->h245_address);
h245_add->h245_port = pi->h245_port;
add_h245_Address(tmp_h323info, h245_add);
}