diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-01-21 14:06:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-01-21 14:06:06 +0000 |
commit | 87b254030acd37b6714565c5ac2e803da743d777 (patch) | |
tree | c542002dffca21eeb335b278d377fa22bef33cf7 | |
parent | c13dfb403b26b07486953500103bccf9132654d6 (diff) | |
download | gnunet-87b254030acd37b6714565c5ac2e803da743d777.tar.gz gnunet-87b254030acd37b6714565c5ac2e803da743d777.zip |
stuff
-rw-r--r-- | src/core/core.h | 55 | ||||
-rw-r--r-- | src/core/core_api_peer_get_info.c | 19 | ||||
-rw-r--r-- | src/include/gnunet_core_service.h | 66 | ||||
-rw-r--r-- | src/include/gnunet_transport_service.h | 6 | ||||
-rw-r--r-- | src/transport/Makefile.am | 3 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_blacklist.c | 202 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_blacklist.h | 30 | ||||
-rw-r--r-- | src/transport/plugin_transport.h | 16 |
8 files changed, 337 insertions, 60 deletions
diff --git a/src/core/core.h b/src/core/core.h index 30130b84b..20c3ddc4b 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
@@ -112,6 +112,36 @@ struct ConnectNotifyMessage | |||
112 | struct GNUNET_MessageHeader header; | 112 | struct GNUNET_MessageHeader header; |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Distance to the peer. | ||
116 | */ | ||
117 | uint32_t distance GNUNET_PACKED; | ||
118 | |||
119 | /** | ||
120 | * Currently observed latency. | ||
121 | */ | ||
122 | struct GNUNET_TIME_RelativeNBO latency; | ||
123 | |||
124 | /** | ||
125 | * Identity of the connecting peer. | ||
126 | */ | ||
127 | struct GNUNET_PeerIdentity peer; | ||
128 | |||
129 | }; | ||
130 | |||
131 | |||
132 | |||
133 | /** | ||
134 | * Message sent by the service to clients to notify them | ||
135 | * about a peer disconnecting. | ||
136 | */ | ||
137 | struct DisconnectNotifyMessage | ||
138 | { | ||
139 | /** | ||
140 | * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT. | ||
141 | */ | ||
142 | struct GNUNET_MessageHeader header; | ||
143 | |||
144 | /** | ||
115 | * Always zero. | 145 | * Always zero. |
116 | */ | 146 | */ |
117 | uint32_t reserved GNUNET_PACKED; | 147 | uint32_t reserved GNUNET_PACKED; |
@@ -143,9 +173,14 @@ struct NotifyTrafficMessage | |||
143 | struct GNUNET_MessageHeader header; | 173 | struct GNUNET_MessageHeader header; |
144 | 174 | ||
145 | /** | 175 | /** |
146 | * Always zero. | 176 | * Distance to the peer. |
147 | */ | 177 | */ |
148 | uint32_t reserved GNUNET_PACKED; | 178 | uint32_t distance GNUNET_PACKED; |
179 | |||
180 | /** | ||
181 | * Currently observed latency. | ||
182 | */ | ||
183 | struct GNUNET_TIME_RelativeNBO latency; | ||
149 | 184 | ||
150 | /** | 185 | /** |
151 | * Identity of the receiver or sender. | 186 | * Identity of the receiver or sender. |
@@ -230,12 +265,6 @@ struct ConfigurationInfoMessage | |||
230 | uint32_t bpm_out GNUNET_PACKED; | 265 | uint32_t bpm_out GNUNET_PACKED; |
231 | 266 | ||
232 | /** | 267 | /** |
233 | * Latest transport latency estimate for the peer. | ||
234 | * FOREVER if we have been disconnected. | ||
235 | */ | ||
236 | struct GNUNET_TIME_RelativeNBO latency; | ||
237 | |||
238 | /** | ||
239 | * Current traffic preference for the peer. | 268 | * Current traffic preference for the peer. |
240 | * 0 if we have been disconnected. | 269 | * 0 if we have been disconnected. |
241 | */ | 270 | */ |
@@ -280,11 +309,11 @@ struct SendMessage | |||
280 | 309 | ||
281 | 310 | ||
282 | /** | 311 | /** |
283 | * Client asking core to transmit a particular message to a particular | 312 | * Client asking core to connect to a particular target. There is no |
284 | * target. There is no response from the core to this type of request | 313 | * response from the core to this type of request (however, if an |
285 | * (however, if an actual connection is created or destroyed, be it | 314 | * actual connection is created or destroyed, be it because of this |
286 | * because of this type request or not, the core generally needs to | 315 | * type request or not, the core generally needs to notify the |
287 | * notify the clients). | 316 | * clients). |
288 | */ | 317 | */ |
289 | struct ConnectMessage | 318 | struct ConnectMessage |
290 | { | 319 | { |
diff --git a/src/core/core_api_peer_get_info.c b/src/core/core_api_peer_get_info.c index 23ae04f01..f6ce31110 100644 --- a/src/core/core_api_peer_get_info.c +++ b/src/core/core_api_peer_get_info.c | |||
@@ -88,7 +88,6 @@ receive_info (void *cls, | |||
88 | &cim->peer, | 88 | &cim->peer, |
89 | ntohl (cim->bpm_in), | 89 | ntohl (cim->bpm_in), |
90 | ntohl (cim->bpm_out), | 90 | ntohl (cim->bpm_out), |
91 | GNUNET_TIME_relative_ntoh (cim->latency), | ||
92 | ntohl (cim->reserved_amount), | 91 | ntohl (cim->reserved_amount), |
93 | GNUNET_ntohll (cim->preference)); | 92 | GNUNET_ntohll (cim->preference)); |
94 | GNUNET_CLIENT_disconnect (irc->client); | 93 | GNUNET_CLIENT_disconnect (irc->client); |
@@ -122,15 +121,15 @@ receive_info (void *cls, | |||
122 | * @return NULL on error | 121 | * @return NULL on error |
123 | */ | 122 | */ |
124 | struct GNUNET_CORE_InformationRequestContext * | 123 | struct GNUNET_CORE_InformationRequestContext * |
125 | GNUNET_CORE_peer_get_info (struct GNUNET_SCHEDULER_Handle *sched, | 124 | GNUNET_CORE_peer_change_preference (struct GNUNET_SCHEDULER_Handle *sched, |
126 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 125 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
127 | const struct GNUNET_PeerIdentity *peer, | 126 | const struct GNUNET_PeerIdentity *peer, |
128 | struct GNUNET_TIME_Relative timeout, | 127 | struct GNUNET_TIME_Relative timeout, |
129 | uint32_t bpm_out, | 128 | uint32_t bpm_out, |
130 | int32_t amount, | 129 | int32_t amount, |
131 | uint64_t preference, | 130 | uint64_t preference, |
132 | GNUNET_CORE_PeerConfigurationInfoCallback info, | 131 | GNUNET_CORE_PeerConfigurationInfoCallback info, |
133 | void *info_cls) | 132 | void *info_cls) |
134 | { | 133 | { |
135 | struct GNUNET_CORE_InformationRequestContext *irc; | 134 | struct GNUNET_CORE_InformationRequestContext *irc; |
136 | struct RequestInfoMessage rim; | 135 | struct RequestInfoMessage rim; |
diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h index cffdf0a14..3ba4ef137 100644 --- a/src/include/gnunet_core_service.h +++ b/src/include/gnunet_core_service.h | |||
@@ -51,15 +51,30 @@ struct GNUNET_CORE_Handle; | |||
51 | 51 | ||
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Method called whenever a given peer either connects or | 54 | * Method called whenever a given peer either connects. |
55 | * disconnects (or list of connections was requested). | ||
56 | * | 55 | * |
57 | * @param cls closure | 56 | * @param cls closure |
58 | * @param peer peer identity this notification is about | 57 | * @param peer peer identity this notification is about |
58 | * @param latency reported latency of the connection with 'other' | ||
59 | * @param distance reported distance (DV) to 'other' | ||
59 | */ | 60 | */ |
60 | typedef void (*GNUNET_CORE_ClientEventHandler) (void *cls, | 61 | typedef void (*GNUNET_CORE_ConnectEventHandler) (void *cls, |
61 | const struct | 62 | const struct |
62 | GNUNET_PeerIdentity * peer); | 63 | GNUNET_PeerIdentity * peer, |
64 | struct GNUNET_TIME_Relative latency, | ||
65 | uint32_t distance); | ||
66 | |||
67 | |||
68 | |||
69 | /** | ||
70 | * Method called whenever a given peer either disconnects. | ||
71 | * | ||
72 | * @param cls closure | ||
73 | * @param peer peer identity this notification is about | ||
74 | */ | ||
75 | typedef void (*GNUNET_CORE_DisconnectEventHandler) (void *cls, | ||
76 | const struct | ||
77 | GNUNET_PeerIdentity * peer); | ||
63 | 78 | ||
64 | 79 | ||
65 | /** | 80 | /** |
@@ -70,6 +85,8 @@ typedef void (*GNUNET_CORE_ClientEventHandler) (void *cls, | |||
70 | * @param peer the other peer involved (sender or receiver, NULL | 85 | * @param peer the other peer involved (sender or receiver, NULL |
71 | * for loopback messages where we are both sender and receiver) | 86 | * for loopback messages where we are both sender and receiver) |
72 | * @param message the actual message | 87 | * @param message the actual message |
88 | * @param latency reported latency of the connection with 'other' | ||
89 | * @param distance reported distance (DV) to 'other' | ||
73 | * @return GNUNET_OK to keep the connection open, | 90 | * @return GNUNET_OK to keep the connection open, |
74 | * GNUNET_SYSERR to close it (signal serious error) | 91 | * GNUNET_SYSERR to close it (signal serious error) |
75 | */ | 92 | */ |
@@ -77,7 +94,9 @@ typedef int | |||
77 | (*GNUNET_CORE_MessageCallback) (void *cls, | 94 | (*GNUNET_CORE_MessageCallback) (void *cls, |
78 | const struct GNUNET_PeerIdentity * other, | 95 | const struct GNUNET_PeerIdentity * other, |
79 | const struct GNUNET_MessageHeader * | 96 | const struct GNUNET_MessageHeader * |
80 | message); | 97 | message, |
98 | struct GNUNET_TIME_Relative latency, | ||
99 | uint32_t distance); | ||
81 | 100 | ||
82 | 101 | ||
83 | /** | 102 | /** |
@@ -159,9 +178,9 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
159 | struct GNUNET_TIME_Relative timeout, | 178 | struct GNUNET_TIME_Relative timeout, |
160 | void *cls, | 179 | void *cls, |
161 | GNUNET_CORE_StartupCallback init, | 180 | GNUNET_CORE_StartupCallback init, |
162 | GNUNET_CORE_ClientEventHandler pre_connects, | 181 | GNUNET_CORE_ConnectEventHandler pre_connects, |
163 | GNUNET_CORE_ClientEventHandler connects, | 182 | GNUNET_CORE_ConnectEventHandler connects, |
164 | GNUNET_CORE_ClientEventHandler disconnects, | 183 | GNUNET_CORE_DisconnectEventHandler disconnects, |
165 | GNUNET_CORE_MessageCallback inbound_notify, | 184 | GNUNET_CORE_MessageCallback inbound_notify, |
166 | int inbound_hdr_only, | 185 | int inbound_hdr_only, |
167 | GNUNET_CORE_MessageCallback outbound_notify, | 186 | GNUNET_CORE_MessageCallback outbound_notify, |
@@ -270,9 +289,8 @@ typedef void | |||
270 | GNUNET_PeerIdentity * peer, | 289 | GNUNET_PeerIdentity * peer, |
271 | unsigned int bpm_in, | 290 | unsigned int bpm_in, |
272 | unsigned int bpm_out, | 291 | unsigned int bpm_out, |
273 | struct GNUNET_TIME_Relative | 292 | int amount, |
274 | latency, int amount, | 293 | uint64_t preference); |
275 | unsigned long long preference); | ||
276 | 294 | ||
277 | 295 | ||
278 | 296 | ||
@@ -307,15 +325,15 @@ struct GNUNET_CORE_InformationRequestContext; | |||
307 | * @return NULL on error | 325 | * @return NULL on error |
308 | */ | 326 | */ |
309 | struct GNUNET_CORE_InformationRequestContext * | 327 | struct GNUNET_CORE_InformationRequestContext * |
310 | GNUNET_CORE_peer_get_info (struct GNUNET_SCHEDULER_Handle *sched, | 328 | GNUNET_CORE_peer_change_preference (struct GNUNET_SCHEDULER_Handle *sched, |
311 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 329 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
312 | const struct GNUNET_PeerIdentity *peer, | 330 | const struct GNUNET_PeerIdentity *peer, |
313 | struct GNUNET_TIME_Relative timeout, | 331 | struct GNUNET_TIME_Relative timeout, |
314 | uint32_t bpm_out, | 332 | uint32_t bpm_out, |
315 | int32_t amount, | 333 | int32_t amount, |
316 | uint64_t preference, | 334 | uint64_t preference, |
317 | GNUNET_CORE_PeerConfigurationInfoCallback info, | 335 | GNUNET_CORE_PeerConfigurationInfoCallback info, |
318 | void *info_cls); | 336 | void *info_cls); |
319 | 337 | ||
320 | 338 | ||
321 | /** | 339 | /** |
@@ -324,7 +342,7 @@ GNUNET_CORE_peer_get_info (struct GNUNET_SCHEDULER_Handle *sched, | |||
324 | * @param irc context returned by the original GNUNET_CORE_peer_get_info call | 342 | * @param irc context returned by the original GNUNET_CORE_peer_get_info call |
325 | */ | 343 | */ |
326 | void | 344 | void |
327 | GNUNET_CORE_peer_get_info_cancel (struct GNUNET_CORE_InformationRequestContext *irc); | 345 | GNUNET_CORE_peer_change_preference_cancel (struct GNUNET_CORE_InformationRequestContext *irc); |
328 | 346 | ||
329 | 347 | ||
330 | /** | 348 | /** |
@@ -355,9 +373,7 @@ struct GNUNET_CORE_TransmitHandle * | |||
355 | GNUNET_CORE_notify_transmit_ready (struct | 373 | GNUNET_CORE_notify_transmit_ready (struct |
356 | GNUNET_CORE_Handle | 374 | GNUNET_CORE_Handle |
357 | *handle, | 375 | *handle, |
358 | unsigned | 376 | uint32_t priority, |
359 | int | ||
360 | priority, | ||
361 | struct | 377 | struct |
362 | GNUNET_TIME_Relative | 378 | GNUNET_TIME_Relative |
363 | maxdelay, | 379 | maxdelay, |
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h index 0d378cbd3..b86bb1663 100644 --- a/src/include/gnunet_transport_service.h +++ b/src/include/gnunet_transport_service.h | |||
@@ -68,7 +68,7 @@ typedef void (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls, | |||
68 | message, | 68 | message, |
69 | struct GNUNET_TIME_Relative | 69 | struct GNUNET_TIME_Relative |
70 | latency, | 70 | latency, |
71 | unsigned int distance); | 71 | uint32_t distance); |
72 | 72 | ||
73 | 73 | ||
74 | /** | 74 | /** |
@@ -91,7 +91,7 @@ typedef void | |||
91 | (*GNUNET_TRANSPORT_NotifyConnect) (void *cls, | 91 | (*GNUNET_TRANSPORT_NotifyConnect) (void *cls, |
92 | const struct GNUNET_PeerIdentity * peer, | 92 | const struct GNUNET_PeerIdentity * peer, |
93 | struct GNUNET_TIME_Relative latency, | 93 | struct GNUNET_TIME_Relative latency, |
94 | unsigned int distance); | 94 | uint32_t distance); |
95 | 95 | ||
96 | /** | 96 | /** |
97 | * Function called to notify transport users that another | 97 | * Function called to notify transport users that another |
@@ -204,7 +204,7 @@ struct GNUNET_TRANSPORT_TransmitHandle | |||
204 | *handle, | 204 | *handle, |
205 | const struct GNUNET_PeerIdentity | 205 | const struct GNUNET_PeerIdentity |
206 | *target, size_t size, | 206 | *target, size_t size, |
207 | unsigned int priority, | 207 | uint32_t priority, |
208 | struct GNUNET_TIME_Relative | 208 | struct GNUNET_TIME_Relative |
209 | timeout, | 209 | timeout, |
210 | GNUNET_CONNECTION_TransmitReadyNotify | 210 | GNUNET_CONNECTION_TransmitReadyNotify |
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 87860c202..a612fa4f4 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -39,7 +39,8 @@ gnunet_transport_LDADD = \ | |||
39 | $(GN_LIBINTL) | 39 | $(GN_LIBINTL) |
40 | 40 | ||
41 | gnunet_service_transport_SOURCES = \ | 41 | gnunet_service_transport_SOURCES = \ |
42 | gnunet-service-transport.c plugin_transport.h | 42 | gnunet-service-transport.c plugin_transport.h \ |
43 | gnunet-service-transport_blacklist.c gnunet-service-transport_blacklist.h | ||
43 | gnunet_service_transport_LDADD = \ | 44 | gnunet_service_transport_LDADD = \ |
44 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | 45 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ |
45 | $(top_builddir)/src/util/libgnunetutil.la \ | 46 | $(top_builddir)/src/util/libgnunetutil.la \ |
diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c new file mode 100644 index 000000000..a1b13f33e --- /dev/null +++ b/src/transport/gnunet-service-transport_blacklist.c | |||
@@ -0,0 +1,202 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010 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 2, 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.c | ||
23 | * @brief low-level P2P messaging | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_protocols.h" | ||
28 | #include "gnunet_service_lib.h" | ||
29 | #include "transport.h" | ||
30 | #include "gnunet-service-transport_blacklist.h" | ||
31 | |||
32 | |||
33 | /** | ||
34 | * Information kept for each blacklisted peer. | ||
35 | */ | ||
36 | struct BlacklistEntry | ||
37 | { | ||
38 | /** | ||
39 | * How long until this entry times out? | ||
40 | */ | ||
41 | struct GNUNET_TIME_Absolute until; | ||
42 | |||
43 | /** | ||
44 | * Task scheduled to run the moment the time does run out. | ||
45 | */ | ||
46 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | ||
47 | }; | ||
48 | |||
49 | |||
50 | /** | ||
51 | * Entry in list of notifications still to transmit to | ||
52 | * a client. | ||
53 | */ | ||
54 | struct PendingNotificationList | ||
55 | { | ||
56 | |||
57 | /** | ||
58 | * This is a linked list. | ||
59 | */ | ||
60 | struct PendingNotificationList *next; | ||
61 | |||
62 | /** | ||
63 | * Identity of the peer to send notification about. | ||
64 | */ | ||
65 | struct GNUNET_PeerIdentity peer; | ||
66 | |||
67 | }; | ||
68 | |||
69 | |||
70 | /** | ||
71 | * List of clients to notify whenever the blacklist changes. | ||
72 | */ | ||
73 | struct BlacklistNotificationList | ||
74 | { | ||
75 | |||
76 | /** | ||
77 | * This is a linked list. | ||
78 | */ | ||
79 | struct BlacklistNotificationList *next; | ||
80 | |||
81 | /** | ||
82 | * Client to notify. | ||
83 | */ | ||
84 | struct GNUNET_SERVER_Client *client; | ||
85 | |||
86 | /** | ||
87 | * Pending request for transmission to client, or NULL. | ||
88 | */ | ||
89 | struct GNUNET_CONNECTION_TransmitHandle *req; | ||
90 | |||
91 | /** | ||
92 | * Blacklist entries that still need to be submitted. | ||
93 | */ | ||
94 | struct PendingNotificationList *pending; | ||
95 | |||
96 | }; | ||
97 | |||
98 | |||
99 | /** | ||
100 | * Map of blacklisted peers (maps from peer identities | ||
101 | * to 'struct BlacklistEntry*' values). | ||
102 | */ | ||
103 | static struct GNUNET_CONTAINER_MultiHashMap *blacklist; | ||
104 | |||
105 | /** | ||
106 | * Linked list of clients to notify whenever the blacklist changes. | ||
107 | */ | ||
108 | static struct BlacklistNotificationList *blacklist_notifiers; | ||
109 | |||
110 | /** | ||
111 | * Our scheduler. | ||
112 | */ | ||
113 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
114 | |||
115 | |||
116 | /** | ||
117 | * Free the entries in the blacklist hash map. | ||
118 | * | ||
119 | * @param cls closure, unused | ||
120 | * @param key current key code | ||
121 | * @param value value in the hash map | ||
122 | * @return GNUNET_YES if we should continue to | ||
123 | * iterate, | ||
124 | * GNUNET_NO if not. | ||
125 | */ | ||
126 | static int | ||
127 | free_blacklist_entry (void *cls, | ||
128 | const GNUNET_HashCode *key, | ||
129 | void *value) | ||
130 | { | ||
131 | struct BlacklistEntry *be = value; | ||
132 | |||
133 | GNUNET_SCHEDULER_cancel (sched, | ||
134 | be->timeout_task); | ||
135 | GNUNET_free (be); | ||
136 | return GNUNET_YES; | ||
137 | } | ||
138 | |||
139 | |||
140 | static void | ||
141 | shutdown_task (void *cls, | ||
142 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
143 | { | ||
144 | GNUNET_CONTAINER_multihashmap_iterate (blacklist, | ||
145 | &free_blacklist_entry, | ||
146 | NULL); | ||
147 | GNUNET_CONTAINER_multihashmap_destroy (blacklist); | ||
148 | } | ||
149 | |||
150 | |||
151 | /** | ||
152 | * Handle a request to blacklist a peer. | ||
153 | */ | ||
154 | void | ||
155 | GNUNET_TRANSPORT_handle_blacklist (void *cls, | ||
156 | struct GNUNET_SERVER_Client *client, | ||
157 | const struct GNUNET_MessageHeader *message) | ||
158 | { | ||
159 | } | ||
160 | |||
161 | |||
162 | /** | ||
163 | * Handle a request for notification of blacklist changes. | ||
164 | */ | ||
165 | void | ||
166 | GNUNET_TRANSPORT_handle_blacklist_notify (void *cls, | ||
167 | struct GNUNET_SERVER_Client *client, | ||
168 | const struct GNUNET_MessageHeader *message) | ||
169 | { | ||
170 | } | ||
171 | |||
172 | |||
173 | /** | ||
174 | * Is the given peer currently blacklisted? | ||
175 | * | ||
176 | * @param id identity of the peer | ||
177 | * @return GNUNET_YES if the peer is blacklisted, GNUNET_NO if not | ||
178 | */ | ||
179 | int | ||
180 | GNUNET_TRANSPORT_blacklist_check (const struct GNUNET_PeerIdentity *id) | ||
181 | { | ||
182 | return GNUNET_CONTAINER_multihashmap_contains (blacklist, &id->hashPubKey); | ||
183 | } | ||
184 | |||
185 | |||
186 | /** | ||
187 | * Initialize the blacklisting subsystem. | ||
188 | * | ||
189 | * @param s scheduler to use | ||
190 | */ | ||
191 | void | ||
192 | GNUNET_TRANSPORT_blacklist_init (struct GNUNET_SCHEDULER_Handle *s) | ||
193 | { | ||
194 | sched = s; | ||
195 | blacklist = GNUNET_CONTAINER_multihashmap_create (4); | ||
196 | GNUNET_SCHEDULER_add_delayed (sched, | ||
197 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
198 | &shutdown_task, | ||
199 | NULL); | ||
200 | } | ||
201 | |||
202 | /* end of gnunet-service-transport_blacklist.c */ | ||
diff --git a/src/transport/gnunet-service-transport_blacklist.h b/src/transport/gnunet-service-transport_blacklist.h new file mode 100644 index 000000000..95a86dc9a --- /dev/null +++ b/src/transport/gnunet-service-transport_blacklist.h | |||
@@ -0,0 +1,30 @@ | |||
1 | * | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010 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 2, 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 internal API for blacklisting functionality | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_protocols.h" | ||
28 | #include "gnunet_service_lib.h" | ||
29 | #include "transport.h" | ||
30 | |||
diff --git a/src/transport/plugin_transport.h b/src/transport/plugin_transport.h index b04cab990..2b3a87f3b 100644 --- a/src/transport/plugin_transport.h +++ b/src/transport/plugin_transport.h | |||
@@ -50,24 +50,24 @@ | |||
50 | * message to signal that the other peer disconnected. | 50 | * message to signal that the other peer disconnected. |
51 | * | 51 | * |
52 | * @param cls closure | 52 | * @param cls closure |
53 | * @param peer (claimed) identity of the other peer | ||
54 | * @param message the message, NULL if peer was disconnected | ||
53 | * @param distance in overlay hops; use 1 unless DV | 55 | * @param distance in overlay hops; use 1 unless DV |
54 | * @param sender_address binary address of the sender (if observed) | 56 | * @param sender_address binary address of the sender (if observed) |
55 | * @param sender_address_len number of bytes in sender_address | 57 | * @param sender_address_len number of bytes in sender_address |
56 | * @param peer (claimed) identity of the other peer | ||
57 | * @param message the message, NULL if peer was disconnected | ||
58 | */ | 58 | */ |
59 | typedef void (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls, const struct | 59 | typedef void (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls, |
60 | GNUNET_MessageHeader * | ||
61 | message, | ||
62 | const struct | 60 | const struct |
63 | GNUNET_PeerIdentity * | 61 | GNUNET_PeerIdentity * |
64 | peer, | 62 | peer, |
65 | unsigned int distance, | 63 | const struct |
64 | GNUNET_MessageHeader * | ||
65 | message, | ||
66 | uint32_t distance, | ||
66 | const char *sender_address, | 67 | const char *sender_address, |
67 | size_t sender_address_len); | 68 | size_t sender_address_len); |
68 | 69 | ||
69 | 70 | ||
70 | |||
71 | /** | 71 | /** |
72 | * Function that will be called for each address the transport | 72 | * Function that will be called for each address the transport |
73 | * is aware that it might be reachable under. | 73 | * is aware that it might be reachable under. |
@@ -198,7 +198,7 @@ typedef ssize_t | |||
198 | const struct GNUNET_PeerIdentity * | 198 | const struct GNUNET_PeerIdentity * |
199 | target, | 199 | target, |
200 | const struct GNUNET_MessageHeader *msg, | 200 | const struct GNUNET_MessageHeader *msg, |
201 | unsigned int priority, | 201 | uint32_t priority, |
202 | struct GNUNET_TIME_Relative timeout, | 202 | struct GNUNET_TIME_Relative timeout, |
203 | const void *addr, | 203 | const void *addr, |
204 | size_t addrlen, | 204 | size_t addrlen, |