[sr-dev] git:tmp/interconnectroute_module: modules/interconnectroute: Added video_service_code

Richard Good richard.good at smilecoms.com
Wed Dec 3 16:44:45 CET 2014


Module: sip-router
Branch: tmp/interconnectroute_module
Commit: 306e40d613c15ccda88e46224788e363ca9ddb3b
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=306e40d613c15ccda88e46224788e363ca9ddb3b

Author: Richard Good <richard.good at smilecoms.com>
Committer: Richard Good <richard.good at smilecoms.com>
Date:   Wed Dec  3 17:44:15 2014 +0200

modules/interconnectroute: Added video_service_code

---

 modules/interconnectroute/interconnect_data.c |    1 -
 modules/interconnectroute/interconnect_data.h |   14 ------
 modules/interconnectroute/interconnectroute.c |   52 ++++++++++++++--------
 modules/interconnectroute/query.c             |   56 +++++++++++++++++++++----
 4 files changed, 80 insertions(+), 43 deletions(-)

diff --git a/modules/interconnectroute/interconnect_data.c b/modules/interconnectroute/interconnect_data.c
deleted file mode 100644
index 8b13789..0000000
--- a/modules/interconnectroute/interconnect_data.c
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/modules/interconnectroute/interconnect_data.h b/modules/interconnectroute/interconnect_data.h
deleted file mode 100644
index 65db4ec..0000000
--- a/modules/interconnectroute/interconnect_data.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* 
- * File:   interconnect_data.h
- * Author: jaybeepee
- *
- * Created on 14 October 2014, 5:44 PM
- */
-
-#ifndef INTERCONNECT_DATA_H
-#define	INTERCONNECT_DATA_H
-
-typedef struct  
-
-#endif	/* INTERCONNECT_DATA_H */
-
diff --git a/modules/interconnectroute/interconnectroute.c b/modules/interconnectroute/interconnectroute.c
index 3c2e159..1f1033a 100644
--- a/modules/interconnectroute/interconnectroute.c
+++ b/modules/interconnectroute/interconnectroute.c
@@ -8,23 +8,29 @@
 MODULE_VERSION
 
 str interconnectroute_db_url = str_init(DEFAULT_IXDB_URL);
-str service_code = str_init("ext.01.001.8.32260 at 3gpp.org_1000");
-	
+str voice_service_code = str_init("ext.01.001.8.32260 at 3gpp.org_1000");
+str video_service_code = str_init("ext.01.001.8.32260 at 3gpp.org_1001");	
+
 static int mod_init(void);
 static int child_init(int);
-static int mi_child_init(void);
+//static int mi_child_init(void);
 static void mod_destroy(void);
 
+
+static int w_ix_orig_trunk_query(struct sip_msg* msg);
+static int w_ix_term_trunk_query(struct sip_msg* msg, char* ext_trunk_id);
+
 /************* Module Exports **********************************************/
 static cmd_export_t cmds[]={
-	{"ix_orig_trunk_query",  (cmd_function)ix_orig_trunk_query,  0, 0, 0, REQUEST_ROUTE | FAILURE_ROUTE },
-	{"ix_term_trunk_query",  (cmd_function)ix_term_trunk_query,  1, ix_trunk_query_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
+	{"ix_orig_trunk_query",  (cmd_function)w_ix_orig_trunk_query,  0, 0, 0, REQUEST_ROUTE | FAILURE_ROUTE },
+	{"ix_term_trunk_query",  (cmd_function)w_ix_term_trunk_query,  1, ix_trunk_query_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
 	{0, 0, 0, 0, 0, 0}
 };
 
 static param_export_t params[]= {
     { "db_url", PARAM_STR, &interconnectroute_db_url },
-    { "service_code", PARAM_STR, &service_code },
+    { "voice_service_code", PARAM_STR, &voice_service_code },
+    { "video_service_code", PARAM_STR, &video_service_code },
     {0,0,0}
 };
 
@@ -68,12 +74,20 @@ static int child_init(int rank) {
 }
 
 
-static int mi_child_init(void) {
+static int w_ix_orig_trunk_query(struct sip_msg* msg) {
+    return ix_orig_trunk_query(msg);
+}
+
+static int w_ix_term_trunk_query(struct sip_msg* msg, char* ext_trunk_id) {
+    return ix_term_trunk_query(msg, ext_trunk_id);
+}
+
+//static int mi_child_init(void) {
 //	if(mode == CARRIERROUTE_MODE_DB){
 //		return carrierroute_db_open();
 //	}
-	return 0;
-}
+//	return 0;
+//}
 
 static void mod_destroy(void) {
 //	if(mode == CARRIERROUTE_MODE_DB){
@@ -82,15 +96,15 @@ static void mod_destroy(void) {
 //	destroy_route_data();
 }
 
-static const char *rpc_cr_reload_routes_doc[2] = {
-	"Reload routes", 0
-};
+//static const char *rpc_cr_reload_routes_doc[2] = {
+//	"Reload routes", 0
+//};
 
-static void rpc_cr_reload_routes(rpc_t *rpc, void *c) {
-
-}
+//static void rpc_cr_reload_routes(rpc_t *rpc, void *c) {
+//
+//}
 
-static rpc_export_t rpc_methods[] = {
-//	{ "cr.reload_routes",  rpc_cr_reload_routes, rpc_cr_reload_routes_doc, 0},
-	{0, 0, 0, 0}
-};
\ No newline at end of file
+//static rpc_export_t rpc_methods[] = {
+////	{ "cr.reload_routes",  rpc_cr_reload_routes, rpc_cr_reload_routes_doc, 0},
+//	{0, 0, 0, 0}
+//};
\ No newline at end of file
diff --git a/modules/interconnectroute/query.c b/modules/interconnectroute/query.c
index ff4bfca..da79f76 100644
--- a/modules/interconnectroute/query.c
+++ b/modules/interconnectroute/query.c
@@ -4,18 +4,56 @@
 #include "../../sr_module.h"
 #include "../../lib/ims/ims_getters.h"
 #include "interconnectroute.h"
+#include "../../parser/sdp/sdp.h"
 
-extern str service_code;
+extern str voice_service_code, video_service_code;
 
 /**We need to get the service code
  currently we hard code this to voice service context id _ voice service id
  This is Smile specific - think about making this more generic*/
-inline int get_service_code(str *sc) {
-    if(!service_code.s) {
+inline int get_service_code(str *sc, struct sip_msg* msg) {
+    int sdp_stream_num = 0;
+    sdp_session_cell_t* msg_sdp_session;
+    sdp_stream_cell_t* msg_sdp_stream;
+    int intportA;
+    
+    //check SDP - if there is video then use video service code otherwise use voice service code
+    if (parse_sdp(msg) < 0) {
+	LM_ERR("Unable to parse req SDP\n");
 	return -1;
     }
-    sc->s = service_code.s;
-    sc->len = service_code.len;
+
+    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) {
+		break;
+	    }
+
+	    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 use video service code: [%.*s]", 
+			video_service_code.len, video_service_code.s);
+		sc->s = video_service_code.s;
+		sc->len = video_service_code.len;
+		break;
+	    }
+
+	    sdp_stream_num++;
+	}
+    }
+
+    free_sdp((sdp_info_t**) (void*) &msg->body);
+    
+    if(sc->len == 0) {
+	LM_DBG("We use default voice service code: [%.*s]", 
+			voice_service_code.len, voice_service_code.s);
+		sc->s = voice_service_code.s;
+		sc->len = voice_service_code.len;
+    }
     return 1;
     
 }
@@ -63,7 +101,7 @@ int isonlydigits(str* s) {
 }
 
 int ix_orig_trunk_query(struct sip_msg* msg) {
-    str sc;
+    str sc = {0, 0};
     sip_uri_t calling_party_sip_uri, called_party_sip_uri;
     ix_route_list_t* ix_route_list;
     str called_asserted_identity = {0 , 0 },
@@ -139,7 +177,7 @@ int ix_orig_trunk_query(struct sip_msg* msg) {
 	goto error;
     }
     
-    if(!get_service_code(&sc)){
+    if(!get_service_code(&sc, msg)){
 	LM_ERR("Could not get service code\n");
 	goto error;
     }
@@ -188,7 +226,7 @@ error:
 int ix_term_trunk_query(struct sip_msg* msg, char* ext_trunk_id) {
     str external_trunk_id = {0, 0};
     ix_route_list_t* ix_route_list;
-    str sc;
+    str sc = {0, 0};
     sip_uri_t calling_party_sip_uri, called_party_sip_uri;
     str called_asserted_identity = {0 , 0 },
 	asserted_identity = {0 , 0 },
@@ -266,7 +304,7 @@ int ix_term_trunk_query(struct sip_msg* msg, char* ext_trunk_id) {
 	goto error;
     }
     
-    if(!get_service_code(&sc)){
+    if(!get_service_code(&sc, msg)){
 	LM_ERR("Could not get service code\n");
 	goto error;
     }




More information about the sr-dev mailing list