mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-17 16:26:59 +00:00
IPv6: add DHCPv6 support
The DHCP version is determined according to the first IP address that appears in the configuration file. Caveat; counters are of native long type. Since IPv6 address space has 2^128 addresses, they are subject to overflow. [Sami Kerola: This commit also fixed a percent sorting bug, which has been broken always. See changes ret_percent() for the fix.] CC: LI Zimu <lzm@cernet.edu.cn> CC: Xing Li <xing@cernet.edu.cn> Reviewed-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Cheer Xiao <xiaqqaix@gmail.com>
This commit is contained in:
parent
71bcee14e9
commit
a57d399643
8 changed files with 267 additions and 119 deletions
21
src/hash.c
21
src/hash.c
|
|
@ -36,20 +36,31 @@
|
|||
#include "dhcpd-pools.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
void add_lease(int ip, enum ltype type)
|
||||
#define HASH_FIND_V6(head, findv6, out) HASH_FIND(hh, head, findv6, 16, out)
|
||||
#define HASH_ADD_V6(head, v6field, add) HASH_ADD(hh, head, v6field, 16, add)
|
||||
|
||||
void add_lease(union ipaddr_t *addr, enum ltype type)
|
||||
{
|
||||
struct leases_t *l;
|
||||
l = xmalloc(sizeof(struct leases_t));
|
||||
l->ip = ip;
|
||||
copy_ipaddr(&l->ip, addr);
|
||||
l->type = type;
|
||||
HASH_ADD_INT(leases, ip, l);
|
||||
if (dhcp_version == VERSION_6) {
|
||||
HASH_ADD_V6(leases, ip.v6, l);
|
||||
} else {
|
||||
HASH_ADD_INT(leases, ip.v4, l);
|
||||
}
|
||||
}
|
||||
|
||||
struct leases_t *find_lease(int ip)
|
||||
struct leases_t *find_lease(union ipaddr_t *addr)
|
||||
{
|
||||
struct leases_t *l;
|
||||
|
||||
HASH_FIND_INT(leases, &ip, l);
|
||||
if (dhcp_version == VERSION_6) {
|
||||
HASH_FIND_V6(leases, &addr->v6, l);
|
||||
} else {
|
||||
HASH_FIND_INT(leases, &addr->v4, l);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue