OpenVPN 3 Core Library
Loading...
Searching...
No Matches
addrlist.hpp
Go to the documentation of this file.
1// OpenVPN -- An application to securely tunnel IP networks
2// over a single port, with support for SSL/TLS-based
3// session authentication and key exchange,
4// packet encryption, packet authentication, and
5// packet compression.
6//
7// Copyright (C) 2012- OpenVPN Inc.
8//
9// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10//
11
12#ifndef OPENVPN_ADDR_ADDRLIST_H
13#define OPENVPN_ADDR_ADDRLIST_H
14
15#include <openvpn/common/rc.hpp>
16#include <openvpn/addr/ip.hpp>
17
18namespace openvpn::IP {
19
20// A list of unique IP addresses
21class AddrList : public std::vector<IP::Addr>, public RC<thread_unsafe_refcount>
22{
23 public:
25
26 void add(const IP::Addr &a)
27 {
28 if (!exists(a))
29 push_back(a);
30 }
31
32 bool exists(const IP::Addr &a) const
33 {
34 return std::find(begin(), end(), a) != end();
35 }
36
37#if 0
38 void dump() const
39 {
40 OPENVPN_LOG("******* AddrList::dump");
41 for (const auto& i : *this)
42 {
43 OPENVPN_LOG(i.to_string());
44 }
45 }
46#endif
47};
48} // namespace openvpn::IP
49
50#endif
RCPtr< AddrList > Ptr
Definition addrlist.hpp:24
bool exists(const IP::Addr &a) const
Definition addrlist.hpp:32
void add(const IP::Addr &a)
Definition addrlist.hpp:26
The smart pointer class.
Definition rc.hpp:119
Reference count base class for objects tracked by RCPtr. Disallows copying and assignment.
Definition rc.hpp:912
#define OPENVPN_LOG(args)