@@ -90,7 +90,7 @@ pub struct FrameFiltering {
9090impl FrameFiltering {
9191 /// Create a new basic [`FrameFiltering`] that:
9292 /// * Does not filter out frames destined for `station_addr` or an address
93- /// contained in `extra_address.
93+ /// contained in `extra_address` .
9494 /// * Does not filter out multicast frames.
9595 /// * Does not filter out broadcast frames.
9696 /// * Filters out all control frames.
@@ -244,6 +244,25 @@ impl Mac {
244244 Self ( address)
245245 }
246246
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+
247266 /// Return bytes in a form that can be put into the high portion
248267 /// of a MAC address register by converting them to little-endian
249268 fn high ( & self ) -> u16 {
@@ -265,6 +284,23 @@ impl From<[u8; 6]> for Mac {
265284 }
266285}
267286
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+
268304/// A MAC address filter
269305#[ derive( Debug , Clone ) ]
270306
0 commit comments