aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpd.h
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-01-01 17:52:09 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-01-01 17:52:09 +0000
commit0416e3dde17ea9295635c52183b30fe3d7172333 (patch)
tree4eea1c401c74d6ec42f18c67090f73001103e0db /networking/udhcp/dhcpd.h
parentb2ec03813c34bc3de2ddf9a0974be4e5b31ec757 (diff)
downloadbusybox-w32-0416e3dde17ea9295635c52183b30fe3d7172333.tar.gz
busybox-w32-0416e3dde17ea9295635c52183b30fe3d7172333.tar.bz2
busybox-w32-0416e3dde17ea9295635c52183b30fe3d7172333.zip
udhcpd: disable opton to have absolute lease times in lease file
(that does not work with dumpleases) dumpleases: fix -a option. networking/udhcp/*: code shrink, more compact static leases struture, better comments, etc function old new delta find_free_or_expired_address - 147 +147 nobody_responds_to_arp - 84 +84 read_opt 781 830 +49 dumpleases_main 435 447 +12 send_ACK 229 232 +3 read_staticlease 90 93 +3 addStaticLease 60 61 +1 getIpByMac 46 43 -3 reservedIp 31 20 -11 keywords 304 288 -16 send_offer 428 403 -25 write_leases 225 193 -32 read_leases 184 143 -41 read_yn 64 - -64 find_address 191 - -191 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 5/6 up/down: 299/-383) Total: -84 bytes
Diffstat (limited to 'networking/udhcp/dhcpd.h')
-rw-r--r--networking/udhcp/dhcpd.h36
1 files changed, 24 insertions, 12 deletions
diff --git a/networking/udhcp/dhcpd.h b/networking/udhcp/dhcpd.h
index 2d9752845..02e392aaf 100644
--- a/networking/udhcp/dhcpd.h
+++ b/networking/udhcp/dhcpd.h
@@ -26,8 +26,8 @@ struct option_set {
26 26
27struct static_lease { 27struct static_lease {
28 struct static_lease *next; 28 struct static_lease *next;
29 uint8_t *mac; 29 uint32_t ip;
30 uint32_t *ip; 30 uint8_t mac[6];
31}; 31};
32 32
33struct server_config_t { 33struct server_config_t {
@@ -42,8 +42,11 @@ struct server_config_t {
42 char *interface; /* The name of the interface to use */ 42 char *interface; /* The name of the interface to use */
43 int ifindex; /* Index number of the interface to use */ 43 int ifindex; /* Index number of the interface to use */
44 uint8_t arp[6]; /* Our arp address */ 44 uint8_t arp[6]; /* Our arp address */
45 char remaining; /* should the lease file be interpreted as lease time remaining, or 45// disabled: dumpleases has no way of knowing this value,
46 * as the time the lease expires */ 46// and will break if it's off. Now it's on always.
47// char remaining; /* Should the lease time in lease file
48// * be written as lease time remaining, or
49// * as the absolute time the lease expires */
47 uint32_t lease; /* lease time in seconds (host order) */ 50 uint32_t lease; /* lease time in seconds (host order) */
48 uint32_t max_leases; /* maximum number of leases (including reserved address) */ 51 uint32_t max_leases; /* maximum number of leases (including reserved address) */
49 uint32_t auto_time; /* how long should udhcpd wait before writing a config file. 52 uint32_t auto_time; /* how long should udhcpd wait before writing a config file.
@@ -52,11 +55,11 @@ struct server_config_t {
52 * decline message */ 55 * decline message */
53 uint32_t conflict_time; /* how long an arp conflict offender is leased for */ 56 uint32_t conflict_time; /* how long an arp conflict offender is leased for */
54 uint32_t offer_time; /* how long an offered address is reserved */ 57 uint32_t offer_time; /* how long an offered address is reserved */
55 uint32_t min_lease; /* minimum lease a client can request */ 58 uint32_t min_lease; /* minimum lease time a client can request */
59 uint32_t siaddr; /* next server bootp option */
56 char *lease_file; 60 char *lease_file;
57 char *pidfile; 61 char *pidfile;
58 char *notify_file; /* What to run whenever leases are written */ 62 char *notify_file; /* What to run whenever leases are written */
59 uint32_t siaddr; /* next server bootp option */
60 char *sname; /* bootp server name */ 63 char *sname; /* bootp server name */
61 char *boot_file; /* bootp boot file option */ 64 char *boot_file; /* bootp boot file option */
62 struct static_lease *static_leases; /* List of ip/mac pairs to assign static leases */ 65 struct static_lease *static_leases; /* List of ip/mac pairs to assign static leases */
@@ -76,28 +79,37 @@ extern struct dhcpOfferedAddr *leases;
76 79
77/*** leases.h ***/ 80/*** leases.h ***/
78 81
82typedef uint32_t leasetime_t;
83typedef int32_t signed_leasetime_t;
84
79struct dhcpOfferedAddr { 85struct dhcpOfferedAddr {
80 uint8_t chaddr[16]; 86 uint8_t chaddr[16];
81 uint32_t yiaddr; /* network order */ 87 /* In network order */
82 uint32_t expires; /* host order */ 88 uint32_t yiaddr;
89 /* Unix time when lease expires, regardless of value of
90 * server_config.remaining. Kept in memory in host order.
91 * When written to file, converted to network order
92 * and optionally adjusted (current time subtracted)
93 * if server_config.remaining = 1 */
94 leasetime_t expires;
83}; 95};
84 96
85struct dhcpOfferedAddr *add_lease(const uint8_t *chaddr, uint32_t yiaddr, unsigned long lease) FAST_FUNC; 97struct dhcpOfferedAddr *add_lease(const uint8_t *chaddr, uint32_t yiaddr, leasetime_t leasetime) FAST_FUNC;
86int lease_expired(struct dhcpOfferedAddr *lease) FAST_FUNC; 98int lease_expired(struct dhcpOfferedAddr *lease) FAST_FUNC;
87struct dhcpOfferedAddr *find_lease_by_chaddr(const uint8_t *chaddr) FAST_FUNC; 99struct dhcpOfferedAddr *find_lease_by_chaddr(const uint8_t *chaddr) FAST_FUNC;
88struct dhcpOfferedAddr *find_lease_by_yiaddr(uint32_t yiaddr) FAST_FUNC; 100struct dhcpOfferedAddr *find_lease_by_yiaddr(uint32_t yiaddr) FAST_FUNC;
89uint32_t find_address(int check_expired) FAST_FUNC; 101uint32_t find_free_or_expired_address(void) FAST_FUNC;
90 102
91 103
92/*** static_leases.h ***/ 104/*** static_leases.h ***/
93 105
94/* Config file will pass static lease info to this function which will add it 106/* Config file will pass static lease info to this function which will add it
95 * to a data structure that can be searched later */ 107 * to a data structure that can be searched later */
96int addStaticLease(struct static_lease **lease_struct, uint8_t *mac, uint32_t *ip) FAST_FUNC; 108void addStaticLease(struct static_lease **lease_struct, uint8_t *mac, uint32_t ip) FAST_FUNC;
97/* Check to see if a mac has an associated static lease */ 109/* Check to see if a mac has an associated static lease */
98uint32_t getIpByMac(struct static_lease *lease_struct, void *arg) FAST_FUNC; 110uint32_t getIpByMac(struct static_lease *lease_struct, void *arg) FAST_FUNC;
99/* Check to see if an ip is reserved as a static ip */ 111/* Check to see if an ip is reserved as a static ip */
100uint32_t reservedIp(struct static_lease *lease_struct, uint32_t ip) FAST_FUNC; 112int reservedIp(struct static_lease *lease_struct, uint32_t ip) FAST_FUNC;
101/* Print out static leases just to check what's going on (debug code) */ 113/* Print out static leases just to check what's going on (debug code) */
102void printStaticLeases(struct static_lease **lease_struct) FAST_FUNC; 114void printStaticLeases(struct static_lease **lease_struct) FAST_FUNC;
103 115