@@ -88,6 +88,33 @@ pub struct FrameFiltering {
8888}
8989
9090impl FrameFiltering {
91+ /// Create a new basic [`FrameFiltering`] that:
92+ /// * Does not filter out frames destined for `station_addr` or an address
93+ /// contained in `extra_address.
94+ /// * Does not filter out multicast frames.
95+ /// * Does not filter out broadcast frames.
96+ /// * Filters out all control frames.
97+ pub fn filter_destinations ( station_addr : Mac , extra_addresses : Vec < Mac , 3 > ) -> Self {
98+ let extra_addrs = extra_addresses
99+ . into_iter ( )
100+ . map ( |a| MacAddressFilter :: new ( a, MacAddressFilterMask :: empty ( ) ) )
101+ . collect ( ) ;
102+
103+ FrameFiltering {
104+ address : station_addr,
105+ destination_address_filter : DestinationAddressFiltering {
106+ perfect_filtering : PerfectDestinationAddressFiltering :: Normal ( extra_addrs) ,
107+ hash_table_filtering : false ,
108+ } ,
109+ source_address_filter : SourceAddressFiltering :: Ignore ,
110+ multicast_address_filter : MulticastAddressFiltering :: PassAll ,
111+ control_filter : ControlFrameFiltering :: BlockAll ,
112+ hash_table_value : HashTableValue :: new ( ) ,
113+ filter_broadcast : false ,
114+ receive_all : false ,
115+ }
116+ }
117+
91118 fn configure ( & self , eth_mac : & ETHERNET_MAC ) {
92119 let FrameFiltering {
93120 address,
@@ -112,7 +139,7 @@ impl FrameFiltering {
112139 let empty_vec = Vec :: new ( ) ;
113140
114141 let ( saf, saif, source_addrs) = match & source_address_filter {
115- SourceAddressFiltering :: PassAll => ( false , false , & empty_vec) ,
142+ SourceAddressFiltering :: Ignore => ( false , false , & empty_vec) ,
116143 SourceAddressFiltering :: Normal ( addrs) => ( true , false , addrs) ,
117144 SourceAddressFiltering :: Inverse ( addrs) => ( true , true , addrs) ,
118145 } ;
@@ -243,6 +270,13 @@ pub struct MacAddressFilter {
243270 pub mask : MacAddressFilterMask ,
244271}
245272
273+ impl MacAddressFilter {
274+ /// Create a new MAC address filter.
275+ pub fn new ( address : Mac , mask : MacAddressFilterMask ) -> Self {
276+ Self { address, mask }
277+ }
278+ }
279+
246280bitflags:: bitflags! {
247281 /// A mask to be applied when comparing a [`MacAddressFilter`]
248282 /// to an incoming address.
0 commit comments