Module for filtering (black- or white-listing) link layer addresses.
More...
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.
|
file | l2filter.h |
| Link layer address filter interface definition.
|
|
◆ l2filter_add()
int l2filter_add |
( |
l2filter_t * |
list, |
|
|
const void * |
addr, |
|
|
size_t |
addr_len |
|
) |
| |
Add an entry to a devices filter list.
- Parameters
-
[in,out] | list | pointer to the filter list |
[in] | addr | address to be added to list |
[in] | addr_len | size of addr [in byte] |
- Precondition
list
!= NULL
-
addr
!= NULL
-
addr_maxlen
<= CONFIG_L2FILTER_ADDR_MAXLEN
- Returns
- 0 on success
-
-ENOMEM if no empty slot left in list
◆ l2filter_pass()
bool l2filter_pass |
( |
const l2filter_t * |
list, |
|
|
const void * |
addr, |
|
|
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
-
[in] | list | list with black-/whitelisted addresses |
[in] | addr | address to check against the entries in list |
[in] | addr_len | length of addr [in byte] |
- Precondition
list
!= NULL
-
addr
!= NULL
-
addr_maxlen
<= CONFIG_L2FILTER_ADDR_MAXLEN
- Returns
- in whitelist mode: true if
addr
is in list
-
in whitelist mode: false if
addr
is not in list
-
in blacklist mode: true if
addr
is not in list
-
in blacklist mode: false if
addr
is in list
◆ l2filter_rm()
int l2filter_rm |
( |
l2filter_t * |
list, |
|
|
const void * |
addr, |
|
|
size_t |
addr_len |
|
) |
| |
Remove an entry from the given filter list.
- Parameters
-
[in,out] | list | pointer to the filter list |
[in] | addr | address to remove from the list |
[in] | addr_len | length of addr [in byte] |
- Precondition
list
!= NULL
-
addr
!= NULL
-
addr_maxlen
<= CONFIG_L2FILTER_ADDR_MAXLEN
- Returns
- 0 on success
-
-ENOENT if
addr
was not found in list