James Flemer cleaned up the make_netmask() function to remove the static
table. Very nice.
This commit is contained in:
parent
b3a5b17b7d
commit
3c631c6e5c
@ -1,5 +1,9 @@
|
|||||||
2002-04-09 Robert James Kaes <rjkaes@flarenet.com>
|
2002-04-09 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* src/acl.c (make_netmask): James Flemer cleaned up the
|
||||||
|
make_netmask() function to remove the big static table. Much
|
||||||
|
nicer now.
|
||||||
|
|
||||||
* configure.ac: The configure script now doesn't include a check
|
* configure.ac: The configure script now doesn't include a check
|
||||||
for the malloc.h header if tinyproxy is being compiled on an
|
for the malloc.h header if tinyproxy is being compiled on an
|
||||||
OpenBSD machine. I might actually just remove the malloc.h header
|
OpenBSD machine. I might actually just remove the malloc.h header
|
||||||
|
18
src/acl.c
18
src/acl.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: acl.c,v 1.11 2001-11-22 00:31:10 rjkaes Exp $
|
/* $Id: acl.c,v 1.12 2002-04-09 19:11:09 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* This system handles Access Control for use of this daemon. A list of
|
* This system handles Access Control for use of this daemon. A list of
|
||||||
* domains, or IP addresses (including IP blocks) are stored in a list
|
* domains, or IP addresses (including IP blocks) are stored in a list
|
||||||
@ -36,26 +36,14 @@ static struct acl_s *access_list = NULL;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Take a netmask number (between 0 and 32) and returns a network ordered
|
* Take a netmask number (between 0 and 32) and returns a network ordered
|
||||||
* value for comparison. Somebody please clean this up. :)
|
* value for comparison.
|
||||||
*/
|
*/
|
||||||
static in_addr_t
|
static in_addr_t
|
||||||
make_netmask(int netmask_num)
|
make_netmask(int netmask_num)
|
||||||
{
|
{
|
||||||
static in_addr_t netmasks[] = {
|
|
||||||
0x00000000, 0x80000000, 0xc0000000, 0xe0000000,
|
|
||||||
0xf8000000, 0xfc000000, 0xfe000000, 0xff000000,
|
|
||||||
0xff800000, 0xffc00000, 0xffe00000, 0xfff00000,
|
|
||||||
0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000,
|
|
||||||
0xffff0000, 0xffff8000, 0xffffc000, 0xffffe000,
|
|
||||||
0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00,
|
|
||||||
0xffffff00, 0xffffff80, 0xffffffc0, 0xffffffe0,
|
|
||||||
0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe,
|
|
||||||
0xffffffff
|
|
||||||
};
|
|
||||||
|
|
||||||
assert(netmask_num >= 0 && netmask_num <= 32);
|
assert(netmask_num >= 0 && netmask_num <= 32);
|
||||||
|
|
||||||
return htonl(netmasks[netmask_num]);
|
return htonl(~((1 << (32 - netmask_num)) - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user