示例#1
0
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;
}
示例#2
0
/**
 * 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, &copy_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;
}
示例#3
0
service_information_t * new_service_information(ims_information_t * ims_info, subscription_id_t * subscription) {
    service_information_t * x = 0;
    subscription_id_list_element_t * sl = 0;

    mem_new(x, sizeof (service_information_t), pkg);

    x->ims_information = ims_info;
    if (subscription) {
        mem_new(sl, sizeof (subscription_id_list_element_t), pkg);
        subscription_id_list_t_copy(&(sl->s), subscription, pkg);
        WL_APPEND(&(x->subscription_id), sl);
    }

    return x;

out_of_memory:
    LM_ERR("new service information: out of pkg memory\n");
    service_information_free(x);
    return 0;
}
示例#4
0
int get_all_media_lines(char * start, char * end, char line_name, 
				str_list_t * sdp_media_descriptions){

	
	str sdp_par = {0,0};
	str_list_slot_t * str_slot = NULL;

       while((sdp_par.s = find_next_sdp_line(start, end,line_name,NULL))){
                sdp_par.len = get_line_length(sdp_par.s, end);
                mem_new(str_slot, sizeof(str_list_slot_t), pkg);
                str_dup(str_slot->data,sdp_par,pkg);
                WL_APPEND(sdp_media_descriptions,str_slot);
                str_slot=0;
		start = sdp_par.s + sdp_par.len;
        }

	return 1;

out_of_memory:
	LOG(L_ERR, "ERR:"M_NAME":get_media_description_list: out of pkg memory\n");
	if(str_slot) WL_FREE(str_slot, str_list_t,pkg);
	return 0;
}