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 throw option_error(ERR_INVALID_OPTION_VAL, "mssfix must have a value");
41 }
42
43 const bool status = parse_number_validate<decltype(mssfix)>(*val,
44 16,
45 576,
46 65535,
47 &mssfix);
48 if (!status)
49 {
50 if (nothrow)
51 {
52 // no need to warn if mssfix is actually 0
53 if (*val != "0")
54 {
55 OPENVPN_LOG("Invalid mssfix value " << *val << ", mssfix functionality disabled");
56 mssfix_default = false;
57 }
58 }
59 else
60 throw option_error(ERR_INVALID_OPTION_VAL, "mssfix: parse/range issue");
61 }
62 else
63 {
64 mssfix_default = false;
65 }
66 mtu = (o->get_optional(2, 16) == "mtu");
67 fixed = (o->get_optional(2, 16) == "fixed");
68 }
69 }
70
71 unsigned int mssfix = 0; // standard OpenVPN mssfix parm
72 bool mtu = false; // include overhead from IP and TCP/UDP encapsulation
73 bool fixed = false; // use mssfix value without any encapsulation adjustments
74 bool mssfix_default = true;
75};
76
78{
80 {
81 mssfix_ctrl = opt.get_num<decltype(mssfix_ctrl)>("mssfix-ctrl", 1, 1250, 256, 65535);
82 }
83
84 unsigned int mssfix_ctrl;
85};
86} // namespace openvpn
87
88#endif
T get_num(const std::string &name, const size_t idx, const T default_value) const
Definition options.hpp:1395
const Option * get_ptr(const std::string &name) const
Definition options.hpp:1174
std::string get_optional(const size_t index, const size_t max_len) const
Definition options.hpp:191
const std::string * get_ptr(const size_t index, const size_t max_len) const
Definition options.hpp:207
#define OPENVPN_LOG(args)
unsigned int mssfix_ctrl
Definition mssparms.hpp:84
MSSCtrlParms(const OptionList &opt)
Definition mssparms.hpp:79
void parse(const OptionList &opt, bool nothrow=false)
Definition mssparms.hpp:26
unsigned int mssfix
Definition mssparms.hpp:71