OpenVPN 3 Core Library
|
Base class for route-related functionality representing a network route. More...
#include <capture.hpp>
Public Member Functions | |
std::string | to_string () const |
Converts the route to a human-readable string. | |
Json::Value | to_json () const |
Serializes the route to a JSON object. | |
void | from_json (const Json::Value &root, const std::string &title) |
Deserializes the route from a JSON object. | |
Public Attributes | |
std::string | address |
unsigned char | prefix_length = 0 |
int | metric = -1 |
std::string | gateway |
bool | ipv6 = false |
bool | net30 = false |
Protected Member Functions | |
void | validate_ (const std::string &title, const bool require_canonical) const |
Protected validation method used by derived classes. | |
Static Protected Attributes | |
static constexpr int | net30_prefix_length = 30 |
Base class for route-related functionality representing a network route.
This class serves as a base for route classes, providing common validation functionality. It encapsulates the components of a network route, including address, prefix length, gateway, and various options. It provides methods for string representation, JSON serialization/deserialization, and validation. The class handles both IPv4 and IPv6 routes, with special support for net30 routes commonly used in certain VPN configurations.
Definition at line 196 of file capture.hpp.
|
inline |
Deserializes the route from a JSON object.
Populates the route properties from a JSON object. Throws exceptions if required fields are missing or have invalid types.
root | The JSON object to parse. |
title | A string identifier used in error messages. |
Definition at line 252 of file capture.hpp.
|
inline |
Serializes the route to a JSON object.
Creates a JSON object with keys for each route property.
Definition at line 233 of file capture.hpp.
|
inline |
Converts the route to a human-readable string.
Formats the route in CIDR notation (address/prefix_length), including gateway, metric, IPv6 flag, and net30 flag if applicable.
Definition at line 212 of file capture.hpp.
|
inlineprotected |
Protected validation method used by derived classes.
Performs validation with different requirements based on the canonical flag. Checks if the route is valid and properly formatted. Validates address format, prefix length, gateway format if specified, and net30 compliance if required.
title | A string identifier used in error messages. |
require_canonical | If true , verifies the route is in canonical form. |
Exception | if validation fails. |
Definition at line 277 of file capture.hpp.
std::string openvpn::TunBuilderCapture::RouteBase::address |
Definition at line 199 of file capture.hpp.
std::string openvpn::TunBuilderCapture::RouteBase::gateway |
Definition at line 202 of file capture.hpp.
bool openvpn::TunBuilderCapture::RouteBase::ipv6 = false |
Definition at line 203 of file capture.hpp.
int openvpn::TunBuilderCapture::RouteBase::metric = -1 |
Definition at line 201 of file capture.hpp.
bool openvpn::TunBuilderCapture::RouteBase::net30 = false |
Definition at line 204 of file capture.hpp.
|
staticconstexprprotected |
Definition at line 265 of file capture.hpp.
unsigned char openvpn::TunBuilderCapture::RouteBase::prefix_length = 0 |
Definition at line 200 of file capture.hpp.