diff options
Diffstat (limited to 'networking/udhcp/leases.c')
-rw-r--r-- | networking/udhcp/leases.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/networking/udhcp/leases.c b/networking/udhcp/leases.c index 7ade91d93..0b6b409cd 100644 --- a/networking/udhcp/leases.c +++ b/networking/udhcp/leases.c | |||
@@ -9,12 +9,12 @@ | |||
9 | #include <netinet/in.h> | 9 | #include <netinet/in.h> |
10 | #include <arpa/inet.h> | 10 | #include <arpa/inet.h> |
11 | 11 | ||
12 | #include "debug.h" | ||
13 | #include "dhcpd.h" | 12 | #include "dhcpd.h" |
14 | #include "files.h" | 13 | #include "files.h" |
15 | #include "options.h" | 14 | #include "options.h" |
16 | #include "leases.h" | ||
17 | #include "arpping.h" | 15 | #include "arpping.h" |
16 | #include "common.h" | ||
17 | |||
18 | 18 | ||
19 | unsigned char blank_chaddr[] = {[0 ... 15] = 0}; | 19 | unsigned char blank_chaddr[] = {[0 ... 15] = 0}; |
20 | 20 | ||
@@ -102,6 +102,20 @@ struct dhcpOfferedAddr *find_lease_by_yiaddr(u_int32_t yiaddr) | |||
102 | } | 102 | } |
103 | 103 | ||
104 | 104 | ||
105 | /* check is an IP is taken, if it is, add it to the lease table */ | ||
106 | static int check_ip(u_int32_t addr) | ||
107 | { | ||
108 | struct in_addr temp; | ||
109 | |||
110 | if (arpping(addr, server_config.server, server_config.arp, server_config.interface) == 0) { | ||
111 | temp.s_addr = addr; | ||
112 | LOG(LOG_INFO, "%s belongs to someone, reserving it for %ld seconds", | ||
113 | inet_ntoa(temp), server_config.conflict_time); | ||
114 | add_lease(blank_chaddr, addr, server_config.conflict_time); | ||
115 | return 1; | ||
116 | } else return 0; | ||
117 | } | ||
118 | |||
105 | /* find an assignable address, it check_expired is true, we check all the expired leases as well. | 119 | /* find an assignable address, it check_expired is true, we check all the expired leases as well. |
106 | * Maybe this should try expired leases by age... */ | 120 | * Maybe this should try expired leases by age... */ |
107 | u_int32_t find_address(int check_expired) | 121 | u_int32_t find_address(int check_expired) |
@@ -133,19 +147,3 @@ u_int32_t find_address(int check_expired) | |||
133 | } | 147 | } |
134 | return 0; | 148 | return 0; |
135 | } | 149 | } |
136 | |||
137 | |||
138 | /* check is an IP is taken, if it is, add it to the lease table */ | ||
139 | int check_ip(u_int32_t addr) | ||
140 | { | ||
141 | struct in_addr temp; | ||
142 | |||
143 | if (arpping(addr, server_config.server, server_config.arp, server_config.interface) == 0) { | ||
144 | temp.s_addr = addr; | ||
145 | LOG(LOG_INFO, "%s belongs to someone, reserving it for %ld seconds", | ||
146 | inet_ntoa(temp), server_config.conflict_time); | ||
147 | add_lease(blank_chaddr, addr, server_config.conflict_time); | ||
148 | return 1; | ||
149 | } else return 0; | ||
150 | } | ||
151 | |||