Browse code

tm: exported t_relay_to_*() variants to kemi framework

Daniel-Constantin Mierla authored on 14/03/2019 07:40:55
Showing 1 changed files
... ...
@@ -2793,6 +2793,71 @@ static int ki_t_relay(sip_msg_t *msg)
2793 2793
 /**
2794 2794
  *
2795 2795
  */
2796
+static int ki_t_relay_to_proxy_flags(sip_msg_t *msg, str *sproxy, int rflags)
2797
+{
2798
+	proxy_l_t *proxy = NULL;
2799
+	int ret = -1;
2800
+	int proto;
2801
+	str host;
2802
+	int port;
2803
+
2804
+	if (sproxy != NULL && sproxy->s != NULL && sproxy->len > 0) {
2805
+		if (parse_phostport(sproxy->s, &host.s, &host.len, &port, &proto)!=0) {
2806
+			LM_CRIT("invalid proxy addr parameter <%s>\n", sproxy->s);
2807
+			return E_UNSPEC;
2808
+		}
2809
+
2810
+		proxy = mk_proxy(&host, port, proto);
2811
+		if (proxy==0) {
2812
+			LM_ERR("failed to build proxy structure for <%.*s>\n",
2813
+				sproxy->len, sproxy->s );
2814
+			return E_UNSPEC;
2815
+		}
2816
+	}
2817
+	if(rflags!=0) {
2818
+		/* no auto 100 trying */
2819
+		if(rflags&1) {
2820
+			t_set_auto_inv_100(msg, 0);
2821
+		}
2822
+		/* no auto negative reply */
2823
+		if(rflags&2) {
2824
+			t_set_disable_internal_reply(msg, 1);
2825
+		}
2826
+		/* no dns failover */
2827
+		if(rflags&4) {
2828
+			t_set_disable_failover(msg, 1);
2829
+		}
2830
+	}
2831
+
2832
+	ret = _w_t_relay_to(msg, proxy, PROTO_NONE);
2833
+
2834
+	if(proxy != NULL) {
2835
+		free_proxy(proxy);
2836
+		pkg_free(proxy);
2837
+	}
2838
+
2839
+	return ret;
2840
+}
2841
+
2842
+/**
2843
+ *
2844
+ */
2845
+static int ki_t_relay_to_proxy(sip_msg_t *msg, str *sproxy)
2846
+{
2847
+	return ki_t_relay_to_proxy_flags(msg, sproxy, 0);
2848
+}
2849
+
2850
+/**
2851
+ *
2852
+ */
2853
+static int ki_t_relay_to_flags(sip_msg_t *msg, int rflags)
2854
+{
2855
+	return ki_t_relay_to_proxy_flags(msg, NULL, rflags);
2856
+}
2857
+
2858
+/**
2859
+ *
2860
+ */
2796 2861
 static sr_kemi_t tm_kemi_exports[] = {
2797 2862
 	{ str_init("tm"), str_init("t_relay"),
2798 2863
 		SR_KEMIP_INT, ki_t_relay,
... ...
@@ -3019,6 +3084,21 @@ static sr_kemi_t tm_kemi_exports[] = {
3019 3019
 		{ SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
3020 3020
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3021 3021
 	},
3022
+	{ str_init("tm"), str_init("t_relay_to_proxy"),
3023
+		SR_KEMIP_INT, ki_t_relay_to_proxy,
3024
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
3025
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3026
+	},
3027
+	{ str_init("tm"), str_init("t_relay_to_flags"),
3028
+		SR_KEMIP_INT, ki_t_relay_to_flags,
3029
+		{ SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
3030
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3031
+	},
3032
+	{ str_init("tm"), str_init("t_relay_to_proxy_flags"),
3033
+		SR_KEMIP_INT, ki_t_relay_to_proxy_flags,
3034
+		{ SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_NONE,
3035
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3036
+	},
3022 3037
 
3023 3038
 
3024 3039
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }