Module: kamailio
Branch: master
Commit: fb878ee5b90fa79363c75338c294e78a9bc9f73a
URL:
https://github.com/kamailio/kamailio/commit/fb878ee5b90fa79363c75338c294e78…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-11-24T13:25:43+01:00
kemix: added functions to get contact header uri
---
Modified: src/modules/kemix/kemix_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/fb878ee5b90fa79363c75338c294e78…
Patch:
https://github.com/kamailio/kamailio/commit/fb878ee5b90fa79363c75338c294e78…
---
diff --git a/src/modules/kemix/kemix_mod.c b/src/modules/kemix/kemix_mod.c
index ba56a6c16f..37854bfa86 100644
--- a/src/modules/kemix/kemix_mod.c
+++ b/src/modules/kemix/kemix_mod.c
@@ -32,6 +32,8 @@
#include "../../core/parser/parse_from.h"
#include "../../core/parser/parse_to.h"
#include "../../core/parser/digest/digest.h"
+#include "../../core/parser/contact/parse_contact.h"
+
#include "../../core/tcp_conn.h"
MODULE_VERSION
@@ -997,6 +999,61 @@ static int ki_kx_get_msgtype(sip_msg_t *msg)
}
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_cturi_mode(sip_msg_t *msg, int xmode)
+{
+ contact_t *c;
+
+ memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
+
+ if((parse_contact_headers(msg) < 0) || (msg->contact == NULL)
+ || (msg->contact->parsed == NULL)) {
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, xmode);
+ return &_sr_kemi_kx_xval;
+ }
+
+ if (((contact_body_t*)msg->contact->parsed)->star == 1) {
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, xmode);
+ return &_sr_kemi_kx_xval;
+ }
+
+ c = (((contact_body_t*)msg->contact->parsed)->contacts);
+ if(c==NULL || c->uri.s==NULL || c->uri.len<=0) {
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, xmode);
+ return &_sr_kemi_kx_xval;
+ }
+
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
+ _sr_kemi_kx_xval.v.s = c->uri;
+ return &_sr_kemi_kx_xval;
+}
+
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_cturi(sip_msg_t *msg)
+{
+ return ki_kx_get_cturi_mode(msg, SR_KEMI_XVAL_NULL_NONE);
+}
+
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_getw_cturi(sip_msg_t *msg)
+{
+ return ki_kx_get_cturi_mode(msg, SR_KEMI_XVAL_NULL_PRINT);
+}
+
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_gete_cturi(sip_msg_t *msg)
+{
+ return ki_kx_get_cturi_mode(msg, SR_KEMI_XVAL_NULL_EMPTY);
+}
+
/**
*
*/
@@ -1127,6 +1184,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_cturi"),
+ SR_KEMIP_XVAL, ki_kx_get_cturi,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("kx"), str_init("gete_cturi"),
+ SR_KEMIP_XVAL, ki_kx_gete_cturi,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("kx"), str_init("getw_cturi"),
+ SR_KEMIP_XVAL, ki_kx_getw_cturi,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
{ str_init("kx"), str_init("get_nhuri"),
SR_KEMIP_XVAL, ki_kx_get_nhuri,
{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,