time_stamps_t * new_time_stamps(time_t *sip_request_timestamp, uint32_t *sip_request_timestamp_fraction, time_t *sip_response_timestamp, uint32_t *sip_response_timestamp_fraction) { time_stamps_t * x = 0; mem_new(x, sizeof (time_stamps_t), pkg); if (sip_request_timestamp && *sip_request_timestamp > 0) { mem_new(x->sip_request_timestamp, sizeof (time_t), pkg); *(x->sip_request_timestamp) = *sip_request_timestamp; } if (sip_request_timestamp_fraction && *sip_request_timestamp_fraction > 0) { mem_new(x->sip_request_timestamp_fraction, sizeof (uint32_t), pkg); *(x->sip_request_timestamp_fraction) = *sip_request_timestamp_fraction; } if (sip_response_timestamp && *sip_response_timestamp > 0) { mem_new(x->sip_response_timestamp, sizeof (time_t), pkg); *(x->sip_response_timestamp) = *sip_response_timestamp; } if (sip_response_timestamp_fraction && *sip_response_timestamp_fraction > 0) { mem_new(x->sip_response_timestamp_fraction, sizeof (uint32_t), pkg); *(x->sip_response_timestamp_fraction) = *sip_response_timestamp_fraction; } return x; out_of_memory: LM_ERR("out of pkg memory\n"); time_stamps_free(x); return 0; }
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); }
Ro_CCR_t * dlg_create_ro_session(struct sip_msg * req, struct sip_msg * reply, AAASession ** authp, int dir, str asserted_identity, str called_asserted_identity, str subscription_id, int subscription_id_type, str* incoming_trunk_id, str *outgoing_trunk_id, str* pani) { Ro_CCR_t * ro_ccr_data = 0; AAASession * auth = NULL; 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}; 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 acc_record_type; subscription_id_t subscr; *authp = 0; if (!get_sip_header_info(req, reply, &acc_record_type, &sip_method, &event, &expires, &callid, &from_uri, &to_uri)) goto error; user_name.s = subscription_id.s; user_name.len = subscription_id.len; /* if(!get_ims_charging_info(req, reply, &icid, &orig_ioi, &term_ioi)) goto error; */ LM_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 (!(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, &asserted_identity, &called_asserted_identity, &icid, &orig_ioi, &term_ioi, dir, incoming_trunk_id, outgoing_trunk_id, pani))) goto error; event_type = 0; time_stamps = 0; subscr.id.s = subscription_id.s; subscr.id.len = subscription_id.len; subscr.type = subscription_id_type; ro_ccr_data = new_Ro_CCR(acc_record_type, &user_name, ims_info, &subscr); if (!ro_ccr_data) { LM_ERR("dlg_create_ro_session: no memory left for generic\n"); goto out_of_memory; } ims_info = 0; if (strncmp(req->first_line.u.request.method.s, "INVITE", 6) == 0) { //create CDP CC Accounting session auth = cdpb.AAACreateCCAccSession(credit_control_session_callback, 1/*is_session*/, NULL); //must unlock session hash when done LM_DBG("Created Ro Session with id Session ID [%.*s]\n", auth->id.len, auth->id.s); //save_session = auth->id; } /*if (strncmp(req->first_line.u.request.method.s, "BYE", 3) == 0) { auth = cdp_avp->cdp->AAAGetAuthSession(save_session); }*/ if (!auth) { LM_ERR("unable to create the Ro Session\n"); goto error; } *authp = auth; return ro_ccr_data; out_of_memory: error : time_stamps_free(time_stamps); event_type_free(event_type); ims_information_free(ims_info); Ro_free_CCR(ro_ccr_data); return NULL; }
int create_stop_acr_rf_info(str callid, str from_uri, str to_uri, int dir, Rf_ACR_t ** rf_data){ Rf_ACR_t * gen_rf_data=0; str user_name ={0,0}, sip_method = {0,0}, event = {0,0}; uint32_t expires = 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; acct_record_type = AAA_ACCT_STOP; sip_method = BYE_method; expires =0; 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_stop_acr_rf_info: 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; } // user_name = from_uri; req_timestamp = reply_timestamp = time(NULL); 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, NULL, NULL, NULL,dir))) goto error; event_type = 0; time_stamps = 0; subscr.type = Subscription_Type_IMPU; subscr.id.s = from_uri.s; subscr.id.len = from_uri.len; gen_rf_data = new_Rf_ACR(acct_record_type, acct_record_number, &user_name, ims_info, NULL, &subscr); if(!gen_rf_data) { LOG(L_ERR,"ERR:"M_NAME":create_stop_acr_rf_info: no memory left for generic\n"); goto out_of_memory; } ims_info = 0; *rf_data = gen_rf_data; return 1; out_of_memory: LOG(L_ERR, "create_stop_acr_rf_info: out of memory\n"); error: time_stamps_free(time_stamps); event_type_free(event_type); ims_information_free(ims_info); Rf_free_ACR(gen_rf_data); 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; }