OpenVPN 3 Core Library
Loading...
Searching...
No Matches
tristate_setting.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_TUN_IPv6_SETTING_H
13
#define OPENVPN_TUN_IPv6_SETTING_H
14
15
#include <
openvpn/common/exception.hpp
>
16
17
namespace
openvpn
{
18
class
TriStateSetting
19
{
20
public
:
21
enum
Type
22
{
23
No
,
24
Yes
,
25
Default
,
26
};
27
28
TriStateSetting
()
29
{
30
}
31
32
explicit
TriStateSetting
(
const
Type
t)
33
:
type_
(t)
34
{
35
}
36
37
Type
operator()
()
const
38
{
39
return
type_
;
40
}
41
42
std::string
to_string
()
const
43
{
44
switch
(
type_
)
45
{
46
case
No
:
47
return
"no"
;
48
case
Yes
:
49
return
"yes"
;
50
case
Default
:
51
default
:
52
return
"default"
;
53
}
54
}
55
56
static
TriStateSetting
parse
(
const
std::string &
str
)
57
{
58
if
(
str
==
"no"
)
59
return
TriStateSetting
(
No
);
60
else
if
(
str
==
"yes"
)
61
return
TriStateSetting
(
Yes
);
62
else
if
(
str
==
"default"
)
63
return
TriStateSetting
(
Default
);
64
else
65
throw
Exception
(
"IPv6Setting: unrecognized setting: '"
+
str
+
'\''
);
66
}
67
68
bool
operator==
(
const
TriStateSetting
&other)
const
69
{
70
return
type_
== other.
type_
;
71
}
72
73
bool
operator!=
(
const
TriStateSetting
&other)
const
74
{
75
return
type_
!= other.
type_
;
76
}
77
78
private
:
79
Type
type_
=
Default
;
80
};
81
}
// namespace openvpn
82
83
#endif
openvpn::Exception
Definition
exception.hpp:38
openvpn::TriStateSetting
Definition
tristate_setting.hpp:19
openvpn::TriStateSetting::TriStateSetting
TriStateSetting(const Type t)
Definition
tristate_setting.hpp:32
openvpn::TriStateSetting::operator()
Type operator()() const
Definition
tristate_setting.hpp:37
openvpn::TriStateSetting::operator==
bool operator==(const TriStateSetting &other) const
Definition
tristate_setting.hpp:68
openvpn::TriStateSetting::operator!=
bool operator!=(const TriStateSetting &other) const
Definition
tristate_setting.hpp:73
openvpn::TriStateSetting::parse
static TriStateSetting parse(const std::string &str)
Definition
tristate_setting.hpp:56
openvpn::TriStateSetting::type_
Type type_
Definition
tristate_setting.hpp:79
openvpn::TriStateSetting::TriStateSetting
TriStateSetting()
Definition
tristate_setting.hpp:28
openvpn::TriStateSetting::to_string
std::string to_string() const
Definition
tristate_setting.hpp:42
openvpn::TriStateSetting::Type
Type
Definition
tristate_setting.hpp:22
openvpn::TriStateSetting::Yes
@ Yes
Definition
tristate_setting.hpp:24
openvpn::TriStateSetting::No
@ No
Definition
tristate_setting.hpp:23
openvpn::TriStateSetting::Default
@ Default
Definition
tristate_setting.hpp:25
exception.hpp
openvpn
Definition
ovpncli.cpp:97
str
os<< "Session Name: "<< tbc-> session_name<< '\n';os<< "Layer: "<< tbc-> layer str()<< '\n'
openvpn
tun
tristate_setting.hpp
Generated by
1.9.8