Module: kamailio
Branch: master
Commit: 06656adee855dd1033fe7cdd631124d48b0c11c6
URL:
https://github.com/kamailio/kamailio/commit/06656adee855dd1033fe7cdd631124d…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-02-26T14:54:04+01:00
kemix: exported get_srcuri() to kemi
- return source address in uri format, similar to $su
---
Modified: src/modules/kemix/kemix_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/06656adee855dd1033fe7cdd631124d…
Patch:
https://github.com/kamailio/kamailio/commit/06656adee855dd1033fe7cdd631124d…
---
diff --git a/src/modules/kemix/kemix_mod.c b/src/modules/kemix/kemix_mod.c
index 5cb7b20e3f..1633188089 100644
--- a/src/modules/kemix/kemix_mod.c
+++ b/src/modules/kemix/kemix_mod.c
@@ -27,6 +27,7 @@
#include "../../core/sr_module.h"
#include "../../core/dprint.h"
+#include "../../core/pvapi.h"
#include "../../core/kemi.h"
#include "../../core/ppcfg.h"
#include "../../core/parser/parse_uri.h"
@@ -1066,6 +1067,39 @@ 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);
}
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_srcuri(sip_msg_t *msg)
+{
+ str ssock;
+
+ if(msg==NULL) {
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_EMPTY);
+ return &_sr_kemi_kx_xval;
+
+ }
+
+ if(get_src_uri(msg, 0, &ssock)<0) {
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_EMPTY);
+ return &_sr_kemi_kx_xval;
+ }
+
+ if (ssock.len + 1 >= pv_get_buffer_size()) {
+ LM_ERR("local buffer size exceeded\n");
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_EMPTY);
+ return &_sr_kemi_kx_xval;
+ }
+
+ _sr_kemi_kx_xval.v.s.s = pv_get_buffer();
+ strncpy(_sr_kemi_kx_xval.v.s.s, ssock.s, ssock.len);
+ _sr_kemi_kx_xval.v.s.len = ssock.len;
+ _sr_kemi_kx_xval.v.s.s[_sr_kemi_kx_xval.v.s.len] = '\0';
+
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
+ return &_sr_kemi_kx_xval;
+}
+
/**
*
*/
@@ -1301,6 +1335,11 @@ 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_srcuri"),
+ SR_KEMIP_XVAL, ki_kx_get_srcuri,
+ { 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,