INet6Address.ih
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 internal header */
16 
17 #ifndef IH_SENF_Socket_Protocols_INet_INet6Address_
18 #define IH_SENF_Socket_Protocols_INet_INet6Address_ 1
19 
20 // Custom includes
21 
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 namespace senf {
25 
26  class INet6Address;
27 
28 namespace detail {
29 
30 # ifndef DOXYGEN
31 
32  template <unsigned a, unsigned bytes, unsigned restbits>
33  struct CheckINet6Network_impl5
34  {};
35 
36  template <unsigned a>
37  struct CheckINet6Network_impl5<a,0,0>
38  {
39  static bool match(boost::uint8_t v0, boost::uint8_t v1);
40  };
41 
42  template <unsigned a, unsigned restbits>
43  struct CheckINet6Network_impl5<a,0,restbits>
44  {
45  static bool match(boost::uint8_t v0, boost::uint8_t v1);
46  };
47 
48  template <unsigned a>
49  struct CheckINet6Network_impl5<a,1,0>
50  {
51  static bool match(boost::uint8_t v0, boost::uint8_t v1);
52  };
53 
54  template <unsigned a, unsigned restbits>
55  struct CheckINet6Network_impl5<a,1,restbits>
56  {
57  static bool match(boost::uint8_t v0, boost::uint8_t v1);
58  };
59 
60  template <unsigned a, unsigned bits>
61  struct CheckINet6Network_impl4
62  : public CheckINet6Network_impl5<a,bits/8,bits%8>
63  {};
64 
65  template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4,
66  unsigned a5, unsigned a6, unsigned a7, unsigned words, unsigned restbits>
67  struct CheckINet6Network_impl3
68  {};
69 
70  template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4,
71  unsigned a5, unsigned a6, unsigned a7, unsigned restbits>
72  struct CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,0,restbits>
73  {
74  static bool match(INet6Address const & addr);
75  };
76 
77  template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4,
78  unsigned a5, unsigned a6, unsigned a7, unsigned restbits>
79  struct CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,1,restbits>
80  {
81  static bool match(INet6Address const & addr);
82  };
83 
84  template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4,
85  unsigned a5, unsigned a6, unsigned a7, unsigned restbits>
86  struct CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,2,restbits>
87  {
88  static bool match(INet6Address const & addr);
89  };
90 
91  template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4,
92  unsigned a5, unsigned a6, unsigned a7, unsigned restbits>
93  struct CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,3,restbits>
94  {
95  static bool match(INet6Address const & addr);
96  };
97 
98  template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4,
99  unsigned a5, unsigned a6, unsigned a7, unsigned restbits>
100  struct CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,4,restbits>
101  {
102  static bool match(INet6Address const & addr);
103  };
104 
105  template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4,
106  unsigned a5, unsigned a6, unsigned a7, unsigned restbits>
107  struct CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,5,restbits>
108  {
109  static bool match(INet6Address const & addr);
110  };
111 
112  template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4,
113  unsigned a5, unsigned a6, unsigned a7, unsigned restbits>
114  struct CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,6,restbits>
115  {
116  static bool match(INet6Address const & addr);
117  };
118 
119  template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4,
120  unsigned a5, unsigned a6, unsigned a7, unsigned restbits>
121  struct CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,7,restbits>
122  {
123  static bool match(INet6Address const & addr);
124  };
125 
126  template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4,
127  unsigned a5, unsigned a6, unsigned a7, unsigned bits>
128  struct CheckINet6Network_impl2
129  : public CheckINet6Network_impl3<a0,a1,a2,a3,a4,a5,a6,a7,bits/16,bits%16>
130  {};
131 
132  template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4,
133  unsigned a5, unsigned a6, unsigned a7, unsigned a8>
134  struct CheckINet6Network_impl
135  : public CheckINet6Network_impl2<a0,a1,a2,a3,a4,a5,a6,a7,a8>
136  {};
137 
138  template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4,
139  unsigned a5, unsigned a6, unsigned a7>
140  struct CheckINet6Network_impl<a0,a1,a2,a3,a4,a5,a6,a7,0>
141  : public CheckINet6Network_impl2<a0,a1,a2,a3,a4,a5,a6,0,a7>
142  {};
143 
144  template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4,
145  unsigned a5, unsigned a6>
146  struct CheckINet6Network_impl<a0,a1,a2,a3,a4,a5,a6,0,0>
147  : public CheckINet6Network_impl2<a0,a1,a2,a3,a4,a5,0,0,a6>
148  {};
149 
150  template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4,
151  unsigned a5>
152  struct CheckINet6Network_impl<a0,a1,a2,a3,a4,a5,0,0,0>
153  : public CheckINet6Network_impl2<a0,a1,a2,a3,a4,0,0,0,a5>
154  {};
155 
156  template <unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a4>
157  struct CheckINet6Network_impl<a0,a1,a2,a3,a4,0,0,0,0>
158  : public CheckINet6Network_impl2<a0,a1,a2,a3,0,0,0,0,a4>
159  {};
160 
161  template <unsigned a0, unsigned a1, unsigned a2, unsigned a3>
162  struct CheckINet6Network_impl<a0,a1,a2,a3,0,0,0,0,0>
163  : public CheckINet6Network_impl2<a0,a1,a2,0,0,0,0,0,a3>
164  {};
165 
166  template <unsigned a0, unsigned a1, unsigned a2>
167  struct CheckINet6Network_impl<a0,a1,a2,0,0,0,0,0,0>
168  : public CheckINet6Network_impl2<a0,a1,0,0,0,0,0,0,a2>
169  {};
170 
171  template <unsigned a0, unsigned a1>
172  struct CheckINet6Network_impl<a0,a1,0,0,0,0,0,0,0>
173  : public CheckINet6Network_impl2<a0,0,0,0,0,0,0,0,a1>
174  {};
175 
176 # endif
177 
178  boost::uint8_t low_bits_mask(unsigned bits);
179 
180  template <class ForwardIterator, class Function>
181  void apply_mask(unsigned bits, ForwardIterator b, ForwardIterator e, Function fn);
182 
183  template <class ForwardIterator1, class ForwardIterator2, class Function>
184  ForwardIterator1 find_if_mask(unsigned bits,
185  ForwardIterator1 b1, ForwardIterator1 e1, ForwardIterator2 b2,
186  Function fn);
187 
188 }}
189 
190 //-/////////////////////////////////////////////////////////////////////////////////////////////////
191 #endif
192 
193 
194 // Local Variables:
195 // mode: c++
196 // fill-column: 100
197 // comment-column: 40
198 // c-file-style: "senf"
199 // indent-tabs-mode: nil
200 // ispell-local-dictionary: "american"
201 // compile-command: "scons -u test"
202 // End: