Check that you are not present in trail twice
[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  * @param cfg configuration handle
37  * @param my_id my peer id
38  */
39 void
40 GST_blacklist_start (struct GNUNET_SERVER_Handle *server,
41                                                                                  const struct GNUNET_CONFIGURATION_Handle *cfg,
42                                                                                  const struct GNUNET_PeerIdentity *my_id);
43
44
45 /**
46  * Stop blacklist subsystem.
47  */
48 void
49 GST_blacklist_stop (void);
50
51
52 /**
53  * Initialize a blacklisting client.  We got a blacklist-init
54  * message from this client, add him to the list of clients
55  * to query for blacklisting.
56  *
57  * @param cls unused
58  * @param client the client
59  * @param message the blacklist-init message that was sent
60  */
61 void
62 GST_blacklist_handle_init (void *cls, struct GNUNET_SERVER_Client *client,
63                            const struct GNUNET_MessageHeader *message);
64
65
66 /**
67  * A blacklisting client has sent us reply. Process it.
68  *
69  * @param cls unused
70  * @param client the client
71  * @param message the blacklist-init message that was sent
72  */
73 void
74 GST_blacklist_handle_reply (void *cls, struct GNUNET_SERVER_Client *client,
75                             const struct GNUNET_MessageHeader *message);
76
77
78 /**
79  * Add the given peer to the blacklist (for the given transport).
80  *
81  * @param peer peer to blacklist
82  * @param transport_name transport to blacklist for this peer, NULL for all
83  */
84 void
85 GST_blacklist_add_peer (const struct GNUNET_PeerIdentity *peer,
86                         const char *transport_name);
87
88
89 /**
90  * Handle to an active blacklist check.
91  */
92 struct GST_BlacklistCheck;
93
94
95 /**
96  * Continuation called from a blacklist test.
97  *
98  * @param cls closure
99  * @param peer identity of peer that was tested
100  * @param result GNUNET_OK if the connection is allowed,
101  *               GNUNET_NO if not
102  */
103 typedef void (*GST_BlacklistTestContinuation) (void *cls,
104                                                const struct GNUNET_PeerIdentity
105                                                * peer, int result);
106
107
108 /**
109  * Test if a peer/transport combination is blacklisted.
110  *
111  * @param peer the identity of the peer to test
112  * @param transport_name name of the transport to test, never NULL
113  * @param cont function to call with result
114  * @param cont_cls closure for 'cont'
115  * @return handle to the blacklist check, NULL if the decision
116  *        was made instantly and 'cont' was already called
117  */
118 struct GST_BlacklistCheck *
119 GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer,
120                             const char *transport_name,
121                             GST_BlacklistTestContinuation cont, void *cont_cls);
122
123
124 /**
125  * Cancel a blacklist check.
126  *
127  * @param bc check to cancel
128  */
129 void
130 GST_blacklist_test_cancel (struct GST_BlacklistCheck *bc);
131
132 #endif
133 /* end of file gnunet-service-transport_blacklist.h */