OpenVPN 3 Core Library
Loading...
Searching...
No Matches
mssparms.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_SSL_MSSPARMS_H
13#define OPENVPN_SSL_MSSPARMS_H
14
17
18namespace openvpn {
20{
21 enum
22 {
24 };
25
26 void parse(const OptionList &opt, bool nothrow = false)
27 {
28 const Option *o = opt.get_ptr("mssfix");
29 if (o)
30 {
31 const std::string *val = o->get_ptr(1, 16);
32 if (val == nullptr)
33 {
34 if (nothrow)
35 {
36 OPENVPN_LOG("Missing mssfix value, mssfix functionality disabled");
37 mssfix_default = false;
38 return;
39 }
40 else
41 throw option_error(ERR_INVALID_OPTION_VAL, "mssfix must have a value");
42 }
43
44 const bool status = parse_number_validate<decltype(mssfix)>(*val,
45 16,
46 576,
47 65535,
48 &mssfix);
49 if (!status)
50 {
51 if (nothrow)
52 {
53 // no need to warn if mssfix is actually 0
54 if (*val != "0")
55 {
56 OPENVPN_LOG("Invalid mssfix value " << *val << ", mssfix functionality disabled");
57 mssfix_default = false;
58 }
59 }
60 else
61 throw option_error(ERR_INVALID_OPTION_VAL, "mssfix: parse/range issue");
62 }
63 else
64 {
65 mssfix_default = false;
66 }
67 mtu = (o->get_optional(2, 16) == "mtu");
68 fixed = (o->get_optional(2, 16) == "fixed");
69 }
70 }
71
72 unsigned int mssfix = 0; // standard OpenVPN mssfix parm
73 bool mtu = false; // include overhead from IP and TCP/UDP encapsulation
74 bool fixed = false; // use mssfix value without any encapsulation adjustments
75 bool mssfix_default = true;
76};
77
79{
81 {
82 mssfix_ctrl = opt.get_num<decltype(mssfix_ctrl)>("mssfix-ctrl", 1, 1250, 256, 65535);
83 }
84
85 unsigned int mssfix_ctrl;
86};
87} // namespace openvpn
88
89#endif
T get_num(const std::string &name, const size_t idx, const T default_value) const
Definition options.hpp:1416
const Option * get_ptr(const std::string &name) const
Definition options.hpp:1186
std::string get_optional(const size_t index, const size_t max_len) const
Definition options.hpp:194
const std::string * get_ptr(const size_t index, const size_t max_len) const
Definition options.hpp:212
#define OPENVPN_LOG(args)
unsigned int mssfix_ctrl
Definition mssparms.hpp:85
MSSCtrlParms(const OptionList &opt)
Definition mssparms.hpp:80
void parse(const OptionList &opt, bool nothrow=false)
Definition mssparms.hpp:26
unsigned int mssfix
Definition mssparms.hpp:72