Browse code

- added tls support: get_proto support for tls uri2proxy sips uris support (uri->secure) t_relay_to_tls, t_replicate_tls, t_forward_nonack_tls - added #ifdef USE_TLS, USE_TCP

Andrei Pelinescu-Onciul authored on 07/07/2003 20:53:21
Showing 3 changed files
... ...
@@ -64,6 +64,9 @@
64 64
  *  2003-03-30  set_kr for requests only (jiri)
65 65
  *  2003-04-05  s/reply_route/failure_route, onreply_route introduced (jiri)
66 66
  *  2003-04-14  use protocol from uri (jiri)
67
+ *  2003-07-07  added t_relay_to_tls, t_replicate_tls, t_forward_nonack_tls
68
+ *              added #ifdef USE_TCP, USE_TLS
69
+ *              removed t_relay_{udp,tcp,tls} (andrei)
67 70
  */
68 71
 
69 72
 
... ...
@@ -109,20 +112,38 @@ inline static int w_t_newtran(struct sip_msg* p_msg, char* foo, char* bar );
109 112
 inline static int w_t_relay( struct sip_msg  *p_msg , char *_foo, char *_bar);
110 113
 inline static int w_t_relay_to_udp( struct sip_msg  *p_msg , char *proxy, 
111 114
 				    char *);
115
+#ifdef USE_TCP
112 116
 inline static int w_t_relay_to_tcp( struct sip_msg  *p_msg , char *proxy,
113 117
 				    char *);
118
+#endif
119
+#ifdef USE_TLS
120
+inline static int w_t_relay_to_tls( struct sip_msg  *p_msg , char *proxy,
121
+				    char *);
122
+#endif
114 123
 inline static int w_t_replicate( struct sip_msg  *p_msg , 
115 124
 				 char *proxy, /* struct proxy_l *proxy expected */
116 125
 				 char *_foo       /* nothing expected */ );
117 126
 inline static int w_t_replicate_udp( struct sip_msg  *p_msg , 
118 127
 				     char *proxy, /* struct proxy_l *proxy expected */
119 128
 				     char *_foo       /* nothing expected */ );
129
+#ifdef USE_TCP
120 130
 inline static int w_t_replicate_tcp( struct sip_msg  *p_msg , 
121 131
 				     char *proxy, /* struct proxy_l *proxy expected */
122 132
 				     char *_foo       /* nothing expected */ );
133
+#endif
134
+#ifdef USE_TLS
135
+inline static int w_t_replicate_tls( struct sip_msg  *p_msg , 
136
+				     char *proxy, /* struct proxy_l *proxy expected */
137
+				     char *_foo       /* nothing expected */ );
138
+#endif
123 139
 inline static int w_t_forward_nonack(struct sip_msg* msg, char* str, char* );
124 140
 inline static int w_t_forward_nonack_udp(struct sip_msg* msg, char* str,char*);
141
+#ifdef USE_TCP
125 142
 inline static int w_t_forward_nonack_tcp(struct sip_msg* msg, char* str,char*);
143
+#endif
144
+#ifdef USE_TLS
145
+inline static int w_t_forward_nonack_tls(struct sip_msg* msg, char* str,char*);
146
+#endif
126 147
 inline static int fixup_hostport2proxy(void** param, int param_no);
127 148
 inline static int w_t_on_negative( struct sip_msg* msg, char *go_to, char *foo );
128 149
 inline static int w_t_on_reply( struct sip_msg* msg, char *go_to, char *foo );
... ...
@@ -141,15 +162,30 @@ static cmd_export_t cmds[]={
141 162
 	{"t_retransmit_reply", w_t_retransmit_reply,    0, 0,                    REQUEST_ROUTE},
142 163
 	{"t_release",          w_t_release,             0, 0,                    REQUEST_ROUTE},
143 164
 	{T_RELAY_TO_UDP,       w_t_relay_to_udp,        2, fixup_hostport2proxy, REQUEST_ROUTE|FAILURE_ROUTE},
165
+#ifdef USE_TCP
144 166
 	{T_RELAY_TO_TCP,       w_t_relay_to_tcp,        2, fixup_hostport2proxy, REQUEST_ROUTE|FAILURE_ROUTE},
167
+#endif
168
+#ifdef USE_TLS
169
+	{T_RELAY_TO_TLS,       w_t_relay_to_tls,        2, fixup_hostport2proxy, REQUEST_ROUTE|FAILURE_ROUTE},
170
+#endif
145 171
 	{"t_replicate",        w_t_replicate,           2, fixup_hostport2proxy, REQUEST_ROUTE},
146 172
 	{"t_replicate_udp",    w_t_replicate_udp,       2, fixup_hostport2proxy, REQUEST_ROUTE},
173
+#ifdef USE_TCP
147 174
 	{"t_replicate_tcp",    w_t_replicate_tcp,       2, fixup_hostport2proxy, REQUEST_ROUTE},
175
+#endif
176
+#ifdef USE_TLS
177
+	{"t_replicate_tls",    w_t_replicate_tls,       2, fixup_hostport2proxy, REQUEST_ROUTE},
178
+#endif
148 179
 	{T_RELAY,              w_t_relay,               0, 0,                    
149 180
 			REQUEST_ROUTE | FAILURE_ROUTE },
150 181
 	{T_FORWARD_NONACK,     w_t_forward_nonack,      2, fixup_hostport2proxy, REQUEST_ROUTE},
151 182
 	{T_FORWARD_NONACK_UDP, w_t_forward_nonack_udp,  2, fixup_hostport2proxy, REQUEST_ROUTE},
183
+#ifdef USE_TCP
152 184
 	{T_FORWARD_NONACK_TCP, w_t_forward_nonack_tcp,  2, fixup_hostport2proxy, REQUEST_ROUTE},
185
+#endif
186
+#ifdef USE_TLS
187
+	{T_FORWARD_NONACK_TLS, w_t_forward_nonack_tls,  2, fixup_hostport2proxy, REQUEST_ROUTE},
188
+#endif
153 189
 	{"t_on_failure",       w_t_on_negative,         1, fixup_str2int,
154 190
 			REQUEST_ROUTE | FAILURE_ROUTE | ONREPLY_ROUTE },
155 191
 	{"t_on_reply",         w_t_on_reply,            1, fixup_str2int,
... ...
@@ -449,11 +485,21 @@ inline static int w_t_forward_nonack_udp( struct sip_msg* msg, char* proxy,
449 485
 	return _w_t_forward_nonack(msg, proxy, foo, PROTO_UDP);
450 486
 }
451 487
 
488
+#ifdef USE_TCP
452 489
 inline static int w_t_forward_nonack_tcp( struct sip_msg* msg, char* proxy,
453 490
 										char* foo)
454 491
 {
455 492
 	return _w_t_forward_nonack(msg, proxy, foo, PROTO_TCP);
456 493
 }
494
+#endif
495
+
496
+#ifdef USE_TLS
497
+inline static int w_t_forward_nonack_tls( struct sip_msg* msg, char* proxy,
498
+										char* foo)
499
+{
500
+	return _w_t_forward_nonack(msg, proxy, foo, PROTO_TLS);
501
+}
502
+#endif
457 503
 
458 504
 
459 505
 
... ...
@@ -607,6 +653,7 @@ inline static int w_t_relay_to_udp( struct sip_msg  *p_msg ,
607 653
 	return _w_t_relay_to( p_msg, ( struct proxy_l *) proxy);
608 654
 }
609 655
 
656
+#ifdef USE_TCP
610 657
 inline static int w_t_relay_to_tcp( struct sip_msg  *p_msg , 
611 658
 	char *proxy, /* struct proxy_l *proxy expected */
612 659
 	char *_foo       /* nothing expected */ )
... ...
@@ -614,6 +661,17 @@ inline static int w_t_relay_to_tcp( struct sip_msg  *p_msg ,
614 661
 	((struct proxy_l *)proxy)->proto=PROTO_TCP;
615 662
 	return _w_t_relay_to( p_msg, ( struct proxy_l *) proxy);
616 663
 }
664
+#endif
665
+
666
+#ifdef USE_TLS
667
+inline static int w_t_relay_to_tls( struct sip_msg  *p_msg , 
668
+	char *proxy, /* struct proxy_l *proxy expected */
669
+	char *_foo       /* nothing expected */ )
670
+{
671
+	((struct proxy_l *)proxy)->proto=PROTO_TLS;
672
+	return _w_t_relay_to( p_msg, ( struct proxy_l *) proxy);
673
+}
674
+#endif
617 675
 
618 676
 
619 677
 
... ...
@@ -631,12 +689,23 @@ inline static int w_t_replicate_udp( struct sip_msg  *p_msg ,
631 689
 	return t_replicate(p_msg, ( struct proxy_l *) proxy, PROTO_UDP );
632 690
 }
633 691
 
692
+#ifdef USE_TCP
634 693
 inline static int w_t_replicate_tcp( struct sip_msg  *p_msg , 
635 694
 	char *proxy, /* struct proxy_l *proxy expected */
636 695
 	char *_foo       /* nothing expected */ )
637 696
 {
638 697
 	return t_replicate(p_msg, ( struct proxy_l *) proxy, PROTO_TCP );
639 698
 }
699
+#endif
700
+
701
+#ifdef USE_TLS
702
+inline static int w_t_replicate_tls( struct sip_msg  *p_msg , 
703
+	char *proxy, /* struct proxy_l *proxy expected */
704
+	char *_foo       /* nothing expected */ )
705
+{
706
+	return t_replicate(p_msg, ( struct proxy_l *) proxy, PROTO_TLS );
707
+}
708
+#endif
640 709
 
641 710
 
642 711
 
... ...
@@ -664,21 +733,3 @@ inline static int w_t_relay( struct sip_msg  *p_msg ,
664 733
 	LOG(L_CRIT, "ERROR: w_t_relay_to: unsupported mode: %d\n", rmode);
665 734
 	return 0;
666 735
 }
667
-
668
-
669
-inline static int w_t_relay_udp( struct sip_msg  *p_msg , 
670
-						char *_foo, char *_bar)
671
-{
672
-	return t_relay_to( p_msg, 
673
-		(struct proxy_l *) 0 /* no proxy */, PROTO_UDP,
674
-		0 /* no replication */ );
675
-}
676
-
677
-
678
-inline static int w_t_relay_tcp( struct sip_msg  *p_msg , 
679
-						char *_foo, char *_bar)
680
-{
681
-	return t_relay_to( p_msg, 
682
-		(struct proxy_l *) 0 /* no proxy */, PROTO_TCP,
683
-		0 /* no replication */ );
684
-}
... ...
@@ -52,9 +52,8 @@
52 52
 #define T_RELAY_TO           "t_relay_to"
53 53
 #define T_RELAY_TO_UDP       "t_relay_to_udp"
54 54
 #define T_RELAY_TO_TCP       "t_relay_to_tcp"
55
+#define T_RELAY_TO_TLS       "t_relay_tls"
55 56
 #define T_RELAY              "t_relay"
56
-#define T_RELAY_UDP          "t_relay_udp"
57
-#define T_RELAY_TCP          "t_relay_tcp"
58 57
 #define T_REPLY              "t_reply"
59 58
 #define T_REPLY_WB           "t_reply_with_body"
60 59
 #define T_ADDBLIND           "t_add_blind"
... ...
@@ -62,6 +61,7 @@
62 61
 #define T_FORWARD_NONACK     "t_forward_nonack"
63 62
 #define T_FORWARD_NONACK_UDP "t_forward_nonack_udp"
64 63
 #define T_FORWARD_NONACK_TCP "t_forward_nonack_tcp"
64
+#define T_FORWARD_NONACK_TLS "t_forward_nonack_tls"
65 65
 #define T_GET_TI             "t_get_trans_ident"
66 66
 #define T_LOOKUP_IDENT       "t_lookup_ident"
67 67
 #define T_IS_LOCAL           "t_is_local"
... ...
@@ -34,6 +34,7 @@
34 34
  *  2003-04-14  added get_proto to determine protocol from uri unless
35 35
  *              specified explicitely (jiri)
36 36
  *  2003-07-07  get_proto takes now two protos as arguments (andrei)
37
+ *              tls/sips support for get_proto & uri2proxy (andrei)
37 38
  */
38 39
 
39 40
 
... ...
@@ -65,6 +66,9 @@ inline static enum sip_protos get_proto(enum sip_protos force_proto,
65 66
 				case PROTO_UDP:/* transport specified explicitely */
66 67
 #ifdef USE_TCP
67 68
 				case PROTO_TCP:
69
+#endif
70
+#ifdef USE_TLS
71
+				case PROTO_TLS:
68 72
 #endif
69 73
 						return proto;
70 74
 				default:
... ...
@@ -75,6 +79,9 @@ inline static enum sip_protos get_proto(enum sip_protos force_proto,
75 79
 		case PROTO_UDP: /* some protocol has been forced -- take it */
76 80
 #ifdef USE_TCP
77 81
 		case PROTO_TCP:
82
+#endif
83
+#ifdef USE_TLS
84
+		case PROTO_TLS:
78 85
 #endif
79 86
 			return force_proto;
80 87
 		default:
... ...
@@ -93,6 +100,7 @@ inline static struct proxy_l *uri2proxy( str *uri, int proto )
93 100
 {
94 101
 	struct sip_uri parsed_uri;
95 102
 	struct proxy_l *p;
103
+	enum sip_protos uri_proto;
96 104
 
97 105
 	if (parse_uri(uri->s, uri->len, &parsed_uri) < 0) {
98 106
 		LOG(L_ERR, "ERROR: uri2proxy: bad_uri: %.*s\n",
... ...
@@ -100,9 +108,18 @@ inline static struct proxy_l *uri2proxy( str *uri, int proto )
100 108
 		return 0;
101 109
 	}
102 110
 	
111
+	if (parsed_uri.secure){
112
+		if ((parsed_uri.proto!=PROTO_TCP) && (parsed_uri.proto!=PROTO_NONE)){
113
+			LOG(L_ERR, "ERROR: uri2proxy: bad transport  for sips uri: %d\n",
114
+					parsed_uri.proto);
115
+			return 0;
116
+		}else
117
+			uri_proto=PROTO_TLS;
118
+	}else
119
+		uri_proto=parsed_uri.proto;
103 120
 	p = mk_proxy(&parsed_uri.host, 
104 121
 		      parsed_uri.port_no, 
105
-		      get_proto(proto, parsed_uri.proto));
122
+		      get_proto(proto, uri_proto));
106 123
 	if (p == 0) {
107 124
 		LOG(L_ERR, "ERROR: uri2proxy: bad host name in URI <%.*s>\n",
108 125
 		    uri->len, ZSW(uri->s));