示例#1
0
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);
}
示例#2
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;
}
示例#3
0
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;
}
示例#4
0
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;
}
示例#5
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;
}