void ims_information_free(ims_information_t *x) { if (!x) return; event_type_free(x->event_type); mem_free(x->role_of_node, pkg); str_free_ptr(x->user_session_id, pkg); str_free_ptr(x->outgoing_session_id, pkg); WL_FREE_ALL(&(x->calling_party_address), str_list_t, pkg); str_free_ptr(x->called_party_address, pkg); WL_FREE_ALL(&(x->called_asserted_identity), str_list_t, pkg); str_free_ptr(x->requested_party_address, pkg); str_free_ptr(x->trunk_id, pkg); time_stamps_free(x->time_stamps); WL_FREE_ALL(&(x->as_info), as_info_list_t, pkg); WL_FREE_ALL(&(x->ioi), ioi_list_t, pkg); str_free_ptr(x->icid, pkg); str_free_ptr(x->service_id, pkg); WL_FREE_ALL(&(x->service_specific_info), service_specific_info_list_t, pkg); mem_free(x->cause_code, pkg); mem_free(x, pkg); }
void service_information_free(service_information_t *x) { if (!x) return; WL_FREE_ALL(&(x->subscription_id), subscription_id_list_t, pkg); ims_information_free(x->ims_information); mem_free(x, pkg); }
/** * create the sdp media component information * @param req - the SIP request * @param reply - the SIP reply, possibly null * @param from_uri - the From URI of the request * @param to_uri - the To URI of the request * @param sdp_media_comps - the returned structure * @returns 1 if ok, 0 if an error occurs */ int get_sdp_media_comp(struct sip_msg* req, struct sip_msg * reply, str from_uri, str to_uri, str user_sip_uri, sdp_media_component_list_t * sdp_media_comps){ if(req && !(append_sip_sdp_comp(req, 0, from_uri, user_sip_uri, sdp_media_comps))) goto error; if(reply && !(append_sip_sdp_comp(reply, 1, to_uri, user_sip_uri, sdp_media_comps))) goto error; return 1; error: WL_FREE_ALL(sdp_media_comps, sdp_media_component_list_t, pkg); return 0; }
Rf_ACR_t * create_rf_data(struct sip_msg * req, struct sip_msg * reply, int dir, int interim){ Rf_ACR_t * rf_data=0; str user_name ={0,0}, sip_method = {0,0}, event = {0,0}; uint32_t expires = 0; str callid = {0,0}, to_uri = {0,0}, from_uri ={0,0}, icid= {0,0}, orig_ioi = {0,0}, term_ioi = {0,0}; uint32_t rating_group = 0; event_type_t * event_type = 0; ims_information_t * ims_info = 0; time_stamps_t * time_stamps = 0; time_t req_timestamp=0, reply_timestamp=0; int32_t acct_record_type; uint32_t acct_record_number; subscription_id_t subscr; sdp_media_component_list_t sdp_media_comps = {0,0}; service_data_container_t * serv_data_container = NULL; ps_information_t * ps_info = NULL; uint32_t an_charg_id; if(!get_sip_header_info(req, reply, interim, &acct_record_type, &sip_method, &event, &expires, &callid, &from_uri, &to_uri)) goto error; if(dir == 0) user_name = from_uri; else user_name = to_uri; if(!get_subseq_acct_record_nb(callid, user_name, acct_record_type, &acct_record_number, &dir, expires)){ LOG(L_ERR, "ERR:"M_NAME":create_rf_data: could not retrieve " "accounting record number for session id %.*s, maybe already ended and this is a retransmission\n", callid.len, callid.s); goto error; } if(!get_ims_charging_info(req, reply, dir, &icid, &orig_ioi, &term_ioi, &rating_group)) goto error; LOG(L_DBG, "retrieved ims charging info icid %.*s orig_ioi %.*s term_ioi %.*s\n", icid.len, icid.s, orig_ioi.len, orig_ioi.s, term_ioi.len, term_ioi.s); if(!get_timestamps(req, reply, &req_timestamp, &reply_timestamp)) goto error; if(!get_sdp_media_comp(req, reply, from_uri, to_uri, user_name, &sdp_media_comps)) goto error; if(!(event_type = new_event_type(&sip_method, &event, &expires))) goto error; if(!(time_stamps = new_time_stamps(&req_timestamp, NULL, &reply_timestamp, NULL))) goto error; if(!(ims_info = new_ims_information(event_type, time_stamps, &callid, &callid, &from_uri, &to_uri, &icid, &orig_ioi, &term_ioi,dir))) goto error; if(rating_group){ if(!(serv_data_container = new_service_data_container(rating_group))) goto out_of_memory; } an_charg_id = get_an_charg_info(user_name); if(serv_data_container || an_charg_id) if(!(ps_info = new_ps_information(an_charg_id, serv_data_container))) goto out_of_memory; ims_info->sdp_media_component.head = sdp_media_comps.head; ims_info->sdp_media_component.tail = sdp_media_comps.tail; str_free(icid, pkg); sdp_media_comps.head = sdp_media_comps.tail = 0; event_type = 0; time_stamps = 0; subscr.type = Subscription_Type_IMPU; subscr.id.s = from_uri.s; subscr.id.len = from_uri.len; rf_data = new_Rf_ACR(acct_record_type, acct_record_number, &user_name, ims_info, ps_info, &subscr); if(!rf_data) { LOG(L_ERR,"ERR:"M_NAME":create_rf_data: no memory left for generic\n"); goto out_of_memory; } ims_info = 0; return rf_data; out_of_memory: LOG(L_ERR, "create_rf_data: out of memory\n"); error: WL_FREE_ALL(&sdp_media_comps, sdp_media_component_list_t, pkg); time_stamps_free(time_stamps); event_type_free(event_type); ims_information_free(ims_info); service_data_container_free(serv_data_container); ps_information_free(ps_info); Rf_free_ACR(rf_data); str_free(icid, pkg); return NULL; }