OpenVPN 3 Core Library
Loading...
Searching...
No Matches
mode.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_COMMON_MODE_H
13#define OPENVPN_COMMON_MODE_H
14
15// A client/server mode class.
16
17namespace openvpn {
18class Mode
19{
20 public:
21 enum Type
22 {
25 };
26
28 : type_(CLIENT)
29 {
30 }
31 explicit Mode(const Type t)
32 : type_(t)
33 {
34 }
35
36 bool is_server() const
37 {
38 return type_ == SERVER;
39 }
40 bool is_client() const
41 {
42 return type_ == CLIENT;
43 }
44
45 bool operator==(const Mode &other)
46 {
47 return type_ == other.type_;
48 }
49
50 bool operator!=(const Mode &other)
51 {
52 return type_ != other.type_;
53 }
54
55 const char *str() const
56 {
57 switch (type_)
58 {
59 case CLIENT:
60 return "CLIENT";
61 case SERVER:
62 return "SERVER";
63 default:
64 return "UNDEF_MODE";
65 }
66 }
67
68 private:
70};
71} // namespace openvpn
72
73#endif // OPENVPN_COMMON_MODE_H
bool operator==(const Mode &other)
Definition mode.hpp:45
bool is_server() const
Definition mode.hpp:36
bool is_client() const
Definition mode.hpp:40
const char * str() const
Definition mode.hpp:55
Mode(const Type t)
Definition mode.hpp:31
bool operator!=(const Mode &other)
Definition mode.hpp:50
Type type_
Definition mode.hpp:69