@@ -90,7 +90,7 @@ pub struct FrameFiltering {
90
90
impl FrameFiltering {
91
91
/// Create a new basic [`FrameFiltering`] that:
92
92
/// * Does not filter out frames destined for `station_addr` or an address
93
- /// contained in `extra_address.
93
+ /// contained in `extra_address` .
94
94
/// * Does not filter out multicast frames.
95
95
/// * Does not filter out broadcast frames.
96
96
/// * Filters out all control frames.
@@ -244,6 +244,25 @@ impl Mac {
244
244
Self ( address)
245
245
}
246
246
247
+ /// Get the raw bytes of this MAC address.
248
+ pub fn raw ( & self ) -> & [ u8 ; 6 ] {
249
+ & self . 0
250
+ }
251
+ /// Returns `true` if this MAC is locally administred, i.e. it has the I/G bit set.
252
+ pub fn is_multicast ( & self ) -> bool {
253
+ ( self . 0 [ 0 ] & 0b1 ) == 0b1
254
+ }
255
+
256
+ /// Returns `true` if this MAC is locally administred, i.e. it has the U/L bit set.
257
+ pub fn is_locally_administred ( & self ) -> bool {
258
+ ( self . 0 [ 0 ] & 0b10 ) == 0b10
259
+ }
260
+
261
+ /// Returns `true` if this MAC is the broadcast address.
262
+ pub fn is_broadcast ( & self ) -> bool {
263
+ self . 0 . iter ( ) . all ( |v| v == & 0xFF )
264
+ }
265
+
247
266
/// Return bytes in a form that can be put into the high portion
248
267
/// of a MAC address register by converting them to little-endian
249
268
fn high ( & self ) -> u16 {
@@ -265,6 +284,23 @@ impl From<[u8; 6]> for Mac {
265
284
}
266
285
}
267
286
287
+ #[ cfg( feature = "defmt" ) ]
288
+ impl defmt:: Format for Mac {
289
+ fn format ( & self , fmt : defmt:: Formatter ) {
290
+ let addr = self . 0 ;
291
+ defmt:: write!(
292
+ fmt,
293
+ "{:02X}:{:02X}:{:02X}:{:02X}:{:02X}:{:02X}" ,
294
+ addr[ 0 ] ,
295
+ addr[ 1 ] ,
296
+ addr[ 2 ] ,
297
+ addr[ 3 ] ,
298
+ addr[ 4 ] ,
299
+ addr[ 5 ]
300
+ )
301
+ }
302
+ }
303
+
268
304
/// A MAC address filter
269
305
#[ derive( Debug , Clone ) ]
270
306
0 commit comments