Module: kamailio
Branch: master
Commit: 5e9e991cb11c85ad5cf6b72802728a42d70edd4e
URL:
https://github.com/kamailio/kamailio/commit/5e9e991cb11c85ad5cf6b72802728a4…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-07-08T17:28:46+02:00
kemix: added functions to get proto string and id
---
Modified: src/modules/kemix/kemix_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/5e9e991cb11c85ad5cf6b72802728a4…
Patch:
https://github.com/kamailio/kamailio/commit/5e9e991cb11c85ad5cf6b72802728a4…
---
diff --git a/src/modules/kemix/kemix_mod.c b/src/modules/kemix/kemix_mod.c
index aef7fc75d1..fd27d47fca 100644
--- a/src/modules/kemix/kemix_mod.c
+++ b/src/modules/kemix/kemix_mod.c
@@ -450,6 +450,38 @@ static sr_kemi_xval_t* ki_kx_get_rcvport(sip_msg_t *msg)
return &_sr_kemi_kx_xval;
}
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_proto(sip_msg_t *msg)
+{
+ memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
+ if(msg==NULL) {
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_EMPTY);
+ return &_sr_kemi_kx_xval;
+ }
+
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
+ if(get_valid_proto_string(msg->rcv.proto, 0, 0, &_sr_kemi_kx_xval.v.s)<0) {
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_EMPTY);
+ }
+
+ return &_sr_kemi_kx_xval;
+}
+
+/**
+ *
+ */
+static int ki_kx_get_protoid(sip_msg_t *msg)
+{
+ if(msg==NULL) {
+ return -1;
+ }
+
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
+ return (int)msg->rcv.proto;
+}
+
/**
*
*/
@@ -570,6 +602,16 @@ 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_proto"),
+ SR_KEMIP_XVAL, ki_kx_get_proto,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("kx"), str_init("get_protoid"),
+ SR_KEMIP_INT, ki_kx_get_protoid,
+ { 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 } }
};