Link layer address filter¶
Module for filtering (black- or white-listing) link layer addresses.
This module is used as a base for filtering link layer addresses. It allows to be (globally) configured in either blacklist or in whitelist mode. This configuration is done via RIOTs module system, for whitelist mode simply include the module L2FILTER_WHITELIST
, for blacklist mode include L2FILTER_BLACKLIST
.
The actual memory for the filter lists should be allocated for every network device. This is done centrally in netdev_t type.
-
int
l2filter_add
(l2filter_t * list, const void * addr,msp430_types.h::size_t
addr_len)¶ Add an entry to a devices filter list.
Parameters
list: pointer to the filter list addr: address to be added to list addr_len: size of addr
[in byte]Return values
- 0 on success
- -ENOMEM if no empty slot left in list
-
int
l2filter_rm
(l2filter_t * list, const void * addr,msp430_types.h::size_t
addr_len)¶ Remove an entry from the given filter list.
Parameters
list: pointer to the filter list addr: address to remove from the list addr_len: length of addr
[in byte]Return values
- 0 on success
- -ENOENT if
addr
was not found inlist
-
bool
l2filter_pass
(const l2filter_t * list, const void * addr,msp430_types.h::size_t
addr_len)¶ Check if the given address passes the set filters.
Independent if the l2filter module is used in blacklist or in whitelist mode, this function returns whether the given address passes the filter. In whitelist mode, this means that the given address has to be in the list, in blacklist mode this means that the given address is not in the list.
Parameters
list: list with black-/whitelisted addresses addr: address to check against the entries in list
addr_len: length of addr
[in byte]Return values
- in whitelist mode: true if
addr
is inlist
- in whitelist mode: false if
addr
is not inlist
- in blacklist mode: true if
addr
is not inlist
- in blacklist mode: false if
addr
is inlist
- in whitelist mode: true if
-
L2FILTER_ADDR_MAXLEN
¶ Maximal length of addresses that can be stored in the filter list.
1
(8U)
-
L2FILTER_LISTSIZE
¶ Number of slots in each filter list (filter entries per device)
1
(8U)
-
struct
l2filter_t
¶ Filter list entries.
The filter list supports address entries with differing length. This is useful e.g. for IEEE802.15.4, where the list can store short and long addresses at the same time.
-
uint8_t
addr
()¶ link layer address
-
msp430_types.h::size_t
addr_len
¶ address length in byte
-
uint8_t