Browse code

permissions: set peer tag avp for allow_address_group()

- also for allow_source_address_group()
- reported by Kelvin Chua

(cherry picked from commit 0c67042fa629ee4744cfc31a15e571b7340b0881)

Daniel-Constantin Mierla authored on 06/01/2014 18:48:54
Showing 1 changed files
... ...
@@ -486,6 +486,7 @@ int find_group_in_addr_hash_table(struct addr_list** table,
486 486
 {
487 487
 	struct addr_list *np;
488 488
 	str addr_str;
489
+	avp_value_t val;
489 490
 
490 491
 	addr_str.s = (char*)addr->u.addr;
491 492
 	addr_str.len = 4;
... ...
@@ -493,6 +494,15 @@ int find_group_in_addr_hash_table(struct addr_list** table,
493 493
 	for (np = table[perm_hash(addr_str)]; np != NULL; np = np->next) {
494 494
 		if (((np->port == 0) || (np->port == port))
495 495
 				&& ip_addr_cmp(&np->addr, addr)) {
496
+
497
+			if (tag_avp.n && np->tag.s) {
498
+				val.s = np->tag;
499
+				if (add_avp(tag_avp_type|AVP_VAL_STR, tag_avp, val) != 0) {
500
+					LM_ERR("setting of tag_avp failed\n");
501
+					return -1;
502
+				}
503
+			}
504
+
496 505
 			return np->grp;
497 506
 		}
498 507
 	}
... ...
@@ -710,6 +720,7 @@ int find_group_in_subnet_table(struct subnet* table,
710 710
 		ip_addr_t *addr, unsigned int port)
711 711
 {
712 712
 	unsigned int count, i;
713
+	avp_value_t val;
713 714
 
714 715
 	count = table[PERM_MAX_SUBNETS].grp;
715 716
 
... ...
@@ -717,7 +728,16 @@ int find_group_in_subnet_table(struct subnet* table,
717 717
 	while (i < count) {
718 718
 		if ( ((table[i].port == port) || (table[i].port == 0))
719 719
 			&& (ip_addr_match_net(addr, &table[i].subnet, table[i].mask)==0))
720
+		{
721
+			if (tag_avp.n && np->tag.s) {
722
+				val.s = np->tag;
723
+				if (add_avp(tag_avp_type|AVP_VAL_STR, tag_avp, val) != 0) {
724
+					LM_ERR("setting of tag_avp failed\n");
725
+					return -1;
726
+				}
727
+			}
720 728
 			return table[i].grp;
729
+		}
721 730
 		i++;
722 731
 	}
723 732