Module: kamailio Branch: master Commit: e6eabea9e7806a708b0af8a45b7390eceb51dfdb URL: https://github.com/kamailio/kamailio/commit/e6eabea9e7806a708b0af8a45b7390ec...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2018-05-09T09:23:07+02:00
corex: exported kemi function to test if user-agend header is set
- KSR.has_user_agent() - return 1 if User-Agent has value; -1 otherwise
---
Modified: src/modules/corex/corex_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/e6eabea9e7806a708b0af8a45b7390ec... Patch: https://github.com/kamailio/kamailio/commit/e6eabea9e7806a708b0af8a45b7390ec...
---
diff --git a/src/modules/corex/corex_mod.c b/src/modules/corex/corex_mod.c index 6d6b03da29..b86876a191 100644 --- a/src/modules/corex/corex_mod.c +++ b/src/modules/corex/corex_mod.c @@ -751,7 +751,7 @@ static int w_via_add_xavp_params(sip_msg_t *msg, char *pflags, char *s2) }
/** - * + * */ static int ki_has_ruri_user(sip_msg_t *msg) { @@ -773,6 +773,28 @@ static int ki_has_ruri_user(sip_msg_t *msg) return -1; }
+/** + * + */ +static int ki_has_user_agent(sip_msg_t *msg) +{ + if(msg==NULL) + return -1; + + if(msg->user_agent==NULL && ((parse_headers(msg, HDR_USERAGENT_F, 0)==-1) + || (msg->user_agent==NULL))) + { + LM_DBG("no User-Agent header\n"); + return -1; + } + + if(msg->user_agent->body.s!=NULL && msg->user_agent->body.len>0) { + return 1; + } + + return -1; +} + /** * */ @@ -838,6 +860,11 @@ static sr_kemi_t sr_kemi_corex_exports[] = { { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } }, + { str_init("corex"), str_init("has_user_agent"), + SR_KEMIP_INT, ki_has_user_agent, + { 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 } } };