Module: sip-router
Branch: master
Commit: 939f29361571385e4222494caab4a1b6272405c5
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=939f293…
Author: Richard Good <richard.good(a)smilecoms.com>
Committer: Richard Good <richard.good(a)smilecoms.com>
Date: Mon Aug 18 13:02:30 2014 +0200
modules/ims_charging: added support for video charging
Previously service identifier was hard coded
This change adds configurable parameter for voice service id and rating group and video
service id and rating group
If INVITE SDP includes audio only we use voice parameter, if INVITE SDP includes video we
use video parameters
---
modules/ims_charging/doc/ims_charging_admin.xml | 76 +++++++++++++++++++++++
modules/ims_charging/ims_ro.c | 72 ++++++++++++++++++++-
modules/ims_charging/mod.c | 14 ++++
3 files changed, 158 insertions(+), 4 deletions(-)
diff --git a/modules/ims_charging/doc/ims_charging_admin.xml
b/modules/ims_charging/doc/ims_charging_admin.xml
index abd705f..a77f03d 100644
--- a/modules/ims_charging/doc/ims_charging_admin.xml
+++ b/modules/ims_charging/doc/ims_charging_admin.xml
@@ -611,6 +611,82 @@ modparam("ims_charging",
"service_context_id_mnc", "42")
</programlisting>
</example>
</section>
+
+ <section>
+
<title><varname>voice_service_identifier</varname>(string)</title>
+
+ <para>This defines the service identifier to be used for charging
voice.</para>
+
+ <para><emphasis>Default value is
"1000".</emphasis></para>
+
+ <example>
+ <title><varname>voice_service_identifier</varname>parameter
+ usage</title>
+
+ <programlisting format="linespecific">
+...
+modparam("ims_charging", "voice_service_identifier",
"1000")
+...
+ </programlisting>
+ </example>
+ </section>
+
+ <section>
+
<title><varname>voice_rating_group</varname>(string)</title>
+
+ <para>This defines the rating group to be used for charging
voice.</para>
+
+ <para><emphasis>Default value is
"100".</emphasis></para>
+
+ <example>
+ <title><varname>voice_rating_group</varname>parameter
+ usage</title>
+
+ <programlisting format="linespecific">
+...
+modparam("ims_charging", "voice_rating_group", "100")
+...
+ </programlisting>
+ </example>
+ </section>
+
+ <section>
+
<title><varname>video_service_identifier</varname>(string)</title>
+
+ <para>This defines the service identifier to be used for charging
video.</para>
+
+ <para><emphasis>Default value is
"1001".</emphasis></para>
+
+ <example>
+ <title><varname>video_service_identifier</varname>parameter
+ usage</title>
+
+ <programlisting format="linespecific">
+...
+modparam("ims_charging", "video_service_identifier",
"1000")
+...
+ </programlisting>
+ </example>
+ </section>
+
+ <section>
+
<title><varname>video_rating_group</varname>(string)</title>
+
+ <para>This defines the rating group to be used for charging
video.</para>
+
+ <para><emphasis>Default value is
"200".</emphasis></para>
+
+ <example>
+ <title><varname>video_rating_group</varname>parameter
+ usage</title>
+
+ <programlisting format="linespecific">
+...
+modparam("ims_charging", "video_rating_group", "100")
+...
+ </programlisting>
+ </example>
+ </section>
<section>
<title><varname>service_context_id_mcc</varname>(string)</title>
diff --git a/modules/ims_charging/ims_ro.c b/modules/ims_charging/ims_ro.c
index ef324f1..7f0ece2 100644
--- a/modules/ims_charging/ims_ro.c
+++ b/modules/ims_charging/ims_ro.c
@@ -19,6 +19,7 @@
#include "../../parser/parse_to.h"
#include "../../lib/ims/ims_getters.h"
+#include "../../parser/sdp/sdp.h"
#include "diameter_ro.h"
#include "ims_ro.h"
@@ -51,6 +52,13 @@ extern struct tm_binds tmb;
int interim_request_credits;
+extern int voice_service_identifier;
+extern int voice_rating_group;
+extern int video_service_identifier;
+extern int video_rating_group;
+extern int active_service_identifier;
+extern int active_rating_group;
+
static int create_cca_return_code(int result);
static void resume_on_initial_ccr(int is_timeout, void *param, AAAMessage *cca, long
elapsed_msecs);
static void resume_on_interim_ccr(int is_timeout, void *param, AAAMessage *cca, long
elapsed_msecs);
@@ -179,7 +187,9 @@ inline int Ro_add_multiple_service_credit_Control_stop(AAAMessage
*msg, int used
str used_group;
char x[4];
- unsigned int service_id = 1000; //VOICE TODO FIX as config item
+ //unsigned int service_id = 1000; //Removed these are now configurable config file
params
+
+ //unsigned int rating_group = 500; //Removed these are now configurable config file
params
used_list.head = 0;
used_list.tail = 0;
@@ -195,8 +205,11 @@ inline int Ro_add_multiple_service_credit_Control_stop(AAAMessage
*msg, int used
Ro_add_avp_list(&mscc_list, used_group.s, used_group.len,
AVP_Used_Service_Unit, AAA_AVP_FLAG_MANDATORY, 0, AVP_FREE_DATA, __FUNCTION__);
}
- set_4bytes(x, service_id);
+ set_4bytes(x, active_service_identifier);
Ro_add_avp_list(&mscc_list, x, 4, AVP_Service_Identifier, AAA_AVP_FLAG_MANDATORY,
0, AVP_DUPLICATE_DATA, __FUNCTION__);
+
+ set_4bytes(x, active_rating_group);
+ Ro_add_avp_list(&mscc_list, x, 4, AVP_Rating_Group, AAA_AVP_FLAG_MANDATORY, 0,
AVP_DUPLICATE_DATA, __FUNCTION__);
used_group = cdpb.AAAGroupAVPS(mscc_list);
cdpb.AAAFreeAVPList(&mscc_list);
@@ -207,7 +220,10 @@ inline int Ro_add_multiple_service_credit_Control_stop(AAAMessage
*msg, int used
inline int Ro_add_multiple_service_credit_Control(AAAMessage *msg, unsigned int
requested_unit, int used_unit) {
AAA_AVP_LIST list, used_list, mscc_list;
str group, used_group;
- unsigned int service_id = 1000; //VOICE TODO FIX as config item - should be a MAP
that can be identified based on SDP params
+ //unsigned int service_id = 1000; //VOICE TODO FIX as config item - should be a MAP
that can be identified based on SDP params
+
+ //unsigned int rating_group = 500; //VOICE TODO FIX as config item - should be a MAP
that can be identified based on SDP params
+
char x[4];
list.head = 0;
@@ -224,8 +240,11 @@ inline int Ro_add_multiple_service_credit_Control(AAAMessage *msg,
unsigned int
Ro_add_avp_list(&mscc_list, group.s, group.len, AVP_Requested_Service_Unit,
AAA_AVP_FLAG_MANDATORY, 0, AVP_FREE_DATA, __FUNCTION__);
- set_4bytes(x, service_id);
+ set_4bytes(x, active_service_identifier);
Ro_add_avp_list(&mscc_list, x, 4, AVP_Service_Identifier, AAA_AVP_FLAG_MANDATORY,
0, AVP_DUPLICATE_DATA, __FUNCTION__);
+
+ set_4bytes(x, active_rating_group);
+ Ro_add_avp_list(&mscc_list, x, 4, AVP_Rating_Group, AAA_AVP_FLAG_MANDATORY, 0,
AVP_DUPLICATE_DATA, __FUNCTION__);
/* if we must Used-Service-Unit */
if (used_unit >= 0) {
@@ -919,6 +938,11 @@ 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;
+
+ sdp_session_cell_t* msg_sdp_session;
+ sdp_stream_cell_t* msg_sdp_stream;
+
+ int sdp_stream_num = 0;
ssd = shm_malloc(sizeof(struct session_setup_data)); // lookup structure used to load
session info from cdp callback on CCA
if (!ssd) {
@@ -987,6 +1011,46 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir,
str* charge_
if (!cc_acc_session)
goto error;
+ //by default we use voice service id and rate group
+ //then we check SDP - if we find video then we use video service id and rate group
+ LM_DBG("Setting default SID to %d and RG to %d for voice",
+ voice_service_identifier, voice_rating_group);
+ active_service_identifier = voice_service_identifier;
+ active_rating_group = voice_rating_group;
+
+ //check SDP - if there is video then set default to video, if not set it to audio
+ if (parse_sdp(msg) < 0) {
+ LM_ERR("Unable to parse req SDP\n");
+ goto error;
+ }
+
+ msg_sdp_session = get_sdp_session(msg, 0);
+ if (!msg_sdp_session ) {
+ LM_ERR("Missing SDP session information from rpl\n");
+ } else {
+ for (;;) {
+ msg_sdp_stream = get_sdp_stream(msg, 0, sdp_stream_num);
+ if (!msg_sdp_stream) {
+ //LM_ERR("Missing SDP stream information\n");
+ break;
+ }
+
+ int intportA = atoi(msg_sdp_stream->port.s);
+ if(intportA != 0 &&
strncasecmp(msg_sdp_stream->media.s,"video",5)==0){
+ LM_DBG("This SDP has a video component and src ports not equal to 0 - so we
set default SID to %d and RG to %d for video",
+ video_service_identifier, video_rating_group);
+ active_service_identifier = video_service_identifier;
+ active_rating_group = video_rating_group;
+ break;
+ }
+
+ sdp_stream_num++;
+ }
+ }
+
+ free_sdp((sdp_info_t**) (void*) &msg->body);
+
+
if (!(ccr = Ro_new_ccr(cc_acc_session, ro_ccr_data)))
goto error;
diff --git a/modules/ims_charging/mod.c b/modules/ims_charging/mod.c
index e55482f..1a60ef9 100644
--- a/modules/ims_charging/mod.c
+++ b/modules/ims_charging/mod.c
@@ -33,6 +33,16 @@ char* ro_service_context_id_release_s = "8";
static int ro_session_hash_size = 4096;
int ro_timer_buffer = 5;
int interim_request_credits = 30;
+
+int voice_service_identifier = 1000;
+int voice_rating_group = 100;
+
+int video_service_identifier = 1001;
+int video_rating_group = 200;
+
+int active_service_identifier = 1000; //current SID to be used - will be changed
depending on SDP info
+int active_rating_group = 200; //current RG to be used - will be changed depending on
SDP info
+
client_ro_cfg cfg = { str_init("scscf.ims.smilecoms.com"),
str_init("ims.smilecoms.com"),
str_init("ims.smilecoms.com"),
@@ -106,6 +116,10 @@ static param_export_t params[] = {
{ "service_context_id_mnc", PARAM_STRING, &ro_service_context_id_mnc_s
},
{ "service_context_id_mcc", PARAM_STRING, &ro_service_context_id_mcc_s
},
{ "service_context_id_release", PARAM_STRING,
&ro_service_context_id_release_s},
+ { "voice_service_identifier", INT_PARAM, &voice_service_identifier
},/*service id for voice*/
+ { "voice_rating_group", INT_PARAM, &voice_rating_group },/*rating
group for voice*/
+ { "video_service_identifier", INT_PARAM, &video_service_identifier
},/*service id for voice*/
+ { "video_rating_group", INT_PARAM, &video_rating_group },/*rating
group for voice*/
{ 0, 0, 0 }
};