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 
46 #ifndef L2FILTER_ADDR_MAXLEN
47 #define L2FILTER_ADDR_MAXLEN (8U)
48 #endif
49 
53 #ifndef L2FILTER_LISTSIZE
54 #define L2FILTER_LISTSIZE (8U)
55 #endif
56 
64 typedef struct {
65  uint8_t addr[L2FILTER_ADDR_MAXLEN];
66  size_t addr_len;
67 } l2filter_t;
68 
83 int l2filter_add(l2filter_t *list, const void *addr, size_t addr_len);
84 
99 int l2filter_rm(l2filter_t *list, const void *addr, size_t addr_len);
100 
122 bool l2filter_pass(const l2filter_t *list, const void *addr, size_t addr_len);
123 
124 #ifdef __cplusplus
125 }
126 #endif
127 
128 #endif /* NET_L2FILTER_H */
129 
size_t addr_len
address length in byte
Definition: l2filter.h:66
int l2filter_add(l2filter_t *list, const void *addr, size_t addr_len)
Add an entry to a devices filter list.
Filter list entries.
Definition: l2filter.h:64
bool l2filter_pass(const l2filter_t *list, const void *addr, size_t addr_len)
Check if the given address passes the set filters.
int l2filter_rm(l2filter_t *list, const void *addr, size_t addr_len)
Remove an entry from the given filter list.
#define L2FILTER_ADDR_MAXLEN
Maximal length of addresses that can be stored in the filter list.
Definition: l2filter.h:47