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
29 {
30 }
31
32 explicit TriStateSetting(const Type t)
33 : type_(t)
34 {
35 }
36
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")
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:
80};
81} // namespace openvpn
82
83#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'