netplan_types/netplan/device_types/bridges.rs
1#[cfg(feature = "serde")]
2use serde::{Deserialize, Serialize};
3
4#[cfg(feature = "derive_builder")]
5use derive_builder::Builder;
6
7use crate::CommonPropertiesAllDevices;
8
9#[derive(Default, Debug, Clone, PartialEq, Eq)]
10#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
11#[cfg_attr(feature = "derive_builder", derive(Builder))]
12#[cfg_attr(feature = "serde", serde(rename_all = "kebab-case"))]
13#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
14pub struct BridgeConfig {
15 /// All devices matching this ID list will be added to the bridge. This may
16 /// be an empty list, in which case the bridge will be brought online with
17 /// no member interfaces.
18 #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
19 pub interfaces: Option<Vec<String>>,
20 /// Customization parameters for special bridging options. Time intervals
21 /// may need to be expressed as a number of seconds or milliseconds: the
22 /// default value type is specified below. If necessary, time intervals can
23 /// be qualified using a time suffix (such as “s” for seconds, “ms” for
24 /// milliseconds) to allow for more control over its behavior.
25 #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
26 pub parameters: Option<BridgeParameters>,
27 /// Common properties for all devices
28 #[cfg_attr(feature = "serde", serde(flatten))]
29 #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
30 pub common_all: Option<CommonPropertiesAllDevices>,
31}
32
33/// Customization parameters for special bridging options. Time intervals
34/// may need to be expressed as a number of seconds or milliseconds: the
35/// default value type is specified below. If necessary, time intervals can
36/// be qualified using a time suffix (such as “s” for seconds, “ms” for
37/// milliseconds) to allow for more control over its behavior.
38#[derive(Default, Debug, Clone, PartialEq, Eq)]
39#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
40#[cfg_attr(feature = "derive_builder", derive(Builder))]
41#[cfg_attr(feature = "serde", serde(rename_all = "kebab-case"))]
42#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
43pub struct BridgeParameters {
44 /// Set the period of time to keep a MAC address in the forwarding
45 /// database after a packet is received. This maps to the AgeingTimeSec=
46 /// property when the networkd renderer is used. If no time suffix is
47 /// specified, the value will be interpreted as seconds.
48 #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
49 pub ageing_time: Option<String>,
50 /// Set the priority value for the bridge. This value should be a
51 /// number between 0 and 65535. Lower values mean higher
52 /// priority. The bridge with the higher priority will be elected as
53 /// the root bridge.
54 #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
55 pub priority: Option<u32>,
56 /// Set the port priority to . The priority value is
57 /// a number between 0 and 63. This metric is used in the
58 /// designated port and root port selection algorithms.
59 #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
60 pub port_priority: Option<u8>,
61 /// Specify the period of time the bridge will remain in Listening and
62 /// Learning states before getting to the Forwarding state. This field
63 /// maps to the ForwardDelaySec= property for the networkd renderer.
64 /// If no time suffix is specified, the value will be interpreted as
65 /// seconds.
66 #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
67 pub forward_delay: Option<String>,
68 /// Specify the interval between two hello packets being sent out from
69 /// the root and designated bridges. Hello packets communicate
70 /// information about the network topology. When the networkd renderer
71 /// is used, this maps to the HelloTimeSec= property. If no time suffix
72 /// is specified, the value will be interpreted as seconds.
73 #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
74 pub hello_time: Option<String>,
75 /// Set the maximum age of a hello packet. If the last hello packet is
76 /// older than that value, the bridge will attempt to become the root
77 /// bridge. This maps to the MaxAgeSec= property when the networkd
78 /// renderer is used. If no time suffix is specified, the value will be
79 /// interpreted as seconds.
80 #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
81 pub max_age: Option<String>,
82 /// Set the cost of a path on the bridge. Faster interfaces should have
83 /// a lower cost. This allows a finer control on the network topology
84 /// so that the fastest paths are available whenever possible.
85 #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
86 pub path_cost: Option<i32>,
87 /// Define whether the bridge should use Spanning Tree Protocol. The
88 /// default value is “true”, which means that Spanning Tree should be
89 /// used.
90 #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
91 #[cfg_attr(feature = "serde", serde(default))]
92 #[cfg_attr(
93 feature = "serde",
94 serde(deserialize_with = "crate::bool::string_or_bool_option")
95 )]
96 pub stp: Option<bool>,
97}