diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-11-15 13:56:40 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-11-15 13:56:40 +0100 |
commit | 478a4c062b7d12b5d75d10667aa7739bd15b6405 (patch) | |
tree | 2fb3c5474a510d242fadeae772114343313b1f5d | |
parent | ad1244d958b76cb249028c7ad87ff84df49293ff (diff) | |
download | gnunet-478a4c062b7d12b5d75d10667aa7739bd15b6405.tar.gz gnunet-478a4c062b7d12b5d75d10667aa7739bd15b6405.zip |
get gnunet-service-tng to build
-rw-r--r-- | src/include/gnunet_transport_core_service.h | 12 | ||||
-rw-r--r-- | src/transport/Makefile.am | 20 | ||||
-rw-r--r-- | src/transport/gnunet-service-tng.c | 59 | ||||
-rw-r--r-- | src/transport/transport-testing.c | 4 | ||||
-rw-r--r-- | src/transport/transport-testing.h | 8 | ||||
-rw-r--r-- | src/transport/transport_api2_core.c | 128 | ||||
-rw-r--r-- | src/transport/transport_api_core.c | 12 |
7 files changed, 89 insertions, 154 deletions
diff --git a/src/include/gnunet_transport_core_service.h b/src/include/gnunet_transport_core_service.h index 5fbfcee21..b52dbe5f8 100644 --- a/src/include/gnunet_transport_core_service.h +++ b/src/include/gnunet_transport_core_service.h | |||
@@ -66,7 +66,7 @@ struct GNUNET_TRANSPORT_CoreHandle; | |||
66 | * @return closure to use in MQ handlers | 66 | * @return closure to use in MQ handlers |
67 | */ | 67 | */ |
68 | typedef void * | 68 | typedef void * |
69 | (*GNUNET_TRANSPORT_NotifyConnecT) (void *cls, | 69 | (*GNUNET_TRANSPORT_NotifyConnect) (void *cls, |
70 | const struct GNUNET_PeerIdentity *peer, | 70 | const struct GNUNET_PeerIdentity *peer, |
71 | struct GNUNET_MQ_Handle *mq); | 71 | struct GNUNET_MQ_Handle *mq); |
72 | 72 | ||
@@ -83,7 +83,7 @@ typedef void * | |||
83 | * connect notification callback | 83 | * connect notification callback |
84 | */ | 84 | */ |
85 | typedef void | 85 | typedef void |
86 | (*GNUNET_TRANSPORT_NotifyDisconnecT) (void *cls, | 86 | (*GNUNET_TRANSPORT_NotifyDisconnect) (void *cls, |
87 | const struct GNUNET_PeerIdentity *peer, | 87 | const struct GNUNET_PeerIdentity *peer, |
88 | void *handler_cls); | 88 | void *handler_cls); |
89 | 89 | ||
@@ -105,7 +105,7 @@ typedef void | |||
105 | * connect notification callback | 105 | * connect notification callback |
106 | */ | 106 | */ |
107 | typedef void | 107 | typedef void |
108 | (*GNUNET_TRANSPORT_NotifyExcessBandwidtH)(void *cls, | 108 | (*GNUNET_TRANSPORT_NotifyExcessBandwidth)(void *cls, |
109 | const struct GNUNET_PeerIdentity *neighbour, | 109 | const struct GNUNET_PeerIdentity *neighbour, |
110 | void *handlers_cls); | 110 | void *handlers_cls); |
111 | 111 | ||
@@ -133,9 +133,9 @@ GNUNET_TRANSPORT_core_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
133 | const struct GNUNET_PeerIdentity *self, | 133 | const struct GNUNET_PeerIdentity *self, |
134 | const struct GNUNET_MQ_MessageHandler *handlers, | 134 | const struct GNUNET_MQ_MessageHandler *handlers, |
135 | void *cls, | 135 | void *cls, |
136 | GNUNET_TRANSPORT_NotifyConnecT nc, | 136 | GNUNET_TRANSPORT_NotifyConnect nc, |
137 | GNUNET_TRANSPORT_NotifyDisconnecT nd, | 137 | GNUNET_TRANSPORT_NotifyDisconnect nd, |
138 | GNUNET_TRANSPORT_NotifyExcessBandwidtH neb); | 138 | GNUNET_TRANSPORT_NotifyExcessBandwidth neb); |
139 | 139 | ||
140 | 140 | ||
141 | /** | 141 | /** |
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 2a549d413..ad39abe6a 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -141,6 +141,7 @@ endif | |||
141 | noinst_PROGRAMS = \ | 141 | noinst_PROGRAMS = \ |
142 | gnunet-transport-profiler \ | 142 | gnunet-transport-profiler \ |
143 | gnunet-communicator-unix \ | 143 | gnunet-communicator-unix \ |
144 | gnunet-service-tng \ | ||
144 | $(WLAN_BIN_SENDER) \ | 145 | $(WLAN_BIN_SENDER) \ |
145 | $(WLAN_BIN_RECEIVER) | 146 | $(WLAN_BIN_RECEIVER) |
146 | 147 | ||
@@ -150,6 +151,7 @@ endif | |||
150 | 151 | ||
151 | lib_LTLIBRARIES = \ | 152 | lib_LTLIBRARIES = \ |
152 | libgnunettransport.la \ | 153 | libgnunettransport.la \ |
154 | libgnunettransportcore.la \ | ||
153 | libgnunettransportcommunicator.la \ | 155 | libgnunettransportcommunicator.la \ |
154 | libgnunettransportmonitor.la \ | 156 | libgnunettransportmonitor.la \ |
155 | $(TESTING_LIBS) | 157 | $(TESTING_LIBS) |
@@ -192,6 +194,15 @@ libgnunettransport_la_LDFLAGS = \ | |||
192 | 194 | ||
193 | 195 | ||
194 | 196 | ||
197 | libgnunettransportcore_la_SOURCES = \ | ||
198 | transport_api2_core.c | ||
199 | libgnunettransportcore_la_LIBADD = \ | ||
200 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
201 | $(GN_LIBINTL) | ||
202 | libgnunettransportcore_la_LDFLAGS = \ | ||
203 | $(GN_LIB_LDFLAGS) $(WINFLAGS) \ | ||
204 | -version-info 0:0:0 | ||
205 | |||
195 | libgnunettransportcommunicator_la_SOURCES = \ | 206 | libgnunettransportcommunicator_la_SOURCES = \ |
196 | transport_api2_communication.c | 207 | transport_api2_communication.c |
197 | libgnunettransportcommunicator_la_LIBADD = \ | 208 | libgnunettransportcommunicator_la_LIBADD = \ |
@@ -311,6 +322,15 @@ gnunet_service_transport_CFLAGS = \ | |||
311 | $(CFLAGS) | 322 | $(CFLAGS) |
312 | # -DANALYZE | 323 | # -DANALYZE |
313 | 324 | ||
325 | |||
326 | gnunet_service_tng_SOURCES = \ | ||
327 | gnunet-service-tng.c | ||
328 | gnunet_service_tng_LDADD = \ | ||
329 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
330 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
331 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
332 | $(GN_LIBINTL) | ||
333 | |||
314 | plugin_LTLIBRARIES = \ | 334 | plugin_LTLIBRARIES = \ |
315 | libgnunet_plugin_transport_tcp.la \ | 335 | libgnunet_plugin_transport_tcp.la \ |
316 | libgnunet_plugin_transport_udp.la \ | 336 | libgnunet_plugin_transport_udp.la \ |
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index d92964654..73b295442 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -233,7 +233,6 @@ handle_client_start (void *cls, | |||
233 | const struct StartMessage *start) | 233 | const struct StartMessage *start) |
234 | { | 234 | { |
235 | struct TransportClient *tc = cls; | 235 | struct TransportClient *tc = cls; |
236 | const struct GNUNET_MessageHeader *hello; | ||
237 | uint32_t options; | 236 | uint32_t options; |
238 | 237 | ||
239 | options = ntohl (start->options); | 238 | options = ntohl (start->options); |
@@ -255,46 +254,6 @@ handle_client_start (void *cls, | |||
255 | return; | 254 | return; |
256 | } | 255 | } |
257 | tc->type = CT_CORE; | 256 | tc->type = CT_CORE; |
258 | #if 0 | ||
259 | hello = GST_hello_get (); | ||
260 | if (NULL != hello) | ||
261 | unicast (tc, | ||
262 | hello, | ||
263 | GNUNET_NO); | ||
264 | #endif | ||
265 | GNUNET_SERVICE_client_continue (tc->client); | ||
266 | } | ||
267 | |||
268 | |||
269 | /** | ||
270 | * Client sent us a HELLO. Check the request. | ||
271 | * | ||
272 | * @param cls the client | ||
273 | * @param message the HELLO message | ||
274 | */ | ||
275 | static int | ||
276 | check_client_hello (void *cls, | ||
277 | const struct GNUNET_MessageHeader *message) | ||
278 | { | ||
279 | (void) cls; | ||
280 | return GNUNET_OK; /* FIXME: check here? */ | ||
281 | } | ||
282 | |||
283 | |||
284 | /** | ||
285 | * Client sent us a HELLO. Process the request. | ||
286 | * | ||
287 | * @param cls the client | ||
288 | * @param message the HELLO message | ||
289 | */ | ||
290 | static void | ||
291 | handle_client_hello (void *cls, | ||
292 | const struct GNUNET_MessageHeader *message) | ||
293 | { | ||
294 | struct TransportClient *tc = cls; | ||
295 | |||
296 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
297 | "Received HELLO message\n"); | ||
298 | GNUNET_SERVICE_client_continue (tc->client); | 257 | GNUNET_SERVICE_client_continue (tc->client); |
299 | } | 258 | } |
300 | 259 | ||
@@ -395,7 +354,7 @@ handle_communicator_available (void *cls, | |||
395 | tc->type = CT_COMMUNICATOR; | 354 | tc->type = CT_COMMUNICATOR; |
396 | size = ntohs (cam->header.size) - sizeof (*cam); | 355 | size = ntohs (cam->header.size) - sizeof (*cam); |
397 | if (0 == size) | 356 | if (0 == size) |
398 | return GNUNET_OK; /* receive-only communicator */ | 357 | return; /* receive-only communicator */ |
399 | tc->details.address_prefix = GNUNET_strdup ((const char *) &cam[1]); | 358 | tc->details.address_prefix = GNUNET_strdup ((const char *) &cam[1]); |
400 | GNUNET_SERVICE_client_continue (tc->client); | 359 | GNUNET_SERVICE_client_continue (tc->client); |
401 | } | 360 | } |
@@ -421,7 +380,7 @@ check_add_address (void *cls, | |||
421 | GNUNET_break (0); | 380 | GNUNET_break (0); |
422 | return GNUNET_SYSERR; | 381 | return GNUNET_SYSERR; |
423 | } | 382 | } |
424 | addr = (const char *) &cam[1]; | 383 | addr = (const char *) &aam[1]; |
425 | if ('\0' != addr[size-1]) | 384 | if ('\0' != addr[size-1]) |
426 | { | 385 | { |
427 | GNUNET_break (0); | 386 | GNUNET_break (0); |
@@ -651,15 +610,7 @@ run (void *cls, | |||
651 | { | 610 | { |
652 | /* setup globals */ | 611 | /* setup globals */ |
653 | GST_cfg = c; | 612 | GST_cfg = c; |
654 | if (GNUNET_OK != | 613 | GST_my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (GST_cfg); |
655 | GNUNET_CONFIGURATION_get_value_time (c, | ||
656 | "transport", | ||
657 | "HELLO_EXPIRATION", | ||
658 | &hello_expiration)) | ||
659 | { | ||
660 | hello_expiration = GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION; | ||
661 | } | ||
662 | GST_my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg); | ||
663 | if (NULL == GST_my_private_key) | 614 | if (NULL == GST_my_private_key) |
664 | { | 615 | { |
665 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 616 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
@@ -696,10 +647,6 @@ GNUNET_SERVICE_MAIN | |||
696 | GNUNET_MESSAGE_TYPE_TRANSPORT_START, | 647 | GNUNET_MESSAGE_TYPE_TRANSPORT_START, |
697 | struct StartMessage, | 648 | struct StartMessage, |
698 | NULL), | 649 | NULL), |
699 | GNUNET_MQ_hd_var_size (client_hello, | ||
700 | GNUNET_MESSAGE_TYPE_HELLO, | ||
701 | struct GNUNET_MessageHeader, | ||
702 | NULL), | ||
703 | GNUNET_MQ_hd_var_size (client_send, | 650 | GNUNET_MQ_hd_var_size (client_send, |
704 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, | 651 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, |
705 | struct OutboundMessage, | 652 | struct OutboundMessage, |
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c index e3d4b7a9b..4295446d2 100644 --- a/src/transport/transport-testing.c +++ b/src/transport/transport-testing.c | |||
@@ -374,8 +374,8 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_Handle *tth | |||
374 | const char *cfgname, | 374 | const char *cfgname, |
375 | int peer_id, | 375 | int peer_id, |
376 | const struct GNUNET_MQ_MessageHandler *handlers, | 376 | const struct GNUNET_MQ_MessageHandler *handlers, |
377 | GNUNET_TRANSPORT_NotifyConnecT nc, | 377 | GNUNET_TRANSPORT_NotifyConnect nc, |
378 | GNUNET_TRANSPORT_NotifyDisconnecT nd, | 378 | GNUNET_TRANSPORT_NotifyDisconnect nd, |
379 | void *cb_cls, | 379 | void *cb_cls, |
380 | GNUNET_SCHEDULER_TaskCallback start_cb, | 380 | GNUNET_SCHEDULER_TaskCallback start_cb, |
381 | void *start_cb_cls) | 381 | void *start_cb_cls) |
diff --git a/src/transport/transport-testing.h b/src/transport/transport-testing.h index a4cfd89f6..3a638580d 100644 --- a/src/transport/transport-testing.h +++ b/src/transport/transport-testing.h | |||
@@ -115,12 +115,12 @@ struct GNUNET_TRANSPORT_TESTING_PeerContext | |||
115 | /** | 115 | /** |
116 | * Notify connect callback | 116 | * Notify connect callback |
117 | */ | 117 | */ |
118 | GNUNET_TRANSPORT_NotifyConnecT nc; | 118 | GNUNET_TRANSPORT_NotifyConnect nc; |
119 | 119 | ||
120 | /** | 120 | /** |
121 | * Notify disconnect callback | 121 | * Notify disconnect callback |
122 | */ | 122 | */ |
123 | GNUNET_TRANSPORT_NotifyDisconnecT nd; | 123 | GNUNET_TRANSPORT_NotifyDisconnect nd; |
124 | 124 | ||
125 | /** | 125 | /** |
126 | * Startup completed callback | 126 | * Startup completed callback |
@@ -291,8 +291,8 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_Handle *tth | |||
291 | const char *cfgname, | 291 | const char *cfgname, |
292 | int peer_id, | 292 | int peer_id, |
293 | const struct GNUNET_MQ_MessageHandler *handlers, | 293 | const struct GNUNET_MQ_MessageHandler *handlers, |
294 | GNUNET_TRANSPORT_NotifyConnecT nc, | 294 | GNUNET_TRANSPORT_NotifyConnect nc, |
295 | GNUNET_TRANSPORT_NotifyDisconnecT nd, | 295 | GNUNET_TRANSPORT_NotifyDisconnect nd, |
296 | void *cb_cls, | 296 | void *cb_cls, |
297 | GNUNET_SCHEDULER_TaskCallback start_cb, | 297 | GNUNET_SCHEDULER_TaskCallback start_cb, |
298 | void *start_cb_cls); | 298 | void *start_cb_cls); |
diff --git a/src/transport/transport_api2_core.c b/src/transport/transport_api2_core.c index b7edc3cc1..78d8dcce0 100644 --- a/src/transport/transport_api2_core.c +++ b/src/transport/transport_api2_core.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009-2013, 2016 GNUnet e.V. | 3 | Copyright (C) 2009-2013, 2016, 2018 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -33,12 +33,6 @@ | |||
33 | #define LOG(kind,...) GNUNET_log_from (kind, "transport-api-core",__VA_ARGS__) | 33 | #define LOG(kind,...) GNUNET_log_from (kind, "transport-api-core",__VA_ARGS__) |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * If we could not send any payload to a peer for this amount of | ||
37 | * time, we print a warning. | ||
38 | */ | ||
39 | #define UNREADY_WARN_TIME GNUNET_TIME_UNIT_MINUTES | ||
40 | |||
41 | /** | ||
42 | * How large to start with for the hashmap of neighbours. | 36 | * How large to start with for the hashmap of neighbours. |
43 | */ | 37 | */ |
44 | #define STARTING_NEIGHBOURS_SIZE 16 | 38 | #define STARTING_NEIGHBOURS_SIZE 16 |
@@ -49,6 +43,12 @@ | |||
49 | */ | 43 | */ |
50 | struct Neighbour | 44 | struct Neighbour |
51 | { | 45 | { |
46 | |||
47 | /** | ||
48 | * Identity of this neighbour. | ||
49 | */ | ||
50 | struct GNUNET_PeerIdentity id; | ||
51 | |||
52 | /** | 52 | /** |
53 | * Overall transport handle. | 53 | * Overall transport handle. |
54 | */ | 54 | */ |
@@ -70,16 +70,6 @@ struct Neighbour | |||
70 | void *handlers_cls; | 70 | void *handlers_cls; |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * Identity of this neighbour. | ||
74 | */ | ||
75 | struct GNUNET_PeerIdentity id; | ||
76 | |||
77 | /** | ||
78 | * Outbound bandwidh tracker. | ||
79 | */ | ||
80 | struct GNUNET_BANDWIDTH_Tracker out_tracker; | ||
81 | |||
82 | /** | ||
83 | * Entry in our readyness heap (which is sorted by @e next_ready | 73 | * Entry in our readyness heap (which is sorted by @e next_ready |
84 | * value). NULL if there is no pending transmission request for | 74 | * value). NULL if there is no pending transmission request for |
85 | * this neighbour or if we're waiting for @e is_ready to become | 75 | * this neighbour or if we're waiting for @e is_ready to become |
@@ -96,6 +86,11 @@ struct Neighbour | |||
96 | struct GNUNET_SCHEDULER_Task *timeout_task; | 86 | struct GNUNET_SCHEDULER_Task *timeout_task; |
97 | 87 | ||
98 | /** | 88 | /** |
89 | * Outbound bandwidh tracker. | ||
90 | */ | ||
91 | struct GNUNET_BANDWIDTH_Tracker out_tracker; | ||
92 | |||
93 | /** | ||
99 | * Sending consumed more bytes on wire than payload was announced | 94 | * Sending consumed more bytes on wire than payload was announced |
100 | * This overhead is added to the delay of next sending operation | 95 | * This overhead is added to the delay of next sending operation |
101 | */ | 96 | */ |
@@ -136,17 +131,17 @@ struct GNUNET_TRANSPORT_CoreHandle | |||
136 | /** | 131 | /** |
137 | * function to call on connect events | 132 | * function to call on connect events |
138 | */ | 133 | */ |
139 | GNUNET_TRANSPORT_NotifyConnecT nc_cb; | 134 | GNUNET_TRANSPORT_NotifyConnect nc_cb; |
140 | 135 | ||
141 | /** | 136 | /** |
142 | * function to call on disconnect events | 137 | * function to call on disconnect events |
143 | */ | 138 | */ |
144 | GNUNET_TRANSPORT_NotifyDisconnecT nd_cb; | 139 | GNUNET_TRANSPORT_NotifyDisconnect nd_cb; |
145 | 140 | ||
146 | /** | 141 | /** |
147 | * function to call on excess bandwidth events | 142 | * function to call on excess bandwidth events |
148 | */ | 143 | */ |
149 | GNUNET_TRANSPORT_NotifyExcessBandwidtH neb_cb; | 144 | GNUNET_TRANSPORT_NotifyExcessBandwidth neb_cb; |
150 | 145 | ||
151 | /** | 146 | /** |
152 | * My client connection to the transport service. | 147 | * My client connection to the transport service. |
@@ -306,44 +301,6 @@ mq_error_handler (void *cls, | |||
306 | 301 | ||
307 | 302 | ||
308 | /** | 303 | /** |
309 | * Function we use for checking incoming HELLO messages. | ||
310 | * | ||
311 | * @param cls closure, a `struct GNUNET_TRANSPORT_CoreHandle *` | ||
312 | * @param msg message received | ||
313 | * @return #GNUNET_OK if message is well-formed | ||
314 | */ | ||
315 | static int | ||
316 | check_hello (void *cls, | ||
317 | const struct GNUNET_MessageHeader *msg) | ||
318 | { | ||
319 | struct GNUNET_PeerIdentity me; | ||
320 | |||
321 | if (GNUNET_OK != | ||
322 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) msg, | ||
323 | &me)) | ||
324 | { | ||
325 | GNUNET_break (0); | ||
326 | return GNUNET_SYSERR; | ||
327 | } | ||
328 | return GNUNET_OK; | ||
329 | } | ||
330 | |||
331 | |||
332 | /** | ||
333 | * Function we use for handling incoming HELLO messages. | ||
334 | * | ||
335 | * @param cls closure, a `struct GNUNET_TRANSPORT_CoreHandle *` | ||
336 | * @param msg message received | ||
337 | */ | ||
338 | static void | ||
339 | handle_hello (void *cls, | ||
340 | const struct GNUNET_MessageHeader *msg) | ||
341 | { | ||
342 | /* we do not care => FIXME: signal in options to NEVER send HELLOs! */ | ||
343 | } | ||
344 | |||
345 | |||
346 | /** | ||
347 | * A message from the handler's message queue to a neighbour was | 304 | * A message from the handler's message queue to a neighbour was |
348 | * transmitted. Now trigger (possibly delayed) notification of the | 305 | * transmitted. Now trigger (possibly delayed) notification of the |
349 | * neighbour's message queue that we are done and thus ready for | 306 | * neighbour's message queue that we are done and thus ready for |
@@ -551,7 +508,8 @@ handle_connect (void *cls, | |||
551 | "Receiving CONNECT message for `%s' with quota %u\n", | 508 | "Receiving CONNECT message for `%s' with quota %u\n", |
552 | GNUNET_i2s (&cim->id), | 509 | GNUNET_i2s (&cim->id), |
553 | ntohl (cim->quota_out.value__)); | 510 | ntohl (cim->quota_out.value__)); |
554 | n = neighbour_find (h, &cim->id); | 511 | n = neighbour_find (h, |
512 | &cim->id); | ||
555 | if (NULL != n) | 513 | if (NULL != n) |
556 | { | 514 | { |
557 | GNUNET_break (0); | 515 | GNUNET_break (0); |
@@ -613,7 +571,8 @@ handle_disconnect (void *cls, | |||
613 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 571 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
614 | "Receiving DISCONNECT message for `%s'.\n", | 572 | "Receiving DISCONNECT message for `%s'.\n", |
615 | GNUNET_i2s (&dim->peer)); | 573 | GNUNET_i2s (&dim->peer)); |
616 | n = neighbour_find (h, &dim->peer); | 574 | n = neighbour_find (h, |
575 | &dim->peer); | ||
617 | if (NULL == n) | 576 | if (NULL == n) |
618 | { | 577 | { |
619 | GNUNET_break (0); | 578 | GNUNET_break (0); |
@@ -647,7 +606,9 @@ handle_send_ok (void *cls, | |||
647 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 606 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
648 | "Receiving SEND_OK message, transmission to %s %s.\n", | 607 | "Receiving SEND_OK message, transmission to %s %s.\n", |
649 | GNUNET_i2s (&okm->peer), | 608 | GNUNET_i2s (&okm->peer), |
650 | ntohl (okm->success) == GNUNET_OK ? "succeeded" : "failed"); | 609 | (GNUNET_OK == ntohl (okm->success)) |
610 | ? "succeeded" | ||
611 | : "failed"); | ||
651 | n = neighbour_find (h, | 612 | n = neighbour_find (h, |
652 | &okm->peer); | 613 | &okm->peer); |
653 | if (NULL == n) | 614 | if (NULL == n) |
@@ -662,8 +623,8 @@ handle_send_ok (void *cls, | |||
662 | { | 623 | { |
663 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 624 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
664 | "Overhead for %u byte message was %u\n", | 625 | "Overhead for %u byte message was %u\n", |
665 | bytes_msg, | 626 | (unsigned int) bytes_msg, |
666 | bytes_physical - bytes_msg); | 627 | (unsigned int) (bytes_physical - bytes_msg)); |
667 | n->traffic_overhead += bytes_physical - bytes_msg; | 628 | n->traffic_overhead += bytes_physical - bytes_msg; |
668 | } | 629 | } |
669 | } | 630 | } |
@@ -677,7 +638,7 @@ handle_send_ok (void *cls, | |||
677 | */ | 638 | */ |
678 | static int | 639 | static int |
679 | check_recv (void *cls, | 640 | check_recv (void *cls, |
680 | const struct InboundMessage *im) | 641 | const struct InboundMessage *im) |
681 | { | 642 | { |
682 | const struct GNUNET_MessageHeader *imm; | 643 | const struct GNUNET_MessageHeader *imm; |
683 | uint16_t size; | 644 | uint16_t size; |
@@ -718,7 +679,8 @@ handle_recv (void *cls, | |||
718 | (unsigned int) ntohs (imm->type), | 679 | (unsigned int) ntohs (imm->type), |
719 | (unsigned int) ntohs (imm->size), | 680 | (unsigned int) ntohs (imm->size), |
720 | GNUNET_i2s (&im->peer)); | 681 | GNUNET_i2s (&im->peer)); |
721 | n = neighbour_find (h, &im->peer); | 682 | n = neighbour_find (h, |
683 | &im->peer); | ||
722 | if (NULL == n) | 684 | if (NULL == n) |
723 | { | 685 | { |
724 | GNUNET_break (0); | 686 | GNUNET_break (0); |
@@ -754,7 +716,7 @@ handle_set_quota (void *cls, | |||
754 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 716 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
755 | "Receiving SET_QUOTA message for `%s' with quota %u\n", | 717 | "Receiving SET_QUOTA message for `%s' with quota %u\n", |
756 | GNUNET_i2s (&qm->peer), | 718 | GNUNET_i2s (&qm->peer), |
757 | ntohl (qm->quota.value__)); | 719 | (unsigned int) ntohl (qm->quota.value__)); |
758 | GNUNET_BANDWIDTH_tracker_update_quota (&n->out_tracker, | 720 | GNUNET_BANDWIDTH_tracker_update_quota (&n->out_tracker, |
759 | qm->quota); | 721 | qm->quota); |
760 | } | 722 | } |
@@ -770,10 +732,6 @@ reconnect (void *cls) | |||
770 | { | 732 | { |
771 | struct GNUNET_TRANSPORT_CoreHandle *h = cls; | 733 | struct GNUNET_TRANSPORT_CoreHandle *h = cls; |
772 | struct GNUNET_MQ_MessageHandler handlers[] = { | 734 | struct GNUNET_MQ_MessageHandler handlers[] = { |
773 | GNUNET_MQ_hd_var_size (hello, | ||
774 | GNUNET_MESSAGE_TYPE_HELLO, | ||
775 | struct GNUNET_MessageHeader, | ||
776 | h), | ||
777 | GNUNET_MQ_hd_fixed_size (connect, | 735 | GNUNET_MQ_hd_fixed_size (connect, |
778 | GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT, | 736 | GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT, |
779 | struct ConnectInfoMessage, | 737 | struct ConnectInfoMessage, |
@@ -826,16 +784,13 @@ reconnect (void *cls) | |||
826 | 784 | ||
827 | 785 | ||
828 | /** | 786 | /** |
829 | * Function that will schedule the job that will try | 787 | * Disconnect from the transport service. |
830 | * to connect us again to the client. | ||
831 | * | 788 | * |
832 | * @param h transport service to reconnect | 789 | * @param h transport service to reconnect |
833 | */ | 790 | */ |
834 | static void | 791 | static void |
835 | disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_CoreHandle *h) | 792 | disconnect (struct GNUNET_TRANSPORT_CoreHandle *h) |
836 | { | 793 | { |
837 | GNUNET_assert (NULL == h->reconnect_task); | ||
838 | /* Forget about all neighbours that we used to be connected to */ | ||
839 | GNUNET_CONTAINER_multipeermap_iterate (h->neighbours, | 794 | GNUNET_CONTAINER_multipeermap_iterate (h->neighbours, |
840 | &neighbour_delete, | 795 | &neighbour_delete, |
841 | h); | 796 | h); |
@@ -844,6 +799,20 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_CoreHandle *h) | |||
844 | GNUNET_MQ_destroy (h->mq); | 799 | GNUNET_MQ_destroy (h->mq); |
845 | h->mq = NULL; | 800 | h->mq = NULL; |
846 | } | 801 | } |
802 | } | ||
803 | |||
804 | |||
805 | /** | ||
806 | * Function that will schedule the job that will try | ||
807 | * to connect us again to the client. | ||
808 | * | ||
809 | * @param h transport service to reconnect | ||
810 | */ | ||
811 | static void | ||
812 | disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_CoreHandle *h) | ||
813 | { | ||
814 | GNUNET_assert (NULL == h->reconnect_task); | ||
815 | disconnect (h); | ||
847 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 816 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
848 | "Scheduling task to reconnect to transport service in %s.\n", | 817 | "Scheduling task to reconnect to transport service in %s.\n", |
849 | GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay, | 818 | GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay, |
@@ -896,9 +865,9 @@ GNUNET_TRANSPORT_core_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
896 | const struct GNUNET_PeerIdentity *self, | 865 | const struct GNUNET_PeerIdentity *self, |
897 | const struct GNUNET_MQ_MessageHandler *handlers, | 866 | const struct GNUNET_MQ_MessageHandler *handlers, |
898 | void *cls, | 867 | void *cls, |
899 | GNUNET_TRANSPORT_NotifyConnecT nc, | 868 | GNUNET_TRANSPORT_NotifyConnect nc, |
900 | GNUNET_TRANSPORT_NotifyDisconnecT nd, | 869 | GNUNET_TRANSPORT_NotifyDisconnect nd, |
901 | GNUNET_TRANSPORT_NotifyExcessBandwidtH neb) | 870 | GNUNET_TRANSPORT_NotifyExcessBandwidth neb) |
902 | { | 871 | { |
903 | struct GNUNET_TRANSPORT_CoreHandle *h; | 872 | struct GNUNET_TRANSPORT_CoreHandle *h; |
904 | unsigned int i; | 873 | unsigned int i; |
@@ -951,8 +920,7 @@ GNUNET_TRANSPORT_core_disconnect (struct GNUNET_TRANSPORT_CoreHandle *handle) | |||
951 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 920 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
952 | "Transport disconnect called!\n"); | 921 | "Transport disconnect called!\n"); |
953 | /* this disconnects all neighbours... */ | 922 | /* this disconnects all neighbours... */ |
954 | if (NULL == handle->reconnect_task) | 923 | disconnect (handle); |
955 | disconnect_and_schedule_reconnect (handle); | ||
956 | /* and now we stop trying to connect again... */ | 924 | /* and now we stop trying to connect again... */ |
957 | if (NULL != handle->reconnect_task) | 925 | if (NULL != handle->reconnect_task) |
958 | { | 926 | { |
diff --git a/src/transport/transport_api_core.c b/src/transport/transport_api_core.c index b7edc3cc1..5310054fd 100644 --- a/src/transport/transport_api_core.c +++ b/src/transport/transport_api_core.c | |||
@@ -136,17 +136,17 @@ struct GNUNET_TRANSPORT_CoreHandle | |||
136 | /** | 136 | /** |
137 | * function to call on connect events | 137 | * function to call on connect events |
138 | */ | 138 | */ |
139 | GNUNET_TRANSPORT_NotifyConnecT nc_cb; | 139 | GNUNET_TRANSPORT_NotifyConnect nc_cb; |
140 | 140 | ||
141 | /** | 141 | /** |
142 | * function to call on disconnect events | 142 | * function to call on disconnect events |
143 | */ | 143 | */ |
144 | GNUNET_TRANSPORT_NotifyDisconnecT nd_cb; | 144 | GNUNET_TRANSPORT_NotifyDisconnect nd_cb; |
145 | 145 | ||
146 | /** | 146 | /** |
147 | * function to call on excess bandwidth events | 147 | * function to call on excess bandwidth events |
148 | */ | 148 | */ |
149 | GNUNET_TRANSPORT_NotifyExcessBandwidtH neb_cb; | 149 | GNUNET_TRANSPORT_NotifyExcessBandwidth neb_cb; |
150 | 150 | ||
151 | /** | 151 | /** |
152 | * My client connection to the transport service. | 152 | * My client connection to the transport service. |
@@ -896,9 +896,9 @@ GNUNET_TRANSPORT_core_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
896 | const struct GNUNET_PeerIdentity *self, | 896 | const struct GNUNET_PeerIdentity *self, |
897 | const struct GNUNET_MQ_MessageHandler *handlers, | 897 | const struct GNUNET_MQ_MessageHandler *handlers, |
898 | void *cls, | 898 | void *cls, |
899 | GNUNET_TRANSPORT_NotifyConnecT nc, | 899 | GNUNET_TRANSPORT_NotifyConnect nc, |
900 | GNUNET_TRANSPORT_NotifyDisconnecT nd, | 900 | GNUNET_TRANSPORT_NotifyDisconnect nd, |
901 | GNUNET_TRANSPORT_NotifyExcessBandwidtH neb) | 901 | GNUNET_TRANSPORT_NotifyExcessBandwidth neb) |
902 | { | 902 | { |
903 | struct GNUNET_TRANSPORT_CoreHandle *h; | 903 | struct GNUNET_TRANSPORT_CoreHandle *h; |
904 | unsigned int i; | 904 | unsigned int i; |