@@ -88,6 +88,33 @@ pub struct FrameFiltering {
88
88
}
89
89
90
90
impl 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
+
91
118
fn configure ( & self , eth_mac : & ETHERNET_MAC ) {
92
119
let FrameFiltering {
93
120
address,
@@ -112,7 +139,7 @@ impl FrameFiltering {
112
139
let empty_vec = Vec :: new ( ) ;
113
140
114
141
let ( saf, saif, source_addrs) = match & source_address_filter {
115
- SourceAddressFiltering :: PassAll => ( false , false , & empty_vec) ,
142
+ SourceAddressFiltering :: Ignore => ( false , false , & empty_vec) ,
116
143
SourceAddressFiltering :: Normal ( addrs) => ( true , false , addrs) ,
117
144
SourceAddressFiltering :: Inverse ( addrs) => ( true , true , addrs) ,
118
145
} ;
@@ -243,6 +270,13 @@ pub struct MacAddressFilter {
243
270
pub mask : MacAddressFilterMask ,
244
271
}
245
272
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
+
246
280
bitflags:: bitflags! {
247
281
/// A mask to be applied when comparing a [`MacAddressFilter`]
248
282
/// to an incoming address.
0 commit comments