From 6112cb9a43327fed0c1ebc6e25959c849a10f9b1 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 7 Oct 2010 21:51:28 +0000 Subject: [PATCH] Fix bugs in ip6_pack_hdr so that the traffic class and flow label are set correctly. 1. Shift the low-order bits of fc by 20 bits, not 28, because fl is a 20-bit field. 2. Use a mask in host byte order to mask fl, which is also provided in host byte order. 3. Swap | and & in combining fc and fl. --- libdnet-stripped/include/dnet/ip6.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdnet-stripped/include/dnet/ip6.h b/libdnet-stripped/include/dnet/ip6.h index d09b3fd7c..881ba50f8 100644 --- a/libdnet-stripped/include/dnet/ip6.h +++ b/libdnet-stripped/include/dnet/ip6.h @@ -164,8 +164,8 @@ struct ip6_ext_hdr { #define ip6_pack_hdr(hdr, fc, fl, plen, nxt, hlim, src, dst) do { \ struct ip6_hdr *ip6 = (struct ip6_hdr *)(hdr); \ - ip6->ip6_flow = htonl(((uint32_t)(fc) << 28) & \ - (IP6_FLOWLABEL_MASK | (fl))); \ + ip6->ip6_flow = htonl(((uint32_t)(fc) << 20) | \ + (0x000fffff & (fl))); \ ip6->ip6_vfc = (IP6_VERSION | ((fc) >> 4)); \ ip6->ip6_plen = htons((plen)); \ ip6->ip6_nxt = (nxt); ip6->ip6_hlim = (hlim); \