[sr-dev] git:master:003871b0: kemix: exported functions to get common URI values via KSR.kx
Daniel-Constantin Mierla
miconda at gmail.com
Mon May 27 11:57:40 CEST 2019
Module: kamailio
Branch: master
Commit: 003871b0a81afcc029c34e6e0ca26b6efff38857
URL: https://github.com/kamailio/kamailio/commit/003871b0a81afcc029c34e6e0ca26b6efff38857
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-05-27T11:56:52+02:00
kemix: exported functions to get common URI values via KSR.kx
---
Modified: src/modules/kemix/kemix_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/003871b0a81afcc029c34e6e0ca26b6efff38857.diff
Patch: https://github.com/kamailio/kamailio/commit/003871b0a81afcc029c34e6e0ca26b6efff38857.patch
---
diff --git a/src/modules/kemix/kemix_mod.c b/src/modules/kemix/kemix_mod.c
index f342ef6b53..7ed5fe9c98 100644
--- a/src/modules/kemix/kemix_mod.c
+++ b/src/modules/kemix/kemix_mod.c
@@ -28,6 +28,8 @@
#include "../../core/dprint.h"
#include "../../core/kemi.h"
#include "../../core/parser/parse_uri.h"
+#include "../../core/parser/parse_from.h"
+#include "../../core/parser/parse_to.h"
MODULE_VERSION
@@ -83,6 +85,95 @@ static sr_kemi_xval_t* ki_kx_get_ruri(sip_msg_t *msg)
return &_sr_kemi_kx_xval;
}
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_ouri(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, 0);
+ return &_sr_kemi_kx_xval;
+ }
+
+ if(msg->first_line.type == SIP_REPLY) {
+ /* REPLY doesnt have a ruri */
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, 0);
+ return &_sr_kemi_kx_xval;
+ }
+
+ if(msg->parsed_uri_ok==0 /* R-URI not parsed*/ && parse_sip_msg_uri(msg)<0) {
+ LM_ERR("failed to parse the R-URI\n");
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, 0);
+ return &_sr_kemi_kx_xval;
+ }
+
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
+ _sr_kemi_kx_xval.v.s = msg->first_line.u.request.uri;
+ return &_sr_kemi_kx_xval;
+}
+
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_furi(sip_msg_t *msg)
+{
+ to_body_t *xto = NULL;
+
+ memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
+
+ if(msg==NULL) {
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, 0);
+ return &_sr_kemi_kx_xval;
+ }
+ if(parse_from_header(msg)<0) {
+ LM_ERR("cannot parse From header\n");
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, 0);
+ return &_sr_kemi_kx_xval;
+ }
+ if(msg->from==NULL || get_from(msg)==NULL) {
+ LM_DBG("no From header\n");
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, 0);
+ return &_sr_kemi_kx_xval;
+ }
+
+ xto = get_from(msg);
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
+ _sr_kemi_kx_xval.v.s = xto->uri;
+ return &_sr_kemi_kx_xval;
+}
+
+/**
+ *
+ */
+static sr_kemi_xval_t* ki_kx_get_turi(sip_msg_t *msg)
+{
+ to_body_t *xto = NULL;
+
+ memset(&_sr_kemi_kx_xval, 0, sizeof(sr_kemi_xval_t));
+
+ if(msg==NULL) {
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, 0);
+ return &_sr_kemi_kx_xval;
+ }
+ if(parse_to_header(msg)<0) {
+ LM_ERR("cannot parse To header\n");
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, 0);
+ return &_sr_kemi_kx_xval;
+ }
+ if(msg->to==NULL || get_to(msg)==NULL) {
+ LM_DBG("no To header\n");
+ sr_kemi_xval_null(&_sr_kemi_kx_xval, 0);
+ return &_sr_kemi_kx_xval;
+ }
+
+ xto = get_to(msg);
+ _sr_kemi_kx_xval.vtype = SR_KEMIP_STR;
+ _sr_kemi_kx_xval.v.s = xto->uri;
+ return &_sr_kemi_kx_xval;
+}
+
/**
*
*/
@@ -93,6 +184,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_ouri"),
+ SR_KEMIP_XVAL, ki_kx_get_ouri,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("kx"), str_init("get_furi"),
+ SR_KEMIP_XVAL, ki_kx_get_furi,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("kx"), str_init("get_turi"),
+ SR_KEMIP_XVAL, ki_kx_get_turi,
+ { 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 } }
};
More information about the sr-dev
mailing list