summaryrefslogtreecommitdiff
path: root/networking/udhcp/clientpacket.c
diff options
context:
space:
mode:
authorEric Andersen2004-03-15 08:29:22 +0000
committerEric Andersen2004-03-15 08:29:22 +0000
commitc7bda1ce659294d6e22c06e087f6f265983c7578 (patch)
tree4c6d2217f4d8306c59cf1096f8664e1cfd167213 /networking/udhcp/clientpacket.c
parent8854004b41065b3d081af7f3df13a100b0c8bfbe (diff)
downloadbusybox-c7bda1ce659294d6e22c06e087f6f265983c7578.zip
busybox-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.gz
Remove trailing whitespace. Update copyright to include 2004.
Diffstat (limited to 'networking/udhcp/clientpacket.c')
-rw-r--r--networking/udhcp/clientpacket.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c
index 6838c07..5b27004 100644
--- a/networking/udhcp/clientpacket.c
+++ b/networking/udhcp/clientpacket.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 <string.h>
#include <sys/socket.h>
#include <features.h>
@@ -73,7 +73,7 @@ static void init_packet(struct dhcpMessage *packet, char type)
char vendor, length;
char str[sizeof("udhcp "VERSION)];
} vendor_id = { DHCP_VENDOR, sizeof("udhcp "VERSION) - 1, "udhcp "VERSION};
-
+
init_header(packet, type);
memcpy(packet->chaddr, client_config.arp, 6);
add_option_string(packet->options, client_config.clientid);
@@ -112,7 +112,7 @@ int send_discover(unsigned long xid, unsigned long requested)
add_requests(&packet);
LOG(LOG_DEBUG, "Sending discover...");
- return raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
+ return raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
}
@@ -128,11 +128,11 @@ int send_selecting(unsigned long xid, unsigned long server, unsigned long reques
add_simple_option(packet.options, DHCP_REQUESTED_IP, requested);
add_simple_option(packet.options, DHCP_SERVER_ID, server);
-
+
add_requests(&packet);
addr.s_addr = requested;
LOG(LOG_DEBUG, "Sending select for %s...", inet_ntoa(addr));
- return raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
+ return raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
}
@@ -149,12 +149,12 @@ int send_renew(unsigned long xid, unsigned long server, unsigned long ciaddr)
add_requests(&packet);
LOG(LOG_DEBUG, "Sending renew...");
- if (server)
+ if (server)
ret = kernel_packet(&packet, ciaddr, CLIENT_PORT, server, SERVER_PORT);
else ret = raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
return ret;
-}
+}
/* Unicasts a DHCP release message */
@@ -165,7 +165,7 @@ int send_release(unsigned long server, unsigned long ciaddr)
init_packet(&packet, DHCPRELEASE);
packet.xid = random_xid();
packet.ciaddr = ciaddr;
-
+
add_simple_option(packet.options, DHCP_REQUESTED_IP, ciaddr);
add_simple_option(packet.options, DHCP_SERVER_ID, server);
@@ -189,20 +189,20 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
usleep(500000); /* possible down interface, looping condition */
return -1;
}
-
+
if (bytes < (int) (sizeof(struct iphdr) + sizeof(struct udphdr))) {
DEBUG(LOG_INFO, "message too short, ignoring");
return -2;
}
-
+
if (bytes < ntohs(packet.ip.tot_len)) {
DEBUG(LOG_INFO, "Truncated packet");
return -2;
}
-
+
/* ignore any extra garbage bytes */
bytes = ntohs(packet.ip.tot_len);
-
+
/* Make sure its the right packet for us, and that it passes sanity checks */
if (packet.ip.protocol != IPPROTO_UDP || packet.ip.version != IPVERSION ||
packet.ip.ihl != sizeof(packet.ip) >> 2 || packet.udp.dest != htons(CLIENT_PORT) ||
@@ -219,7 +219,7 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
DEBUG(LOG_INFO, "bad IP header checksum, ignoring");
return -1;
}
-
+
/* verify the UDP checksum by replacing the header with a psuedo header */
source = packet.ip.saddr;
dest = packet.ip.daddr;
@@ -235,14 +235,14 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
DEBUG(LOG_ERR, "packet with bad UDP checksum received, ignoring");
return -2;
}
-
+
memcpy(payload, &(packet.data), bytes - (sizeof(packet.ip) + sizeof(packet.udp)));
-
+
if (ntohl(payload->cookie) != DHCP_MAGIC) {
LOG(LOG_ERR, "received bogus message (bad magic) -- ignoring");
return -2;
}
DEBUG(LOG_INFO, "oooooh!!! got some!");
return bytes - (sizeof(packet.ip) + sizeof(packet.udp));
-
+
}