Ejemplo n.º 1
0
Archivo: aaa.c Proyecto: aunoor/xl2tpd
unsigned int get_addr (struct iprange *ipr)
{
    unsigned int x, y;
    int status;
    struct iprange *ipr2;
    while (ipr)
    {
        if (ipr->sense == SENSE_ALLOW)
            for (x = ntohl (ipr->start); x <= ntohl (ipr->end); x++)
            {
                /* Found an IP in an ALLOW range, check to be sure it is
                   consistent through the remaining regions */
                if (!ip_used (x))
                {
                    status = SENSE_ALLOW;
                    ipr2 = ipr->next;
                    while (ipr2)
                    {
                        if ((x >= ntohl (ipr2->start))
                            && (x <= ntohl (ipr2->end)))
                            status = ipr2->sense;
                        ipr2 = ipr2->next;
                    }
                    y = htonl (x);
                    if (status == SENSE_ALLOW)
                        return y;
                }
            };
        ipr = ipr->next;
    }
    return 0;
}
Ejemplo n.º 2
0
Archivo: aaa.c Proyecto: aunoor/xl2tpd
void reserve_addr (unsigned int addr)
{
    /* Mark this address as in use */
    struct addr_ent *tmp, *tmp2;
    addr = ntohl (addr);
    if (ip_used (addr))
        return;
    tmp = uaddr[addr % ADDR_HASH_SIZE];
    tmp2 = (struct addr_ent *) malloc (sizeof (struct addr_ent));
    uaddr[addr % ADDR_HASH_SIZE] = tmp2;
    tmp2->next = tmp;
    tmp2->addr = addr;
}
Ejemplo n.º 3
0
Archivo: aaa.c Proyecto: Ansud/xxl2tpd
unsigned int get_addr (struct iprange *ipr)
{
	unsigned int x, y;
	int status;
	struct iprange *ipr2;

	for(; ipr; ipr = ipr->next)
	{
		if (unlikely(ipr->sense != SENSE_ALLOW))
			continue;

		for (x = ntohl (ipr->start); x <= ntohl (ipr->end); x++)
		{
			/*
			 * Found an IP in an ALLOW range, check to be sure it is
			 * consistant through the remaining regions
			 */
			if (ip_used(x))
				continue;

			status = SENSE_ALLOW;

			for(ipr2 = ipr->next; ipr2; ipr2 = ipr2->next)
			{
				if ((x >= ntohl(ipr2->start)) &&
				    (x <= ntohl (ipr2->end)))
					status = ipr2->sense;
			}

			if (status == SENSE_ALLOW) {
				y = htonl(x);
				return y;
			}
		}
	}

	return 0;
}