aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/leases.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/leases.c')
-rw-r--r--networking/udhcp/leases.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/networking/udhcp/leases.c b/networking/udhcp/leases.c
index 06bc086ba..4039f4dfb 100644
--- a/networking/udhcp/leases.c
+++ b/networking/udhcp/leases.c
@@ -11,9 +11,9 @@
11 11
12 12
13/* Find the oldest expired lease, NULL if there are no expired leases */ 13/* Find the oldest expired lease, NULL if there are no expired leases */
14static struct dhcpOfferedAddr *oldest_expired_lease(void) 14static struct dyn_lease *oldest_expired_lease(void)
15{ 15{
16 struct dhcpOfferedAddr *oldest_lease = NULL; 16 struct dyn_lease *oldest_lease = NULL;
17 leasetime_t oldest_time = time(NULL); 17 leasetime_t oldest_time = time(NULL);
18 unsigned i; 18 unsigned i;
19 19
@@ -38,7 +38,7 @@ static void clear_lease(const uint8_t *chaddr, uint32_t yiaddr)
38 continue; 38 continue;
39 39
40 for (i = 0; i < server_config.max_leases; i++) { 40 for (i = 0; i < server_config.max_leases; i++) {
41 if ((j != 16 && memcmp(leases[i].lease_mac16, chaddr, 16) == 0) 41 if ((j != 16 && memcmp(leases[i].lease_mac, chaddr, 6) == 0)
42 || (yiaddr && leases[i].lease_nip == yiaddr) 42 || (yiaddr && leases[i].lease_nip == yiaddr)
43 ) { 43 ) {
44 memset(&leases[i], 0, sizeof(leases[i])); 44 memset(&leases[i], 0, sizeof(leases[i]));
@@ -48,11 +48,11 @@ static void clear_lease(const uint8_t *chaddr, uint32_t yiaddr)
48 48
49 49
50/* Add a lease into the table, clearing out any old ones */ 50/* Add a lease into the table, clearing out any old ones */
51struct dhcpOfferedAddr* FAST_FUNC add_lease( 51struct dyn_lease* FAST_FUNC add_lease(
52 const uint8_t *chaddr, uint32_t yiaddr, 52 const uint8_t *chaddr, uint32_t yiaddr,
53 leasetime_t leasetime, uint8_t *hostname) 53 leasetime_t leasetime, uint8_t *hostname)
54{ 54{
55 struct dhcpOfferedAddr *oldest; 55 struct dyn_lease *oldest;
56 uint8_t hostname_length; 56 uint8_t hostname_length;
57 57
58 /* clean out any old ones */ 58 /* clean out any old ones */
@@ -75,7 +75,7 @@ struct dhcpOfferedAddr* FAST_FUNC add_lease(
75 hostname++; 75 hostname++;
76 } 76 }
77 } 77 }
78 memcpy(oldest->lease_mac16, chaddr, 16); 78 memcpy(oldest->lease_mac, chaddr, 6);
79 oldest->lease_nip = yiaddr; 79 oldest->lease_nip = yiaddr;
80 oldest->expires = time(NULL) + leasetime; 80 oldest->expires = time(NULL) + leasetime;
81 } 81 }
@@ -85,19 +85,19 @@ struct dhcpOfferedAddr* FAST_FUNC add_lease(
85 85
86 86
87/* True if a lease has expired */ 87/* True if a lease has expired */
88int FAST_FUNC lease_expired(struct dhcpOfferedAddr *lease) 88int FAST_FUNC lease_expired(struct dyn_lease *lease)
89{ 89{
90 return (lease->expires < (leasetime_t) time(NULL)); 90 return (lease->expires < (leasetime_t) time(NULL));
91} 91}
92 92
93 93
94/* Find the first lease that matches chaddr, NULL if no match */ 94/* Find the first lease that matches chaddr, NULL if no match */
95struct dhcpOfferedAddr* FAST_FUNC find_lease_by_chaddr(const uint8_t *chaddr) 95struct dyn_lease* FAST_FUNC find_lease_by_chaddr(const uint8_t *chaddr)
96{ 96{
97 unsigned i; 97 unsigned i;
98 98
99 for (i = 0; i < server_config.max_leases; i++) 99 for (i = 0; i < server_config.max_leases; i++)
100 if (!memcmp(leases[i].lease_mac16, chaddr, 16)) 100 if (memcmp(leases[i].lease_mac, chaddr, 6) == 0)
101 return &(leases[i]); 101 return &(leases[i]);
102 102
103 return NULL; 103 return NULL;
@@ -105,7 +105,7 @@ struct dhcpOfferedAddr* FAST_FUNC find_lease_by_chaddr(const uint8_t *chaddr)
105 105
106 106
107/* Find the first lease that matches yiaddr, NULL is no match */ 107/* Find the first lease that matches yiaddr, NULL is no match */
108struct dhcpOfferedAddr* FAST_FUNC find_lease_by_yiaddr(uint32_t yiaddr) 108struct dyn_lease* FAST_FUNC find_lease_by_yiaddr(uint32_t yiaddr)
109{ 109{
110 unsigned i; 110 unsigned i;
111 111
@@ -146,12 +146,12 @@ static int nobody_responds_to_arp(uint32_t addr, const uint8_t *safe_mac)
146uint32_t FAST_FUNC find_free_or_expired_address(const uint8_t *chaddr) 146uint32_t FAST_FUNC find_free_or_expired_address(const uint8_t *chaddr)
147{ 147{
148 uint32_t addr; 148 uint32_t addr;
149 struct dhcpOfferedAddr *oldest_lease = NULL; 149 struct dyn_lease *oldest_lease = NULL;
150 150
151 addr = server_config.start_ip; /* addr is in host order here */ 151 addr = server_config.start_ip; /* addr is in host order here */
152 for (; addr <= server_config.end_ip; addr++) { 152 for (; addr <= server_config.end_ip; addr++) {
153 uint32_t net_addr; 153 uint32_t net_addr;
154 struct dhcpOfferedAddr *lease; 154 struct dyn_lease *lease;
155 155
156 /* ie, 192.168.55.0 */ 156 /* ie, 192.168.55.0 */
157 if ((addr & 0xff) == 0) 157 if ((addr & 0xff) == 0)