Browse code

- forward_{udp,tcp,tls} fix: if one of them is used (instead of simple forward) force the corresponding protocol and don't use the uri one

Andrei Pelinescu-Onciul authored on 31/08/2004 16:50:34
Showing 2 changed files
... ...
@@ -48,7 +48,7 @@ MAIN_NAME=ser
48 48
 VERSION = 0
49 49
 PATCHLEVEL = 8
50 50
 SUBLEVEL =   99
51
-EXTRAVERSION = -dev1
51
+EXTRAVERSION = -dev2
52 52
 
53 53
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
54 54
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
... ...
@@ -120,7 +120,7 @@ int do_action(struct action* a, struct sip_msg* msg)
120 120
 #ifdef USE_TLS
121 121
 			else if (a->type==FORWARD_TLS_T) proto= PROTO_TLS;
122 122
 #endif
123
-			else proto=msg->rcv.proto;
123
+			else proto= PROTO_NONE;
124 124
 			if (a->p1_type==URIHOST_ST){
125 125
 				/*parse uri*/
126 126
 
... ...
@@ -151,36 +151,39 @@ int do_action(struct action* a, struct sip_msg* msg)
151 151
 							ret=E_UNSPEC;
152 152
 							goto error_fwd_uri;
153 153
 				}
154
-				switch(u->proto){
155
-					case PROTO_NONE:
156
-						proto=PROTO_UDP;
157
-						break;
158
-					case PROTO_UDP:
154
+				if (proto == PROTO_NONE){ /* only if proto not set get it
155
+											 from the uri */
156
+					switch(u->proto){
157
+						case PROTO_NONE:
158
+							proto=PROTO_UDP;
159
+							break;
160
+						case PROTO_UDP:
159 161
 #ifdef USE_TCP
160
-					case PROTO_TCP:
162
+						case PROTO_TCP:
161 163
 #endif
162 164
 #ifdef USE_TLS
163
-					case PROTO_TLS:
165
+						case PROTO_TLS:
164 166
 #endif
165
-						proto=u->proto;
166
-						break;
167
-					default:
168
-						LOG(L_ERR,"ERROR: do action: forward: bad uri"
169
-								" transport %d\n", u->proto);
170
-						ret=E_BAD_PROTO;
171
-						goto error_fwd_uri;
172
-				}
167
+							proto=u->proto;
168
+							break;
169
+						default:
170
+							LOG(L_ERR,"ERROR: do action: forward: bad uri"
171
+									" transport %d\n", u->proto);
172
+							ret=E_BAD_PROTO;
173
+							goto error_fwd_uri;
174
+					}
173 175
 #ifdef USE_TLS
174
-				if (u->secure){
175
-					if (u->proto==PROTO_UDP){
176
-						LOG(L_ERR, "ERROR: do_action: forward: secure uri"
177
-								" incompatible with transport %d\n", u->proto);
178
-						ret=E_BAD_PROTO;
179
-						goto error_fwd_uri;
176
+					if (u->secure){
177
+						if (u->proto==PROTO_UDP){
178
+							LOG(L_ERR, "ERROR: do_action: forward: secure uri"
179
+									" incompatible with transport %d\n", u->proto);
180
+							ret=E_BAD_PROTO;
181
+							goto error_fwd_uri;
182
+						}
183
+						proto=PROTO_TLS;
180 184
 					}
181
-					proto=PROTO_TLS;
182
-				}
183 185
 #endif
186
+				}
184 187
 				/* create a temporary proxy*/
185 188
 				p=mk_proxy(&u->host, port, proto);
186 189
 				if (p==0){
... ...
@@ -195,6 +198,8 @@ int do_action(struct action* a, struct sip_msg* msg)
195 195
 				pkg_free(p);
196 196
 				if (ret>=0) ret=1;
197 197
 			}else if ((a->p1_type==PROXY_ST) && (a->p2_type==NUMBER_ST)){
198
+				if (proto==PROTO_NONE)
199
+					proto=msg->rcv.proto;
198 200
 				ret=forward_request(msg,(struct proxy_l*)a->p1.data, proto);
199 201
 				if (ret>=0) ret=1;
200 202
 			}else{