From 63abc6f8036937ab6253260aa6e4ccaf04536922 Mon Sep 17 00:00:00 2001 From: Richard Good Date: Wed, 28 Jan 2015 12:48:52 +0200 Subject: [PATCH] modules/ims_charging: Modified Ro_CCR method - removed unused params (IEC, SCUR, etc.) and added incoming and outgoing trunk id needed for interconnect charging --- examples/scscf/kamailio.cfg | 5 ++- modules/ims_charging/Ro_data.c | 12 ++++-- modules/ims_charging/Ro_data.h | 6 ++- modules/ims_charging/ccr.c | 14 +++--- .../ims_charging/doc/ims_charging_admin.xml | 29 +++++-------- modules/ims_charging/ims_ro.c | 43 ++++++++++--------- modules/ims_charging/ims_ro.h | 3 +- modules/ims_charging/mod.c | 38 +++++++--------- modules/ims_charging/ro_db_handler.c | 16 ++++--- modules/ims_charging/ro_db_handler.h | 5 ++- modules/ims_charging/ro_session_hash.c | 17 +++++--- modules/ims_charging/ro_session_hash.h | 5 ++- 12 files changed, 99 insertions(+), 94 deletions(-) diff --git a/examples/scscf/kamailio.cfg b/examples/scscf/kamailio.cfg index f8c2ee6c9ae..b8f7a1eb13e 100644 --- a/examples/scscf/kamailio.cfg +++ b/examples/scscf/kamailio.cfg @@ -308,6 +308,9 @@ modparam("enum", "domain_suffix", ENUM_SUFFIX) # ----- sanity params ----- modparam("sanity", "autodrop", 0) +# -- presence params -- +modparam("presence", "subs_remove_match", 1) #means we match subscriptions on all attributes + # ----------------- Settings for Dispatcher --------------- modparam("dispatcher", "list_file", "/etc/kamailio/dispatcher.list") # Dispatcher: Enable Failover-Support @@ -768,7 +771,7 @@ route[orig] # before we allow call - lets check credit if (is_method("INVITE")) { xlog("L_DBG","Sending initial CCR Request for call\n"); - $var(cc_ret) = Ro_CCR("CHARGING_CCR_REPLY", "orig", "SCUR", "", "30", "location"); + $var(cc_ret) = Ro_CCR("CHARGING_CCR_REPLY", "orig", 30, "0", "0"); if ($var(cc_ret) < 0) { xlog("L_ERR","CCR Request failure\n"); sl_send_reply("402","Payment required"); diff --git a/modules/ims_charging/Ro_data.c b/modules/ims_charging/Ro_data.c index 4b1721b1425..f53fec8e0c8 100644 --- a/modules/ims_charging/Ro_data.c +++ b/modules/ims_charging/Ro_data.c @@ -87,7 +87,7 @@ time_stamps_t * new_time_stamps(time_t *sip_request_timestamp, uint32_t *sip_req } 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 * called_party, str * icid, str * orig_ioi, str * term_ioi, int node_role, str *incoming_trunk_id, str *outgoing_trunk_id) { str_list_slot_t *sl = 0; ims_information_t *x = 0; @@ -118,8 +118,11 @@ ims_information_t * new_ims_information(event_type_t * event_type, time_stamps_t 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); + if (incoming_trunk_id && incoming_trunk_id->s) + str_dup_ptr(x->incoming_trunk_id, *incoming_trunk_id, pkg); + + if (outgoing_trunk_id && outgoing_trunk_id->s) + str_dup_ptr(x->outgoing_trunk_id, *outgoing_trunk_id, pkg); //WL_FREE_ALL(&(x->called_asserted_identity),str_list_t,pkg); //str_free_ptr(x->requested_party_address,pkg); @@ -234,7 +237,8 @@ void ims_information_free(ims_information_t *x) { 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); + str_free_ptr(x->incoming_trunk_id, pkg); + str_free_ptr(x->outgoing_trunk_id, pkg); time_stamps_free(x->time_stamps); diff --git a/modules/ims_charging/Ro_data.h b/modules/ims_charging/Ro_data.h index a6495b54efe..e68d4b7ba0d 100644 --- a/modules/ims_charging/Ro_data.h +++ b/modules/ims_charging/Ro_data.h @@ -282,7 +282,8 @@ typedef struct { str *service_id; - str *trunk_id; + str *incoming_trunk_id; + str *outgoing_trunk_id; service_specific_info_list_t service_specific_info; @@ -396,7 +397,8 @@ ims_information_t * new_ims_information(event_type_t * event_type, str * orig_ioi, str * term_ioi, int node_role, - str *trunk_id); + str *incoming_trunk_id, + str *outgoing_trunk_id); void event_type_free(event_type_t *x); void time_stamps_free(time_stamps_t *x); diff --git a/modules/ims_charging/ccr.c b/modules/ims_charging/ccr.c index 35e33d1f64e..6392805d165 100644 --- a/modules/ims_charging/ccr.c +++ b/modules/ims_charging/ccr.c @@ -96,15 +96,13 @@ int Ro_write_ims_information_avps(AAA_AVP_LIST * avp_list, ims_information_t* x) if (!cdp_avp->epcapp.add_Called_Party_Address(&aList2, *(x->called_party_address), 0)) goto error; - if (x->trunk_id && x->role_of_node) { - if (*(x->role_of_node) == RO_ORIG_DIRECTION) { - if (!cdp_avp->epcapp.add_Outgoing_Trunk_Group_Id(&aList, *(x->trunk_id), 0)) - goto error; + if (x->incoming_trunk_id && x->outgoing_trunk_id) { + if (!cdp_avp->epcapp.add_Outgoing_Trunk_Group_Id(&aList, *(x->outgoing_trunk_id), 0)) + goto error; + + if (!cdp_avp->epcapp.add_Incoming_Trunk_Group_Id(&aList, *(x->incoming_trunk_id), 0)) + goto error; - } else if (*(x->role_of_node) == RO_TERM_DIRECTION){ - if (!cdp_avp->epcapp.add_Incoming_Trunk_Group_Id(&aList, *(x->trunk_id), 0)) - goto error; - } if (!cdp_avp->epcapp.add_Trunk_Group_Id(&aList2, &aList, 0)) goto error; aList.head = aList.tail = 0; diff --git a/modules/ims_charging/doc/ims_charging_admin.xml b/modules/ims_charging/doc/ims_charging_admin.xml index 4bdf9b4d1d8..a00b1262204 100644 --- a/modules/ims_charging/doc/ims_charging_admin.xml +++ b/modules/ims_charging/doc/ims_charging_admin.xml @@ -737,7 +737,8 @@ modparam("ims_charging", "service_context_id_release", "262")
<function moreinfo="none">Ro_CCR(route_name, direction, - charge_type, unit_type, reservation_units, domain, trunk_id</function> + reservation_units, domain, incoming_trunk_id, outgoing_trunk_id + Perform a CCR on Diameter Ro interface for Charging @@ -754,21 +755,6 @@ modparam("ims_charging", "service_context_id_release", "262") "term"inating - - charge_type "IEC" = Immediate Event - Charging, "ECUR" - Event Charging with Unit Reservation or "SCUR" - - Session Charging with Unit Reservation. - - (Note: At the moment only SCUR is supported) - - - - unit_type Types of the unit to be - requested - - (unused at the moment) - - reservation_units how many units (at the moment seconds) should be reservated at the moment. @@ -780,8 +766,13 @@ modparam("ims_charging", "service_context_id_release", "262") - trunk_id Identifies to trunk group from - which this originates or terminates. + incoming_trunk_id Identifies the trunk group + from which this originates. + + + + outgoing_trunk_id Identifies the trunk + group where this will be terminated. @@ -796,7 +787,7 @@ modparam("ims_charging", "service_context_id_release", "262") ... xlog("L_DBG","Sending initial CCR Request for call\n"); - Ro_CCR("CHARGING_CCR_REPLY", "orig", "SCUR", "", "30","1"); + Ro_CCR("RO_ASYNC_TERM_REPLY", "term", 30, "1", "1"); } route[CHARGING_CCR_REPLY] diff --git a/modules/ims_charging/ims_ro.c b/modules/ims_charging/ims_ro.c index caf93152781..ee8a025efd7 100644 --- a/modules/ims_charging/ims_ro.c +++ b/modules/ims_charging/ims_ro.c @@ -381,7 +381,8 @@ int get_timestamps(struct sip_msg * req, struct sip_msg * reply, time_t * req_ti * */ -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* trunk_id) { +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) { Ro_CCR_t * ro_ccr_data = 0; AAASession * auth = NULL; @@ -419,7 +420,8 @@ Ro_CCR_t * dlg_create_ro_session(struct sip_msg * req, struct sip_msg * reply, A 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, trunk_id))) + 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))) goto error; event_type = 0; time_stamps = 0; @@ -466,12 +468,14 @@ error : return NULL; } -int sip_create_ro_ccr_data(struct sip_msg * msg, int dir, Ro_CCR_t ** ro_ccr_data, AAASession ** auth, str asserted_identity, str called_asserted_identity, str subscription_id, int subscription_id_type, str* trunk_id) { +int sip_create_ro_ccr_data(struct sip_msg * msg, int dir, Ro_CCR_t ** ro_ccr_data, AAASession ** auth, str asserted_identity, str called_asserted_identity, + str subscription_id, int subscription_id_type, str* incoming_trunk_id, str* outgoing_trunk_id) { if (msg->first_line.type == SIP_REQUEST) { /*end of session*/ if (strncmp(msg->first_line.u.request.method.s, "INVITE", 6) == 0) { - if (!(*ro_ccr_data = dlg_create_ro_session(msg, NULL, auth, dir, asserted_identity, called_asserted_identity, subscription_id, subscription_id_type, trunk_id))) + if (!(*ro_ccr_data = dlg_create_ro_session(msg, NULL, auth, dir, asserted_identity, called_asserted_identity, subscription_id, + subscription_id_type, incoming_trunk_id, outgoing_trunk_id))) goto error; } } else { @@ -508,13 +512,14 @@ void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned event_type = new_event_type(&sip_method, &sip_event, 0); - LM_DBG("Sending interim CCR request for (usage:new) [%i:%i] seconds for user [%.*s] using session id [%.*s] active rating group [%d] active service identifier [%d] trunk_id [%.*s]\n", + LM_DBG("Sending interim CCR request for (usage:new) [%i:%i] seconds for user [%.*s] using session id [%.*s] active rating group [%d] active service identifier [%d] incoming_trunk_id [%.*s] outgoing_trunk_id [%.*s]\n", used, reserve, ro_session->asserted_identity.len, ro_session->asserted_identity.s, ro_session->ro_session_id.len, ro_session->ro_session_id.s, ro_session->rating_group, ro_session->service_identifier, - ro_session->trunk_id.len, ro_session->trunk_id.s); + ro_session->incoming_trunk_id.len, ro_session->incoming_trunk_id.s, + ro_session->outgoing_trunk_id.len, ro_session->outgoing_trunk_id.s); req_timestamp = time(0); @@ -522,7 +527,7 @@ void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned goto error; if (!(ims_info = new_ims_information(event_type, time_stamps, &ro_session->callid, &ro_session->callid, &ro_session->asserted_identity, - &ro_session->called_asserted_identity, 0, 0, 0, ro_session->direction, &ro_session->trunk_id))) + &ro_session->called_asserted_identity, 0, 0, 0, ro_session->direction, &ro_session->incoming_trunk_id, &ro_session->outgoing_trunk_id))) goto error; LM_DBG("Created IMS information\n"); @@ -741,12 +746,13 @@ void send_ccr_stop(struct ro_session *ro_session) { event_type = new_event_type(&sip_method, &sip_event, 0); - LM_DBG("Sending stop CCR request for (usage) [%i] seconds for user [%.*s] using session id [%.*s] active rating group [%d] active service identifier [%d] trunk_id [%.*s]\n", + LM_DBG("Sending stop CCR request for (usage) [%i] seconds for user [%.*s] using session id [%.*s] active rating group [%d] active service identifier [%d] incoming_trunk_id [%.*s] outgoing_trunk_id [%.*s]\n", used, ro_session->asserted_identity.len, ro_session->asserted_identity.s, ro_session->ro_session_id.len, ro_session->ro_session_id.s, ro_session->rating_group, ro_session->service_identifier, - ro_session->trunk_id.len, ro_session->trunk_id.s); + ro_session->incoming_trunk_id.len, ro_session->incoming_trunk_id.s, + ro_session->outgoing_trunk_id.len, ro_session->outgoing_trunk_id.s); req_timestamp = time(0); @@ -754,7 +760,7 @@ void send_ccr_stop(struct ro_session *ro_session) { goto error0; if (!(ims_info = new_ims_information(event_type, time_stamps, &ro_session->callid, &ro_session->callid, &ro_session->asserted_identity, - &ro_session->called_asserted_identity, 0, 0, 0, ro_session->direction, &ro_session->trunk_id))) + &ro_session->called_asserted_identity, 0, 0, 0, ro_session->direction, &ro_session->incoming_trunk_id, &ro_session->outgoing_trunk_id))) goto error0; event_type = 0; @@ -914,8 +920,6 @@ static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *c * Send a CCR to the OCS based on the SIP message (INVITE ONLY) * @param msg - SIP message * @param direction - orig|term - * @param charge_type - IEC (Immediate Event Charging), ECUR (Event Charging with Unit Reservation), SCUR (Session Charging with Unit Reservation) - * @param unit_type - unused * @param reservation_units - units to try to reserve * @param reservation_units - config route to call when receiving a CCA * @param tindex - transaction index @@ -923,7 +927,7 @@ static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *c * * @returns #CSCF_RETURN_BREAK if OK, #CSCF_RETURN_ERROR on error */ -int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, str* charge_type, str* unit_type, int reservation_units, str* trunk_id, +int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservation_units, str* incoming_trunk_id, str* outgoing_trunk_id, cfg_action_t* action, unsigned int tindex, unsigned int tlabel) { str session_id = { 0, 0 }, called_asserted_identity = {0 , 0 }, @@ -950,11 +954,10 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, str* charge_ int sdp_stream_num = 0; - LM_DBG("Sending initial CCR request for charge_type [%.*s] unit_type [%.*s] reservation_units [%d] trunk_id [%.*s]\n", - charge_type->len, charge_type->s, - unit_type->len, unit_type->s, - reservation_units, - trunk_id->len, trunk_id->s); + LM_DBG("Sending initial CCR request for reservation_units [%d] incoming_trunk_id [%.*s] outgoing_trunk_id [%.*s]\n", + reservation_units, + incoming_trunk_id->len, incoming_trunk_id->s, + outgoing_trunk_id->len, outgoing_trunk_id->s); @@ -1043,7 +1046,7 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, str* charge_ //create a session object without auth and diameter session id - we will add this later. new_session = build_new_ro_session(dir, 0, 0, &session_id, &dlg->callid, &asserted_identity, &called_asserted_identity, &mac, dlg->h_entry, dlg->h_id, - reservation_units, 0, active_rating_group, active_service_identifier, trunk_id); + reservation_units, 0, active_rating_group, active_service_identifier, incoming_trunk_id, outgoing_trunk_id); if (!new_session) { LM_ERR("Couldn't create new Ro Session - this is BAD!\n"); @@ -1055,7 +1058,7 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, str* charge_ ssd->tlabel = tlabel; ssd->ro_session = new_session; - if (!sip_create_ro_ccr_data(msg, dir, &ro_ccr_data, &cc_acc_session, asserted_identity, called_asserted_identity, subscription_id, subscription_id_type, trunk_id)) + if (!sip_create_ro_ccr_data(msg, dir, &ro_ccr_data, &cc_acc_session, asserted_identity, called_asserted_identity, subscription_id, subscription_id_type, incoming_trunk_id, outgoing_trunk_id)) goto error; if (!ro_ccr_data) diff --git a/modules/ims_charging/ims_ro.h b/modules/ims_charging/ims_ro.h index 59d5b816caa..b6087b8cac9 100644 --- a/modules/ims_charging/ims_ro.h +++ b/modules/ims_charging/ims_ro.h @@ -14,7 +14,8 @@ struct interim_ccr { void credit_control_session_callback(int event, void* session); void remove_aaa_session(str *session_id); -int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, str* charge_type, str* unit_type, int reservation_units, str *trunk_id, cfg_action_t* action, unsigned int tindex, unsigned int tlabel); +int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservation_units, + str *incoming_trunk_id, str *outgoing_trunk_id, cfg_action_t* action, unsigned int tindex, unsigned int tlabel); void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned int reserve); void send_ccr_stop(struct ro_session *ro_session); int get_direction_as_int(str* direction); diff --git a/modules/ims_charging/mod.c b/modules/ims_charging/mod.c index 10d4feea569..303380ebca5 100644 --- a/modules/ims_charging/mod.c +++ b/modules/ims_charging/mod.c @@ -91,13 +91,13 @@ static int mod_init(void); static int mod_child_init(int); static void mod_destroy(void); -static int w_ro_ccr(struct sip_msg *msg, char* route_name, char* direction, char* charge_type, char* unit_type, int reservation_units, char* trunk_id); +static int w_ro_ccr(struct sip_msg *msg, char* route_name, char* direction, int reservation_units, char* incoming_trunk_id, char* outgoing_trunk_id); //void ro_session_ontimeout(struct ro_tl *tl); static int ro_fixup(void **param, int param_no); static cmd_export_t cmds[] = { - { "Ro_CCR", (cmd_function) w_ro_ccr, 6, ro_fixup, 0, REQUEST_ROUTE }, + { "Ro_CCR", (cmd_function) w_ro_ccr, 5, ro_fixup, 0, REQUEST_ROUTE }, { 0, 0, 0, 0, 0, 0 } }; @@ -346,13 +346,10 @@ static void mod_destroy(void) { } -static int w_ro_ccr(struct sip_msg *msg, char* c_route_name, char* c_direction, char* c_charge_type, char* c_unit_type, int reservation_units, char* c_trunk_id) { +static int w_ro_ccr(struct sip_msg *msg, char* c_route_name, char* c_direction, int reservation_units, char* c_incoming_trunk_id, char* c_outgoing_trunk_id) { /* PSEUDOCODE/NOTES * 1. What mode are we in - terminating or originating - * 2. check request type - IEC - Immediate Event Charging - * ECUR - Event Charging with Unit Reservation - * SCUR - Session Charging with Unit Reservation - * 3. probably only do SCUR in this module for now - can see event based charging in another component instead (AS for SMS for example, etc) + * 2. We assume this is SCUR in this module for now - can see event based charging in another component instead (AS for SMS for example, etc) * 4. Check a dialog exists for call, if not we fail * 5. make sure we dont already have an Ro Session for this dialog * 6. create new Ro Session @@ -377,7 +374,7 @@ static int w_ro_ccr(struct sip_msg *msg, char* c_route_name, char* c_direction, struct ro_session *ro_session = 0; int free_contact = 0; - str s_route_name, s_direction, s_charge_type, s_unit_type, s_trunk_id; + str s_route_name, s_direction, s_incoming_trunk_id, s_outgoing_trunk_id; if (get_str_fparam(&s_route_name, msg, (fparam_t*) c_route_name) < 0) { LM_ERR("failed to get s_route_name\n"); @@ -387,26 +384,21 @@ static int w_ro_ccr(struct sip_msg *msg, char* c_route_name, char* c_direction, LM_ERR("failed to get s_direction\n"); return RO_RETURN_ERROR; } - if (get_str_fparam(&s_charge_type, msg, (fparam_t*) c_charge_type) < 0) { - LM_ERR("failed to get s_charge_type\n"); + if (get_str_fparam(&s_incoming_trunk_id, msg, (fparam_t*) c_incoming_trunk_id) < 0) { + LM_ERR("failed to get s_incoming_trunk_id\n"); return RO_RETURN_ERROR; } - if (get_str_fparam(&s_unit_type, msg, (fparam_t*) c_unit_type) < 0) { - LM_ERR("failed to get s_unit_type\n"); - return RO_RETURN_ERROR; - } - if (get_str_fparam(&s_trunk_id, msg, (fparam_t*) c_trunk_id) < 0) { - LM_ERR("failed to get s_trunk_id\n"); + if (get_str_fparam(&s_outgoing_trunk_id, msg, (fparam_t*) c_outgoing_trunk_id) < 0) { + LM_ERR("failed to get s_outgoing_trunk_id\n"); return RO_RETURN_ERROR; } - LM_DBG("Ro CCR initiated: direction:%.*s, charge_type:%.*s, unit_type:%.*s, reservation_units:%i, route_name:%.*s, trunk_id:%.*s\n", + LM_DBG("Ro CCR initiated: direction:%.*s, reservation_units:%i, route_name:%.*s, incoming_trunk_id:%.*s outgoing_trunk_id:%.*s\n", s_direction.len, s_direction.s, - s_charge_type.len, s_charge_type.s, - s_unit_type.len, s_unit_type.s, reservation_units, s_route_name.len, s_route_name.s, - s_trunk_id.len, s_trunk_id.s); + s_incoming_trunk_id.len, s_incoming_trunk_id.s, + s_outgoing_trunk_id.len, s_outgoing_trunk_id.s); if (msg->first_line.type != SIP_REQUEST) { @@ -546,7 +538,7 @@ static int w_ro_ccr(struct sip_msg *msg, char* c_route_name, char* c_direction, goto done; } - ret = Ro_Send_CCR(msg, dlg, dir, &s_charge_type, &s_unit_type, reservation_units, &s_trunk_id, cfg_action, tindex, tlabel); + ret = Ro_Send_CCR(msg, dlg, dir, reservation_units, &s_incoming_trunk_id, &s_outgoing_trunk_id, cfg_action, tindex, tlabel); if(ret < 0){ LM_ERR("Failed to send CCR\n"); @@ -562,9 +554,9 @@ static int ro_fixup(void **param, int param_no) { str s; unsigned int num; - if ( (param_no > 0 && param_no <= 4) || (param_no == 6) ) { + if ( (param_no > 0 && param_no <= 2) || (param_no >= 4 && param_no <= 6)) { return fixup_var_str_12(param, param_no); - } else if (param_no == 5) { + } else if (param_no == 3) { /*convert to int */ s.s = (char*)*param; s.len = strlen(s.s); diff --git a/modules/ims_charging/ro_db_handler.c b/modules/ims_charging/ro_db_handler.c index 631ad4b869f..f66292de763 100644 --- a/modules/ims_charging/ro_db_handler.c +++ b/modules/ims_charging/ro_db_handler.c @@ -19,7 +19,8 @@ str last_event_ts_column = str_init(LAST_EVENT_TS_COL); str reserved_sec_column = str_init(RESERVED_SECS_COL); str valid_for_column = str_init(VALID_FOR_COL); str state_column = str_init(STATE_COL); -str trunk_id_column = str_init(TRUNK_ID_COL); +str incoming_trunk_id_column = str_init(INCOMING_TRUNK_ID_COL); +str outgoing_trunk_id_column = str_init(OUTGOING_TRUNK_ID_COL); str rating_group_column = str_init(RATING_GROUP_COL); str service_identifier_column = str_init(SERVICE_IDENTIFIER_COL); @@ -38,7 +39,8 @@ typedef enum ro_session_field_idx { RESERVED_SECS_COL_IDX, VALID_FOR_COL_IDX, STATE_COL_IDX, - TRUNK_ID_COL_IDX, + INCOMING_TRUNK_ID_COL_IDX, + OUTGOING_TRUNK_ID_COL_IDX, RATING_GROUP_COL_IDX, SERVICE_IDENTIFIER_COL_IDX @@ -164,7 +166,7 @@ int update_ro_dbinfo_unsafe(struct ro_session* ro_session) { db_key_t insert_keys[RO_SESSION_TABLE_COL_NUM] = { &id_column, &h_entry_column, &h_id_column, &session_id_column, &dlg_h_entry_column, &dlg_h_id_column, &direction_column, &asserted_column, &callee_column, &start_time_col, &last_event_ts_column, - &reserved_sec_column, &valid_for_column, &state_column, &trunk_id_column, &rating_group_column, &service_identifier_column + &reserved_sec_column, &valid_for_column, &state_column, &incoming_trunk_id_column, &outgoing_trunk_id_column, &rating_group_column, &service_identifier_column }; VAL_TYPE(GET_FIELD_IDX(values, ID_COL_IDX)) = DB1_INT; @@ -183,7 +185,8 @@ int update_ro_dbinfo_unsafe(struct ro_session* ro_session) { db_set_int_val(values, RESERVED_SECS_COL_IDX, ro_session->reserved_secs); db_set_int_val(values, VALID_FOR_COL_IDX, ro_session->valid_for); db_set_int_val(values, STATE_COL_IDX, ro_session->active); - db_set_str_val(values, TRUNK_ID_COL_IDX, &ro_session->trunk_id); + db_set_str_val(values, INCOMING_TRUNK_ID_COL_IDX, &ro_session->incoming_trunk_id); + db_set_str_val(values, OUTGOING_TRUNK_ID_COL_IDX, &ro_session->outgoing_trunk_id); db_set_int_val(values, RATING_GROUP_COL_IDX, ro_session->rating_group); db_set_int_val(values, SERVICE_IDENTIFIER_COL_IDX, ro_session->service_identifier); @@ -202,7 +205,7 @@ int update_ro_dbinfo_unsafe(struct ro_session* ro_session) { db_key_t update_keys[RO_SESSION_TABLE_COL_NUM-1] = { &h_entry_column, &h_id_column, &session_id_column, &dlg_h_entry_column, &dlg_h_id_column, &direction_column, &asserted_column, &callee_column, &start_time_col, &last_event_ts_column, - &reserved_sec_column, &valid_for_column, &state_column, &trunk_id_column, &rating_group_column, &service_identifier_column + &reserved_sec_column, &valid_for_column, &state_column, &incoming_trunk_id_column, &outgoing_trunk_id_column, &rating_group_column, &service_identifier_column }; db_set_int_val(values, HASH_ENTRY_COL_IDX - 1, ro_session->h_entry); @@ -218,7 +221,8 @@ int update_ro_dbinfo_unsafe(struct ro_session* ro_session) { db_set_int_val(values, RESERVED_SECS_COL_IDX - 1, ro_session->reserved_secs); db_set_int_val(values, VALID_FOR_COL_IDX - 1, ro_session->valid_for); db_set_int_val(values, STATE_COL_IDX - 1, ro_session->active); - db_set_str_val(values, TRUNK_ID_COL_IDX - 1, &ro_session->trunk_id); + db_set_str_val(values, INCOMING_TRUNK_ID_COL_IDX - 1, &ro_session->incoming_trunk_id); + db_set_str_val(values, OUTGOING_TRUNK_ID_COL_IDX - 1, &ro_session->outgoing_trunk_id); db_set_int_val(values, RATING_GROUP_COL_IDX - 1, ro_session->rating_group); db_set_int_val(values, SERVICE_IDENTIFIER_COL_IDX - 1, ro_session->service_identifier); diff --git a/modules/ims_charging/ro_db_handler.h b/modules/ims_charging/ro_db_handler.h index fc56cccddda..cb5fdd95070 100644 --- a/modules/ims_charging/ro_db_handler.h +++ b/modules/ims_charging/ro_db_handler.h @@ -14,7 +14,7 @@ #define RO_TABLE_VERSION 1 #define RO_SESSION_TABLE_NAME "ro_session" -#define RO_SESSION_TABLE_COL_NUM 17 +#define RO_SESSION_TABLE_COL_NUM 18 #define ID_COL "id" #define HASH_ENTRY_COL "hash_entry" @@ -32,7 +32,8 @@ #define STATE_COL "state" #define RATING_GROUP_COL "rating_group" #define SERVICE_IDENTIFIER_COL "service_identifier" -#define TRUNK_ID_COL "trunk_id" +#define INCOMING_TRUNK_ID_COL "incoming_trunk_id" +#define OUTGOING_TRUNK_ID_COL "outgoing_trunk_id" int init_ro_db(const str *db_url, int dlg_hash_size , int db_update_period, int fetch_num_rows); int load_ro_info_from_db(int hash_size, int fetch_num_rows); diff --git a/modules/ims_charging/ro_session_hash.c b/modules/ims_charging/ro_session_hash.c index d0e11c5a94c..1a0dd9431b2 100644 --- a/modules/ims_charging/ro_session_hash.c +++ b/modules/ims_charging/ro_session_hash.c @@ -176,10 +176,10 @@ void destroy_dlg_table(void) { struct ro_session* build_new_ro_session(int direction, int auth_appid, int auth_session_type, str *session_id, str *callid, str *asserted_identity, str* called_asserted_identity, str* mac, unsigned int dlg_h_entry, unsigned int dlg_h_id, unsigned int requested_secs, unsigned int validity_timeout, - int active_rating_group, int active_service_identifier, str *trunk_id){ + int active_rating_group, int active_service_identifier, str *incoming_trunk_id, str *outgoing_trunk_id){ LM_DBG("Building Ro Session **********"); char *p; - unsigned int len = session_id->len + callid->len + asserted_identity->len + called_asserted_identity->len + mac->len + trunk_id->len + sizeof (struct ro_session); + unsigned int len = session_id->len + callid->len + asserted_identity->len + called_asserted_identity->len + mac->len + incoming_trunk_id->len + outgoing_trunk_id->len + sizeof (struct ro_session); struct ro_session *new_ro_session = (struct ro_session*) shm_malloc(len); if (!new_ro_session) { @@ -235,10 +235,15 @@ struct ro_session* build_new_ro_session(int direction, int auth_appid, int auth_ memcpy(p, called_asserted_identity->s, called_asserted_identity->len); p += called_asserted_identity->len; - new_ro_session->trunk_id.s = p; - new_ro_session->trunk_id.len = trunk_id->len; - memcpy(p, trunk_id->s, trunk_id->len); - p += trunk_id->len; + new_ro_session->incoming_trunk_id.s = p; + new_ro_session->incoming_trunk_id.len = incoming_trunk_id->len; + memcpy(p, incoming_trunk_id->s, incoming_trunk_id->len); + p += incoming_trunk_id->len; + + new_ro_session->outgoing_trunk_id.s = p; + new_ro_session->outgoing_trunk_id.len = outgoing_trunk_id->len; + memcpy(p, outgoing_trunk_id->s, outgoing_trunk_id->len); + p += outgoing_trunk_id->len; new_ro_session->avp_value.mac.s = p; new_ro_session->avp_value.mac.len = mac->len; diff --git a/modules/ims_charging/ro_session_hash.h b/modules/ims_charging/ro_session_hash.h index f6f63efb0de..8c0a661f102 100644 --- a/modules/ims_charging/ro_session_hash.h +++ b/modules/ims_charging/ro_session_hash.h @@ -48,7 +48,8 @@ struct ro_session { str callid; str asserted_identity; str called_asserted_identity; - str trunk_id; + str incoming_trunk_id; + str outgoing_trunk_id; unsigned int hop_by_hop; struct ro_tl ro_tl; unsigned int reserved_secs; @@ -190,7 +191,7 @@ void remove_aaa_session(str *session_id); struct ro_session* build_new_ro_session(int direction, int auth_appid, int auth_session_type, str *session_id, str *callid, str *asserted_identity, str* called_asserted_identity, str* mac, unsigned int dlg_h_entry, unsigned int dlg_h_id, unsigned int requested_secs, unsigned int validity_timeout, - int active_rating_group, int active_service_identifier, str *trunk_id); + int active_rating_group, int active_service_identifier, str *incoming_trunk_id, str *outgoing_trunk_id); /*! * \brief Refefence a ro_session with locking