[sr-dev] git:master:067fbd44: kemix: added kemi functions to return user-agent header body
Daniel-Constantin Mierla
miconda at gmail.com
Wed Jun 5 11:51:54 CEST 2019
Module: kamailio
Branch: master
Commit: 067fbd44e110c0f0b95d43bc65d83a47385601ff
URL: https://github.com/kamailio/kamailio/commit/067fbd44e110c0f0b95d43bc65d83a47385601ff
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-06-05T11:51:24+02:00
kemix: added kemi functions to return user-agent header body
- shortcut to improve tests for security in scripts
---
Modified: src/modules/kemix/kemix_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/067fbd44e110c0f0b95d43bc65d83a47385601ff.diff
Patch: https://github.com/kamailio/kamailio/commit/067fbd44e110c0f0b95d43bc65d83a47385601ff.patch
---
diff --git a/src/modules/kemix/kemix_mod.c b/src/modules/kemix/kemix_mod.c
index ff675442d4..4f69098b8b 100644
--- a/src/modules/kemix/kemix_mod.c
+++ b/src/modules/kemix/kemix_mod.c
@@ -272,6 +272,51 @@ static sr_kemi_xval_t* ki_kx_get_rhoste(sip_msg_t *msg)
return ki_kx_get_ruri_attr(msg, 2, SR_KEMI_XVAL_NULL_EMPTY);
}
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_ua_mode(sip_msg_t *msg, int rmode)
+{
+ memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
+ if(msg==NULL) {
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, rmode);
+ return &_sr_kemi_kx_xval;
+ }
+ if(msg->user_agent==NULL && ((parse_headers(msg, HDR_USERAGENT_F, 0)==-1)
+ || (msg->user_agent==NULL))) {
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, rmode);
+ return &_sr_kemi_kx_xval;
+ }
+
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
+ _sr_kemi_kx_xval.v.s = msg->user_agent->body;
+ return &_sr_kemi_kx_xval;
+}
+
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_ua(sip_msg_t *msg)
+{
+ return ki_kx_get_ua_mode(msg, SR_KEMI_XVAL_NULL_NONE);
+}
+
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_gete_ua(sip_msg_t *msg)
+{
+ return ki_kx_get_ua_mode(msg, SR_KEMI_XVAL_NULL_EMPTY);
+}
+
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_getw_ua(sip_msg_t *msg)
+{
+ return ki_kx_get_ua_mode(msg, SR_KEMI_XVAL_NULL_PRINT);
+}
+
/**
*
*/
@@ -327,6 +372,21 @@ static sr_kemi_t sr_kemi_kx_exports[] = {
{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init("kx"), str_init("get_ua"),
+ SR_KEMIP_XVAL, ki_kx_get_ua,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("kx"), str_init("gete_ua"),
+ SR_KEMIP_XVAL, ki_kx_gete_ua,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("kx"), str_init("getw_ua"),
+ SR_KEMIP_XVAL, ki_kx_getw_ua,
+ { 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 } }
};
More information about the sr-dev
mailing list