libDwm-0.9.45
DwmIpv6PrefixMap.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 2021, 2023, 2024
5// All rights reserved.
6//
7// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions
9// are met:
10//
11// 1. Redistributions of source code must retain the above copyright
12// notice, this list of conditions and the following disclaimer.
13// 2. Redistributions in binary form must reproduce the above copyright
14// notice, this list of conditions and the following disclaimer in the
15// documentation and/or other materials provided with the distribution.
16// 3. The names of the authors and copyright holders may not be used to
17// endorse or promote products derived from this software without
18// specific prior written permission.
19//
20// IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
21// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
22// INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
23// EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
24// DAMAGE.
25//
26// THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
27// DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
28// UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
29// REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
30// IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31// WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
32// OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
33// TRADEMARK OR OTHER RIGHTS.
34//===========================================================================
35
36//---------------------------------------------------------------------------
40//---------------------------------------------------------------------------
41
42#ifndef _DWMIPV6PREFIXMAP_HH_
43#define _DWMIPV6PREFIXMAP_HH_
44
45#include <map>
46#include <mutex>
47#include <shared_mutex>
48#include <unordered_map>
49#include <vector>
50
51#include "DwmASIO.hh"
52#include "DwmBZ2IO.hh"
53#include "DwmDescriptorIO.hh"
54#include "DwmFileIO.hh"
55#include "DwmGZIO.hh"
56#include "DwmIOUtils.hh"
57#include "DwmIpv6Prefix.hh"
58#include "DwmStreamIO.hh"
59
60namespace Dwm {
61
62 //--------------------------------------------------------------------------
85 //--------------------------------------------------------------------------
87 {
88 inline size_t operator () (const Dwm::Ipv6Prefix & pfx) const
89 {
90 return pfx.Hash();
91 }
92 };
93
94 //--------------------------------------------------------------------------
102 //--------------------------------------------------------------------------
103 template <typename T, typename Hash = OurIpv6PrefixHash>
105 {
106 public:
107 //------------------------------------------------------------------------
109 //------------------------------------------------------------------------
110 using MapType = std::unordered_map<Ipv6Prefix,T,Hash>;
111 using LengthMapType = std::map<uint8_t,uint64_t>;
112
113 //------------------------------------------------------------------------
116 //------------------------------------------------------------------------
117 using MapPair = std::pair<MapType,LengthMapType>;
118
119 //------------------------------------------------------------------------
121 //------------------------------------------------------------------------
123 : _mtx(), _maps()
124 {
125 _maps.first.max_load_factor(.25);
126 }
127
128 //------------------------------------------------------------------------
131 //------------------------------------------------------------------------
132 void Add(const Ipv6Prefix & pfx, const T & value)
133 {
134 std::unique_lock lck(_mtx);
135 return Add(lck, pfx, value);
136 }
137
138 //------------------------------------------------------------------------
142 //------------------------------------------------------------------------
143 void Add(std::unique_lock<std::shared_mutex> & lck,
144 const Ipv6Prefix & pfx, const T & value)
145 {
146 assert((lck.mutex() == &_mtx) && lck.owns_lock());
147 if (_maps.first.insert_or_assign(pfx, value).second) {
148 _maps.second[pfx.MaskLength()]++;
149 }
150 return;
151 }
152
153 //------------------------------------------------------------------------
157 //------------------------------------------------------------------------
158 bool Find(const Ipv6Prefix & pfx, T & value) const
159 {
160 std::shared_lock lck(_mtx);
161 return Find(lck, pfx, value);
162 }
163
164 //------------------------------------------------------------------------
169 //------------------------------------------------------------------------
170 bool Find(std::shared_lock<std::shared_mutex> & lck,
171 const Ipv6Prefix & pfx, T & value) const
172 {
173 assert((lck.mutex() == &_mtx) && lck.owns_lock());
174 return FindNoLock(pfx, value);
175 }
176
177 //------------------------------------------------------------------------
182 //------------------------------------------------------------------------
183 bool Find(std::unique_lock<std::shared_mutex> & lck,
184 const Ipv6Prefix & pfx, T & value) const
185 {
186 assert((lck.mutex() == &_mtx) && lck.owns_lock());
187 return FindNoLock(pfx, value);
188 }
189
190 //------------------------------------------------------------------------
195 //------------------------------------------------------------------------
196 bool FindLongest(const Ipv6Address & addr,
197 std::pair<Ipv6Prefix,T> & value) const
198 {
199 std::shared_lock lck(_mtx);
200 return FindLongest(lck, addr, value);
201 }
202
203 //------------------------------------------------------------------------
209 //------------------------------------------------------------------------
210 bool FindLongest(std::shared_lock<std::shared_mutex> & lck,
211 const Ipv6Address & addr,
212 std::pair<Ipv6Prefix,T> & value) const
213 {
214 assert((lck.mutex() == &_mtx) && lck.owns_lock());
215 return FindLongestNoLock(addr, value);
216 }
217
218 //------------------------------------------------------------------------
224 //------------------------------------------------------------------------
225 bool FindLongest(std::unique_lock<std::shared_mutex> & lck,
226 const Ipv6Address & addr,
227 std::pair<Ipv6Prefix,T> & value) const
228 {
229 assert((lck.mutex() == &_mtx) && lck.owns_lock());
230 return FindLongestNoLock(addr, value);
231 }
232
233 //------------------------------------------------------------------------
238 //------------------------------------------------------------------------
239 bool FindMatches(const Ipv6Address & addr,
240 std::vector<std::pair<Ipv6Prefix,T>> & values) const
241 {
242 std::shared_lock lck(_mtx);
243 return FindMatches(lck, addr, values);
244 }
245
246 //------------------------------------------------------------------------
252 //------------------------------------------------------------------------
253 bool FindMatches(std::shared_lock<std::shared_mutex> & lck,
254 const Ipv6Address & addr,
255 std::vector<std::pair<Ipv6Prefix,T>> & values) const
256 {
257 assert((lck.mutex() == &_mtx) && lck.owns_lock());
258 return FindMatchesNoLock(addr, values);
259 }
260
261 //------------------------------------------------------------------------
267 //------------------------------------------------------------------------
268 bool FindMatches(std::unique_lock<std::shared_mutex> & lck,
269 const Ipv6Address & addr,
270 std::vector<std::pair<Ipv6Prefix,T>> & values) const
271 {
272 assert((lck.mutex() == &_mtx) && lck.owns_lock());
273 return FindMatchesNoLock(addr, values);
274 }
275
276 //------------------------------------------------------------------------
279 //------------------------------------------------------------------------
280 bool Remove(const Ipv6Prefix & pfx)
281 {
282 std::unique_lock lck(_mtx);
283 return Remove(lck, pfx);
284 }
285
286 //------------------------------------------------------------------------
290 //------------------------------------------------------------------------
291 bool Remove(std::unique_lock<std::shared_mutex> & lck,
292 const Ipv6Prefix & pfx)
293 {
294 assert((lck.mutex() == &_mtx) && lck.owns_lock());
295 bool rc = false;
296 auto it = _maps.first.find(pfx);
297 if (it != _maps.first.end()) {
298 _maps.first.erase(it);
299 auto lit = _maps.second.find(pfx.MaskLength());
300 lit->second--;
301 if (0 == lit->second) {
302 _maps.second.erase(lit);
303 }
304 rc = true;
305 }
306 return rc;
307 }
308
309 //------------------------------------------------------------------------
311 //------------------------------------------------------------------------
312 void Clear()
313 {
314 std::unique_lock lck(_mtx);
315 return Clear(lck);
316 }
317
318 //------------------------------------------------------------------------
321 //------------------------------------------------------------------------
322 void Clear(std::unique_lock<std::shared_mutex> & lck)
323 {
324 assert((lck.mutex() == &_mtx) && lck.owns_lock());
325 _maps.first.clear();
326 _maps.second.clear();
327 return;
328 }
329
330 //------------------------------------------------------------------------
332 //------------------------------------------------------------------------
333 bool Empty() const
334 {
335 std::shared_lock lck(_mtx);
336 return Empty(lck);
337 }
338
339 //------------------------------------------------------------------------
342 //------------------------------------------------------------------------
343 bool Empty(std::shared_lock<std::shared_mutex> & lck) const
344 {
345 assert((lck.mutex() == &_mtx) && lck.owns_lock());
346 return _maps.first.empty();
347 }
348
349 //------------------------------------------------------------------------
352 //------------------------------------------------------------------------
353 bool Empty(std::unique_lock<std::shared_mutex> & lck) const
354 {
355 assert((lck.mutex() == &_mtx) && lck.owns_lock());
356 return _maps.first.empty();
357 }
358
359 //------------------------------------------------------------------------
361 //------------------------------------------------------------------------
362 std::istream & Read(std::istream & is)
363 {
364 std::unique_lock lck(_mtx);
365 return StreamIO::Read(is, _maps);
366 }
367
368 //------------------------------------------------------------------------
370 //------------------------------------------------------------------------
371 std::ostream & Write(std::ostream & os) const
372 {
373 std::shared_lock lck(_mtx);
374 return StreamIO::Write(os, _maps);
375 }
376
377 //------------------------------------------------------------------------
380 //------------------------------------------------------------------------
381 size_t Read(FILE *f)
382 {
383 std::unique_lock lck(_mtx);
384 return FileIO::Read(f, _maps);
385 }
386
387 //------------------------------------------------------------------------
390 //------------------------------------------------------------------------
391 size_t Write(FILE *f) const
392 {
393 std::shared_lock lck(_mtx);
394 return FileIO::Write(f, _maps);
395 }
396
397 //------------------------------------------------------------------------
400 //------------------------------------------------------------------------
401 ssize_t Read(int fd)
402 {
403 std::unique_lock lck(_mtx);
404 return DescriptorIO::Read(fd, _maps);
405 }
406
407 //------------------------------------------------------------------------
410 //------------------------------------------------------------------------
411 ssize_t Write(int fd) const
412 {
413 std::shared_lock lck(_mtx);
414 return DescriptorIO::Write(fd, _maps);
415 }
416
417 //------------------------------------------------------------------------
422 //------------------------------------------------------------------------
423 int Read(gzFile gzf)
424 {
425 std::unique_lock lck(_mtx);
426 return GZIO::Read(gzf, _maps);
427 }
428
429 //------------------------------------------------------------------------
434 //------------------------------------------------------------------------
435 int Write(gzFile gzf) const
436 {
437 std::shared_lock lck(_mtx);
438 return GZIO::Write(gzf, _maps);
439 }
440
441 //------------------------------------------------------------------------
446 //------------------------------------------------------------------------
447 int BZRead(BZFILE *bzf)
448 {
449 std::unique_lock lck(_mtx);
450 return BZ2IO::BZRead(bzf, _maps);
451 }
452
453 //------------------------------------------------------------------------
458 //------------------------------------------------------------------------
459 int BZWrite(BZFILE *bzf) const
460 {
461 std::shared_lock lck(_mtx);
462 return BZ2IO::BZWrite(bzf, _maps);
463 }
464
465 //------------------------------------------------------------------------
468 //------------------------------------------------------------------------
469 uint64_t StreamedLength() const
470 {
471 std::shared_lock lck(_mtx);
472 return IOUtils::StreamedLength(_maps);
473 }
474
475 //------------------------------------------------------------------------
478 //------------------------------------------------------------------------
479 bool Read(boost::asio::ip::tcp::socket & s,
480 boost::system::error_code & ec)
481 {
482 std::unique_lock lck(_mtx);
483 return ASIO::Read(s, _maps, ec);
484 }
485
486 //------------------------------------------------------------------------
489 //------------------------------------------------------------------------
490 bool Read(boost::asio::local::stream_protocol::socket & s,
491 boost::system::error_code & ec)
492 {
493 std::unique_lock lck(_mtx);
494 return ASIO::Read(s, _maps, ec);
495 }
496
497 //------------------------------------------------------------------------
500 //------------------------------------------------------------------------
501 bool Read(boost::asio::generic::stream_protocol::socket & s,
502 boost::system::error_code & ec)
503 {
504 std::unique_lock lck(_mtx);
505 return ASIO::Read(s, _maps, ec);
506 }
507
508 //------------------------------------------------------------------------
511 //------------------------------------------------------------------------
512 bool Write(boost::asio::ip::tcp::socket & s,
513 boost::system::error_code & ec) const
514 {
515 std::shared_lock lck(_mtx);
516 return ASIO::Write(s, _maps, ec);
517 }
518
519 //------------------------------------------------------------------------
522 //------------------------------------------------------------------------
523 bool Write(boost::asio::local::stream_protocol::socket & s,
524 boost::system::error_code & ec) const
525 {
526 std::shared_lock lck(_mtx);
527 return ASIO::Write(s, _maps, ec);
528 }
529
530 //------------------------------------------------------------------------
533 //------------------------------------------------------------------------
534 bool Write(boost::asio::generic::stream_protocol::socket & s,
535 boost::system::error_code & ec) const
536 {
537 std::shared_lock lck(_mtx);
538 return ASIO::Write(s, _maps, ec);
539 }
540
541 //------------------------------------------------------------------------
551 //------------------------------------------------------------------------
552 std::shared_lock<std::shared_mutex> SharedLock() const
553 {
554 return std::shared_lock(_mtx);
555 }
556
557 //------------------------------------------------------------------------
569 //------------------------------------------------------------------------
570 std::unique_lock<std::shared_mutex> UniqueLock()
571 {
572 return std::unique_lock(_mtx);
573 }
574
575 private:
576 mutable std::shared_mutex _mtx;
577 MapPair _maps;
578
579 //------------------------------------------------------------------------
581 //------------------------------------------------------------------------
582 bool FindNoLock(const Ipv6Prefix & pfx, T & value) const
583 {
584 bool rc = false;
585 auto it = _maps.first.find(pfx);
586 if (it != _maps.first.end()) {
587 value = it->second;
588 rc = true;
589 }
590 return rc;
591 }
592
593 //------------------------------------------------------------------------
595 //------------------------------------------------------------------------
596 bool FindLongestNoLock(const Ipv6Address & addr,
597 std::pair<Ipv6Prefix,T> & value) const
598 {
599 bool rc = false;
600 value.first.Set(addr, 128);
601 for (auto lit = _maps.second.rbegin();
602 lit != _maps.second.rend(); ++lit) {
603 value.first.MaskLength(lit->first);
604 auto it = _maps.first.find(value.first);
605 if (it != _maps.first.end()) {
606 value.second = it->second;
607 rc = true;
608 break;
609 }
610 }
611 return rc;
612 }
613
614 //------------------------------------------------------------------------
616 //------------------------------------------------------------------------
617 bool FindMatchesNoLock(const Ipv6Address & addr,
618 std::vector<std::pair<Ipv6Prefix,T>> & values) const
619 {
620 values.clear();
621 std::pair<Ipv6Prefix,T> value;
622 for (auto lit = _maps.second.rbegin();
623 lit != _maps.second.rend(); ++lit) {
624 Ipv6Prefix pfx(addr, lit->first);
625 auto it = _maps.first.find(pfx);
626 if (it != _maps.first.end()) {
627 value.first = pfx;
628 value.second = it->second;
629 values.push_back(value);
630 }
631 }
632 return (! values.empty());
633 }
634
635 };
636
637} // namespace Dwm
638
639#endif // _DWMIPV6PREFIXMAP_HH_
Dwm::ASIO class declaration.
Dwm::BZ2IO class declaration.
Dwm::DescriptorIO class declaration.
Dwm::FileIO class declaration.
Dwm::GZIO class definition.
Dwm::IOUtils class declaration and implementation.
Dwm::Ipv6Prefix class definition.
Dwm::StreamIO class declaration.
static bool Write(boost::asio::ip::tcp::socket &s, uint8_t value, boost::system::error_code &ec)
Write value to the given socket s.
static bool Read(boost::asio::ip::tcp::socket &s, uint8_t &value, boost::system::error_code &ec)
Reads value from the given socket s.
static int BZRead(BZFILE *bzf, char &c)
Reads from bzf.
static int BZWrite(BZFILE *bzf, char c)
Writes c to bzf.
static ssize_t Write(int fd, char c)
Writes c to fd.
static ssize_t Read(int fd, char &c)
Reads c from fd.
static size_t Write(FILE *f, char c)
Writes c to f.
static size_t Read(FILE *f, char &c)
Reads c from f.
static int Write(gzFile gzf, char c)
Writes c to gzf.
static int Read(gzFile gzf, char &c)
Reads from gzf.
static uint64_t StreamedLength(char c)
Returns the number of bytes that would be written if we called Write() for a char.
Definition DwmIOUtils.hh:85
This class encapsulates an IPv6 address.
Definition DwmIpv6Address.hh:64
A wrapper around an unordered_map of T keyed by Ipv6Prefix using Hash as the hash function.
Definition DwmIpv6PrefixMap.hh:105
uint64_t StreamedLength() const
Returns the number of bytes that would be written if the Ipv6PrefixMap was written to a FILE,...
Definition DwmIpv6PrefixMap.hh:469
bool Write(boost::asio::ip::tcp::socket &s, boost::system::error_code &ec) const
Writes the Ipv6PrefixMap to s.
Definition DwmIpv6PrefixMap.hh:512
bool Empty() const
Returns true if the map is empty.
Definition DwmIpv6PrefixMap.hh:333
std::pair< MapType, LengthMapType > MapPair
Internally we keep our maps in a pair.
Definition DwmIpv6PrefixMap.hh:117
std::istream & Read(std::istream &is)
Reads the Ipv6PrefixMap from an istream. Returns the istream.
Definition DwmIpv6PrefixMap.hh:362
bool Write(boost::asio::local::stream_protocol::socket &s, boost::system::error_code &ec) const
Writes the Ipv6PrefixMap to s.
Definition DwmIpv6PrefixMap.hh:523
bool Find(const Ipv6Prefix &pfx, T &value) const
Find the entry with key pfx.
Definition DwmIpv6PrefixMap.hh:158
ssize_t Read(int fd)
Reads the Ipv6PrefixMap from file descriptor fd.
Definition DwmIpv6PrefixMap.hh:401
size_t Read(FILE *f)
Reads the Ipv6PrefixMap from f.
Definition DwmIpv6PrefixMap.hh:381
bool Read(boost::asio::local::stream_protocol::socket &s, boost::system::error_code &ec)
Reads the Ipv6PrefixMap from s.
Definition DwmIpv6PrefixMap.hh:490
bool Find(std::shared_lock< std::shared_mutex > &lck, const Ipv6Prefix &pfx, T &value) const
Find the entry with key pfx.
Definition DwmIpv6PrefixMap.hh:170
int BZRead(BZFILE *bzf)
Reads the Ipv6PrefixMap from bzf.
Definition DwmIpv6PrefixMap.hh:447
std::unique_lock< std::shared_mutex > UniqueLock()
Returns a unique lock of the Ipv6PrefixMap, in the locked state.
Definition DwmIpv6PrefixMap.hh:570
bool Empty(std::shared_lock< std::shared_mutex > &lck) const
Returns true if the map is empty.
Definition DwmIpv6PrefixMap.hh:343
void Add(std::unique_lock< std::shared_mutex > &lck, const Ipv6Prefix &pfx, const T &value)
Adds the given value to the map at key pfx.
Definition DwmIpv6PrefixMap.hh:143
bool Remove(const Ipv6Prefix &pfx)
Removes the entry for the given prefix pfx.
Definition DwmIpv6PrefixMap.hh:280
bool FindMatches(std::shared_lock< std::shared_mutex > &lck, const Ipv6Address &addr, std::vector< std::pair< Ipv6Prefix, T > > &values) const
Find all matches for the given IPv6 address addr.
Definition DwmIpv6PrefixMap.hh:253
bool FindLongest(const Ipv6Address &addr, std::pair< Ipv6Prefix, T > &value) const
Find the longest match for the given IPv6 address addr.
Definition DwmIpv6PrefixMap.hh:196
Ipv6PrefixMap()
Default constructor.
Definition DwmIpv6PrefixMap.hh:122
void Clear()
Clears the map.
Definition DwmIpv6PrefixMap.hh:312
bool Write(boost::asio::generic::stream_protocol::socket &s, boost::system::error_code &ec) const
Writes the Ipv6PrefixMap to s.
Definition DwmIpv6PrefixMap.hh:534
bool Read(boost::asio::ip::tcp::socket &s, boost::system::error_code &ec)
Reads the Ipv6PrefixMap from s.
Definition DwmIpv6PrefixMap.hh:479
std::ostream & Write(std::ostream &os) const
Writes the Ipv6PrefixMap to an ostream. Returns the ostream.
Definition DwmIpv6PrefixMap.hh:371
std::unordered_map< Ipv6Prefix, T, Hash > MapType
The types of our encapsulated containers.
Definition DwmIpv6PrefixMap.hh:110
bool Find(std::unique_lock< std::shared_mutex > &lck, const Ipv6Prefix &pfx, T &value) const
Find the entry with key pfx.
Definition DwmIpv6PrefixMap.hh:183
ssize_t Write(int fd) const
Writes the Ipv6PrefixMap to file descriptor fd.
Definition DwmIpv6PrefixMap.hh:411
bool FindLongest(std::shared_lock< std::shared_mutex > &lck, const Ipv6Address &addr, std::pair< Ipv6Prefix, T > &value) const
Find the longest match for the given IPv6 address addr.
Definition DwmIpv6PrefixMap.hh:210
std::shared_lock< std::shared_mutex > SharedLock() const
Returns a shared lock of the Ipv6PrefixMap, in the locked state.
Definition DwmIpv6PrefixMap.hh:552
bool Remove(std::unique_lock< std::shared_mutex > &lck, const Ipv6Prefix &pfx)
Removes the entry for the given prefix pfx.
Definition DwmIpv6PrefixMap.hh:291
int Write(gzFile gzf) const
Writes the Ipv6PrefixMap to gzf.
Definition DwmIpv6PrefixMap.hh:435
bool FindLongest(std::unique_lock< std::shared_mutex > &lck, const Ipv6Address &addr, std::pair< Ipv6Prefix, T > &value) const
Find the longest match for the given IPv6 address addr.
Definition DwmIpv6PrefixMap.hh:225
bool Empty(std::unique_lock< std::shared_mutex > &lck) const
Returns true if the map is empty.
Definition DwmIpv6PrefixMap.hh:353
int BZWrite(BZFILE *bzf) const
Writes the Ipv6PrefixMap to bzf.
Definition DwmIpv6PrefixMap.hh:459
void Add(const Ipv6Prefix &pfx, const T &value)
Adds the given value to the map at key pfx.
Definition DwmIpv6PrefixMap.hh:132
int Read(gzFile gzf)
Reads the Ipv6PrefixMap from gzf.
Definition DwmIpv6PrefixMap.hh:423
void Clear(std::unique_lock< std::shared_mutex > &lck)
Clears the map.
Definition DwmIpv6PrefixMap.hh:322
bool Read(boost::asio::generic::stream_protocol::socket &s, boost::system::error_code &ec)
Reads the Ipv6PrefixMap from s.
Definition DwmIpv6PrefixMap.hh:501
size_t Write(FILE *f) const
Writes the Ipv6PrefixMap to f.
Definition DwmIpv6PrefixMap.hh:391
bool FindMatches(const Ipv6Address &addr, std::vector< std::pair< Ipv6Prefix, T > > &values) const
Find all matches for the given IPv6 address addr.
Definition DwmIpv6PrefixMap.hh:239
bool FindMatches(std::unique_lock< std::shared_mutex > &lck, const Ipv6Address &addr, std::vector< std::pair< Ipv6Prefix, T > > &values) const
Find all matches for the given IPv6 address addr.
Definition DwmIpv6PrefixMap.hh:268
This class encapsulates an IPv6 network prefix.
Definition DwmIpv6Prefix.hh:52
uint64_t Hash() const
Given that the number of IPv6 addresses I typically deal with is nowhere near 4 billion,...
Definition DwmIpv6Prefix.hh:255
uint8_t MaskLength() const
Returns the netmask length.
Definition DwmIpv6Prefix.hh:95
static std::istream & Read(std::istream &is, char &c)
Reads c from is. Returns is.
static std::ostream & Write(std::ostream &os, char c)
Writes c to os. Returns os.
Default hash for our unordered_map in Ipv6PrefixMap.
Definition DwmIpv6PrefixMap.hh:87