GNUnet  0.11.x
transport_api2_communication.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 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_protocols.h"
31 #include "transport.h"
32 
33 
39 #define DEFAULT_MAX_QUEUE_LENGTH 16
40 
41 
46 {
50  struct FlowControl *next;
51 
55  struct FlowControl *prev;
56 
61 
65  void *cb_cls;
66 
71 
75  uint64_t id;
76 };
77 
78 
83 struct AckPending
84 {
88  struct AckPending *next;
89 
93  struct AckPending *prev;
94 
99 
103  struct GNUNET_PeerIdentity receiver;
104 
108  uint64_t mid;
109 };
110 
111 
116 {
121 
126 
131 
136 
141 
146 
151 
156 
161 
165  const char *config_section;
166 
170  const char *addr_prefix;
171 
177 
181  void *mq_init_cls;
182 
189 
194 
199 
203  unsigned long long max_queue_length;
204 
208  uint64_t fc_gen;
209 
214  uint32_t aid_gen;
215 
219  uint32_t queue_gen;
220 
225 };
226 
227 
233 {
238 
243 
248 
252  char *address;
253 
258 
263 
268 
273 
277  uint32_t queue_id;
278 
282  uint32_t mtu;
283 };
284 
285 
291 {
296 
301 
306 
310  char *address;
311 
317 
322  uint32_t aid;
323 
328 };
329 
330 
336 static void
338 
339 
346 static void
348 {
349  struct GNUNET_MQ_Envelope *env;
350  struct GNUNET_TRANSPORT_AddAddressMessage *aam;
351 
352  if (NULL == ai->ch->mq)
353  return;
354  env = GNUNET_MQ_msg_extra (aam,
355  strlen (ai->address) + 1,
357  aam->expiration = GNUNET_TIME_relative_hton (ai->expiration);
358  aam->nt = htonl ((uint32_t) ai->nt);
359  memcpy (&aam[1], ai->address, strlen (ai->address) + 1);
360  GNUNET_MQ_send (ai->ch->mq, env);
361 }
362 
363 
370 static void
372 {
373  struct GNUNET_MQ_Envelope *env;
374  struct GNUNET_TRANSPORT_DelAddressMessage *dam;
375 
376  if (NULL == ai->ch->mq)
377  return;
379  dam->aid = htonl (ai->aid);
380  GNUNET_MQ_send (ai->ch->mq, env);
381 }
382 
383 
390 static void
392 {
393  struct GNUNET_MQ_Envelope *env;
394  struct GNUNET_TRANSPORT_AddQueueMessage *aqm;
395 
396  if (NULL == qh->ch->mq)
397  return;
398  env = GNUNET_MQ_msg_extra (aqm,
399  strlen (qh->address) + 1,
401  aqm->qid = htonl (qh->queue_id);
402  aqm->receiver = qh->peer;
403  aqm->nt = htonl ((uint32_t) qh->nt);
404  aqm->mtu = htonl (qh->mtu);
405  aqm->cs = htonl ((uint32_t) qh->cs);
406  memcpy (&aqm[1], qh->address, strlen (qh->address) + 1);
407  GNUNET_MQ_send (qh->ch->mq, env);
408 }
409 
410 
417 static void
419 {
420  struct GNUNET_MQ_Envelope *env;
421  struct GNUNET_TRANSPORT_DelQueueMessage *dqm;
422 
423  if (NULL == qh->ch->mq)
424  return;
426  dqm->qid = htonl (qh->queue_id);
427  dqm->receiver = qh->peer;
428  GNUNET_MQ_send (qh->ch->mq, env);
429 }
430 
431 
440 static void
442 {
443  struct FlowControl *fcn;
444  struct AckPending *apn;
445 
446  for (struct FlowControl *fc = ch->fc_head; NULL != fc; fc = fcn)
447  {
448  fcn = fc->next;
450  fc->cb (fc->cb_cls, GNUNET_SYSERR);
451  GNUNET_free (fc);
452  }
453  for (struct AckPending *ap = ch->ap_head; NULL != ap; ap = apn)
454  {
455  apn = ap->next;
457  GNUNET_free (ap);
458  }
459  if (NULL == ch->mq)
460  return;
461  GNUNET_MQ_destroy (ch->mq);
462  ch->mq = NULL;
463 }
464 
465 
469 static void
470 error_handler (void *cls, enum GNUNET_MQ_Error error)
471 {
473 
475  "MQ failure %d, reconnecting to transport service.\n",
476  error);
477  disconnect (ch);
478  /* TODO: maybe do this with exponential backoff/delay */
479  reconnect (ch);
480 }
481 
482 
490 static void
492  void *cls,
493  const struct GNUNET_TRANSPORT_IncomingMessageAck *incoming_ack)
494 {
496 
497  for (struct FlowControl *fc = ch->fc_head; NULL != fc; fc = fc->next)
498  {
499  if ((fc->id == incoming_ack->fc_id) &&
500  (0 == memcmp (&fc->sender,
501  &incoming_ack->sender,
502  sizeof(struct GNUNET_PeerIdentity))))
503  {
505  fc->cb (fc->cb_cls, GNUNET_OK);
506  GNUNET_free (fc);
507  return;
508  }
509  }
510  GNUNET_break (0);
511  disconnect (ch);
512  /* TODO: maybe do this with exponential backoff/delay */
513  reconnect (ch);
514 }
515 
516 
525 static int
526 check_create_queue (void *cls, const struct GNUNET_TRANSPORT_CreateQueue *cq)
527 {
528  (void) cls;
530  return GNUNET_OK;
531 }
532 
533 
540 static void
541 handle_create_queue (void *cls, const struct GNUNET_TRANSPORT_CreateQueue *cq)
542 {
544  const char *addr = (const char *) &cq[1];
545  struct GNUNET_TRANSPORT_CreateQueueResponse *cqr;
546  struct GNUNET_MQ_Envelope *env;
547 
548  if (GNUNET_OK != ch->mq_init (ch->mq_init_cls, &cq->receiver, addr))
549  {
551  "Address `%s' invalid for this communicator\n",
552  addr);
554  }
555  else
556  {
558  }
559  cqr->request_id = cq->request_id;
560  GNUNET_MQ_send (ch->mq, env);
561 }
562 
563 
572 static int
573 check_send_msg (void *cls, const struct GNUNET_TRANSPORT_SendMessageTo *smt)
574 {
575  (void) cls;
577  return GNUNET_OK;
578 }
579 
580 
590 static void
592  int status,
593  const struct GNUNET_PeerIdentity *receiver,
594  uint64_t mid)
595 {
596  struct GNUNET_MQ_Envelope *env;
597  struct GNUNET_TRANSPORT_SendMessageToAck *ack;
598 
600  ack->status = htonl (status);
601  ack->mid = mid;
602  ack->receiver = *receiver;
603  GNUNET_MQ_send (ch->mq, env);
604 }
605 
606 
613 static void
614 send_ack_cb (void *cls)
615 {
616  struct AckPending *ap = cls;
618 
620  send_ack (ch, GNUNET_OK, &ap->receiver, ap->mid);
621  GNUNET_free (ap);
622 }
623 
624 
631 static void
632 handle_send_msg (void *cls, const struct GNUNET_TRANSPORT_SendMessageTo *smt)
633 {
635  const struct GNUNET_MessageHeader *mh;
636  struct GNUNET_MQ_Envelope *env;
637  struct AckPending *ap;
638  struct GNUNET_TRANSPORT_QueueHandle *qh;
639 
640  for (qh = ch->queue_head; NULL != qh; qh = qh->next)
641  if ((qh->queue_id == smt->qid) &&
642  (0 == memcmp (&qh->peer,
643  &smt->receiver,
644  sizeof(struct GNUNET_PeerIdentity))))
645  break;
646  if (NULL == qh)
647  {
648  /* queue is already gone, tell transport this one failed */
650  "Transmission failed, queue no longer exists.\n");
651  send_ack (ch, GNUNET_NO, &smt->receiver, smt->mid);
652  return;
653  }
654  ap = GNUNET_new (struct AckPending);
655  ap->ch = ch;
656  ap->receiver = smt->receiver;
657  ap->mid = smt->mid;
659  mh = (const struct GNUNET_MessageHeader *) &smt[1];
660  env = GNUNET_MQ_msg_copy (mh);
662  GNUNET_MQ_send (qh->mq, env);
663 }
664 
665 
674 static int
676  void *cls,
677  const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi)
678 {
679  (void) cls;
681  return GNUNET_OK;
682 }
683 
684 
691 static void
693  void *cls,
694  const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi)
695 {
697  if (NULL != ch->notify_cb)
698  ch->notify_cb (ch->notify_cb_cls,
699  &bi->pid,
700  (const struct GNUNET_MessageHeader *) &bi[1]);
701  else
702  GNUNET_log (
704  _ ("Dropped backchanel message: handler not provided by communicator\n"));
705 }
706 
707 
713 static void
715 {
716  struct GNUNET_MQ_MessageHandler handlers[] =
717  { GNUNET_MQ_hd_fixed_size (incoming_ack,
719  struct GNUNET_TRANSPORT_IncomingMessageAck,
720  ch),
721  GNUNET_MQ_hd_var_size (create_queue,
723  struct GNUNET_TRANSPORT_CreateQueue,
724  ch),
727  struct GNUNET_TRANSPORT_SendMessageTo,
728  ch),
730  backchannel_incoming,
732  struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming,
733  ch),
735  struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam;
736  struct GNUNET_MQ_Envelope *env;
737 
738  ch->mq =
739  GNUNET_CLIENT_connect (ch->cfg, "transport", handlers, &error_handler, ch);
740  if (NULL == ch->mq)
741  return;
742  env = GNUNET_MQ_msg_extra (cam,
743  strlen (ch->addr_prefix) + 1,
745  cam->cc = htonl ((uint32_t) ch->cc);
746  memcpy (&cam[1], ch->addr_prefix, strlen (ch->addr_prefix) + 1);
747  GNUNET_MQ_send (ch->mq, env);
748  for (struct GNUNET_TRANSPORT_AddressIdentifier *ai = ch->ai_head; NULL != ai;
749  ai = ai->next)
751  for (struct GNUNET_TRANSPORT_QueueHandle *qh = ch->queue_head; NULL != qh;
752  qh = qh->next)
753  send_add_queue (qh);
754 }
755 
756 
777  const struct GNUNET_CONFIGURATION_Handle *cfg,
778  const char *config_section,
779  const char *addr_prefix,
782  void *mq_init_cls,
784  void *notify_cb_cls)
785 {
787 
789  ch->cfg = cfg;
791  ch->addr_prefix = addr_prefix;
792  ch->mq_init = mq_init;
793  ch->mq_init_cls = mq_init_cls;
794  ch->notify_cb = notify_cb;
796  ch->cc = cc;
797  reconnect (ch);
798  if (GNUNET_OK !=
800  config_section,
801  "MAX_QUEUE_LENGTH",
802  &ch->max_queue_length))
804  if (NULL == ch->mq)
805  {
806  GNUNET_free (ch);
807  return NULL;
808  }
809  return ch;
810 }
811 
812 
818 void
821 {
822  disconnect (ch);
823  while (NULL != ch->ai_head)
824  {
825  GNUNET_break (0); /* communicator forgot to remove address, warn! */
827  }
828  GNUNET_free (ch);
829 }
830 
831 
832 /* ************************* Receiving *************************** */
833 
834 
855 int
858  const struct GNUNET_PeerIdentity *sender,
859  const struct GNUNET_MessageHeader *msg,
860  struct GNUNET_TIME_Relative expected_addr_validity,
862  void *cb_cls)
863 {
864  struct GNUNET_MQ_Envelope *env;
865  struct GNUNET_TRANSPORT_IncomingMessage *im;
866  uint16_t msize;
867 
868  if (NULL == ch->mq)
869  return GNUNET_SYSERR;
870  if ((NULL == cb) && (GNUNET_MQ_get_length (ch->mq) >= ch->max_queue_length))
871  {
872  GNUNET_log (
874  "Dropping message: transport is too slow, queue length %llu exceeded\n",
875  ch->max_queue_length);
876  return GNUNET_NO;
877  }
878 
879  msize = ntohs (msg->size);
880  env =
882  if (NULL == env)
883  {
884  GNUNET_break (0);
885  return GNUNET_SYSERR;
886  }
887  im->expected_address_validity =
888  GNUNET_TIME_relative_hton (expected_addr_validity);
889  im->sender = *sender;
890  // FIXME: this is expensive, would be better if we would
891  // re-design the API to allow us to create the envelope first,
892  // and then have the application fill in the body so we do
893  // not have to memcpy()
894  memcpy (&im[1], msg, msize);
895  im->fc_on = htonl (GNUNET_NO);
896  if (NULL != cb)
897  {
898  struct FlowControl *fc;
899 
900  im->fc_on = htonl (GNUNET_YES);
901  im->fc_id = ch->fc_gen++;
902  fc = GNUNET_new (struct FlowControl);
903  fc->sender = *sender;
904  fc->id = im->fc_id;
905  fc->cb = cb;
906  fc->cb_cls = cb_cls;
908  }
909  GNUNET_MQ_send (ch->mq, env);
910  return GNUNET_OK;
911 }
912 
913 
914 /* ************************* Discovery *************************** */
915 
916 
936  const struct GNUNET_PeerIdentity *peer,
937  const char *address,
938  uint32_t mtu,
939  enum GNUNET_NetworkType nt,
941  struct GNUNET_MQ_Handle *mq)
942 {
943  struct GNUNET_TRANSPORT_QueueHandle *qh;
944 
946  qh->ch = ch;
947  qh->peer = *peer;
948  qh->address = GNUNET_strdup (address);
949  qh->nt = nt;
950  qh->mtu = mtu;
951  qh->cs = cs;
952  qh->mq = mq;
953  qh->queue_id = ch->queue_gen++;
955  send_add_queue (qh);
956  return qh;
957 }
958 
959 
966 void
968 {
970 
971  send_del_queue (qh);
973  GNUNET_MQ_destroy (qh->mq);
974  GNUNET_free (qh->address);
975  GNUNET_free (qh);
976 }
977 
978 
991  const char *address,
992  enum GNUNET_NetworkType nt,
994 {
996 
998  ai->ch = ch;
999  ai->address = GNUNET_strdup (address);
1000  ai->nt = nt;
1001  ai->expiration = expiration;
1002  ai->aid = ch->aid_gen++;
1004  send_add_address (ai);
1005  return ai;
1006 }
1007 
1008 
1015 void
1018 {
1020 
1021  send_del_address (ai);
1023  GNUNET_free (ai->address);
1024  GNUNET_free (ai);
1025 }
1026 
1027 
1028 /* ************************* Backchannel *************************** */
1029 
1030 
1045 void
1048  const struct GNUNET_PeerIdentity *pid,
1049  const char *comm,
1050  const struct GNUNET_MessageHeader *header)
1051 {
1052  struct GNUNET_MQ_Envelope *env;
1053  struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb;
1054  size_t slen = strlen (comm) + 1;
1055  uint16_t mlen = ntohs (header->size);
1056 
1057  GNUNET_assert (mlen + slen + sizeof(*cb) < UINT16_MAX);
1058  env =
1059  GNUNET_MQ_msg_extra (cb,
1060  slen + mlen,
1062  cb->pid = *pid;
1063  memcpy (&cb[1], header, mlen);
1064  memcpy (((char *) &cb[1]) + mlen, comm, slen);
1065  GNUNET_MQ_send (ch->mq, env);
1066 }
1067 
1068 
1069 /* end of transport_api2_communication.c */
GNUNET_TRANSPORT_CommunicatorCharacteristics
What characteristics does this communicator have?
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
uint32_t aid_gen
Internal UUID for the address used in communication with the transport service.
enum GNUNET_NetworkType nt
Network type of the communciation queue.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
Definition: mq.c:660
static void handle_send_msg(void *cls, const struct GNUNET_TRANSPORT_SendMessageTo *smt)
Transport service wants us to send a message.
struct GNUNET_PeerIdentity receiver
Which peer is this about?
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG
transport tells communicator it wants to transmit
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static void send_add_queue(struct GNUNET_TRANSPORT_QueueHandle *qh)
Send message to the transport service about queue qh being now available.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE
transport tells communicator it wants a queue
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
uint64_t id
More-or-less unique ID for the message.
unsigned long long max_queue_length
Maximum permissable queue length.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
common internal definitions for transport service
static void send_ack_cb(void *cls)
Message queue transmission by communicator was successful, notify 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:1063
struct GNUNET_TRANSPORT_AddressIdentifier * GNUNET_TRANSPORT_communicator_address_add(struct GNUNET_TRANSPORT_CommunicatorHandle *ch, const char *address, enum GNUNET_NetworkType nt, struct GNUNET_TIME_Relative expiration)
Notify transport service about an address that this communicator provides for this peer...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK
Response from communicator: will try to create queue.
GNUNET_MQ_Error
Error codes for the queue.
char * address
Address used by the communication queue.
static void handle_backchannel_incoming(void *cls, const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi)
Transport service gives us backchannel message.
uint32_t queue_id
ID for this queue when talking to the transport service.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
struct GNUNET_TRANSPORT_QueueHandle * next
Kept in a DLL.
const char * config_section
Config section to use.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
struct GNUNET_TRANSPORT_AddressIdentifier * next
Kept in a DLL.
GNUNET_TRANSPORT_MessageCompletedCallback cb
Function to call once the message was processed.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_NO
Definition: gnunet_common.h:86
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
#define GNUNET_new(type)
Allocate a struct or union of the given type.
GNUNET_TRANSPORT_CommunicatorNotify notify_cb
Function to call when the transport service receives messages for a communicator (i.e.
void(* GNUNET_TRANSPORT_CommunicatorNotify)(void *cls, const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *msg)
Function called when the transport service has received a backchannel message for this communicator (...
struct GNUNET_TRANSPORT_QueueHandle * prev
Kept in a DLL.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING
Transport signalling incoming backchannel message to a communicator.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
static int check_backchannel_incoming(void *cls, const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi)
Transport service gives us backchannel message.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Definition: gnunet_nt_lib.h:35
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Information we track per packet to enable flow control.
struct GNUNET_TRANSPORT_AddressIdentifier * ai_tail
Tail of DLL of addresses this communicator offers to the transport service.
#define GNUNET_MQ_check_boxed_message(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Handle this queue belongs to.
struct GNUNET_TRANSPORT_QueueHandle * queue_head
DLL of queues we offer.
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Transport handle where the address was added.
Opaque handle to the transport service for communicators.
#define _(String)
GNU gettext support macro.
Definition: platform.h:180
void GNUNET_TRANSPORT_communicator_disconnect(struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
Disconnect from the transport service.
struct AckPending * prev
Kept in a DLL.
enum GNUNET_TRANSPORT_ConnectionStatus cs
Communication status of the queue.
void * cb_cls
Closure for cb.
static void error_handler(void *cls, enum GNUNET_MQ_Error error)
Function called on MQ errors.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG
inform transport about an incoming message
void GNUNET_TRANSPORT_communicator_mq_del(struct GNUNET_TRANSPORT_QueueHandle *qh)
Notify transport service that an MQ became unavailable due to a disconnect or timeout.
static int check_send_msg(void *cls, const struct GNUNET_TRANSPORT_SendMessageTo *smt)
Transport service wants us to send a message.
int(* GNUNET_TRANSPORT_CommunicatorMqInit)(void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
Function called by the transport service to initialize a message queue given address information abou...
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
struct GNUNET_TRANSPORT_QueueHandle * queue_tail
DLL of queues we offer.
uint64_t fc_gen
Flow-control identifier generator.
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
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:781
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK
transport acknowledges processing an incoming message
unsigned int GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq)
Obtain the current length of the message queue.
Definition: mq.c:335
static void send_del_address(struct GNUNET_TRANSPORT_AddressIdentifier *ai)
Send message to the transport service about address ai being no longer available. ...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP
inform transport that a queue was setup to talk to some peer
const char * addr_prefix
Address prefix to use.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL
Tell transport that it should assist with exchanging a message between communicators.
struct GNUNET_TIME_Relative expiration
When does the address expire? (Expected lifetime of the address.)
void(* GNUNET_TRANSPORT_MessageCompletedCallback)(void *cls, int success)
Function called to notify communicator that we have received and processed the message.
static void disconnect(struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
Disconnect from the transport service.
uint16_t status
See PRISM_STATUS_*-constants.
struct AckPending * ap_tail
DLL of messages awaiting transmission confirmation (ack).
static void send_del_queue(struct GNUNET_TRANSPORT_QueueHandle *qh)
Send message to the transport service about queue qh being no longer available.
struct GNUNET_TRANSPORT_CommunicatorHandle * GNUNET_TRANSPORT_communicator_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *config_section, const char *addr_prefix, enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc, GNUNET_TRANSPORT_CommunicatorMqInit mq_init, void *mq_init_cls, GNUNET_TRANSPORT_CommunicatorNotify notify_cb, void *notify_cb_cls)
Connect to the transport service.
struct FlowControl * fc_head
DLL of messages awaiting flow control confirmation (ack).
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK
communicator tells transports that message was sent
Information we track per message to tell the transport about success or failures. ...
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
struct GNUNET_PeerIdentity sender
Which peer is this about?
Message handler for a specific message type.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS
inform transport to delete an address of this peer
void GNUNET_TRANSPORT_communicator_address_remove(struct GNUNET_TRANSPORT_AddressIdentifier *ai)
Notify transport service about an address that this communicator no longer provides for this peer...
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:625
static int mq_init(void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
Function called by the transport service to initialize a message queue given address information abou...
struct FlowControl * prev
Kept in a DLL.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static void send_msg(void *cls)
Function called to notify a client about the socket begin ready to queue more data.
struct GNUNET_MQ_Handle * mq
Queue to talk to the transport service.
int GNUNET_TRANSPORT_communicator_receive(struct GNUNET_TRANSPORT_CommunicatorHandle *ch, const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *msg, struct GNUNET_TIME_Relative expected_addr_validity, GNUNET_TRANSPORT_MessageCompletedCallback cb, void *cb_cls)
Notify transport service that the communicator has received a message.
struct GNUNET_TRANSPORT_AddressIdentifier * ai_head
Head of DLL of addresses this communicator offers to the transport service.
struct GNUNET_TRANSPORT_AddressIdentifier * prev
Kept in a DLL.
static void reconnect(struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
(re)connect our communicator to the transport service
Handle to a message queue.
Definition: mq.c:85
struct GNUNET_PeerIdentity peer
Which peer we can communciate with.
The identity of the host (wraps the signing key of the peer).
enum GNUNET_NetworkType nt
Network type for the address.
configuration data
Definition: configuration.c:84
#define DEFAULT_MAX_QUEUE_LENGTH
How many messages do we keep at most in the queue to the transport service before we start to drop (d...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR
Message sent to indicate to the transport which address prefix is supported by a communicator.
void GNUNET_TRANSPORT_communicator_notify(struct GNUNET_TRANSPORT_CommunicatorHandle *ch, const struct GNUNET_PeerIdentity *pid, const char *comm, const struct GNUNET_MessageHeader *header)
The communicator asks the transport service to route a message via a different path to another commun...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL
Response from communicator: address bogus, will not try to create queue.
static void send_add_address(struct GNUNET_TRANSPORT_AddressIdentifier *ai)
Send message to the transport service about address ai being now available.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN
inform transport that a queue was torn down
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define GNUNET_log(kind,...)
static void send_ack(struct GNUNET_TRANSPORT_CommunicatorHandle *ch, int status, const struct GNUNET_PeerIdentity *receiver, uint64_t mid)
Notify transport service about status of a message with mid sent to receiver.
struct GNUNET_MQ_Handle * mq
The queue itself.
static int check_create_queue(void *cls, const struct GNUNET_TRANSPORT_CreateQueue *cq)
Transport service wants us to create a queue.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS
inform transport to add an address of this peer
uint32_t queue_gen
Queue identifier generator.
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Communicator this entry belongs to.
Header for all communications.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:831
#define GNUNET_YES
Definition: gnunet_common.h:85
uint64_t mid
More-or-less unique ID for the message.
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:353
struct GNUNET_TRANSPORT_QueueHandle * GNUNET_TRANSPORT_communicator_mq_add(struct GNUNET_TRANSPORT_CommunicatorHandle *ch, const struct GNUNET_PeerIdentity *peer, const char *address, uint32_t mtu, enum GNUNET_NetworkType nt, enum GNUNET_TRANSPORT_ConnectionStatus cs, struct GNUNET_MQ_Handle *mq)
Notify transport service that an MQ became available due to an "inbound" connection or because the co...
GNUNET_TRANSPORT_ConnectionStatus
Possible states of a connection.
uint32_t aid
Internal UUID for the address used in communication with the transport service.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
struct FlowControl * fc_tail
DLL of messages awaiting flow control confirmation (ack).
GNUNET_TRANSPORT_CommunicatorMqInit mq_init
Function to call when the transport service wants us to initiate a communication channel with another...
struct AckPending * next
Kept in a DLL.
enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc
Characteristics of the communicator.
struct FlowControl * next
Kept in a DLL.
static char * address
GNS address for this phone.
uint32_t mtu
Maximum transmission unit for the queue.
Handle returned to identify the internal data structure the transport API has created to manage a mes...
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
static void handle_incoming_ack(void *cls, const struct GNUNET_TRANSPORT_IncomingMessageAck *incoming_ack)
Transport service acknowledged a message we gave it (with flow control enabled).
struct AckPending * ap_head
DLL of messages awaiting transmission confirmation (ack).
Internal representation of an address a communicator is currently providing for the transport service...
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
Bandwidth allocation API for the transport service.
static void handle_create_queue(void *cls, const struct GNUNET_TRANSPORT_CreateQueue *cq)
Transport service wants us to create a queue.