diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-01-22 17:27:16 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-01-22 17:27:16 +0000 |
commit | 07632b2d9509b0e425967cbc80d2abd6ffc81c9d (patch) | |
tree | 905060f30d74d05304a448fe3e3cd06dad583328 /src/topology | |
parent | 068bd6929580eb6521c7ac40c8ae05eb632f6c58 (diff) | |
download | gnunet-07632b2d9509b0e425967cbc80d2abd6ffc81c9d.tar.gz gnunet-07632b2d9509b0e425967cbc80d2abd6ffc81c9d.zip |
use new APIs for connect/disconnect
Diffstat (limited to 'src/topology')
-rw-r--r-- | src/topology/gnunet-daemon-topology.c | 62 |
1 files changed, 20 insertions, 42 deletions
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index a636360d6..3bcc29704 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -87,7 +87,7 @@ struct PeerList | |||
87 | * Our handle for the request to connect to this peer; NULL if no | 87 | * Our handle for the request to connect to this peer; NULL if no |
88 | * such request is pending. | 88 | * such request is pending. |
89 | */ | 89 | */ |
90 | struct GNUNET_CORE_TransmitHandle *connect_req; | 90 | struct GNUNET_CORE_PeerRequestHandle *connect_req; |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * Pointer to the HELLO message of this peer; can be NULL. | 93 | * Pointer to the HELLO message of this peer; can be NULL. |
@@ -158,8 +158,8 @@ struct DisconnectList | |||
158 | /** | 158 | /** |
159 | * Our request handle. | 159 | * Our request handle. |
160 | */ | 160 | */ |
161 | struct GNUNET_CORE_PeerRequestHandle *rh; | 161 | struct GNUNET_TRANSPORT_BlacklistRequest *rh; |
162 | 162 | ||
163 | /** | 163 | /** |
164 | * Peer we tried to disconnect. | 164 | * Peer we tried to disconnect. |
165 | */ | 165 | */ |
@@ -268,9 +268,7 @@ disconnect_done (void *cls, | |||
268 | 268 | ||
269 | 269 | ||
270 | /** | 270 | /** |
271 | * Force a disconnect from the specified peer. This is currently done by | 271 | * Force a disconnect from the specified peer. |
272 | * changing the bandwidth policy to 0 bytes per second. | ||
273 | * FIXME: maybe we want a nicer CORE API for both connect and disconnect... | ||
274 | * FIXME: this policy change is never undone; how do we reconnect ever? | 272 | * FIXME: this policy change is never undone; how do we reconnect ever? |
275 | */ | 273 | */ |
276 | static void | 274 | static void |
@@ -283,43 +281,25 @@ force_disconnect (const struct GNUNET_PeerIdentity *peer) | |||
283 | GNUNET_CONTAINER_DLL_insert (disconnect_head, | 281 | GNUNET_CONTAINER_DLL_insert (disconnect_head, |
284 | disconnect_tail, | 282 | disconnect_tail, |
285 | dl); | 283 | dl); |
286 | dl->rh = GNUNET_CORE_peer_request_disconnect (sched, cfg, | 284 | dl->rh = GNUNET_TRANSPORT_blacklist (sched, cfg, |
287 | GNUNET_TIME_UNIT_FOREVER_REL, | 285 | peer, |
288 | peer, | 286 | GNUNET_TIME_UNIT_FOREVER_REL, |
289 | &disconnect_done, | 287 | GNUNET_TIME_UNIT_FOREVER_REL, |
290 | dl); | 288 | &disconnect_done, |
289 | dl); | ||
291 | } | 290 | } |
292 | 291 | ||
293 | 292 | ||
294 | /** | 293 | /** |
295 | * Function called by core when our attempt to connect succeeded. | 294 | * Function called by core when our attempt to connect succeeded. |
296 | * Transmits a 'DUMMY' message to trigger the session key exchange. | ||
297 | * FIXME: this is an issue with the current CORE API. | ||
298 | */ | 295 | */ |
299 | static size_t | 296 | static void |
300 | ready_callback (void *cls, | 297 | connect_completed_callback (void *cls, |
301 | size_t size, void *buf) | 298 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
302 | { | 299 | { |
303 | struct PeerList *pos = cls; | 300 | struct PeerList *pos = cls; |
304 | struct GNUNET_MessageHeader hdr; | ||
305 | 301 | ||
306 | pos->connect_req = NULL; | 302 | pos->connect_req = NULL; |
307 | if (buf == NULL) | ||
308 | { | ||
309 | #if DEBUG_TOPOLOGY | ||
310 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
311 | "Core told us that our attempt to connect failed.\n"); | ||
312 | #endif | ||
313 | return 0; | ||
314 | } | ||
315 | #if DEBUG_TOPOLOGY | ||
316 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
317 | "Sending dummy message to establish connection.\n"); | ||
318 | #endif | ||
319 | hdr.size = htons (sizeof (struct GNUNET_MessageHeader)); | ||
320 | hdr.type = htons (GNUNET_MESSAGE_TYPE_TOPOLOGY_DUMMY); | ||
321 | memcpy (buf, &hdr, sizeof (struct GNUNET_MessageHeader)); | ||
322 | return sizeof (struct GNUNET_MessageHeader); | ||
323 | } | 303 | } |
324 | 304 | ||
325 | 305 | ||
@@ -340,13 +320,11 @@ attempt_connect (struct PeerList *pos) | |||
340 | "Asking core to connect to `%s'\n", | 320 | "Asking core to connect to `%s'\n", |
341 | GNUNET_i2s (&pos->id)); | 321 | GNUNET_i2s (&pos->id)); |
342 | #endif | 322 | #endif |
343 | pos->connect_req = GNUNET_CORE_notify_transmit_ready (handle, | 323 | pos->connect_req = GNUNET_CORE_peer_request_connect (sched, cfg, |
344 | 0 /* priority */, | 324 | GNUNET_TIME_UNIT_MINUTES, |
345 | GNUNET_TIME_UNIT_MINUTES, | 325 | &pos->id, |
346 | &pos->id, | 326 | &connect_completed_callback, |
347 | sizeof(struct GNUNET_MessageHeader), | 327 | pos); |
348 | &ready_callback, | ||
349 | pos); | ||
350 | } | 328 | } |
351 | 329 | ||
352 | 330 | ||
@@ -457,7 +435,7 @@ free_peer (struct PeerList *peer) | |||
457 | if (pos->hello_req != NULL) | 435 | if (pos->hello_req != NULL) |
458 | GNUNET_CORE_notify_transmit_ready_cancel (pos->hello_req); | 436 | GNUNET_CORE_notify_transmit_ready_cancel (pos->hello_req); |
459 | if (pos->connect_req != NULL) | 437 | if (pos->connect_req != NULL) |
460 | GNUNET_CORE_notify_transmit_ready_cancel (pos->connect_req); | 438 | GNUNET_CORE_peer_request_connect_cancel (pos->connect_req); |
461 | if (pos->hello_delay_task != GNUNET_SCHEDULER_NO_TASK) | 439 | if (pos->hello_delay_task != GNUNET_SCHEDULER_NO_TASK) |
462 | GNUNET_SCHEDULER_cancel (sched, | 440 | GNUNET_SCHEDULER_cancel (sched, |
463 | pos->hello_delay_task); | 441 | pos->hello_delay_task); |
@@ -1203,7 +1181,7 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1203 | GNUNET_CONTAINER_DLL_remove (disconnect_head, | 1181 | GNUNET_CONTAINER_DLL_remove (disconnect_head, |
1204 | disconnect_tail, | 1182 | disconnect_tail, |
1205 | dl); | 1183 | dl); |
1206 | GNUNET_CORE_peer_request_cancel (dl->rh); | 1184 | GNUNET_TRANSPORT_blacklist_cancel (dl->rh); |
1207 | GNUNET_free (dl); | 1185 | GNUNET_free (dl); |
1208 | } | 1186 | } |
1209 | } | 1187 | } |