Browse code

permissions: use perm prefix for global param variables

Daniel-Constantin Mierla authored on 01/05/2020 11:50:54
Showing 8 changed files
... ...
@@ -42,22 +42,22 @@
42 42
 
43 43
 #define TABLE_VERSION 6
44 44
 
45
-struct addr_list ***addr_hash_table = NULL; /* Ptr to current hash table ptr */
46
-struct addr_list **addr_hash_table_1 = NULL; /* Pointer to hash table 1 */
47
-struct addr_list **addr_hash_table_2 = NULL; /* Pointer to hash table 2 */
45
+struct addr_list ***perm_addr_table = NULL; /* Ptr to current address hash table ptr */
46
+struct addr_list **perm_addr_table_1 = NULL; /* Pointer to address hash table 1 */
47
+struct addr_list **perm_addr_table_2 = NULL; /* Pointer to address hash table 2 */
48 48
 
49
-struct subnet **subnet_table = NULL;  /* Ptr to current subnet table */
50
-struct subnet *subnet_table_1 = NULL; /* Ptr to subnet table 1 */
51
-struct subnet *subnet_table_2 = NULL; /* Ptr to subnet table 2 */
49
+struct subnet **perm_subnet_table = NULL;  /* Ptr to current subnet table */
50
+struct subnet *perm_subnet_table_1 = NULL; /* Ptr to subnet table 1 */
51
+struct subnet *perm_subnet_table_2 = NULL; /* Ptr to subnet table 2 */
52 52
 
53
-struct domain_name_list ***domain_list_table = NULL; /* Ptr to current domain name table */
54
-static struct domain_name_list **domain_list_table_1 = NULL; /* Ptr to domain name table 1 */
55
-static struct domain_name_list **domain_list_table_2 = NULL; /* Ptr to domain name table 2 */
53
+struct domain_name_list ***perm_domain_table = NULL; /* Ptr to current domain name table */
54
+static struct domain_name_list **perm_domain_table_1 = NULL; /* Ptr to domain name table 1 */
55
+static struct domain_name_list **perm_domain_table_2 = NULL; /* Ptr to domain name table 2 */
56 56
 
57
-static db1_con_t* db_handle = 0;
57
+static db1_con_t* perm_db_handle = 0;
58 58
 static db_func_t perm_dbf;
59 59
 
60
-extern str address_file;
60
+extern str perm_address_file;
61 61
 
62 62
 typedef struct address_tables_group {
63 63
 	struct addr_list **address_table;
... ...
@@ -158,18 +158,18 @@ int reload_address_db_table(address_tables_group_t *atg)
158 158
 	str ips;
159 159
 	str tagv;
160 160
 
161
-	cols[0] = &grp_col;
162
-	cols[1] = &ip_addr_col;
163
-	cols[2] = &mask_col;
164
-	cols[3] = &port_col;
165
-	cols[4] = &tag_col;
161
+	cols[0] = &perm_grp_col;
162
+	cols[1] = &perm_ip_addr_col;
163
+	cols[2] = &perm_mask_col;
164
+	cols[3] = &perm_port_col;
165
+	cols[4] = &perm_tag_col;
166 166
 
167
-	if (perm_dbf.use_table(db_handle, &address_table) < 0) {
167
+	if (perm_dbf.use_table(perm_db_handle, &perm_address_table) < 0) {
168 168
 		LM_ERR("failed to use table\n");
169 169
 		return -1;
170 170
 	}
171 171
 
172
-	if (perm_dbf.query(db_handle, NULL, 0, NULL, cols, 0, 5, 0, &res) < 0) {
172
+	if (perm_dbf.query(perm_db_handle, NULL, 0, NULL, cols, 0, 5, 0, &res) < 0) {
173 173
 		LM_ERR("failed to query database\n");
174 174
 		return -1;
175 175
 	}
... ...
@@ -225,13 +225,13 @@ int reload_address_db_table(address_tables_group_t *atg)
225 225
 		}
226 226
 	}
227 227
 
228
-	perm_dbf.free_result(db_handle, res);
228
+	perm_dbf.free_result(perm_db_handle, res);
229 229
 
230 230
 	return 1;
231 231
 
232 232
 dberror:
233 233
 	LM_ERR("database problem - invalid record\n");
234
-	perm_dbf.free_result(db_handle, res);
234
+	perm_dbf.free_result(perm_db_handle, res);
235 235
 	return -1;
236 236
 }
237 237
 
... ...
@@ -284,9 +284,9 @@ int reload_address_file_table(address_tables_group_t *atg)
284 284
 	str ips;
285 285
 	str tagv;
286 286
 
287
-	f = fopen(address_file.s, "r");
287
+	f = fopen(perm_address_file.s, "r");
288 288
 	if(f == NULL) {
289
-		LM_ERR("can't open list file [%s]\n", address_file.s);
289
+		LM_ERR("can't open list file [%s]\n", perm_address_file.s);
290 290
 		return -1;
291 291
 	}
292 292
 
... ...
@@ -342,8 +342,8 @@ next_line:
342 342
 		p = fgets(line, 1024, f);
343 343
 	}
344 344
 
345
-	LM_DBG("processed file: %s (%d lines)- added %d records\n", address_file.s,
346
-			i, n);
345
+	LM_DBG("processed file: %s (%d lines)- added %d records\n",
346
+			perm_address_file.s, i, n);
347 347
 
348 348
 	fclose(f);
349 349
 	return 1;
... ...
@@ -366,33 +366,33 @@ int reload_address_table(void)
366 366
 	address_tables_group_t atg;
367 367
 
368 368
 	/* Choose new hash table and free its old contents */
369
-	if (*addr_hash_table == addr_hash_table_1) {
370
-		empty_addr_hash_table(addr_hash_table_2);
371
-		atg.address_table = addr_hash_table_2;
369
+	if (*perm_addr_table == perm_addr_table_1) {
370
+		empty_addr_hash_table(perm_addr_table_2);
371
+		atg.address_table = perm_addr_table_2;
372 372
 	} else {
373
-		empty_addr_hash_table(addr_hash_table_1);
374
-		atg.address_table = addr_hash_table_1;
373
+		empty_addr_hash_table(perm_addr_table_1);
374
+		atg.address_table = perm_addr_table_1;
375 375
 	}
376 376
 
377 377
 	/* Choose new subnet table */
378
-	if (*subnet_table == subnet_table_1) {
379
-		empty_subnet_table(subnet_table_2);
380
-		atg.subnet_table = subnet_table_2;
378
+	if (*perm_subnet_table == perm_subnet_table_1) {
379
+		empty_subnet_table(perm_subnet_table_2);
380
+		atg.subnet_table = perm_subnet_table_2;
381 381
 	} else {
382
-		empty_subnet_table(subnet_table_1);
383
-		atg.subnet_table = subnet_table_1;
382
+		empty_subnet_table(perm_subnet_table_1);
383
+		atg.subnet_table = perm_subnet_table_1;
384 384
 	}
385 385
 
386 386
 	/* Choose new domain name table */
387
-	if (*domain_list_table == domain_list_table_1) {
388
-		empty_domain_name_table(domain_list_table_2);
389
-		atg.domain_table = domain_list_table_2;
387
+	if (*perm_domain_table == perm_domain_table_1) {
388
+		empty_domain_name_table(perm_domain_table_2);
389
+		atg.domain_table = perm_domain_table_2;
390 390
 	} else {
391
-		empty_domain_name_table(domain_list_table_1);
392
-		atg.domain_table = domain_list_table_1;
391
+		empty_domain_name_table(perm_domain_table_1);
392
+		atg.domain_table = perm_domain_table_1;
393 393
 	}
394 394
 
395
-	if(address_file.s==NULL) {
395
+	if(perm_address_file.s==NULL) {
396 396
 		ret = reload_address_db_table(&atg);
397 397
 	} else {
398 398
 		ret = reload_address_file_table(&atg);
... ...
@@ -401,9 +401,9 @@ int reload_address_table(void)
401 401
 		return ret;
402 402
 	}
403 403
 
404
-	*addr_hash_table = atg.address_table;
405
-	*subnet_table = atg.subnet_table;
406
-	*domain_list_table = atg.domain_table;
404
+	*perm_addr_table = atg.address_table;
405
+	*perm_subnet_table = atg.subnet_table;
406
+	*perm_domain_table = atg.domain_table;
407 407
 
408 408
 	LM_DBG("address table reloaded successfully.\n");
409 409
 
... ...
@@ -417,15 +417,15 @@ int reload_address_table(void)
417 417
  */
418 418
 int reload_address_table_cmd(void)
419 419
 {
420
-	if(address_file.s==NULL) {
421
-		if(!db_url.s) {
420
+	if(perm_address_file.s==NULL) {
421
+		if(!perm_db_url.s) {
422 422
 			LM_ERR("db_url not set\n");
423 423
 			return -1;
424 424
 		}
425 425
 
426
-		if (!db_handle) {
427
-			db_handle = perm_dbf.init(&db_url);
428
-			if (!db_handle) {
426
+		if (!perm_db_handle) {
427
+			perm_db_handle = perm_dbf.init(&perm_db_url);
428
+			if (!perm_db_handle) {
429 429
 				LM_ERR("unable to connect database\n");
430 430
 				return -1;
431 431
 			}
... ...
@@ -433,16 +433,16 @@ int reload_address_table_cmd(void)
433 433
 	}
434 434
 
435 435
 	if (reload_address_table () != 1) {
436
-		if(address_file.s==NULL) {
437
-			perm_dbf.close(db_handle);
438
-			db_handle = 0;
436
+		if(perm_address_file.s==NULL) {
437
+			perm_dbf.close(perm_db_handle);
438
+			perm_db_handle = 0;
439 439
 		}
440 440
 		return -1;
441 441
 	}
442 442
 
443
-	if(address_file.s==NULL) {
444
-		perm_dbf.close(db_handle);
445
-		db_handle = 0;
443
+	if(perm_address_file.s==NULL) {
444
+		perm_dbf.close(perm_db_handle);
445
+		perm_db_handle = 0;
446 446
 	}
447 447
 
448 448
 	return 1;
... ...
@@ -453,16 +453,16 @@ int reload_address_table_cmd(void)
453 453
  */
454 454
 int init_addresses(void)
455 455
 {
456
-	addr_hash_table_1 = addr_hash_table_2 = 0;
457
-	addr_hash_table = 0;
456
+	perm_addr_table_1 = perm_addr_table_2 = 0;
457
+	perm_addr_table = 0;
458 458
 
459
-	if(address_file.s==NULL) {
460
-		if (!db_url.s) {
459
+	if(perm_address_file.s==NULL) {
460
+		if (!perm_db_url.s) {
461 461
 			LM_INFO("db_url parameter of permissions module not set, "
462 462
 					"disabling allow_address\n");
463 463
 			return 0;
464 464
 		} else {
465
-			if (db_bind_mod(&db_url, &perm_dbf) < 0) {
465
+			if (db_bind_mod(&perm_db_url, &perm_dbf) < 0) {
466 466
 				LM_ERR("load a database support module\n");
467 467
 				return -1;
468 468
 			}
... ...
@@ -473,62 +473,63 @@ int init_addresses(void)
473 473
 			}
474 474
 		}
475 475
 
476
-		db_handle = perm_dbf.init(&db_url);
477
-		if (!db_handle) {
476
+		perm_db_handle = perm_dbf.init(&perm_db_url);
477
+		if (!perm_db_handle) {
478 478
 			LM_ERR("unable to connect database\n");
479 479
 			return -1;
480 480
 		}
481 481
 
482
-		if(db_check_table_version(&perm_dbf, db_handle, &address_table, TABLE_VERSION) < 0) {
483
-			DB_TABLE_VERSION_ERROR(address_table);
484
-			perm_dbf.close(db_handle);
485
-			db_handle = 0;
482
+		if(db_check_table_version(&perm_dbf, perm_db_handle, &perm_address_table,
483
+					TABLE_VERSION) < 0) {
484
+			DB_TABLE_VERSION_ERROR(perm_address_table);
485
+			perm_dbf.close(perm_db_handle);
486
+			perm_db_handle = 0;
486 487
 			return -1;
487 488
 		}
488 489
 	}
489 490
 
490
-	addr_hash_table_1 = new_addr_hash_table();
491
-	if (!addr_hash_table_1) return -1;
491
+	perm_addr_table_1 = new_addr_hash_table();
492
+	if (!perm_addr_table_1) return -1;
492 493
 
493
-	addr_hash_table_2  = new_addr_hash_table();
494
-	if (!addr_hash_table_2) goto error;
494
+	perm_addr_table_2  = new_addr_hash_table();
495
+	if (!perm_addr_table_2) goto error;
495 496
 
496
-	addr_hash_table = (struct addr_list ***)shm_malloc
497
+	perm_addr_table = (struct addr_list ***)shm_malloc
497 498
 		(sizeof(struct addr_list **));
498
-	if (!addr_hash_table) {
499
+	if (!perm_addr_table) {
499 500
 		LM_ERR("no more shm memory for addr_hash_table\n");
500 501
 		goto error;
501 502
 	}
502 503
 
503
-	*addr_hash_table = addr_hash_table_1;
504
+	*perm_addr_table = perm_addr_table_1;
504 505
 
505
-	subnet_table_1 = new_subnet_table();
506
-	if (!subnet_table_1) goto error;
506
+	perm_subnet_table_1 = new_subnet_table();
507
+	if (!perm_subnet_table_1) goto error;
507 508
 
508
-	subnet_table_2 = new_subnet_table();
509
-	if (!subnet_table_2) goto error;
509
+	perm_subnet_table_2 = new_subnet_table();
510
+	if (!perm_subnet_table_2) goto error;
510 511
 
511
-	subnet_table = (struct subnet **)shm_malloc(sizeof(struct subnet *));
512
-	if (!subnet_table) {
512
+	perm_subnet_table = (struct subnet **)shm_malloc(sizeof(struct subnet *));
513
+	if (!perm_subnet_table) {
513 514
 		LM_ERR("no more shm memory for subnet_table\n");
514 515
 		goto error;
515 516
 	}
516 517
 
517
-	*subnet_table = subnet_table_1;
518
+	*perm_subnet_table = perm_subnet_table_1;
518 519
 
519
-	domain_list_table_1 = new_domain_name_table();
520
-	if (!domain_list_table_1) goto error;
520
+	perm_domain_table_1 = new_domain_name_table();
521
+	if (!perm_domain_table_1) goto error;
521 522
 
522
-	domain_list_table_2 = new_domain_name_table();
523
-	if (!domain_list_table_2) goto error;
523
+	perm_domain_table_2 = new_domain_name_table();
524
+	if (!perm_domain_table_2) goto error;
524 525
 
525
-	domain_list_table = (struct domain_name_list ***)shm_malloc(sizeof(struct domain_name_list **));
526
-	if (!domain_list_table) {
526
+	perm_domain_table = (struct domain_name_list ***)shm_malloc(sizeof(struct domain_name_list **));
527
+	if (!perm_domain_table) {
527 528
 		LM_ERR("no more shm memory for domain name table\n");
528 529
 		goto error;
529 530
 	}
530 531
 
531
-	*domain_list_table = domain_list_table_1;
532
+	*perm_domain_table = perm_domain_table_1;
532 533
 
533 534
 
534 535
 	if (reload_address_table() == -1) {
... ...
@@ -536,55 +537,55 @@ int init_addresses(void)
536 537
 		goto error;
537 538
 	}
538 539
 
539
-	if(address_file.s==NULL) {
540
-		perm_dbf.close(db_handle);
541
-		db_handle = 0;
540
+	if(perm_address_file.s==NULL) {
541
+		perm_dbf.close(perm_db_handle);
542
+		perm_db_handle = 0;
542 543
 	}
543 544
 
544 545
 	return 0;
545 546
 
546 547
 error:
547
-	if (addr_hash_table_1) {
548
-		free_addr_hash_table(addr_hash_table_1);
549
-		addr_hash_table_1 = 0;
548
+	if (perm_addr_table_1) {
549
+		free_addr_hash_table(perm_addr_table_1);
550
+		perm_addr_table_1 = 0;
550 551
 	}
551
-	if (addr_hash_table_2) {
552
-		free_addr_hash_table(addr_hash_table_2);
553
-		addr_hash_table_2 = 0;
552
+	if (perm_addr_table_2) {
553
+		free_addr_hash_table(perm_addr_table_2);
554
+		perm_addr_table_2 = 0;
554 555
 	}
555
-	if (addr_hash_table) {
556
-		shm_free(addr_hash_table);
557
-		addr_hash_table = 0;
556
+	if (perm_addr_table) {
557
+		shm_free(perm_addr_table);
558
+		perm_addr_table = 0;
558 559
 	}
559
-	if (subnet_table_1) {
560
-		free_subnet_table(subnet_table_1);
561
-		subnet_table_1 = 0;
560
+	if (perm_subnet_table_1) {
561
+		free_subnet_table(perm_subnet_table_1);
562
+		perm_subnet_table_1 = 0;
562 563
 	}
563
-	if (subnet_table_2) {
564
-		free_subnet_table(subnet_table_2);
565
-		subnet_table_2 = 0;
564
+	if (perm_subnet_table_2) {
565
+		free_subnet_table(perm_subnet_table_2);
566
+		perm_subnet_table_2 = 0;
566 567
 	}
567
-	if (subnet_table) {
568
-		shm_free(subnet_table);
569
-		subnet_table = 0;
568
+	if (perm_subnet_table) {
569
+		shm_free(perm_subnet_table);
570
+		perm_subnet_table = 0;
570 571
 	}
571 572
 
572
-	if (domain_list_table_1) {
573
-		free_domain_name_table(domain_list_table_1);
574
-		domain_list_table_1 = 0;
573
+	if (perm_domain_table_1) {
574
+		free_domain_name_table(perm_domain_table_1);
575
+		perm_domain_table_1 = 0;
575 576
 	}
576
-	if (domain_list_table_2) {
577
-		free_domain_name_table(domain_list_table_2);
578
-		domain_list_table_2 = 0;
577
+	if (perm_domain_table_2) {
578
+		free_domain_name_table(perm_domain_table_2);
579
+		perm_domain_table_2 = 0;
579 580
 	}
580
-	if (domain_list_table) {
581
-		shm_free(domain_list_table);
582
-		domain_list_table = 0;
581
+	if (perm_domain_table) {
582
+		shm_free(perm_domain_table);
583
+		perm_domain_table = 0;
583 584
 	}
584 585
 
585
-	if(address_file.s==NULL) {
586
-		perm_dbf.close(db_handle);
587
-		db_handle = 0;
586
+	if(perm_address_file.s==NULL) {
587
+		perm_dbf.close(perm_db_handle);
588
+		perm_db_handle = 0;
588 589
 	}
589 590
 	return -1;
590 591
 }
... ...
@@ -595,15 +596,15 @@ error:
595 596
  */
596 597
 void clean_addresses(void)
597 598
 {
598
-	if (addr_hash_table_1) free_addr_hash_table(addr_hash_table_1);
599
-	if (addr_hash_table_2) free_addr_hash_table(addr_hash_table_2);
600
-	if (addr_hash_table) shm_free(addr_hash_table);
601
-	if (subnet_table_1) free_subnet_table(subnet_table_1);
602
-	if (subnet_table_2) free_subnet_table(subnet_table_2);
603
-	if (subnet_table) shm_free(subnet_table);
604
-	if (domain_list_table_1) free_domain_name_table(domain_list_table_1);
605
-	if (domain_list_table_2) free_domain_name_table(domain_list_table_2);
606
-	if (domain_list_table) shm_free(domain_list_table);
599
+	if (perm_addr_table_1) free_addr_hash_table(perm_addr_table_1);
600
+	if (perm_addr_table_2) free_addr_hash_table(perm_addr_table_2);
601
+	if (perm_addr_table) shm_free(perm_addr_table);
602
+	if (perm_subnet_table_1) free_subnet_table(perm_subnet_table_1);
603
+	if (perm_subnet_table_2) free_subnet_table(perm_subnet_table_2);
604
+	if (perm_subnet_table) shm_free(perm_subnet_table);
605
+	if (perm_domain_table_1) free_domain_name_table(perm_domain_table_1);
606
+	if (perm_domain_table_2) free_domain_name_table(perm_domain_table_2);
607
+	if (perm_domain_table) shm_free(perm_domain_table);
607 608
 }
608 609
 
609 610
 
... ...
@@ -614,19 +615,19 @@ int allow_address(sip_msg_t *_msg, int addr_group, str *ips, int port)
614 615
 	ipa=strtoipX(ips);
615 616
 
616 617
 	if ( ipa ) {
617
-		if (addr_hash_table
618
-				&& match_addr_hash_table(*addr_hash_table, addr_group,
618
+		if (perm_addr_table
619
+				&& match_addr_hash_table(*perm_addr_table, addr_group,
619 620
 					ipa, (unsigned int)port) == 1) {
620 621
 			return 1;
621 622
 		} else {
622
-			if(subnet_table) {
623
-				return match_subnet_table(*subnet_table, addr_group, ipa,
623
+			if(perm_subnet_table) {
624
+				return match_subnet_table(*perm_subnet_table, addr_group, ipa,
624 625
 						(unsigned int)port);
625 626
 			}
626 627
 		}
627 628
 	} else {
628
-		if(domain_list_table) {
629
-			return match_domain_name_table(*domain_list_table, addr_group, ips,
629
+		if(perm_domain_table) {
630
+			return match_domain_name_table(*perm_domain_table, addr_group, ips,
630 631
 					(unsigned int)port);
631 632
 		}
632 633
 	}
... ...
@@ -670,12 +671,12 @@ int allow_source_address(sip_msg_t *_msg, int addr_group)
670 671
 	LM_DBG("looking for <%u, %x, %u>\n",
671 672
 			addr_group, _msg->rcv.src_ip.u.addr32[0], _msg->rcv.src_port);
672 673
 
673
-	if (addr_hash_table && match_addr_hash_table(*addr_hash_table, addr_group,
674
+	if (perm_addr_table && match_addr_hash_table(*perm_addr_table, addr_group,
674 675
 				&_msg->rcv.src_ip, _msg->rcv.src_port) == 1) {
675 676
 		return 1;
676 677
 	} else {
677
-		if(subnet_table) {
678
-			return match_subnet_table(*subnet_table, addr_group,
678
+		if(perm_subnet_table) {
679
+			return match_subnet_table(*perm_subnet_table, addr_group,
679 680
 					&_msg->rcv.src_ip,
680 681
 					_msg->rcv.src_port);
681 682
 		}
... ...
@@ -711,8 +712,8 @@ int ki_allow_source_address_group(sip_msg_t* _msg)
711 712
 
712 713
 	LM_DBG("looking for <%x, %u> in address table\n",
713 714
 			_msg->rcv.src_ip.u.addr32[0], _msg->rcv.src_port);
714
-	if(addr_hash_table) {
715
-		group = find_group_in_addr_hash_table(*addr_hash_table,
715
+	if(perm_addr_table) {
716
+		group = find_group_in_addr_hash_table(*perm_addr_table,
716 717
 				&_msg->rcv.src_ip, _msg->rcv.src_port);
717 718
 		LM_DBG("Found <%d>\n", group);
718 719
 
... ...
@@ -721,8 +722,8 @@ int ki_allow_source_address_group(sip_msg_t* _msg)
721 722
 
722 723
 	LM_DBG("looking for <%x, %u> in subnet table\n",
723 724
 			_msg->rcv.src_ip.u.addr32[0], _msg->rcv.src_port);
724
-	if(subnet_table) {
725
-		group = find_group_in_subnet_table(*subnet_table,
725
+	if(perm_subnet_table) {
726
+		group = find_group_in_subnet_table(*perm_subnet_table,
726 727
 				&_msg->rcv.src_ip, _msg->rcv.src_port);
727 728
 	}
728 729
 	LM_DBG("Found <%d>\n", group);
... ...
@@ -756,25 +757,25 @@ int ki_allow_address_group(sip_msg_t* _msg, str* _addr, int _port)
756 757
 	if ( ipa ) {
757 758
 		LM_DBG("looking for <%.*s, %u> in address table\n",
758 759
 				_addr->len, _addr->s, (unsigned int)_port);
759
-		if(addr_hash_table) {
760
-			group = find_group_in_addr_hash_table(*addr_hash_table,
760
+		if(perm_addr_table) {
761
+			group = find_group_in_addr_hash_table(*perm_addr_table,
761 762
 					ipa, (unsigned int)_port);
762 763
 			LM_DBG("Found address in group <%d>\n", group);
763 764
 
764 765
 			if (group != -1) return group;
765 766
 		}
766
-		if(subnet_table) {
767
+		if(perm_subnet_table) {
767 768
 			LM_DBG("looking for <%.*s, %u> in subnet table\n",
768 769
 					_addr->len, _addr->s, _port);
769
-			group = find_group_in_subnet_table(*subnet_table,
770
+			group = find_group_in_subnet_table(*perm_subnet_table,
770 771
 					ipa, (unsigned int)_port);
771 772
 			LM_DBG("Found a match of subnet in group <%d>\n", group);
772 773
 		}
773 774
 	} else {
774 775
 		LM_DBG("looking for <%.*s, %u> in domain_name table\n",
775 776
 				_addr->len, _addr->s, (unsigned int)_port);
776
-		if(domain_list_table) {
777
-			group = find_group_in_domain_name_table(*domain_list_table,
777
+		if(perm_domain_table) {
778
+			group = find_group_in_domain_name_table(*perm_domain_table,
778 779
 					_addr, (unsigned int)_port);
779 780
 			LM_DBG("Found a match of domain_name in group <%d>\n", group);
780 781
 		}
... ...
@@ -27,15 +27,15 @@
27 27
 
28 28
 
29 29
 /* Pointer to current address hash table pointer */
30
-extern struct addr_list ***addr_hash_table;
30
+extern struct addr_list ***perm_addr_table;
31 31
 
32 32
 
33 33
 /* Pointer to current subnet table */
34
-extern struct subnet **subnet_table;
34
+extern struct subnet **perm_subnet_table;
35 35
 
36 36
 
37 37
 /* Pointer to current domain name table */
38
-extern struct domain_name_list ***domain_list_table;
38
+extern struct domain_name_list ***perm_domain_table;
39 39
 
40 40
 /*
41 41
  * Initialize data structures
... ...
@@ -41,7 +41,7 @@
41 41
 static int     tag_avp_type;
42 42
 static int_str tag_avp;
43 43
 
44
-extern int peer_tag_mode;
44
+extern int perm_peer_tag_mode;
45 45
 
46 46
 
47 47
 extern int _perm_max_subnets;
... ...
@@ -321,7 +321,7 @@ int match_hash_table(struct trusted_list** table, struct sip_msg* msg,
321 321
 					return -1;
322 322
 				}
323 323
 			}
324
-			if (!peer_tag_mode)
324
+			if (!perm_peer_tag_mode)
325 325
 				return 1;
326 326
 			count++;
327 327
 		}
... ...
@@ -46,47 +46,47 @@
46 46
 
47 47
 MODULE_VERSION
48 48
 
49
-static rule_file_t allow[MAX_RULE_FILES]; /* Parsed allow files */
50
-static rule_file_t deny[MAX_RULE_FILES];  /* Parsed deny files */
51
-static int rules_num = 0;  /* Number of parsed allow/deny files */
49
+static rule_file_t perm_allow[MAX_RULE_FILES]; /* Parsed allow files */
50
+static rule_file_t perm_deny[MAX_RULE_FILES];  /* Parsed deny files */
51
+static int perm_rules_num = 0;  /* Number of parsed allow/deny files */
52 52
 
53 53
 
54 54
 /* Module parameter variables */
55
-static char* default_allow_file = DEFAULT_ALLOW_FILE;
56
-static char* default_deny_file = DEFAULT_DENY_FILE;
57
-char* allow_suffix = ".allow";
58
-static char* deny_suffix = ".deny";
55
+static char* perm_default_allow_file = DEFAULT_ALLOW_FILE;
56
+static char* perm_default_deny_file = DEFAULT_DENY_FILE;
57
+char* perm_allow_suffix = ".allow";
58
+static char* perm_deny_suffix = ".deny";
59 59
 
60 60
 
61 61
 /* for allow_trusted and allow_address function */
62
-str db_url = {NULL, 0};                    /* Don't connect to the database by default */
62
+str perm_db_url = {NULL, 0};                    /* Don't connect to the database by default */
63 63
 
64 64
 /* for allow_trusted function */
65
-int db_mode = DISABLE_CACHE;               /* Database usage mode: 0=no cache, 1=cache */
66
-str trusted_table = str_init("trusted");   /* Name of trusted table */
67
-str source_col = str_init("src_ip");       /* Name of source address column */
68
-str proto_col = str_init("proto");         /* Name of protocol column */
69
-str from_col = str_init("from_pattern");   /* Name of from pattern column */
70
-str ruri_col = str_init("ruri_pattern");   /* Name of RURI pattern column */
71
-str tag_col = str_init("tag");             /* Name of tag column */
72
-str priority_col = str_init("priority");   /* Name of priority column */
73
-str tag_avp_param = {NULL, 0};             /* Peer tag AVP spec */
74
-int peer_tag_mode = 0;                     /* Add tags form all mathcing peers to avp */
65
+int perm_db_mode = DISABLE_CACHE;               /* Database usage mode: 0=no cache, 1=cache */
66
+str perm_trusted_table = str_init("trusted");   /* Name of trusted table */
67
+str perm_source_col = str_init("src_ip");       /* Name of source address column */
68
+str perm_proto_col = str_init("proto");         /* Name of protocol column */
69
+str perm_from_col = str_init("from_pattern");   /* Name of from pattern column */
70
+str perm_ruri_col = str_init("ruri_pattern");   /* Name of RURI pattern column */
71
+str perm_tag_col = str_init("tag");             /* Name of tag column */
72
+str perm_priority_col = str_init("priority");   /* Name of priority column */
73
+str perm_tag_avp_param = {NULL, 0};             /* Peer tag AVP spec */
74
+int perm_peer_tag_mode = 0;                     /* Add tags form all mathcing peers to avp */
75 75
 
76 76
 /* for allow_address function */
77
-str address_table = str_init("address");   /* Name of address table */
78
-str grp_col = str_init("grp");             /* Name of address group column */
79
-str ip_addr_col = str_init("ip_addr");     /* Name of ip address column */
80
-str mask_col = str_init("mask");           /* Name of mask column */
81
-str port_col = str_init("port");           /* Name of port column */
77
+str perm_address_table = str_init("address");   /* Name of address table */
78
+str perm_grp_col = str_init("grp");             /* Name of address group column */
79
+str perm_ip_addr_col = str_init("ip_addr");     /* Name of ip address column */
80
+str perm_mask_col = str_init("mask");           /* Name of mask column */
81
+str perm_port_col = str_init("port");           /* Name of port column */
82 82
 
83
-static str address_file_param = STR_NULL;  /* Path to file with address records */
84
-str address_file = STR_NULL;			   /* Full path to file with address records */
83
+static str perm_address_file_param = STR_NULL;  /* Path to file with address records */
84
+str perm_address_file = STR_NULL;			   /* Full path to file with address records */
85 85
 
86 86
 /*
87 87
  * By default we check all branches
88 88
  */
89
-static int check_all_branches = 1;
89
+static int perm_check_all_branches = 1;
90 90
 
91 91
 
92 92
 int _perm_max_subnets = 512;
... ...
@@ -162,30 +162,30 @@ static cmd_export_t cmds[] = {
162 162
 
163 163
 /* Exported parameters */
164 164
 static param_export_t params[] = {
165
-	{"default_allow_file", PARAM_STRING, &default_allow_file},
166
-	{"default_deny_file",  PARAM_STRING, &default_deny_file },
167
-	{"check_all_branches", INT_PARAM, &check_all_branches},
168
-	{"allow_suffix",       PARAM_STRING, &allow_suffix      },
169
-	{"deny_suffix",        PARAM_STRING, &deny_suffix       },
170
-	{"db_url",             PARAM_STR, &db_url          },
171
-	{"db_mode",            INT_PARAM, &db_mode           },
172
-	{"trusted_table",      PARAM_STR, &trusted_table   },
173
-	{"source_col",         PARAM_STR, &source_col      },
174
-	{"proto_col",          PARAM_STR, &proto_col       },
175
-	{"from_col",           PARAM_STR, &from_col        },
176
-	{"ruri_col",           PARAM_STR, &ruri_col        },
177
-	{"tag_col",            PARAM_STR, &tag_col         },
178
-	{"priority_col",       PARAM_STR, &priority_col    },
179
-	{"peer_tag_avp",       PARAM_STR, &tag_avp_param   },
180
-	{"peer_tag_mode",      INT_PARAM, &peer_tag_mode     },
181
-	{"address_table",      PARAM_STR, &address_table   },
182
-	{"address_file",       PARAM_STR, &address_file_param   },
183
-	{"grp_col",            PARAM_STR, &grp_col         },
184
-	{"ip_addr_col",        PARAM_STR, &ip_addr_col     },
185
-	{"mask_col",           PARAM_STR, &mask_col        },
186
-	{"port_col",           PARAM_STR, &port_col        },
187
-	{"max_subnets",        PARAM_INT, &_perm_max_subnets },
188
-	{"load_backends",      PARAM_INT, &_perm_load_backends },
165
+	{"default_allow_file", PARAM_STRING, &perm_default_allow_file},
166
+	{"default_deny_file",  PARAM_STRING, &perm_default_deny_file },
167
+	{"check_all_branches", INT_PARAM, &perm_check_all_branches   },
168
+	{"allow_suffix",       PARAM_STRING, &perm_allow_suffix      },
169
+	{"deny_suffix",        PARAM_STRING, &perm_deny_suffix       },
170
+	{"db_url",             PARAM_STR, &perm_db_url          },
171
+	{"db_mode",            INT_PARAM, &perm_db_mode         },
172
+	{"trusted_table",      PARAM_STR, &perm_trusted_table   },
173
+	{"source_col",         PARAM_STR, &perm_source_col      },
174
+	{"proto_col",          PARAM_STR, &perm_proto_col       },
175
+	{"from_col",           PARAM_STR, &perm_from_col        },
176
+	{"ruri_col",           PARAM_STR, &perm_ruri_col        },
177
+	{"tag_col",            PARAM_STR, &perm_tag_col         },
178
+	{"priority_col",       PARAM_STR, &perm_priority_col    },
179
+	{"peer_tag_avp",       PARAM_STR, &perm_tag_avp_param   },
180
+	{"peer_tag_mode",      INT_PARAM, &perm_peer_tag_mode   },
181
+	{"address_table",      PARAM_STR, &perm_address_table   },
182
+	{"address_file",       PARAM_STR, &perm_address_file_param   },
183
+	{"grp_col",            PARAM_STR, &perm_grp_col         },
184
+	{"ip_addr_col",        PARAM_STR, &perm_ip_addr_col     },
185
+	{"mask_col",           PARAM_STR, &perm_mask_col        },
186
+	{"port_col",           PARAM_STR, &perm_port_col        },
187
+	{"max_subnets",        PARAM_INT, &_perm_max_subnets    },
188
+	{"load_backends",      PARAM_INT, &_perm_load_backends  },
189 189
 	{0, 0, 0}
190 190
 };
191 191
 
... ...
@@ -264,7 +264,7 @@ static int find_index(rule_file_t* array, char* pathname)
264 264
 {
265 265
 	int i;
266 266
 
267
-	for(i = 0; i < rules_num; i++) {
267
+	for(i = 0; i < perm_rules_num; i++) {
268 268
 		if (!strcmp(pathname, array[i].filename)) return i;
269 269
 	}
270 270
 
... ...
@@ -332,7 +332,7 @@ static int check_routing(struct sip_msg* msg, int idx)
332 332
 	int br_idx;
333 333
 
334 334
 	/* turn off control, allow any routing */
335
-	if ((!allow[idx].rules) && (!deny[idx].rules)) {
335
+	if ((!perm_allow[idx].rules) && (!perm_deny[idx].rules)) {
336 336
 		LM_DBG("no rules => allow any routing\n");
337 337
 		return 1;
338 338
 	}
... ...
@@ -383,19 +383,19 @@ static int check_routing(struct sip_msg* msg, int idx)
383 383
 
384 384
 	LM_DBG("looking for From: %s Request-URI: %s\n", from_str, ruri_str);
385 385
 	/* rule exists in allow file */
386
-	if (search_rule(allow[idx].rules, from_str, ruri_str)) {
387
-		if (check_all_branches) goto check_branches;
386
+	if (search_rule(perm_allow[idx].rules, from_str, ruri_str)) {
387
+		if (perm_check_all_branches) goto check_branches;
388 388
 		LM_DBG("allow rule found => routing is allowed\n");
389 389
 		return 1;
390 390
 	}
391 391
 
392 392
 	/* rule exists in deny file */
393
-	if (search_rule(deny[idx].rules, from_str, ruri_str)) {
393
+	if (search_rule(perm_deny[idx].rules, from_str, ruri_str)) {
394 394
 		LM_DBG("deny rule found => routing is denied\n");
395 395
 		return -1;
396 396
 	}
397 397
 
398
-	if (!check_all_branches) {
398
+	if (!perm_check_all_branches) {
399 399
 		LM_DBG("neither allow nor deny rule found => routing is allowed\n");
400 400
 		return 1;
401 401
 	}
... ...
@@ -410,11 +410,11 @@ check_branches:
410 410
 		}
411 411
 		LM_DBG("looking for From: %s Branch: %s\n", from_str, uri_str);
412 412
 
413
-		if (search_rule(allow[idx].rules, from_str, uri_str)) {
413
+		if (search_rule(perm_allow[idx].rules, from_str, uri_str)) {
414 414
 			continue;
415 415
 		}
416 416
 
417
-		if (search_rule(deny[idx].rules, from_str, uri_str)) {
417
+		if (search_rule(perm_deny[idx].rules, from_str, uri_str)) {
418 418
 			LM_DBG("deny rule found for one of branches => routing"
419 419
 					"is denied\n");
420 420
 			return -1;
... ...
@@ -436,9 +436,9 @@ static int load_fixup(void** param, int param_no)
436 436
 	rule_file_t* table;
437 437
 
438 438
 	if (param_no == 1) {
439
-		table = allow;
439
+		table = perm_allow;
440 440
 	} else {
441
-		table = deny;
441
+		table = perm_deny;
442 442
 	}
443 443
 
444 444
 	pathname = get_pathname(*param);
... ...
@@ -446,15 +446,15 @@ static int load_fixup(void** param, int param_no)
446 446
 
447 447
 	if (idx == -1) {
448 448
 		/* Not opened yet, open the file and parse it */
449
-		table[rules_num].filename = pathname;
450
-		table[rules_num].rules = parse_config_file(pathname);
451
-		if (table[rules_num].rules) {
449
+		table[perm_rules_num].filename = pathname;
450
+		table[perm_rules_num].rules = parse_config_file(pathname);
451
+		if (table[perm_rules_num].rules) {
452 452
 			LM_DBG("file (%s) parsed\n", pathname);
453 453
 		} else {
454 454
 			LM_INFO("file (%s) not parsed properly => empty rule set\n", pathname);
455 455
 		}
456
-		*param = (void*)(long)rules_num;
457
-		if (param_no == 2) rules_num++;
456
+		*param = (void*)(long)perm_rules_num;
457
+		if (param_no == 2) perm_rules_num++;
458 458
 	} else {
459 459
 		/* File already parsed, re-use it */
460 460
 		LM_DBG("file (%s) already loaded, re-using\n", pathname);
... ...
@@ -478,10 +478,10 @@ static int single_fixup(void** param, int param_no)
478 478
 	if (param_no != 1) return 0;
479 479
 
480 480
 	param_len = strlen((char*)*param);
481
-	if (strlen(allow_suffix) > strlen(deny_suffix)) {
482
-		suffix_len = strlen(allow_suffix);
481
+	if (strlen(perm_allow_suffix) > strlen(perm_deny_suffix)) {
482
+		suffix_len = strlen(perm_allow_suffix);
483 483
 	} else {
484
-		suffix_len = strlen(deny_suffix);
484
+		suffix_len = strlen(perm_deny_suffix);
485 485
 	}
486 486
 
487 487
 	buffer = pkg_malloc(param_len + suffix_len + 1);
... ...
@@ -491,11 +491,11 @@ static int single_fixup(void** param, int param_no)
491 491
 	}
492 492
 
493 493
 	strcpy(buffer, (char*)*param);
494
-	strcat(buffer, allow_suffix);
494
+	strcat(buffer, perm_allow_suffix);
495 495
 	tmp = buffer;
496 496
 	ret = load_fixup(&tmp, 1);
497 497
 
498
-	strcpy(buffer + param_len, deny_suffix);
498
+	strcpy(buffer + param_len, perm_deny_suffix);
499 499
 	tmp = buffer;
500 500
 	ret |= load_fixup(&tmp, 2);
501 501
 
... ...
@@ -520,10 +520,10 @@ static int double_fixup(void** param, int param_no)
520 520
 
521 521
 	if (param_no == 1) { /* basename */
522 522
 		param_len = strlen((char*)*param);
523
-		if (strlen(allow_suffix) > strlen(deny_suffix)) {
524
-			suffix_len = strlen(allow_suffix);
523
+		if (strlen(perm_allow_suffix) > strlen(perm_deny_suffix)) {
524
+			suffix_len = strlen(perm_allow_suffix);
525 525
 		} else {
526
-			suffix_len = strlen(deny_suffix);
526
+			suffix_len = strlen(perm_deny_suffix);
527 527
 		}
528 528
 
529 529
 		buffer = pkg_malloc(param_len + suffix_len + 1);
... ...
@@ -533,11 +533,11 @@ static int double_fixup(void** param, int param_no)
533 533
 		}
534 534
 
535 535
 		strcpy(buffer, (char*)*param);
536
-		strcat(buffer, allow_suffix);
536
+		strcat(buffer, perm_allow_suffix);
537 537
 		tmp = buffer;
538 538
 		ret = load_fixup(&tmp, 1);
539 539
 
540
-		strcpy(buffer + param_len, deny_suffix);
540
+		strcpy(buffer + param_len, perm_deny_suffix);
541 541
 		tmp = buffer;
542 542
 		ret |= load_fixup(&tmp, 2);
543 543
 
... ...
@@ -593,34 +593,34 @@ static int mod_init(void)
593 593
 	}
594 594
 
595 595
 	if(_perm_load_backends&PERM_LOAD_ALLOWFILE) {
596
-		allow[0].filename = get_pathname(default_allow_file);
597
-		allow[0].rules = parse_config_file(allow[0].filename);
598
-		if (allow[0].rules) {
599
-			LM_DBG("default allow file (%s) parsed\n", allow[0].filename);
596
+		perm_allow[0].filename = get_pathname(perm_default_allow_file);
597
+		perm_allow[0].rules = parse_config_file(perm_allow[0].filename);
598
+		if (perm_allow[0].rules) {
599
+			LM_DBG("default allow file (%s) parsed\n", perm_allow[0].filename);
600 600
 		} else {
601 601
 			LM_INFO("default allow file (%s) not found => empty rule set\n",
602
-					allow[0].filename);
602
+					perm_allow[0].filename);
603 603
 		}
604 604
 	} else {
605
-		allow[0].filename = NULL;
606
-		allow[0].rules = NULL;
605
+		perm_allow[0].filename = NULL;
606
+		perm_allow[0].rules = NULL;
607 607
 	}
608 608
 
609 609
 	if(_perm_load_backends&PERM_LOAD_DENYFILE) {
610
-		deny[0].filename = get_pathname(default_deny_file);
611
-		deny[0].rules = parse_config_file(deny[0].filename);
612
-		if (deny[0].rules) {
613
-			LM_DBG("default deny file (%s) parsed\n", deny[0].filename);
610
+		perm_deny[0].filename = get_pathname(perm_default_deny_file);
611
+		perm_deny[0].rules = parse_config_file(perm_deny[0].filename);
612
+		if (perm_deny[0].rules) {
613
+			LM_DBG("default deny file (%s) parsed\n", perm_deny[0].filename);
614 614
 		} else {
615 615
 			LM_INFO("default deny file (%s) not found => empty rule set\n",
616
-					deny[0].filename);
616
+					perm_deny[0].filename);
617 617
 		}
618 618
 	} else {
619
-		deny[0].filename = NULL;
620
-		deny[0].rules = NULL;
619
+		perm_deny[0].filename = NULL;
620
+		perm_deny[0].rules = NULL;
621 621
 	}
622 622
 
623
-	if (init_tag_avp(&tag_avp_param) < 0) {
623
+	if (init_tag_avp(&perm_tag_avp_param) < 0) {
624 624
 		LM_ERR("failed to process peer_tag_avp AVP param\n");
625 625
 		return -1;
626 626
 	}
... ...
@@ -633,13 +633,13 @@ static int mod_init(void)
633 633
 	}
634 634
 
635 635
 	if(_perm_load_backends&PERM_LOAD_ADDRESSDB) {
636
-		if(address_file_param.s!=NULL && address_file_param.len>0) {
637
-			address_file.s = get_pathname(address_file_param.s);
638
-			if(address_file.s==NULL) {
636
+		if(perm_address_file_param.s!=NULL && perm_address_file_param.len>0) {
637
+			perm_address_file.s = get_pathname(perm_address_file_param.s);
638
+			if(perm_address_file.s==NULL) {
639 639
 				LM_ERR("failed to set full path to address file\n");
640 640
 				return -1;
641 641
 			}
642
-			address_file.len = strlen(address_file.s);
642
+			perm_address_file.len = strlen(perm_address_file.s);
643 643
 		}
644 644
 		if (init_addresses() != 0) {
645 645
 			LM_ERR("failed to initialize the allow_address function\n");
... ...
@@ -647,12 +647,12 @@ static int mod_init(void)
647 647
 		}
648 648
 	}
649 649
 
650
-	if ((db_mode != DISABLE_CACHE) && (db_mode != ENABLE_CACHE)) {
651
-		LM_ERR("invalid db_mode value: %d\n", db_mode);
650
+	if ((perm_db_mode != DISABLE_CACHE) && (perm_db_mode != ENABLE_CACHE)) {
651
+		LM_ERR("invalid db_mode value: %d\n", perm_db_mode);
652 652
 		return -1;
653 653
 	}
654 654
 
655
-	rules_num = 1;
655
+	perm_rules_num = 1;
656 656
 	return 0;
657 657
 }
658 658
 
... ...
@@ -674,12 +674,12 @@ static void mod_exit(void)
674 674
 {
675 675
 	int i;
676 676
 
677
-	for(i = 0; i < rules_num; i++) {
678
-		if(allow[i].rules) free_rule(allow[i].rules);
679
-		if(allow[i].filename) pkg_free(allow[i].filename);
677
+	for(i = 0; i < perm_rules_num; i++) {
678
+		if(perm_allow[i].rules) free_rule(perm_allow[i].rules);
679
+		if(perm_allow[i].filename) pkg_free(perm_allow[i].filename);
680 680
 
681
-		if(deny[i].rules) free_rule(deny[i].rules);
682
-		if(deny[i].filename) pkg_free(deny[i].filename);
681
+		if(perm_deny[i].rules) free_rule(perm_deny[i].rules);
682
+		if(perm_deny[i].filename) pkg_free(perm_deny[i].filename);
683 683
 	}
684 684
 
685 685
 	clean_trusted();
... ...
@@ -728,7 +728,7 @@ static int check_register(struct sip_msg* msg, int idx)
728 728
 	contact_t* c;
729 729
 
730 730
 	/* turn off control, allow any routing */
731
-	if ((!allow[idx].rules) && (!deny[idx].rules)) {
731
+	if ((!perm_allow[idx].rules) && (!perm_deny[idx].rules)) {
732 732
 		LM_DBG("no rules => allow any registration\n");
733 733
 		return 1;
734 734
 	}
... ...
@@ -793,12 +793,12 @@ static int check_register(struct sip_msg* msg, int idx)
793 793
 		LM_DBG("looking for To: %s Contact: %s\n", to_str, contact_str);
794 794
 
795 795
 		/* rule exists in allow file */
796
-		if (search_rule(allow[idx].rules, to_str, contact_str)) {
797
-			if (check_all_branches) goto skip_deny;
796
+		if (search_rule(perm_allow[idx].rules, to_str, contact_str)) {
797
+			if (perm_check_all_branches) goto skip_deny;
798 798
 		}
799 799
 
800 800
 		/* rule exists in deny file */
801
-		if (search_rule(deny[idx].rules, to_str, contact_str)) {
801
+		if (search_rule(perm_deny[idx].rules, to_str, contact_str)) {
802 802
 			LM_DBG("deny rule found => Register denied\n");
803 803
 			return -1;
804 804
 		}
... ...
@@ -845,7 +845,7 @@ static int allow_uri(struct sip_msg* msg, char* _idx, char* _sp)
845 845
 	sp = (pv_spec_t *)_sp;
846 846
 
847 847
 	/* turn off control, allow any uri */
848
-	if ((!allow[idx].rules) && (!deny[idx].rules)) {
848
+	if ((!perm_allow[idx].rules) && (!perm_deny[idx].rules)) {
849 849
 		LM_DBG("no rules => allow any uri\n");
850 850
 		return 1;
851 851
 	}
... ...
@@ -896,13 +896,13 @@ static int allow_uri(struct sip_msg* msg, char* _idx, char* _sp)
896 896
 
897 897
 	LM_DBG("looking for From: %s URI: %s\n", from_str, uri_str);
898 898
 	/* rule exists in allow file */
899
-	if (search_rule(allow[idx].rules, from_str, uri_str)) {
899
+	if (search_rule(perm_allow[idx].rules, from_str, uri_str)) {
900 900
 		LM_DBG("allow rule found => URI is allowed\n");
901 901
 		return 1;
902 902
 	}
903 903
 
904 904
 	/* rule exists in deny file */
905
-	if (search_rule(deny[idx].rules, from_str, uri_str)) {
905
+	if (search_rule(perm_deny[idx].rules, from_str, uri_str)) {
906 906
 		LM_DBG("deny rule found => URI is denied\n");
907 907
 		return -1;
908 908
 	}
... ...
@@ -927,7 +927,7 @@ int allow_test(char *file, char *uri, char *contact)
927 927
 		return 0;
928 928
 	}
929 929
 
930
-	idx = find_index(allow, pathname);
930
+	idx = find_index(perm_allow, pathname);
931 931
 	if (idx == -1) {
932 932
 		LM_ERR("File <%s> has not been loaded\n", pathname);
933 933
 		pkg_free(pathname);
... ...
@@ -937,7 +937,7 @@ int allow_test(char *file, char *uri, char *contact)
937 937
 	pkg_free(pathname);
938 938
 
939 939
 	/* turn off control, allow any routing */
940
-	if ((!allow[idx].rules) && (!deny[idx].rules)) {
940
+	if ((!perm_allow[idx].rules) && (!perm_deny[idx].rules)) {
941 941
 		LM_DBG("No rules => Allowed\n");
942 942
 		return 1;
943 943
 	}
... ...
@@ -945,13 +945,13 @@ int allow_test(char *file, char *uri, char *contact)
945 945
 	LM_DBG("Looking for URI: %s, Contact: %s\n", uri, contact);
946 946
 
947 947
 	/* rule exists in allow file */
948
-	if (search_rule(allow[idx].rules, uri, contact)) {
948
+	if (search_rule(perm_allow[idx].rules, uri, contact)) {
949 949
 		LM_DBG("Allow rule found => Allowed\n");
950 950
 		return 1;
951 951
 	}
952 952
 
953 953
 	/* rule exists in deny file */
954
-	if (search_rule(deny[idx].rules, uri, contact)) {
954
+	if (search_rule(perm_deny[idx].rules, uri, contact)) {
955 955
 		LM_DBG("Deny rule found => Denied\n");
956 956
 		return 0;
957 957
 	}
... ...
@@ -44,21 +44,21 @@ typedef struct rule_file {
44 44
  */
45 45
 #define MAX_RULE_FILES 64
46 46
 
47
-extern str db_url;        /* Database URL */
48
-extern int db_mode;       /* Database usage mode: 0=no cache, 1=cache */
49
-extern str trusted_table; /* Name of trusted table */
50
-extern str source_col;    /* Name of source address column */
51
-extern str proto_col;     /* Name of protocol column */
52
-extern str from_col;      /* Name of from pattern column */
53
-extern str ruri_col;      /* Name of RURI pattern column */
54
-extern str tag_col;       /* Name of tag column */
55
-extern str priority_col;  /* Name of priority column */
56
-extern str address_table; /* Name of address table */
57
-extern str grp_col;       /* Name of address group column */
58
-extern str ip_addr_col;   /* Name of ip address column */
59
-extern str mask_col;      /* Name of mask column */
60
-extern str port_col;      /* Name of port column */
61
-extern int peer_tag_mode; /* Matching mode */
47
+extern str perm_db_url;        /* Database URL */
48
+extern int perm_db_mode;       /* Database usage mode: 0=no cache, 1=cache */
49
+extern str perm_trusted_table; /* Name of trusted table */
50
+extern str perm_source_col;    /* Name of source address column */
51
+extern str perm_proto_col;     /* Name of protocol column */
52
+extern str perm_from_col;      /* Name of from pattern column */
53
+extern str perm_ruri_col;      /* Name of RURI pattern column */
54
+extern str perm_tag_col;       /* Name of tag column */
55
+extern str perm_priority_col;  /* Name of priority column */
56
+extern str perm_address_table; /* Name of address table */
57
+extern str perm_grp_col;       /* Name of address group column */
58
+extern str perm_ip_addr_col;   /* Name of ip address column */
59
+extern str perm_mask_col;      /* Name of mask column */
60
+extern str perm_port_col;      /* Name of port column */
61
+extern int perm_peer_tag_mode; /* Matching mode */
62 62
 
63 63
 /* backends to be loaded */
64 64
 #define PERM_LOAD_ADDRESSDB	(1<<0)
... ...
@@ -75,7 +75,7 @@ typedef struct int_or_pvar {
75 75
 #define DISABLE_CACHE 0
76 76
 #define ENABLE_CACHE 1
77 77
 
78
-extern char *allow_suffix;
78
+extern char *perm_allow_suffix;
79 79
 int allow_test(char *file, char *uri, char *contact);
80 80
 
81 81
 #endif
... ...
@@ -49,12 +49,12 @@ void rpc_trusted_reload(rpc_t* rpc, void* c) {
49 49
  */
50 50
 void rpc_trusted_dump(rpc_t* rpc, void* c) {
51 51
 
52
-	if (hash_table==NULL) {
52
+	if (perm_trust_table==NULL) {
53 53
 		rpc->fault(c, 500, "No trusted table");
54 54
 		return;
55 55
 	}
56 56
 
57
-	if(hash_table_rpc_print(*hash_table, rpc, c) < 0) {
57
+	if(hash_table_rpc_print(*perm_trust_table, rpc, c) < 0) {
58 58
 		LM_DBG("failed to print a hash_table dump\n");
59 59
 		return;
60 60
 	}
... ...
@@ -82,11 +82,11 @@ void rpc_address_reload(rpc_t* rpc, void* c) {
82 82
  */
83 83
 void rpc_address_dump(rpc_t* rpc, void* c) {
84 84
 
85
-	if(addr_hash_table==NULL) {
85
+	if(perm_addr_table==NULL) {
86 86
 		rpc->fault(c, 500, "No address table");
87 87
 		return;
88 88
 	}
89
-	if(addr_hash_table_rpc_print(*addr_hash_table, rpc, c) < 0 ) {
89
+	if(addr_hash_table_rpc_print(*perm_addr_table, rpc, c) < 0 ) {
90 90
 		LM_DBG("failed to print address table dump\n");
91 91
 	}
92 92
 	return;
... ...
@@ -97,11 +97,11 @@ void rpc_address_dump(rpc_t* rpc, void* c) {
97 97
  * RPC function to dump subnet table
98 98
  */
99 99
 void rpc_subnet_dump(rpc_t* rpc, void* c) {
100
-	if(subnet_table==NULL) {
100
+	if(perm_subnet_table==NULL) {
101 101
 		rpc->fault(c, 500, "No subnet table");
102 102
 		return;
103 103
 	}
104
-	if(subnet_table_rpc_print(*subnet_table, rpc, c) < 0) {
104
+	if(subnet_table_rpc_print(*perm_subnet_table, rpc, c) < 0) {
105 105
 		LM_DBG("failed to print subnet table dump\n");
106 106
 	}
107 107
 
... ...
@@ -114,11 +114,11 @@ void rpc_subnet_dump(rpc_t* rpc, void* c) {
114 114
  */
115 115
 void rpc_domain_name_dump(rpc_t* rpc, void* c) {
116 116
 
117
-	if(domain_list_table==NULL) {
117
+	if(perm_domain_table==NULL) {
118 118
 		rpc->fault(c, 500, "No domain list table");
119 119
 		return;
120 120
 	}
121
-	if ( domain_name_table_rpc_print(*domain_list_table, rpc, c) < 0 ) {
121
+	if ( domain_name_table_rpc_print(*perm_domain_table, rpc, c) < 0 ) {
122 122
 		LM_DBG("failed to print domain table dump\n");
123 123
 	}
124 124
 	return;
... ...
@@ -155,14 +155,14 @@ void rpc_test_uri(rpc_t* rpc, void* c)
155 155
 		rpc->fault(c, 500, "Contact is too long");
156 156
 		return;
157 157
 	}
158
-	allow_suffix_len = strlen(allow_suffix);
158
+	allow_suffix_len = strlen(perm_allow_suffix);
159 159
 	if (basenamep.len + allow_suffix_len + 1 > MAX_FILE_LEN) {
160 160
 		rpc->fault(c, 500, "Basename is too long");
161 161
 		return;
162 162
 	}
163 163
 
164 164
 	memcpy(basename, basenamep.s, basenamep.len);
165
-	memcpy(basename + basenamep.len, allow_suffix, allow_suffix_len);
165
+	memcpy(basename + basenamep.len, perm_allow_suffix, allow_suffix_len);
166 166
 	basename[basenamep.len + allow_suffix_len] = 0;
167 167
 	memcpy(uri, urip.s, urip.len);
168 168
 	memcpy(contact, contactp.s, contactp.len);
... ...
@@ -38,12 +38,12 @@
38 38
 
39 39
 #define TABLE_VERSION 6
40 40
 
41
-struct trusted_list ***hash_table = 0;    /* Pointer to current hash table pointer */
42
-struct trusted_list **hash_table_1 = 0;   /* Pointer to hash table 1 */
43
-struct trusted_list **hash_table_2 = 0;   /* Pointer to hash table 2 */
41
+struct trusted_list ***perm_trust_table = 0;    /* Pointer to current hash table pointer */
42
+struct trusted_list **perm_trust_table_1 = 0;   /* Pointer to hash table 1 */
43
+struct trusted_list **perm_trust_table_2 = 0;   /* Pointer to hash table 2 */
44 44
 
45 45
 
46
-static db1_con_t* db_handle = 0;
46
+static db1_con_t* perm_db_handle = 0;
47 47
 static db_func_t perm_dbf;
48 48
 
49 49
 
... ...
@@ -65,38 +65,38 @@ int reload_trusted_table(void)
65 65
 
66 66
 	char *pattern, *ruri_pattern, *tag;
67 67
 
68
-	if (hash_table == 0) {
68
+	if (perm_trust_table == 0) {
69 69
 		LM_ERR("in-memory hash table not initialized\n");
70 70
 		return -1;
71 71
 	}
72 72
 
73
-	if (db_handle == 0) {
73
+	if (perm_db_handle == 0) {
74 74
 		LM_ERR("no connection to database\n");
75 75
 		return -1;
76 76
 	}
77 77
 
78
-	cols[0] = &source_col;
79
-	cols[1] = &proto_col;
80
-	cols[2] = &from_col;
81
-	cols[3] = &ruri_col;
82
-	cols[4] = &tag_col;
83
-	cols[5] = &priority_col;
78
+	cols[0] = &perm_source_col;
79
+	cols[1] = &perm_proto_col;
80
+	cols[2] = &perm_from_col;
81
+	cols[3] = &perm_ruri_col;
82
+	cols[4] = &perm_tag_col;
83
+	cols[5] = &perm_priority_col;
84 84
 
85
-	if (perm_dbf.use_table(db_handle, &trusted_table) < 0) {
85
+	if (perm_dbf.use_table(perm_db_handle, &perm_trusted_table) < 0) {
86 86
 		LM_ERR("failed to use trusted table\n");
87 87
 		return -1;
88 88
 	}
89 89
 
90
-	if (perm_dbf.query(db_handle, NULL, 0, NULL, cols, 0, 6, 0, &res) < 0) {
90
+	if (perm_dbf.query(perm_db_handle, NULL, 0, NULL, cols, 0, 6, 0, &res) < 0) {
91 91
 		LM_ERR("failed to query database\n");
92 92
 		return -1;
93 93
 	}
94 94
 
95 95
 	/* Choose new hash table and free its old contents */
96
-	if (*hash_table == hash_table_1) {
97
-		new_hash_table = hash_table_2;
96
+	if (*perm_trust_table == perm_trust_table_1) {
97
+		new_hash_table = perm_trust_table_2;
98 98
 	} else {
99
-		new_hash_table = hash_table_1;
99
+		new_hash_table = perm_trust_table_1;
100 100
 	}
101 101
 	empty_hash_table(new_hash_table);
102 102
 
... ...
@@ -143,7 +143,7 @@ int reload_trusted_table(void)
143 143
 						(char *)VAL_STRING(val + 1),
144 144
 						pattern, ruri_pattern, tag, priority) == -1) {
145 145
 				LM_ERR("hash table problem\n");
146
-				perm_dbf.free_result(db_handle, res);
146
+				perm_dbf.free_result(perm_db_handle, res);
147 147
 				empty_hash_table(new_hash_table);
148 148
 				return -1;
149 149
 			}
... ...
@@ -152,16 +152,16 @@ int reload_trusted_table(void)
152 152
 					pattern, ruri_pattern, tag);
153 153
 		} else {
154 154
 			LM_ERR("database problem\n");
155
-			perm_dbf.free_result(db_handle, res);
155
+			perm_dbf.free_result(perm_db_handle, res);
156 156
 			empty_hash_table(new_hash_table);
157 157
 			return -1;
158 158
 		}
159 159
 	}
160 160
 
161
-	perm_dbf.free_result(db_handle, res);
161
+	perm_dbf.free_result(perm_db_handle, res);
162 162
 
163
-	old_hash_table = *hash_table;
164
-	*hash_table = new_hash_table;
163
+	old_hash_table = *perm_trust_table;
164
+	*perm_trust_table = new_hash_table;
165 165
 	empty_hash_table(old_hash_table);
166 166
 
167 167
 	LM_DBG("trusted table reloaded successfully.\n");
... ...
@@ -176,12 +176,12 @@ int reload_trusted_table(void)
176 176
 int init_trusted(void)
177 177
 {
178 178
 	/* Check if hash table needs to be loaded from trusted table */
179
-	if (!db_url.s) {
179
+	if (!perm_db_url.s) {
180 180
 		LM_INFO("db_url parameter of permissions module not set, "
181 181
 				"disabling allow_trusted\n");
182 182
 		return 0;
183 183
 	} else {
184
-		if (db_bind_mod(&db_url, &perm_dbf) < 0) {
184
+		if (db_bind_mod(&perm_db_url, &perm_dbf) < 0) {
185 185
 			LM_ERR("load a database support module\n");
186 186
 			return -1;
187 187
 		}
... ...
@@ -192,60 +192,61 @@ int init_trusted(void)
192 192
 		}
193 193
 	}
194 194
 
195
-	hash_table_1 = hash_table_2 = 0;
196
-	hash_table = 0;
195
+	perm_trust_table_1 = perm_trust_table_2 = 0;
196
+	perm_trust_table = 0;
197 197
 
198
-	if (db_mode == ENABLE_CACHE) {
199
-		db_handle = perm_dbf.init(&db_url);
200
-		if (!db_handle) {
198
+	if (perm_db_mode == ENABLE_CACHE) {
199
+		perm_db_handle = perm_dbf.init(&perm_db_url);
200
+		if (!perm_db_handle) {
201 201
 			LM_ERR("unable to connect database\n");
202 202
 			return -1;
203 203
 		}
204 204
 
205
-		if(db_check_table_version(&perm_dbf, db_handle, &trusted_table, TABLE_VERSION) < 0) {
206
-			DB_TABLE_VERSION_ERROR(trusted_table);
207
-			perm_dbf.close(db_handle);
208
-			db_handle = 0;
205
+		if(db_check_table_version(&perm_dbf, perm_db_handle, &perm_trusted_table,
206
+					TABLE_VERSION) < 0) {
207
+			DB_TABLE_VERSION_ERROR(perm_trusted_table);
208
+			perm_dbf.close(perm_db_handle);
209
+			perm_db_handle = 0;
209 210
 			return -1;
210 211
 		}
211 212
 
212
-		hash_table_1 = new_hash_table();
213
-		if (!hash_table_1) return -1;
213
+		perm_trust_table_1 = new_hash_table();
214
+		if (!perm_trust_table_1) return -1;
214 215
 
215
-		hash_table_2  = new_hash_table();
216
-		if (!hash_table_2) goto error;
216
+		perm_trust_table_2  = new_hash_table();
217
+		if (!perm_trust_table_2) goto error;
217 218
 
218
-		hash_table = (struct trusted_list ***)shm_malloc
219
+		perm_trust_table = (struct trusted_list ***)shm_malloc
219 220
 			(sizeof(struct trusted_list **));
220
-		if (!hash_table) goto error;
221
+		if (!perm_trust_table) goto error;
221 222
 
222
-		*hash_table = hash_table_1;
223
+		*perm_trust_table = perm_trust_table_1;
223 224
 
224 225
 		if (reload_trusted_table() == -1) {
225 226
 			LM_CRIT("reload of trusted table failed\n");
226 227
 			goto error;
227 228
 		}
228 229
 
229
-		perm_dbf.close(db_handle);
230
-		db_handle = 0;
230
+		perm_dbf.close(perm_db_handle);
231
+		perm_db_handle = 0;
231 232
 	}
232 233
 	return 0;
233 234
 
234 235
 error:
235
-	if (hash_table_1) {
236
-		free_hash_table(hash_table_1);
237
-		hash_table_1 = 0;
236
+	if (perm_trust_table_1) {
237
+		free_hash_table(perm_trust_table_1);
238
+		perm_trust_table_1 = 0;
238 239
 	}
239
-	if (hash_table_2) {
240
-		free_hash_table(hash_table_2);
241
-		hash_table_2 = 0;
240
+	if (perm_trust_table_2) {
241
+		free_hash_table(perm_trust_table_2);
242
+		perm_trust_table_2 = 0;
242 243
 	}
243
-	if (hash_table) {
244
-		shm_free(hash_table);
245
-		hash_table = 0;
244
+	if (perm_trust_table) {
245
+		shm_free(perm_trust_table);
246
+		perm_trust_table = 0;
246 247
 	}
247
-	perm_dbf.close(db_handle);
248
-	db_handle = 0;
248
+	perm_dbf.close(perm_db_handle);
249
+	perm_db_handle = 0;
249 250
 	return -1;
250 251
 }
251 252
 
... ...
@@ -255,26 +256,26 @@ error:
255 256
  */
256 257
 int init_child_trusted(int rank)
257 258
 {
258
-	if (db_mode == ENABLE_CACHE)
259
+	if (perm_db_mode == ENABLE_CACHE)
259 260
 		return 0;
260 261
 
261 262
 	if ((rank <= 0) && (rank != PROC_RPC) && (rank != PROC_UNIXSOCK))
262 263
 		return 0;
263 264
 
264
-	if (!db_url.s) {
265
+	if (!perm_db_url.s) {
265 266
 		return 0;
266 267
 	}
267 268
 
268
-	db_handle = perm_dbf.init(&db_url);
269
-	if (!db_handle) {
269
+	perm_db_handle = perm_dbf.init(&perm_db_url);
270
+	if (!perm_db_handle) {
270 271
 		LM_ERR("unable to connect database\n");
271 272
 		return -1;
272 273
 	}
273 274
 
274
-	if (db_check_table_version(&perm_dbf, db_handle, &trusted_table,
275
+	if (db_check_table_version(&perm_dbf, perm_db_handle, &perm_trusted_table,
275 276
 				TABLE_VERSION) < 0) {
276
-		DB_TABLE_VERSION_ERROR(trusted_table);
277
-		perm_dbf.close(db_handle);
277
+		DB_TABLE_VERSION_ERROR(perm_trusted_table);
278
+		perm_dbf.close(perm_db_handle);
278 279
 		return -1;
279 280
 	}
280 281
 
... ...
@@ -287,9 +288,9 @@ int init_child_trusted(int rank)
287 288
  */
288 289
 void clean_trusted(void)
289 290
 {
290
-	if (hash_table_1) free_hash_table(hash_table_1);
291
-	if (hash_table_2) free_hash_table(hash_table_2);
292
-	if (hash_table) shm_free(hash_table);
291
+	if (perm_trust_table_1) free_hash_table(perm_trust_table_1);
292
+	if (perm_trust_table_2) free_hash_table(perm_trust_table_2);
293
+	if (perm_trust_table) shm_free(perm_trust_table);
293 294
 }
294 295
 
295 296
 
... ...
@@ -435,7 +436,7 @@ static int match_res(struct sip_msg* msg, int proto, db1_res_t* _r, char* uri)
435 436
 					return -1;
436 437
 				}
437 438
 			}
438
-			if (!peer_tag_mode)
439
+			if (!perm_peer_tag_mode)
439 440
 				return 1;
440 441
 			count++;
441 442
 		}
... ...
@@ -459,21 +460,21 @@ int allow_trusted(struct sip_msg* msg, char *src_ip, int proto, char *from_uri)
459 460
 	db_val_t vals[1];
460 461
 	db_key_t cols[4];
461 462
 
462
-	if (db_mode == DISABLE_CACHE) {
463
-		db_key_t order = &priority_col;
463
+	if (perm_db_mode == DISABLE_CACHE) {
464
+		db_key_t order = &perm_priority_col;
464 465
 
465
-		if (db_handle == 0) {
466
+		if (perm_db_handle == 0) {
466 467
 			LM_ERR("no connection to database\n");
467 468
 			return -1;
468 469
 		}
469 470
 
470
-		keys[0] = &source_col;
471
-		cols[0] = &proto_col;
472
-		cols[1] = &from_col;
473
-		cols[2] = &ruri_col;
474
-		cols[3] = &tag_col;
471
+		keys[0] = &perm_source_col;