2014-12-30 05:58:20 +01:00
|
|
|
// 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.
|
|
|
|
//
|
2022-09-29 11:41:13 +02:00
|
|
|
// Copyright (C) 2012-2022 OpenVPN Inc.
|
2014-12-30 05:58:20 +01:00
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
2017-12-21 21:42:20 +01:00
|
|
|
// it under the terms of the GNU Affero General Public License Version 3
|
2014-12-30 05:58:20 +01:00
|
|
|
// 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
|
2017-12-21 21:42:20 +01:00
|
|
|
// GNU Affero General Public License for more details.
|
2014-12-30 05:58:20 +01:00
|
|
|
//
|
2017-12-21 21:42:20 +01:00
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
2014-12-30 05:58:20 +01:00
|
|
|
// 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
|
|
|
|
{
|
2022-04-28 15:18:03 +02:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
MSSFIX_DEFAULT = 1492,
|
|
|
|
};
|
2014-12-30 05:58:20 +01:00
|
|
|
|
2020-06-03 11:42:16 +02:00
|
|
|
void parse(const OptionList &opt, bool nothrow = false)
|
2014-12-30 05:58:20 +01:00
|
|
|
{
|
|
|
|
const Option *o = opt.get_ptr("mssfix");
|
|
|
|
if (o)
|
|
|
|
{
|
2020-06-03 11:42:16 +02:00
|
|
|
const std::string *val = o->get_ptr(1, 16);
|
|
|
|
if (val == nullptr)
|
|
|
|
{
|
|
|
|
if (nothrow)
|
|
|
|
{
|
|
|
|
OPENVPN_LOG("Missing mssfix value, mssfix functionality disabled");
|
2022-04-28 15:18:03 +02:00
|
|
|
mssfix_default = false;
|
2020-06-03 11:42:16 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2024-03-08 05:09:11 +01:00
|
|
|
throw option_error(ERR_INVALID_OPTION_VAL, "mssfix must have a value");
|
2020-06-03 11:42:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const bool status = parse_number_validate<decltype(mssfix)>(*val,
|
2015-06-07 05:52:12 +02:00
|
|
|
16,
|
|
|
|
576,
|
|
|
|
65535,
|
|
|
|
&mssfix);
|
2014-12-30 05:58:20 +01:00
|
|
|
if (!status)
|
2020-06-03 11:42:16 +02:00
|
|
|
{
|
|
|
|
if (nothrow)
|
|
|
|
{
|
|
|
|
// no need to warn if mssfix is actually 0
|
|
|
|
if (*val != "0")
|
|
|
|
{
|
|
|
|
OPENVPN_LOG("Invalid mssfix value " << *val << ", mssfix functionality disabled");
|
2022-04-28 15:18:03 +02:00
|
|
|
mssfix_default = false;
|
2020-06-03 11:42:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2024-03-08 05:09:11 +01:00
|
|
|
throw option_error(ERR_INVALID_OPTION_VAL, "mssfix: parse/range issue");
|
2020-06-03 11:42:16 +02:00
|
|
|
}
|
2022-04-28 15:18:03 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
mssfix_default = false;
|
|
|
|
}
|
2014-12-30 05:58:20 +01:00
|
|
|
mtu = (o->get_optional(2, 16) == "mtu");
|
2022-04-28 15:18:03 +02:00
|
|
|
fixed = (o->get_optional(2, 16) == "fixed");
|
2014-12-30 05:58:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-28 15:18:03 +02:00
|
|
|
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;
|
2014-12-30 05:58:20 +01:00
|
|
|
};
|
2015-06-07 05:52:12 +02:00
|
|
|
|
|
|
|
struct MSSCtrlParms
|
|
|
|
{
|
|
|
|
MSSCtrlParms(const OptionList &opt)
|
|
|
|
{
|
|
|
|
mssfix_ctrl = opt.get_num<decltype(mssfix_ctrl)>("mssfix-ctrl", 1, 1250, 256, 65535);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int mssfix_ctrl;
|
|
|
|
};
|
2014-12-30 05:58:20 +01:00
|
|
|
} // namespace openvpn
|
|
|
|
|
|
|
|
#endif
|