Module: kamailio
Branch: master
Commit: 09ac5b6c5330bc0a9eb4617d2385745b4a09c116
URL:
https://github.com/kamailio/kamailio/commit/09ac5b6c5330bc0a9eb4617d2385745…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-12-15T14:53:00+01:00
kemix: exported kx.get_sas()
- return source address in socket format, similar to $sas
---
Modified: src/modules/kemix/kemix_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/09ac5b6c5330bc0a9eb4617d2385745…
Patch:
https://github.com/kamailio/kamailio/commit/09ac5b6c5330bc0a9eb4617d2385745…
---
diff --git a/src/modules/kemix/kemix_mod.c b/src/modules/kemix/kemix_mod.c
index 2b6f6ec9c2..089ad5e326 100644
--- a/src/modules/kemix/kemix_mod.c
+++ b/src/modules/kemix/kemix_mod.c
@@ -1100,6 +1100,39 @@ static sr_kemi_xval_t* ki_kx_get_srcuri(sip_msg_t *msg)
return &_sr_kemi_kx_xval;
}
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_sas(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_address_socket(msg, &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;
+}
+
/**
*
*/
@@ -1370,6 +1403,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_sas"),
+ SR_KEMIP_XVAL, ki_kx_get_sas,
+ { 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,