Browse code

MADDR support (check-in not to forget about)

If you need to support maddr parameter in uri (oh, poor you) set the HONOR_MADDR define in the Makefile.defs and recompile.
Tested with Windows Messenger 5.1 on TCP connection.

Michal Matyska authored on 05/06/2006 10:37:27
Showing 3 changed files
... ...
@@ -339,6 +339,10 @@ endif
339 339
 #		compiles in comp=[sergz|sigcomp] support (parsing uri & via, 
340 340
 #		adding it to via, lumps a.s.o). WARNING: right now this option
341 341
 #		is useless since the compression code doesn't exist yet.
342
+# -DHONOR_MADDR
343
+#		compiles in checks and use for maddr parameter in uri.
344
+#		Required to support Windows Messenger 5.x over TCP connection
345
+#		which (mis)uses this parameter.
342 346
 
343 347
 # Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
344 348
 
... ...
@@ -207,6 +207,17 @@ int do_action(struct action* a, struct sip_msg* msg)
207 207
 					}
208 208
 #endif
209 209
 				}
210
+
211
+#ifdef HONOR_MADDR				
212
+				if (u->maddr_val.s && u->maddr_val.len) {
213
+					if (sip_hostport2su(&dst.to, &u->maddr_val, port, dst.proto)<0){
214
+						LOG(L_ERR, "ERROR:  bad maddr param in uri,"
215
+								" dropping packet\n");
216
+						ret=E_BAD_ADDRESS;
217
+						goto error_fwd_uri;
218
+					}
219
+				} else
220
+#endif
210 221
 				if (sip_hostport2su(&dst.to, &u->host, port, dst.proto)<0){
211 222
 					LOG(L_ERR, "ERROR:  bad host name in uri,"
212 223
 							" dropping packet\n");
... ...
@@ -119,9 +119,21 @@ inline static struct proxy_l *uri2proxy( str *uri, int proto )
119 119
 			uri_proto=PROTO_TLS;
120 120
 	}else
121 121
 		uri_proto=parsed_uri.proto;
122
+#ifdef HONOR_MADDR
123
+	if (parsed_uri.maddr_val.s && parsed_uri.maddr_val.len) {
124
+		p = mk_proxy(&parsed_uri.maddr_val, 
125
+					  parsed_uri.port_no, 
126
+					  get_proto(proto, uri_proto));
127
+		if (p == 0) {
128
+			LOG(L_ERR, "ERROR: uri2proxy: bad maddr param in URI <%.*s>\n",
129
+				uri->len, ZSW(uri->s));
130
+			return 0;
131
+		}
132
+	} else
133
+#endif
122 134
 	p = mk_proxy(&parsed_uri.host, 
123
-		      parsed_uri.port_no, 
124
-		      get_proto(proto, uri_proto));
135
+				  parsed_uri.port_no, 
136
+				  get_proto(proto, uri_proto));
125 137
 	if (p == 0) {
126 138
 		LOG(L_ERR, "ERROR: uri2proxy: bad host name in URI <%.*s>\n",
127 139
 		    uri->len, ZSW(uri->s));
... ...
@@ -171,6 +183,12 @@ inline static struct dest_info *uri2dst(struct dest_info* dst,
171 183
 	dst->proto= get_proto(proto, uri_proto);
172 184
 #ifdef USE_COMP
173 185
 	dst->comp=parsed_uri.comp;
186
+#endif
187
+#ifdef HONOR_MADDR
188
+	if (parsed_uri.maddr_val.s && parsed_uri.maddr_val.len) {
189
+		sip_hostport2su(&dst->to, &parsed_uri.maddr_val, parsed_uri.port_no, dst->proto);
190
+		DBG("maddr dst: %.*s:%d\n", parsed_uri.maddr_val.len, parsed_uri.maddr_val.s, parsed_uri.port_no);
191
+	} else
174 192
 #endif
175 193
 	sip_hostport2su(&dst->to, &parsed_uri.host, parsed_uri.port_no,
176 194
 						dst->proto);