[sr-dev] git:master:6520ee44: tm: KEMI expose t_relay_to_xxx protocol functions

Anthony Alba ascanio.alba7 at gmail.com
Mon Nov 30 09:02:39 CET 2020


Module: kamailio
Branch: master
Commit: 6520ee4422b24ca26f6d095d30cd2a0b0ea80aa2
URL: https://github.com/kamailio/kamailio/commit/6520ee4422b24ca26f6d095d30cd2a0b0ea80aa2

Author: Anthony Alba <ascanio.alba7 at gmail.com>
Committer: Anthony Alba <ascanio.alba7 at gmail.com>
Date: 2020-11-26T22:52:25+08:00

tm: KEMI expose t_relay_to_xxx protocol functions

In KEMI let's expose
    t_relay_to_tcp
    t_relay_to_udp
    t_relay_to_tls
to force the transport.

---

Modified: src/modules/tm/tm.c

---

Diff:  https://github.com/kamailio/kamailio/commit/6520ee4422b24ca26f6d095d30cd2a0b0ea80aa2.diff
Patch: https://github.com/kamailio/kamailio/commit/6520ee4422b24ca26f6d095d30cd2a0b0ea80aa2.patch

---

diff --git a/src/modules/tm/tm.c b/src/modules/tm/tm.c
index 99c932b417..d6bb017287 100644
--- a/src/modules/tm/tm.c
+++ b/src/modules/tm/tm.c
@@ -2897,6 +2897,29 @@ static int ki_t_relay(sip_msg_t *msg)
 	return _w_t_relay_to(msg, (struct proxy_l *)0, PROTO_NONE);
 }
 
+/**
+ *
+ */
+static int ki_t_relay_to_proto(sip_msg_t *msg, str *sproto)
+{
+
+	int proto = PROTO_NONE;
+
+	if (sproto != NULL && sproto->s != NULL && sproto->len == 3) {
+		if (strncasecmp(sproto->s, "UDP", 3) == 0) {
+			proto = PROTO_UDP;
+		} else if (strncasecmp(sproto->s, "TCP", 3) == 0) {
+			proto = PROTO_TCP;
+		} else if (strncasecmp(sproto->s, "TLS", 3)) {
+			proto = PROTO_TLS;
+		} else {
+			LM_ERR("t_relay_to_proto failed, bad protocol specified <%s>\n", sproto->s);
+			return E_UNSPEC;
+		}
+	}
+	return _w_t_relay_to(msg, (struct proxy_l *)0, proto);
+}
+
 /**
  *
  */
@@ -3226,6 +3249,11 @@ static sr_kemi_t tm_kemi_exports[] = {
 		{ SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
+	{ str_init("tm"), str_init("t_relay_to_proto"),
+		SR_KEMIP_INT, ki_t_relay_to_proto,
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
 	{ str_init("tm"), str_init("t_get_status_code"),
 		SR_KEMIP_INT, ki_t_get_status_code,
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,




More information about the sr-dev mailing list