adds rt_tables to files installed by ip ipkg
[openwrt.git] / package / busybox / patches / 241-udhcpc-oversized_packets.patch
1 Index: busybox-1.7.2/networking/udhcp/packet.c
2 ===================================================================
3 --- busybox-1.7.2.orig/networking/udhcp/packet.c 2007-10-30 15:35:00.000000000 -0500
4 +++ busybox-1.7.2/networking/udhcp/packet.c 2007-10-30 15:35:01.000000000 -0500
5 @@ -121,6 +121,10 @@
6 return ~sum;
7 }
8
9 +int udhcp_get_payload_len(struct dhcpMessage *payload)
10 +{
11 + return sizeof(struct dhcpMessage) - MAX_OPTIONS_LEN + end_option(payload->options) + sizeof(payload->options[0]);
12 +}
13
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);
16 @@ -132,6 +136,7 @@
17 int result;
18 struct sockaddr_ll dest;
19 struct udp_dhcp_packet packet;
20 + int p_len = udhcp_get_payload_len(payload);
21
22 fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
23 if (fd < 0) {
24 @@ -141,6 +146,7 @@
25
26 memset(&dest, 0, sizeof(dest));
27 memset(&packet, 0, sizeof(packet));
28 + memcpy(&(packet.data), payload, p_len);
29
30 dest.sll_family = AF_PACKET;
31 dest.sll_protocol = htons(ETH_P_IP);
32 @@ -158,12 +164,13 @@
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);
44
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;
50 @@ -172,7 +179,7 @@
51 if (sizeof(struct udp_dhcp_packet) != 576)
52 BUG_sizeof_struct_udp_dhcp_packet_must_be_576();
53
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));
57 if (result <= 0) {
58 bb_perror_msg("sendto");
59 @@ -216,7 +223,7 @@
60 return -1;
61 }
62
63 - result = write(fd, payload, sizeof(struct dhcpMessage));
64 + result = write(fd, payload, udhcp_get_payload_len(payload));
65 close(fd);
66 return result;
67 }
68 Index: busybox-1.7.2/networking/udhcp/common.h
69 ===================================================================
70 --- busybox-1.7.2.orig/networking/udhcp/common.h 2007-10-30 15:35:00.000000000 -0500
71 +++ busybox-1.7.2/networking/udhcp/common.h 2007-10-30 15:35:01.000000000 -0500
72 @@ -21,6 +21,8 @@
73 #include <netinet/udp.h>
74 #include <netinet/ip.h>
75
76 +#define MAX_OPTIONS_LEN 308
77 +
78 struct dhcpMessage {
79 uint8_t op;
80 uint8_t htype;
81 @@ -37,7 +39,7 @@
82 uint8_t sname[64];
83 uint8_t file[128];
84 uint32_t cookie;
85 - uint8_t options[308]; /* 312 - cookie */
86 + uint8_t options[MAX_OPTIONS_LEN]; /* 312 - cookie */
87 };
88
89 struct udp_dhcp_packet {
This page took 0.050445 seconds and 5 git commands to generate.