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

(cherry picked from commit 194743bf0de92ae09fdc817e57863f6bdb159539)
(cherry picked from commit 7ebf861b27ae7e90092bc875d75772e5a1c941d5)

Daniel-Constantin Mierla authored on 01/12/2014 10:47:19
Showing 2 changed files
... ...
@@ -251,7 +251,8 @@ static int check_via_address(struct ip_addr* ip, str *name,
251 251
 }
252 252
 
253 253
 
254
-/* check if IP address in Via != source IP address of signaling */
254
+/* check if IP address in Via != source IP address of signaling,
255
+ * or the sender requires adding rport or received values */
255 256
 int received_test( struct sip_msg *msg )
256 257
 {
257 258
 	int rcvd;
... ...
@@ -262,6 +263,15 @@ int received_test( struct sip_msg *msg )
262 263
 	return rcvd;
263 264
 }
264 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
+}
265 275
 
266 276
 static char * warning_builder( struct sip_msg *msg, unsigned int *returned_len)
267 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
  */