]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Randomize ip_id and remove IPTOS_LOWDELAY and IP_DF flags.
authorRoy Marples <roy@marples.name>
Fri, 12 Mar 2010 20:33:15 +0000 (20:33 +0000)
committerRoy Marples <roy@marples.name>
Fri, 12 Mar 2010 20:33:15 +0000 (20:33 +0000)
This makes us a better net citizen.

net.c

diff --git a/net.c b/net.c
index 20edd0e7358ed3a786d7ef7f87235cced0d09705..910c340d14205b8aad57f82c91c50e54a138ebf3 100644 (file)
--- a/net.c
+++ b/net.c
@@ -668,14 +668,10 @@ make_udp_packet(uint8_t **packet, const uint8_t *data, size_t length,
        udp->uh_sum = checksum(udpp, sizeof(*udpp));
 
        ip->ip_v = IPVERSION;
-       ip->ip_hl = 5;
-       ip->ip_id = 0;
-       ip->ip_tos = IPTOS_LOWDELAY;
-       ip->ip_len = htons (sizeof(*ip) + sizeof(*udp) + length);
-       ip->ip_id = 0;
-       ip->ip_off = htons(IP_DF); /* Don't fragment */
+       ip->ip_hl = sizeof(*ip) >> 2;
+       ip->ip_id = arc4random() & UINT16_MAX;
        ip->ip_ttl = IPDEFTTL;
-
+       ip->ip_len = htons(sizeof(*ip) + sizeof(*udp) + length);
        ip->ip_sum = checksum(ip, sizeof(*ip));
 
        *packet = (uint8_t *)udpp;