"Audio Layer %d", mpa_layer(&mpa) + 1);
if (MPA_BITRATE_VALID(&mpa) && MPA_FREQUENCY_VALID(&mpa)) {
data_size = (int)(MPA_DATA_BYTES(&mpa) - sizeof mpa);
- set_address(&pinfo->src, AT_NONE, 0, NULL);
+ clear_address(&pinfo->src);
col_add_fstr(pinfo->cinfo, COL_DEF_SRC,
"%d kb/s", mpa_bitrate(&mpa) / 1000);
- set_address(&pinfo->dst, AT_NONE, 0, NULL);
+ clear_address(&pinfo->dst);
col_add_fstr(pinfo->cinfo, COL_DEF_DST,
"%g kHz", mpa_frequency(&mpa) / (float)1000);
}
{
return offset;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
{
return offset;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
{
return offset;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
return offset;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
{
return offset;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
}
/* 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);
* 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);
/*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);
}
/* 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",
}
/* 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);
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){
}
/*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,
}
/* 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,
return;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
/*
* Check if the ip address and port combination is not
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 = -1;
+ addr->data = NULL;
+ addr->priv = NULL;
+}
+
/** Initialize an address with the given values.
*
* @param addr [in,out] The address to initialize.
*/
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.
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) {
+ addr->type = addr_type;
+ addr->len = addr_len;
+ 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.
return FALSE;
}
-/** Copy an address, allocating a new buffer for the address data.
+/** 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(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_shallow(address *to, const address *from) {
+ set_address(to, from->type, from->len, from->data);
}
-/** Perform a shallow copy of the address (both addresses point to the same
- * memory location).
+/** 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_shallow(address *to, const address *from) {
- memcpy(to, from, sizeof(address));
- /*
- to->type = from->type;
- to->len = from->len;
- to->data = from->data;
- */
+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
- * using wmem-scoped memory.
+/** Copy an address, allocating a new buffer for the address data.
*
- * @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.
*/
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;
+copy_address(address *to, const address *from) {
+ copy_address_wmem(NULL, to, from);
+}
+
+/** Free an address allocated with wmem-scoped memory.
+ *
+ * @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
+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);
+}
+
+/** Free an address.
+ *
+ * @param addr [in,out] The address whose data to free.
+ */
+static inline void
+free_address(address *addr) {
+ free_address_wmem(NULL, addr);
}
/** Hash an address into a hash value (which must already have been set).
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);
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);
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)) {
{
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);
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;
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;
/*
* 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);
}
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 */
}
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) ) {
((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)
{
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);
}
}
}
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");
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);
}
}
}
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;
* 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. */
#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);
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);
}
/* 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) &&
/* 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 {
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);
}
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);
/* 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)
{
/* 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)
{
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)
{
};
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_)
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;
"Audio Layer %d", mpa_layer(&mpa) + 1);
if (MPA_BITRATE_VALID(&mpa) && MPA_FREQUENCY_VALID(&mpa)) {
data_size = (int)(MPA_DATA_BYTES(&mpa) - sizeof mpa);
- set_address(&pinfo->src, AT_NONE, 0, NULL);
+ clear_address(&pinfo->src);
col_add_fstr(pinfo->cinfo, COL_DEF_SRC,
"%d kb/s", mpa_bitrate(&mpa) / 1000);
- set_address(&pinfo->dst, AT_NONE, 0, NULL);
+ clear_address(&pinfo->dst);
col_add_fstr(pinfo->cinfo, COL_DEF_DST,
"%g kHz", mpa_frequency(&mpa) / (float)1000);
}
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. */
return;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
/*
* Check if the ip address and port combination is not
}
/*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,
}
/* 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);
/*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);
* 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);
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){
}
/* 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",
}
/* 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);
return offset;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
{
return offset;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
{
return offset;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
{
return offset;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
{
return offset;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &transportLayerAddress_ipv4);
}
/* 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,
/* 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);
/* 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);
}
}
/* 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);
/* 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);
}
}
/* 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);
/* 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);
}
}
/* 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);
/* 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);
}
}
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)){
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. */
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,
return;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
/*
* Check if the ip address and port combination is not
return;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
/*
* Check if the ip address and port combination is not
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
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));
}
}
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
{
/* 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;
return;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
/*
* Check if the ip address and port combination is not
/* 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;
return;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
/*
* Check if the ip address and port combination is not
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;
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:
{
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);
{
break;
}
- set_address(&null_addr, AT_NONE, 0, NULL);
+ clear_address(&null_addr);
set_address(&dst_addr, AT_IPv4, 4, &unc_ipv4_address);
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){
set_address_tvb( &addr, AT_IPv6, ip_length, tvb, offset);
break;
default:
- addr.type = AT_NONE;
+ clear_address(&addr);
break;
}
offset += ip_length;
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;
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;
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 {
* 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
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;
}
/*
* 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;
/*
* 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);
}
/*
* 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;
/*
* 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);
}
#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. */
}
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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. */
}
Address addr = toAddress(L,1);
if (addr) {
- g_free((void*)(addr->data));
- g_free((void*)(addr));
+ free_address(addr);
+ g_free(addr);
}
return 0;
}
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;
}
/* 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) {
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. */
/* 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) {
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. */
/* 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) {
}
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. */
/* 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)
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);
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);
/*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)
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;
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. */
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;
/* 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 */
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);
/* 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 */
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);
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);
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;
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);
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;
}
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));
while (details) {
tmp = details;
details = details->next;
- g_free ((void*)tmp->addr.data);
+ free_address(&tmp->addr);
g_free (tmp);
}
}
tmp = list;
dealloc_wlan_details_ep(tmp->details);
list = tmp->next;
- g_free((void*)tmp->bssid.data);
+ free_address(&tmp->bssid);
g_free(tmp);
}
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;
}
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);
}
}
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);
}
}
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);
}
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;
}
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);
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) ) {
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);
}
wmem_free(NULL, tmp_str);
g_free(comment);
- g_free((char *)pstn_add.data);
+ free_address(&pstn_add);
}
tapinfo->redraw |= REDRAW_Q931;
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);
}
/* 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);
}