summaryrefslogtreecommitdiffstats
path: root/cpukit/libnetworking/rtems/rtems_dhcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/libnetworking/rtems/rtems_dhcp.c')
-rw-r--r--cpukit/libnetworking/rtems/rtems_dhcp.c92
1 files changed, 46 insertions, 46 deletions
diff --git a/cpukit/libnetworking/rtems/rtems_dhcp.c b/cpukit/libnetworking/rtems/rtems_dhcp.c
index 490c11611c..df1acca710 100644
--- a/cpukit/libnetworking/rtems/rtems_dhcp.c
+++ b/cpukit/libnetworking/rtems/rtems_dhcp.c
@@ -1,5 +1,5 @@
/*
- * DCHP client for RTEMS
+ * DCHP client for RTEMS
* Andrew Bythell, <abythell@nortelnetworks.com>
* based on and uses subroutines from c/src/libnetworking/nfs/bootp_subr.c
*/
@@ -166,7 +166,7 @@ struct dhcp_packet
unsigned char vend[312];
};
-/*
+/*
* External Declarations for Functions found in
* rtems/c/src/libnetworking/nfs/
*/
@@ -236,11 +236,11 @@ printsetup (const char *iface,
char ip_str[15];
printf ("dhcpc: %s: ", iface);
-
+
ip = ntohl (ip_addr.s_addr);
format_ip (ip, ip_str);
printf ("inet: %-15s ", ip_str);
-
+
ip = ntohl (mask_addr.s_addr);
format_ip (ip, ip_str);
printf ("mask: %-15s\n", ip_str);
@@ -248,11 +248,11 @@ printsetup (const char *iface,
ip = ntohl (srv_addr.s_addr);
format_ip (ip, ip_str);
printf (" srv: %-15s ", ip_str);
-
+
ip = ntohl (gw_addr.s_addr);
format_ip (ip, ip_str);
printf (" gw: %-15s\n", ip_str);
-
+
return;
}
@@ -283,13 +283,13 @@ process_options (unsigned char *optbuf, int optbufSize)
}
len = optbuf[j + 1];
j += 2;
-
+
if ((len + j) >= optbufSize)
{
printf ("Truncated field for code %d", code);
return;
}
-
+
ncode = optbuf[j + len];
optbuf[j + len] = '\0';
p = (char*) &optbuf[j];
@@ -420,7 +420,7 @@ process_options (unsigned char *optbuf, int optbufSize)
/* DHCP Requested IP Address */
if (len != 4)
printf ("dhcpc: DHCP option requested IP len is %d", len);
- /*
+ /*
* although nothing happens here, this case keeps the client
* from complaining about unknown options. The Requested IP
* is necessary to return to the server for a DHCP REQUEST
@@ -436,7 +436,7 @@ process_options (unsigned char *optbuf, int optbufSize)
memcpy (&dhcp_lease_time, &p[0], 4);
dhcp_lease_time = ntohl (dhcp_lease_time);
break;
-
+
case 52:
/* DHCP option override */
if (len != 1) {
@@ -455,7 +455,7 @@ process_options (unsigned char *optbuf, int optbufSize)
dhcp_message_type = p[0];
break;
- case 128: /* Site-specific option for DHCP servers that
+ case 128: /* Site-specific option for DHCP servers that
* a) don't supply tag 54
* and
* b) don't supply the server address in siaddr
@@ -501,7 +501,7 @@ dhcp_discover_req (struct dhcp_packet* call,
unsigned long *xid)
{
int len = 0;
-
+
memset (call, 0, sizeof (struct dhcp_packet));
/*
@@ -514,7 +514,7 @@ dhcp_discover_req (struct dhcp_packet* call,
(*xid)++;
call->xid = htonl (*xid);
call->flags = htons (DHCP_BROADCAST);
-
+
memcpy (&call->chaddr, LLADDR (sdl), sdl->sdl_alen);
/*
@@ -567,7 +567,7 @@ dhcp_request_req (struct dhcp_packet* call,
int len = 0;
unsigned long temp;
char *hostname;
-
+
memset (call, 0, sizeof (struct dhcp_packet));
/*
@@ -619,7 +619,7 @@ dhcp_request_req (struct dhcp_packet* call,
call->vend[len++] = sizeof (reply->yiaddr);
memcpy (&call->vend[len], &reply->yiaddr, sizeof (reply->yiaddr));
len += sizeof (reply->yiaddr);
-
+
/*
* DHCP Parameter request list
*/
@@ -690,12 +690,12 @@ dhcp_task (rtems_task_argument _sdl)
struct proc *procp = NULL;
int disconnected;
rtems_status_code ev_st;
-
+
sdl = (struct sockaddr_dl *) _sdl;
-
+
count = dhcp_elapsed_time;
disconnected = 0;
-
+
while (true)
{
/*
@@ -709,7 +709,7 @@ dhcp_task (rtems_task_argument _sdl)
/*
* Check if not a poll timeout. So when ANY event received, exit task.
* Actually, only event RTEMS_EVENT_0 sent from rtem_dhcp_failsafe.c
- * if "failsafe" dhcp enabled when interface down. Otherwise, no
+ * if "failsafe" dhcp enabled when interface down. Otherwise, no
* event should occur, just timeout.
*/
if(ev_st != RTEMS_TIMEOUT)
@@ -720,7 +720,7 @@ dhcp_task (rtems_task_argument _sdl)
if (count >= (dhcp_lease_time / 2))
{
rtems_bsdnet_semaphore_obtain ();
-
+
dhcp_request_req (&call, &dhcp_req, sdl, true);
/*
@@ -744,18 +744,18 @@ dhcp_task (rtems_task_argument _sdl)
printf ("DHCP server did not send Magic Cookie.\n");
continue;
}
-
+
process_options (&dhcp_req.vend[4], sizeof (dhcp_req.vend) - 4);
-
+
if (dhcp_message_type != DHCP_ACK)
{
rtems_bsdnet_semaphore_release ();
printf ("DHCP server did not accept the DHCP request");
continue;
}
-
+
rtems_bsdnet_semaphore_release ();
-
+
count = 0;
}
}
@@ -776,7 +776,7 @@ dhcp_start_task (struct sockaddr_dl *sdl,
int priority)
{
rtems_status_code sc;
-
+
memcpy (&dhcp_req, reply, sizeof (struct dhcp_packet));
sc = rtems_task_create (rtems_build_name ('d','h','c','p'),
@@ -810,14 +810,14 @@ dhcp_interface_has_ip (struct ifreq *ireq, struct socket *so, struct proc *procp
{
struct sockaddr_in* sin;
int error;
-
+
/*
* Check if the interface is already up.
*/
error = ifioctl(so, SIOCGIFFLAGS, (caddr_t)ireq, procp);
if (error)
return 0;
-
+
if ((ireq->ifr_flags & IFF_UP) == 0)
return 0;
@@ -836,7 +836,7 @@ dhcp_interface_has_ip (struct ifreq *ireq, struct socket *so, struct proc *procp
}
/*
- * DCHP Client Routine
+ * DCHP Client Routine
* - The first DHCP offer is always accepted
* - No DHCP DECLINE message is sent if ARPing fails
*
@@ -869,7 +869,7 @@ dhcp_init (int update_files)
printf("Error creating the root filesystem.\nFile not created.\n");
update_files = 0;
}
-
+
/*
* Find a network interface.
*/
@@ -938,7 +938,7 @@ dhcp_init (int update_files)
}
process_options (&reply.vend[4], sizeof (reply.vend) - 4);
-
+
if (dhcp_message_type != DHCP_OFFER) {
printf ("DHCP server did not send a DHCP Offer.\n");
soclose (so);
@@ -946,10 +946,10 @@ dhcp_init (int update_files)
}
/*
- * Send a DHCP REQUEST
+ * Send a DHCP REQUEST
*/
dhcp_request_req (&call, &reply, sdl, true);
-
+
error = bootpc_call (&call, &reply, procp);
if (error) {
printf ("BOOTP call failed -- %s\n", strerror(error));
@@ -965,9 +965,9 @@ dhcp_init (int update_files)
soclose (so);
return -1;
}
-
+
process_options (&reply.vend[4], sizeof (reply.vend) - 4);
-
+
if (dhcp_message_type != DHCP_ACK) {
printf ("DHCP server did not accept the DHCP request\n");
soclose (so);
@@ -997,13 +997,13 @@ dhcp_init (int update_files)
*/
if (memcmp (&reply.vend[0], dhcp_magic_cookie, sizeof (dhcp_magic_cookie)) == 0)
process_options (&reply.vend[4], sizeof (reply.vend) - 4);
-
+
if (dhcp_option_overload & 1)
process_options ((unsigned char*) reply.file, sizeof reply.file);
else
if (reply.file[0])
rtems_bsdnet_bootp_boot_file_name = strdup (reply.file);
-
+
if (dhcp_option_overload & 2)
process_options ((unsigned char*) reply.sname, sizeof reply.sname);
else
@@ -1022,13 +1022,13 @@ dhcp_init (int update_files)
else
dhcp_netmask.sin_addr.s_addr = htonl (IN_CLASSC_NET);
}
-
+
if (!dhcp_gotserver)
rtems_bsdnet_bootp_server_address = reply.siaddr;
-
+
if (!dhcp_gotgw)
dhcp_gw.sin_addr = reply.giaddr;
-
+
if (!dhcp_gotlogserver)
rtems_bsdnet_log_host_address = rtems_bsdnet_bootp_server_address;
@@ -1076,9 +1076,9 @@ dhcp_init (int update_files)
const char *bufl[1];
bufl[0] = buf;
-
+
#define MKFILE_MODE (S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP | S_IROTH)
-
+
if (rtems_bsdnet_domain_name &&
(strlen(rtems_bsdnet_domain_name) < (sizeof(buf) - 1))) {
strcpy(buf, "search ");
@@ -1096,7 +1096,7 @@ dhcp_init (int update_files)
}
}
}
-
+
/*
* Configure the interface with the new settings
*/
@@ -1108,7 +1108,7 @@ dhcp_init (int update_files)
*/
if (dhcp_lease_time != 0xffffffff)
dhcp_start_task (sdl, &reply, 150);
-
+
soclose (so);
return 0;
@@ -1171,7 +1171,7 @@ rtems_bsdnet_do_dhcp_refresh_only (unsigned long xid,
*/
if (lease_time == 0xffffffff)
return;
-
+
/*
* Find a network interface.
*/
@@ -1199,7 +1199,7 @@ rtems_bsdnet_do_dhcp_refresh_only (unsigned long xid,
(sdl = ((struct sockaddr_dl *) ifa->ifa_addr)) &&
sdl->sdl_type == IFT_ETHER)
break;
-
+
if (!match) {
printf ("dhcpc: no matching interface address\n");
return;
@@ -1220,7 +1220,7 @@ rtems_bsdnet_do_dhcp_refresh_only (unsigned long xid,
dhcp_lease_time = lease_time;
dhcp_elapsed_time = elapsed_time;
-
+
if (hostname)
{
sethostname ((char *) hostname, strlen (hostname));