diff options
author | Eric Andersen | 2004-10-08 08:49:26 +0000 |
---|---|---|
committer | Eric Andersen | 2004-10-08 08:49:26 +0000 |
commit | abf58d6ba5df9bbe04c4c7008cbbc8c7dc626392 (patch) | |
tree | c64a5328d250449c9a4e3964d59a657543e06440 /networking/udhcp/dhcpd.c | |
parent | 751750e3ee0195eef802a1554e97712285bf8fd7 (diff) | |
download | busybox-abf58d6ba5df9bbe04c4c7008cbbc8c7dc626392.zip busybox-abf58d6ba5df9bbe04c4c7008cbbc8c7dc626392.tar.gz |
Wade Berrier writes:
Hello,
Here's a patch for a first attempt at static leases for udhcpd.
Included in the tarball are 2 files (static_leases.c, static_leases.h)
and a patch against the latest cvs.
In the config file you can configure static leases with the following
format:
static_lease 00:60:08:11:CE:4E 192.168.0.54
static_lease 00:60:08:11:CE:3E 192.168.0.44
Comments/suggestions/improvements are welcome.
Wade
Diffstat (limited to 'networking/udhcp/dhcpd.c')
-rw-r--r-- | networking/udhcp/dhcpd.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index 6f38f07..ab3ddfe 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c @@ -44,6 +44,7 @@ #include "serverpacket.h" #include "common.h" #include "signalpipe.h" +#include "static_leases.h" /* globals */ @@ -68,9 +69,12 @@ int main(int argc, char *argv[]) unsigned long timeout_end; struct option_set *option; struct dhcpOfferedAddr *lease; + struct dhcpOfferedAddr static_lease; int max_sock; unsigned long num_ips; + uint32_t static_lease_ip; + memset(&server_config, 0, sizeof(struct server_config_t)); read_config(argc < 2 ? DHCPD_CONF_FILE : argv[1]); @@ -162,8 +166,25 @@ int main(int argc, char *argv[]) continue; } - /* ADDME: look for a static lease */ + /* Look for a static lease */ + static_lease_ip = getIpByMac(server_config.static_leases, &packet.chaddr); + + if(static_lease_ip) + { + printf("Found static lease: %x\n", static_lease_ip); + + memcpy(&static_lease.chaddr, &packet.chaddr, 16); + static_lease.yiaddr = static_lease_ip; + static_lease.expires = 0; + + lease = &static_lease; + + } + else + { lease = find_lease_by_chaddr(packet.chaddr); + } + switch (state[0]) { case DHCPDISCOVER: DEBUG(LOG_INFO,"received DISCOVER"); @@ -181,7 +202,7 @@ int main(int argc, char *argv[]) if (requested) memcpy(&requested_align, requested, 4); if (server_id) memcpy(&server_id_align, server_id, 4); - if (lease) { /*ADDME: or static lease */ + if (lease) { if (server_id) { /* SELECTING State */ DEBUG(LOG_INFO, "server_id = %08x", ntohl(server_id_align)); |