aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-11-07 18:22:06 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2011-11-07 18:22:06 +0100
commit2b6a6b90cc7cebe777ce5d6eec10ecfc8f7a54b7 (patch)
tree7bdc5f7fa00853d313bf30ce361a6b09062dd61f /networking/udhcp
parent68c5b28156450d686605bd4715980037cabf1286 (diff)
downloadbusybox-w32-2b6a6b90cc7cebe777ce5d6eec10ecfc8f7a54b7.tar.gz
busybox-w32-2b6a6b90cc7cebe777ce5d6eec10ecfc8f7a54b7.tar.bz2
busybox-w32-2b6a6b90cc7cebe777ce5d6eec10ecfc8f7a54b7.zip
udhcpc6: set hop limit to 1 in emitted raw packets
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp')
-rw-r--r--networking/udhcp/d6_packet.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c
index 3a1bb3df1..79b2946ef 100644
--- a/networking/udhcp/d6_packet.c
+++ b/networking/udhcp/d6_packet.c
@@ -92,16 +92,20 @@ int FAST_FUNC d6_send_raw_packet(
92 /* size, excluding IP header: */ 92 /* size, excluding IP header: */
93 packet.udp.len = htons(sizeof(struct udphdr) + d6_pkt_size); 93 packet.udp.len = htons(sizeof(struct udphdr) + d6_pkt_size);
94 packet.ip6.ip6_plen = packet.udp.len; 94 packet.ip6.ip6_plen = packet.udp.len;
95 /* UDP checksum skips first four bytes of IP header. 95 /*
96 * IPv6 'hop limit' field should be 0. 96 * Someone was smoking weed (at least) while inventing UDP checksumming:
97 * 'next header' field should be summed as if it is in a different 97 * UDP checksum skips first four bytes of IPv6 header.
98 * position, therefore we write its value into ip6_hlim: 98 * 'next header' field should be summed as if it is one more byte
99 * to the right, therefore we write its value (IPPROTO_UDP)
100 * into ip6_hlim, and its 'real' location remains zero-filled for now.
99 */ 101 */
100 packet.ip6.ip6_hlim = IPPROTO_UDP; 102 packet.ip6.ip6_hlim = IPPROTO_UDP;
101 packet.udp.check = inet_cksum((uint16_t *)&packet + 2, 103 packet.udp.check = inet_cksum(
102 offsetof(struct ip6_udp_d6_packet, data) - 4 + d6_pkt_size); 104 (uint16_t *)&packet + 2,
105 offsetof(struct ip6_udp_d6_packet, data) - 4 + d6_pkt_size
106 );
103 /* fix 'hop limit' and 'next header' after UDP checksumming */ 107 /* fix 'hop limit' and 'next header' after UDP checksumming */
104 packet.ip6.ip6_hlim = 8; 108 packet.ip6.ip6_hlim = 1; /* observed Windows machines to use hlim=1 */
105 packet.ip6.ip6_nxt = IPPROTO_UDP; 109 packet.ip6.ip6_nxt = IPPROTO_UDP;
106 110
107 d6_dump_packet(d6_pkt); 111 d6_dump_packet(d6_pkt);