GNUnet  0.11.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 {
50 
55 
61 
66 
71 };
72 
73 
78 {
84 
90 
96 };
97 
98 
104 {
110 
115 };
116 
117 
123 {
130 
136 
142 
147  struct Neighbour *p2n;
148 };
149 
154 {
159 
164 
170 
174  struct Peer *peer;
175 
181 
186 
192 
197 
202 
206  char *emsg;
207 
211  union
212  {
216  struct LocalPeer2Context local;
217 
221  struct RemotePeer2Context remote;
222  } p2ctx;
223 
227  struct GNUNET_PeerIdentity peer_identity;
228 
232  struct GNUNET_PeerIdentity other_peer_identity;
233 
237  uint64_t op_id;
238 
244 
249 
254 
259 
263  uint32_t other_peer_id;
264 };
265 
266 
275 {
280 
285 
289  struct Peer *peer;
290 
295 
300 
305 
309  struct GNUNET_PeerIdentity a_id;
310 
315 
320 
324  uint64_t op_id;
325 };
326 
327 
332 
337 
343 
348 
349 
355 void
357 {
358  struct RegisteredHostContext *rhc = focc->rhc;
359 
361  rhc->focc_dll_tail,
362  focc);
364  GNUNET_free (focc);
365 }
366 
367 
373 static void
375 {
376  struct ForwardedOperationContext *fopc = cls;
377  struct RegisteredHostContext *rhc;
378  struct ForwardedOverlayConnectContext *focc;
379 
380  fopc->timeout_task = NULL;
381  rhc = fopc->cls;
382  focc = rhc->focc_dll_head;
383  LOG_DEBUG ("Overlay linking between peers %u and %u failed\n",
384  focc->peer1,
385  focc->peer2);
386  GST_cleanup_focc (focc);
388  if (NULL != rhc->focc_dll_head)
389  GST_process_next_focc (rhc);
390 }
391 
392 
401 static void
403  const struct GNUNET_MessageHeader *msg)
404 {
405  struct ForwardedOperationContext *fopc = cls;
406  struct RegisteredHostContext *rhc;
407  struct ForwardedOverlayConnectContext *focc;
408 
409  rhc = fopc->cls;
411  focc = rhc->focc_dll_head;
412  GST_cleanup_focc (focc);
413  if (NULL != rhc->focc_dll_head)
414  GST_process_next_focc (rhc);
415 }
416 
417 
423 void
425 {
426  struct ForwardedOperationContext *fopc;
427  struct ForwardedOverlayConnectContext *focc;
428  struct Peer *peer;
429  struct Slave *slave;
430 
431  focc = rhc->focc_dll_head;
432  GNUNET_assert (NULL != focc);
433  GNUNET_assert (RHC_DONE == rhc->state);
435  peer = GST_peer_list[focc->peer1];
437  GNUNET_assert (NULL != (slave = peer->details.remote.slave));
438  fopc = GNUNET_new (struct ForwardedOperationContext);
439  fopc->client = focc->client;
440  fopc->operation_id = focc->operation_id;
441  fopc->cls = rhc;
442  fopc->type = OP_OVERLAY_CONNECT;
443  fopc->opc =
445  focc->operation_id,
446  focc->orig_msg,
448  fopc);
449  GNUNET_free (focc->orig_msg);
450  focc->orig_msg = NULL;
452  &
454  fopc);
456  fopcq_tail,
457  fopc);
458 }
459 
460 
466 static void
468 {
469  if (NULL != lp2c->ohh)
470  {
472  lp2c->ohh = NULL;
473  }
474  if (NULL != lp2c->tcc.cgh_p2_th)
475  {
477  lp2c->tcc.cgh_p2_th = NULL;
478  }
479  if (NULL != lp2c->tcc.cgh_p2_ats)
480  {
482  lp2c->tcc.cgh_p2_ats = NULL;
483  }
484  if (NULL != lp2c->tcc.csh)
485  {
487  lp2c->tcc.csh = NULL;
488  }
489 }
490 
491 
498 static void
500 {
501  if (NULL != rp2c->opc)
502  {
504  rp2c->opc = NULL;
505  }
506  if (NULL != rp2c->ncn)
507  {
509  rp2c->ncn = NULL;
510  }
511  if ((NULL != rp2c->p2c) && (NULL != rp2c->p2n))
512  {
514  rp2c->p2n = NULL;
515  }
516 }
517 
518 
524 #define PEER_EXPIRED(peer) \
525  ((GNUNET_YES == peer->destroy_flag) && (0 == peer->reference_cnt))
526 
532 static void
534 {
535  struct Peer *peer2;
536 
537  LOG_DEBUG ("0x%llx: Cleaning up occ\n",
538  occ->op_id);
539  GNUNET_free_non_null (occ->emsg);
541  if (NULL != occ->send_hello_task)
543  if (NULL != occ->cleanup_task)
545  if (NULL != occ->timeout_task)
547  if (NULL != occ->cgh_ch)
549  if (NULL != occ->ghh)
552  GNUNET_assert (NULL != GST_peer_list);
553  GNUNET_assert (occ->peer->reference_cnt > 0);
554  occ->peer->reference_cnt--;
555  if (PEER_EXPIRED (occ->peer))
556  GST_destroy_peer (occ->peer);
557  switch (occ->type)
558  {
559  case OCC_TYPE_LOCAL:
560  peer2 = GST_peer_list[occ->other_peer_id];
561  GNUNET_assert (peer2->reference_cnt > 0);
562  peer2->reference_cnt--;
563  if (PEER_EXPIRED (peer2))
564  GST_destroy_peer (peer2);
565  cleanup_occ_lp2c (&occ->p2ctx.local);
566  break;
567 
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 
652 static void
654 {
655  struct GNUNET_MQ_Envelope *env;
657 
658  LOG_DEBUG ("0x%llx: Peers connected - Sending overlay connect success\n",
659  occ->op_id);
660  env = GNUNET_MQ_msg (msg,
662  msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT);
663  msg->peer1 = htonl (occ->peer->id);
664  msg->peer2 = htonl (occ->other_peer_id);
665  msg->operation_id = GNUNET_htonll (occ->op_id);
667  env);
668 }
669 
670 
678 static void
680  const struct GNUNET_PeerIdentity *new_peer)
681 {
682  struct OverlayConnectContext *occ = cls;
683  char *new_peer_str;
684  char *other_peer_str;
685 
686  LOG_DEBUG ("Overlay connect notify\n");
687  if (0 ==
688  memcmp (new_peer, &occ->peer_identity,
689  sizeof(struct GNUNET_PeerIdentity)))
690  return;
691  new_peer_str = GNUNET_strdup (GNUNET_i2s (new_peer));
692  other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
693  if (0 !=
694  memcmp (new_peer,
695  &occ->other_peer_identity,
696  sizeof(struct GNUNET_PeerIdentity)))
697  {
698  LOG_DEBUG ("Unexpected peer %s connected when expecting peer %s\n",
699  new_peer_str,
700  other_peer_str);
701  GNUNET_free (new_peer_str);
702  GNUNET_free (other_peer_str);
703  return;
704  }
705  GNUNET_free (new_peer_str);
706  LOG_DEBUG ("0x%llx: Peer %s connected to peer %s\n",
707  occ->op_id,
708  other_peer_str,
709  GNUNET_i2s (&occ->peer_identity));
710  GNUNET_free (other_peer_str);
711  if (NULL != occ->send_hello_task)
712  {
714  occ->send_hello_task = NULL;
715  }
716  GNUNET_assert (NULL != occ->timeout_task);
718  occ->timeout_task = NULL;
719  switch (occ->type)
720  {
721  case OCC_TYPE_LOCAL:
722  cleanup_occ_lp2c (&occ->p2ctx.local);
723  break;
724 
727  cleanup_occ_rp2c (&occ->p2ctx.remote);
728  break;
729  }
730  GNUNET_free_non_null (occ->emsg);
731  occ->emsg = NULL;
734  occ);
735 }
736 
737 
748 static void
750  struct GNUNET_CORE_Handle *ch,
751  struct GNUNET_TRANSPORT_CoreHandle *th,
753  const struct GNUNET_PeerIdentity *my_identity,
754  const struct GNUNET_CONFIGURATION_Handle *cfg)
755 {
756  struct OverlayConnectContext *occ = cls;
757  struct LocalPeer2Context *lp2c;
758 
760  GNUNET_assert (NULL != occ->timeout_task);
761  GNUNET_free_non_null (occ->emsg);
762  if (NULL == ac)
763  {
764  GNUNET_asprintf (&occ->emsg,
765  "0x%llx: Failed to connect to ATS of peer with id: %u",
766  occ->op_id,
767  occ->peer->id);
769  occ->timeout_task =
771  occ);
772  return;
773  }
774  occ->emsg = NULL;
775 
776  GNUNET_asprintf (&occ->emsg,
777  "0x%llx: Timeout during GNUNET_ATS_connectivity_suggest() at peer %s",
778  occ->op_id,
780 
781  lp2c = &occ->p2ctx.local;
782  lp2c->tcc.csh =
784  &occ->peer_identity,
785  1);
786 }
787 
788 
798 static void
800  struct GNUNET_CORE_Handle *ch,
801  struct GNUNET_TRANSPORT_CoreHandle *th,
803  const struct GNUNET_PeerIdentity *my_identity,
804  const struct GNUNET_CONFIGURATION_Handle *cfg)
805 {
806  struct RemoteOverlayConnectCtx *rocc = cls;
807 
808  rocc->tcc.csh =
810  &rocc->a_id,
811  1);
812 }
813 
814 
821 static void
822 send_hello (void *cls);
823 
824 
832 static void
833 occ_hello_sent_cb (void *cls)
834 {
835  struct OverlayConnectContext *occ = cls;
836  struct LocalPeer2Context *lp2c;
837  struct Peer *peer2;
838 
840  GNUNET_assert (NULL != occ->timeout_task);
841  lp2c = &occ->p2ctx.local;
842  lp2c->ohh = NULL;
843 
844  GNUNET_assert (NULL == occ->send_hello_task);
845  GNUNET_free_non_null (occ->emsg);
846 
847  GNUNET_asprintf (&occ->emsg,
848  "0x%llx: Timeout while acquiring ATS of %s from cache",
849  occ->op_id,
851  GNUNET_assert (NULL != (peer2 = GST_peer_list[occ->other_peer_id]));
852  lp2c->tcc.cgh_p2_ats =
854  peer2->details.local.cfg,
857  occ, NULL, NULL, NULL);
858 }
859 
860 
868 static void
870 {
872  char *other_peer_str;
873  uint16_t msize;
874  uint16_t hello_size;
875 
877  GNUNET_assert (NULL != occ->hello);
878  other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
879  LOG_DEBUG (
880  "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)
888  + hello_size;
889  msg = GNUNET_malloc (msize);
890  msg->header.type =
892  msg->header.size = htons (msize);
893  msg->peer = htonl (occ->other_peer_id);
894  msg->operation_id = GNUNET_htonll (occ->op_id);
895  msg->peer_identity = occ->peer_identity;
896  GNUNET_memcpy (msg->hello,
897  occ->hello,
898  hello_size);
900  &msg->header);
901 }
902 
903 
911 static void
912 send_hello (void *cls)
913 {
914  struct OverlayConnectContext *occ = cls;
915  struct LocalPeer2Context *lp2c;
916  char *other_peer_str;
917 
918  occ->send_hello_task = NULL;
919  GNUNET_assert (NULL != occ->timeout_task);
920  GNUNET_assert (NULL != occ->hello);
921  if (OCC_TYPE_LOCAL != occ->type)
922  {
923  send_hello_thru_rocc (occ);
924  return;
925  }
926  lp2c = &occ->p2ctx.local;
927  other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity));
928  LOG_DEBUG ("0x%llx: Offering HELLO of %s to %s\n",
929  occ->op_id,
930  GNUNET_i2s (&occ->peer_identity),
931  other_peer_str);
932  GNUNET_free (other_peer_str);
933  lp2c->ohh =
935  occ->hello,
937  occ);
938  if (NULL == lp2c->ohh)
939  {
940  GNUNET_break (0);
941  occ->send_hello_task =
944  100
947  &send_hello, occ);
948  }
949 }
950 
951 
962 static void
964  struct GNUNET_CORE_Handle *ch,
965  struct GNUNET_TRANSPORT_CoreHandle *th,
967  const struct GNUNET_PeerIdentity *ignore_,
968  const struct
970 {
971  struct OverlayConnectContext *occ = cls;
972 
974  if (NULL == th)
975  {
976  GNUNET_asprintf (&occ->emsg,
977  "0x%llx: Cannot connect to TRANSPORT of %s",
978  occ->op_id,
981  occ->timeout_task =
983  return;
984  }
985  occ->p2ctx.local.tcc.th_ = th;
986  occ->p2ctx.local.tcc.cfg = cfg;
987  GNUNET_asprintf (&occ->emsg,
988  "0x%llx: Timeout while offering HELLO to %s",
989  occ->op_id,
992 }
993 
994 
1001 static void
1003 {
1004  struct Peer *peer2;
1005 
1006  /* HUH? Why to *obtain* HELLO? Seems we use this to *SEND* the
1007  HELLO! */
1009  "Connecting to transport of peer %s to obtain HELLO\n",
1011  GNUNET_assert (NULL == occ->emsg);
1012  GNUNET_assert (NULL != occ->hello);
1013  GNUNET_assert (NULL == occ->ghh);
1014  GNUNET_assert (NULL == occ->p1th_);
1015  GNUNET_assert (NULL == occ->cgh_p1th);
1016  if (OCC_TYPE_LOCAL == occ->type)
1017  {
1018  GNUNET_assert (NULL != (peer2 = GST_peer_list[occ->other_peer_id]));
1019  occ->p2ctx.local.tcc.cgh_p2_th =
1021  peer2->details.local.cfg,
1024  occ, NULL, NULL, NULL);
1025  return;
1026  }
1027  GNUNET_asprintf (&occ->emsg,
1028  "0x%llx: Timeout while offering HELLO to %s",
1029  occ->op_id,
1032 }
1033 
1034 
1043 static int
1044 test_address (void *cls,
1045  const struct GNUNET_HELLO_Address *address,
1047 {
1048  int *empty = cls;
1049 
1050  *empty = GNUNET_NO;
1051  return GNUNET_OK;
1052 }
1053 
1054 
1063 static void
1064 hello_update_cb (void *cls,
1065  const struct GNUNET_MessageHeader *hello)
1066 {
1067  struct OverlayConnectContext *occ = cls;
1068  int empty;
1069  uint16_t msize;
1070 
1071  msize = ntohs (hello->size);
1072  empty = GNUNET_YES;
1073  (void) GNUNET_HELLO_iterate_addresses ((const struct GNUNET_HELLO_Message *)
1074  hello, GNUNET_NO,
1075  &test_address,
1076  &empty);
1077  if (GNUNET_YES == empty)
1078  {
1079  LOG_DEBUG ("0x%llx: HELLO of %s is empty\n",
1080  occ->op_id,
1081  GNUNET_i2s (&occ->peer_identity));
1082  return;
1083  }
1084  LOG_DEBUG ("0x%llx: Received HELLO of %s\n",
1085  occ->op_id,
1086  GNUNET_i2s (&occ->peer_identity));
1087  occ->hello = GNUNET_malloc (msize);
1088  GST_cache_add_hello (occ->peer->id, hello);
1089  GNUNET_memcpy (occ->hello, hello, msize);
1091  occ->ghh = NULL;
1093  occ->cgh_p1th = NULL;
1094  occ->p1th_ = NULL;
1095  GNUNET_free_non_null (occ->emsg);
1096  occ->emsg = NULL;
1097  p2_transport_connect (occ);
1098 }
1099 
1100 
1110 static void
1112  struct GNUNET_CORE_Handle *ch,
1113  struct GNUNET_TRANSPORT_CoreHandle *th,
1115  const struct GNUNET_PeerIdentity *ignore_,
1116  const struct
1118 {
1119  struct OverlayConnectContext *occ = cls;
1120 
1121  GNUNET_free_non_null (occ->emsg);
1122  occ->emsg = NULL;
1123  if (NULL == th)
1124  {
1125  GNUNET_asprintf (&occ->emsg,
1126  "0x%llx: Cannot connect to TRANSPORT of %s",
1127  occ->op_id,
1128  GNUNET_i2s (&occ->peer_identity));
1130  occ->timeout_task =
1132  return;
1133  }
1134  GNUNET_assert (NULL == occ->p1th_);
1135  GNUNET_assert (NULL != occ->cgh_p1th);
1136  occ->p1th_ = th;
1137  GNUNET_asprintf (&occ->emsg,
1138  "0x%llx: Timeout while acquiring HELLO of peer %s",
1139  occ->op_id,
1140  GNUNET_i2s (&occ->peer_identity));
1141  occ->ghh = GNUNET_TRANSPORT_hello_get (cfg,
1143  &hello_update_cb,
1144  occ);
1145 }
1146 
1147 
1157 static void
1159  struct GNUNET_CORE_Handle *ch,
1160  struct GNUNET_TRANSPORT_CoreHandle *th,
1162  const struct GNUNET_PeerIdentity *my_identity,
1163  const struct GNUNET_CONFIGURATION_Handle *cfg)
1164 {
1165  struct OverlayConnectContext *occ = cls;
1166  const struct GNUNET_MessageHeader *hello;
1167 
1168  GNUNET_assert (NULL != occ->timeout_task);
1169  GNUNET_free_non_null (occ->emsg);
1170  if ((NULL == ch) || (NULL == my_identity))
1171  {
1172  GNUNET_asprintf (&occ->emsg,
1173  "0x%llx: Failed to connect to CORE of peer with "
1174  "id: %u",
1175  occ->op_id,
1176  occ->peer->id);
1178  occ->timeout_task =
1180  return;
1181  }
1182  occ->emsg = NULL;
1183  if (NULL !=
1184  GNUNET_CORE_get_mq (ch,
1185  &occ->other_peer_identity))
1186  {
1187  LOG_DEBUG ("0x%llx: Target peer already connected\n",
1188  occ->op_id);
1190  occ->timeout_task = NULL;
1193  return;
1194  }
1195  occ->peer_identity = *my_identity;
1196  LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n",
1197  occ->op_id,
1198  GNUNET_i2s (&occ->peer_identity));
1199  /* Lookup for HELLO in hello cache */
1200  if (NULL != (hello = GST_cache_lookup_hello (occ->peer->id)))
1201  {
1202  LOG_DEBUG ("0x%llx: HELLO of peer %s found in cache\n",
1203  occ->op_id,
1204  GNUNET_i2s (&occ->peer_identity));
1205  occ->hello = GNUNET_copy_message (hello);
1206  p2_transport_connect (occ);
1207  return;
1208  }
1209  GNUNET_asprintf (&occ->emsg,
1210  "0x%llx: Timeout while acquiring TRANSPORT of %s from cache",
1211  occ->op_id,
1212  GNUNET_i2s (&occ->peer_identity));
1213  occ->cgh_p1th =
1215  occ->peer->details.local.cfg,
1218  occ,
1219  NULL, NULL, NULL);
1220 }
1221 
1222 
1231 static void
1233  const struct GNUNET_MessageHeader *msg)
1234 {
1235  struct OverlayConnectContext *occ = cls;
1236  struct RemotePeer2Context *rp2c;
1238 
1239  GNUNET_assert (OCC_TYPE_LOCAL != occ->type);
1240  rp2c = &occ->p2ctx.remote;
1241  rp2c->opc = NULL;
1242  GNUNET_assert (NULL != occ->timeout_task);
1244  {
1246  occ->timeout_task =
1248  }
1249  cmsg =
1251  occ->other_peer_identity = cmsg->peer_identity;
1252  GNUNET_free_non_null (occ->emsg);
1253  GNUNET_asprintf (&occ->emsg,
1254  "0x%llx: Timeout while connecting to CORE of peer with "
1255  "id: %u",
1256  occ->op_id,
1257  occ->peer->id);
1258  occ->cgh_ch =
1260  occ->peer->details.local.cfg,
1263  occ,
1264  &occ->other_peer_identity,
1266  occ);
1267  return;
1268 }
1269 
1270 
1277 static void
1278 host_registration_comp (void *cls, const char *emsg)
1279 {
1280  struct RegisteredHostContext *rhc = cls;
1281 
1282  rhc->state = RHC_DONE;
1283  GST_process_next_focc (rhc);
1284 }
1285 
1286 
1297 static int
1299  const struct GNUNET_HashCode *key,
1300  void *value)
1301 {
1302  struct RegisteredHostContext **rh = cls;
1303  struct RegisteredHostContext *rh_val = value;
1304 
1305  if ((rh_val->host == (*rh)->host) && (rh_val->reg_host == (*rh)->reg_host))
1306  {
1307  GNUNET_free (*rh);
1308  *rh = rh_val;
1309  return GNUNET_NO;
1310  }
1311  return GNUNET_YES;
1312 }
1313 
1314 
1322 static struct GNUNET_HashCode
1324  struct GNUNET_TESTBED_Host *host)
1325 {
1326  struct GNUNET_HashCode hash;
1327  uint32_t host_ids[2];
1328 
1329  host_ids[0] = GNUNET_TESTBED_host_get_id_ (reg_host);
1330  host_ids[1] = GNUNET_TESTBED_host_get_id_ (host);
1331  GNUNET_CRYPTO_hash (host_ids, sizeof(host_ids), &hash);
1332  return hash;
1333 }
1334 
1335 
1349 static struct RegisteredHostContext *
1350 register_host (struct Slave *slave,
1351  struct GNUNET_TESTBED_Host *host)
1352 {
1353  struct GNUNET_HashCode hash;
1354  struct RegisteredHostContext *rhc;
1355 
1356  rhc = GNUNET_new (struct RegisteredHostContext);
1357  rhc->reg_host = host;
1358  rhc->host = GST_host_list[slave->host_id];
1359  GNUNET_assert (NULL != rhc->reg_host);
1360  GNUNET_assert (NULL != rhc->host);
1361  rhc->state = RHC_INIT;
1362  hash = hash_hosts (rhc->reg_host, rhc->host);
1363  if ((GNUNET_NO ==
1365  &hash)) ||
1366  (GNUNET_SYSERR !=
1368  &hash,
1370  &rhc)))
1371  {
1372  /* create and add a new registerd host context */
1373  /* add the focc to its queue */
1375  &hash,
1376  rhc,
1380  rhc,
1381  rhc->reg_host);
1382  }
1383  else
1384  {
1385  /* rhc is now set to the existing one from the hash map by
1386  * reghost_match_iterator() */
1387  /* if queue is empty then ignore creating focc and proceed with normal
1388  * forwarding */
1389  if (RHC_DONE == rhc->state)
1390  return NULL;
1391  }
1392  return rhc;
1393 }
1394 
1395 
1405 static void
1407  struct GNUNET_SERVICE_Client *client)
1408 {
1409  struct ForwardedOperationContext *fopc;
1410  struct Route *route_to_peer2_host;
1411  struct Route *route_to_peer1_host;
1412  struct Peer *peer;
1413  struct RegisteredHostContext *rhc;
1414  struct ForwardedOverlayConnectContext *focc;
1415  uint64_t op_id;
1416  uint32_t peer2_host_id;
1417  uint32_t p1;
1418  uint32_t p2;
1419 
1420  p1 = ntohl (msg->peer1);
1421  p2 = ntohl (msg->peer2);
1422  op_id = GNUNET_ntohll (msg->operation_id);
1423  peer2_host_id = ntohl (msg->peer2_host_id);
1425  GNUNET_assert (VALID_HOST_ID (peer2_host_id));
1426  peer = GST_peer_list[p1];
1427  GNUNET_assert (GNUNET_YES == peer->is_remote);
1428  LOG_DEBUG ("0x%llx: Forwarding overlay connect\n", op_id);
1429  route_to_peer2_host = GST_find_dest_route (peer2_host_id);
1430  route_to_peer1_host = GST_find_dest_route
1431  (peer->details.remote.remote_host_id);
1432  GNUNET_assert (NULL != route_to_peer1_host);
1433  if ((NULL != route_to_peer2_host) &&
1434  (route_to_peer1_host->dest == route_to_peer2_host->dest))
1435  goto forward;
1436  /* Peer2 is either with us OR peer1 and peer2 can be reached through
1437  different subtrees OR peer2 is on a subtree unknown to us */
1438  if (NULL != (rhc = register_host (peer->details.remote.slave,
1439  GST_host_list[peer2_host_id])))
1440  {
1441  LOG_DEBUG ("Queueing forwarding FOCC for connecting peers %u and %u\n", p1,
1442  p2);
1444  focc->rhc = rhc;
1445  focc->peer1 = p1;
1446  focc->peer2 = p2;
1447  focc->peer2_host_id = peer2_host_id;
1448  focc->orig_msg = GNUNET_copy_message (&msg->header);
1449  focc->operation_id = op_id;
1450  focc->client = client;
1452  rhc->focc_dll_tail,
1453  focc);
1454  return;
1455  }
1456 
1457 forward:
1458  LOG_DEBUG ("Forwarding without FOCC for connecting peers %u and %u\n", p1,
1459  p2);
1460  fopc = GNUNET_new (struct ForwardedOperationContext);
1461  fopc->client = client;
1462  fopc->operation_id = op_id;
1463  fopc->type = OP_OVERLAY_CONNECT;
1464  fopc->opc =
1466  slave->controller, op_id,
1467  &msg->header,
1469  fopc);
1470  fopc->timeout_task =
1473  fopc);
1475  fopcq_tail,
1476  fopc);
1477 }
1478 
1479 
1487 static void
1489  struct GNUNET_TESTBED_Controller *c)
1490 {
1491  struct OverlayConnectContext *occ = cls;
1492  struct RemotePeer2Context *rp2c;
1494 
1495  GNUNET_assert (OCC_TYPE_LOCAL != occ->type);
1496  rp2c = &occ->p2ctx.remote;
1497  rp2c->ncn = NULL;
1498  rp2c->p2c = c;
1499  cmsg.header.size =
1500  htons (sizeof(struct GNUNET_TESTBED_PeerGetConfigurationMessage));
1501  cmsg.header.type =
1503  cmsg.peer_id = htonl (occ->other_peer_id);
1504  cmsg.operation_id = GNUNET_htonll (occ->op_id);
1505  rp2c->opc =
1507  occ->op_id,
1508  &cmsg.header,
1510  occ);
1511  GNUNET_free_non_null (occ->emsg);
1512  GNUNET_asprintf (&occ->emsg,
1513  "0x%llx: Timeout while getting peer identity of peer "
1514  "with id: %u",
1515  occ->op_id,
1516  occ->other_peer_id);
1517 }
1518 
1519 
1526 void
1529 {
1530  struct GNUNET_SERVICE_Client *client = cls;
1531  struct Peer *peer;
1532  struct Peer *peer2;
1533  struct OverlayConnectContext *occ;
1534  struct Neighbour *p2n;
1535  uint64_t operation_id;
1536  uint32_t p1;
1537  uint32_t p2;
1538  uint32_t peer2_host_id;
1539 
1540  p1 = ntohl (msg->peer1);
1541  p2 = ntohl (msg->peer2);
1542  if (! VALID_PEER_ID (p1))
1543  {
1544  GNUNET_break (0);
1545  GNUNET_SERVICE_client_drop (client);
1546  return;
1547  }
1548  peer = GST_peer_list[p1];
1549  operation_id = GNUNET_ntohll (msg->operation_id);
1550  LOG_DEBUG
1551  ("Received overlay connect for peers %u and %u with op id: 0x%llx\n",
1552  p1,
1553  p2,
1554  operation_id);
1555  peer2_host_id = ntohl (msg->peer2_host_id);
1556  if (GNUNET_YES == peer->is_remote)
1557  {
1558  if (! VALID_HOST_ID (peer2_host_id))
1559  {
1560  GNUNET_break (0);
1561  GNUNET_SERVICE_client_drop (client);
1562  return;
1563  }
1564  forward_overlay_connect (msg, client);
1566  return;
1567  }
1568  p2n = NULL;
1569  occ = GNUNET_new (struct OverlayConnectContext);
1570  occ->type = OCC_TYPE_LOCAL;
1571  if (! VALID_PEER_ID (p2)) /* May be peer2 is on a another controller */
1572  {
1573  if (NULL == (p2n = GST_get_neighbour (peer2_host_id)))
1574  {
1575  if (! VALID_HOST_ID (peer2_host_id))
1576  {
1577  GNUNET_break (0);
1579  "0x%llx: Peer %u's host not in our neighbours list\n",
1580  operation_id, p2);
1581  GNUNET_SERVICE_client_drop (client);
1582  GNUNET_free (occ);
1583  return;
1584  }
1585  p2n = GST_create_neighbour (GST_host_list[peer2_host_id]);
1586  }
1588  occ->p2ctx.remote.p2n = p2n;
1589  }
1590  else if (GNUNET_YES == GST_peer_list[p2]->is_remote)
1591  {
1592  occ->type = OCC_TYPE_REMOTE_SLAVE;
1593  occ->p2ctx.remote.p2c = GST_peer_list[p2]->details.remote.slave->controller;
1594  }
1596  occq_tail,
1597  occ);
1598  occ->client = client;
1599  occ->other_peer_id = p2;
1601  occ->peer = GST_peer_list[p1];
1602  occ->op_id = operation_id;
1603  GNUNET_assert (NULL == occ->timeout_task);
1604  occ->timeout_task =
1607  occ);
1608  switch (occ->type)
1609  {
1611  GNUNET_asprintf (&occ->emsg,
1612  "0x%llx: Timeout while acquiring connection to peer %u's "
1613  "host: %u\n",
1614  occ->op_id,
1615  occ->other_peer_id,
1616  peer2_host_id);
1617  occ->p2ctx.remote.ncn
1620  occ);
1621  break;
1622 
1623  case OCC_TYPE_REMOTE_SLAVE:
1625  occ->p2ctx.remote.p2c);
1626  break;
1627 
1628  case OCC_TYPE_LOCAL:
1629  peer2 = GST_peer_list[occ->other_peer_id];
1630  peer2->reference_cnt++;
1632  &occ->other_peer_identity);
1633  GNUNET_asprintf (&occ->emsg,
1634  "0x%llx: Timeout while connecting to CORE of peer with "
1635  "id: %u",
1636  occ->op_id,
1637  occ->peer->id);
1638  occ->cgh_ch =
1640  occ->peer->details.local.cfg,
1643  &occ->other_peer_identity,
1644  &overlay_connect_notify, occ);
1645  break;
1646  }
1648 }
1649 
1650 
1657 static void
1659 {
1660  LOG_DEBUG ("0x%llx: Cleaning up rocc\n",
1661  rocc->op_id);
1662  if (NULL != rocc->attempt_connect_task_id)
1664  if (NULL != rocc->timeout_rocc_task_id)
1666  if (NULL != rocc->ohh)
1668  if (NULL != rocc->tcc.csh)
1672  GNUNET_assert (rocc->peer->reference_cnt > 0);
1673  rocc->peer->reference_cnt--;
1674  if ((GNUNET_YES == rocc->peer->destroy_flag) &&
1675  (0 == rocc->peer->reference_cnt))
1676  GST_destroy_peer (rocc->peer);
1677  GNUNET_free_non_null (rocc->hello);
1678  GNUNET_CONTAINER_DLL_remove (roccq_head,
1679  roccq_tail,
1680  rocc);
1681  GNUNET_free (rocc);
1682 }
1683 
1684 
1690 static void
1692 {
1693  struct RemoteOverlayConnectCtx *rocc = cls;
1694 
1695  GNUNET_assert (rocc->timeout_rocc_task_id != NULL);
1696  rocc->timeout_rocc_task_id = NULL;
1697  LOG_DEBUG ("0x%llx: rocc timed out\n",
1698  rocc->op_id);
1699  cleanup_rocc (rocc);
1700 }
1701 
1702 
1710 static void
1712  const struct GNUNET_PeerIdentity *new_peer)
1713 {
1714  struct RemoteOverlayConnectCtx *rocc = cls;
1715 
1716  LOG_DEBUG ("0x%llx: Request Overlay connect notify\n",
1717  rocc->op_id);
1718  GNUNET_assert (0 ==
1719  memcmp (new_peer, &rocc->a_id,
1720  sizeof(struct GNUNET_PeerIdentity)));
1721  LOG_DEBUG ("0x%llx: Peer %s connected\n",
1722  rocc->op_id,
1723  GNUNET_i2s (&rocc->a_id));
1724  cleanup_rocc (rocc);
1725 }
1726 
1727 
1734 static void
1735 attempt_connect_task (void *cls);
1736 
1737 
1745 static void
1747 {
1748  struct RemoteOverlayConnectCtx *rocc = cls;
1749 
1750  rocc->ohh = NULL;
1751  GNUNET_assert (NULL == rocc->attempt_connect_task_id);
1752  LOG_DEBUG ("0x%llx: HELLO of peer %s delivered to local peer with id: %u\n",
1753  rocc->op_id,
1754  GNUNET_i2s (&rocc->a_id),
1755  rocc->peer->id);
1756  rocc->tcc.cgh_p2_ats =
1758  rocc->peer->details.local.cfg,
1761  rocc, NULL, NULL, NULL);
1762 }
1763 
1764 
1771 static void
1773 {
1774  struct RemoteOverlayConnectCtx *rocc = cls;
1775 
1776  GNUNET_assert (NULL != rocc->attempt_connect_task_id);
1777  rocc->attempt_connect_task_id = NULL;
1778  LOG_DEBUG ("0x%llx: Offering HELLO of peer %s to remote peer with id: %u\n",
1779  rocc->op_id,
1780  GNUNET_i2s (&rocc->a_id),
1781  rocc->peer->id);
1782  rocc->ohh =
1784  rocc->hello,
1786  rocc);
1787  if (NULL == rocc->ohh)
1788  rocc->attempt_connect_task_id =
1791  100
1794  &attempt_connect_task, rocc);
1795 }
1796 
1797 
1807 static void
1809  struct GNUNET_CORE_Handle *ch,
1810  struct GNUNET_TRANSPORT_CoreHandle *th,
1812  const struct GNUNET_PeerIdentity *ignore_,
1813  const struct
1815 {
1816  struct RemoteOverlayConnectCtx *rocc = cls;
1817 
1818  if (NULL == th)
1819  {
1820  rocc->timeout_rocc_task_id =
1822  return;
1823  }
1824  rocc->tcc.th_ = th;
1825  rocc->tcc.cfg = cfg;
1826  if (NULL !=
1828  &rocc->a_id))
1829  {
1830  LOG_DEBUG ("0x%llx: Target peer %s already connected to local peer: %u\n",
1831  rocc->op_id,
1832  GNUNET_i2s (&rocc->a_id),
1833  rocc->peer->id);
1834  cleanup_rocc (rocc);
1835  return;
1836  }
1837  rocc->attempt_connect_task_id =
1839 }
1840 
1841 
1849 int
1851  const struct
1853 {
1854  uint32_t peer_id;
1855  uint16_t msize;
1856  uint16_t hsize;
1857 
1858  msize = ntohs (msg->header.size);
1859  if (GNUNET_MESSAGE_TYPE_HELLO != ntohs (msg->hello->type))
1860  {
1861  GNUNET_break (0);
1862  return GNUNET_SYSERR;
1863  }
1864  hsize = ntohs (msg->hello->size);
1865  if ((sizeof(struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hsize) !=
1866  msize)
1867  {
1868  GNUNET_break (0);
1869  return GNUNET_SYSERR;
1870  }
1871  peer_id = ntohl (msg->peer);
1872  if ((peer_id >= GST_peer_list_size) ||
1873  (NULL == GST_peer_list[peer_id]))
1874  {
1875  GNUNET_break_op (0);
1876  return GNUNET_SYSERR;
1877  }
1878  return GNUNET_OK;
1879 }
1880 
1881 
1888 void
1890  const struct
1892 {
1893  struct GNUNET_SERVICE_Client *client = cls;
1894  struct RemoteOverlayConnectCtx *rocc;
1895  struct Peer *peer;
1896  struct GNUNET_PeerIdentity pid;
1897  static char pid_str[16];
1898  uint32_t peer_id;
1899  uint16_t hsize;
1900 
1901  hsize = ntohs (msg->hello->size);
1902  peer_id = ntohl (msg->peer);
1903  peer = GST_peer_list[peer_id];
1904  if (GNUNET_YES == peer->is_remote)
1905  {
1906  struct GNUNET_MessageHeader *msg2;
1907 
1908  msg2 = GNUNET_copy_message (&msg->header);
1909  GNUNET_TESTBED_queue_message_ (peer->details.remote.slave->controller,
1910  msg2);
1912  return;
1913  }
1914  rocc = GNUNET_new (struct RemoteOverlayConnectCtx);
1915  rocc->op_id = GNUNET_ntohll (msg->operation_id);
1917  roccq_tail,
1918  rocc);
1919  rocc->a_id = msg->peer_identity;
1921  &pid);
1922  (void) GNUNET_strlcpy (pid_str,
1923  GNUNET_i2s (&pid),
1924  sizeof(pid_str));
1925  LOG_DEBUG (
1926  "0x%llx: Remote overlay connect %s to peer %s with hello size: %u\n",
1927  rocc->op_id,
1928  pid_str,
1929  GNUNET_i2s (&rocc->a_id),
1930  hsize);
1931  rocc->peer = peer;
1932  rocc->peer->reference_cnt++;
1933  rocc->hello = GNUNET_malloc (hsize);
1934  GNUNET_memcpy (rocc->hello,
1935  msg->hello,
1936  hsize);
1937  rocc->tcc.cgh_p2_th =
1939  rocc->peer->details.local.cfg,
1942  rocc,
1943  &rocc->a_id,
1945  rocc);
1946  rocc->timeout_rocc_task_id =
1949  rocc);
1951 }
1952 
1953 
1957 void
1959 {
1960  struct OverlayConnectContext *occ;
1961 
1962  while (NULL != (occ = occq_head))
1963  cleanup_occ (occ);
1964 }
1965 
1966 
1970 void
1972 {
1973  struct RemoteOverlayConnectCtx *rocc;
1974 
1975  while (NULL != (rocc = roccq_head))
1976  cleanup_rocc (rocc);
1977 }
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:475
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:408
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
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:193
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:77
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:2437
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:581
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:603
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_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#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:390
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_MessageHeader hello[0]
To be followed by the HELLO message of A.
Definition: testbed.h:433
#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:75
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:591
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:428
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_.
struct Peer::@66::@68 remote
#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:250
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:395
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:1253
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint32_t peer
The Unique ID of B.
Definition: testbed.h:418
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:385
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:596
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:48
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:1406
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION.
Definition: testbed.h:586
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:1280
uint32_t peer2
Second peer.
Definition: testbed.h:496
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:400
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:423
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:501
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:442
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.
union Peer::@66 details
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION
Message containing the peer&#39;s information.
static int forward
Search direction: forward.
Definition: gnunet-abd.c:162
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:623
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:2324
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
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:76
uint32_t peer1
First peer.
Definition: testbed.h:491
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:1335
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 Peer::@66::@67 local
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:1369
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:486
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:761
Allow multiple values with the same key.
Message sent from client to testing service to connect two peers.
Definition: testbed.h:375
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:380
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.
void GST_destroy_peer(struct Peer *peer)
Function to destroy a peer.
configuration data
Definition: configuration.c:85
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
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:1337
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.
union OverlayConnectContext::@69 p2ctx
Context information for operations on the second peer.
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:77
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c: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.
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.
Definition: strings.c:219
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:2243
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.
#define LOG_DEBUG(...)
Debug logging shorthand.
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:136
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT.
Definition: testbed.h:413
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:966
struct ConnectivitySuggestContext tcc
The transport ConnectivitySuggestContext.