Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wireless hidden property to network model #1024

Merged
merged 2 commits into from
Jan 29, 2024
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
1 change: 1 addition & 0 deletions rust/agama-dbus-server/src/network/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ pub struct WirelessConfig {
pub channel: Option<u32>,
pub bssid: Option<macaddr::MacAddr6>,
pub wep_security: Option<WEPSecurity>,
pub hidden: bool,
}

impl TryFrom<ConnectionConfig> for WirelessConfig {
Expand Down
10 changes: 10 additions & 0 deletions rust/agama-dbus-server/src/network/nm/dbus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ fn wireless_config_to_dbus<'a>(
("mode", Value::new(config.mode.to_string())),
("ssid", Value::new(config.ssid.to_vec())),
("assigned-mac-address", Value::new(mac_address.to_string())),
("hidden", Value::new(config.hidden)),
]);

if let Some(band) = &config.band {
Expand Down Expand Up @@ -726,6 +727,9 @@ fn wireless_config_from_dbus(conn: &OwnedNestedHash) -> Option<WirelessConfig> {
*bssid.get(5)?,
));
}
if let Some(hidden) = wireless.get("hidden") {
wireless_config.hidden = *hidden.downcast_ref::<bool>()?;
}

if let Some(security) = conn.get(WIRELESS_SECURITY_KEY) {
let key_mgmt: &str = security.get("key-mgmt")?.downcast_ref()?;
Expand Down Expand Up @@ -1001,6 +1005,7 @@ mod test {
"bssid".to_string(),
Value::new(vec![18_u8, 52_u8, 86_u8, 120_u8, 154_u8, 188_u8]).to_owned(),
),
("hidden".to_string(), Value::new(false).to_owned()),
]);

let security_section = HashMap::from([
Expand Down Expand Up @@ -1032,6 +1037,7 @@ mod test {
wireless.bssid,
Some(macaddr::MacAddr6::from_str("12:34:56:78:9A:BC").unwrap())
);
assert!(!wireless.hidden);
let wep_security = wireless.wep_security.as_ref().unwrap();
assert_eq!(wep_security.wep_key_type, WEPKeyType::Key);
assert_eq!(wep_security.auth_alg, WEPAuthAlg::Open);
Expand Down Expand Up @@ -1082,6 +1088,7 @@ mod test {
"hello".to_string(),
],
}),
hidden: true,
..Default::default()
};
let mut wireless = build_base_connection();
Expand Down Expand Up @@ -1120,6 +1127,9 @@ mod test {
.collect();
assert_eq!(bssid, vec![18, 52, 86, 120, 154, 188]);

let hidden: bool = *wireless.get("hidden").unwrap().downcast_ref().unwrap();
assert!(hidden);

let security = wireless_dbus.get(WIRELESS_SECURITY_KEY).unwrap();
let key_mgmt: &str = security.get("key-mgmt").unwrap().downcast_ref().unwrap();
assert_eq!(key_mgmt, "wpa-psk");
Expand Down
6 changes: 6 additions & 0 deletions rust/package/agama-cli.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Jan 29 15:37:56 UTC 2024 - Jorik Cronenberg <[email protected]>

- Add hidden property for wireless in network model
(gh#openSUSE/agama#1024).

-------------------------------------------------------------------
Mon Jan 29 10:22:49 UTC 2024 - Jorik Cronenberg <[email protected]>

Expand Down
Loading