From: Ted Lemon Date: Tue, 1 Feb 2000 18:25:09 +0000 (+0000) Subject: Make IP_HL and IP_HL_SET consistent. X-Git-Tag: V3-BETA-2-PATCH-1~366 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=11515e7a8c26841c7c5cfb8b705da034cba7ab6a;p=thirdparty%2Fdhcp.git Make IP_HL and IP_HL_SET consistent. --- diff --git a/common/icmp.c b/common/icmp.c index 02e2150f6..c510055ab 100644 --- a/common/icmp.c +++ b/common/icmp.c @@ -23,7 +23,7 @@ #ifndef lint static char copyright[] = -"$Id: icmp.c,v 1.19 2000/02/01 18:19:48 mellon Exp $ Copyright (c) 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: icmp.c,v 1.20 2000/02/01 18:25:07 mellon Exp $ Copyright (c) 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -180,7 +180,7 @@ isc_result_t icmp_echoreply (h) /* Find the IP header length... */ ip = (struct ip *)icbuf; - hlen = IP_HL (ip) << 2; + hlen = IP_HL (ip); /* Short packet? */ if (status < hlen + (sizeof *icfrom)) { diff --git a/common/tr.c b/common/tr.c index f9707816b..e03bc9831 100644 --- a/common/tr.c +++ b/common/tr.c @@ -161,7 +161,7 @@ ssize_t decode_tr_header (interface, buf, bufix, from) * filter code in bpf.c */ llc = (struct trllc *)(buf + bufix + hdr_len); ip = (struct ip *) (llc + 1); - udp = (struct udphdr *) ((unsigned char*) ip + ip->ip_hl * 4); + udp = (struct udphdr *) ((unsigned char*) ip + IP_HL (ip)); /* make sure it is a snap encoded, IP, UDP, unfragmented packet sent * to our port */ diff --git a/includes/netinet/ip.h b/includes/netinet/ip.h index 4afb80d73..0a1e35840 100644 --- a/includes/netinet/ip.h +++ b/includes/netinet/ip.h @@ -64,10 +64,10 @@ struct ip { }; #define IP_V(iph) ((iph)->ip_fvhl >> 4) -#define IP_HL(iph) ((iph)->ip_fvhl & 0x0F) +#define IP_HL(iph) (((iph)->ip_fvhl & 0x0F) << 2) #define IP_V_SET(iph,x) ((iph)->ip_fvhl = ((iph)->ip_fvhl & 0x0F) | ((x) << 4)) #define IP_HL_SET(iph,x) ((iph)->ip_fvhl = \ - ((iph)->ip_fvhl & 0xF0) | ((x) >> 2)) + ((iph)->ip_fvhl & 0xF0) | (((x) >> 2) & 0x0F)) #define IP_MAXPACKET 65535 /* maximum packet size */