GNUnet 0.28.1-dev.4-47-g3e168ca2d
 
Loading...
Searching...
No Matches
transport_api_core.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009-2013, 2016, 2018 GNUnet e.V.
4
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
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_constants.h"
29#include "gnunet_arm_service.h"
30#include "gnunet_protocols.h"
32#include "transport.h"
33
34#define LOG(kind, ...) GNUNET_log_from (kind, "transport-api-core", __VA_ARGS__)
35
39#define STARTING_NEIGHBOURS_SIZE 16
40
49#define SEND_WINDOW_SIZE 4
50
51
55struct Neighbour
56{
61
66
71
76
81
86 unsigned int ready_window;
87
96
100 uint16_t env_size;
101};
102
103
173
174
181static void
183
184
192static struct Neighbour *
194 const struct GNUNET_PeerIdentity *peer)
195{
196 return GNUNET_CONTAINER_multipeermap_get (h->neighbours, peer);
197}
198
199
210static int
211neighbour_delete (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
212{
214 struct Neighbour *n = value;
215
217 "Dropping entry for neighbour `%s'.\n",
218 GNUNET_i2s (key));
219 if (NULL != handle->nd_cb)
220 handle->nd_cb (handle->cls, &n->id, n->handlers_cls);
221 if (NULL != n->env)
222 {
224 n->env = NULL;
225 }
227 GNUNET_assert (NULL == n->mq);
229 GNUNET_YES ==
231 GNUNET_free (n);
232 return GNUNET_YES;
233}
234
235
245static void
246mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
247{
249
251 "Error %u received from transport service, disconnecting temporarily.\n",
252 error);
254}
255
256
267static void
269{
270 struct Neighbour *n = cls;
271
273 n->env = NULL;
274 if (0 < n->ready_window)
276}
277
278
285static void
287{
289 GNUNET_assert (NULL != n->env);
290 n->ready_window--;
293 GNUNET_MQ_send (n->h->mq, n->env);
295 "Passed message of type %u for neighbour `%s' to TRANSPORT. ready_window %u\n",
296 ntohs (GNUNET_MQ_env_get_msg (n->env)->type),
297 GNUNET_i2s (&n->id),
298 n->ready_window);
299}
300
301
312static void
314 const struct GNUNET_MessageHeader *msg,
315 void *impl_state)
316{
317 struct Neighbour *n = impl_state;
318 struct OutboundMessage *obm;
319 uint16_t msize;
320
321 msize = ntohs (msg->size);
322 if (msize >= GNUNET_MAX_MESSAGE_SIZE - sizeof(*obm))
323 {
324 GNUNET_break (0);
326 return;
327 }
329 "CORE requested transmission of message of type %u to neighbour `%s'.\n",
330 ntohs (msg->type),
331 GNUNET_i2s (&n->id));
332
333 GNUNET_assert (NULL == n->env);
334 n->env =
336 n->env_size = ntohs (msg->size);
337 {
338 struct GNUNET_MQ_Envelope *env;
340
343 obm->priority = htonl ((uint32_t) prio);
344 }
345 obm->peer = n->id;
346 if (0 == n->ready_window)
347 {
349 "Flow control delays transmission to CORE until we see SEND_OK.\n");
350 return; /* can't send yet, need to wait for SEND_OK */
351 }
352 do_send (n);
353}
354
355
363static void
364mq_destroy_impl (struct GNUNET_MQ_Handle *mq, void *impl_state)
365{
366 struct Neighbour *n = impl_state;
367
368 GNUNET_assert (mq == n->mq);
369 n->mq = NULL;
370}
371
372
380static void
381mq_cancel_impl (struct GNUNET_MQ_Handle *mq, void *impl_state)
382{
383 struct Neighbour *n = impl_state;
384
385 n->ready_window++;
386 if (GNUNET_YES == n->awaiting_done)
387 {
389 n->env = NULL;
391 }
392 else
393 {
394 GNUNET_assert (0 == n->ready_window);
395 n->env = NULL;
396 }
397}
398
399
408static void
410{
411 struct Neighbour *n = cls;
412
413 if (GNUNET_MQ_ERROR_MALFORMED == error)
414 GNUNET_break_op (0);
415 // TODO Look into bug #7887
416
417 GNUNET_TRANSPORT_core_receive_continue (n->h, &n->id);
418}
419
420
427static void
428handle_connect (void *cls, const struct ConnectInfoMessage *cim)
429{
431 struct Neighbour *n;
432
434 "Receiving CONNECT message for `%s'\n",
435 GNUNET_i2s (&cim->id));
436 n = neighbour_find (h, &cim->id);
437 if (NULL != n)
438 {
439 GNUNET_break (0);
441 return;
442 }
443 n = GNUNET_new (struct Neighbour);
444 n->id = cim->id;
445 n->h = h;
449 h->neighbours,
450 &n->id,
451 n,
453
457 n,
458 h->handlers,
460 n);
461 if (NULL != h->nc_cb)
462 {
463 n->handlers_cls = h->nc_cb (h->cls, &n->id, n->mq);
465 }
466}
467
468
475static void
477{
479 struct Neighbour *n;
480
481 GNUNET_break (ntohl (dim->reserved) == 0);
483 "Receiving DISCONNECT message for `%s'.\n",
484 GNUNET_i2s (&dim->peer));
485 n = neighbour_find (h, &dim->peer);
486 if (NULL == n)
487 {
488 GNUNET_break (0);
490 return;
491 }
493}
494
495
502static void
503handle_send_ok (void *cls, const struct SendOkMessage *okm)
504{
506 struct Neighbour *n;
507
509 "Receiving SEND_OK message for transmission to %s\n",
510 GNUNET_i2s (&okm->peer));
511
512 n = neighbour_find (h, &okm->peer);
513
514 if (NULL == n)
515 {
516 /* A SEND_OK returns one unit of *this peer's* send window, and that
517 window lives in the `struct Neighbour' we just failed to find. So a
518 SEND_OK for a peer we already dropped has nothing left to credit and
519 nothing left to break: it is a message that was in flight when the
520 DISCONNECT overtook it, which is ordinary and not the service
521 misbehaving.
522 It used to reconnect here, which threw away every *other* neighbour
523 too and forced a fresh key exchange with all of them -- turning one
524 raced link teardown into a full-mesh outage. Ignore it instead. */
526 "Discarding SEND_OK for `%s', not connected (anymore)\n",
527 GNUNET_i2s (&okm->peer));
528 return;
529 }
530
531 if ((GNUNET_NO == n->awaiting_done) &&
532 (NULL != n->env) &&
533 (0 == n->ready_window))
534 {
535 n->ready_window++;
536 do_send (n);
537 return;
538 }
539 else if ((GNUNET_NO == n->awaiting_done) &&
540 (0 == n->ready_window))
541 {
542 n->ready_window++;
544 return;
545 }
546 n->ready_window++;
547}
548
549
556static int
557check_recv (void *cls, const struct InboundMessage *im)
558{
559 const struct GNUNET_MessageHeader *imm;
560 uint16_t size;
561
563 "check_recv\n");
564 size = ntohs (im->header.size) - sizeof(*im);
565 if (size < sizeof(struct GNUNET_MessageHeader))
566 {
567 GNUNET_break (0);
568 return GNUNET_SYSERR;
569 }
570 imm = (const struct GNUNET_MessageHeader *) &im[1];
571 if (ntohs (imm->size) != size)
572 {
573 GNUNET_break (0);
574 return GNUNET_SYSERR;
575 }
576 return GNUNET_OK;
577}
578
579
586static void
587handle_recv (void *cls, const struct InboundMessage *im)
588{
590 const struct GNUNET_MessageHeader *imm =
591 (const struct GNUNET_MessageHeader *) &im[1];
592 struct Neighbour *n;
593
595 "Received message of type %u with %u bytes from `%s'.\n",
596 (unsigned int) ntohs (imm->type),
597 (unsigned int) ntohs (imm->size),
598 GNUNET_i2s (&im->peer));
599 n = neighbour_find (h, &im->peer);
600 if (NULL == n)
601 {
602 GNUNET_break (0);
604 return;
605 }
607}
608
609
615static void
616reconnect (void *cls)
617{
620 { GNUNET_MQ_hd_fixed_size (connect,
622 struct ConnectInfoMessage,
623 h),
627 h),
630 struct SendOkMessage,
631 h),
634 struct InboundMessage,
635 h),
637 struct GNUNET_MQ_Envelope *env;
638 struct StartMessage *s;
639 uint32_t options;
640
641 h->reconnect_task = NULL;
642 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service.\n");
643 GNUNET_assert (NULL == h->mq);
644 h->mq =
646 h->restarted_at = GNUNET_TIME_absolute_get ();
647 if (NULL == h->mq)
648 return;
650 options = 0;
651 if (h->check_self)
652 options |= 1;
653 if (NULL != h->handlers)
654 options |= 2;
655 s->options = htonl (options);
656 s->self = h->self;
658}
659
660
666static void
668{
670 if (NULL != h->mq)
671 {
673 h->mq = NULL;
674 }
675}
676
677
684static void
686{
687 GNUNET_assert (NULL == h->reconnect_task);
688 disconnect (h);
689 {
690 /* Reduce delay based on runtime of the connection,
691 so that there is a cool-down if a connection is up
692 for a while. */
693 struct GNUNET_TIME_Relative runtime;
694 unsigned int minutes;
695
696 runtime = GNUNET_TIME_absolute_get_duration (h->restarted_at);
697 minutes = runtime.rel_value_us / GNUNET_TIME_UNIT_MINUTES.rel_value_us;
698 if (minutes > 31)
699 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
700 else
701 h->reconnect_delay.rel_value_us >>= minutes;
702 }
704 "Scheduling task to reconnect to transport service in %s.\n",
707 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
708 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
709}
710
711
719struct GNUNET_MQ_Handle *
721 const struct GNUNET_PeerIdentity *peer)
722{
723 struct Neighbour *n;
724
725 n = neighbour_find (handle, peer);
726 if (NULL == n)
727 return NULL;
728 return n->mq;
729}
730
731
752void
753GNUNET_TRANSPORT_core_receive_continue (struct GNUNET_TRANSPORT_CoreHandle *ch,
754 const struct GNUNET_PeerIdentity *pid)
755{
756 struct GNUNET_MQ_Envelope *env;
757 struct RecvOkMessage *rok;
758
760 "Message for %s finished CORE processing, sending RECV_OK.\n",
761 GNUNET_i2s (pid));
762 if (NULL == ch->mq)
763 return;
765 rok->increase_window_delta = htonl (1);
766 rok->peer = *pid;
768}
769
770
786 const struct GNUNET_PeerIdentity *self, // XXX
788 void *cls,
791{
793 unsigned int i;
794
796 if (NULL != self)
797 {
798 h->self = *self;
799 h->check_self = GNUNET_YES;
800 }
801 h->cfg = cfg;
802 h->cls = cls;
803 h->nc_cb = nc;
804 h->nd_cb = nd;
805 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
806 if (NULL != handlers)
807 {
808 for (i = 0; NULL != handlers[i].cb; i++)
809 ;
810 h->handlers = GNUNET_new_array (i + 1, struct GNUNET_MQ_MessageHandler);
811 GNUNET_memcpy (h->handlers,
812 handlers,
813 i * sizeof(struct GNUNET_MQ_MessageHandler));
814 }
815 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service\n");
816 reconnect (h);
817 if (NULL == h->mq)
818 {
819 GNUNET_free (h->handlers);
820 GNUNET_free (h);
821 return NULL;
822 }
823 h->neighbours =
825 return h;
826}
827
828
835void
837{
838 LOG (GNUNET_ERROR_TYPE_DEBUG, "Transport disconnect called!\n");
839 /* this disconnects all neighbours... */
841 /* and now we stop trying to connect again... */
842 if (NULL != handle->reconnect_task)
843 {
844 GNUNET_SCHEDULER_cancel (handle->reconnect_task);
845 handle->reconnect_task = NULL;
846 }
848 handle->neighbours = NULL;
849 GNUNET_free (handle->handlers);
850 handle->handlers = NULL;
852}
853
854
855/* end of transport_api_core.c */
struct GNUNET_GETOPT_CommandLineOption options[]
Definition 002.c:5
struct GNUNET_MQ_MessageHandlers handlers[]
Definition 003.c:1
struct GNUNET_MessageHeader * msg
Definition 005.c:2
struct GNUNET_MQ_Envelope * env
Definition 005.c:1
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition gnunet-arm.c:98
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
static struct GNUNET_CADET_Channel * ch
Channel handle.
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.
static struct GNUNET_NotificationContext * nc
Notification context for broadcasting to monitors.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition gnunet-vpn.c:35
uint32_t dim
Constants for network protocols.
API of the transport service towards the CORE service (TNG version)
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
struct GNUNET_TRANSPORT_CoreHandle * GNUNET_TRANSPORT_core_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *self, const struct GNUNET_MQ_MessageHandler *handlers, void *cls, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd)
Connect to the transport service.
void(* GNUNET_TRANSPORT_NotifyDisconnect)(void *cls, const struct GNUNET_PeerIdentity *peer, void *handler_cls)
Function called to notify transport users that another peer disconnected from us.
void *(* GNUNET_TRANSPORT_NotifyConnect)(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Function called to notify transport users that another peer connected to us.
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition client.c:1182
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_send_cancel(struct GNUNET_MQ_Envelope *ev)
Cancel sending the message.
Definition mq.c:817
GNUNET_MQ_Error
Error codes for the queue.
struct GNUNET_MQ_Handle * GNUNET_MQ_queue_for_callbacks(GNUNET_MQ_SendImpl send, GNUNET_MQ_DestroyImpl destroy, GNUNET_MQ_CancelImpl cancel, void *impl_state, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *cls)
Create a message queue for the specified handlers.
Definition mq.c:514
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition mq.c:337
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_nested_mh(mvar, type, mh)
Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct.
void GNUNET_MQ_impl_send_continue(struct GNUNET_MQ_Handle *mq)
Call the send implementation for the next queued message, if any.
Definition mq.c:469
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
void GNUNET_MQ_inject_message(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *mh)
Call the message message handler that was registered for the type of the given message in the given m...
Definition mq.c:187
GNUNET_MQ_PriorityPreferences
Per envelope preferences and priorities.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
Definition mq.c:687
const struct GNUNET_MessageHeader * GNUNET_MQ_env_get_msg(const struct GNUNET_MQ_Envelope *env)
Obtain message contained in envelope.
Definition mq.c:928
enum GNUNET_MQ_PriorityPreferences GNUNET_MQ_env_get_options(struct GNUNET_MQ_Envelope *env)
Get performance preferences set for this envelope.
Definition mq.c:888
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_set_handlers_closure(struct GNUNET_MQ_Handle *mq, void *handlers_cls)
Change the closure argument in all of the handlers of the mq.
Definition mq.c:538
struct GNUNET_MQ_Envelope * GNUNET_MQ_get_current_envelope(struct GNUNET_MQ_Handle *mq)
Function to obtain the current envelope from within GNUNET_MQ_SendImpl implementations.
Definition mq.c:862
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition mq.c:732
@ GNUNET_MQ_ERROR_MALFORMED
We received a message that was malformed and thus could not be passed to its handler.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
Message from TRANSPORT notifying about a client that connected to us.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_START
Message from the core saying that the transport server should start giving it messages.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_RECV_OK
Message telling transport to limit its receive rate.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
Message from TRANSPORT notifying about a message that was received.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
Message from TRANSPORT notifying about a client that disconnected from us.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND
Request to TRANSPORT to transmit a message.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
Confirmation from TRANSPORT that message for transmission has been queued (and that the next message ...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:986
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition scheduler.c:1283
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition time.c:438
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition strings.c:610
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition time.c:111
#define GNUNET_TIME_UNIT_MINUTES
One minute.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static unsigned int size
Size of the "table".
Definition peer.c:68
static void reconnect(void)
Adjust exponential back-off and reconnect to the service.
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown.
Message from the transport service to the library informing about neighbors.
Definition transport.h:90
struct GNUNET_PeerIdentity id
Identity of the new neighbour.
Definition transport.h:113
Message from the transport service to the library informing about disconnects.
Definition transport.h:122
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition arm_api.c:107
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition arm_api.c:112
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
Definition arm_api.c:147
struct GNUNET_MQ_Handle * mq
Message Queue for the channel (which we are implementing).
Definition cadet.h:142
Internal representation of the hash map.
Handle to a message queue.
Definition mq.c:87
Message handler for a specific message type.
Header for all communications.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Definition scheduler.c:141
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Handle for the transport service (includes all of the state for the transport service).
int check_self
Should we check that self matches what the service thinks? (if GNUNET_NO, then self is all zeros!...
struct GNUNET_PeerIdentity self
Peer identity as assumed by this process, or all zeros.
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the task trying to reconnect to the service.
GNUNET_TRANSPORT_NotifyDisconnect nd_cb
function to call on disconnect events
struct GNUNET_MQ_MessageHandler * handlers
Functions to call for received data (template for new message queues).
void * cls
Closure for the callbacks.
struct GNUNET_CONTAINER_MultiPeerMap * neighbours
Hash map of the current connected neighbours of this peer.
GNUNET_TRANSPORT_NotifyConnect nc_cb
function to call on connect events
struct GNUNET_TIME_Relative reconnect_delay
Delay until we try to reconnect.
const struct GNUNET_CONFIGURATION_Handle * cfg
My configuration.
struct GNUNET_MQ_Handle * mq
My client connection to the transport service.
struct GNUNET_TIME_Absolute restarted_at
Transport connection started at.
Message used to notify the transport API about a message received from the network.
Definition transport.h:145
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV.
Definition transport.h:149
struct GNUNET_PeerIdentity peer
Which peer sent the message?
Definition transport.h:154
A neighbour that at least one communicator is connected to.
uint16_t env_size
Size of the message in env.
int16_t awaiting_done
Used to indicate our status if env is non-NULL.
struct GNUNET_MQ_Envelope * env
Envelope with the message we are currently transmitting (or NULL).
void * handlers_cls
Closure for mq handlers.
unsigned int ready_window
How many messages can we still send to this peer before we should throttle?
struct GNUNET_PeerIdentity id
Identity of this neighbour.
struct GNUNET_TRANSPORT_CoreHandle * h
Overall transport handle.
struct GNUNET_MQ_Handle * mq
Active message queue for the peer.
struct GNUNET_PeerIdentity pid
Which peer is this about?
Message used to notify the transport service about a message to be transmitted to another peer.
Definition transport.h:231
uint32_t priority
An enum GNUNET_MQ_PriorityPreferences in NBO.
Definition transport.h:240
struct GNUNET_PeerIdentity peer
Which peer should receive the message?
Definition transport.h:254
Message used to notify the transport API that it can send another message to the transport service.
Definition transport.h:207
struct GNUNET_PeerIdentity peer
Which peer can CORE handle more from now?
Definition transport.h:222
uint32_t increase_window_delta
Number of messages by which to increase the window, greater or equal to one.
Definition transport.h:217
Message used to notify the transport API that it can send another message to the transport service.
Definition transport.h:163
struct GNUNET_PeerIdentity peer
Which peer can send more now?
Definition transport.h:197
Message from the transport service to the library asking to check if both processes agree about this ...
Definition transport.h:63
uint32_t options
0: no options 1: The self field should be checked 2: this client is interested in payload traffic
Definition transport.h:74
struct GNUNET_PeerIdentity self
Identity we think we have.
Definition transport.h:81
common internal definitions for transport service
static int neighbour_delete(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries, for deleting state of a neighbour.
static void handle_connect(void *cls, const struct ConnectInfoMessage *cim)
Function we use for handling incoming connect messages.
static void peer_mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
We had an error processing a message we forwarded from a peer to the CORE service.
static void disconnect(struct GNUNET_TRANSPORT_CoreHandle *h)
Disconnect from the transport service.
static void do_send(struct Neighbour *n)
We have an envelope waiting for transmission at n, and our transmission window is positive.
static void handle_disconnect(void *cls, const struct DisconnectInfoMessage *dim)
Function we use for handling incoming disconnect messages.
static void handle_send_ok(void *cls, const struct SendOkMessage *okm)
Function we use for handling incoming send-ok messages.
static int check_recv(void *cls, const struct InboundMessage *im)
Function we use for checking incoming "inbound" messages.
static void disconnect_and_schedule_reconnect(struct GNUNET_TRANSPORT_CoreHandle *h)
Function that will schedule the job that will try to connect us again to the client.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
static void notify_send_done(void *cls)
A message from the handler's message queue to a neighbour was transmitted.
static void mq_destroy_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
Handle destruction of a message queue.
static struct Neighbour * neighbour_find(struct GNUNET_TRANSPORT_CoreHandle *h, const struct GNUNET_PeerIdentity *peer)
Get the neighbour list entry for the given peer.
#define STARTING_NEIGHBOURS_SIZE
How large to start with for the hashmap of neighbours.
#define SEND_WINDOW_SIZE
Window size.
static void mq_cancel_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
Implementation function that cancels the currently sent message.
#define LOG(kind,...)
struct GNUNET_MQ_Handle * GNUNET_TRANSPORT_core_get_mq(struct GNUNET_TRANSPORT_CoreHandle *handle, const struct GNUNET_PeerIdentity *peer)
Checks if a given peer is connected to us and get the message queue.
static void handle_recv(void *cls, const struct InboundMessage *im)
Function we use for handling incoming messages.
static void mq_send_impl(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *msg, void *impl_state)
Implement sending functionality of a message queue.