forked from mysteriumnetwork/openvpn3
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmssparms.hpp
99 lines (90 loc) · 2.71 KB
/
mssparms.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// OpenVPN -- An application to securely tunnel IP networks
// over a single port, with support for SSL/TLS-based
// session authentication and key exchange,
// packet encryption, packet authentication, and
// packet compression.
//
// Copyright (C) 2012-2020 OpenVPN Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License Version 3
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program in the COPYING file.
// If not, see <http://www.gnu.org/licenses/>.
#ifndef OPENVPN_SSL_MSSPARMS_H
#define OPENVPN_SSL_MSSPARMS_H
#include <openvpn/common/options.hpp>
#include <openvpn/common/number.hpp>
namespace openvpn {
struct MSSParms
{
enum {
MSSFIX_DEFAULT = 1492,
};
void parse(const OptionList& opt, bool nothrow=false)
{
const Option *o = opt.get_ptr("mssfix");
if (o)
{
const std::string* val = o->get_ptr(1, 16);
if (val == nullptr)
{
if (nothrow)
{
OPENVPN_LOG("Missing mssfix value, mssfix functionality disabled");
mssfix_default = false;
return;
}
else
throw option_error("mssfix must have a value");
}
const bool status = parse_number_validate<decltype(mssfix)>(*val,
16,
576,
65535,
&mssfix);
if (!status)
{
if (nothrow)
{
// no need to warn if mssfix is actually 0
if (*val != "0")
{
OPENVPN_LOG("Invalid mssfix value " << *val << ", mssfix functionality disabled");
mssfix_default = false;
}
}
else
throw option_error("mssfix: parse/range issue");
}
else
{
mssfix_default = false;
}
mtu = (o->get_optional(2, 16) == "mtu");
fixed = (o->get_optional(2, 16) == "fixed");
}
}
unsigned int mssfix = 0; // standard OpenVPN mssfix parm
bool mtu = false; // include overhead from IP and TCP/UDP encapsulation
bool fixed = false; // use mssfix value without any encapsulation adjustments
bool mssfix_default = true;
};
struct MSSCtrlParms
{
MSSCtrlParms(const OptionList& opt)
{
mssfix_ctrl = opt.get_num<decltype(mssfix_ctrl)>("mssfix-ctrl", 1, 1250,
256, 65535);
}
unsigned int mssfix_ctrl;
};
}
#endif