unifly_api/model/
network.rs1use serde::{Deserialize, Serialize};
4use std::net::{IpAddr, Ipv4Addr};
5
6use super::common::{DataSource, EntityOrigin};
7use super::entity_id::EntityId;
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
11pub enum NetworkManagement {
12 Gateway,
13 Switch,
14 Unmanaged,
15}
16
17#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
19pub enum NetworkPurpose {
20 Corporate,
21 Guest,
22 Wan,
23 VlanOnly,
24}
25
26#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
28#[non_exhaustive]
29pub enum Ipv6Mode {
30 PrefixDelegation,
31 Static,
32}
33
34impl std::fmt::Display for Ipv6Mode {
35 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36 match self {
37 Self::PrefixDelegation => f.write_str("Prefix Del"),
38 Self::Static => f.write_str("Static"),
39 }
40 }
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
45pub struct DhcpConfig {
46 pub enabled: bool,
47 pub range_start: Option<Ipv4Addr>,
48 pub range_stop: Option<Ipv4Addr>,
49 pub lease_time_secs: Option<u64>,
50 pub dns_servers: Vec<IpAddr>,
51 pub gateway: Option<Ipv4Addr>,
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56#[allow(clippy::struct_excessive_bools)]
57pub struct Network {
58 pub id: EntityId,
59 pub name: String,
60 pub enabled: bool,
61
62 pub management: Option<NetworkManagement>,
64 pub purpose: Option<NetworkPurpose>,
65 pub is_default: bool,
66
67 pub vlan_id: Option<u16>,
69
70 pub subnet: Option<String>,
72 pub gateway_ip: Option<Ipv4Addr>,
73
74 pub dhcp: Option<DhcpConfig>,
76
77 pub ipv6_enabled: bool,
79 pub ipv6_mode: Option<Ipv6Mode>,
80 pub ipv6_prefix: Option<String>,
81 pub dhcpv6_enabled: bool,
82 pub slaac_enabled: bool,
83
84 pub ntp_server: Option<IpAddr>,
86 pub pxe_enabled: bool,
87 pub tftp_server: Option<String>,
88
89 pub firewall_zone_id: Option<EntityId>,
91
92 pub isolation_enabled: bool,
94 pub internet_access_enabled: bool,
95 pub mdns_forwarding_enabled: bool,
96 pub cellular_backup_enabled: bool,
97
98 pub origin: Option<EntityOrigin>,
99
100 #[serde(skip)]
101 #[allow(dead_code)]
102 pub(crate) source: DataSource,
103}