[sr-dev] git:master:b7ea6973: core: new parameter kemi.onsend_route_callback

Daniel-Constantin Mierla miconda at gmail.com
Fri Mar 9 09:46:30 CET 2018


Module: kamailio
Branch: master
Commit: b7ea6973ff17b31b814c3fb0c40f52aae364ed8b
URL: https://github.com/kamailio/kamailio/commit/b7ea6973ff17b31b814c3fb0c40f52aae364ed8b

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-03-09T09:29:29+01:00

core: new parameter kemi.onsend_route_callback

- allow setting the name of the function to be called by kemi framework
as equivalent of onsend_route {}
- default value: ksr_onsend_route
- set to empty string or "none" to skip the execution of this kemi
callback

---

Modified: src/core/cfg.lex
Modified: src/core/cfg.y
Modified: src/core/kemi.c
Modified: src/core/kemi.h
Modified: src/core/onsend.h

---

Diff:  https://github.com/kamailio/kamailio/commit/b7ea6973ff17b31b814c3fb0c40f52aae364ed8b.diff
Patch: https://github.com/kamailio/kamailio/commit/b7ea6973ff17b31b814c3fb0c40f52aae364ed8b.patch

---

diff --git a/src/core/cfg.lex b/src/core/cfg.lex
index d66857e169..abe2c250f4 100644
--- a/src/core/cfg.lex
+++ b/src/core/cfg.lex
@@ -445,6 +445,9 @@ VERBOSE_STARTUP		"verbose_startup"
 
 SERVER_ID     "server_id"
 
+KEMI     "kemi"
+ONSEND_ROUTE_CALLBACK	"onsend_route_callback"
+
 MAX_RECURSIVE_LEVEL		"max_recursive_level"
 MAX_BRANCHES_PARAM		"max_branches"|"max_branches"
 
@@ -929,6 +932,8 @@ IMPORTFILE      "import_file"
 <INITIAL>{VERBOSE_STARTUP}		{	count(); yylval.strval=yytext;
 									return VERBOSE_STARTUP; }
 <INITIAL>{SERVER_ID}  { count(); yylval.strval=yytext; return SERVER_ID;}
+<INITIAL>{KEMI}  { count(); yylval.strval=yytext; return KEMI;}
+<INITIAL>{ONSEND_ROUTE_CALLBACK}  { count(); yylval.strval=yytext; return ONSEND_ROUTE_CALLBACK;}
 <INITIAL>{MAX_RECURSIVE_LEVEL}  { count(); yylval.strval=yytext; return MAX_RECURSIVE_LEVEL;}
 <INITIAL>{MAX_BRANCHES_PARAM}  { count(); yylval.strval=yytext; return MAX_BRANCHES_PARAM;}
 <INITIAL>{LATENCY_LOG}  { count(); yylval.strval=yytext; return LATENCY_LOG;}
diff --git a/src/core/cfg.y b/src/core/cfg.y
index 85105120b7..e8f76d3537 100644
--- a/src/core/cfg.y
+++ b/src/core/cfg.y
@@ -482,6 +482,8 @@ extern char *default_routename;
 %token VERBOSE_STARTUP
 %token CFG_DESCRIPTION
 %token SERVER_ID
+%token KEMI
+%token ONSEND_ROUTE_CALLBACK
 %token MAX_RECURSIVE_LEVEL
 %token MAX_BRANCHES_PARAM
 %token LATENCY_CFG_LOG
@@ -1568,6 +1570,15 @@ assign_stm:
 	| VERBOSE_STARTUP EQUAL error { yyerror("boolean value expected"); }
     | SERVER_ID EQUAL NUMBER { server_id=$3; }
 	| SERVER_ID EQUAL error  { yyerror("number  expected"); }
+	| KEMI DOT ONSEND_ROUTE_CALLBACK EQUAL STRING {
+			kemi_onsend_route_callback.s = $5;
+			kemi_onsend_route_callback.len = strlen($5);
+			if(kemi_onsend_route_callback.len==4
+					&& strcasecmp(kemi_onsend_route_callback.s, "none")==0) {
+				kemi_onsend_route_callback.s = "";
+				kemi_onsend_route_callback.len = 0;
+			}
+		}
     | MAX_RECURSIVE_LEVEL EQUAL NUMBER { set_max_recursive_level($3); }
     | MAX_BRANCHES_PARAM EQUAL NUMBER { sr_dst_max_branches = $3; }
     | LATENCY_LOG EQUAL intno { default_core_cfg.latency_log=$3; }
diff --git a/src/core/kemi.c b/src/core/kemi.c
index 8348756536..6e078af92c 100644
--- a/src/core/kemi.c
+++ b/src/core/kemi.c
@@ -42,6 +42,7 @@
 
 #define SR_KEMI_HNAME_SIZE 128
 
+str kemi_onsend_route_callback = str_init("ksr_onsend_route");
 /**
  *
  */
diff --git a/src/core/kemi.h b/src/core/kemi.h
index df8ae5ee69..8b33c44aa3 100644
--- a/src/core/kemi.h
+++ b/src/core/kemi.h
@@ -37,6 +37,8 @@
 
 #define SR_KEMI_PARAMS_MAX	6
 
+extern str kemi_onsend_route_callback;
+
 typedef struct sr_kemi {
 	str mname; /* sub-module name */
 	str fname; /* function name */
diff --git a/src/core/onsend.h b/src/core/onsend.h
index 16ea5ce17c..90dbf8c8f0 100644
--- a/src/core/onsend.h
+++ b/src/core/onsend.h
@@ -71,7 +71,9 @@ static inline int run_onsend(sip_msg_t* orig_msg, dest_info_t* dst,
 	}
 	ret=1;
 	// do if onsend_route{} or cfgengine exists
-	keng = sr_kemi_eng_get();
+	if(kemi_onsend_route_callback.len>0) {
+		keng = sr_kemi_eng_get();
+	}
 	if (onsend_rt.rlist[DEFAULT_RT] || keng){
 		onsnd_info.to=&dst->to;
 		onsnd_info.send_sock=dst->send_sock;




More information about the sr-dev mailing list