1 diff -ruN busybox-1.2.1-old/networking/udhcp/packet.c busybox-1.2.1-new/networking/udhcp/packet.c
2 --- busybox-1.2.1-old/networking/udhcp/packet.c 2006-07-01 00:42:02.000000000 +0200
3 +++ busybox-1.2.1-new/networking/udhcp/packet.c 2006-11-19 01:04:40.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 int udhcp_raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port,
17 struct sockaddr_ll dest;
18 struct udp_dhcp_packet packet;
19 + int p_len = udhcp_get_payload_len(payload);
21 if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) {
22 DEBUG(LOG_ERR, "socket call failed: %m");
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;
49 packet.ip.check = udhcp_checksum(&(packet.ip), sizeof(packet.ip));
51 - result = sendto(fd, &packet, sizeof(struct udp_dhcp_packet), 0, (struct sockaddr *) &dest, sizeof(dest));
52 + result = sendto(fd, &packet, p_len, 0, (struct sockaddr *) &dest, sizeof(dest));
54 DEBUG(LOG_ERR, "write on socket failed: %m");
60 - result = write(fd, payload, sizeof(struct dhcpMessage));
61 + result = write(fd, payload, udhcp_get_payload_len(payload));
65 diff -ruN busybox-1.2.1-old/networking/udhcp/packet.h busybox-1.2.1-new/networking/udhcp/packet.h
66 --- busybox-1.2.1-old/networking/udhcp/packet.h 2006-07-01 00:42:02.000000000 +0200
67 +++ busybox-1.2.1-new/networking/udhcp/packet.h 2006-11-19 00:49:38.000000000 +0100
69 #include <netinet/udp.h>
70 #include <netinet/ip.h>
72 +#define MAX_OPTIONS_LEN 308
81 - uint8_t options[308]; /* 312 - cookie */
82 + uint8_t options[MAX_OPTIONS_LEN]; /* 312 - cookie */
85 struct udp_dhcp_packet {