diff options
author | Eric Andersen <andersen@codepoet.org> | 2004-03-15 08:29:22 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2004-03-15 08:29:22 +0000 |
commit | c7bda1ce659294d6e22c06e087f6f265983c7578 (patch) | |
tree | 4c6d2217f4d8306c59cf1096f8664e1cfd167213 /networking/udhcp/serverpacket.c | |
parent | 8854004b41065b3d081af7f3df13a100b0c8bfbe (diff) | |
download | busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.gz busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.bz2 busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.zip |
Remove trailing whitespace. Update copyright to include 2004.
Diffstat (limited to 'networking/udhcp/serverpacket.c')
-rw-r--r-- | networking/udhcp/serverpacket.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/networking/udhcp/serverpacket.c b/networking/udhcp/serverpacket.c index d39e6ba17..937436a11 100644 --- a/networking/udhcp/serverpacket.c +++ b/networking/udhcp/serverpacket.c | |||
@@ -45,7 +45,7 @@ static int send_packet_to_client(struct dhcpMessage *payload, int force_broadcas | |||
45 | { | 45 | { |
46 | uint8_t *chaddr; | 46 | uint8_t *chaddr; |
47 | uint32_t ciaddr; | 47 | uint32_t ciaddr; |
48 | 48 | ||
49 | if (force_broadcast) { | 49 | if (force_broadcast) { |
50 | DEBUG(LOG_INFO, "broadcasting packet to client (NAK)"); | 50 | DEBUG(LOG_INFO, "broadcasting packet to client (NAK)"); |
51 | ciaddr = INADDR_BROADCAST; | 51 | ciaddr = INADDR_BROADCAST; |
@@ -63,7 +63,7 @@ static int send_packet_to_client(struct dhcpMessage *payload, int force_broadcas | |||
63 | ciaddr = payload->yiaddr; | 63 | ciaddr = payload->yiaddr; |
64 | chaddr = payload->chaddr; | 64 | chaddr = payload->chaddr; |
65 | } | 65 | } |
66 | return raw_packet(payload, server_config.server, SERVER_PORT, | 66 | return raw_packet(payload, server_config.server, SERVER_PORT, |
67 | ciaddr, CLIENT_PORT, chaddr, server_config.ifindex); | 67 | ciaddr, CLIENT_PORT, chaddr, server_config.ifindex); |
68 | } | 68 | } |
69 | 69 | ||
@@ -101,7 +101,7 @@ static void add_bootp_options(struct dhcpMessage *packet) | |||
101 | if (server_config.boot_file) | 101 | if (server_config.boot_file) |
102 | strncpy(packet->file, server_config.boot_file, sizeof(packet->file) - 1); | 102 | strncpy(packet->file, server_config.boot_file, sizeof(packet->file) - 1); |
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
106 | /* send a DHCP OFFER to a DHCP DISCOVER */ | 106 | /* send a DHCP OFFER to a DHCP DISCOVER */ |
107 | int sendOffer(struct dhcpMessage *oldpacket) | 107 | int sendOffer(struct dhcpMessage *oldpacket) |
@@ -114,14 +114,14 @@ int sendOffer(struct dhcpMessage *oldpacket) | |||
114 | struct in_addr addr; | 114 | struct in_addr addr; |
115 | 115 | ||
116 | init_packet(&packet, oldpacket, DHCPOFFER); | 116 | init_packet(&packet, oldpacket, DHCPOFFER); |
117 | 117 | ||
118 | /* ADDME: if static, short circuit */ | 118 | /* ADDME: if static, short circuit */ |
119 | /* the client is in our lease/offered table */ | 119 | /* the client is in our lease/offered table */ |
120 | if ((lease = find_lease_by_chaddr(oldpacket->chaddr))) { | 120 | if ((lease = find_lease_by_chaddr(oldpacket->chaddr))) { |
121 | if (!lease_expired(lease)) | 121 | if (!lease_expired(lease)) |
122 | lease_time_align = lease->expires - time(0); | 122 | lease_time_align = lease->expires - time(0); |
123 | packet.yiaddr = lease->yiaddr; | 123 | packet.yiaddr = lease->yiaddr; |
124 | 124 | ||
125 | /* Or the client has a requested ip */ | 125 | /* Or the client has a requested ip */ |
126 | } else if ((req = get_option(oldpacket, DHCP_REQUESTED_IP)) && | 126 | } else if ((req = get_option(oldpacket, DHCP_REQUESTED_IP)) && |
127 | 127 | ||
@@ -131,10 +131,10 @@ int sendOffer(struct dhcpMessage *oldpacket) | |||
131 | /* and the ip is in the lease range */ | 131 | /* and the ip is in the lease range */ |
132 | ntohl(req_align) >= ntohl(server_config.start) && | 132 | ntohl(req_align) >= ntohl(server_config.start) && |
133 | ntohl(req_align) <= ntohl(server_config.end) && | 133 | ntohl(req_align) <= ntohl(server_config.end) && |
134 | 134 | ||
135 | /* and its not already taken/offered */ /* ADDME: check that its not a static lease */ | 135 | /* and its not already taken/offered */ /* ADDME: check that its not a static lease */ |
136 | ((!(lease = find_lease_by_yiaddr(req_align)) || | 136 | ((!(lease = find_lease_by_yiaddr(req_align)) || |
137 | 137 | ||
138 | /* or its taken, but expired */ /* ADDME: or maybe in here */ | 138 | /* or its taken, but expired */ /* ADDME: or maybe in here */ |
139 | lease_expired(lease)))) { | 139 | lease_expired(lease)))) { |
140 | packet.yiaddr = req_align; /* FIXME: oh my, is there a host using this IP? */ | 140 | packet.yiaddr = req_align; /* FIXME: oh my, is there a host using this IP? */ |
@@ -142,32 +142,32 @@ int sendOffer(struct dhcpMessage *oldpacket) | |||
142 | /* otherwise, find a free IP */ /*ADDME: is it a static lease? */ | 142 | /* otherwise, find a free IP */ /*ADDME: is it a static lease? */ |
143 | } else { | 143 | } else { |
144 | packet.yiaddr = find_address(0); | 144 | packet.yiaddr = find_address(0); |
145 | 145 | ||
146 | /* try for an expired lease */ | 146 | /* try for an expired lease */ |
147 | if (!packet.yiaddr) packet.yiaddr = find_address(1); | 147 | if (!packet.yiaddr) packet.yiaddr = find_address(1); |
148 | } | 148 | } |
149 | 149 | ||
150 | if(!packet.yiaddr) { | 150 | if(!packet.yiaddr) { |
151 | LOG(LOG_WARNING, "no IP addresses to give -- OFFER abandoned"); | 151 | LOG(LOG_WARNING, "no IP addresses to give -- OFFER abandoned"); |
152 | return -1; | 152 | return -1; |
153 | } | 153 | } |
154 | 154 | ||
155 | if (!add_lease(packet.chaddr, packet.yiaddr, server_config.offer_time)) { | 155 | if (!add_lease(packet.chaddr, packet.yiaddr, server_config.offer_time)) { |
156 | LOG(LOG_WARNING, "lease pool is full -- OFFER abandoned"); | 156 | LOG(LOG_WARNING, "lease pool is full -- OFFER abandoned"); |
157 | return -1; | 157 | return -1; |
158 | } | 158 | } |
159 | 159 | ||
160 | if ((lease_time = get_option(oldpacket, DHCP_LEASE_TIME))) { | 160 | if ((lease_time = get_option(oldpacket, DHCP_LEASE_TIME))) { |
161 | memcpy(&lease_time_align, lease_time, 4); | 161 | memcpy(&lease_time_align, lease_time, 4); |
162 | lease_time_align = ntohl(lease_time_align); | 162 | lease_time_align = ntohl(lease_time_align); |
163 | if (lease_time_align > server_config.lease) | 163 | if (lease_time_align > server_config.lease) |
164 | lease_time_align = server_config.lease; | 164 | lease_time_align = server_config.lease; |
165 | } | 165 | } |
166 | 166 | ||
167 | /* Make sure we aren't just using the lease time from the previous offer */ | 167 | /* Make sure we aren't just using the lease time from the previous offer */ |
168 | if (lease_time_align < server_config.min_lease) | 168 | if (lease_time_align < server_config.min_lease) |
169 | lease_time_align = server_config.lease; | 169 | lease_time_align = server_config.lease; |
170 | /* ADDME: end of short circuit */ | 170 | /* ADDME: end of short circuit */ |
171 | add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_align)); | 171 | add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_align)); |
172 | 172 | ||
173 | curr = server_config.options; | 173 | curr = server_config.options; |
@@ -178,7 +178,7 @@ int sendOffer(struct dhcpMessage *oldpacket) | |||
178 | } | 178 | } |
179 | 179 | ||
180 | add_bootp_options(&packet); | 180 | add_bootp_options(&packet); |
181 | 181 | ||
182 | addr.s_addr = packet.yiaddr; | 182 | addr.s_addr = packet.yiaddr; |
183 | LOG(LOG_INFO, "sending OFFER of %s", inet_ntoa(addr)); | 183 | LOG(LOG_INFO, "sending OFFER of %s", inet_ntoa(addr)); |
184 | return send_packet(&packet, 0); | 184 | return send_packet(&packet, 0); |
@@ -190,7 +190,7 @@ int sendNAK(struct dhcpMessage *oldpacket) | |||
190 | struct dhcpMessage packet; | 190 | struct dhcpMessage packet; |
191 | 191 | ||
192 | init_packet(&packet, oldpacket, DHCPNAK); | 192 | init_packet(&packet, oldpacket, DHCPNAK); |
193 | 193 | ||
194 | DEBUG(LOG_INFO, "sending NAK"); | 194 | DEBUG(LOG_INFO, "sending NAK"); |
195 | return send_packet(&packet, 1); | 195 | return send_packet(&packet, 1); |
196 | } | 196 | } |
@@ -206,18 +206,18 @@ int sendACK(struct dhcpMessage *oldpacket, uint32_t yiaddr) | |||
206 | 206 | ||
207 | init_packet(&packet, oldpacket, DHCPACK); | 207 | init_packet(&packet, oldpacket, DHCPACK); |
208 | packet.yiaddr = yiaddr; | 208 | packet.yiaddr = yiaddr; |
209 | 209 | ||
210 | if ((lease_time = get_option(oldpacket, DHCP_LEASE_TIME))) { | 210 | if ((lease_time = get_option(oldpacket, DHCP_LEASE_TIME))) { |
211 | memcpy(&lease_time_align, lease_time, 4); | 211 | memcpy(&lease_time_align, lease_time, 4); |
212 | lease_time_align = ntohl(lease_time_align); | 212 | lease_time_align = ntohl(lease_time_align); |
213 | if (lease_time_align > server_config.lease) | 213 | if (lease_time_align > server_config.lease) |
214 | lease_time_align = server_config.lease; | 214 | lease_time_align = server_config.lease; |
215 | else if (lease_time_align < server_config.min_lease) | 215 | else if (lease_time_align < server_config.min_lease) |
216 | lease_time_align = server_config.lease; | 216 | lease_time_align = server_config.lease; |
217 | } | 217 | } |
218 | 218 | ||
219 | add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_align)); | 219 | add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_align)); |
220 | 220 | ||
221 | curr = server_config.options; | 221 | curr = server_config.options; |
222 | while (curr) { | 222 | while (curr) { |
223 | if (curr->data[OPT_CODE] != DHCP_LEASE_TIME) | 223 | if (curr->data[OPT_CODE] != DHCP_LEASE_TIME) |
@@ -230,7 +230,7 @@ int sendACK(struct dhcpMessage *oldpacket, uint32_t yiaddr) | |||
230 | addr.s_addr = packet.yiaddr; | 230 | addr.s_addr = packet.yiaddr; |
231 | LOG(LOG_INFO, "sending ACK to %s", inet_ntoa(addr)); | 231 | LOG(LOG_INFO, "sending ACK to %s", inet_ntoa(addr)); |
232 | 232 | ||
233 | if (send_packet(&packet, 0) < 0) | 233 | if (send_packet(&packet, 0) < 0) |
234 | return -1; | 234 | return -1; |
235 | 235 | ||
236 | add_lease(packet.chaddr, packet.yiaddr, lease_time_align); | 236 | add_lease(packet.chaddr, packet.yiaddr, lease_time_align); |
@@ -245,7 +245,7 @@ int send_inform(struct dhcpMessage *oldpacket) | |||
245 | struct option_set *curr; | 245 | struct option_set *curr; |
246 | 246 | ||
247 | init_packet(&packet, oldpacket, DHCPACK); | 247 | init_packet(&packet, oldpacket, DHCPACK); |
248 | 248 | ||
249 | curr = server_config.options; | 249 | curr = server_config.options; |
250 | while (curr) { | 250 | while (curr) { |
251 | if (curr->data[OPT_CODE] != DHCP_LEASE_TIME) | 251 | if (curr->data[OPT_CODE] != DHCP_LEASE_TIME) |