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
16
17namespace openvpn {
19{
20 public:
21 enum Type
22 {
26 };
27
28 TriStateSetting() = default;
29
30 explicit TriStateSetting(const Type t)
31 : type_(t)
32 {
33 }
34
36 {
37 return type_;
38 }
39
40 std::string to_string() const
41 {
42 switch (type_)
43 {
44 case No:
45 return "no";
46 case Yes:
47 return "yes";
48 case Default:
49 default:
50 return "default";
51 }
52 }
53
54 static TriStateSetting parse(const std::string &str)
55 {
56 if (str == "no")
57 return TriStateSetting(No);
58 if (str == "yes")
59 return TriStateSetting(Yes);
60 if (str == "default")
62 throw Exception("IPv6Setting: unrecognized setting: '" + str + '\'');
63 }
64
65 bool operator==(const TriStateSetting &other) const
66 {
67 return type_ == other.type_;
68 }
69
70 bool operator!=(const TriStateSetting &other) const
71 {
72 return type_ != other.type_;
73 }
74
75 private:
77};
78} // namespace openvpn
79
80#endif
bool operator==(const TriStateSetting &other) const
bool operator!=(const TriStateSetting &other) const
static TriStateSetting parse(const std::string &str)
std::string to_string() const
os<< "Session Name: "<< tbc-> session_name<< '\n';os<< "Layer: "<< tbc-> layer str()<< '\n'