Module: sip-router Branch: master Commit: 0c67042fa629ee4744cfc31a15e571b7340b0881 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0c67042f...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Mon Jan 6 19:48:54 2014 +0100
permissions: set peer tag avp for allow_address_group()
- also for allow_source_address_group() - reported by Kelvin Chua
---
modules/permissions/hash.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/modules/permissions/hash.c b/modules/permissions/hash.c index 3a16581..b8daeb1 100644 --- a/modules/permissions/hash.c +++ b/modules/permissions/hash.c @@ -486,6 +486,7 @@ int find_group_in_addr_hash_table(struct addr_list** table, { struct addr_list *np; str addr_str; + avp_value_t val;
addr_str.s = (char*)addr->u.addr; addr_str.len = 4; @@ -493,6 +494,15 @@ int find_group_in_addr_hash_table(struct addr_list** table, for (np = table[perm_hash(addr_str)]; np != NULL; np = np->next) { if (((np->port == 0) || (np->port == port)) && ip_addr_cmp(&np->addr, addr)) { + + if (tag_avp.n && np->tag.s) { + val.s = np->tag; + if (add_avp(tag_avp_type|AVP_VAL_STR, tag_avp, val) != 0) { + LM_ERR("setting of tag_avp failed\n"); + return -1; + } + } + return np->grp; } } @@ -710,6 +720,7 @@ int find_group_in_subnet_table(struct subnet* table, ip_addr_t *addr, unsigned int port) { unsigned int count, i; + avp_value_t val;
count = table[PERM_MAX_SUBNETS].grp;
@@ -717,7 +728,16 @@ int find_group_in_subnet_table(struct subnet* table, while (i < count) { if ( ((table[i].port == port) || (table[i].port == 0)) && (ip_addr_match_net(addr, &table[i].subnet, table[i].mask)==0)) + { + if (tag_avp.n && np->tag.s) { + val.s = np->tag; + if (add_avp(tag_avp_type|AVP_VAL_STR, tag_avp, val) != 0) { + LM_ERR("setting of tag_avp failed\n"); + return -1; + } + } return table[i].grp; + } i++; }