GNUnet  0.10.x
transport_api2_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_hello_lib.h"
31 #include "gnunet_protocols.h"
33 #include "transport.h"
34 
35 #define LOG(kind, ...) GNUNET_log_from(kind, "transport-api-core", __VA_ARGS__)
36 
40 #define STARTING_NEIGHBOURS_SIZE 16
41 
50 #define SEND_WINDOW_SIZE 4
51 
52 
56 struct Neighbour {
61 
66 
71 
76 
80  void *handlers_cls;
81 
86  unsigned int ready_window;
87 
95  int16_t awaiting_done;
96 
100  uint16_t env_size;
101 };
102 
103 
112  void *cls;
113 
119 
124 
129 
134 
139 
145 
149  struct GNUNET_PeerIdentity self;
150 
155 
159  struct GNUNET_TIME_Relative reconnect_delay;
160 
166 };
167 
168 
175 static void
177 
178 
186 static struct Neighbour *
188  const struct GNUNET_PeerIdentity *peer)
189 {
191 }
192 
193 
204 static int
205 neighbour_delete(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
206 {
208  struct Neighbour *n = value;
209 
211  "Dropping entry for neighbour `%s'.\n",
212  GNUNET_i2s(key));
213  if (NULL != handle->nd_cb)
214  handle->nd_cb(handle->cls, &n->id, n->handlers_cls);
215  if (NULL != n->env)
216  {
218  n->env = NULL;
219  }
220  GNUNET_MQ_destroy(n->mq);
221  GNUNET_assert(NULL == n->mq);
223  GNUNET_YES ==
225  GNUNET_free(n);
226  return GNUNET_YES;
227 }
228 
229 
239 static void
240 mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
241 {
243 
245  "Error receiving from transport service, disconnecting temporarily.\n");
247 }
248 
249 
260 static void
262 {
263  struct Neighbour *n = cls;
264 
266  n->env = NULL;
268 }
269 
270 
277 static void
278 do_send(struct Neighbour *n)
279 {
280  GNUNET_assert(0 < n->ready_window);
281  GNUNET_assert(NULL != n->env);
282  n->ready_window--;
285  GNUNET_MQ_send(n->h->mq, n->env);
287  "Passed message of type %u for neighbour `%s' to TRANSPORT.\n",
288  ntohs(GNUNET_MQ_env_get_msg(n->env)->type),
289  GNUNET_i2s(&n->id));
290 }
291 
292 
303 static void
305  const struct GNUNET_MessageHeader *msg,
306  void *impl_state)
307 {
308  struct Neighbour *n = impl_state;
309  struct OutboundMessage *obm;
310  uint16_t msize;
311 
312  msize = ntohs(msg->size);
313  if (msize >= GNUNET_MAX_MESSAGE_SIZE - sizeof(*obm))
314  {
315  GNUNET_break(0);
317  return;
318  }
320  "CORE requested transmission of message of type %u to neighbour `%s'.\n",
321  ntohs(msg->type),
322  GNUNET_i2s(&n->id));
323 
324  GNUNET_assert(NULL == n->env);
325  n->env =
327  n->env_size = ntohs(msg->size);
328  {
329  struct GNUNET_MQ_Envelope *env;
330 
332  obm->priority = htonl((uint32_t)GNUNET_MQ_env_get_options(env));
333  }
334  obm->peer = n->id;
335  if (0 == n->ready_window)
336  {
338  "Flow control delays transmission to CORE until we see SEND_OK.\n");
339  return; /* can't send yet, need to wait for SEND_OK */
340  }
341  do_send(n);
342 }
343 
344 
352 static void
353 mq_destroy_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
354 {
355  struct Neighbour *n = impl_state;
356 
357  GNUNET_assert(mq == n->mq);
358  n->mq = NULL;
359 }
360 
361 
369 static void
370 mq_cancel_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
371 {
372  struct Neighbour *n = impl_state;
373 
374  n->ready_window++;
375  if (GNUNET_YES == n->awaiting_done)
376  {
378  n->env = NULL;
380  }
381  else
382  {
383  GNUNET_assert(0 == n->ready_window);
384  n->env = NULL;
385  }
386 }
387 
388 
397 static void
399 {
400  /* struct Neighbour *n = cls; */
401 
402  GNUNET_break_op(0);
403 }
404 
405 
412 static void
413 handle_connect(void *cls, const struct ConnectInfoMessage *cim)
414 {
416  struct Neighbour *n;
417 
419  "Receiving CONNECT message for `%s'\n",
420  GNUNET_i2s(&cim->id));
421  n = neighbour_find(h, &cim->id);
422  if (NULL != n)
423  {
424  GNUNET_break(0);
426  return;
427  }
428  n = GNUNET_new(struct Neighbour);
429  n->id = cim->id;
430  n->h = h;
434  h->neighbours,
435  &n->id,
436  n,
438 
442  n,
443  h->handlers,
445  n);
446  if (NULL != h->nc_cb)
447  {
448  n->handlers_cls = h->nc_cb(h->cls, &n->id, n->mq);
450  }
451 }
452 
453 
460 static void
461 handle_disconnect(void *cls, const struct DisconnectInfoMessage *dim)
462 {
464  struct Neighbour *n;
465 
466  GNUNET_break(ntohl(dim->reserved) == 0);
468  "Receiving DISCONNECT message for `%s'.\n",
469  GNUNET_i2s(&dim->peer));
470  n = neighbour_find(h, &dim->peer);
471  if (NULL == n)
472  {
473  GNUNET_break(0);
475  return;
476  }
478 }
479 
480 
487 static void
488 handle_send_ok(void *cls, const struct SendOkMessage *okm)
489 {
491  struct Neighbour *n;
492 
494  "Receiving SEND_OK message for transmission to %s\n",
495  GNUNET_i2s(&okm->peer));
496  n = neighbour_find(h, &okm->peer);
497  if (NULL == n)
498  {
499  /* We should never get a 'SEND_OK' for a peer that we are not
500  connected to */
501  GNUNET_break(0);
503  return;
504  }
505  n->ready_window++;
506  if ((NULL != n->env) && (1 == n->ready_window))
507  do_send(n);
508 }
509 
510 
517 static int
518 check_recv(void *cls, const struct InboundMessage *im)
519 {
520  const struct GNUNET_MessageHeader *imm;
521  uint16_t size;
522 
523  size = ntohs(im->header.size) - sizeof(*im);
524  if (size < sizeof(struct GNUNET_MessageHeader))
525  {
526  GNUNET_break(0);
527  return GNUNET_SYSERR;
528  }
529  imm = (const struct GNUNET_MessageHeader *)&im[1];
530  if (ntohs(imm->size) != size)
531  {
532  GNUNET_break(0);
533  return GNUNET_SYSERR;
534  }
535  return GNUNET_OK;
536 }
537 
538 
545 static void
546 handle_recv(void *cls, const struct InboundMessage *im)
547 {
549  const struct GNUNET_MessageHeader *imm =
550  (const struct GNUNET_MessageHeader *)&im[1];
551  struct Neighbour *n;
552 
554  "Received message of type %u with %u bytes from `%s'.\n",
555  (unsigned int)ntohs(imm->type),
556  (unsigned int)ntohs(imm->size),
557  GNUNET_i2s(&im->peer));
558  n = neighbour_find(h, &im->peer);
559  if (NULL == n)
560  {
561  GNUNET_break(0);
563  return;
564  }
565  GNUNET_MQ_inject_message(n->mq, imm);
566 }
567 
568 
574 static void
575 reconnect(void *cls)
576 {
578  struct GNUNET_MQ_MessageHandler handlers[] =
579  { GNUNET_MQ_hd_fixed_size(connect,
581  struct ConnectInfoMessage,
582  h),
585  struct DisconnectInfoMessage,
586  h),
587  GNUNET_MQ_hd_fixed_size(send_ok,
589  struct SendOkMessage,
590  h),
593  struct InboundMessage,
594  h),
596  struct GNUNET_MQ_Envelope *env;
597  struct StartMessage *s;
598  uint32_t options;
599 
600  h->reconnect_task = NULL;
601  LOG(GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service.\n");
602  GNUNET_assert(NULL == h->mq);
603  h->mq =
604  GNUNET_CLIENT_connect(h->cfg, "transport", handlers, &mq_error_handler, h);
605  if (NULL == h->mq)
606  return;
608  options = 0;
609  if (h->check_self)
610  options |= 1;
611  if (NULL != h->handlers)
612  options |= 2;
613  s->options = htonl(options);
614  s->self = h->self;
615  GNUNET_MQ_send(h->mq, env);
616 }
617 
618 
624 static void
626 {
628  if (NULL != h->mq)
629  {
630  GNUNET_MQ_destroy(h->mq);
631  h->mq = NULL;
632  }
633 }
634 
635 
642 static void
644 {
645  GNUNET_assert(NULL == h->reconnect_task);
646  disconnect(h);
648  "Scheduling task to reconnect to transport service in %s.\n",
650  h->reconnect_task =
653 }
654 
655 
663 struct GNUNET_MQ_Handle *
665  const struct GNUNET_PeerIdentity *peer)
666 {
667  struct Neighbour *n;
668 
669  n = neighbour_find(handle, peer);
670  if (NULL == n)
671  return NULL;
672  return n->mq;
673 }
674 
675 
696 void
697 GNUNET_TRANSPORT_core_receive_continue(struct GNUNET_TRANSPORT_CoreHandle *ch,
698  const struct GNUNET_PeerIdentity *pid)
699 {
700  struct GNUNET_MQ_Envelope *env;
701  struct RecvOkMessage *rok;
702 
704  "Message for %s finished CORE processing, sending RECV_OK.\n",
705  GNUNET_i2s(pid));
706  if (NULL == ch->mq)
707  return;
709  rok->increase_window_delta = htonl(1);
710  rok->peer = *pid;
711  GNUNET_MQ_send(ch->mq, env);
712 }
713 
714 
730  const struct GNUNET_PeerIdentity *self,
731  const struct GNUNET_MQ_MessageHandler *handlers,
732  void *cls,
735 {
737  unsigned int i;
738 
740  if (NULL != self)
741  {
742  h->self = *self;
743  h->check_self = GNUNET_YES;
744  }
745  h->cfg = cfg;
746  h->cls = cls;
747  h->nc_cb = nc;
748  h->nd_cb = nd;
750  if (NULL != handlers)
751  {
752  for (i = 0; NULL != handlers[i].cb; i++)
753  ;
756  handlers,
757  i * sizeof(struct GNUNET_MQ_MessageHandler));
758  }
759  LOG(GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service\n");
760  reconnect(h);
761  if (NULL == h->mq)
762  {
764  GNUNET_free(h);
765  return NULL;
766  }
767  h->neighbours =
769  return h;
770 }
771 
772 
779 void
781 {
782  LOG(GNUNET_ERROR_TYPE_DEBUG, "Transport disconnect called!\n");
783  /* this disconnects all neighbours... */
784  disconnect(handle);
785  /* and now we stop trying to connect again... */
786  if (NULL != handle->reconnect_task)
787  {
789  handle->reconnect_task = NULL;
790  }
792  handle->neighbours = NULL;
794  handle->handlers = NULL;
795  GNUNET_free(handle);
796 }
797 
798 
799 /* end of transport_api_core.c */
struct GNUNET_MQ_MessageHandler * handlers
Functions to call for received data (template for new message queues).
A connected controller which is not our child.
struct GNUNET_PeerIdentity id
Identity of the new neighbour.
Definition: transport.h:139
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
static void reconnect(void *cls)
Try again to connect to transport service.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
void * cls
Closure for the callbacks.
const struct GNUNET_MessageHeader * GNUNET_MQ_env_get_msg(const struct GNUNET_MQ_Envelope *env)
Obtain message contained in envelope.
Definition: mq.c:1077
Message used to notify the transport API that it can send another message to the transport service...
Definition: transport.h:254
uint32_t priority
An enum GNUNET_MQ_PriorityPreferences in NBO.
Definition: transport.h:286
common internal definitions for transport service
static void handle_disconnect(void *cls, const struct DisconnectInfoMessage *dim)
Function we use for handling incoming disconnect messages.
void * handlers_cls
Closure for mq handlers.
GNUNET_TRANSPORT_NotifyDisconnect nd_cb
function to call on disconnect events
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define GNUNET_MESSAGE_TYPE_TRANSPORT_RECV_OK
Message telling transport to limit its receive rate.
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:900
#define GNUNET_MQ_msg_nested_mh(mvar, type, mh)
Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct...
GNUNET_MQ_Error
Error codes for the queue.
struct GNUNET_TRANSPORT_CoreHandle * h
Overall transport handle.
struct GNUNET_MQ_Handle * mq
Active message queue for the peer.
const struct GNUNET_CONFIGURATION_Handle * cfg
My configuration.
struct GNUNET_PeerIdentity peer
Which peer should receive the message?
Definition: transport.h:300
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_Handle * mq
My client connection to the transport service.
struct GNUNET_PeerIdentity peer
Which peer can CORE handle more from now?
Definition: transport.h:269
static void notify_send_done(void *cls)
A message from the handler&#39;s message queue to a neighbour was transmitted.
static void disconnect(struct GNUNET_TRANSPORT_CoreHandle *h)
Disconnect from the transport service.
GNUNET_TRANSPORT_NotifyConnect nc_cb
function to call on connect events
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static void mq_destroy_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
Handle destruction of a message queue.
int 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.
#define GNUNET_NO
Definition: gnunet_common.h:78
uint32_t increase_window_delta
Number of messages by which to increase the window, greater or equal to one.
Definition: transport.h:264
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define STARTING_NEIGHBOURS_SIZE
How large to start with for the hashmap of neighbours.
struct GNUNET_PeerIdentity self
Identity we think we have.
Definition: transport.h:108
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_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.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
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.
struct GNUNET_PeerIdentity self
Peer identity as assumed by this process, or all zeros.
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).
static int neighbour_delete(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries, for deleting state of a neighbour.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_CONTAINER_MultiPeerMap * neighbours
Hash map of the current connected neighbours of this peer.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND
Request to TRANSPORT to transmit a message.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
Message from TRANSPORT notifying about a client that connected to us.
struct GNUNET_TIME_Relative reconnect_delay
Delay until we try to reconnect.
enum GNUNET_MQ_PriorityPreferences GNUNET_MQ_env_get_options(struct GNUNET_MQ_Envelope *env)
Get performance preferences set for this envelope.
Definition: mq.c:1017
uint16_t env_size
Size of the message in env.
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:581
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. ...
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:1237
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint32_t reserved
Reserved, always zero.
Definition: transport.h:156
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:550
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
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:772
static char * value
Value of the record to add/remove.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
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:686
uint32_t options
0: no options 1: The self field should be checked 2: this client is interested in payload traffic ...
Definition: transport.h:102
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
static void handle_connect(void *cls, const struct ConnectInfoMessage *cim)
Function we use for handling incoming connect messages.
Message from the transport service to the library informing about neighbors.
Definition: transport.h:116
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
int check_self
Should we check that self matches what the service thinks? (if GNUNET_NO, then self is all zeros!)...
GNUNET_MQ_MessageCallback cb
Callback, called every time a new message of the specified type has been receied. ...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_START
Message from the core saying that the transport server should start giving it messages.
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:200
Internal representation of the hash map.
struct GNUNET_PeerIdentity id
Identity of this neighbour.
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.
Message handler for a specific message type.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
Message from TRANSPORT notifying about a client that disconnected from us.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
Message used to notify the transport service about a message to be transmitted to another peer...
Definition: transport.h:277
There must only be one value per key; storing a value should fail if a value under the same key alrea...
Message from the transport service to the library asking to check if both processes agree about this ...
Definition: transport.h:91
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
static unsigned int size
Size of the "table".
Definition: peer.c:66
struct GNUNET_PeerIdentity peer
Which peer sent the message?
Definition: transport.h:203
Message from the transport service to the library informing about disconnects.
Definition: transport.h:147
unsigned int ready_window
How many messages can we still send to this peer before we should throttle?
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
Confirmation from TRANSPORT that message for transmission has been queued (and that the next message ...
#define LOG(kind,...)
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
static void handle_send_ok(void *cls, const struct SendOkMessage *okm)
Function we use for handling incoming send-ok messages.
static void mq_cancel_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
Implementation function that cancels the currently sent message.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
static void handle_recv(void *cls, const struct InboundMessage *im)
Function we use for handling incoming messages.
Handle to a message queue.
Definition: mq.c:84
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.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
The identity of the host (wraps the signing key of the peer).
Message used to notify the transport API that it can send another message to the transport service...
Definition: transport.h:211
struct GNUNET_PeerIdentity peer
Which peer can send more now?
Definition: transport.h:245
int16_t awaiting_done
Used to indicate our status if env is non-NULL.
configuration data
Definition: configuration.c:83
static int check_recv(void *cls, const struct InboundMessage *im)
Function we use for checking incoming "inbound" messages.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
Message from TRANSPORT notifying about a message that was received.
struct GNUNET_PeerIdentity peer
Who got disconnected?
Definition: transport.h:161
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_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
Entry in list of pending tasks.
Definition: scheduler.c:131
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the task trying to reconnect to the service.
Header for all communications.
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:971
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
#define GNUNET_YES
Definition: gnunet_common.h:77
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:351
static struct Neighbour * neighbour_find(struct GNUNET_TRANSPORT_CoreHandle *h, const struct GNUNET_PeerIdentity *peer)
Get the neighbour list entry for the given peer.
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.
struct GNUNET_MQ_Envelope * env
Envelope with the message we are currently transmitting (or NULL).
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV.
Definition: transport.h:198
Handle for the transport service (includes all of the state for the transport service).
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:484
void GNUNET_MQ_send_cancel(struct GNUNET_MQ_Envelope *ev)
Cancel sending the message.
Definition: mq.c:913
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
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.
Message used to notify the transport API about a message received from the network.
Definition: transport.h:194
#define GNUNET_free(ptr)
Wrapper around free.
#define SEND_WINDOW_SIZE
Window size.
Time for relative time used by GNUnet, in microseconds.
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 do_send(struct Neighbour *n)
We have an envelope waiting for transmission at n, and our transmission window is positive...
struct GNUNET_PeerIdentity pid
Which peer is this about?
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956