Browse code

core: dedicated function to check Via address with source ip

- received_via_test() as alternative to received_test() which looks also
for rport and received parameters, confusing nat detection tests

Daniel-Constantin Mierla authored on 01/12/2014 10:47:19
Showing 2 changed files
... ...
@@ -252,7 +252,8 @@ static int check_via_address(struct ip_addr* ip, str *name,
252 252
 }
253 253
 
254 254
 
255
-/* check if IP address in Via != source IP address of signaling */
255
+/* check if IP address in Via != source IP address of signaling,
256
+ * or the sender requires adding rport or received values */
256 257
 int received_test( struct sip_msg *msg )
257 258
 {
258 259
 	int rcvd;
... ...
@@ -263,6 +264,15 @@ int received_test( struct sip_msg *msg )
263 263
 	return rcvd;
264 264
 }
265 265
 
266
+/* check if IP address in Via != source IP address of signaling */
267
+int received_via_test( struct sip_msg *msg )
268
+{
269
+	int rcvd;
270
+
271
+	rcvd = (check_via_address(&msg->rcv.src_ip, &msg->via1->host,
272
+							msg->via1->port, received_dns)!=0);
273
+	return rcvd;
274
+}
266 275
 
267 276
 static char * warning_builder( struct sip_msg *msg, unsigned int *returned_len)
268 277
 {
... ...
@@ -129,9 +129,13 @@ int branch_builder( unsigned int hash_index,
129 129
 
130 130
 char* id_builder(struct sip_msg* msg, unsigned int *id_len);
131 131
 
132
-/* check if IP address in Via != source IP address of signaling */
132
+/* check if IP address in Via != source IP address of signaling,
133
+ * or the sender is asking to set the values for rport or received */
133 134
 int received_test( struct sip_msg *msg );
134 135
 
136
+/* check if IP address in Via != source IP address of signaling */
137
+int received_via_test( struct sip_msg *msg );
138
+
135 139
 /* builds a char* buffer from message headers without body
136 140
  * first line is excluded in case of skip_first_line=1
137 141
  */