@@ -14,6 +14,7 @@ use rs_matter::transport::network::NoNetwork;
14
14
use rs_matter:: utils:: init:: { init, Init } ;
15
15
use rs_matter:: utils:: select:: Coalesce ;
16
16
17
+ use crate :: mdns:: Mdns ;
17
18
use crate :: nal:: NetStack ;
18
19
use crate :: network:: { Embedding , Network } ;
19
20
use crate :: persist:: { KvBlobStore , SharedKvBlobStore } ;
@@ -64,23 +65,25 @@ pub type EthMatterStack<'a, E = ()> = MatterStack<'a, Eth<E>>;
64
65
/// A trait representing a task that needs access to the operational Ethernet interface
65
66
/// (Network stack and Netif) to perform its work.
66
67
pub trait EthernetTask {
67
- /// Run the task with the given network stack and network interface
68
- async fn run < S , N > ( & mut self , net_stack : S , netif : N ) -> Result < ( ) , Error >
68
+ /// Run the task with the given network stack, network interface and mDNS
69
+ async fn run < S , N , M > ( & mut self , net_stack : S , netif : N , mdns : M ) -> Result < ( ) , Error >
69
70
where
70
71
S : NetStack ,
71
- N : NetifDiag + NetChangeNotif ;
72
+ N : NetifDiag + NetChangeNotif ,
73
+ M : Mdns ;
72
74
}
73
75
74
76
impl < T > EthernetTask for & mut T
75
77
where
76
78
T : EthernetTask ,
77
79
{
78
- async fn run < S , N > ( & mut self , net_stack : S , netif : N ) -> Result < ( ) , Error >
80
+ async fn run < S , N , M > ( & mut self , net_stack : S , netif : N , mdns : M ) -> Result < ( ) , Error >
79
81
where
80
82
S : NetStack ,
81
83
N : NetifDiag + NetChangeNotif ,
84
+ M : Mdns ,
82
85
{
83
- ( * self ) . run ( net_stack, netif) . await
86
+ ( * self ) . run ( net_stack, netif, mdns ) . await
84
87
}
85
88
}
86
89
@@ -106,28 +109,30 @@ where
106
109
107
110
/// A utility type for running an ethernet task with a pre-existing ethernet interface
108
111
/// rather than bringing up / tearing down the ethernet interface for the task.
109
- pub struct PreexistingEthernet < S , N > {
112
+ pub struct PreexistingEthernet < S , N , M > {
110
113
stack : S ,
111
114
netif : N ,
115
+ mdns : M ,
112
116
}
113
117
114
- impl < S , N > PreexistingEthernet < S , N > {
115
- /// Create a new `PreexistingEthernet` instance with the given network interface and UDP stack.
116
- pub const fn new ( stack : S , netif : N ) -> Self {
117
- Self { stack, netif }
118
+ impl < S , N , M > PreexistingEthernet < S , N , M > {
119
+ /// Create a new `PreexistingEthernet` instance with the given network interface, UDP stack and mDNS .
120
+ pub const fn new ( stack : S , netif : N , mdns : M ) -> Self {
121
+ Self { stack, netif, mdns }
118
122
}
119
123
}
120
124
121
- impl < S , N > Ethernet for PreexistingEthernet < S , N >
125
+ impl < S , N , M > Ethernet for PreexistingEthernet < S , N , M >
122
126
where
123
127
S : NetStack ,
124
128
N : NetifDiag + NetChangeNotif ,
129
+ M : Mdns ,
125
130
{
126
131
async fn run < T > ( & mut self , mut task : T ) -> Result < ( ) , Error >
127
132
where
128
133
T : EthernetTask ,
129
134
{
130
- task. run ( & self . stack , & self . netif ) . await
135
+ task. run ( & self . stack , & self . netif , & mut self . mdns ) . await
131
136
}
132
137
}
133
138
@@ -172,26 +177,29 @@ where
172
177
/// Parameters:
173
178
/// - `netif` - a user-provided `Netif` implementation for the Ethernet network
174
179
/// - `net_stack` - a user-provided network stack implementation
180
+ /// - `mdns` - a user-provided mDNS implementation
175
181
/// - `persist` - a user-provided `Persist` implementation
176
182
/// - `handler` - a user-provided DM handler implementation
177
183
/// - `user` - a user-provided future that will be polled only when the netif interface is up
178
- pub async fn run_preex < U , N , S , H , X > (
184
+ pub async fn run_preex < U , N , M , S , H , X > (
179
185
& self ,
180
186
net_stack : U ,
181
187
netif : N ,
188
+ mdns : M ,
182
189
store : & SharedKvBlobStore < ' _ , S > ,
183
190
handler : H ,
184
191
user : X ,
185
192
) -> Result < ( ) , Error >
186
193
where
187
194
U : NetStack ,
188
195
N : NetifDiag + NetChangeNotif ,
196
+ M : Mdns ,
189
197
S : KvBlobStore ,
190
198
H : AsyncHandler + AsyncMetadata ,
191
199
X : UserTask ,
192
200
{
193
201
self . run (
194
- PreexistingEthernet :: new ( net_stack, netif) ,
202
+ PreexistingEthernet :: new ( net_stack, netif, mdns ) ,
195
203
store,
196
204
handler,
197
205
user,
@@ -261,16 +269,18 @@ where
261
269
H : AsyncMetadata + AsyncHandler ,
262
270
X : UserTask ,
263
271
{
264
- async fn run < S , C > ( & mut self , net_stack : S , netif : C ) -> Result < ( ) , Error >
272
+ async fn run < S , C , M > ( & mut self , net_stack : S , netif : C , mut mdns : M ) -> Result < ( ) , Error >
265
273
where
266
274
S : NetStack ,
267
275
C : NetifDiag + NetChangeNotif ,
276
+ M : Mdns ,
268
277
{
269
278
info ! ( "Ethernet driver started" ) ;
270
279
271
280
let mut net_task = pin ! ( self . 0 . run_oper_net(
272
281
& net_stack,
273
282
& netif,
283
+ & mut mdns,
274
284
core:: future:: pending( ) ,
275
285
Option :: <( NoNetwork , NoNetwork ) >:: None ,
276
286
) ) ;
0 commit comments