GNUnet  0.10.x
gnunet-service-cadet_core.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2017 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 
32 #include "platform.h"
38 #include "gnunet_core_service.h"
40 #include "cadet_protocol.h"
41 
42 #define LOG(level, ...) GNUNET_log_from (level, "cadet-cor", __VA_ARGS__)
43 
47 struct RouteDirection;
48 
55 struct Rung
56 {
57 
61  struct Rung *next;
62 
66  struct Rung *prev;
67 
72 
77 
81  unsigned int num_routes;
82 
87  unsigned int rung_off;
88 };
89 
90 
95 {
96 
101 
106 
110  struct Rung *rung;
111 
116 
121 
125  struct CadetPeer *hop;
126 
131 
136 
140  int is_ready;
141 };
142 
143 
153 {
154 
159 
164 
169 
173  struct GNUNET_TIME_Absolute last_use;
174 
179 };
180 
181 
185 static struct GNUNET_CORE_Handle *core;
186 
191 
196 
200 static struct Rung rung_zero;
201 
206 static struct Rung *rung_head = &rung_zero;
207 
211 static struct Rung *rung_tail = &rung_zero;
212 
216 static unsigned long long max_routes;
217 
221 static unsigned long long max_buffers;
222 
226 static unsigned long long cur_buffers;
227 
232 
233 
239 static struct CadetRoute *
241 {
242  return GNUNET_CONTAINER_multishortmap_get (routes,
243  &cid->connection_of_tunnel);
244 }
245 
246 
252 static void
254 {
255  struct Rung *rung = dir->rung;
256  struct Rung *prev;
257 
258  GNUNET_CONTAINER_DLL_remove (rung->rd_head, rung->rd_tail, dir);
259  prev = rung->prev;
260  GNUNET_assert (NULL != prev);
261  if (prev->rung_off != rung->rung_off - 1)
262  {
263  prev = GNUNET_new (struct Rung);
264  prev->rung_off = rung->rung_off - 1;
265  GNUNET_CONTAINER_DLL_insert_after (rung_head, rung_tail, rung->prev, prev);
266  }
267  GNUNET_assert (NULL != prev);
268  GNUNET_CONTAINER_DLL_insert (prev->rd_head, prev->rd_tail, dir);
269  dir->rung = prev;
270 }
271 
272 
280 static void
282 {
283  GNUNET_MQ_dll_remove (&dir->env_head, &dir->env_tail, env);
284  cur_buffers--;
285  GNUNET_MQ_discard (env);
286  lower_rung (dir);
287  GNUNET_STATISTICS_set (stats, "# buffer use", cur_buffers, GNUNET_NO);
288 }
289 
290 
294 static void
296 {
297  struct Rung *tail = rung_tail;
298  struct RouteDirection *dir;
299 
300  while (NULL != (dir = tail->rd_head))
301  {
303  "Queue full due new message %s on connection %s, dropping old message\n",
306  "# messages dropped due to full buffer",
307  1,
308  GNUNET_NO);
309  discard_buffer (dir, dir->env_head);
310  }
311  GNUNET_CONTAINER_DLL_remove (rung_head, rung_tail, tail);
312  GNUNET_free (tail);
313 }
314 
315 
325 static void
327  const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid,
328  const struct GNUNET_MessageHeader *msg,
329  const enum GNUNET_MQ_PriorityPreferences priority)
330 {
331  struct CadetRoute *route;
332  struct RouteDirection *dir;
333  struct Rung *rung;
334  struct Rung *nxt;
335  struct GNUNET_MQ_Envelope *env;
336 
337  route = get_route (cid);
338  if (NULL == route)
339  {
340  struct GNUNET_MQ_Envelope *env;
342 
344  "Failed to route message of type %u from %s on connection %s: no route\n",
345  ntohs (msg->type),
346  GCP_2s (prev),
348  switch (ntohs (msg->type))
349  {
352  /* No need to respond to these! */
353  return;
354  }
356  bm->cid = *cid;
357  bm->peer1 = my_full_id;
358  GCP_send_ooo (prev, env);
359  return;
360  }
363  dir = (prev == route->prev.hop) ? &route->next : &route->prev;
364  if (GNUNET_YES == dir->is_ready)
365  {
367  "Routing message of type %u from %s to %s on connection %s\n",
368  ntohs (msg->type),
369  GCP_2s (prev),
370  GNUNET_i2s (GCP_get_id (dir->hop)),
372  dir->is_ready = GNUNET_NO;
373  GCP_send (dir->mqm, GNUNET_MQ_msg_copy (msg));
374  return;
375  }
376  /* Check if low latency is required and if the previous message was
377  unreliable; if so, make sure we only queue one message per
378  direction (no buffering). */
379  if ((0 != (priority & GNUNET_MQ_PREF_LOW_LATENCY)) &&
380  (NULL != dir->env_head) &&
381  (0 ==
383  discard_buffer (dir, dir->env_head);
384  /* Check for duplicates */
385  for (const struct GNUNET_MQ_Envelope *env = dir->env_head; NULL != env;
386  env = GNUNET_MQ_env_next (env))
387  {
388  const struct GNUNET_MessageHeader *hdr = GNUNET_MQ_env_get_msg (env);
389 
390  if ((hdr->size == msg->size) && (0 == memcmp (hdr, msg, ntohs (msg->size))))
391  {
393  "Received duplicate of message already in buffer, dropping\n");
395  "# messages dropped due to duplicate in buffer",
396  1,
397  GNUNET_NO);
398  return;
399  }
400  }
401 
402  rung = dir->rung;
403  if (cur_buffers == max_buffers)
404  {
405  /* Need to make room. */
406  if (NULL != rung->next)
407  {
408  /* Easy case, drop messages from route directions in highest rung */
410  }
411  else
412  {
413  /* We are in the highest rung, drop our own! */
415  "Queue full due new message %s on connection %s, dropping old message\n",
418  "# messages dropped due to full buffer",
419  1,
420  GNUNET_NO);
421  discard_buffer (dir, dir->env_head);
422  rung = dir->rung;
423  }
424  }
425  /* remove 'dir' from current rung */
426  GNUNET_CONTAINER_DLL_remove (rung->rd_head, rung->rd_tail, dir);
427  /* make 'nxt' point to the next higher rung, create if necessary */
428  nxt = rung->next;
429  if ((NULL == nxt) || (rung->rung_off + 1 != nxt->rung_off))
430  {
431  nxt = GNUNET_new (struct Rung);
432  nxt->rung_off = rung->rung_off + 1;
433  GNUNET_CONTAINER_DLL_insert_after (rung_head, rung_tail, rung, nxt);
434  }
435  /* insert 'dir' into next higher rung */
436  GNUNET_CONTAINER_DLL_insert (nxt->rd_head, nxt->rd_tail, dir);
437  dir->rung = nxt;
438 
439  /* add message into 'dir' buffer */
441  "Queueing new message of type %u from %s to %s on connection %s\n",
442  ntohs (msg->type),
443  GCP_2s (prev),
444  GNUNET_i2s (GCP_get_id (dir->hop)),
446  env = GNUNET_MQ_msg_copy (msg);
447  GNUNET_MQ_env_set_options (env, priority);
448  if ((0 != (priority & GNUNET_MQ_PREF_LOW_LATENCY)) &&
449  (0 != (priority & GNUNET_MQ_PREF_OUT_OF_ORDER)) &&
450  (NULL != dir->env_head) &&
451  (0 == (GNUNET_MQ_env_get_options (dir->env_head) &
452  GNUNET_MQ_PREF_LOW_LATENCY)))
453  GNUNET_MQ_dll_insert_head (&dir->env_head, &dir->env_tail, env);
454  else
455  GNUNET_MQ_dll_insert_tail (&dir->env_head, &dir->env_tail, env);
456  cur_buffers++;
457  GNUNET_STATISTICS_set (stats, "# buffer use", cur_buffers, GNUNET_NO);
458  /* Clean up 'rung' if now empty (and not head) */
459  if ((NULL == rung->rd_head) && (rung != rung_head))
460  {
461  GNUNET_CONTAINER_DLL_remove (rung_head, rung_tail, rung);
462  GNUNET_free (rung);
463  }
464 }
465 
466 
475 static int
478 {
479  uint16_t size = ntohs (msg->header.size) - sizeof (*msg);
480 
481  if (0 != (size % sizeof (struct GNUNET_PeerIdentity)))
482  {
483  GNUNET_break_op (0);
484  return GNUNET_NO;
485  }
486  return GNUNET_YES;
487 }
488 
489 
495 static void
497 {
498  struct GNUNET_MQ_Envelope *env;
499 
500  while (NULL != (env = dir->env_head))
501  {
503  "# messages dropped due to route destruction",
504  1,
505  GNUNET_NO);
506  discard_buffer (dir, env);
507  }
508  if (NULL != dir->mqm)
509  {
510  GCP_request_mq_cancel (dir->mqm, NULL);
511  dir->mqm = NULL;
512  }
513  GNUNET_CONTAINER_DLL_remove (rung_head->rd_head, rung_head->rd_tail, dir);
514 }
515 
516 
522 static void
523 destroy_route (struct CadetRoute *route)
524 {
526  "Destroying route from %s to %s of connection %s\n",
527  GNUNET_i2s (GCP_get_id (route->prev.hop)),
528  GNUNET_i2s2 (GCP_get_id (route->next.hop)),
531  GNUNET_assert (
532  GNUNET_YES ==
534  &route->cid.connection_of_tunnel,
535  route));
537  "# routes",
539  GNUNET_NO);
540  destroy_direction (&route->prev);
541  destroy_direction (&route->next);
542  GNUNET_free (route);
543 }
544 
545 
554 static void
555 send_broken (struct RouteDirection *target,
556  const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid,
557  const struct GNUNET_PeerIdentity *peer1,
558  const struct GNUNET_PeerIdentity *peer2)
559 {
560  struct GNUNET_MQ_Envelope *env;
562 
563  if (NULL == target->mqm)
564  return; /* Can't send notification, connection is down! */
566  "Notifying %s about BROKEN route at %s-%s of connection %s\n",
567  GCP_2s (target->hop),
568  GNUNET_i2s (peer1),
569  GNUNET_i2s2 (peer2),
571 
573  bm->cid = *cid;
574  if (NULL != peer1)
575  bm->peer1 = *peer1;
576  if (NULL != peer2)
577  bm->peer2 = *peer2;
578  GCP_request_mq_cancel (target->mqm, env);
579  target->mqm = NULL;
580 }
581 
582 
590 static void
591 timeout_cb (void *cls)
592 {
593  struct CadetRoute *r;
594  struct GNUNET_TIME_Relative linger;
595  struct GNUNET_TIME_Absolute exp;
596 
597  timeout_task = NULL;
599  while (NULL != (r = GNUNET_CONTAINER_heap_peek (route_heap)))
600  {
601  exp = GNUNET_TIME_absolute_add (r->last_use, linger);
602  if (0 != GNUNET_TIME_absolute_get_remaining (exp).rel_value_us)
603  {
604  /* Route not yet timed out, wait until it does. */
605  timeout_task = GNUNET_SCHEDULER_add_at (exp, &timeout_cb, NULL);
606  return;
607  }
609  "Sending BROKEN due to timeout (%s was last use, %s linger)\n",
612  send_broken (&r->prev, &r->cid, NULL, NULL);
613  send_broken (&r->next, &r->cid, NULL, NULL);
614  destroy_route (r);
615  }
616  /* No more routes left, so no need for a #timeout_task */
617 }
618 
619 
632 static void
633 dir_ready_cb (void *cls, int ready)
634 {
635  struct RouteDirection *dir = cls;
636  struct CadetRoute *route = dir->my_route;
637  struct RouteDirection *odir;
638 
639  if (GNUNET_YES == ready)
640  {
641  struct GNUNET_MQ_Envelope *env;
642 
643  dir->is_ready = GNUNET_YES;
644  if (NULL != (env = dir->env_head))
645  {
646  GNUNET_MQ_dll_remove (&dir->env_head, &dir->env_tail, env);
647  cur_buffers--;
648  GNUNET_STATISTICS_set (stats, "# buffer use", cur_buffers, GNUNET_NO);
649  lower_rung (dir);
650  dir->is_ready = GNUNET_NO;
651  GCP_send (dir->mqm, env);
652  }
653  return;
654  }
655  odir = (dir == &route->next) ? &route->prev : &route->next;
656  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending BROKEN due to MQ going down\n");
657  send_broken (&route->next, &route->cid, GCP_get_id (odir->hop), &my_full_id);
658  destroy_route (route);
659 }
660 
661 
669 static void
671  struct CadetRoute *route,
672  struct CadetPeer *hop)
673 {
674  dir->hop = hop;
675  dir->my_route = route;
676  dir->mqm = GCP_request_mq (hop, &dir_ready_cb, dir);
677  GNUNET_CONTAINER_DLL_insert (rung_head->rd_head, rung_head->rd_tail, dir);
678  dir->rung = rung_head;
680 }
681 
682 
693 static void
695  struct CadetPeer *target,
696  const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid,
697  const struct GNUNET_PeerIdentity *failure_at)
698 {
699  struct GNUNET_MQ_Envelope *env;
701 
703  bm->cid = *cid;
704  bm->peer1 = my_full_id;
705  if (NULL != failure_at)
706  bm->peer2 = *failure_at;
707  GCP_send_ooo (target, env);
708 }
709 
710 
717 static void
719  void *cls,
721 {
722  struct CadetPeer *sender = cls;
723  struct CadetPeer *next;
724  const struct GNUNET_PeerIdentity *pids =
725  (const struct GNUNET_PeerIdentity *) &msg[1];
726  struct CadetRoute *route;
727  uint16_t size = ntohs (msg->header.size) - sizeof (*msg);
728  unsigned int path_length;
729  unsigned int off;
730 
731  path_length = size / sizeof (struct GNUNET_PeerIdentity);
732  if (0 == path_length)
733  {
735  "Dropping CADET_CONNECTION_CREATE with empty path\n");
736  GNUNET_break_op (0);
737  return;
738  }
740  "Handling CADET_CONNECTION_CREATE from %s for CID %s with %u hops\n",
741  GCP_2s (sender),
743  path_length);
744  /* Check for loops */
745  {
747 
748  map = GNUNET_CONTAINER_multipeermap_create (path_length * 2, GNUNET_YES);
749  GNUNET_assert (NULL != map);
750  for (unsigned int i = 0; i < path_length; i++)
751  {
753  "CADET_CONNECTION_CREATE has peer %s at offset %u\n",
754  GNUNET_i2s (&pids[i]),
755  i);
757  map,
758  &pids[i],
759  NULL,
761  {
762  /* bogus request */
765  "Dropping CADET_CONNECTION_CREATE with cyclic path\n");
766  GNUNET_break_op (0);
767  return;
768  }
769  }
771  }
772  /* Initiator is at offset 0, find us */
773  for (off = 1; off < path_length; off++)
774  if (0 == GNUNET_memcmp (&my_full_id, &pids[off]))
775  break;
776  if (off == path_length)
777  {
779  "Dropping CADET_CONNECTION_CREATE without us in the path\n");
780  GNUNET_break_op (0);
781  return;
782  }
783  /* Check previous hop */
784  if (sender != GCP_get (&pids[off - 1], GNUNET_NO))
785  {
787  "Dropping CADET_CONNECTION_CREATE without sender at previous hop in the path\n");
788  GNUNET_break_op (0);
789  return;
790  }
791  if (NULL != (route = get_route (&msg->cid)))
792  {
793  /* Duplicate CREATE, pass it on, previous one might have been lost! */
794 
796  "Passing on duplicate CADET_CONNECTION_CREATE message on connection %s\n",
798  route_message (sender,
799  &msg->cid,
800  &msg->header,
803  return;
804  }
805  if (off == path_length - 1)
806  {
807  /* We are the destination, create connection */
808  struct CadetConnection *cc;
809  struct CadetPeerPath *path;
810  struct CadetPeer *origin;
811 
812  cc = GCC_lookup (&msg->cid);
813  if (NULL != cc)
814  {
816  "Received duplicate CADET_CONNECTION_CREATE message on connection %s\n",
819  return;
820  }
821 
822  origin = GCP_get (&pids[0], GNUNET_YES);
824  "I am destination for CADET_CONNECTION_CREATE message from %s for connection %s, building inverse path\n",
825  GCP_2s (origin),
827  path = GCPP_get_path_from_route (path_length - 1, pids);
828  if (GNUNET_OK !=
830  &msg->cid,
831  path))
832  {
833  /* Send back BROKEN: duplicate connection on the same path,
834  we will use the other one. */
836  "Received CADET_CONNECTION_CREATE from %s for %s, but %s already has a connection. Sending BROKEN\n",
837  GCP_2s (sender),
839  GCPP_2s (path));
840  send_broken_without_mqm (sender, &msg->cid, NULL);
841  return;
842  }
843  return;
844  }
845  /* We are merely a hop on the way, check if we can support the route */
846  next = GCP_get (&pids[off + 1], GNUNET_NO);
847  if ((NULL == next) || (GNUNET_NO == GCP_has_core_connection (next)))
848  {
849  /* unworkable, send back BROKEN notification */
851  "Received CADET_CONNECTION_CREATE from %s for %s. Next hop %s:%u is down. Sending BROKEN\n",
852  GCP_2s (sender),
854  GNUNET_i2s (&pids[off + 1]),
855  off + 1);
856  send_broken_without_mqm (sender, &msg->cid, &pids[off + 1]);
857  return;
858  }
860  {
862  "Received CADET_CONNECTION_CREATE from %s for %s. We have reached our route limit. Sending BROKEN\n",
863  GCP_2s (sender),
865  send_broken_without_mqm (sender, &msg->cid, &pids[off - 1]);
866  return;
867  }
868 
869  /* Workable route, create routing entry */
871  "Received CADET_CONNECTION_CREATE from %s for %s. Next hop %s:%u is up. Creating route\n",
872  GCP_2s (sender),
874  GNUNET_i2s (&pids[off + 1]),
875  off + 1);
876  route = GNUNET_new (struct CadetRoute);
877  route->cid = msg->cid;
879  dir_init (&route->prev, route, sender);
880  dir_init (&route->next, route, next);
883  routes,
884  &route->cid.connection_of_tunnel,
885  route,
888  "# routes",
890  GNUNET_NO);
891  route->hn = GNUNET_CONTAINER_heap_insert (route_heap,
892  route,
893  route->last_use.abs_value_us);
894  if (NULL == timeout_task)
895  timeout_task =
897  3),
898  &timeout_cb,
899  NULL);
900  /* also pass CREATE message along to next hop */
901  route_message (sender,
902  &msg->cid,
903  &msg->header,
905 }
906 
907 
914 static void
916  void *cls,
918 {
919  struct CadetPeer *peer = cls;
920  struct CadetConnection *cc;
921 
922  /* First, check if ACK belongs to a connection that ends here. */
923  cc = GCC_lookup (&msg->cid);
924  if (NULL != cc)
925  {
926  /* verify ACK came from the right direction */
927  unsigned int len;
928  struct CadetPeerPath *path = GCC_get_path (cc, &len);
929 
930  if (peer != GCPP_get_peer_at_offset (path, 0))
931  {
932  /* received ACK from unexpected direction, ignore! */
933  GNUNET_break_op (0);
934  return;
935  }
937  "Received CONNECTION_CREATE_ACK for connection %s.\n",
940  return;
941  }
942 
943  /* We're just an intermediary peer, route the message along its path */
944  route_message (peer,
945  &msg->cid,
946  &msg->header,
948 }
949 
950 
958 static void
960  void *cls,
962 {
963  struct CadetPeer *peer = cls;
964  struct CadetConnection *cc;
965  struct CadetRoute *route;
966 
967  /* First, check if message belongs to a connection that ends here. */
968  cc = GCC_lookup (&msg->cid);
969  if (NULL != cc)
970  {
971  /* verify message came from the right direction */
972  unsigned int len;
973  struct CadetPeerPath *path = GCC_get_path (cc, &len);
974 
975  if (peer != GCPP_get_peer_at_offset (path, 0))
976  {
977  /* received message from unexpected direction, ignore! */
978  GNUNET_break_op (0);
979  return;
980  }
982  "Received CONNECTION_BROKEN for connection %s. Destroying it.\n",
985 
986  /* FIXME: also destroy the path up to the specified link! */
987  return;
988  }
989 
990  /* We're just an intermediary peer, route the message along its path */
991  route_message (peer,
992  &msg->cid,
993  &msg->header,
995  route = get_route (&msg->cid);
996  if (NULL != route)
997  destroy_route (route);
998  /* FIXME: also destroy paths we MAY have up to the specified link! */
999 }
1000 
1001 
1008 static void
1010  void *cls,
1012 {
1013  struct CadetPeer *peer = cls;
1014  struct CadetConnection *cc;
1015  struct CadetRoute *route;
1016 
1017  /* First, check if message belongs to a connection that ends here. */
1018  cc = GCC_lookup (&msg->cid);
1019  if (NULL != cc)
1020  {
1021  /* verify message came from the right direction */
1022  unsigned int len;
1023  struct CadetPeerPath *path = GCC_get_path (cc, &len);
1024 
1025  if (peer != GCPP_get_peer_at_offset (path, 0))
1026  {
1027  /* received message from unexpected direction, ignore! */
1028  GNUNET_break_op (0);
1029  return;
1030  }
1032  "Received CONNECTION_DESTROY for connection %s. Destroying connection.\n",
1034 
1036  return;
1037  }
1038 
1039  /* We're just an intermediary peer, route the message along its path */
1041  "Received CONNECTION_DESTROY for connection %s. Destroying route.\n",
1043  route_message (peer,
1044  &msg->cid,
1045  &msg->header,
1047  route = get_route (&msg->cid);
1048  if (NULL != route)
1049  destroy_route (route);
1050 }
1051 
1052 
1059 static void
1060 handle_tunnel_kx (void *cls,
1062 {
1063  struct CadetPeer *peer = cls;
1064  struct CadetConnection *cc;
1065 
1066  /* First, check if message belongs to a connection that ends here. */
1068  "Routing KX with ephemeral %s on CID %s\n",
1069  GNUNET_e2s (&msg->ephemeral_key),
1071 
1072 
1073  cc = GCC_lookup (&msg->cid);
1074  if (NULL != cc)
1075  {
1076  /* verify message came from the right direction */
1077  unsigned int len;
1078  struct CadetPeerPath *path = GCC_get_path (cc, &len);
1079 
1080  if (peer != GCPP_get_peer_at_offset (path, 0))
1081  {
1082  /* received message from unexpected direction, ignore! */
1083  GNUNET_break_op (0);
1084  return;
1085  }
1086  GCC_handle_kx (cc, msg);
1087  return;
1088  }
1089 
1090  /* We're just an intermediary peer, route the message along its path */
1091  route_message (peer,
1092  &msg->cid,
1093  &msg->header,
1095 }
1096 
1097 
1104 static void
1106  void *cls,
1108 {
1109  struct CadetPeer *peer = cls;
1110  struct CadetConnection *cc;
1111 
1112  /* First, check if message belongs to a connection that ends here. */
1113  cc = GCC_lookup (&msg->kx.cid);
1114  if (NULL != cc)
1115  {
1116  /* verify message came from the right direction */
1117  unsigned int len;
1118  struct CadetPeerPath *path = GCC_get_path (cc, &len);
1119 
1120  if (peer != GCPP_get_peer_at_offset (path, 0))
1121  {
1122  /* received message from unexpected direction, ignore! */
1123  GNUNET_break_op (0);
1124  return;
1125  }
1126  GCC_handle_kx_auth (cc, msg);
1127  return;
1128  }
1129 
1130  /* We're just an intermediary peer, route the message along its path */
1131  route_message (peer,
1132  &msg->kx.cid,
1133  &msg->kx.header,
1135 }
1136 
1137 
1146 static int
1149 {
1150  return GNUNET_YES;
1151 }
1152 
1153 
1160 static void
1163 {
1164  struct CadetPeer *peer = cls;
1165  struct CadetConnection *cc;
1166 
1167  /* First, check if message belongs to a connection that ends here. */
1168  cc = GCC_lookup (&msg->cid);
1169  if (NULL != cc)
1170  {
1171  /* verify message came from the right direction */
1172  unsigned int len;
1173  struct CadetPeerPath *path = GCC_get_path (cc, &len);
1174 
1175  if (peer != GCPP_get_peer_at_offset (path, 0))
1176  {
1177  /* received message from unexpected direction, ignore! */
1178  GNUNET_break_op (0);
1179  return;
1180  }
1181  GCC_handle_encrypted (cc, msg);
1182  return;
1183  }
1184  /* We're just an intermediary peer, route the message along its path */
1185  route_message (peer, &msg->cid, &msg->header, GNUNET_MQ_PRIO_BEST_EFFORT);
1186 }
1187 
1188 
1201 static void
1203 {
1204  if (NULL == my_identity)
1205  {
1206  GNUNET_break (0);
1207  return;
1208  }
1209  GNUNET_break (0 == GNUNET_memcmp (my_identity, &my_full_id));
1210 }
1211 
1212 
1219 static void *
1220 core_connect_cb (void *cls,
1221  const struct GNUNET_PeerIdentity *peer,
1222  struct GNUNET_MQ_Handle *mq)
1223 {
1224  struct CadetPeer *cp;
1225 
1227  "CORE connection to peer %s was established.\n",
1228  GNUNET_i2s (peer));
1229  cp = GCP_get (peer, GNUNET_YES);
1230  GCP_set_mq (cp, mq);
1231  return cp;
1232 }
1233 
1234 
1241 static void
1243  const struct GNUNET_PeerIdentity *peer,
1244  void *peer_cls)
1245 {
1246  struct CadetPeer *cp = peer_cls;
1247 
1249  "CORE connection to peer %s went down.\n",
1250  GNUNET_i2s (peer));
1251  GCP_set_mq (cp, NULL);
1252 }
1253 
1254 
1260 void
1262 {
1263  struct GNUNET_MQ_MessageHandler handlers[] =
1267  NULL),
1268  GNUNET_MQ_hd_fixed_size (connection_create_ack,
1271  NULL),
1272  GNUNET_MQ_hd_fixed_size (connection_broken,
1275  NULL),
1276  GNUNET_MQ_hd_fixed_size (connection_destroy,
1279  NULL),
1280  GNUNET_MQ_hd_fixed_size (tunnel_kx,
1283  NULL),
1284  GNUNET_MQ_hd_fixed_size (tunnel_kx_auth,
1287  NULL),
1288  GNUNET_MQ_hd_var_size (tunnel_encrypted,
1291  NULL),
1293 
1295  "CADET",
1296  "MAX_ROUTES",
1297  &max_routes))
1298  max_routes = 5000;
1300  "CADET",
1301  "MAX_MSGS_QUEUE",
1302  &max_buffers))
1303  max_buffers = 10000;
1306  core = GNUNET_CORE_connect (c,
1307  NULL,
1308  &core_init_cb,
1309  &core_connect_cb,
1311  handlers);
1312 }
1313 
1314 
1318 void
1320 {
1321  if (NULL != core)
1322  {
1323  GNUNET_CORE_disconnect (core);
1324  core = NULL;
1325  }
1328  routes = NULL;
1329  GNUNET_CONTAINER_heap_destroy (route_heap);
1330  route_heap = NULL;
1331  if (NULL != timeout_task)
1332  {
1333  GNUNET_SCHEDULER_cancel (timeout_task);
1334  timeout_task = NULL;
1335  }
1336 }
1337 
1338 /* end of gnunet-cadet-service_core.c */
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void GNUNET_MQ_dll_insert_tail(struct GNUNET_MQ_Envelope **env_head, struct GNUNET_MQ_Envelope **env_tail, struct GNUNET_MQ_Envelope *env)
Insert env into the envelope DLL starting at env_head Note that env must not be in any MQ while this ...
Definition: mq.c:1175
Axolotl-encrypted tunnel message with application payload.
#define GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED
Axolotl encrypted data.
static struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
void GNUNET_MQ_dll_insert_head(struct GNUNET_MQ_Envelope **env_head, struct GNUNET_MQ_Envelope **env_tail, struct GNUNET_MQ_Envelope *env)
Insert env into the envelope DLL starting at env_head Note that env must not be in any MQ while this ...
Definition: mq.c:1153
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:84
static void handle_tunnel_kx(void *cls, const struct GNUNET_CADET_TunnelKeyExchangeMessage *msg)
Handle for GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX.
static unsigned long long max_buffers
Maximum number of envelopes we will buffer at this peer.
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
void GNUNET_CONTAINER_heap_update_cost(struct GNUNET_CONTAINER_HeapNode *node, GNUNET_CONTAINER_HeapCostType new_cost)
Updates the cost of any node in the tree.
unsigned int num_routes
Total number of route directions in this rung.
static void dir_init(struct RouteDirection *dir, struct CadetRoute *route, struct CadetPeer *hop)
Initialize one of the directions of a route.
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:653
Peer description.
const char * GNUNET_i2s2(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env_head
Head of DLL of envelopes we have in the buffer for this direction.
struct RouteDirection * next
DLL of other route directions within the same struct Rung.
Low-level connection to a destination.
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.
const struct GNUNET_MessageHeader * GNUNET_MQ_env_get_msg(const struct GNUNET_MQ_Envelope *env)
Obtain message contained in envelope.
Definition: mq.c:1080
Message to destroy a connection.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct CadetTunnel * GCP_get_tunnel(struct CadetPeer *cp, int create)
Get the tunnel towards a peer.
unsigned int GNUNET_CONTAINER_multishortmap_size(const struct GNUNET_CONTAINER_MultiShortmap *map)
Get the number of key-value pairs in the map.
Context for the core service connection.
Definition: core_api.c:78
struct GNUNET_CONTAINER_HeapNode * GNUNET_CONTAINER_heap_insert(struct GNUNET_CONTAINER_Heap *heap, void *element, GNUNET_CONTAINER_HeapCostType cost)
Inserts a new element into the heap.
static void handle_tunnel_kx_auth(void *cls, const struct GNUNET_CADET_TunnelKeyExchangeAuthMessage *msg)
Handle for GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH.
Information we keep per direction for a route.
A connection is a live end-to-end messaging mechanism where the peers are identified by a path and kn...
struct GNUNET_CONTAINER_HeapNode * hn
Position of this route in the route_heap.
static unsigned long long max_routes
Maximum number of concurrent routes this peer will support.
#define LOG(level,...)
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE.
Data structure used to track whom we have to notify about changes to our message queue.
struct GNUNET_CADET_TunnelKeyExchangeMessage kx
Message header with key material.
static void core_disconnect_cb(void *cls, const struct GNUNET_PeerIdentity *peer, void *peer_cls)
Method called whenever a peer disconnects.
struct GNUNET_PeerIdentity my_full_id
Local peer own ID.
void GCC_destroy_without_core(struct CadetConnection *cc)
Destroy a connection, called when the CORE layer is already done (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Message for ack&#39;ing a connection.
static unsigned long long cur_buffers
Current number of envelopes we have buffered at this peer.
void GCC_handle_kx(struct CadetConnection *cc, const struct GNUNET_CADET_TunnelKeyExchangeMessage *msg)
Handle KX message.
void GNUNET_MQ_env_set_options(struct GNUNET_MQ_Envelope *env, enum GNUNET_MQ_PriorityPreferences pp)
Set application-specific options for this envelope.
Definition: mq.c:1005
int GNUNET_CONTAINER_multishortmap_remove(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
static struct CadetConnection * connection_create(struct CadetPeer *destination, struct CadetPeerPath *path, unsigned int off, struct CadetTConnection *ct, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, enum CadetConnectionState init_state, GCC_ReadyCallback ready_cb, void *ready_cb_cls)
Create a connection to destination via path and notify cb whenever we are ready for more data...
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
void GCC_handle_connection_create_ack(struct CadetConnection *cc)
A GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK was received for this connection, implying that the end-to-end connection is up.
#define GNUNET_NO
Definition: gnunet_common.h:81
struct GNUNET_PeerIdentity peer2
ID of the endpoint.
void GCP_set_mq(struct CadetPeer *cp, struct GNUNET_MQ_Handle *mq)
Set the message queue to mq for peer cp and notify watchers.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
GNUNET_MQ_PriorityPreferences
Per envelope preferences and priorities.
Information we track per tunnel.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition: time.c:393
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GCP_send(struct GCP_MessageQueueManager *mqm, struct GNUNET_MQ_Envelope *env)
Send the message in env to cp.
static struct GNUNET_PeerIdentity my_identity
Identity of this peer.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
static void * core_connect_cb(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a given peer connects.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
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).
Set of CadetRoutes that have exactly the same number of messages in their buffer. ...
struct Rung * prev
Rung of RouteDirections with one less buffer entry each.
static int check_tunnel_encrypted(void *cls, const struct GNUNET_CADET_TunnelEncryptedMessage *msg)
Check if the encrypted message has the appropriate size.
uint64_t abs_value_us
The actual value.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
const struct GNUNET_MQ_Envelope * GNUNET_MQ_env_next(const struct GNUNET_MQ_Envelope *env)
Return next envelope in queue.
Definition: mq.c:1093
struct Rung * next
Rung of RouteDirections with one more buffer entry each.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
static void destroy_direction(struct RouteDirection *dir)
Free internal data of a route direction.
static struct GNUNET_CONTAINER_MultiPeerMap * map
Handle to the map used to store old latency values for peers.
const char * GCP_2s(const struct CadetPeer *cp)
Get the static string for a peer ID.
static void handle_connection_create_ack(void *cls, const struct GNUNET_CADET_ConnectionCreateAckMessage *msg)
Handle for GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK.
Flag to indicate that low latency is important.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
Unique identifier for the connection that uses this route.
enum GNUNET_MQ_PriorityPreferences GNUNET_MQ_env_get_options(struct GNUNET_MQ_Envelope *env)
Get performance preferences set for this envelope.
Definition: mq.c:1020
Best-effort traffic (i.e.
struct CadetRoute * my_route
Route this direction is part of.
const char * GCPP_2s(struct CadetPeerPath *path)
Convert a path to a human-readable string.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK.
struct RouteDirection * rd_head
DLL of route directions with a number of buffer entries matching this rung.
static void destroy_route(struct CadetRoute *route)
Destroy our state for route.
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:1246
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
static struct CadetRoute * get_route(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Get the route corresponding to a hash.
Information we track per peer.
static struct Rung rung_zero
Rung zero (always pointed to by rung_head).
struct CadetPeerPath * GCPP_get_path_from_route(unsigned int path_length, const struct GNUNET_PeerIdentity *pids)
We got an incoming connection, obtain the corresponding path.
#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.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED.
int GCT_add_inbound_connection(struct CadetTunnel *t, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, struct CadetPeerPath *path)
Add a connection to the tunnel.
Message for a Key eXchange for a tunnel, with authentication.
struct RouteDirection prev
Information about the previous hop on this route.
void * GNUNET_CONTAINER_heap_peek(const struct GNUNET_CONTAINER_Heap *heap)
Get element stored at the root of heap.
void GCP_send_ooo(struct CadetPeer *cp, struct GNUNET_MQ_Envelope *env)
Send the message in env to cp, overriding queueing logic.
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:727
Description of a segment of a struct CadetConnection at the intermediate peers.
struct CadetPeer * hop
Target peer.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
struct GNUNET_TIME_Absolute last_use
When was this route last in use?
static struct Rung * rung_head
DLL of rungs, with the head always point to a rung of route directions with no messages in the queue...
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
int GNUNET_CONTAINER_multishortmap_put(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE
Request the creation of a connection.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:439
#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element)
Insert an element into a DLL after the given other element.
Message for notifying a disconnection in a path.
Handle to a node in a heap.
static void dir_ready_cb(void *cls, int ready)
Function called when the message queue to the previous hop becomes available/unavailable.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK
Send origin an ACK that the connection is complete.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
Internal representation of the hash map.
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
Heap with the minimum cost at the root.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
struct RouteDirection next
Information about the next hop on this route.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
Message handler for a specific message type.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
void GNUNET_MQ_dll_remove(struct GNUNET_MQ_Envelope **env_head, struct GNUNET_MQ_Envelope **env_tail, struct GNUNET_MQ_Envelope *env)
Remove env from the envelope DLL starting at env_head.
Definition: mq.c:1196
static void lower_rung(struct RouteDirection *dir)
Lower the rung in which dir is by 1.
void GCC_handle_duplicate_create(struct CadetConnection *cc)
We got a GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE for a connection that we already have...
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:321
Node in the heap.
void GCO_shutdown()
Shut down the CORE subsystem.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Internal representation of the hash map.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct RouteDirection * rd_tail
DLL of route directions with a number of buffer entries matching this rung.
static unsigned int size
Size of the "table".
Definition: peer.c:67
static void core_init_cb(void *cls, const struct GNUNET_PeerIdentity *my_identity)
Function called after GNUNET_CORE_connect has succeeded (or failed for good).
static void send_broken(struct RouteDirection *target, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, const struct GNUNET_PeerIdentity *peer1, const struct GNUNET_PeerIdentity *peer2)
Send message that a route is broken between peer1 and peer2.
unsigned int rung_off
Number of messages route directions at this rung have in their buffer.
struct GNUNET_CORE_Handle * GNUNET_CORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Connect to the core service.
Definition: core_api.c:694
struct GNUNET_PeerIdentity peer1
ID of the endpoint.
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition: core_api.c:732
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct CadetPeerPath * GCC_get_path(struct CadetConnection *cc, unsigned int *off)
Obtain the path used by this connection.
struct GCP_MessageQueueManager * mqm
Message queue manager for hop.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
P2P messages used by CADET.
int GCP_has_core_connection(struct CadetPeer *cp)
Test if cp has a core-level connection.
Handle to a message queue.
Definition: mq.c:85
struct CadetConnection * GCC_lookup(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Lookup a connection by its identifier.
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.
static void handle_tunnel_encrypted(void *cls, const struct GNUNET_CADET_TunnelEncryptedMessage *msg)
Handle for GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED.
The identity of the host (wraps the signing key of the peer).
Hash uniquely identifying a connection below a tunnel.
static struct GNUNET_CONTAINER_Heap * route_heap
Heap of routes, MIN-sorted by last activity.
static struct GNUNET_SCHEDULER_Task * timeout_task
Task to timeout routes.
configuration data
Definition: configuration.c:85
void * GNUNET_CONTAINER_multishortmap_get(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Given a key find a value in the map matching the key.
void GCC_handle_encrypted(struct CadetConnection *cc, const struct GNUNET_CADET_TunnelEncryptedMessage *msg)
Handle encrypted message.
struct CadetPeer * GCP_get(const struct GNUNET_PeerIdentity *peer_id, int create)
Retrieve the CadetPeer stucture associated with the peer.
#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY
Request the destuction of a connection.
void GCP_request_mq_cancel(struct GCP_MessageQueueManager *mqm, struct GNUNET_MQ_Envelope *last_env)
Stops message queue change notifications.
Message for a Key eXchange for a tunnel.
static void handle_connection_create(void *cls, const struct GNUNET_CADET_ConnectionCreateMessage *msg)
Handle for GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX or GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH as part of stru...
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
Flag to indicate that out-of-order delivery is OK.
static void handle_connection_broken(void *cls, const struct GNUNET_CADET_ConnectionBrokenMessage *msg)
Handle for GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN.
static struct PendingResolutions * tail
Tail of list of pending resolution requests.
Definition: gnunet-ats.c:236
struct CadetPeer * GCPP_get_peer_at_offset(struct CadetPeerPath *path, unsigned int off)
Obtain the peer at offset off in path.
struct GNUNET_TIME_Relative keepalive_period
How frequently do we send KEEPALIVE messages on idle connections?
struct Rung * rung
Rung of this route direction (matches length of the buffer DLL).
#define GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH
Axolotl key exchange response with authentication.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:331
static void route_message(struct CadetPeer *prev, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, const struct GNUNET_MessageHeader *msg, const enum GNUNET_MQ_PriorityPreferences priority)
We message msg from prev.
Header for all communications.
void GCC_handle_kx_auth(struct CadetConnection *cc, const struct GNUNET_CADET_TunnelKeyExchangeAuthMessage *msg)
Handle KX_AUTH message.
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:80
void GCO_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize the CORE subsystem.
int is_ready
Is mqm currently ready for transmission?
Flag to indicate that unreliable delivery is acceptable.
static void send_broken_without_mqm(struct CadetPeer *target, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, const struct GNUNET_PeerIdentity *failure_at)
We could not create the desired route.
static void timeout_cb(void *cls)
Function called to check if any routes have timed out, and if so, to clean them up.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:792
struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key
Sender&#39;s ephemeral public ECC key encoded in a format suitable for network transmission, as created using &#39;gcry_sexp_sprint&#39;.
Highest priority, control traffic (i.e.
const char * GNUNET_e2s(const struct GNUNET_CRYPTO_EcdhePublicKey *p)
Convert a public key value to a string (for printing debug messages).
static void discard_all_from_rung_tail()
Discard all messages from the highest rung, to make space.
static int check_connection_create(void *cls, const struct GNUNET_CADET_ConnectionCreateMessage *msg)
Check if the create_connection message has the appropriate size.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_at(struct GNUNET_TIME_Absolute at, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run at the specified time.
Definition: scheduler.c:1223
cadet service; interaction with CORE service
static void discard_buffer(struct RouteDirection *dir, struct GNUNET_MQ_Envelope *env)
Discard the buffer env from the route direction dir and move dir down a rung.
struct RouteDirection * prev
DLL of other route directions within the same struct Rung.
Information regarding a possible path to reach a peer.
struct GNUNET_ShortHashCode connection_of_tunnel
void * GNUNET_CONTAINER_heap_remove_node(struct GNUNET_CONTAINER_HeapNode *node)
Removes a node from the heap.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
static void handle_connection_destroy(void *cls, const struct GNUNET_CADET_ConnectionDestroyMessage *msg)
Handle for GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN.
static struct Rung * rung_tail
Tail of the rung_head DLL.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN
Notify that a connection is no longer valid.
Message for cadet connection creation.
struct GNUNET_MQ_Envelope * env_tail
Tail of DLL of envelopes we have in the buffer for this direction.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
static struct GNUNET_CORE_Handle * core
Handle to the CORE service.
#define GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX
Axolotl key exchange.
#define GNUNET_free(ptr)
Wrapper around free.
const struct GNUNET_PeerIdentity * GCP_get_id(struct CadetPeer *cp)
Obtain the peer identity for a struct CadetPeer.
Time for relative time used by GNUnet, in microseconds.
struct GCP_MessageQueueManager * GCP_request_mq(struct CadetPeer *cp, GCP_MessageQueueNotificationCallback cb, void *cb_cls)
Start message queue change notifications.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY.
static struct GNUNET_CONTAINER_MultiShortmap * routes
Routes on which this peer is an intermediate.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965