l2filter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
31 #ifndef NET_L2FILTER_H
32 #define NET_L2FILTER_H
33 
34 #include <stddef.h>
35 #include <stdint.h>
36 #include <stdbool.h>
37 #include <errno.h>
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
51 #ifndef CONFIG_L2FILTER_ADDR_MAXLEN
52 #define CONFIG_L2FILTER_ADDR_MAXLEN (8U)
53 #endif
54 
58 #ifndef CONFIG_L2FILTER_LISTSIZE
59 #define CONFIG_L2FILTER_LISTSIZE (8U)
60 #endif
61 
70 typedef struct {
72  size_t addr_len;
73 } l2filter_t;
74 
89 int l2filter_add(l2filter_t *list, const void *addr, size_t addr_len);
90 
105 int l2filter_rm(l2filter_t *list, const void *addr, size_t addr_len);
106 
128 bool l2filter_pass(const l2filter_t *list, const void *addr, size_t addr_len);
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif /* NET_L2FILTER_H */
135 
l2filter_t
Filter list entries.
Definition: l2filter.h:70
l2filter_add
int l2filter_add(l2filter_t *list, const void *addr, size_t addr_len)
Add an entry to a devices filter 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.
l2filter_rm
int l2filter_rm(l2filter_t *list, const void *addr, size_t addr_len)
Remove an entry from the given filter list.
l2filter_t::addr_len
size_t addr_len
address length in byte
Definition: l2filter.h:72
errno.h
CONFIG_L2FILTER_ADDR_MAXLEN
#define CONFIG_L2FILTER_ADDR_MAXLEN
Maximal length of addresses that can be stored in the filter list.
Definition: l2filter.h:52