1 Index: busybox-1.4.2/networking/udhcp/packet.c
2 ===================================================================
3 --- busybox-1.4.2.orig/networking/udhcp/packet.c 2007-06-04 13:21:32.289067984 +0200
4 +++ busybox-1.4.2/networking/udhcp/packet.c 2007-06-04 13:21:33.619865672 +0200
9 +int udhcp_get_payload_len(struct dhcpMessage *payload)
11 + return sizeof(struct dhcpMessage) - MAX_OPTIONS_LEN + end_option(payload->options) + sizeof(payload->options[0]);
14 /* Construct a ip/udp header for a packet, and specify the source and dest hardware address */
15 void BUG_sizeof_struct_udp_dhcp_packet_must_be_576(void);
18 struct sockaddr_ll dest;
19 struct udp_dhcp_packet packet;
20 + int p_len = udhcp_get_payload_len(payload);
22 fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
26 memset(&dest, 0, sizeof(dest));
27 memset(&packet, 0, sizeof(packet));
28 + memcpy(&(packet.data), payload, p_len);
30 dest.sll_family = AF_PACKET;
31 dest.sll_protocol = htons(ETH_P_IP);
33 packet.ip.daddr = dest_ip;
34 packet.udp.source = htons(source_port);
35 packet.udp.dest = htons(dest_port);
36 - packet.udp.len = htons(sizeof(packet.udp) + sizeof(struct dhcpMessage)); /* cheat on the psuedo-header */
37 + p_len += sizeof(packet.udp);
38 + packet.udp.len = htons(p_len);
39 packet.ip.tot_len = packet.udp.len;
40 - memcpy(&(packet.data), payload, sizeof(struct dhcpMessage));
41 - packet.udp.check = udhcp_checksum(&packet, sizeof(struct udp_dhcp_packet));
42 + p_len += sizeof(packet.ip);
43 + packet.udp.check = udhcp_checksum(&packet, p_len);
45 - packet.ip.tot_len = htons(sizeof(struct udp_dhcp_packet));
46 + packet.ip.tot_len = htons(p_len);
47 packet.ip.ihl = sizeof(packet.ip) >> 2;
48 packet.ip.version = IPVERSION;
49 packet.ip.ttl = IPDEFTTL;
51 if (sizeof(struct udp_dhcp_packet) != 576)
52 BUG_sizeof_struct_udp_dhcp_packet_must_be_576();
54 - result = sendto(fd, &packet, sizeof(struct udp_dhcp_packet), 0,
55 + result = sendto(fd, &packet, p_len, 0,
56 (struct sockaddr *) &dest, sizeof(dest));
58 bb_perror_msg("sendto");
63 - result = write(fd, payload, sizeof(struct dhcpMessage));
64 + result = write(fd, payload, udhcp_get_payload_len(payload));
68 Index: busybox-1.4.2/networking/udhcp/common.h
69 ===================================================================
70 --- busybox-1.4.2.orig/networking/udhcp/common.h 2007-06-04 13:21:32.297066768 +0200
71 +++ busybox-1.4.2/networking/udhcp/common.h 2007-06-04 13:21:33.620865520 +0200
73 #include <netinet/udp.h>
74 #include <netinet/ip.h>
76 +#define MAX_OPTIONS_LEN 308
85 - uint8_t options[308]; /* 312 - cookie */
86 + uint8_t options[MAX_OPTIONS_LEN]; /* 312 - cookie */
89 struct udp_dhcp_packet {