Exemple #1
0
/*
 * Check if an entry exists in subnet table that matches given ip_addr,
 * and port.  Port 0 in subnet table matches any port.  Return group of
 * first match or -1 if no match is found.
 */
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;

	i = 0;
	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 && table[i].tag.s) {
				val.s = table[i].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++;
	}

	return -1;
}
Exemple #2
0
/* 
 * Check if an entry exists in subnet table that matches given ip_addr,
 * and port.  Port 0 in subnet table matches any port.  Return group of
 * first match or -1 if no match is found.
 */
int find_group_in_subnet_table(struct subnet* table,
		ip_addr_t *addr, unsigned int port)
{
	unsigned int count, i;

	count = table[PERM_MAX_SUBNETS].grp;

	i = 0;
	while (i < count) {
		if ( ((table[i].port == port) || (table[i].port == 0))
			&& (ip_addr_match_net(addr, &table[i].subnet, table[i].mask)==0))
			return table[i].grp;
		i++;
	}

	return -1;
}