Module: kamailio
Branch: master
Commit: dabcabd3025c2a8988379a40ca65c56fe9b2838b
URL:
https://github.com/kamailio/kamailio/commit/dabcabd3025c2a8988379a40ca65c56…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-05-09T09:07:49+02:00
corex: exported helper function to check if RURI has user field
- KSR.has_ruri_user() - return 1 if user field is set, -1 otherwise
---
Modified: src/modules/corex/corex_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/dabcabd3025c2a8988379a40ca65c56…
Patch:
https://github.com/kamailio/kamailio/commit/dabcabd3025c2a8988379a40ca65c56…
---
diff --git a/src/modules/corex/corex_mod.c b/src/modules/corex/corex_mod.c
index 0d7ce35857..6d6b03da29 100644
--- a/src/modules/corex/corex_mod.c
+++ b/src/modules/corex/corex_mod.c
@@ -30,6 +30,7 @@
#include "../../core/lvalue.h"
#include "../../core/pvar.h"
#include "../../core/kemi.h"
+#include "../../core/parser/parse_uri.h"
#include "corex_lib.h"
#include "corex_rpc.h"
@@ -749,6 +750,29 @@ static int w_via_add_xavp_params(sip_msg_t *msg, char *pflags, char
*s2)
return ki_via_add_xavp_params(msg, fval);
}
+/**
+ *
+ */
+static int ki_has_ruri_user(sip_msg_t *msg)
+{
+ if(msg==NULL)
+ return -1;
+
+ if(msg->first_line.type == SIP_REPLY) /* REPLY doesnt have a ruri */
+ return -1;
+
+ if(msg->parsed_uri_ok==0 /* R-URI not parsed*/ &&
parse_sip_msg_uri(msg)<0) {
+ LM_ERR("failed to parse the R-URI\n");
+ return -1;
+ }
+
+ if(msg->parsed_uri.user.s!=NULL && msg->parsed_uri.user.len>0) {
+ return 1;
+ }
+
+ return -1;
+}
+
/**
*
*/
@@ -809,6 +833,12 @@ static sr_kemi_t sr_kemi_corex_exports[] = {
{ SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init("corex"), str_init("has_ruri_user"),
+ SR_KEMIP_INT, ki_has_ruri_user,
+ { SR_KEMIP_NONE, 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 } }
};
/* clang-format on */