ims_information_t * new_ims_information(event_type_t * event_type, time_stamps_t * time_stamps, str * user_session_id, str * outgoing_session_id, str * calling_party, str * called_party, str * icid, str * orig_ioi, str * term_ioi, int node_role, str *trunk_id) { str_list_slot_t *sl = 0; ims_information_t *x = 0; ioi_list_element_t * ioi_elem = 0; mem_new(x, sizeof (ims_information_t), pkg); x->event_type = event_type; x->time_stamps = time_stamps; mem_new(x->role_of_node, sizeof (int32_t), pkg); *(x->role_of_node) = node_role; //x->node_functionality = cfg.node_func; if (outgoing_session_id && outgoing_session_id->s) str_dup_ptr(x->outgoing_session_id, *outgoing_session_id, pkg); if (user_session_id && user_session_id->s) str_dup_ptr(x->user_session_id, *user_session_id, pkg); if (calling_party && calling_party->s) { mem_new(sl, sizeof (str_list_slot_t), pkg); str_dup(sl->data, *calling_party, pkg); WL_APPEND(&(x->calling_party_address), sl); } if (called_party && called_party->s) str_dup_ptr(x->called_party_address, *called_party, pkg); if (trunk_id && trunk_id->s) str_dup_ptr(x->trunk_id, *trunk_id, pkg); //WL_FREE_ALL(&(x->called_asserted_identity),str_list_t,pkg); //str_free_ptr(x->requested_party_address,pkg); if ((orig_ioi && orig_ioi->s) || (term_ioi && term_ioi->s)) { mem_new(ioi_elem, sizeof (ioi_list_element_t), pkg); if (orig_ioi) str_dup_ptr_ptr(ioi_elem->info.originating_ioi, orig_ioi, pkg); if (term_ioi) str_dup_ptr_ptr(ioi_elem->info.terminating_ioi, term_ioi, pkg); } if (icid && icid->s) str_dup_ptr(x->icid, *icid, pkg); return x; out_of_memory: LM_ERR("out of pkg memory\n"); ims_information_free(x); return NULL; }
/** * add the sdp component from a request or a reply, respectively an offer or an answer * @param msg - the SIP message * @param sdp_type - 0 for SDP offer and 1 for SDP answer * @param sip_uri - the SIP uri of the one that sent the SDP body * @param sdp_media_comps - the built structure * @returns 1 if ok, 0 if an error occured */ int append_sip_sdp_comp(struct sip_msg * msg, int sdp_type, str sip_uri, str user_sip_uri, sdp_media_component_list_t * sdp_media_comps){ sdp_media_component_t * sdp_media_elem = NULL; str sdp_body = {0,0}; str mline_s = {0,0}, next_mline_s= {0,0}; char * end, *media_info_end; str copy_sdp_body = {0,0}; LOG(L_DBG, "checking if the message has sdp body\n"); /*if the SIP message contains SDP body*/ if(extract_sdp_body(msg, ©_sdp_body)==-1) { return 1; } str_dup(sdp_body, copy_sdp_body, pkg); end = sdp_body.s + sdp_body.len; mline_s.s = find_sdp_line(sdp_body.s,end,'m'); for(;mline_s.s;mline_s.s = next_mline_s.s){ mline_s.len = get_line_length(mline_s.s, end); next_mline_s.s = find_next_sdp_line(mline_s.s,end,'m',NULL); mem_new(sdp_media_elem, sizeof(sdp_media_component_t), pkg); str_dup_ptr_ptr(sdp_media_elem->sdp_media_name, &mline_s, pkg); media_info_end = end; mem_new(sdp_media_elem->sdp_type, sizeof(int32_t), pkg); *(sdp_media_elem->sdp_type) = sdp_type; if(!get_media_description_list(mline_s.s+mline_s.len, end, &(sdp_media_elem->sdp_media_descriptions))) goto error; /*if(str_equal(user_sip_uri, sip_uri)) add_an_charging_id(sip_uri, sdp_media_elem);*/ WL_APPEND(sdp_media_comps, sdp_media_elem); } str_free(sdp_body,pkg); return 1; out_of_memory: LOG(L_ERR, "append_sip_sdp_comp: out of pkg memory\n"); error: WL_FREE(sdp_media_elem, sdp_media_component_list_t, pkg); return 0; }
Ro_CCR_t * new_Ro_CCR(int32_t acc_record_type, str * user_name, ims_information_t * ims_info, subscription_id_t * subscription) { Ro_CCR_t *x = 0; service_information_t * service_info = 0; mem_new(x, sizeof (Ro_CCR_t), pkg); str_dup(x->origin_host, cfg.origin_host, pkg); str_dup(x->origin_realm, cfg.origin_realm, pkg); str_dup(x->destination_realm, cfg.destination_realm, pkg); x->acct_record_type = acc_record_type; if (user_name) { str_dup_ptr_ptr(x->user_name, user_name, pkg); } if (cfg.service_context_id && cfg.service_context_id->s) str_dup_ptr(x->service_context_id, *(cfg.service_context_id), pkg); if (ims_info) if (!(service_info = new_service_information(ims_info, subscription))) goto error; x->service_information = service_info; service_info = 0; return x; out_of_memory: LM_ERR("out of pkg memory\n"); error: Ro_free_CCR(x); service_information_free(service_info); return 0; }