Module: kamailio
Branch: master
Commit: 77b0c9355b13013ddeb3cab62de1bb21e0eb74f7
URL:
https://github.com/kamailio/kamailio/commit/77b0c9355b13013ddeb3cab62de1bb2…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-03-12T12:56:24+01:00
core: new parameter kemi.reply_route_callback
- set the name of kemi callback function to be executed on receiving a
sip reply (equivalent of reply_route)
- default: ksr_reply_route
- set to empty or "none" to skip execution of this callback
---
Modified: src/core/cfg.lex
Modified: src/core/cfg.y
Modified: src/core/kemi.c
Modified: src/core/kemi.h
Modified: src/core/receive.c
---
Diff:
https://github.com/kamailio/kamailio/commit/77b0c9355b13013ddeb3cab62de1bb2…
Patch:
https://github.com/kamailio/kamailio/commit/77b0c9355b13013ddeb3cab62de1bb2…
---
diff --git a/src/core/cfg.lex b/src/core/cfg.lex
index abe2c250f4..033512c845 100644
--- a/src/core/cfg.lex
+++ b/src/core/cfg.lex
@@ -447,6 +447,7 @@ SERVER_ID "server_id"
KEMI "kemi"
ONSEND_ROUTE_CALLBACK "onsend_route_callback"
+REPLY_ROUTE_CALLBACK "reply_route_callback"
MAX_RECURSIVE_LEVEL "max_recursive_level"
MAX_BRANCHES_PARAM "max_branches"|"max_branches"
@@ -933,6 +934,7 @@ IMPORTFILE "import_file"
return VERBOSE_STARTUP; }
<INITIAL>{SERVER_ID} { count(); yylval.strval=yytext; return SERVER_ID;}
<INITIAL>{KEMI} { count(); yylval.strval=yytext; return KEMI;}
+<INITIAL>{REPLY_ROUTE_CALLBACK} { count(); yylval.strval=yytext; return
REPLY_ROUTE_CALLBACK;}
<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;}
diff --git a/src/core/cfg.y b/src/core/cfg.y
index e8f76d3537..99bac9c4f1 100644
--- a/src/core/cfg.y
+++ b/src/core/cfg.y
@@ -484,6 +484,7 @@ extern char *default_routename;
%token SERVER_ID
%token KEMI
%token ONSEND_ROUTE_CALLBACK
+%token REPLY_ROUTE_CALLBACK
%token MAX_RECURSIVE_LEVEL
%token MAX_BRANCHES_PARAM
%token LATENCY_CFG_LOG
@@ -1569,7 +1570,7 @@ assign_stm:
| VERBOSE_STARTUP EQUAL NUMBER { ksr_verbose_startup=$3; }
| VERBOSE_STARTUP EQUAL error { yyerror("boolean value expected"); }
| SERVER_ID EQUAL NUMBER { server_id=$3; }
- | SERVER_ID EQUAL error { yyerror("number expected"); }
+ | 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);
@@ -1579,6 +1580,17 @@ assign_stm:
kemi_onsend_route_callback.len = 0;
}
}
+ | KEMI DOT ONSEND_ROUTE_CALLBACK EQUAL error { yyerror("string expected"); }
+ | KEMI DOT REPLY_ROUTE_CALLBACK EQUAL STRING {
+ kemi_reply_route_callback.s = $5;
+ kemi_reply_route_callback.len = strlen($5);
+ if(kemi_reply_route_callback.len==4
+ && strcasecmp(kemi_reply_route_callback.s, "none")==0) {
+ kemi_reply_route_callback.s = "";
+ kemi_reply_route_callback.len = 0;
+ }
+ }
+ | KEMI DOT REPLY_ROUTE_CALLBACK EQUAL error { yyerror("string expected"); }
| 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 6e078af92c..625c55905c 100644
--- a/src/core/kemi.c
+++ b/src/core/kemi.c
@@ -42,7 +42,10 @@
#define SR_KEMI_HNAME_SIZE 128
+/* names for kemi callback functions */
str kemi_onsend_route_callback = str_init("ksr_onsend_route");
+str kemi_reply_route_callback = str_init("ksr_reply_route");
+
/**
*
*/
diff --git a/src/core/kemi.h b/src/core/kemi.h
index 8b33c44aa3..89327e11df 100644
--- a/src/core/kemi.h
+++ b/src/core/kemi.h
@@ -38,6 +38,7 @@
#define SR_KEMI_PARAMS_MAX 6
extern str kemi_onsend_route_callback;
+extern str kemi_reply_route_callback;
typedef struct sr_kemi {
str mname; /* sub-module name */
diff --git a/src/core/receive.c b/src/core/receive.c
index 77294673ef..a4f28edaad 100644
--- a/src/core/receive.c
+++ b/src/core/receive.c
@@ -326,7 +326,9 @@ int receive_msg(char *buf, unsigned int len, struct receive_info
*rcv_info)
}
/* exec the onreply routing script */
- keng = sr_kemi_eng_get();
+ if(kemi_reply_route_callback.len>0) {
+ keng = sr_kemi_eng_get();
+ }
if(onreply_rt.rlist[DEFAULT_RT] != NULL || keng != NULL) {
set_route_type(CORE_ONREPLY_ROUTE);
ret = 1;