svn commit: trunk/busybox/networking/udhcp

vda at busybox.net vda at busybox.net
Mon Nov 20 01:13:10 UTC 2006


Author: vda
Date: 2006-11-19 17:13:09 -0800 (Sun, 19 Nov 2006)
New Revision: 16587

Log:
add compile-time check for correct DHCP packet size


Modified:
   trunk/busybox/networking/udhcp/packet.c


Changeset:
Modified: trunk/busybox/networking/udhcp/packet.c
===================================================================
--- trunk/busybox/networking/udhcp/packet.c	2006-11-20 00:48:22 UTC (rev 16586)
+++ trunk/busybox/networking/udhcp/packet.c	2006-11-20 01:13:09 UTC (rev 16587)
@@ -109,6 +109,7 @@
 
 
 /* Construct a ip/udp header for a packet, and specify the source and dest hardware address */
+void BUG_sizeof_struct_udp_dhcp_packet_must_be_576(void);
 int udhcp_raw_packet(struct dhcpMessage *payload,
 		uint32_t source_ip, int source_port,
 		uint32_t dest_ip, int dest_port, uint8_t *dest_arp, int ifindex)
@@ -154,6 +155,9 @@
 	packet.ip.ttl = IPDEFTTL;
 	packet.ip.check = udhcp_checksum(&(packet.ip), sizeof(packet.ip));
 
+	if (sizeof(struct udp_dhcp_packet) != 576)
+		BUG_sizeof_struct_udp_dhcp_packet_must_be_576();
+
 	result = sendto(fd, &packet, sizeof(struct udp_dhcp_packet), 0,
 			(struct sockaddr *) &dest, sizeof(dest));
 	if (result <= 0) {




More information about the busybox-cvs mailing list