Module: kamailio
Branch: master
Commit: 3806ca121194d54bbd03ff257ec62505b15d0941
URL:
https://github.com/kamailio/kamailio/commit/3806ca121194d54bbd03ff257ec6250…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-07-11T18:01:48+02:00
rr: exported is_direction() to kemi framework
- rework of the patch from GH #1589
---
Modified: src/modules/rr/rr_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/3806ca121194d54bbd03ff257ec6250…
Patch:
https://github.com/kamailio/kamailio/commit/3806ca121194d54bbd03ff257ec6250…
---
diff --git a/src/modules/rr/rr_mod.c b/src/modules/rr/rr_mod.c
index eac10d272b..36b1c046a8 100644
--- a/src/modules/rr/rr_mod.c
+++ b/src/modules/rr/rr_mod.c
@@ -418,6 +418,28 @@ static int w_is_direction(struct sip_msg *msg,char *dir, char *foo)
return ((is_direction(msg,(int)(long)dir)==0)?1:-1);
}
+static int ki_is_direction(sip_msg_t *msg, str *dir)
+{
+ int n;
+
+ if (!append_fromtag) {
+ LM_ERR("usage of \"is_direction\" function requires parameter"
+ "\"append_fromtag\" enabled!!");
+ return E_CFG;
+ }
+
+ if (dir->len==10 && strncasecmp(dir->s, "downstream", 10)==0) {
+ n = RR_FLOW_DOWNSTREAM;
+ } else if (dir->len==8 && strncasecmp(dir->s, "upstream", 8)==0)
{
+ n = RR_FLOW_UPSTREAM;
+ } else {
+ LM_ERR("unknown direction '%.*s' - use 'downstream' or
'upstream'\n",
+ dir->len, dir->s);
+ return E_CFG;
+ }
+
+ return ((is_direction(msg,n)==0)?1:-1);
+}
/*
* Return the URI of the topmost Route-Header.
@@ -720,7 +742,11 @@ static sr_kemi_t sr_kemi_rr_exports[] = {
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
-
+ { str_init("rr"), str_init("is_direction"),
+ SR_KEMIP_INT, ki_is_direction,
+ { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
};