summaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/dhcpc.c')
-rw-r--r--networking/udhcp/dhcpc.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 2ba42d2..dda6789 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+
#include <sys/time.h>
#include <sys/file.h>
#include <unistd.h>
@@ -152,7 +152,7 @@ static void perform_release(void)
temp_addr.s_addr = server_addr;
sprintf(buffer, "%s", inet_ntoa(temp_addr));
temp_addr.s_addr = requested_ip;
- LOG(LOG_INFO, "Unicasting a release of %s to %s",
+ LOG(LOG_INFO, "Unicasting a release of %s to %s",
inet_ntoa(temp_addr), buffer);
send_release(server_addr, requested_ip); /* unicast */
run_script(NULL, "deconfig");
@@ -213,7 +213,7 @@ int main(int argc, char *argv[])
int option_index = 0;
c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:v", arg_options, &option_index);
if (c == -1) break;
-
+
switch (c) {
case 'c':
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
@@ -269,10 +269,10 @@ int main(int argc, char *argv[])
/* Start the log, sanitize fd's, and write a pid file */
start_log_and_pid("udhcpc", client_config.pidfile);
- if (read_interface(client_config.interface, &client_config.ifindex,
+ if (read_interface(client_config.interface, &client_config.ifindex,
NULL, client_config.arp) < 0)
return 1;
-
+
if (!client_config.clientid) {
client_config.clientid = xmalloc(6 + 3);
client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
@@ -282,8 +282,8 @@ int main(int argc, char *argv[])
}
/* setup the signal pipe */
- udhcp_sp_setup();
-
+ udhcp_sp_setup();
+
state = INIT_SELECTING;
run_script(NULL, "deconfig");
change_mode(LISTEN_RAW);
@@ -321,7 +321,7 @@ int main(int argc, char *argv[])
/* send discover packet */
send_discover(xid, requested_ip); /* broadcast */
-
+
timeout = now + ((packet_num == 2) ? 4 : 2);
packet_num++;
} else {
@@ -345,7 +345,7 @@ int main(int argc, char *argv[])
if (state == RENEW_REQUESTED)
send_renew(xid, server_addr, requested_ip); /* unicast */
else send_selecting(xid, server_addr, requested_ip); /* broadcast */
-
+
timeout = now + ((packet_num == 2) ? 10 : 2);
packet_num++;
} else {
@@ -373,7 +373,7 @@ int main(int argc, char *argv[])
} else {
/* send a request packet */
send_renew(xid, server_addr, requested_ip); /* unicast */
-
+
t1 = (t2 - t1) / 2 + t1;
timeout = t1 + start;
}
@@ -403,28 +403,28 @@ int main(int argc, char *argv[])
}
} else if (retval > 0 && listen_mode != LISTEN_NONE && FD_ISSET(fd, &rfds)) {
/* a packet is ready, read it */
-
+
if (listen_mode == LISTEN_KERNEL)
len = get_packet(&packet, fd);
else len = get_raw_packet(&packet, fd);
-
+
if (len == -1 && errno != EINTR) {
DEBUG(LOG_INFO, "error on read, %m, reopening socket");
change_mode(listen_mode); /* just close and reopen */
}
if (len < 0) continue;
-
+
if (packet.xid != xid) {
DEBUG(LOG_INFO, "Ignoring XID %lx (our xid is %lx)",
(unsigned long) packet.xid, xid);
continue;
}
-
+
if ((message = get_option(&packet, DHCP_MESSAGE_TYPE)) == NULL) {
DEBUG(LOG_ERR, "couldnt get option from packet -- ignoring");
continue;
}
-
+
switch (state) {
case INIT_SELECTING:
/* Must be a DHCPOFFER to one of our xid's */
@@ -433,7 +433,7 @@ int main(int argc, char *argv[])
memcpy(&server_addr, temp, 4);
xid = packet.xid;
requested_ip = packet.yiaddr;
-
+
/* enter requesting state */
state = REQUESTING;
timeout = now;
@@ -455,14 +455,14 @@ int main(int argc, char *argv[])
memcpy(&lease, temp, 4);
lease = ntohl(lease);
}
-
+
/* enter bound state */
t1 = lease / 2;
-
+
/* little fixed point for n * .875 */
t2 = (lease * 0x7) >> 3;
temp_addr.s_addr = packet.yiaddr;
- LOG(LOG_INFO, "Lease of %s obtained, lease time %ld",
+ LOG(LOG_INFO, "Lease of %s obtained, lease time %ld",
inet_ntoa(temp_addr), lease);
start = now;
timeout = t1 + start;
@@ -472,7 +472,7 @@ int main(int argc, char *argv[])
state = BOUND;
change_mode(LISTEN_NONE);
- if (client_config.quit_after_lease)
+ if (client_config.quit_after_lease)
return 0;
if (!client_config.foreground)
client_background();
@@ -492,10 +492,10 @@ int main(int argc, char *argv[])
}
break;
/* case BOUND, RELEASED: - ignore all packets */
- }
+ }
} else if (retval > 0 && (sig = udhcp_sp_read(&rfds))) {
switch (sig) {
- case SIGUSR1:
+ case SIGUSR1:
perform_renew();
break;
case SIGUSR2:
@@ -506,12 +506,12 @@ int main(int argc, char *argv[])
return 0;
}
} else if (retval == -1 && errno == EINTR) {
- /* a signal was caught */
+ /* a signal was caught */
} else {
/* An error occured */
DEBUG(LOG_ERR, "Error on select");
}
-
+
}
return 0;
}