Browse code

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.

Anthony Alba authored on 26/11/2020 14:39:08
Showing 1 changed files
... ...
@@ -2897,6 +2897,29 @@ static int ki_t_relay(sip_msg_t *msg)
2897 2897
 	return _w_t_relay_to(msg, (struct proxy_l *)0, PROTO_NONE);
2898 2898
 }
2899 2899
 
2900
+/**
2901
+ *
2902
+ */
2903
+static int ki_t_relay_to_proto(sip_msg_t *msg, str *sproto)
2904
+{
2905
+
2906
+	int proto = PROTO_NONE;
2907
+
2908
+	if (sproto != NULL && sproto->s != NULL && sproto->len == 3) {
2909
+		if (strncasecmp(sproto->s, "UDP", 3) == 0) {
2910
+			proto = PROTO_UDP;
2911
+		} else if (strncasecmp(sproto->s, "TCP", 3) == 0) {
2912
+			proto = PROTO_TCP;
2913
+		} else if (strncasecmp(sproto->s, "TLS", 3)) {
2914
+			proto = PROTO_TLS;
2915
+		} else {
2916
+			LM_ERR("t_relay_to_proto failed, bad protocol specified <%s>\n", sproto->s);
2917
+			return E_UNSPEC;
2918
+		}
2919
+	}
2920
+	return _w_t_relay_to(msg, (struct proxy_l *)0, proto);
2921
+}
2922
+
2900 2923
 /**
2901 2924
  *
2902 2925
  */
... ...
@@ -3226,6 +3249,11 @@ static sr_kemi_t tm_kemi_exports[] = {
3226 3249
 		{ SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_NONE,
3227 3250
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3228 3251
 	},
3252
+	{ str_init("tm"), str_init("t_relay_to_proto"),
3253
+		SR_KEMIP_INT, ki_t_relay_to_proto,
3254
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
3255
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3256
+	},
3229 3257
 	{ str_init("tm"), str_init("t_get_status_code"),
3230 3258
 		SR_KEMIP_INT, ki_t_get_status_code,
3231 3259
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,