indentation
[oweals/gnunet.git] / src / transport / gnunet-service-transport_blacklist.h
1 /*
2      This file is part of GNUnet.
3      (C) 2010,2011 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file transport/gnunet-service-transport_blacklist.h
23  * @brief blacklisting API
24  * @author Christian Grothoff
25  */
26 #ifndef GNUNET_SERVICE_TRANSPORT_BLACKLIST_H
27 #define GNUNET_SERVICE_TRANSPORT_BLACKLIST_H
28
29 #include "gnunet_statistics_service.h"
30 #include "gnunet_util_lib.h"
31
32 /**
33  * Start blacklist subsystem.
34  *
35  * @param server server used to accept clients from
36  */
37 void GST_blacklist_start (struct GNUNET_SERVER_Handle *server);
38
39
40 /**
41  * Stop blacklist subsystem.
42  */
43 void GST_blacklist_stop (void);
44
45
46 /**
47  * Initialize a blacklisting client.  We got a blacklist-init
48  * message from this client, add him to the list of clients
49  * to query for blacklisting.
50  *
51  * @param cls unused
52  * @param client the client
53  * @param message the blacklist-init message that was sent
54  */
55 void
56 GST_blacklist_handle_init (void *cls,
57                            struct GNUNET_SERVER_Client *client,
58                            const struct GNUNET_MessageHeader *message);
59
60 /**
61  * A blacklisting client has sent us reply. Process it.
62  *
63  * @param cls unused
64  * @param client the client
65  * @param message the blacklist-init message that was sent
66  */
67 void
68 GST_blacklist_handle_reply (void *cls,
69                             struct GNUNET_SERVER_Client *client,
70                             const struct GNUNET_MessageHeader *message);
71
72 /**
73  * Add the given peer to the blacklist (for the given transport).
74  * 
75  * @param peer peer to blacklist
76  * @param transport_name transport to blacklist for this peer, NULL for all
77  */
78 void
79 GST_blacklist_add_peer (const struct GNUNET_PeerIdentity *peer,
80                         const char *transport_name);
81
82
83 /**
84  * Handle to an active blacklist check.
85  */
86 struct GST_BlacklistCheck;
87
88
89 /**
90  * Continuation called from a blacklist test.
91  *
92  * @param cls closure
93  * @param peer identity of peer that was tested
94  * @param result GNUNET_OK if the connection is allowed,
95  *               GNUNET_NO if not
96  */
97 typedef void (*GST_BlacklistTestContinuation) (void *cls,
98                                                const struct GNUNET_PeerIdentity
99                                                * peer, int result);
100
101
102 /**
103  * Test if a peer/transport combination is blacklisted.
104  *
105  * @param peer the identity of the peer to test
106  * @param transport_name name of the transport to test, never NULL
107  * @param cont function to call with result
108  * @param cont_cls closure for 'cont'
109  * @return handle to the blacklist check, NULL if the decision
110  *        was made instantly and 'cont' was already called
111  */
112 struct GST_BlacklistCheck *GST_blacklist_test_allowed (const struct
113                                                        GNUNET_PeerIdentity
114                                                        *peer,
115                                                        const char
116                                                        *transport_name,
117                                                        GST_BlacklistTestContinuation
118                                                        cont, void *cont_cls);
119
120
121 /**
122  * Cancel a blacklist check.
123  * 
124  * @param bc check to cancel
125  */
126 void GST_blacklist_test_cancel (struct GST_BlacklistCheck *bc);
127
128 #endif
129 /* end of file gnunet-service-transport_blacklist.h */