Browse code

ipops: removed svn id, history; coherent indentation

Daniel-Constantin Mierla authored on 17/09/2017 17:23:31
Showing 10 changed files
... ...
@@ -1,7 +1,5 @@
1 1
 /*
2
- * $Id$
3
- *
4
- * Functions that process IPOPS message 
2
+ * Functions that process IPOPS message
5 3
  *
6 4
  * Copyright (C) 2012 Hugh Waite (crocodile-rcs.com)
7 5
  *
... ...
@@ -17,8 +15,8 @@
17 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 16
  * GNU General Public License for more details.
19 17
  *
20
- * You should have received a copy of the GNU General Public License 
21
- * along with this program; if not, write to the Free Software 
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program; if not, write to the Free Software
22 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23 21
  *
24 22
  */
... ...
@@ -35,39 +33,39 @@ extern int _ip_is_in_subnet(char *ip1, size_t len1, enum enum_ip_type ip1_type,
35 33
  */
36 34
 int ipopsapi_compare_ips(const str *const ip1, const str *const ip2)
37 35
 {
38
-  str string1 = *ip1;
39
-  str string2 = *ip2;
40
-  enum enum_ip_type ip1_type, ip2_type;
41
-  
42
-  switch(ip1_type = ip_parser_execute(string1.s, string1.len)) {
43
-    case(ip_type_error):
44
-      return -1;
45
-      break;
46
-    case(ip_type_ipv6_reference):
47
-      string1.s += 1;
48
-      string1.len -= 2;
49
-      ip1_type = ip_type_ipv6;
50
-      break;
51
-    default:
52
-      break;
53
-  }
54
-  switch(ip2_type = ip_parser_execute(string2.s, string2.len)) {
55
-    case(ip_type_error):
56
-      return -1;
57
-      break;
58
-    case(ip_type_ipv6_reference):
59
-      string2.s += 1;
60
-      string2.len -= 2;
61
-      ip2_type = ip_type_ipv6;
62
-      break;
63
-    default:
64
-      break;
65
-  }
36
+	str string1 = *ip1;
37
+	str string2 = *ip2;
38
+	enum enum_ip_type ip1_type, ip2_type;
39
+
40
+	switch(ip1_type = ip_parser_execute(string1.s, string1.len)) {
41
+		case(ip_type_error):
42
+			return -1;
43
+			break;
44
+		case(ip_type_ipv6_reference):
45
+			string1.s += 1;
46
+			string1.len -= 2;
47
+			ip1_type = ip_type_ipv6;
48
+			break;
49
+		default:
50
+			break;
51
+	}
52
+	switch(ip2_type = ip_parser_execute(string2.s, string2.len)) {
53
+		case(ip_type_error):
54
+			return -1;
55
+			break;
56
+		case(ip_type_ipv6_reference):
57
+			string2.s += 1;
58
+			string2.len -= 2;
59
+			ip2_type = ip_type_ipv6;
60
+			break;
61
+		default:
62
+			break;
63
+	}
66 64
 
67
-  if (_compare_ips(string1.s, string1.len, ip1_type, string2.s, string2.len, ip2_type))
68
-    return 1;
69
-  else
70
-    return -1;
65
+	if (_compare_ips(string1.s, string1.len, ip1_type, string2.s, string2.len, ip2_type))
66
+		return 1;
67
+	else
68
+		return -1;
71 69
 }
72 70
 
73 71
 /**
... ...
@@ -75,46 +73,46 @@ int ipopsapi_compare_ips(const str *const ip1, const str *const ip2)
75 73
  */
76 74
 int ipopsapi_ip_is_in_subnet(const str *const ip1, const str *const ip2)
77 75
 {
78
-  str string1 = *ip1;
79
-  str string2 = *ip2;
80
-  enum enum_ip_type ip1_type, ip2_type;
81
-  char *cidr_pos = NULL;
82
-  int netmask = 0;
83
-  
84
-  switch(ip1_type = ip_parser_execute(string1.s, string1.len)) {
85
-    case(ip_type_error):
86
-      return -1;
87
-      break;
88
-    case(ip_type_ipv6_reference):
89
-      return -1;
90
-      break;
91
-    default:
92
-      break;
93
-  }
94
-  cidr_pos = string2.s + string2.len - 1;
95
-  while (cidr_pos > string2.s)
96
-  {
97
-    if (*cidr_pos == '/') break;
98
-    cidr_pos--;
99
-  }
100
-  if (cidr_pos == string2.s) return -1;
101
-  string2.len = (cidr_pos - string2.s);
102
-  netmask = atoi(cidr_pos+1);
103
-  switch(ip2_type = ip_parser_execute(string2.s, string2.len)) {
104
-    case(ip_type_error):
105
-      return -1;
106
-      break;
107
-    case(ip_type_ipv6_reference):
108
-      return -1;
109
-      break;
110
-    default:
111
-      break;
112
-  }
113
-  
114
-  if (_ip_is_in_subnet(string1.s, string1.len, ip1_type, string2.s, string2.len, ip2_type, netmask))
115
-    return 1;
116
-  else
117
-    return -1;
76
+	str string1 = *ip1;
77
+	str string2 = *ip2;
78
+	enum enum_ip_type ip1_type, ip2_type;
79
+	char *cidr_pos = NULL;
80
+	int netmask = 0;
81
+
82
+	switch(ip1_type = ip_parser_execute(string1.s, string1.len)) {
83
+		case(ip_type_error):
84
+			return -1;
85
+			break;
86
+		case(ip_type_ipv6_reference):
87
+			return -1;
88
+			break;
89
+		default:
90
+			break;
91
+	}
92
+	cidr_pos = string2.s + string2.len - 1;
93
+	while (cidr_pos > string2.s)
94
+	{
95
+		if (*cidr_pos == '/') break;
96
+		cidr_pos--;
97
+	}
98
+	if (cidr_pos == string2.s) return -1;
99
+	string2.len = (cidr_pos - string2.s);
100
+	netmask = atoi(cidr_pos+1);
101
+	switch(ip2_type = ip_parser_execute(string2.s, string2.len)) {
102
+		case(ip_type_error):
103
+			return -1;
104
+			break;
105
+		case(ip_type_ipv6_reference):
106
+			return -1;
107
+			break;
108
+		default:
109
+			break;
110
+	}
111
+
112
+	if (_ip_is_in_subnet(string1.s, string1.len, ip1_type, string2.s, string2.len, ip2_type, netmask))
113
+		return 1;
114
+	else
115
+		return -1;
118 116
 }
119 117
 
120 118
 /**
... ...
@@ -122,10 +120,10 @@ int ipopsapi_ip_is_in_subnet(const str *const ip1, const str *const ip2)
122 120
  */
123 121
 int ipopsapi_is_ip(const str * const ip)
124 122
 {
125
-  if (ip_parser_execute(ip->s, ip->len) != ip_type_error)
126
-    return 1;
127
-  else
128
-    return -1;
123
+	if (ip_parser_execute(ip->s, ip->len) != ip_type_error)
124
+		return 1;
125
+	else
126
+		return -1;
129 127
 }
130 128
 
131 129
 /**
... ...
@@ -1,6 +1,4 @@
1 1
 /*
2
- * $Id$
3
- *
4 2
  * Functions that operate on IP addresses
5 3
  *
6 4
  * Copyright (C) 2012 Hugh Waite (crocodile-rcs.com)
... ...
@@ -17,8 +15,8 @@
17 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 16
  * GNU General Public License for more details.
19 17
  *
20
- * You should have received a copy of the GNU General Public License 
21
- * along with this program; if not, write to the Free Software 
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program; if not, write to the Free Software
22 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23 21
  *
24 22
  */
... ...
@@ -1,6 +1,4 @@
1 1
 /*
2
- * $Id$
3
- *
4 2
  * Functions that operate on IP addresses
5 3
  *
6 4
  * Copyright (C) 2012 Hugh Waite (crocodile-rcs.com)
... ...
@@ -1,6 +1,4 @@
1 1
 /*
2
- * $Id$
3
- *
4 2
  * Functions that operate on IP addresses
5 3
  *
6 4
  * Copyright (C) 2012 Hugh Waite (crocodile-rcs.com)
... ...
@@ -26,14 +26,14 @@ enum enum_ip_type ip_parser_execute(const char *str, size_t len)
26 26
   p = str;
27 27
   pe = str+len;
28 28
 
29
-  
29
+
30 30
 #line 36 "ip_parser.c"
31 31
 	{
32 32
 	cs = ip_parser_start;
33 33
 	}
34 34
 
35 35
 #line 58 "ip_parser.rl"
36
-  
36
+
37 37
 #line 43 "ip_parser.c"
38 38
 	{
39 39
 	if ( p == pe )
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
  * Warning: This file is auto generated from a ragel syntax (ip_parser.rl),
3 3
  * do not change it!
4
- */   
4
+ */
5 5
 
6 6
 #ifndef ip_parser_h
7 7
 #define ip_parser_h
... ...
@@ -19,11 +19,6 @@
19 19
  * along with this program; if not, write to the Free Software
20 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21 21
  *
22
- * History:
23
- * -------
24
- *  2015-03-31: Added srv_query function (rboisvert)
25
- *  2011-07-29: Added a function to detect RFC1918 private IPv4 addresses (ibc)
26
- *  2011-04-27: Initial version (ibc)
27 22
  */
28 23
 /*!
29 24
  * \file
... ...
@@ -74,16 +69,21 @@ MODULE_VERSION
74 69
 /*
75 70
  * Module internal functions
76 71
  */
77
-int _compare_ips(char*, size_t, enum enum_ip_type, char*, size_t, enum enum_ip_type);
72
+int _compare_ips(char*, size_t, enum enum_ip_type, char*, size_t,
73
+		enum enum_ip_type);
78 74
 int _compare_ips_v4(struct in_addr *ip, char*, size_t);
79 75
 int _compare_ips_v6(struct in6_addr *ip, char*, size_t);
80 76
 int _ip_is_in_subnet(char *ip1, size_t len1, enum enum_ip_type ip1_type,
81 77
 		char *ip2, size_t len2, enum enum_ip_type ip2_type, int netmask);
82
-int _ip_is_in_subnet_v4(struct in_addr *ip, char *net, size_t netlen, int netmask);
83
-int _ip_is_in_subnet_v6(struct in6_addr *ip, char *net, size_t netlen, int netmask);
78
+int _ip_is_in_subnet_v4(struct in_addr *ip, char *net, size_t netlen,
79
+		int netmask);
80
+int _ip_is_in_subnet_v6(struct in6_addr *ip, char *net, size_t netlen,
81
+		int netmask);
84 82
 int _ip_is_in_subnet_str(void *ip, enum enum_ip_type type, char *s, int slen);
85
-int _ip_is_in_subnet_str_trimmed(void *ip, enum enum_ip_type type, char *b, char *e);
86
-static int _detailed_ip_type(unsigned int _type, struct sip_msg* _msg, char* _s,  char *_dst);
83
+int _ip_is_in_subnet_str_trimmed(void *ip, enum enum_ip_type type, char *b,
84
+		char *e);
85
+static int _detailed_ip_type(unsigned int _type, struct sip_msg* _msg,
86
+		char* _s,  char *_dst);
87 87
 
88 88
 
89 89
 /*
... ...
@@ -189,11 +189,11 @@ struct module_exports exports = {
189 189
 
190 190
 
191 191
 static int mod_init(void) {
192
-    /* turn detailed_ip_type relevant structures to netowork byte order so no need to
193
-     * transform each ip to host order before comparing */
194
-    ipv4ranges_hton();
195
-    ipv6ranges_hton();
196
-    return 0;
192
+	/* turn detailed_ip_type relevant structures to netowork byte order
193
+	 * so no need to transform each ip to host order before comparing */
194
+	ipv4ranges_hton();
195
+	ipv6ranges_hton();
196
+	return 0;
197 197
 }
198 198
 
199 199
 
... ...
@@ -204,39 +204,39 @@ static int mod_init(void) {
204 204
  */
205 205
 static int fixup_detailed_ip_type(void** param, int param_no)
206 206
 {
207
-    if (param_no == 1) {
208
-        return fixup_spve_null(param, 1);
209
-    }
210
-
211
-    if (param_no == 2) {
212
-        if (fixup_pvar_null(param, 1) != 0) {
213
-            LM_ERR("failed to fixup result pvar\n");
214
-            return -1;
215
-        }
216
-        if (((pv_spec_t *) (*param))->setf == NULL) {
217
-            LM_ERR("result pvar is not writeble\n");
218
-            return -1;
219
-        }
220
-        return 0;
221
-    }
222
-
223
-    LM_ERR("invalid parameter number <%d>\n", param_no);
224
-    return -1;
207
+	if (param_no == 1) {
208
+		return fixup_spve_null(param, 1);
209
+	}
210
+
211
+	if (param_no == 2) {
212
+		if (fixup_pvar_null(param, 1) != 0) {
213
+			LM_ERR("failed to fixup result pvar\n");
214
+			return -1;
215
+		}
216
+		if (((pv_spec_t *) (*param))->setf == NULL) {
217
+			LM_ERR("result pvar is not writeble\n");
218
+			return -1;
219
+		}
220
+		return 0;
221
+	}
222
+
223
+	LM_ERR("invalid parameter number <%d>\n", param_no);
224
+	return -1;
225 225
 }
226 226
 
227 227
 static int fixup_free_detailed_ip_type(void** param, int param_no)
228 228
 {
229
-    if (param_no == 1) {
230
-    //LM_WARN("free function has not been defined for spve\n");
231
-    return 0;
232
-    }
229
+	if (param_no == 1) {
230
+		//LM_WARN("free function has not been defined for spve\n");
231
+		return 0;
232
+	}
233 233
 
234
-    if (param_no == 2) {
235
-    return fixup_free_pvar_null(param, 1);
236
-    }
234
+	if (param_no == 2) {
235
+		return fixup_free_pvar_null(param, 1);
236
+	}
237 237
 
238
-    LM_ERR("invalid parameter number <%d>\n", param_no);
239
-    return -1;
238
+	LM_ERR("invalid parameter number <%d>\n", param_no);
239
+	return -1;
240 240
 }
241 241
 
242 242
 /*
... ...
@@ -244,7 +244,8 @@ static int fixup_free_detailed_ip_type(void** param, int param_no)
244 244
  */
245 245
 
246 246
 /*! \brief Return 1 if both pure IP's are equal, 0 otherwise. */
247
-int _compare_ips(char *ip1, size_t len1, enum enum_ip_type ip1_type, char *ip2, size_t len2, enum enum_ip_type ip2_type)
247
+int _compare_ips(char *ip1, size_t len1, enum enum_ip_type ip1_type, char *ip2,
248
+		size_t len2, enum enum_ip_type ip2_type)
248 249
 {
249 250
 	struct in_addr in_addr1, in_addr2;
250 251
 	struct in6_addr in6_addr1, in6_addr2;
... ...
@@ -273,7 +274,8 @@ int _compare_ips(char *ip1, size_t len1, enum enum_ip_type ip1_type, char *ip2,
273 274
 		case(ip_type_ipv6):
274 275
 			if (inet_pton(AF_INET6, _ip1, &in6_addr1) != 1)  return 0;
275 276
 			if (inet_pton(AF_INET6, _ip2, &in6_addr2) != 1)  return 0;
276
-			if (memcmp(in6_addr1.s6_addr, in6_addr2.s6_addr, sizeof(in6_addr1.s6_addr)) == 0)
277
+			if (memcmp(in6_addr1.s6_addr, in6_addr2.s6_addr,
278
+						sizeof(in6_addr1.s6_addr)) == 0)
277 279
 				return 1;
278 280
 			else
279 281
 				return 0;
... ...
@@ -305,8 +307,10 @@ int _compare_ips_v6(struct in6_addr *ip, char* ip2, size_t len2)
305 307
 	memcpy(_ip2, ip2, len2);
306 308
 	_ip2[len2] = '\0';
307 309
 
308
-	if (inet_pton(AF_INET6, _ip2, &in6_addr2) != 1)  return 0;
309
-	if (memcmp(ip->s6_addr, in6_addr2.s6_addr, sizeof(ip->s6_addr)) == 0) return 1;
310
+	if (inet_pton(AF_INET6, _ip2, &in6_addr2) != 1)
311
+		return 0;
312
+	if (memcmp(ip->s6_addr, in6_addr2.s6_addr, sizeof(ip->s6_addr)) == 0)
313
+		return 1;
310 314
 	return 0;
311 315
 }
312 316
 
... ...
@@ -352,11 +356,13 @@ int _ip_is_in_subnet(char *ip1, size_t len1, enum enum_ip_type ip1_type,
352 356
 			for (i=0; i<16; i++)
353 357
 			{
354 358
 				if (netmask > ((i+1)*8)) ipv6_mask[i] = 0xFF;
355
-				else if (netmask > (i*8))  ipv6_mask[i] = ~(0xFF >> (netmask-(i*8)));
359
+				else if (netmask > (i*8))
360
+					ipv6_mask[i] = ~(0xFF >> (netmask-(i*8)));
356 361
 				else ipv6_mask[i] = 0x00;
357 362
 			}
358 363
 			for (i=0; i<16; i++)  in6_addr1.s6_addr[i] &= ipv6_mask[i];
359
-			if (memcmp(in6_addr1.s6_addr, in6_addr2.s6_addr, sizeof(in6_addr1.s6_addr)) == 0)
364
+			if (memcmp(in6_addr1.s6_addr, in6_addr2.s6_addr,
365
+						sizeof(in6_addr1.s6_addr)) == 0)
360 366
 				return 1;
361 367
 			else
362 368
 				return 0;
... ...
@@ -367,7 +373,8 @@ int _ip_is_in_subnet(char *ip1, size_t len1, enum enum_ip_type ip1_type,
367 373
 	}
368 374
 }
369 375
 
370
-int _ip_is_in_subnet_v4(struct in_addr *ip, char *net, size_t netlen, int netmask)
376
+int _ip_is_in_subnet_v4(struct in_addr *ip, char *net, size_t netlen,
377
+		int netmask)
371 378
 {
372 379
 	struct in_addr net_addr;
373 380
 	char _net[INET6_ADDRSTRLEN];
... ...
@@ -387,7 +394,8 @@ int _ip_is_in_subnet_v4(struct in_addr *ip, char *net, size_t netlen, int netmas
387 394
 	return 0;
388 395
 }
389 396
 
390
-int _ip_is_in_subnet_v6(struct in6_addr *ip, char *net, size_t netlen, int netmask)
397
+int _ip_is_in_subnet_v6(struct in6_addr *ip, char *net, size_t netlen,
398
+		int netmask)
391 399
 {
392 400
 	struct in6_addr net_addr;
393 401
 	char _net[INET6_ADDRSTRLEN];
... ...
@@ -444,47 +452,48 @@ int _ip_is_in_subnet_str(void *ip, enum enum_ip_type type, char *s, int slen)
444 452
 	if (netmask == -1)
445 453
 	{
446 454
 		switch(type){
447
-		case ip_type_ipv4:
448
-			if (_compare_ips_v4((struct in_addr *)ip, s, slen))
449
-				return 1;
450
-			else
451
-				return -1;
452
-			break;
453
-		case ip_type_ipv6:
454
-			if (_compare_ips_v6((struct in6_addr *)ip, s, slen))
455
-				return 1;
456
-			else
457
-				return -1;
458
-			break;
459
-			break;
460
-		default:
461
-			break;
455
+			case ip_type_ipv4:
456
+				if (_compare_ips_v4((struct in_addr *)ip, s, slen))
457
+					return 1;
458
+				else
459
+					return -1;
460
+				break;
461
+			case ip_type_ipv6:
462
+				if (_compare_ips_v6((struct in6_addr *)ip, s, slen))
463
+					return 1;
464
+				else
465
+					return -1;
466
+				break;
467
+				break;
468
+			default:
469
+				break;
462 470
 		}
463 471
 	}
464 472
 	else
465 473
 	{
466 474
 		switch(type){
467
-		case ip_type_ipv4:
468
-			if (_ip_is_in_subnet_v4((struct in_addr *)ip, s, slen,netmask))
469
-				return 1;
470
-			else
471
-				return -1;
472
-			break;
473
-		case ip_type_ipv6:
474
-			if (_ip_is_in_subnet_v6((struct in6_addr *)ip, s, slen,netmask))
475
-				return 1;
476
-			else
477
-				return -1;
478
-			break;
479
-			break;
480
-		default:
481
-			break;
475
+			case ip_type_ipv4:
476
+				if (_ip_is_in_subnet_v4((struct in_addr *)ip, s, slen,netmask))
477
+					return 1;
478
+				else
479
+					return -1;
480
+				break;
481
+			case ip_type_ipv6:
482
+				if (_ip_is_in_subnet_v6((struct in6_addr *)ip, s, slen,netmask))
483
+					return 1;
484
+				else
485
+					return -1;
486
+				break;
487
+				break;
488
+			default:
489
+				break;
482 490
 		}
483 491
 	}
484 492
 	return 0;
485 493
 }
486 494
 
487
-int _ip_is_in_subnet_str_trimmed(void *ip, enum enum_ip_type type, char *b, char *e)
495
+int _ip_is_in_subnet_str_trimmed(void *ip, enum enum_ip_type type, char *b,
496
+		char *e)
488 497
 {
489 498
 	while(b<e && *b==' ') b++;
490 499
 	while(b<e && *(e-1)==' ') e--;
... ...
@@ -496,7 +505,8 @@ int _ip_is_in_subnet_str_trimmed(void *ip, enum enum_ip_type type, char *b, char
496 505
  * Script functions
497 506
  */
498 507
 
499
-/*! \brief Return true if the given argument (string or pv) is a valid IPv4, IPv6 or IPv6 reference. */
508
+/*! \brief Return true if the given argument (string or pv) is a valid IPv4,
509
+ * IPv6 or IPv6 reference. */
500 510
 static int w_is_ip(struct sip_msg* _msg, char* _s)
501 511
 {
502 512
 	str string;
... ...
@@ -519,7 +529,8 @@ static int w_is_ip(struct sip_msg* _msg, char* _s)
519 529
 }
520 530
 
521 531
 
522
-/*! \brief Return true if the given argument (string or pv) is a valid IPv4 or IPv6. */
532
+/*! \brief Return true if the given argument (string or pv) is a valid
533
+ * IPv4 or IPv6. */
523 534
 static int w_is_pure_ip(struct sip_msg* _msg, char* _s)
524 535
 {
525 536
 	str string;
... ...
@@ -595,7 +606,8 @@ static int w_is_ipv6(struct sip_msg* _msg, char* _s)
595 606
 }
596 607
 
597 608
 
598
-/*! \brief Return true if the given argument (string or pv) is a valid IPv6 reference. */
609
+/*! \brief Return true if the given argument (string or pv) is a valid
610
+ * IPv6 reference. */
599 611
 static int w_is_ipv6_reference(struct sip_msg* _msg, char* _s)
600 612
 {
601 613
 	str string;
... ...
@@ -618,7 +630,8 @@ static int w_is_ipv6_reference(struct sip_msg* _msg, char* _s)
618 630
 }
619 631
 
620 632
 
621
-/*! \brief Return the IP type of the given argument (string or pv): 1 = IPv4, 2 = IPv6, 3 = IPv6 refenrece, -1 = invalid IP. */
633
+/*! \brief Return the IP type of the given argument (string or pv):
634
+ *  1 = IPv4, 2 = IPv6, 3 = IPv6 refenrece, -1 = invalid IP. */
622 635
 static int w_ip_type(struct sip_msg* _msg, char* _s)
623 636
 {
624 637
 	str string;
... ...
@@ -652,73 +665,76 @@ static int w_ip_type(struct sip_msg* _msg, char* _s)
652 665
 
653 666
 static int w_detailed_ipv4_type(struct sip_msg* _msg, char* _s,  char *_dst)
654 667
 {
655
-    return _detailed_ip_type(ip_type_ipv4, _msg, _s, _dst);
668
+	return _detailed_ip_type(ip_type_ipv4, _msg, _s, _dst);
656 669
 }
657 670
 
658 671
 static int w_detailed_ipv6_type(struct sip_msg* _msg, char* _s,  char *_dst)
659 672
 {
660
-    return _detailed_ip_type(ip_type_ipv6, _msg, _s, _dst);
673
+	return _detailed_ip_type(ip_type_ipv6, _msg, _s, _dst);
661 674
 }
662 675
 
663 676
 static int w_detailed_ip_type(struct sip_msg* _msg, char* _s,  char *_dst)
664 677
 {
665
-    /* `ip_type_error` should read `unknown type` */
666
-    return _detailed_ip_type(ip_type_error, _msg, _s, _dst);
678
+	/* `ip_type_error` should read `unknown type` */
679
+	return _detailed_ip_type(ip_type_error, _msg, _s, _dst);
667 680
 }
668 681
 
669
-static int _detailed_ip_type(unsigned int _type, struct sip_msg* _msg, char* _s,  char *_dst)
682
+static int _detailed_ip_type(unsigned int _type, struct sip_msg* _msg,
683
+		char* _s,  char *_dst)
670 684
 {
671
-  str string;
672
-  pv_spec_t *dst;
673
-  pv_value_t val;
674
-  char *res;
675
-  unsigned int assumed_type;
676
-
677
-  if (_s == NULL) {
678
-    LM_ERR("bad parameter\n");
679
-    return -2;
680
-  }
681
-
682
-  if (fixup_get_svalue(_msg, (gparam_p)_s, &string))
683
-  {
684
-    LM_ERR("cannot print the format for string\n");
685
-    return -3;
686
-  }
687
-
688
-  assumed_type = (ip_type_error == _type)? ip_parser_execute(string.s, string.len) : _type;
689
-
690
-  switch (assumed_type) {
691
-      case ip_type_ipv4:
692
-          if (!ip4_iptype(string, &res)) {
693
-              LM_ERR("bad ip parameter\n");
694
-              return -1;
695
-          }
696
-          break;
697
-      case ip_type_ipv6_reference:
698
-      case ip_type_ipv6:
699
-          /* consider this reference */
700
-          if (string.s[0] == '[') {
701
-              string.s++;
702
-              string.len -= 2;
703
-          }
704
-          if (!ip6_iptype(string, &res)) {
705
-              LM_ERR("bad ip parameter\n");
706
-              return -1;
707
-          }
708
-          break;
709
-      default:
710
-          return -1;
711
-  }
712
-
713
-  val.rs.s = res;
714
-  val.rs.len = strlen(res);
715
-  val.flags = PV_VAL_STR;
716
-  dst = (pv_spec_t *)_dst;
717
-  dst->setf(_msg, &dst->pvp, (int)EQ_T, &val);
718
-  return 1;
685
+	str string;
686
+	pv_spec_t *dst;
687
+	pv_value_t val;
688
+	char *res;
689
+	unsigned int assumed_type;
690
+
691
+	if (_s == NULL) {
692
+		LM_ERR("bad parameter\n");
693
+		return -2;
694
+	}
695
+
696
+	if (fixup_get_svalue(_msg, (gparam_p)_s, &string))
697
+	{
698
+		LM_ERR("cannot print the format for string\n");
699
+		return -3;
700
+	}
701
+
702
+	assumed_type = (ip_type_error == _type)?
703
+						ip_parser_execute(string.s, string.len) : _type;
704
+
705
+	switch (assumed_type) {
706
+		case ip_type_ipv4:
707
+			if (!ip4_iptype(string, &res)) {
708
+				LM_ERR("bad ip parameter\n");
709
+				return -1;
710
+			}
711
+			break;
712
+		case ip_type_ipv6_reference:
713
+		case ip_type_ipv6:
714
+			/* consider this reference */
715
+			if (string.s[0] == '[') {
716
+				string.s++;
717
+				string.len -= 2;
718
+			}
719
+			if (!ip6_iptype(string, &res)) {
720
+				LM_ERR("bad ip parameter\n");
721
+				return -1;
722
+			}
723
+			break;
724
+		default:
725
+			return -1;
726
+	}
727
+
728
+	val.rs.s = res;
729
+	val.rs.len = strlen(res);
730
+	val.flags = PV_VAL_STR;
731
+	dst = (pv_spec_t *)_dst;
732
+	dst->setf(_msg, &dst->pvp, (int)EQ_T, &val);
733
+	return 1;
719 734
 }
720 735
 
721
-/*! \brief Return true if both IP's (string or pv) are equal. This function also allows comparing an IPv6 with an IPv6 reference. */
736
+/*! \brief Return true if both IP's (string or pv) are equal.
737
+ * This function also allows comparing an IPv6 with an IPv6 reference. */
722 738
 static int w_compare_ips(struct sip_msg* _msg, char* _s1, char* _s2)
723 739
 {
724 740
 	str string1, string2;
... ...
@@ -766,14 +782,16 @@ static int w_compare_ips(struct sip_msg* _msg, char* _s1, char* _s2)
766 782
 			break;
767 783
 	}
768 784
 
769
-	if (_compare_ips(string1.s, string1.len, ip1_type, string2.s, string2.len, ip2_type))
785
+	if (_compare_ips(string1.s, string1.len, ip1_type, string2.s, string2.len,
786
+				ip2_type))
770 787
 		return 1;
771 788
 	else
772 789
 		return -1;
773 790
 }
774 791
 
775 792
 
776
-/*! \brief Return true if both pure IP's (string or pv) are equal. IPv6 references not allowed. */
793
+/*! \brief Return true if both pure IP's (string or pv) are equal.
794
+ * IPv6 references not allowed. */
777 795
 static int w_compare_pure_ips(struct sip_msg* _msg, char* _s1, char* _s2)
778 796
 {
779 797
 	str string1, string2;
... ...
@@ -817,14 +835,17 @@ static int w_compare_pure_ips(struct sip_msg* _msg, char* _s1, char* _s2)
817 835
 			break;
818 836
 	}
819 837
 
820
-	if (_compare_ips(string1.s, string1.len, ip1_type, string2.s, string2.len, ip2_type))
838
+	if (_compare_ips(string1.s, string1.len, ip1_type, string2.s, string2.len,
839
+				ip2_type))
821 840
 		return 1;
822 841
 	else
823 842
 		return -1;
824 843
 }
825 844
 
826 845
 
827
-/*! \brief Return true if the first IP (string or pv) is within the subnet defined by the second commma-separated IP list in CIDR notation. IPv6 references not allowed. */
846
+/*! \brief Return true if the first IP (string or pv) is within the subnet
847
+ * defined by the second commma-separated IP list in CIDR notation.
848
+ * IPv6 references not allowed. */
828 849
 static int w_ip_is_in_subnet(struct sip_msg* _msg, char* _s1, char* _s2)
829 850
 {
830 851
 	struct in6_addr ip_addr6;
... ...
@@ -889,7 +910,8 @@ static int w_ip_is_in_subnet(struct sip_msg* _msg, char* _s1, char* _s2)
889 910
 }
890 911
 
891 912
 
892
-/*! \brief Return true if the given argument (string or pv) is a valid RFC 1918 IPv4 (private address). */
913
+/*! \brief Return true if the given argument (string or pv) is a valid
914
+ * RFC 1918 IPv4 (private address). */
893 915
 static int w_is_ip_rfc1918(struct sip_msg* _msg, char* _s)
894 916
 {
895 917
 	str string;
... ...
@@ -1121,4 +1143,3 @@ static int w_naptr_query(struct sip_msg* msg, char* str1, char* str2)
1121 1143
 
1122 1144
 	return naptr_update_pv(&naptrname, &name);
1123 1145
 }
1124
-
... ...
@@ -1,6 +1,4 @@
1 1
 /**
2
- * $Id$
3
- *
4 2
  * Copyright (C) 2013 Daniel-Constantin Mierla (asipto.com)
5 3
  *
6 4
  * This file is part of Kamailio, a free SIP server.
... ...
@@ -204,7 +202,7 @@ int pv_parse_dns_name(pv_spec_t *sp, str *in)
204 202
 
205 203
 	switch(pvs.len)
206 204
 	{
207
-		case 4: 
205
+		case 4:
208 206
 			if(strncmp(pvs.s, "addr", 4)==0)
209 207
 				dpv->type = 0;
210 208
 			else if(strncmp(pvs.s, "type", 4)==0)
... ...
@@ -215,7 +213,7 @@ int pv_parse_dns_name(pv_spec_t *sp, str *in)
215 213
 				dpv->type = 3;
216 214
 			else goto error;
217 215
 			break;
218
-		case 5: 
216
+		case 5:
219 217
 			if(strncmp(pvs.s, "count", 5)==0)
220 218
 				dpv->type = 4;
221 219
 			else goto error;
... ...
@@ -537,7 +535,7 @@ int pv_parse_hn_name(pv_spec_p sp, str *in)
537 535
 
538 536
 	switch(in->len)
539 537
 	{
540
-		case 1: 
538
+		case 1:
541 539
 			if(strncmp(in->s, "n", 1)==0)
542 540
 				sp->pvp.pvn.u.isname.name.n = 0;
543 541
 			else if(strncmp(in->s, "f", 1)==0)
... ...
@@ -1,6 +1,4 @@
1 1
 /**
2
- * $Id$
3
- *
4 2
  * Copyright (C) 2013 Daniel-Constantin Mierla (asipto.com)
5 3
  *
6 4
  * This file is part of Kamailio, a free SIP server.
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
  * Warning: This file is auto generated from a ragel syntax (rfc1918_parser.rl),
3 3
  * do not change it!
4
- */   
4
+ */
5 5
 
6 6
 #ifndef rfc1918_parser_h
7 7
 #define rfc1918_parser_h