GNUnet  0.10.x
gnunet-service-testbed_oc.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2008--2016 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 
27 #include "gnunet-service-testbed.h"
30 
34 #ifdef LOG
35 #undef LOG
36 #endif
37 #define LOG(kind,...) \
38  GNUNET_log_from (kind, "testbed-OC", __VA_ARGS__)
39 
40 
45 {
46 
51 
56 
62 
67 
72 
73 };
74 
75 
80 {
86 
92 
98 };
99 
100 
106 {
112 
117 };
118 
119 
125 {
132 
138 
144 
149  struct Neighbour *p2n;
150 };
151 
156 {
161 
166 
172 
176  struct Peer *peer;
177 
183 
188 
194 
199 
204 
208  char *emsg;
209 
213  union {
214 
218  struct LocalPeer2Context local;
219 
223  struct RemotePeer2Context remote;
224 
225  } p2ctx;
226 
230  struct GNUNET_PeerIdentity peer_identity;
231 
235  struct GNUNET_PeerIdentity other_peer_identity;
236 
240  uint64_t op_id;
241 
247 
252 
257 
262 
266  uint32_t other_peer_id;
267 };
268 
269 
278 {
283 
288 
292  struct Peer *peer;
293 
298 
303 
308 
312  struct GNUNET_PeerIdentity a_id;
313 
318 
323 
327  uint64_t op_id;
328 };
329 
330 
335 
340 
346 
351 
352 
358 void
360 {
361  struct RegisteredHostContext *rhc = focc->rhc;
362 
364  rhc->focc_dll_tail,
365  focc);
367  GNUNET_free (focc);
368 }
369 
370 
376 static void
378 {
379  struct ForwardedOperationContext *fopc = cls;
380  struct RegisteredHostContext *rhc;
381  struct ForwardedOverlayConnectContext *focc;
382 
383  fopc->timeout_task = NULL;
384  rhc = fopc->cls;
385  focc = rhc->focc_dll_head;
386  LOG_DEBUG ("Overlay linking between peers %u and %u failed\n",
387  focc->peer1,
388  focc->peer2);
389  GST_cleanup_focc (focc);
391  if (NULL != rhc->focc_dll_head)
392  GST_process_next_focc (rhc);
393 }
394 
395 
404 static void
406  const struct GNUNET_MessageHeader *msg)
407 {
408  struct ForwardedOperationContext *fopc = cls;
409  struct RegisteredHostContext *rhc;
410  struct ForwardedOverlayConnectContext *focc;
411 
412  rhc = fopc->cls;
414  focc = rhc->focc_dll_head;
415  GST_cleanup_focc (focc);
416  if (NULL != rhc->focc_dll_head)
417  GST_process_next_focc (rhc);
418 }
419 
420 
426 void
428 {
429  struct ForwardedOperationContext *fopc;
430  struct ForwardedOverlayConnectContext *focc;
431  struct Peer *peer;
432  struct Slave *slave;
433 
434  focc = rhc->focc_dll_head;
435  GNUNET_assert (NULL != focc);
436  GNUNET_assert (RHC_DONE == rhc->state);
438  peer = GST_peer_list[focc->peer1];
440  GNUNET_assert (NULL != (slave = peer->details.remote.slave));
441  fopc = GNUNET_new (struct ForwardedOperationContext);
442  fopc->client = focc->client;
443  fopc->operation_id = focc->operation_id;
444  fopc->cls = rhc;
445  fopc->type = OP_OVERLAY_CONNECT;
446  fopc->opc =
448  focc->operation_id,
449  focc->orig_msg,
451  fopc);
452  GNUNET_free (focc->orig_msg);
453  focc->orig_msg = NULL;
456  fopc);
458  fopcq_tail,
459  fopc);
460 }
461 
462 
468 static void
470 {
471  if (NULL != lp2c->ohh)
472  {
474  lp2c->ohh = NULL;
475  }
476  if (NULL != lp2c->tcc.cgh_p2_th)
477  {
479  lp2c->tcc.cgh_p2_th = NULL;
480  }
481  if (NULL != lp2c->tcc.cgh_p2_ats)
482  {
484  lp2c->tcc.cgh_p2_ats = NULL;
485  }
486  if (NULL != lp2c->tcc.csh)
487  {
489  lp2c->tcc.csh = NULL;
490  }
491 }
492 
493 
500 static void
502 {
503  if (NULL != rp2c->opc)
504  {
506  rp2c->opc = NULL;
507  }
508  if (NULL != rp2c->ncn)
509  {
511  rp2c->ncn = NULL;
512  }
513  if ( (NULL != rp2c->p2c) && (NULL != rp2c->p2n) )
514  {
516  rp2c->p2n = NULL;
517  }
518 }
519 
525 #define PEER_EXPIRED(peer) \
526  ( (GNUNET_YES == peer->destroy_flag) && (0 == peer->reference_cnt) )
527 
533 static void
535 {
536  struct Peer *peer2;
537 
538  LOG_DEBUG ("0x%llx: Cleaning up occ\n",
539  occ->op_id);
540  GNUNET_free_non_null (occ->emsg);
542  if (NULL != occ->send_hello_task)
544  if (NULL != occ->cleanup_task)
546  if (NULL != occ->timeout_task)
548  if (NULL != occ->cgh_ch)
550  if (NULL != occ->ghh)
553  GNUNET_assert (NULL != GST_peer_list);
554  GNUNET_assert (occ->peer->reference_cnt > 0);
555  occ->peer->reference_cnt--;
556  if (PEER_EXPIRED (occ->peer))
557  GST_destroy_peer (occ->peer);
558  switch (occ->type)
559  {
560  case OCC_TYPE_LOCAL:
561  peer2 = GST_peer_list[occ->other_peer_id];
562  GNUNET_assert (peer2->reference_cnt > 0);
563  peer2->reference_cnt--;
564  if (PEER_EXPIRED (peer2))
565  GST_destroy_peer (peer2);
566  cleanup_occ_lp2c (&occ->p2ctx.local);
567  break;
570  cleanup_occ_rp2c (&occ->p2ctx.remote);
571  break;
572  }
573  GNUNET_CONTAINER_DLL_remove (occq_head,
574  occq_tail,
575  occ);
576  GNUNET_free (occ);
577 }
578 
579 
585 static void
586 do_cleanup_occ (void *cls)
587 {
588  struct OverlayConnectContext *occ = cls;
589 
590  occ->cleanup_task = NULL;
591  cleanup_occ (occ);
592 }
593 
594 
600 static void
602 {
603  struct OverlayConnectContext *occ = cls;
604 
605  GNUNET_assert (NULL != occ->timeout_task);
606  occ->timeout_task = NULL;
607  /* LOG (GNUNET_ERROR_TYPE_WARNING, */
608  /* "0x%llx: Timeout while connecting peers %u and %u: %s\n", occ->op_id, */
609  /* occ->peer->id, occ->other_peer_id, occ->emsg); */
611  occ->op_id,
612  occ->emsg);
613  cleanup_occ (occ);
614 }
615 
616 
622 void
624 {
625  struct ForwardedOperationContext *fopc;
626  struct ForwardedOperationContext *fopcn;
627  struct OverlayConnectContext *occ;
628  struct OverlayConnectContext *occn;
629 
630  for (fopc = fopcq_head; NULL != fopc; fopc = fopcn)
631  {
632  fopcn = fopc->next;
633  if (fopc->client == client)
634  {
637  }
638  }
639  for (occ = occq_head; NULL != occ; occ = occn)
640  {
641  occn = occ->next;
642  if (occ->client == client)
643  cleanup_occ (occ);
644  }
645  // FIXME: implement clean up for client_keep replacements!
646 }
647 
648 
649 
650 
654 static void
656 {
657  struct GNUNET_MQ_Envelope *env;
659 
660  LOG_DEBUG ("0x%llx: Peers connected - Sending overlay connect success\n",
661  occ->op_id);
662  env = GNUNET_MQ_msg (msg,
664  msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT);
665  msg->peer1 = htonl (occ->peer->id);
666  msg->peer2 = htonl (occ->other_peer_id);
667  msg->operation_id = GNUNET_htonll (occ->op_id);
669  env);
670 }
671 
672 
680 static void
682  const struct GNUNET_PeerIdentity *new_peer)
683 {
684  struct OverlayConnectContext *occ = cls;
685  char *new_peer_str;
686  char *other_peer_str;
687 
688  LOG_DEBUG ("Overlay connect notify\n");
689  if (0 ==
690  memcmp (new_peer, &occ->peer_identity,
691  sizeof (struct GNUNET_PeerIdentity)))
692  return;
693  new_peer_str = GNUNET_strdup (GNUNET_i2s (new_peer));
694  other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
695  if (0 !=
696  memcmp (new_peer,
697  &occ->other_peer_identity,
698  sizeof (struct GNUNET_PeerIdentity)))
699  {
700  LOG_DEBUG ("Unexpected peer %s connected when expecting peer %s\n",
701  new_peer_str,
702  other_peer_str);
703  GNUNET_free (new_peer_str);
704  GNUNET_free (other_peer_str);
705  return;
706  }
707  GNUNET_free (new_peer_str);
708  LOG_DEBUG ("0x%llx: Peer %s connected to peer %s\n",
709  occ->op_id,
710  other_peer_str,
711  GNUNET_i2s (&occ->peer_identity));
712  GNUNET_free (other_peer_str);
713  if (NULL != occ->send_hello_task)
714  {
716  occ->send_hello_task = NULL;
717  }
718  GNUNET_assert (NULL != occ->timeout_task);
720  occ->timeout_task = NULL;
721  switch (occ->type)
722  {
723  case OCC_TYPE_LOCAL:
724  cleanup_occ_lp2c (&occ->p2ctx.local);
725  break;
728  cleanup_occ_rp2c (&occ->p2ctx.remote);
729  break;
730  }
731  GNUNET_free_non_null (occ->emsg);
732  occ->emsg = NULL;
735  occ);
736 }
737 
738 
749 static void
751  struct GNUNET_CORE_Handle *ch,
752  struct GNUNET_TRANSPORT_CoreHandle *th,
754  const struct GNUNET_PeerIdentity *my_identity,
755  const struct GNUNET_CONFIGURATION_Handle *cfg)
756 {
757  struct OverlayConnectContext *occ = cls;
758  struct LocalPeer2Context *lp2c;
759 
761  GNUNET_assert (NULL != occ->timeout_task);
762  GNUNET_free_non_null (occ->emsg);
763  if (NULL == ac)
764  {
765  GNUNET_asprintf (&occ->emsg,
766  "0x%llx: Failed to connect to ATS of peer with id: %u",
767  occ->op_id,
768  occ->peer->id);
770  occ->timeout_task =
772  occ);
773  return;
774  }
775  occ->emsg = NULL;
776 
777  GNUNET_asprintf (&occ->emsg,
778  "0x%llx: Timeout during GNUNET_ATS_connectivity_suggest() at peer %s",
779  occ->op_id,
781 
782  lp2c = &occ->p2ctx.local;
783  lp2c->tcc.csh =
785  &occ->peer_identity,
786  1);
787 }
788 
789 
799 static void
801  struct GNUNET_CORE_Handle *ch,
802  struct GNUNET_TRANSPORT_CoreHandle *th,
804  const struct GNUNET_PeerIdentity *my_identity,
805  const struct GNUNET_CONFIGURATION_Handle *cfg)
806 {
807  struct RemoteOverlayConnectCtx *rocc = cls;
808 
809  rocc->tcc.csh =
811  &rocc->a_id,
812  1);
813 }
814 
815 
822 static void
823 send_hello (void *cls);
824 
825 
833 static void
834 occ_hello_sent_cb (void *cls)
835 {
836  struct OverlayConnectContext *occ = cls;
837  struct LocalPeer2Context *lp2c;
838  struct Peer *peer2;
839 
841  GNUNET_assert (NULL != occ->timeout_task);
842  lp2c = &occ->p2ctx.local;
843  lp2c->ohh = NULL;
844 
845  GNUNET_assert (NULL == occ->send_hello_task);
846  GNUNET_free_non_null (occ->emsg);
847 
848  GNUNET_asprintf (&occ->emsg,
849  "0x%llx: Timeout while acquiring ATS of %s from cache",
850  occ->op_id,
852  GNUNET_assert (NULL != (peer2 = GST_peer_list[occ->other_peer_id]));
853  lp2c->tcc.cgh_p2_ats =
855  peer2->details.local.cfg,
858  occ, NULL, NULL, NULL);
859 }
860 
861 
869 static void
871 {
873  char *other_peer_str;
874  uint16_t msize;
875  uint16_t hello_size;
876 
878  GNUNET_assert (NULL != occ->hello);
879  other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
880  LOG_DEBUG ("0x%llx: Offering HELLO of %s (size: %u) to %s via Remote Overlay Request\n",
881  occ->op_id,
882  GNUNET_i2s (&occ->peer_identity),
883  ntohs (occ->hello->size),
884  other_peer_str);
885  GNUNET_free (other_peer_str);
886  hello_size = ntohs (occ->hello->size);
887  msize = sizeof (struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hello_size;
888  msg = GNUNET_malloc (msize);
889  msg->header.type =
891  msg->header.size = htons (msize);
892  msg->peer = htonl (occ->other_peer_id);
893  msg->operation_id = GNUNET_htonll (occ->op_id);
894  msg->peer_identity = occ->peer_identity;
895  GNUNET_memcpy (msg->hello,
896  occ->hello,
897  hello_size);
899  &msg->header);
900 }
901 
902 
910 static void
911 send_hello (void *cls)
912 {
913  struct OverlayConnectContext *occ = cls;
914  struct LocalPeer2Context *lp2c;
915  char *other_peer_str;
916 
917  occ->send_hello_task = NULL;
918  GNUNET_assert (NULL != occ->timeout_task);
919  GNUNET_assert (NULL != occ->hello);
920  if (OCC_TYPE_LOCAL != occ->type)
921  {
922  send_hello_thru_rocc (occ);
923  return;
924  }
925  lp2c = &occ->p2ctx.local;
926  other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
927  LOG_DEBUG ("0x%llx: Offering HELLO of %s to %s\n",
928  occ->op_id,
929  GNUNET_i2s (&occ->peer_identity),
930  other_peer_str);
931  GNUNET_free (other_peer_str);
932  lp2c->ohh =
934  occ->hello,
936  occ);
937  if (NULL == lp2c->ohh)
938  {
939  GNUNET_break (0);
940  occ->send_hello_task =
943  100 +
946  &send_hello, occ);
947  }
948 }
949 
950 
961 static void
963  struct GNUNET_CORE_Handle *ch,
964  struct GNUNET_TRANSPORT_CoreHandle *th,
966  const struct GNUNET_PeerIdentity *ignore_,
967  const struct GNUNET_CONFIGURATION_Handle *cfg)
968 {
969  struct OverlayConnectContext *occ = cls;
970 
972  if (NULL == th)
973  {
974  GNUNET_asprintf (&occ->emsg,
975  "0x%llx: Cannot connect to TRANSPORT of %s",
976  occ->op_id,
979  occ->timeout_task =
981  return;
982  }
983  occ->p2ctx.local.tcc.th_ = th;
984  occ->p2ctx.local.tcc.cfg = cfg;
985  GNUNET_asprintf (&occ->emsg,
986  "0x%llx: Timeout while offering HELLO to %s",
987  occ->op_id,
990 }
991 
992 
999 static void
1001 {
1002  struct Peer *peer2;
1003 
1004  /* HUH? Why to *obtain* HELLO? Seems we use this to *SEND* the
1005  HELLO! */
1007  "Connecting to transport of peer %s to obtain HELLO\n",
1009  GNUNET_assert (NULL == occ->emsg);
1010  GNUNET_assert (NULL != occ->hello);
1011  GNUNET_assert (NULL == occ->ghh);
1012  GNUNET_assert (NULL == occ->p1th_);
1013  GNUNET_assert (NULL == occ->cgh_p1th);
1014  if (OCC_TYPE_LOCAL == occ->type)
1015  {
1016  GNUNET_assert (NULL != (peer2 = GST_peer_list[occ->other_peer_id]));
1017  occ->p2ctx.local.tcc.cgh_p2_th =
1019  peer2->details.local.cfg,
1022  occ, NULL, NULL, NULL);
1023  return;
1024  }
1025  GNUNET_asprintf (&occ->emsg,
1026  "0x%llx: Timeout while offering HELLO to %s",
1027  occ->op_id,
1030 }
1031 
1032 
1041 static int
1042 test_address (void *cls,
1043  const struct GNUNET_HELLO_Address *address,
1045 {
1046  int *empty = cls;
1047 
1048  *empty = GNUNET_NO;
1049  return GNUNET_OK;
1050 }
1051 
1052 
1061 static void
1062 hello_update_cb (void *cls,
1063  const struct GNUNET_MessageHeader *hello)
1064 {
1065  struct OverlayConnectContext *occ = cls;
1066  int empty;
1067  uint16_t msize;
1068 
1069  msize = ntohs (hello->size);
1070  empty = GNUNET_YES;
1071  (void) GNUNET_HELLO_iterate_addresses ((const struct GNUNET_HELLO_Message *)
1072  hello, GNUNET_NO,
1073  &test_address,
1074  &empty);
1075  if (GNUNET_YES == empty)
1076  {
1077  LOG_DEBUG ("0x%llx: HELLO of %s is empty\n",
1078  occ->op_id,
1079  GNUNET_i2s (&occ->peer_identity));
1080  return;
1081  }
1082  LOG_DEBUG ("0x%llx: Received HELLO of %s\n",
1083  occ->op_id,
1084  GNUNET_i2s (&occ->peer_identity));
1085  occ->hello = GNUNET_malloc (msize);
1086  GST_cache_add_hello (occ->peer->id, hello);
1087  GNUNET_memcpy (occ->hello, hello, msize);
1089  occ->ghh = NULL;
1091  occ->cgh_p1th = NULL;
1092  occ->p1th_ = NULL;
1093  GNUNET_free_non_null (occ->emsg);
1094  occ->emsg = NULL;
1095  p2_transport_connect (occ);
1096 }
1097 
1098 
1108 static void
1110  struct GNUNET_CORE_Handle *ch,
1111  struct GNUNET_TRANSPORT_CoreHandle *th,
1113  const struct GNUNET_PeerIdentity *ignore_,
1114  const struct GNUNET_CONFIGURATION_Handle *cfg)
1115 {
1116  struct OverlayConnectContext *occ = cls;
1117 
1118  GNUNET_free_non_null (occ->emsg);
1119  occ->emsg = NULL;
1120  if (NULL == th)
1121  {
1122  GNUNET_asprintf (&occ->emsg,
1123  "0x%llx: Cannot connect to TRANSPORT of %s",
1124  occ->op_id,
1125  GNUNET_i2s (&occ->peer_identity));
1127  occ->timeout_task =
1129  return;
1130  }
1131  GNUNET_assert (NULL == occ->p1th_);
1132  GNUNET_assert (NULL != occ->cgh_p1th);
1133  occ->p1th_ = th;
1134  GNUNET_asprintf (&occ->emsg,
1135  "0x%llx: Timeout while acquiring HELLO of peer %s",
1136  occ->op_id,
1137  GNUNET_i2s (&occ->peer_identity));
1138  occ->ghh = GNUNET_TRANSPORT_hello_get (cfg,
1140  &hello_update_cb,
1141  occ);
1142 }
1143 
1144 
1154 static void
1156  struct GNUNET_CORE_Handle *ch,
1157  struct GNUNET_TRANSPORT_CoreHandle *th,
1159  const struct GNUNET_PeerIdentity *my_identity,
1160  const struct GNUNET_CONFIGURATION_Handle *cfg)
1161 {
1162  struct OverlayConnectContext *occ = cls;
1163  const struct GNUNET_MessageHeader *hello;
1164 
1165  GNUNET_assert (NULL != occ->timeout_task);
1166  GNUNET_free_non_null (occ->emsg);
1167  if ((NULL == ch) || (NULL == my_identity))
1168  {
1169  GNUNET_asprintf (&occ->emsg,
1170  "0x%llx: Failed to connect to CORE of peer with "
1171  "id: %u",
1172  occ->op_id,
1173  occ->peer->id);
1175  occ->timeout_task =
1177  return;
1178  }
1179  occ->emsg = NULL;
1180  if (NULL !=
1181  GNUNET_CORE_get_mq (ch,
1182  &occ->other_peer_identity))
1183  {
1184  LOG_DEBUG ("0x%llx: Target peer already connected\n",
1185  occ->op_id);
1187  occ->timeout_task = NULL;
1190  return;
1191  }
1192  occ->peer_identity = *my_identity;
1193  LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n",
1194  occ->op_id,
1195  GNUNET_i2s (&occ->peer_identity));
1196  /* Lookup for HELLO in hello cache */
1197  if (NULL != (hello = GST_cache_lookup_hello (occ->peer->id)))
1198  {
1199  LOG_DEBUG ("0x%llx: HELLO of peer %s found in cache\n",
1200  occ->op_id,
1201  GNUNET_i2s (&occ->peer_identity));
1202  occ->hello = GNUNET_copy_message (hello);
1203  p2_transport_connect (occ);
1204  return;
1205  }
1206  GNUNET_asprintf (&occ->emsg,
1207  "0x%llx: Timeout while acquiring TRANSPORT of %s from cache",
1208  occ->op_id,
1209  GNUNET_i2s (&occ->peer_identity));
1210  occ->cgh_p1th =
1212  occ->peer->details.local.cfg,
1215  occ,
1216  NULL, NULL, NULL);
1217 }
1218 
1219 
1228 static void
1230  const struct GNUNET_MessageHeader *msg)
1231 {
1232  struct OverlayConnectContext *occ = cls;
1233  struct RemotePeer2Context *rp2c;
1235 
1236  GNUNET_assert (OCC_TYPE_LOCAL != occ->type);
1237  rp2c = &occ->p2ctx.remote;
1238  rp2c->opc = NULL;
1239  GNUNET_assert (NULL != occ->timeout_task);
1241  {
1243  occ->timeout_task =
1245  }
1246  cmsg =
1248  occ->other_peer_identity = cmsg->peer_identity;
1249  GNUNET_free_non_null (occ->emsg);
1250  GNUNET_asprintf (&occ->emsg,
1251  "0x%llx: Timeout while connecting to CORE of peer with "
1252  "id: %u",
1253  occ->op_id,
1254  occ->peer->id);
1255  occ->cgh_ch =
1257  occ->peer->details.local.cfg,
1260  occ,
1261  &occ->other_peer_identity,
1263  occ);
1264  return;
1265 }
1266 
1267 
1274 static void
1275 host_registration_comp (void *cls, const char *emsg)
1276 {
1277  struct RegisteredHostContext *rhc = cls;
1278 
1279  rhc->state = RHC_DONE;
1280  GST_process_next_focc (rhc);
1281 }
1282 
1283 
1294 static int
1296  const struct GNUNET_HashCode *key,
1297  void *value)
1298 {
1299  struct RegisteredHostContext **rh = cls;
1300  struct RegisteredHostContext *rh_val = value;
1301 
1302  if ((rh_val->host == (*rh)->host) && (rh_val->reg_host == (*rh)->reg_host))
1303  {
1304  GNUNET_free (*rh);
1305  *rh = rh_val;
1306  return GNUNET_NO;
1307  }
1308  return GNUNET_YES;
1309 }
1310 
1311 
1319 static struct GNUNET_HashCode
1321  struct GNUNET_TESTBED_Host *host)
1322 {
1323  struct GNUNET_HashCode hash;
1324  uint32_t host_ids[2];
1325 
1326  host_ids[0] = GNUNET_TESTBED_host_get_id_ (reg_host);
1327  host_ids[1] = GNUNET_TESTBED_host_get_id_ (host);
1328  GNUNET_CRYPTO_hash (host_ids, sizeof (host_ids), &hash);
1329  return hash;
1330 }
1331 
1332 
1346 static struct RegisteredHostContext *
1347 register_host (struct Slave *slave,
1348  struct GNUNET_TESTBED_Host *host)
1349 {
1350  struct GNUNET_HashCode hash;
1351  struct RegisteredHostContext *rhc;
1352 
1353  rhc = GNUNET_new (struct RegisteredHostContext);
1354  rhc->reg_host = host;
1355  rhc->host = GST_host_list[slave->host_id];
1356  GNUNET_assert (NULL != rhc->reg_host);
1357  GNUNET_assert (NULL != rhc->host);
1358  rhc->state = RHC_INIT;
1359  hash = hash_hosts (rhc->reg_host, rhc->host);
1360  if ((GNUNET_NO ==
1362  &hash)) ||
1363  (GNUNET_SYSERR !=
1365  &hash,
1367  &rhc)))
1368  {
1369  /* create and add a new registerd host context */
1370  /* add the focc to its queue */
1372  &hash,
1373  rhc,
1377  rhc,
1378  rhc->reg_host);
1379  }
1380  else
1381  {
1382  /* rhc is now set to the existing one from the hash map by
1383  * reghost_match_iterator() */
1384  /* if queue is empty then ignore creating focc and proceed with normal
1385  * forwarding */
1386  if (RHC_DONE == rhc->state)
1387  return NULL;
1388  }
1389  return rhc;
1390 }
1391 
1392 
1402 static void
1404  struct GNUNET_SERVICE_Client *client)
1405 {
1406  struct ForwardedOperationContext *fopc;
1407  struct Route *route_to_peer2_host;
1408  struct Route *route_to_peer1_host;
1409  struct Peer *peer;
1410  struct RegisteredHostContext *rhc;
1411  struct ForwardedOverlayConnectContext *focc;
1412  uint64_t op_id;
1413  uint32_t peer2_host_id;
1414  uint32_t p1;
1415  uint32_t p2;
1416 
1417  p1 = ntohl (msg->peer1);
1418  p2 = ntohl (msg->peer2);
1419  op_id = GNUNET_ntohll (msg->operation_id);
1420  peer2_host_id = ntohl (msg->peer2_host_id);
1422  GNUNET_assert (VALID_HOST_ID (peer2_host_id));
1423  peer = GST_peer_list[p1];
1424  GNUNET_assert (GNUNET_YES == peer->is_remote);
1425  LOG_DEBUG ("0x%llx: Forwarding overlay connect\n", op_id);
1426  route_to_peer2_host = GST_find_dest_route (peer2_host_id);
1427  route_to_peer1_host = GST_find_dest_route
1428  (peer->details.remote.remote_host_id);
1429  GNUNET_assert (NULL != route_to_peer1_host);
1430  if ((NULL != route_to_peer2_host) &&
1431  (route_to_peer1_host->dest == route_to_peer2_host->dest))
1432  goto forward;
1433  /* Peer2 is either with us OR peer1 and peer2 can be reached through
1434  different subtrees OR peer2 is on a subtree unknown to us */
1435  if (NULL != (rhc = register_host (peer->details.remote.slave,
1436  GST_host_list[peer2_host_id])))
1437  {
1438  LOG_DEBUG ("Queueing forwarding FOCC for connecting peers %u and %u\n", p1, p2);
1440  focc->rhc = rhc;
1441  focc->peer1 = p1;
1442  focc->peer2 = p2;
1443  focc->peer2_host_id = peer2_host_id;
1444  focc->orig_msg = GNUNET_copy_message (&msg->header);
1445  focc->operation_id = op_id;
1446  focc->client = client;
1448  rhc->focc_dll_tail,
1449  focc);
1450  return;
1451  }
1452 
1453  forward:
1454  LOG_DEBUG ("Forwarding without FOCC for connecting peers %u and %u\n", p1, p2);
1455  fopc = GNUNET_new (struct ForwardedOperationContext);
1456  fopc->client = client;
1457  fopc->operation_id = op_id;
1458  fopc->type = OP_OVERLAY_CONNECT;
1459  fopc->opc =
1461  slave->controller, op_id,
1462  &msg->header,
1464  fopc);
1465  fopc->timeout_task =
1468  fopc);
1470  fopcq_tail,
1471  fopc);
1472 }
1473 
1474 
1482 static void
1484  struct GNUNET_TESTBED_Controller *c)
1485 {
1486  struct OverlayConnectContext *occ = cls;
1487  struct RemotePeer2Context *rp2c;
1489 
1490  GNUNET_assert (OCC_TYPE_LOCAL != occ->type);
1491  rp2c = &occ->p2ctx.remote;
1492  rp2c->ncn = NULL;
1493  rp2c->p2c = c;
1494  cmsg.header.size =
1495  htons (sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage));
1496  cmsg.header.type =
1498  cmsg.peer_id = htonl (occ->other_peer_id);
1499  cmsg.operation_id = GNUNET_htonll (occ->op_id);
1500  rp2c->opc =
1502  occ->op_id,
1503  &cmsg.header,
1505  occ);
1506  GNUNET_free_non_null (occ->emsg);
1507  GNUNET_asprintf (&occ->emsg,
1508  "0x%llx: Timeout while getting peer identity of peer "
1509  "with id: %u",
1510  occ->op_id,
1511  occ->other_peer_id);
1512 }
1513 
1514 
1521 void
1524 {
1525  struct GNUNET_SERVICE_Client *client = cls;
1526  struct Peer *peer;
1527  struct Peer *peer2;
1528  struct OverlayConnectContext *occ;
1529  struct Neighbour *p2n;
1530  uint64_t operation_id;
1531  uint32_t p1;
1532  uint32_t p2;
1533  uint32_t peer2_host_id;
1534 
1535  p1 = ntohl (msg->peer1);
1536  p2 = ntohl (msg->peer2);
1537  if (! VALID_PEER_ID (p1))
1538  {
1539  GNUNET_break (0);
1540  GNUNET_SERVICE_client_drop (client);
1541  return;
1542  }
1543  peer = GST_peer_list[p1];
1544  operation_id = GNUNET_ntohll (msg->operation_id);
1545  LOG_DEBUG
1546  ("Received overlay connect for peers %u and %u with op id: 0x%llx\n",
1547  p1,
1548  p2,
1549  operation_id);
1550  peer2_host_id = ntohl (msg->peer2_host_id);
1551  if (GNUNET_YES == peer->is_remote)
1552  {
1553  if (! VALID_HOST_ID (peer2_host_id))
1554  {
1555  GNUNET_break (0);
1556  GNUNET_SERVICE_client_drop (client);
1557  return;
1558  }
1559  forward_overlay_connect (msg, client);
1561  return;
1562  }
1563  p2n = NULL;
1564  occ = GNUNET_new (struct OverlayConnectContext);
1565  occ->type = OCC_TYPE_LOCAL;
1566  if (! VALID_PEER_ID (p2)) /* May be peer2 is on a another controller */
1567  {
1568  if (NULL == (p2n = GST_get_neighbour (peer2_host_id)))
1569  {
1570  if (! VALID_HOST_ID (peer2_host_id))
1571  {
1572  GNUNET_break (0);
1574  "0x%llx: Peer %u's host not in our neighbours list\n",
1575  operation_id, p2);
1576  GNUNET_SERVICE_client_drop (client);
1577  GNUNET_free (occ);
1578  return;
1579  }
1580  p2n = GST_create_neighbour (GST_host_list[peer2_host_id]);
1581  }
1583  occ->p2ctx.remote.p2n = p2n;
1584  }
1585  else if (GNUNET_YES == GST_peer_list[p2]->is_remote)
1586  {
1587  occ->type = OCC_TYPE_REMOTE_SLAVE;
1588  occ->p2ctx.remote.p2c = GST_peer_list[p2]->details.remote.slave->controller;
1589  }
1591  occq_tail,
1592  occ);
1593  occ->client = client;
1594  occ->other_peer_id = p2;
1596  occ->peer = GST_peer_list[p1];
1597  occ->op_id = operation_id;
1598  GNUNET_assert (NULL == occ->timeout_task);
1599  occ->timeout_task =
1602  occ);
1603  switch (occ->type)
1604  {
1606  GNUNET_asprintf (&occ->emsg,
1607  "0x%llx: Timeout while acquiring connection to peer %u's "
1608  "host: %u\n",
1609  occ->op_id,
1610  occ->other_peer_id,
1611  peer2_host_id);
1612  occ->p2ctx.remote.ncn
1615  occ);
1616  break;
1617  case OCC_TYPE_REMOTE_SLAVE:
1619  occ->p2ctx.remote.p2c);
1620  break;
1621  case OCC_TYPE_LOCAL:
1622  peer2 = GST_peer_list[occ->other_peer_id];
1623  peer2->reference_cnt++;
1625  &occ->other_peer_identity);
1626  GNUNET_asprintf (&occ->emsg,
1627  "0x%llx: Timeout while connecting to CORE of peer with "
1628  "id: %u",
1629  occ->op_id,
1630  occ->peer->id);
1631  occ->cgh_ch =
1633  occ->peer->details.local.cfg,
1636  &occ->other_peer_identity,
1637  &overlay_connect_notify, occ);
1638  break;
1639  }
1641 }
1642 
1643 
1650 static void
1652 {
1653  LOG_DEBUG ("0x%llx: Cleaning up rocc\n",
1654  rocc->op_id);
1655  if (NULL != rocc->attempt_connect_task_id)
1657  if (NULL != rocc->timeout_rocc_task_id)
1659  if (NULL != rocc->ohh)
1661  if (NULL != rocc->tcc.csh)
1665  GNUNET_assert (rocc->peer->reference_cnt > 0);
1666  rocc->peer->reference_cnt--;
1667  if ((GNUNET_YES == rocc->peer->destroy_flag) &&
1668  (0 == rocc->peer->reference_cnt))
1669  GST_destroy_peer (rocc->peer);
1670  GNUNET_free_non_null (rocc->hello);
1671  GNUNET_CONTAINER_DLL_remove (roccq_head,
1672  roccq_tail,
1673  rocc);
1674  GNUNET_free (rocc);
1675 }
1676 
1677 
1683 static void
1685 {
1686  struct RemoteOverlayConnectCtx *rocc = cls;
1687 
1688  GNUNET_assert (rocc->timeout_rocc_task_id != NULL);
1689  rocc->timeout_rocc_task_id = NULL;
1690  LOG_DEBUG ("0x%llx: rocc timed out\n",
1691  rocc->op_id);
1692  cleanup_rocc (rocc);
1693 }
1694 
1695 
1703 static void
1705  const struct GNUNET_PeerIdentity *new_peer)
1706 {
1707  struct RemoteOverlayConnectCtx *rocc = cls;
1708 
1709  LOG_DEBUG ("0x%llx: Request Overlay connect notify\n",
1710  rocc->op_id);
1711  GNUNET_assert (0 ==
1712  memcmp (new_peer, &rocc->a_id,
1713  sizeof (struct GNUNET_PeerIdentity)));
1714  LOG_DEBUG ("0x%llx: Peer %s connected\n",
1715  rocc->op_id,
1716  GNUNET_i2s (&rocc->a_id));
1717  cleanup_rocc (rocc);
1718 }
1719 
1720 
1727 static void
1728 attempt_connect_task (void *cls);
1729 
1730 
1738 static void
1740 {
1741  struct RemoteOverlayConnectCtx *rocc = cls;
1742 
1743  rocc->ohh = NULL;
1744  GNUNET_assert (NULL == rocc->attempt_connect_task_id);
1745  LOG_DEBUG ("0x%llx: HELLO of peer %s delivered to local peer with id: %u\n",
1746  rocc->op_id,
1747  GNUNET_i2s (&rocc->a_id),
1748  rocc->peer->id);
1749  rocc->tcc.cgh_p2_ats =
1751  rocc->peer->details.local.cfg,
1754  rocc, NULL, NULL, NULL);
1755 }
1756 
1757 
1764 static void
1766 {
1767  struct RemoteOverlayConnectCtx *rocc = cls;
1768 
1769  GNUNET_assert (NULL != rocc->attempt_connect_task_id);
1770  rocc->attempt_connect_task_id = NULL;
1771  LOG_DEBUG ("0x%llx: Offering HELLO of peer %s to remote peer with id: %u\n",
1772  rocc->op_id,
1773  GNUNET_i2s (&rocc->a_id),
1774  rocc->peer->id);
1775  rocc->ohh =
1777  rocc->hello,
1779  rocc);
1780  if (NULL == rocc->ohh)
1781  rocc->attempt_connect_task_id =
1784  100 +
1787  &attempt_connect_task, rocc);
1788 }
1789 
1790 
1800 static void
1802  struct GNUNET_CORE_Handle *ch,
1803  struct GNUNET_TRANSPORT_CoreHandle *th,
1805  const struct GNUNET_PeerIdentity *ignore_,
1806  const struct GNUNET_CONFIGURATION_Handle *cfg)
1807 {
1808  struct RemoteOverlayConnectCtx *rocc = cls;
1809 
1810  if (NULL == th)
1811  {
1812  rocc->timeout_rocc_task_id =
1814  return;
1815  }
1816  rocc->tcc.th_ = th;
1817  rocc->tcc.cfg = cfg;
1818  if (NULL !=
1820  &rocc->a_id))
1821  {
1822  LOG_DEBUG ("0x%llx: Target peer %s already connected to local peer: %u\n",
1823  rocc->op_id,
1824  GNUNET_i2s (&rocc->a_id),
1825  rocc->peer->id);
1826  cleanup_rocc (rocc);
1827  return;
1828  }
1829  rocc->attempt_connect_task_id =
1831 }
1832 
1833 
1841 int
1844 {
1845  uint32_t peer_id;
1846  uint16_t msize;
1847  uint16_t hsize;
1848 
1849  msize = ntohs (msg->header.size);
1850  if (GNUNET_MESSAGE_TYPE_HELLO != ntohs (msg->hello->type))
1851  {
1852  GNUNET_break (0);
1853  return GNUNET_SYSERR;
1854  }
1855  hsize = ntohs (msg->hello->size);
1856  if ((sizeof (struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hsize) != msize)
1857  {
1858  GNUNET_break (0);
1859  return GNUNET_SYSERR;
1860  }
1861  peer_id = ntohl (msg->peer);
1862  if ((peer_id >= GST_peer_list_size) ||
1863  (NULL == GST_peer_list[peer_id]))
1864  {
1865  GNUNET_break_op (0);
1866  return GNUNET_SYSERR;
1867  }
1868  return GNUNET_OK;
1869 }
1870 
1871 
1878 void
1881 {
1882  struct GNUNET_SERVICE_Client *client = cls;
1883  struct RemoteOverlayConnectCtx *rocc;
1884  struct Peer *peer;
1885  struct GNUNET_PeerIdentity pid;
1886  static char pid_str[16];
1887  uint32_t peer_id;
1888  uint16_t hsize;
1889 
1890  hsize = ntohs (msg->hello->size);
1891  peer_id = ntohl (msg->peer);
1892  peer = GST_peer_list[peer_id];
1893  if (GNUNET_YES == peer->is_remote)
1894  {
1895  struct GNUNET_MessageHeader *msg2;
1896 
1897  msg2 = GNUNET_copy_message (&msg->header);
1898  GNUNET_TESTBED_queue_message_ (peer->details.remote.slave->controller,
1899  msg2);
1901  return;
1902  }
1903  rocc = GNUNET_new (struct RemoteOverlayConnectCtx);
1904  rocc->op_id = GNUNET_ntohll (msg->operation_id);
1906  roccq_tail,
1907  rocc);
1908  rocc->a_id = msg->peer_identity;
1910  &pid);
1911  (void) GNUNET_strlcpy (pid_str,
1912  GNUNET_i2s (&pid),
1913  sizeof (pid_str));
1914  LOG_DEBUG ("0x%llx: Remote overlay connect %s to peer %s with hello size: %u\n",
1915  rocc->op_id,
1916  pid_str,
1917  GNUNET_i2s (&rocc->a_id),
1918  hsize);
1919  rocc->peer = peer;
1920  rocc->peer->reference_cnt++;
1921  rocc->hello = GNUNET_malloc (hsize);
1922  GNUNET_memcpy (rocc->hello,
1923  msg->hello,
1924  hsize);
1925  rocc->tcc.cgh_p2_th =
1927  rocc->peer->details.local.cfg,
1930  rocc,
1931  &rocc->a_id,
1933  rocc);
1934  rocc->timeout_rocc_task_id =
1937  rocc);
1939 }
1940 
1941 
1945 void
1947 {
1948  struct OverlayConnectContext *occ;
1949 
1950  while (NULL != (occ = occq_head))
1951  cleanup_occ (occ);
1952 }
1953 
1954 
1958 void
1960 {
1961  struct RemoteOverlayConnectCtx *rocc;
1962 
1963  while (NULL != (rocc = roccq_head))
1964  cleanup_rocc (rocc);
1965 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
struct ForwardedOverlayConnectContext * focc_dll_head
Head of the ForwardedOverlayConnectContext DLL.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_CONTAINER_MultiHashMap * reghost_map
Hashmap to hold Registered host contexts.
A connected controller which is not our child.
static void forwarded_overlay_connect_listener(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to be called when forwarded overlay connection operation has a reply from the sub-controller...
static void occ_cache_get_handle_core_cb(void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CONFIGURATION_Handle *cfg)
Callback from cache with needed CORE handle set.
This context information will be created for each host that is registered at slave controllers during...
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
static struct RemoteOverlayConnectCtx * roccq_head
DLL head for RequectOverlayConnectContext DLL - to be used to clean up during shutdown.
int is_remote
Is this peer locally created?
uint64_t op_id
The id of the operation responsible for creating this context.
struct NeighbourConnectNotification * ncn
Notification handle acquire to connect to a remote controller.
void GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
Send operation failure message to client.
struct GNUNET_MessageHeader * orig_msg
A copy of the original overlay connect message.
Event notification from a controller to a client.
Definition: testbed.h:501
A HELLO message is used to exchange information about transports with other peers.
struct GNUNET_PeerIdentity a_id
The peer identity of peer A.
Message sent from host controller of a peer(A) to the host controller of another peer(B) to request B...
Definition: testbed.h:431
static void send_hello_thru_rocc(struct OverlayConnectContext *occ)
Sends the HELLO of peer1 to peer2&#39;s controller through remote overlay connect request.
Entry in linked list for all offer-HELLO requests.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct Peer::@69::@71 remote
static char * expiration
Credential TTL.
static void forwarded_overlay_connect_timeout(void *cls)
Timeout task for cancelling a forwarded overlay connect connect.
Type to be used when the first peer is local and the other peer is on a controller which is not start...
Context data for operations on second peer in local overlay connection contexts.
static void p2_transport_connect(struct OverlayConnectContext *occ)
Connects to the transport of the other peer if it is a local peer and schedules the send hello task...
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT
Message for peer connect events.
Handle to interact with a GNUnet testbed controller.
Definition: testbed_api.h:194
struct GST_ConnectionPool_GetHandle * cgh_ch
The GST_ConnectionPool_GetHandle for registering callback to notify CORE level peer connects and to g...
Context for the core service connection.
Definition: core_api.c:78
static struct GNUNET_HashCode hash_hosts(struct GNUNET_TESTBED_Host *reg_host, struct GNUNET_TESTBED_Host *host)
Function to generate the hashcode corresponding to a RegisteredHostContext.
struct GNUNET_SCHEDULER_Task * timeout_task
The id of the overlay connect timeout task.
struct GNUNET_TRANSPORT_OfferHelloHandle * ohh
The handle for offering the HELLO of the first peer to the second peer.
data structures shared amongst components of TESTBED service
static void occ_cache_get_handle_ats_occ_cb(void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CONFIGURATION_Handle *cfg)
Callback from cache with needed ATS handle set.
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
uint32_t destroy_flag
While destroying a peer, due to the fact that there could be references to this peer, we delay the peer destroy to a further time.
Message sent from client to testing service to obtain the configuration of a peer.
Definition: testbed.h:615
Context information for connecting 2 peers in overlay.
struct GNUNET_SERVICE_Client * client
The client handle.
The request handle for obtaining a pooled connection.
static void attempt_connect_task(void *cls)
Task to offer the HELLO message to the peer and ask it to connect to the peer whose identity is in Re...
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Notification context to be used to notify when connection to the neighbour&#39;s controller is opened...
uint32_t id
Our local reference id for this peer.
struct ConnectivitySuggestContext tcc
The transport try connect context.
struct OverlayConnectContext * next
The next pointer for maintaining a DLL of all OverlayConnectContexts.
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
Peer configuration and identity reply from controller to a client.
Definition: testbed.h:639
struct OperationContext * opc
The generated operation context.
void GST_queue_host_registration(struct Slave *slave, GNUNET_TESTBED_HostRegistrationCompletion cb, void *cb_cls, struct GNUNET_TESTBED_Host *host)
Adds a host registration&#39;s request to a slave&#39;s registration queue.
struct ForwardedOverlayConnectContext * focc_dll_tail
Tail of the ForwardedOverlayConnectContext DLL.
static void cleanup_rocc(struct RemoteOverlayConnectCtx *rocc)
Function to cleanup RemoteOverlayConnectCtx and any associated tasks with it.
struct RemoteOverlayConnectCtx * prev
the prev pointer for DLL
struct Peer ** GST_peer_list
A list of peers we know about.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
unsigned int GST_peer_list_size
The size of the peer list.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:412
#define GNUNET_NO
Definition: gnunet_common.h:81
struct GNUNET_MessageHeader hello[0]
To be followed by the HELLO message of A.
Definition: testbed.h:456
#define LOG(kind,...)
Redefine LOG with a changed log component string.
void GST_cleanup_focc(struct ForwardedOverlayConnectContext *focc)
Cleans up ForwardedOverlayConnectContext.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:626
static void hello_update_cb(void *cls, const struct GNUNET_MessageHeader *hello)
Function called whenever there is an update to the HELLO of peers in the OverlayConnectClosure.
#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.
Context data for operations on second peer in remote overlay connection contexts. ...
void GNUNET_ATS_connectivity_suggest_cancel(struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
We no longer care about being connected to a peer.
Structure representing a connected(directly-linked) controller.
struct GNUNET_PeerIdentity peer_identity
Identity of A.
Definition: testbed.h:451
static struct GNUNET_PeerIdentity my_identity
Identity of this peer.
struct RemotePeer2Context remote
Context information to be used if the second peer is remote.
struct GST_ConnectionPool_GetHandle * cgh_p1th
The GST_ConnectionPool_GetHandle for the peer1&#39;s transport handle.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
int GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL)...
Opaque handle to a host running experiments managed by the testing framework.
struct GNUNET_TESTBED_Host * host
The host of the controller which has to connect to the above rhost.
char * emsg
The error message we send if this overlay connect operation has timed out.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void GST_forwarded_operation_reply_relay(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to relay the reply msg of a forwarded operation back to the client.
void GST_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
static void timeout_overlay_connect(void *cls)
Task which will be run when overlay connect request has been timed out.
struct GNUNET_ATS_ConnectivitySuggestHandle * GNUNET_ATS_connectivity_suggest(struct GNUNET_ATS_ConnectivityHandle *ch, const struct GNUNET_PeerIdentity *peer, uint32_t strength)
We would like to receive address suggestions for a peer.
struct GNUNET_SERVICE_Client * client
The client which has requested for overlay connection.
Handle to a client that is connected to a service.
Definition: service.c:249
uint32_t peer2
The id of peer 2.
static void overlay_connect_notify(void *cls, const struct GNUNET_PeerIdentity *new_peer)
Function called to notify transport users that another peer connected to us.
struct GNUNET_TESTBED_Controller * p2c
Controller of peer 2; If OCC_TYPE_REMOTE_LATERAL is the type of overlay connection then this can be N...
static struct OverlayConnectContext * occq_tail
DLL tail for OverlayConnectContext DLL.
uint32_t peer2
Unique ID for the second peer.
Definition: testbed.h:417
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct GNUNET_TRANSPORT_OfferHelloHandle * ohh
The handle for offering HELLO.
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.
struct Peer::@69::@70 local
#define GNUNET_memcpy(dst, src, n)
uint32_t peer
The Unique ID of B.
Definition: testbed.h:441
struct GNUNET_TRANSPORT_CoreHandle * p1th_
Transport handle of the first peer obtained from cache to get its HELLO.
struct Peer * peer
the first peer which is to expect an overlay connection from the second peer.
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
static char * value
Value of the record to add/remove.
uint64_t operation_id
The id of the operation which created this context information.
#define GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT
Message to request a controller to make one of its peer to connect to another peer using the containe...
struct GNUNET_SCHEDULER_Task * timeout_rocc_task_id
Task to timeout RequestOverlayConnect.
uint32_t peer1
Unique ID for the first peer.
Definition: testbed.h:407
void GST_free_occq()
Clears all pending overlay connect contexts in queue.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:631
struct GNUNET_HELLO_Message * GNUNET_HELLO_iterate_addresses(const struct GNUNET_HELLO_Message *msg, int return_modified, GNUNET_HELLO_AddressIterator it, void *it_cls)
Iterate over all of the addresses in the HELLO.
Definition: hello.c:254
static struct RemoteOverlayConnectCtx * roccq_tail
DLL tail for RequectOverlayConnectContext DLL.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
void GNUNET_TESTBED_forward_operation_msg_cancel_(struct OperationContext *opc)
Function to cancel an operation created by simply forwarding an operation message.
Definition: testbed_api.c:1386
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION.
Definition: testbed.h:621
struct GNUNET_TRANSPORT_HelloGetHandle * ghh
Get GetHelloHandle to acquire a HELLO of the first peer.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
uint32_t peer2
Second peer.
Definition: testbed.h:523
void GST_free_roccq()
Clears all pending remote overlay connect contexts in queue.
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
enum OperationType type
The type of the operation which is forwarded.
Context information to used during operations which forward the overlay connect message.
uint32_t peer2_host_id
The ID of the host which runs peer2.
Definition: testbed.h:422
enum OverlayConnectContextType type
The type of this context information.
struct LocalPeer2Context local
Context information to be used if the second peer is local.
uint64_t operation_id
The Operation ID that is used to identify this operation.
Definition: testbed.h:446
struct Neighbour * p2n
The neighbour handle.
static void send_hello(void *cls)
Task to offer HELLO of peer 1 to peer 2 and try to make peer 2 to connect to peer 1...
A routing entry.
Handle for ATS address suggestion requests.
struct GNUNET_MessageHeader * hello
HELLO of the first peer.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:528
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
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s unique global ID.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration of the peer from cache.
struct OverlayConnectContext * prev
The prev pointer for maintaining a DLL of all OverlayConnectContexts.
uint64_t op_id
The id of the operation responsible for creating this context.
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION
Message containing the peer&#39;s information.
struct GNUNET_PeerIdentity other_peer_identity
The peer identity of the other peer.
const struct GNUNET_MessageHeader * GST_cache_lookup_hello(const unsigned int peer_id)
Looks up in the hello cache and returns the HELLO of the given peer.
struct GNUNET_PeerIdentity peer_identity
Identity of the peer.
Definition: testbed.h:660
struct Route * GST_find_dest_route(uint32_t host_id)
Finds the route with directly connected host as destination through which the destination host can be...
void GST_notify_client_disconnect_oc(struct GNUNET_SERVICE_Client *client)
Notify OC subsystem that client disconnected.
A 512-bit hashcode.
OverlayConnectContextType
Types for context information we create for overlay connect requests.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2618
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
enum RegisteredHostContext::RHCState state
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
void GNUNET_TRANSPORT_offer_hello_cancel(struct GNUNET_TRANSPORT_OfferHelloHandle *ohh)
Cancel the request to transport to offer the HELLO message.
static struct RegisteredHostContext * register_host(struct Slave *slave, struct GNUNET_TESTBED_Host *host)
Checks if the given host is registered at the given slave.
static void overlay_connect_get_config(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to be called when forwarded get peer config operation as part of overlay connect is successf...
void * cls
Closure pointer.
static void rocc_cache_get_handle_transport_cb(void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *ignore_, const struct GNUNET_CONFIGURATION_Handle *cfg)
Callback from cache with needed handles set.
This type is used if the overlay connection is local i.e.
static void cleanup_occ(struct OverlayConnectContext *occ)
Cleanup overlay connect context structure.
static void p2_transport_connect_cache_callback(void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *ignore_, const struct GNUNET_CONFIGURATION_Handle *cfg)
Callback from cache with needed handles set.
uint32_t peer2_host_id
Id of the host where peer2 is running.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
Interface for connection pooling subroutines.
static void p1_transport_connect_cache_callback(void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *ignore_, const struct GNUNET_CONFIGURATION_Handle *cfg)
Callback from cache with needed handles set.
static struct OverlayConnectContext * occq_head
DLL head for OverlayConnectContext DLL - to be used to clean up during shutdown.
void GST_process_next_focc(struct RegisteredHostContext *rhc)
Processes a forwarded overlay connect context in the queue of the given RegisteredHostContext.
Context information for remote overlay connect operations.
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:79
uint32_t peer1
First peer.
Definition: testbed.h:518
GUID host
void GNUNET_TESTBED_queue_message_(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_MessageHeader *msg)
Queues a message in send queue for sending to the service.
Definition: testbed_api.c:1315
Overlay connection operation.
Definition: testbed_api.h:79
static void occ_cache_get_handle_ats_rocc_cb(void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CONFIGURATION_Handle *cfg)
Callback from cache with needed ATS handle set.
static void rocc_hello_sent_cb(void *cls)
Task that is run when hello has been sent If tc->reason = GNUNET_SCHEDULER_REASON_TIMEOUT then sendin...
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct GNUNET_SCHEDULER_Task * send_hello_task
The id of the task for sending HELLO of peer 2 to peer 1 and ask peer 1 to connect to peer 2...
#define GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION
Message to get a peer&#39;s information.
struct OperationContext * GNUNET_TESTBED_forward_operation_msg_(struct GNUNET_TESTBED_Controller *controller, uint64_t operation_id, const struct GNUNET_MessageHeader *msg, GNUNET_MQ_MessageCallback cc, void *cc_cls)
Sends the given message as an operation.
Definition: testbed_api.c:1349
struct GNUNET_ATS_ConnectivitySuggestHandle * csh
The ATS handle for the connectivity suggestion.
Type to be used when the first peer is local and the other peer is on a slave controller started by u...
#define VALID_HOST_ID(id)
Condition to check if host id is valid.
struct GNUNET_TESTBED_Host * reg_host
The host which is being registered.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
static int reghost_match_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator to match a registered host context.
int32_t event_type
&#39;enum GNUNET_TESTBED_EventType&#39; (in NBO); either GNUNET_TESTBED_ET_CONNECT or GNUNET_TESTBED_ET_DISCO...
Definition: testbed.h:513
A connection between two peers was established.
static void send_overlay_connect_success_msg(struct OverlayConnectContext *occ)
FIXME.
uint32_t other_peer_id
The id of the second peer which has to connect to the first peer.
struct GNUNET_MQ_Handle * GNUNET_CORE_get_mq(const struct GNUNET_CORE_Handle *h, const struct GNUNET_PeerIdentity *pid)
Obtain the message queue for a connected peer.
Definition: core_api.c:763
Allow multiple values with the same key.
Message sent from client to testing service to connect two peers.
Definition: testbed.h:396
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT.
Definition: testbed.h:402
struct GNUNET_PeerIdentity peer_identity
The peer identity of the first peer.
static void forward_overlay_connect(const struct GNUNET_TESTBED_OverlayConnectMessage *msg, struct GNUNET_SERVICE_Client *client)
Forwards the overlay connect request to a slave controller.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
uint32_t host_id
The id of the host this controller is running on.
union Peer::@69 details
void GST_destroy_peer(struct Peer *peer)
Function to destroy a peer.
configuration data
Definition: configuration.c:85
union OverlayConnectContext::@72 p2ctx
Context information for operations on the second peer.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
Information about preferences and sessions we track per peer.
struct GST_ConnectionPool_GetHandle * GST_connection_pool_get_handle(unsigned int peer_id, const struct GNUNET_CONFIGURATION_Handle *cfg, enum GST_ConnectionPool_Service service, GST_connection_pool_connection_ready_cb cb, void *cb_cls, const struct GNUNET_PeerIdentity *target, GST_connection_pool_peer_connect_notify connect_notify_cb, void *connect_notify_cb_cls)
Get a connection handle to service.
An address for communicating with a peer.
#define PEER_EXPIRED(peer)
Condition for checking if given peer is ready to be destroyed.
Context information for requesting ATS to connect to a peer.
struct GNUNET_TRANSPORT_HelloGetHandle * GNUNET_TRANSPORT_hello_get(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_TRANSPORT_AddressClass ac, GNUNET_TRANSPORT_HelloUpdateCallback rec, void *rec_cls)
Obtain updates on changes to the HELLO message for this peer.
void handle_remote_overlay_connect(void *cls, const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg)
Handler for GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT messages.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
struct ForwardedOperationContext * next
The next pointer for DLL.
static void occ_hello_sent_cb(void *cls)
Task that is run when hello has been sent If tc->reason = GNUNET_SCHEDULER_REASON_TIMEOUT then sendin...
struct GNUNET_TRANSPORT_OfferHelloHandle * GNUNET_TRANSPORT_offer_hello(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_MessageHeader *hello, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Offer the transport service the HELLO of another peer.
static int test_address(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Test for checking whether HELLO message is empty.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
struct GNUNET_HELLO_Message * hello
Pointer to the HELLO message of this peer; can be NULL.
void GNUNET_TESTING_peer_get_identity(struct GNUNET_TESTING_Peer *peer, struct GNUNET_PeerIdentity *id)
Obtain the peer identity from a peer handle.
Definition: testing.c:1292
struct GNUNET_SCHEDULER_Task * cleanup_task
The id of the cleanup task.
struct RegisteredHostContext * rhc
Which host does this FOCC belong to?
struct GNUNET_MessageHeader * hello
Peer A&#39;s HELLO.
uint64_t operation_id
The id of the operation that has been forwarded.
static void cleanup_occ_lp2c(struct LocalPeer2Context *lp2c)
Cleans up any used handles in local peer2 context.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Functions to call with this peer&#39;s HELLO.
Header for all communications.
struct GST_ConnectionPool_GetHandle * cgh_p2_th
The GetCacheHandle for the peer2&#39;s transport handle (used to offer the HELLO to the peer)...
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:80
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
static void cache_transport_peer_connect_notify(void *cls, const struct GNUNET_PeerIdentity *new_peer)
Function called to notify transport users that another peer connected to us.
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.
#define LOG_DEBUG(msg)
void GST_connection_pool_get_handle_done(struct GST_ConnectionPool_GetHandle *gh)
Relinquish a GST_ConnectionPool_GetHandle object.
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
static void timeout_rocc_task(void *cls)
Task to timeout rocc and cleanit up.
static void cleanup_occ_rp2c(struct RemotePeer2Context *rp2c)
Cleans up any used handles in remote peer2 context.
Handle for the transport service (includes all of the state for the transport service).
struct GNUNET_TRANSPORT_CoreHandle * th_
The transport handle obtained from cache.
Handle to the ATS subsystem for connectivity management.
State where we attempt to do the overlay connection again.
static void p2_controller_connect_cb(void *cls, struct GNUNET_TESTBED_Controller *c)
Callback called when a connection to the controller of peer2 has been established.
Context information for operations forwarded to subcontrollers.
static char * address
GNS address for this phone.
size_t GNUNET_strlcpy(char *dst, const char *src, size_t n)
Like strlcpy but portable.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static void do_cleanup_occ(void *cls)
Task for cleaing up overlay connect context structure.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
uint32_t dest
destination host
struct Peer * peer
The peer handle of peer B.
void GNUNET_TRANSPORT_hello_get_cancel(struct GNUNET_TRANSPORT_HelloGetHandle *ghh)
Stop receiving updates about changes to our HELLO message.
static void host_registration_comp(void *cls, const char *emsg)
Callback which will be called after a host registration succeeded or failed.
int check_remote_overlay_connect(void *cls, const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg)
Check GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT messages.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
#define GNUNET_malloc(size)
Wrapper around malloc.
struct RemoteOverlayConnectCtx * next
the next pointer for DLL
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:137
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT.
Definition: testbed.h:436
void handle_overlay_connect(void *cls, const struct GNUNET_TESTBED_OverlayConnectMessage *msg)
Handler for GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT messages.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
struct OperationContext * opc
Operation context for the suboperation we start to get the identity of the second peer...
struct GST_ConnectionPool_GetHandle * cgh_p2_ats
The GetCacheHandle for the peer2&#39;s ATS handle.
struct GNUNET_SCHEDULER_Task * attempt_connect_task_id
Task for offering HELLO of A to B and doing try_connect.
void GST_cache_add_hello(const unsigned int peer_id, const struct GNUNET_MessageHeader *hello)
Caches the HELLO of the given peer.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
struct ConnectivitySuggestContext tcc
The transport ConnectivitySuggestContext.