Module: sip-router
Branch: master
Commit: 871ca61d1fac900b17d9c6857012e3bf90a71e1a
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=871ca61…
Author: Richard Good <richard.good(a)smilecoms.com>
Committer: Richard Good <richard.good(a)smilecoms.com>
Date: Thu Mar 6 10:58:52 2014 +0200
modules/ims_charging: use cscf_get_public_identity_from_requri instead of
msg->first_line.u.request.uri in mod.c and ims_charging.c
When getting public identity from Req URI use ims_getters method instead of
reading directly from message
This allows ims_charging to identify subscribers to charge even when clients add
extra info
(e.g. phone context) after the identity in the request URI
---
modules/ims_charging/ims_ro.c | 6 +++++-
modules/ims_charging/mod.c | 37 ++++++++++++++++++++++++++-----------
2 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/modules/ims_charging/ims_ro.c b/modules/ims_charging/ims_ro.c
index 650aad6..ae13389 100644
--- a/modules/ims_charging/ims_ro.c
+++ b/modules/ims_charging/ims_ro.c
@@ -944,6 +944,7 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir,
str* charge_
int cc_event_number = 0; //According to IOT tests this should start at 0
int cc_event_type = RO_CC_START;
+ int free_called_asserted_identity = 0;
//getting asserted identity
if ((asserted_identity = cscf_get_asserted_identity(msg, 0)).len == 0) {
@@ -955,7 +956,8 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir,
str* charge_
//getting called asserted identity
if ((called_asserted_identity = cscf_get_called_party_id(msg, &h)).len == 0) {
LM_DBG("No P-Called-Identity hdr found. Using request URI for
called_asserted_identity");
- called_asserted_identity = msg->first_line.u.request.uri;
+ called_asserted_identity = cscf_get_public_identity_from_requri(msg);
+ free_called_asserted_identity = 1;
}
if (dir == RO_ORIG_DIRECTION) {
@@ -1066,9 +1068,11 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir,
str* charge_
update_stat(initial_ccrs, 1);
+ if(free_called_asserted_identity) shm_free(called_asserted_identity.s);// shm_malloc
in cscf_get_public_identity_from_requri
return RO_RETURN_BREAK;
error:
+ if(free_called_asserted_identity) shm_free(called_asserted_identity.s);// shm_malloc
in cscf_get_public_identity_from_requri
Ro_free_CCR(ro_ccr_data);
if (cc_acc_session) {
cdpb.AAASessionsUnlock(cc_acc_session->hash);
diff --git a/modules/ims_charging/mod.c b/modules/ims_charging/mod.c
index e1256a1..4fb423f 100644
--- a/modules/ims_charging/mod.c
+++ b/modules/ims_charging/mod.c
@@ -324,6 +324,7 @@ static int w_ro_ccr(struct sip_msg *msg, str* route_name, str*
direction, str* c
struct dlg_cell* dlg;
unsigned int len;
struct ro_session *ro_session = 0;
+ int free_contact = 0;
LM_DBG("Ro CCR initiated: direction:%.*s, charge_type:%.*s, unit_type:%.*s,
reservation_units:%i, route_name:%.*s",
direction->len, direction->s,
@@ -366,19 +367,24 @@ static int w_ro_ccr(struct sip_msg *msg, str* route_name, str*
direction, str* c
goto send_ccr;
}
//get callee contact from request URI
- contact = msg->first_line.u.request.uri;
+ contact = cscf_get_public_identity_from_requri(msg);
+ free_contact = 1;
} else {
LM_CRIT("don't know what to do in unknown mode - should we even get
here\n");
- return RO_RETURN_ERROR;
+ ret = RO_RETURN_ERROR;
+ goto done;
}
+ LM_DBG("IMPU data to pass to usrloc: contact <%.*s> identity
<%.*s>\n", contact.len, contact.s, identity.len, identity.s);
+
//create impu_data_parcel
len = identity.len + contact.len + sizeof (struct impu_data);
impu_data = (struct impu_data*) shm_malloc(len);
if (!impu_data) {
LM_ERR("Unable to allocate memory for impu_data, trying to send CCR\n");
- return RO_RETURN_ERROR;
+ ret = RO_RETURN_ERROR;
+ goto done;
}
memset(impu_data, 0, len);
@@ -398,19 +404,22 @@ static int w_ro_ccr(struct sip_msg *msg, str* route_name, str*
direction, str* c
if (p != (((char*) impu_data) + len)) {
LM_ERR("buffer overflow creating impu data, trying to send CCR\n");
shm_free(impu_data);
- return RO_RETURN_ERROR;
+ ret = RO_RETURN_ERROR;
+ goto done;
}
//reg for callbacks on confirmed and terminated
if (dlgb.register_dlgcb(dlg, /* DLGCB_RESPONSE_FWDED */ DLGCB_CONFIRMED,
add_dlg_data_to_contact, (void*)impu_data ,NULL ) != 0) {
LM_CRIT("cannot register callback for dialog confirmation\n");
- return RO_RETURN_ERROR;
+ ret = RO_RETURN_ERROR;
+ goto done;
}
if (dlgb.register_dlgcb(dlg, DLGCB_TERMINATED | DLGCB_FAILED | DLGCB_EXPIRED /*|
DLGCB_DESTROY */, remove_dlg_data_from_contact, (void*)impu_data, NULL ) != 0) {
LM_CRIT("cannot register callback for dialog termination\n");
- return RO_RETURN_ERROR;
+ ret = RO_RETURN_ERROR;
+ goto done;
}
send_ccr:
@@ -429,13 +438,15 @@ send_ccr:
int ri = route_get(&main_rt, route_name->s);
if (ri < 0) {
LM_ERR("unable to find route block [%.*s]\n", route_name->len,
route_name->s);
- return RO_RETURN_ERROR;
+ ret = RO_RETURN_ERROR;
+ goto done;
}
cfg_action = main_rt.rlist[ri];
if (!cfg_action) {
LM_ERR("empty action lists in route block [%.*s]\n", route_name->len,
route_name->s);
- return RO_RETURN_ERROR;
+ ret = RO_RETURN_ERROR;
+ goto done;
}
//before we send lets suspend the transaction
@@ -443,19 +454,22 @@ send_ccr:
if (t == NULL || t == T_UNDEFINED) {
if (tmb.t_newtran(msg) < 0) {
LM_ERR("cannot create the transaction for CCR async\n");
- return RO_RETURN_ERROR;
+ ret = RO_RETURN_ERROR;
+ goto done;
}
t = tmb.t_gett();
if (t == NULL || t == T_UNDEFINED) {
LM_ERR("cannot lookup the transaction\n");
- return RO_RETURN_ERROR;
+ ret = RO_RETURN_ERROR;
+ goto done;
}
}
LM_DBG("Suspending SIP TM transaction\n");
if (tmb.t_suspend(msg, &tindex, &tlabel) < 0) {
LM_ERR("failed to suspend the TM processing\n");
- return RO_RETURN_ERROR;
+ ret = RO_RETURN_ERROR;
+ goto done;
}
ret = Ro_Send_CCR(msg, dlg, dir, charge_type, unit_type, reservation_units, cfg_action,
tindex, tlabel);
@@ -466,6 +480,7 @@ send_ccr:
}
done:
+ if(free_contact) shm_free(contact.s);// shm_malloc in
cscf_get_public_identity_from_requri
return ret;
}