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
9 changes: 9 additions & 0 deletions rust/agama-dbus-server/src/network/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ pub enum Connection {
Ethernet(EthernetConnection),
Wireless(WirelessConnection),
Loopback(LoopbackConnection),
Dummy(DummyConnection),
}

impl Connection {
Expand All @@ -236,6 +237,7 @@ impl Connection {
}),
DeviceType::Loopback => Connection::Loopback(LoopbackConnection { base }),
DeviceType::Ethernet => Connection::Ethernet(EthernetConnection { base }),
DeviceType::Dummy => Connection::Dummy(DummyConnection { base }),
}
}

Expand All @@ -246,6 +248,7 @@ impl Connection {
Connection::Ethernet(conn) => &conn.base,
Connection::Wireless(conn) => &conn.base,
Connection::Loopback(conn) => &conn.base,
Connection::Dummy(conn) => &conn.base,
}
}

Expand All @@ -254,6 +257,7 @@ impl Connection {
Connection::Ethernet(conn) => &mut conn.base,
Connection::Wireless(conn) => &mut conn.base,
Connection::Loopback(conn) => &mut conn.base,
Connection::Dummy(conn) => &mut conn.base,
}
}

Expand Down Expand Up @@ -479,6 +483,11 @@ pub struct LoopbackConnection {
pub base: BaseConnection,
}

#[derive(Debug, Default, PartialEq, Clone)]
pub struct DummyConnection {
pub base: BaseConnection,
}

#[derive(Debug, Default, PartialEq, Clone)]
pub struct WirelessConfig {
pub mode: WirelessMode,
Expand Down
9 changes: 9 additions & 0 deletions rust/agama-dbus-server/src/network/nm/dbus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const ETHERNET_KEY: &str = "802-3-ethernet";
const WIRELESS_KEY: &str = "802-11-wireless";
const WIRELESS_SECURITY_KEY: &str = "802-11-wireless-security";
const LOOPBACK_KEY: &str = "loopback";
const DUMMY_KEY: &str = "dummy";

/// Converts a connection struct into a HashMap that can be sent over D-Bus.
///
Expand All @@ -40,6 +41,10 @@ pub fn connection_to_dbus(conn: &Connection) -> NestedHash {
}
}

if let Connection::Dummy(_) = conn {
connection_dbus.insert("type", DUMMY_KEY.into());
}

result.insert("connection", connection_dbus);
result
}
Expand All @@ -57,6 +62,10 @@ pub fn connection_from_dbus(conn: OwnedNestedHash) -> Option<Connection> {
}));
}

if conn.get(DUMMY_KEY).is_some() {
return Some(Connection::Dummy(DummyConnection { base }));
};

if conn.get(LOOPBACK_KEY).is_some() {
return Some(Connection::Loopback(LoopbackConnection { base }));
};
Expand Down
1 change: 1 addition & 0 deletions rust/agama-dbus-server/src/network/nm/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl TryFrom<NmDeviceType> for DeviceType {
NmDeviceType(0) => Ok(DeviceType::Loopback),
NmDeviceType(1) => Ok(DeviceType::Ethernet),
NmDeviceType(2) => Ok(DeviceType::Wireless),
NmDeviceType(3) => Ok(DeviceType::Dummy),
NmDeviceType(_) => Err(NmError::UnsupportedDeviceType(value.into())),
}
}
Expand Down
2 changes: 2 additions & 0 deletions rust/agama-lib/src/network/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub enum DeviceType {
Loopback = 0,
Ethernet = 1,
Wireless = 2,
Dummy = 3,
}

#[derive(Debug, Error, PartialEq)]
Expand All @@ -43,6 +44,7 @@ impl TryFrom<u8> for DeviceType {
0 => Ok(DeviceType::Loopback),
1 => Ok(DeviceType::Ethernet),
2 => Ok(DeviceType::Wireless),
3 => Ok(DeviceType::Dummy),
_ => Err(InvalidDeviceType(value)),
}
}
Expand Down