diff options
| author | Philip Paeps <philip@FreeBSD.org> | 2009-10-23 14:43:17 +0000 |
|---|---|---|
| committer | Philip Paeps <philip@FreeBSD.org> | 2009-10-23 14:43:17 +0000 |
| commit | 1ca0e46fdfb82b931d25332101e5d56289794911 (patch) | |
| tree | d283f9cb1fc13d3a0c23f2d3c1098420badddcc2 /sbin/dhclient/packet.c | |
| parent | de411f4cd2b28c94938e2548d6a28ec8785856f1 (diff) | |
Notes
Diffstat (limited to 'sbin/dhclient/packet.c')
| -rw-r--r-- | sbin/dhclient/packet.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sbin/dhclient/packet.c b/sbin/dhclient/packet.c index 484953ca2d98..2e90cc85a8de 100644 --- a/sbin/dhclient/packet.c +++ b/sbin/dhclient/packet.c @@ -135,6 +135,17 @@ assemble_udp_ip_header(unsigned char *buf, int *bufix, u_int32_t from, ip.ip_dst.s_addr = to; ip.ip_sum = wrapsum(checksum((unsigned char *)&ip, sizeof(ip), 0)); + + /* + * While the BPF -- used for broadcasts -- expects a "true" IP header + * with all the bytes in network byte order, the raw socket interface + * which is used for unicasts expects the ip_len field to be in host + * byte order. In both cases, the checksum has to be correct, so this + * is as good a place as any to turn the bytes around again. + */ + if (to != INADDR_BROADCAST) + ip.ip_len = ntohs(ip.ip_len); + memcpy(&buf[*bufix], &ip, sizeof(ip)); *bufix += sizeof(ip); |
