From: Roy Marples Date: Fri, 12 Mar 2010 20:33:15 +0000 (+0000) Subject: Randomize ip_id and remove IPTOS_LOWDELAY and IP_DF flags. X-Git-Tag: v5.2.2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58c910e8b759f898839fef35d52936b9874affda;p=thirdparty%2Fdhcpcd.git Randomize ip_id and remove IPTOS_LOWDELAY and IP_DF flags. This makes us a better net citizen. --- diff --git a/net.c b/net.c index 20edd0e7..910c340d 100644 --- 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;