]>
Commit | Line | Data |
---|---|---|
5e603aba MW |
1 | /* |
2 | * Copyright (C) 2011 Martin Willi | |
19ef2aec TB |
3 | * |
4 | * Copyright (C) secunet Security Networks AG | |
5e603aba MW |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2 of the License, or (at your | |
9 | * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 | * for more details. | |
15 | */ | |
16 | ||
17 | /** | |
18 | * @defgroup whitelist_listener whitelist_listener | |
19 | * @{ @ingroup whitelist | |
20 | */ | |
21 | ||
22 | #ifndef WHITELIST_LISTENER_H_ | |
23 | #define WHITELIST_LISTENER_H_ | |
24 | ||
25 | #include <bus/listeners/listener.h> | |
26 | ||
27 | typedef struct whitelist_listener_t whitelist_listener_t; | |
28 | ||
29 | /** | |
30 | * Listener checking connecting peer against a whitelist. | |
31 | */ | |
32 | struct whitelist_listener_t { | |
33 | ||
34 | /** | |
35 | * Implements listener_t interface. | |
36 | */ | |
37 | listener_t listener; | |
38 | ||
39 | /** | |
40 | * Add a peer identity to the whitelist. | |
41 | * | |
42 | * @param id identity to whitelist | |
43 | */ | |
44 | void (*add)(whitelist_listener_t *this, identification_t *id); | |
45 | ||
46 | /** | |
47 | * Remove a peer identity from the whitelist. | |
48 | * | |
49 | * @param id identity to remove from whitelist | |
50 | */ | |
51 | void (*remove)(whitelist_listener_t *this, identification_t *id); | |
52 | ||
53 | /** | |
54 | * Create an enumerator over whitelisted peer identities. | |
55 | * | |
56 | * The enumerator read-locks the whitelist, do not call add/remove while | |
57 | * it is alive. | |
58 | * | |
59 | * @return enumerator over identification_t* | |
60 | */ | |
61 | enumerator_t* (*create_enumerator)(whitelist_listener_t *this); | |
62 | ||
63 | /** | |
64 | * Flush identities from whitelist matching id. | |
65 | * | |
66 | * @param id id to match | |
67 | */ | |
68 | void (*flush)(whitelist_listener_t *this, identification_t *id); | |
69 | ||
c236b214 MW |
70 | /** |
71 | * Enable/Disable whitelist checking. | |
72 | * | |
73 | * @param enable TRUE to enable, FALSE to disable | |
74 | */ | |
75 | void (*set_active)(whitelist_listener_t *this, bool enable); | |
76 | ||
5e603aba MW |
77 | /** |
78 | * Destroy a whitelist_listener_t. | |
79 | */ | |
80 | void (*destroy)(whitelist_listener_t *this); | |
81 | }; | |
82 | ||
83 | /** | |
84 | * Create a whitelist_listener instance. | |
85 | */ | |
86 | whitelist_listener_t *whitelist_listener_create(); | |
87 | ||
88 | #endif /** WHITELIST_LISTENER_H_ @}*/ |