Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 74 additions & 10 deletions rust/agama-lib/share/profile.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,11 @@
"additionalProperties": false,
"properties": {
"password": {
"title": "Password of the wireless network",
"type": "string"
},
"security": {
"title": "Security method/key management",
"type": "string",
"enum": [
"none",
Expand All @@ -154,16 +156,78 @@
]
},
"ssid": {
"title": "SSID of the wireless network",
"type": "string"
},
"mode": {
"title": "Wireless network mode",
"type": "string",
"enum": [
"infrastructure",
"adhoc",
"mesh",
"ap"
]
},
"hidden": {
"title": "Indicates that the wireless network is not broadcasting its SSID",
"type": "boolean"
},
"band": {
"title": "Frequency band of the wireless network",
"type": "string",
"enum": [
"a",
"bg"
]
},
"channel": {
"title": "Wireless channel of the wireless network",
"type": "integer",
"minimum" : 0
},
"bssid": {
"title": "Only allow connection to this mac address",
"type": "string"
},
"groupAlgorithms": {
"type": "array",
"items": {
"title": "A list of group/broadcast encryption algorithms",
"type": "string",
"enum": [
"wep40",
"wep104",
"tkip",
"ccmp"
]
},
},
"pairwiseAlgorithms": {
"type": "array",
"items": {
"title": "A list of pairwise encryption algorithms",
"type": "string",
"enum": [
"tkip",
"ccmp"
]
}
},
"wpaProtocolVersions": {
"type": "array",
"items": {
"title": "A list of allowed WPA protocol versions",
"type": "string",
"enum": [
"wpa",
"rsn"
]
}
},
"pmf": {
"title": "Indicates whether Protected Management Frames must be enabled for the connection",
"type": "integer"
}
}
},
Expand Down Expand Up @@ -252,7 +316,7 @@
]
}
},
"phase2_auth": {
"phase2Auth": {
"title": "Phase 2 inner auth method",
"type": "string",
"enum": [
Expand All @@ -274,43 +338,43 @@
"title": "Password string used for EAP authentication",
"type": "string"
},
"ca_cert": {
"caCert": {
"title": "Path to CA certificate",
"type": "string"
},
"ca_cert_password": {
"caCertPassword": {
"title": "Password string for CA certificate if it is encrypted",
"type": "string"
},
"client_cert": {
"clientCert": {
"title": "Path to client certificate",
"type": "string"
},
"client_cert_password": {
"clientCertPassword": {
"title": "Password string for client certificate if it is encrypted",
"type": "string"
},
"private_key": {
"privateKey": {
"title": "Path to private key",
"type": "string"
},
"private_key_password": {
"privateKeyPassword": {
"title": "Password string for private key if it is encrypted",
"type": "string"
},
"anonymous_identity": {
"anonymousIdentity": {
"title": "Anonymous identity string for EAP authentication methods",
"type": "string"
},
"peap_version": {
"peapVersion": {
"title": "Which PEAP version is used when PEAP is set as the EAP method in the 'eap' property",
"type": "string",
"enum": [
"0",
"1"
]
},
"peap_label": {
"peapLabel": {
"title": "Force the use of the new PEAP label during key derivation",
"type": "boolean"
}
Expand Down
35 changes: 33 additions & 2 deletions rust/agama-lib/src/network/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,43 @@ impl MatchSettings {
}
}

/// Wireless configuration
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WirelessSettings {
/// Password of the wireless network
#[serde(skip_serializing_if = "Option::is_none")]
pub password: Option<String>,
/// Security method/key management
pub security: String,
/// SSID of the wireless network
pub ssid: String,
/// Wireless network mode
pub mode: String,
/// Frequency band of the wireless network
#[serde(skip_serializing_if = "Option::is_none")]
pub band: Option<String>,
/// Wireless channel of the wireless network
#[serde(skip_serializing_if = "is_zero", default)]
pub channel: u32,
/// Only allow connection to this mac address
#[serde(skip_serializing_if = "Option::is_none")]
pub bssid: Option<String>,
/// Indicates that the wireless network is not broadcasting its SSID
#[serde(skip_serializing_if = "std::ops::Not::not", default)]
pub hidden: bool,
/// A list of group/broadcast encryption algorithms
#[serde(skip_serializing_if = "Vec::is_empty")]
pub group_algorithms: Vec<String>,
/// A list of pairwise encryption algorithms
#[serde(skip_serializing_if = "Vec::is_empty")]
pub pairwise_algorithms: Vec<String>,
/// A list of allowed WPA protocol versions
#[serde(skip_serializing_if = "Vec::is_empty")]
pub wpa_protocol_versions: Vec<String>,
/// Indicates whether Protected Management Frames must be enabled for the connection
#[serde(skip_serializing_if = "is_zero", default)]
pub pmf: i32,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
Expand All @@ -65,6 +95,7 @@ impl Default for BondSettings {

/// IEEE 802.1x (EAP) settings
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct IEEE8021XSettings {
/// List of EAP methods used
#[serde(skip_serializing_if = "Vec::is_empty", default)]
Expand Down Expand Up @@ -154,8 +185,8 @@ pub struct NetworkConnection {
pub ieee_8021x: Option<IEEE8021XSettings>,
}

fn is_zero(u: &u32) -> bool {
*u == 0
fn is_zero<T: PartialEq + From<u16>>(u: &T) -> bool {
*u == T::from(0)
}

impl NetworkConnection {
Expand Down
10 changes: 10 additions & 0 deletions rust/agama-server/src/network/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ pub enum NetworkStateError {
InvalidEAPMethod(String),
#[error("Invalid phase2 authentication method: '{0}'")]
InvalidPhase2AuthMethod(String),
#[error("Invalid group algorithm: '{0}'")]
InvalidGroupAlgorithm(String),
#[error("Invalid pairwise algorithm: '{0}'")]
InvalidPairwiseAlgorithm(String),
#[error("Invalid WPA protocol version: '{0}'")]
InvalidWPAProtocolVersion(String),
#[error("Invalid wireless band: '{0}'")]
InvalidWirelessBand(String),
#[error("Invalid bssid: '{0}'")]
InvalidBssid(String),
}

impl From<NetworkStateError> for zbus::fdo::Error {
Expand Down
Loading