[sr-dev] git:master:45260517: core: kemi - exported KSR.add_tcp_alias() and KSR.add_tcp_alias_via()

Daniel-Constantin Mierla miconda at gmail.com
Fri Feb 23 09:57:55 CET 2018


Module: kamailio
Branch: master
Commit: 45260517ce4b97387d98bcc7c303bcdec55e4114
URL: https://github.com/kamailio/kamailio/commit/45260517ce4b97387d98bcc7c303bcdec55e4114

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-02-23T09:56:55+01:00

core: kemi - exported KSR.add_tcp_alias() and KSR.add_tcp_alias_via()

---

Modified: src/core/kemi.c

---

Diff:  https://github.com/kamailio/kamailio/commit/45260517ce4b97387d98bcc7c303bcdec55e4114.diff
Patch: https://github.com/kamailio/kamailio/commit/45260517ce4b97387d98bcc7c303bcdec55e4114.patch

---

diff --git a/src/core/kemi.c b/src/core/kemi.c
index 655d98a767..8348756536 100644
--- a/src/core/kemi.c
+++ b/src/core/kemi.c
@@ -933,6 +933,60 @@ static int sr_kemi_core_set_advertised_port(sip_msg_t *msg, str *port)
 	return SR_KEMI_TRUE;
 }
 
+/**
+ *
+ */
+static int sr_kemi_core_add_tcp_alias(sip_msg_t *msg, int port)
+{
+	if(msg==NULL) {
+		LM_WARN("invalid msg parameter\n");
+		return SR_KEMI_FALSE;
+	}
+
+#ifdef USE_TCP
+	if ( msg->rcv.proto==PROTO_TCP
+#ifdef USE_TLS
+				|| msg->rcv.proto==PROTO_TLS
+#endif
+			) {
+		if (tcpconn_add_alias(msg->rcv.proto_reserved1, port,
+							msg->rcv.proto)!=0){
+			LM_ERR("adding tcp alias failed\n");
+			return SR_KEMI_FALSE;
+		}
+	}
+#endif
+
+	return SR_KEMI_TRUE;
+}
+
+/**
+ *
+ */
+static int sr_kemi_core_add_tcp_alias_via(sip_msg_t *msg)
+{
+	if(msg==NULL) {
+		LM_WARN("invalid msg parameter\n");
+		return SR_KEMI_FALSE;
+	}
+
+#ifdef USE_TCP
+	if ( msg->rcv.proto==PROTO_TCP
+#ifdef USE_TLS
+				|| msg->rcv.proto==PROTO_TLS
+#endif
+			) {
+		if (tcpconn_add_alias(msg->rcv.proto_reserved1, msg->via1->port,
+							msg->rcv.proto)!=0){
+			LM_ERR("adding tcp alias failed\n");
+			return SR_KEMI_FALSE;
+		}
+	}
+#endif
+	return SR_KEMI_TRUE;
+}
+
+
 /**
  *
  */
@@ -1132,6 +1186,16 @@ static sr_kemi_t _sr_kemi_core[] = {
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
+	{ str_init(""), str_init("add_tcp_alias"),
+		SR_KEMIP_INT, sr_kemi_core_add_tcp_alias,
+		{ SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+	{ str_init(""), str_init("add_tcp_alias_via"),
+		SR_KEMIP_INT, sr_kemi_core_add_tcp_alias_via,
+		{ 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