Module: kamailio
Branch: master
Commit: 28b939cc72cdaf6625caa4f7c2d72b15cf57949d
URL:
https://github.com/kamailio/kamailio/commit/28b939cc72cdaf6625caa4f7c2d72b1…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-08-01T11:15:26+02:00
kemix: functions to get status code for reply
---
Modified: src/modules/kemix/kemix_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/28b939cc72cdaf6625caa4f7c2d72b1…
Patch:
https://github.com/kamailio/kamailio/commit/28b939cc72cdaf6625caa4f7c2d72b1…
---
diff --git a/src/modules/kemix/kemix_mod.c b/src/modules/kemix/kemix_mod.c
index a31588eb70..9265d36890 100644
--- a/src/modules/kemix/kemix_mod.c
+++ b/src/modules/kemix/kemix_mod.c
@@ -584,6 +584,39 @@ static sr_kemi_xval_t* ki_kx_get_method(sip_msg_t *msg)
return &_sr_kemi_kx_xval;
}
+/**
+ *
+ */
+static int ki_kx_get_status(sip_msg_t *msg)
+{
+ if(msg==NULL) {
+ return -1;
+ }
+ if(msg->first_line.type != SIP_REPLY) {
+ return -1;
+ }
+ return (int)msg->first_line.u.reply.statuscode;
+}
+
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_gets_status(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_NONE);
+ return &_sr_kemi_kx_xval;
+ }
+ if(msg->first_line.type != SIP_REPLY) {
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, SR_KEMI_XVAL_NULL_NONE);
+ return &_sr_kemi_kx_xval;
+ }
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
+ _sr_kemi_kx_xval.v.s = msg->first_line.u.reply.status;
+ return &_sr_kemi_kx_xval;
+}
+
/**
*
*/
@@ -734,6 +767,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_status"),
+ SR_KEMIP_INT, ki_kx_get_status,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("kx"), str_init("gets_status"),
+ SR_KEMIP_XVAL, ki_kx_gets_status,
+ { 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 } }
};