Browse code

ipops: mask subnet address when comparing

- allow using full ip address when specifying subnet parameter
- more flexibility on using values from sip message
- GH #1250

Daniel-Constantin Mierla authored on 03/04/2018 07:11:37
Showing 1 changed files
... ...
@@ -390,7 +390,7 @@ int _ip_is_in_subnet_v4(struct in_addr *ip, char *net, size_t netlen,
390 390
 	if (netmask == 32) ipv4_mask = 0xFFFFFFFF;
391 391
 	else ipv4_mask = htonl(~(0xFFFFFFFF >> netmask));
392 392
 
393
-	if ((ip->s_addr & ipv4_mask) == net_addr.s_addr)
393
+	if ((ip->s_addr & ipv4_mask) == (net_addr.s_addr & ipv4_mask))
394 394
 		return 1;
395 395
 	return 0;
396 396
 }
... ...
@@ -1456,4 +1456,4 @@ int mod_register(char *path, int *dlflags, void *p1, void *p2)
1456 1456
 {
1457 1457
 	sr_kemi_modules_add(sr_kemi_ipops_exports);
1458 1458
 	return 0;
1459
-}
1460 1459
\ No newline at end of file
1460
+}