INet6Address.cti
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief INet6Address inline template implementation */
16 
17 #include "INet6Address.ih"
18 
19 // Custom includes
20 #include <boost/integer/integer_mask.hpp>
21 
22 #define prefix_ inline
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 #ifndef DOXYGEN
26 
27 template <unsigned a>
28 prefix_ bool senf::detail::CheckINet6Network_impl5<a,0,0>::match(boost::uint8_t v0,
29  boost::uint8_t v1)
30 {
31  return true;
32 }
33 
34 template <unsigned a, unsigned restbits>
35 prefix_ bool senf::detail::CheckINet6Network_impl5<a,0,restbits>::match(boost::uint8_t v0,
36  boost::uint8_t v1)
37 {
38  return (v0 & ~boost::low_bits_mask_t<8-restbits>::sig_bits) ==
39  (boost::uint8_t(a>>8) & ~boost::low_bits_mask_t<8-restbits>::sig_bits);
40 }
41 
42 template <unsigned a>
43 prefix_ bool senf::detail::CheckINet6Network_impl5<a,1,0>::match(boost::uint8_t v0,
44  boost::uint8_t v1)
45 {
46  return v0 == boost::uint8_t(a>>8);
47 }
48 
49 template <unsigned a, unsigned restbits>
50 prefix_ bool senf::detail::CheckINet6Network_impl5<a,1,restbits>::match(boost::uint8_t v0,
51  boost::uint8_t v1)
52 {
53  return (v0 == boost::uint8_t(a>>8)) &&
54  ((v1 & ~boost::low_bits_mask_t<8-restbits>::sig_bits)
55  == (boost::uint8_t(a) & ~boost::low_bits_mask_t<8-restbits>::sig_bits));
56 }
57 
58 template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4, unsigned a5,
59  unsigned a6, unsigned a7, unsigned restbits>
60 prefix_ bool senf::detail::CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,0,restbits>::
61 match(INet6Address const & addr)
62 {
63  return CheckINet6Network_impl4<a0,restbits>::match(addr[0],addr[1]);
64 }
65 
66 template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4, unsigned a5,
67  unsigned a6, unsigned a7, unsigned restbits>
68 prefix_ bool senf::detail::CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,1,restbits>::
69 match(INet6Address const & addr)
70 {
71  return
72  addr[0] == boost::uint8_t(a0>>8) && addr[1] == boost::uint8_t(a0) &&
73  CheckINet6Network_impl4<a1,restbits>::match(addr[2],addr[3]);
74 }
75 
76 template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4, unsigned a5,
77  unsigned a6, unsigned a7, unsigned restbits>
78 prefix_ bool senf::detail::CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,2,restbits>::
79 match(INet6Address const & addr)
80 {
81  return
82  addr[0] == boost::uint8_t(a0>>8) && addr[1] == boost::uint8_t(a0) &&
83  addr[2] == boost::uint8_t(a1>>8) && addr[3] == boost::uint8_t(a1) &&
84  CheckINet6Network_impl4<a1,restbits>::match(addr[4],addr[5]);
85 }
86 
87 template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4, unsigned a5,
88  unsigned a6, unsigned a7, unsigned restbits>
89 prefix_ bool senf::detail::CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,3,restbits>::
90 match(INet6Address const & addr)
91 {
92  return
93  addr[0] == boost::uint8_t(a0>>8) && addr[1] == boost::uint8_t(a0) &&
94  addr[2] == boost::uint8_t(a1>>8) && addr[3] == boost::uint8_t(a1) &&
95  addr[4] == boost::uint8_t(a2>>8) && addr[5] == boost::uint8_t(a2) &&
96  CheckINet6Network_impl4<a3,restbits>::match(addr[6],addr[7]);
97 }
98 
99 template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4, unsigned a5,
100  unsigned a6, unsigned a7, unsigned restbits>
101 prefix_ bool senf::detail::CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,4,restbits>::
102 match(INet6Address const & addr)
103 {
104  return
105  addr[0] == boost::uint8_t(a0>>8) && addr[1] == boost::uint8_t(a0) &&
106  addr[2] == boost::uint8_t(a1>>8) && addr[3] == boost::uint8_t(a1) &&
107  addr[4] == boost::uint8_t(a2>>8) && addr[5] == boost::uint8_t(a2) &&
108  addr[6] == boost::uint8_t(a3>>8) && addr[7] == boost::uint8_t(a3) &&
109  CheckINet6Network_impl4<a4,restbits>::match(addr[8],addr[9]);
110 }
111 
112 template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4, unsigned a5,
113  unsigned a6, unsigned a7, unsigned restbits>
114 prefix_ bool senf::detail::CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,5,restbits>::
115 match(INet6Address const & addr)
116 {
117  return
118  addr[0] == boost::uint8_t(a0>>8) && addr[1] == boost::uint8_t(a0) &&
119  addr[2] == boost::uint8_t(a1>>8) && addr[3] == boost::uint8_t(a1) &&
120  addr[4] == boost::uint8_t(a2>>8) && addr[5] == boost::uint8_t(a2) &&
121  addr[6] == boost::uint8_t(a3>>8) && addr[7] == boost::uint8_t(a3) &&
122  addr[8] == boost::uint8_t(a4>>8) && addr[9] == boost::uint8_t(a4) &&
123  CheckINet6Network_impl4<a5,restbits>::match(addr[10],addr[11]);
124 }
125 
126 template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4, unsigned a5,
127  unsigned a6, unsigned a7, unsigned restbits>
128 prefix_ bool senf::detail::CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,6,restbits>::
129 match(INet6Address const & addr)
130 {
131  return
132  addr[0] == boost::uint8_t(a0>>8) && addr[1] == boost::uint8_t(a0) &&
133  addr[2] == boost::uint8_t(a1>>8) && addr[3] == boost::uint8_t(a1) &&
134  addr[4] == boost::uint8_t(a2>>8) && addr[5] == boost::uint8_t(a2) &&
135  addr[6] == boost::uint8_t(a3>>8) && addr[7] == boost::uint8_t(a3) &&
136  addr[8] == boost::uint8_t(a4>>8) && addr[9] == boost::uint8_t(a4) &&
137  addr[10] == boost::uint8_t(a5>>8) && addr[11] == boost::uint8_t(a5) &&
138  CheckINet6Network_impl4<a6,restbits>::match(addr[12],addr[13]);
139 }
140 
141 template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4, unsigned a5,
142  unsigned a6, unsigned a7, unsigned restbits>
143 prefix_ bool senf::detail::CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,7,restbits>::
144 match(INet6Address const & addr)
145 {
146  return
147  addr[0] == boost::uint8_t(a0>>8) && addr[1] == boost::uint8_t(a0) &&
148  addr[2] == boost::uint8_t(a1>>8) && addr[3] == boost::uint8_t(a1) &&
149  addr[4] == boost::uint8_t(a2>>8) && addr[5] == boost::uint8_t(a2) &&
150  addr[6] == boost::uint8_t(a3>>8) && addr[7] == boost::uint8_t(a3) &&
151  addr[8] == boost::uint8_t(a4>>8) && addr[9] == boost::uint8_t(a4) &&
152  addr[10] == boost::uint8_t(a5>>8) && addr[11] == boost::uint8_t(a5) &&
153  addr[12] == boost::uint8_t(a6>>8) && addr[13] == boost::uint8_t(a6) &&
154  CheckINet6Network_impl4<a7,restbits>::match(addr[14],addr[15]);
155 }
156 
157 #endif
158 
159 //-/////////////////////////////////////////////////////////////////////////////////////////////////
160 #undef prefix_
161 
162 
163 // Local Variables:
164 // mode: c++
165 // fill-column: 100
166 // comment-column: 40
167 // c-file-style: "senf"
168 // indent-tabs-mode: nil
169 // ispell-local-dictionary: "american"
170 // compile-command: "scons -u test"
171 // End: