@@ -23,8 +23,16 @@ use serde::{Deserialize, Serialize};
23
23
use crate :: broker:: { BrokerBuilder , Topic } ;
24
24
use crate :: led:: BlinkPattern ;
25
25
26
+ // Macro use makes these modules quite heavy, so we keep them commented
27
+ // out until they are actually used
28
+ //mod active_connection;
26
29
mod devices;
27
- mod hostname;
30
+ //mod dhcp4_config;
31
+ //mod dhcp6_config;
32
+ mod ipv4_config;
33
+ //mod ipv6_config;
34
+ mod manager;
35
+ //mod settings;
28
36
29
37
// All of the following includes are not used in demo_mode.
30
38
// Put them inside a mod so we do not have to decorate each one with
@@ -39,14 +47,15 @@ mod optional_includes {
39
47
pub ( super ) use std:: time:: Duration ;
40
48
pub ( super ) use zbus:: { Connection , PropertyStream } ;
41
49
pub ( super ) use zvariant:: { ObjectPath , OwnedObjectPath } ;
50
+
51
+ pub ( super ) use super :: devices:: { DeviceProxy , WiredProxy } ;
52
+ pub ( super ) use super :: ipv4_config:: IP4ConfigProxy ;
53
+ pub ( super ) use super :: manager:: NetworkManagerProxy ;
42
54
}
43
55
44
56
#[ cfg( not( feature = "demo_mode" ) ) ]
45
57
use optional_includes:: * ;
46
58
47
- #[ allow( clippy:: module_inception) ]
48
- mod networkmanager;
49
-
50
59
#[ derive( Serialize , Deserialize , Debug , Clone ) ]
51
60
pub struct LinkInfo {
52
61
pub speed : u32 ,
@@ -55,14 +64,11 @@ pub struct LinkInfo {
55
64
56
65
#[ cfg( not( feature = "demo_mode" ) ) ]
57
66
async fn path_from_interface ( con : & Connection , interface : & str ) -> Result < OwnedObjectPath > {
58
- let proxy = networkmanager :: NetworkManagerProxy :: new ( con) . await ?;
67
+ let proxy = NetworkManagerProxy :: new ( con) . await ?;
59
68
let device_paths = proxy. get_devices ( ) . await ?;
60
69
61
70
for path in device_paths {
62
- let device_proxy = devices:: DeviceProxy :: builder ( con)
63
- . path ( & path) ?
64
- . build ( )
65
- . await ?;
71
+ let device_proxy = DeviceProxy :: builder ( con) . path ( & path) ?. build ( ) . await ?;
66
72
67
73
let interface_name = device_proxy. interface ( ) . await ?; // name
68
74
@@ -76,10 +82,7 @@ async fn path_from_interface(con: &Connection, interface: &str) -> Result<OwnedO
76
82
77
83
#[ cfg( not( feature = "demo_mode" ) ) ]
78
84
async fn get_link_info ( con : & Connection , path : & str ) -> Result < LinkInfo > {
79
- let eth_proxy = devices:: WiredProxy :: builder ( con)
80
- . path ( path) ?
81
- . build ( )
82
- . await ?;
85
+ let eth_proxy = WiredProxy :: builder ( con) . path ( path) ?. build ( ) . await ?;
83
86
84
87
let speed = eth_proxy. speed ( ) . await ?;
85
88
let carrier = eth_proxy. carrier ( ) . await ?;
95
98
P : TryInto < ObjectPath < ' a > > ,
96
99
P :: Error : Into < zbus:: Error > ,
97
100
{
98
- let ip_4_proxy = devices:: ip4:: IP4ConfigProxy :: builder ( con)
99
- . path ( path) ?
100
- . build ( )
101
- . await ?;
101
+ let ip_4_proxy = IP4ConfigProxy :: builder ( con) . path ( path) ?. build ( ) . await ?;
102
102
103
- let ip_address = ip_4_proxy. address_data2 ( ) . await ?;
103
+ let ip_address = ip_4_proxy. address_data ( ) . await ?;
104
104
trace ! ( "get IPv4: {:?}" , ip_address) ;
105
105
let ip_address = ip_address
106
106
. get ( 0 )
@@ -128,7 +128,7 @@ impl<'a> LinkStream<'a> {
128
128
. as_str ( )
129
129
. to_string ( ) ;
130
130
131
- let eth_proxy = devices :: WiredProxy :: builder ( & con)
131
+ let eth_proxy = WiredProxy :: builder ( & con)
132
132
. path ( path. clone ( ) ) ?
133
133
. build ( )
134
134
. await ?;
@@ -192,7 +192,7 @@ impl<'a> IpStream<'a> {
192
192
. as_str ( )
193
193
. to_string ( ) ;
194
194
195
- let device_proxy = devices :: DeviceProxy :: builder ( & con)
195
+ let device_proxy = DeviceProxy :: builder ( & con)
196
196
. path ( path. clone ( ) ) ?
197
197
. build ( )
198
198
. await ?;
@@ -208,7 +208,7 @@ impl<'a> IpStream<'a> {
208
208
}
209
209
210
210
pub async fn now ( & mut self , con : & Connection ) -> Result < Vec < String > > {
211
- let device_proxy = devices :: DeviceProxy :: builder ( con)
211
+ let device_proxy = DeviceProxy :: builder ( con)
212
212
. path ( self . path . as_str ( ) ) ?
213
213
. build ( )
214
214
. await ?;
@@ -237,7 +237,6 @@ impl<'a> IpStream<'a> {
237
237
}
238
238
239
239
pub struct Network {
240
- pub hostname : Arc < Topic < String > > ,
241
240
pub bridge_interface : Arc < Topic < Vec < String > > > ,
242
241
pub dut_interface : Arc < Topic < LinkInfo > > ,
243
242
pub uplink_interface : Arc < Topic < LinkInfo > > ,
@@ -246,7 +245,6 @@ pub struct Network {
246
245
impl Network {
247
246
fn setup_topics ( bb : & mut BrokerBuilder ) -> Self {
248
247
Self {
249
- hostname : bb. topic_ro ( "/v1/tac/network/hostname" , None ) ,
250
248
bridge_interface : bb. topic_ro ( "/v1/tac/network/interface/tac-bridge" , None ) ,
251
249
dut_interface : bb. topic_ro ( "/v1/tac/network/interface/dut" , None ) ,
252
250
uplink_interface : bb. topic_ro ( "/v1/tac/network/interface/uplink" , None ) ,
@@ -262,7 +260,6 @@ impl Network {
262
260
) -> Self {
263
261
let this = Self :: setup_topics ( bb) ;
264
262
265
- this. hostname . set ( "lxatac" . to_string ( ) ) ;
266
263
this. bridge_interface . set ( vec ! [ String :: from( "192.168.1.1" ) ] ) ;
267
264
this. dut_interface . set ( LinkInfo {
268
265
speed : 0 ,
@@ -285,26 +282,6 @@ impl Network {
285
282
) -> Self {
286
283
let this = Self :: setup_topics ( bb) ;
287
284
288
- {
289
- let conn = conn. clone ( ) ;
290
- let hostname_topic = this. hostname . clone ( ) ;
291
- async_std:: task:: spawn ( async move {
292
- let proxy = hostname:: HostnameProxy :: new ( & conn) . await . unwrap ( ) ;
293
-
294
- let mut stream = proxy. receive_hostname_changed ( ) . await ;
295
-
296
- if let Ok ( h) = proxy. hostname ( ) . await {
297
- hostname_topic. set ( h) ;
298
- }
299
-
300
- while let Some ( v) = stream. next ( ) . await {
301
- if let Ok ( h) = v. get ( ) . await {
302
- hostname_topic. set ( h) ;
303
- }
304
- }
305
- } ) ;
306
- }
307
-
308
285
{
309
286
let conn = conn. clone ( ) ;
310
287
let dut_interface = this. dut_interface . clone ( ) ;
0 commit comments