Link layer address filter

Module for filtering (black- or white-listing) link layer addresses. More...

Detailed Description

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.

Modules

 Link layer address filter compile configurations
 

Files

file  l2filter.h
 Link layer address filter interface definition.
 

Data Structures

struct  l2filter_t
 Filter list entries. More...
 

Functions

int l2filter_add (l2filter_t *list, const void *addr, size_t addr_len)
 Add an entry to a devices filter list. More...
 
int l2filter_rm (l2filter_t *list, const void *addr, size_t addr_len)
 Remove an entry from the given filter list. More...
 
bool l2filter_pass (const l2filter_t *list, const void *addr, size_t addr_len)
 Check if the given address passes the set filters. More...
 

Function Documentation

◆ 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]listpointer to the filter list
[in]addraddress to be added to list
[in]addr_lensize 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]listlist with black-/whitelisted addresses
[in]addraddress to check against the entries in list
[in]addr_lenlength 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]listpointer to the filter list
[in]addraddress to remove from the list
[in]addr_lenlength 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