1 diff -ruN busybox-1.3.1-old/networking/udhcp/packet.c busybox-1.3.1/networking/udhcp/packet.c
2 --- busybox-1.3.1-old/networking/udhcp/packet.c 2006-12-27 05:52:33.000000000 +0100
3 +++ busybox-1.3.1/networking/udhcp/packet.c 2006-12-28 05:38:36.000000000 +0100
8 +int udhcp_get_payload_len(struct dhcpMessage *payload)
10 + return sizeof(struct dhcpMessage) - MAX_OPTIONS_LEN + end_option(payload->options) + sizeof(payload->options[0]);
13 /* Construct a ip/udp header for a packet, and specify the source and dest hardware address */
14 void BUG_sizeof_struct_udp_dhcp_packet_must_be_576(void);
17 struct sockaddr_ll dest;
18 struct udp_dhcp_packet packet;
19 + int p_len = udhcp_get_payload_len(payload);
21 fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
25 memset(&dest, 0, sizeof(dest));
26 memset(&packet, 0, sizeof(packet));
27 + memcpy(&(packet.data), payload, p_len);
29 dest.sll_family = AF_PACKET;
30 dest.sll_protocol = htons(ETH_P_IP);
32 packet.ip.daddr = dest_ip;
33 packet.udp.source = htons(source_port);
34 packet.udp.dest = htons(dest_port);
35 - packet.udp.len = htons(sizeof(packet.udp) + sizeof(struct dhcpMessage)); /* cheat on the psuedo-header */
36 + p_len += sizeof(packet.udp);
37 + packet.udp.len = htons(p_len);
38 packet.ip.tot_len = packet.udp.len;
39 - memcpy(&(packet.data), payload, sizeof(struct dhcpMessage));
40 - packet.udp.check = udhcp_checksum(&packet, sizeof(struct udp_dhcp_packet));
41 + p_len += sizeof(packet.ip);
42 + packet.udp.check = udhcp_checksum(&packet, p_len);
44 - packet.ip.tot_len = htons(sizeof(struct udp_dhcp_packet));
45 + packet.ip.tot_len = htons(p_len);
46 packet.ip.ihl = sizeof(packet.ip) >> 2;
47 packet.ip.version = IPVERSION;
48 packet.ip.ttl = IPDEFTTL;
50 if (sizeof(struct udp_dhcp_packet) != 576)
51 BUG_sizeof_struct_udp_dhcp_packet_must_be_576();
53 - result = sendto(fd, &packet, sizeof(struct udp_dhcp_packet), 0,
54 + result = sendto(fd, &packet, p_len, 0,
55 (struct sockaddr *) &dest, sizeof(dest));
57 bb_perror_msg("sendto");
62 - result = write(fd, payload, sizeof(struct dhcpMessage));
63 + result = write(fd, payload, udhcp_get_payload_len(payload));
67 diff -ruN busybox-1.3.1-old/networking/udhcp/common.h busybox-1.3.1/networking/udhcp/common.h
68 --- busybox-1.3.1-old/networking/udhcp/common.h 2006-12-27 05:52:33.000000000 +0100
69 +++ busybox-1.3.1/networking/udhcp/common.h 2006-12-28 05:17:06.000000000 +0100
71 #include <netinet/udp.h>
72 #include <netinet/ip.h>
74 +#define MAX_OPTIONS_LEN 308
83 - uint8_t options[308]; /* 312 - cookie */
84 + uint8_t options[MAX_OPTIONS_LEN]; /* 312 - cookie */
87 struct udp_dhcp_packet {