Module: kamailio
Branch: master
Commit: 136f0b6afae9279b07ba827451cc5a80980134b5
URL:
https://github.com/kamailio/kamailio/commit/136f0b6afae9279b07ba827451cc5a8…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-02-13T12:47:46+01:00
core: kemi - exported more core functions
- add_local_rport(), set_advertised_address(addr),
set_advertised_port(port)
---
Modified: src/core/kemi.c
---
Diff:
https://github.com/kamailio/kamailio/commit/136f0b6afae9279b07ba827451cc5a8…
Patch:
https://github.com/kamailio/kamailio/commit/136f0b6afae9279b07ba827451cc5a8…
---
diff --git a/src/core/kemi.c b/src/core/kemi.c
index 5631f4b909..a24f1b869d 100644
--- a/src/core/kemi.c
+++ b/src/core/kemi.c
@@ -498,6 +498,20 @@ static int sr_kemi_core_force_rport(sip_msg_t *msg)
return SR_KEMI_TRUE;
}
+/**
+ *
+ */
+static int sr_kemi_core_add_local_rport(sip_msg_t *msg)
+{
+ if(msg==NULL) {
+ LM_WARN("invalid msg parameter\n");
+ return SR_KEMI_FALSE;
+ }
+
+ msg->msg_flags|=FL_ADD_LOCAL_RPORT;
+ return SR_KEMI_TRUE;
+}
+
/**
*
*/
@@ -696,6 +710,68 @@ static int sr_kemi_core_set_reply_no_connect(sip_msg_t *msg)
return SR_KEMI_TRUE;
}
+/**
+ *
+ */
+static int sr_kemi_core_set_advertised_address(sip_msg_t *msg, str *addr)
+{
+#define SR_ADV_ADDR_SIZE 128
+ static char _sr_adv_addr_buf[SR_ADV_ADDR_SIZE];
+
+ if(addr==NULL || addr->s==NULL) {
+ LM_ERR("invalid addr parameter\n");
+ return SR_KEMI_FALSE;
+ }
+
+ if(addr->len>=SR_ADV_ADDR_SIZE) {
+ LM_ERR("addr parameter is too large\n");
+ return SR_KEMI_FALSE;
+ }
+
+ if(msg==NULL) {
+ LM_WARN("invalid msg parameter\n");
+ return SR_KEMI_FALSE;
+ }
+
+ memcpy(_sr_adv_addr_buf, addr->s, addr->len);
+ _sr_adv_addr_buf[addr->len] = '\0';
+ msg->set_global_address.s = _sr_adv_addr_buf;
+ msg->set_global_address.len = addr->len;
+
+ return SR_KEMI_TRUE;
+}
+
+/**
+ *
+ */
+static int sr_kemi_core_set_advertised_port(sip_msg_t *msg, str *port)
+{
+#define SR_ADV_PORT_SIZE 8
+ static char _sr_adv_port_buf[SR_ADV_PORT_SIZE];
+
+ if(port==NULL || port->s==NULL) {
+ LM_ERR("invalid port parameter\n");
+ return SR_KEMI_FALSE;
+ }
+
+ if(port->len>=SR_ADV_PORT_SIZE) {
+ LM_ERR("port parameter is too large\n");
+ return SR_KEMI_FALSE;
+ }
+
+ if(msg==NULL) {
+ LM_WARN("invalid msg parameter\n");
+ return SR_KEMI_FALSE;
+ }
+
+ memcpy(_sr_adv_port_buf, port->s, port->len);
+ _sr_adv_port_buf[port->len] = '\0';
+ msg->set_global_port.s = _sr_adv_port_buf;
+ msg->set_global_port.len = port->len;
+
+ return SR_KEMI_TRUE;
+}
+
/**
*
*/
@@ -825,6 +901,11 @@ static sr_kemi_t _sr_kemi_core[] = {
{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init(""), str_init("add_local_rport"),
+ SR_KEMIP_BOOL, sr_kemi_core_add_local_rport,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
{ str_init(""), str_init("is_method"),
SR_KEMIP_BOOL, sr_kemi_core_is_method,
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
@@ -860,6 +941,16 @@ static sr_kemi_t _sr_kemi_core[] = {
{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init(""), str_init("set_advertised_address"),
+ SR_KEMIP_INT, sr_kemi_core_set_advertised_address,
+ { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init(""), str_init("set_advertised_port"),
+ SR_KEMIP_INT, sr_kemi_core_set_advertised_port,
+ { SR_KEMIP_STR, 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 } }
};