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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "derive_builder")]
use derive_builder::Builder;
/// The routes block defines standard static routes for an interface.
/// At least to must be specified. If type is local or nat a
/// default scope of host is assumed.
/// If type is unicast and no gateway (via) is given or type is
/// broadcast, multicast or anycast a default scope of link
/// is assumend. Otherwise, a global scope is the default setting.
///
/// For from, to, and via, both IPv4 and IPv6 addresses are
/// recognized, and must be in the form addr/prefixlen or addr.
#[derive(Default, Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "derive_builder", derive(Builder))]
#[cfg_attr(feature = "serde", serde(rename_all = "kebab-case"))]
pub struct RoutingConfig {
/// Set a source IP address for traffic going through the route.
/// (NetworkManager: as of v1.8.0)
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub from: Option<String>,
/// Destination address for the route.
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub to: Option<String>,
/// Address to the gateway to use for this route.
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub via: Option<String>,
/// When set to “true”, specifies that the route is directly connected
/// to the interface.
/// (NetworkManager: as of v1.12.0 for IPv4 and v1.18.0 for IPv6)
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
#[cfg_attr(feature = "serde", serde(default))]
#[cfg_attr(
feature = "serde",
serde(deserialize_with = "crate::bool::string_or_bool_option")
)]
pub on_link: Option<bool>,
/// The relative priority of the route. Must be a positive integer value.
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub metric: Option<u16>,
/// The type of route. Valid options are “unicast” (default), “anycast”,
/// “blackhole”, “broadcast”, “local”, “multicast”, “nat”, “prohibit”,
/// “throw”, “unreachable” or “xresolve”.
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub r#type: Option<RouteType>,
/// The route scope, how wide-ranging it is to the network. Possible
/// values are “global”, “link”, or “host”.
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub scope: Option<RouteScope>,
/// The table number to use for the route. In some scenarios, it may be
/// useful to set routes in a separate routing table. It may also be used
/// to refer to routing policy rules which also accept a table
/// parameter. Allowed values are positive integers starting from 1.
/// Some values are already in use to refer to specific routing tables:
/// see /etc/iproute2/rt_tables.
/// (NetworkManager: as of v1.10.0)
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub table: Option<u16>,
/// The MTU to be used for the route, in bytes. Must be a positive integer
/// value.
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub mtu: Option<u16>,
/// The congestion window to be used for the route, represented by number
/// of segments. Must be a positive integer value.
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub congestion_window: Option<u16>,
/// The receive window to be advertised for the route, represented by
/// number of segments. Must be a positive integer value.
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub advertised_receive_window: Option<u16>,
}
/// The type of route. Valid options are “unicast” (default), “anycast”,
/// “blackhole”, “broadcast”, “local”, “multicast”, “nat”, “prohibit”,
/// “throw”, “unreachable” or “xresolve”.
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "lowercase"))]
pub enum RouteType {
Unicast,
Anycast,
Blackhole,
Broadcast,
Local,
Multicast,
Nat,
Prohibit,
Throw,
Unreachable,
Xresolve,
}
/// The route scope, how wide-ranging it is to the network. Possible
/// values are “global”, “link”, or “host”.
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "lowercase"))]
pub enum RouteScope {
Global,
Link,
Host,
}
/// The routing-policy block defines extra routing policy for a network,
/// where traffic may be handled specially based on the source IP, firewall
/// marking, etc.
///
/// For from, to, both IPv4 and IPv6 addresses are recognized, and
/// must be in the form addr/prefixlen or addr.
#[derive(Default, Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "derive_builder", derive(Builder))]
#[cfg_attr(feature = "serde", serde(rename_all = "kebab-case"))]
pub struct RoutingPolicy {
/// Set a source IP address to match traffic for this policy rule.
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub from: Option<String>,
/// Match on traffic going to the specified destination.
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub to: Option<String>,
/// The table number to match for the route. In some scenarios, it may be
/// useful to set routes in a separate routing table. It may also be used
/// to refer to routes which also accept a table parameter.
/// Allowed values are positive integers starting from 1.
/// Some values are already in use to refer to specific routing tables:
/// see /etc/iproute2/rt_tables.
pub table: u16,
/// Specify a priority for the routing policy rule, to influence the order
/// in which routing rules are processed. A higher number means lower
/// priority: rules are processed in order by increasing priority number.
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub priority: Option<i32>,
/// Have this routing policy rule match on traffic that has been marked
/// by the iptables firewall with this value. Allowed values are positive
/// integers starting from 1.
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub mark: Option<u16>,
/// Match this policy rule based on the type of service number applied to
/// the traffic.
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub type_of_service: Option<String>,
}
/// Set DNS servers and search domains, for manual address configuration.
#[derive(Default, Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "derive_builder", derive(Builder))]
pub struct NameserverConfig {
/// A list of IPv4 or IPv6 addresses
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub addresses: Option<Vec<String>>,
/// A list of search domains.
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub search: Option<Vec<String>>,
}