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 
49 
54 
60 
65 
70 };
71 
72 
82 
88 
94 };
95 
96 
107 
112 };
113 
114 
126 
132 
138 
143  struct Neighbour *p2n;
144 };
145 
154 
159 
165 
169  struct Peer *peer;
170 
176 
181 
187 
192 
197 
201  char *emsg;
202 
206  union {
210  struct LocalPeer2Context local;
211 
215  struct RemotePeer2Context remote;
216  } p2ctx;
217 
221  struct GNUNET_PeerIdentity peer_identity;
222 
226  struct GNUNET_PeerIdentity other_peer_identity;
227 
231  uint64_t op_id;
232 
238 
243 
248 
253 
257  uint32_t other_peer_id;
258 };
259 
260 
273 
278 
282  struct Peer *peer;
283 
288 
293 
298 
302  struct GNUNET_PeerIdentity a_id;
303 
308 
313 
317  uint64_t op_id;
318 };
319 
320 
325 
330 
336 
341 
342 
348 void
350 {
351  struct RegisteredHostContext *rhc = focc->rhc;
352 
354  rhc->focc_dll_tail,
355  focc);
357  GNUNET_free(focc);
358 }
359 
360 
366 static void
368 {
369  struct ForwardedOperationContext *fopc = cls;
370  struct RegisteredHostContext *rhc;
371  struct ForwardedOverlayConnectContext *focc;
372 
373  fopc->timeout_task = NULL;
374  rhc = fopc->cls;
375  focc = rhc->focc_dll_head;
376  LOG_DEBUG("Overlay linking between peers %u and %u failed\n",
377  focc->peer1,
378  focc->peer2);
379  GST_cleanup_focc(focc);
381  if (NULL != rhc->focc_dll_head)
383 }
384 
385 
394 static void
396  const struct GNUNET_MessageHeader *msg)
397 {
398  struct ForwardedOperationContext *fopc = cls;
399  struct RegisteredHostContext *rhc;
400  struct ForwardedOverlayConnectContext *focc;
401 
402  rhc = fopc->cls;
404  focc = rhc->focc_dll_head;
405  GST_cleanup_focc(focc);
406  if (NULL != rhc->focc_dll_head)
408 }
409 
410 
416 void
418 {
419  struct ForwardedOperationContext *fopc;
420  struct ForwardedOverlayConnectContext *focc;
421  struct Peer *peer;
422  struct Slave *slave;
423 
424  focc = rhc->focc_dll_head;
425  GNUNET_assert(NULL != focc);
426  GNUNET_assert(RHC_DONE == rhc->state);
428  peer = GST_peer_list[focc->peer1];
430  GNUNET_assert(NULL != (slave = peer->details.remote.slave));
431  fopc = GNUNET_new(struct ForwardedOperationContext);
432  fopc->client = focc->client;
433  fopc->operation_id = focc->operation_id;
434  fopc->cls = rhc;
435  fopc->type = OP_OVERLAY_CONNECT;
436  fopc->opc =
438  focc->operation_id,
439  focc->orig_msg,
441  fopc);
442  GNUNET_free(focc->orig_msg);
443  focc->orig_msg = NULL;
446  fopc);
448  fopcq_tail,
449  fopc);
450 }
451 
452 
458 static void
460 {
461  if (NULL != lp2c->ohh)
462  {
464  lp2c->ohh = NULL;
465  }
466  if (NULL != lp2c->tcc.cgh_p2_th)
467  {
469  lp2c->tcc.cgh_p2_th = NULL;
470  }
471  if (NULL != lp2c->tcc.cgh_p2_ats)
472  {
474  lp2c->tcc.cgh_p2_ats = NULL;
475  }
476  if (NULL != lp2c->tcc.csh)
477  {
479  lp2c->tcc.csh = NULL;
480  }
481 }
482 
483 
490 static void
492 {
493  if (NULL != rp2c->opc)
494  {
496  rp2c->opc = NULL;
497  }
498  if (NULL != rp2c->ncn)
499  {
501  rp2c->ncn = NULL;
502  }
503  if ((NULL != rp2c->p2c) && (NULL != rp2c->p2n))
504  {
506  rp2c->p2n = NULL;
507  }
508 }
509 
515 #define PEER_EXPIRED(peer) \
516  ((GNUNET_YES == peer->destroy_flag) && (0 == peer->reference_cnt))
517 
523 static void
525 {
526  struct Peer *peer2;
527 
528  LOG_DEBUG("0x%llx: Cleaning up occ\n",
529  occ->op_id);
532  if (NULL != occ->send_hello_task)
534  if (NULL != occ->cleanup_task)
536  if (NULL != occ->timeout_task)
538  if (NULL != occ->cgh_ch)
540  if (NULL != occ->ghh)
543  GNUNET_assert(NULL != GST_peer_list);
544  GNUNET_assert(occ->peer->reference_cnt > 0);
545  occ->peer->reference_cnt--;
546  if (PEER_EXPIRED(occ->peer))
547  GST_destroy_peer(occ->peer);
548  switch (occ->type)
549  {
550  case OCC_TYPE_LOCAL:
551  peer2 = GST_peer_list[occ->other_peer_id];
552  GNUNET_assert(peer2->reference_cnt > 0);
553  peer2->reference_cnt--;
554  if (PEER_EXPIRED(peer2))
555  GST_destroy_peer(peer2);
557  break;
558 
562  break;
563  }
564  GNUNET_CONTAINER_DLL_remove(occq_head,
565  occq_tail,
566  occ);
567  GNUNET_free(occ);
568 }
569 
570 
576 static void
577 do_cleanup_occ(void *cls)
578 {
579  struct OverlayConnectContext *occ = cls;
580 
581  occ->cleanup_task = NULL;
582  cleanup_occ(occ);
583 }
584 
585 
591 static void
593 {
594  struct OverlayConnectContext *occ = cls;
595 
596  GNUNET_assert(NULL != occ->timeout_task);
597  occ->timeout_task = NULL;
598  /* LOG (GNUNET_ERROR_TYPE_WARNING, */
599  /* "0x%llx: Timeout while connecting peers %u and %u: %s\n", occ->op_id, */
600  /* occ->peer->id, occ->other_peer_id, occ->emsg); */
602  occ->op_id,
603  occ->emsg);
604  cleanup_occ(occ);
605 }
606 
607 
613 void
615 {
616  struct ForwardedOperationContext *fopc;
617  struct ForwardedOperationContext *fopcn;
618  struct OverlayConnectContext *occ;
619  struct OverlayConnectContext *occn;
620 
621  for (fopc = fopcq_head; NULL != fopc; fopc = fopcn)
622  {
623  fopcn = fopc->next;
624  if (fopc->client == client)
625  {
628  }
629  }
630  for (occ = occq_head; NULL != occ; occ = occn)
631  {
632  occn = occ->next;
633  if (occ->client == client)
634  cleanup_occ(occ);
635  }
636  // FIXME: implement clean up for client_keep replacements!
637 }
638 
639 
640 
641 
645 static void
647 {
648  struct GNUNET_MQ_Envelope *env;
650 
651  LOG_DEBUG("0x%llx: Peers connected - Sending overlay connect success\n",
652  occ->op_id);
653  env = GNUNET_MQ_msg(msg,
656  msg->peer1 = htonl(occ->peer->id);
657  msg->peer2 = htonl(occ->other_peer_id);
658  msg->operation_id = GNUNET_htonll(occ->op_id);
660  env);
661 }
662 
663 
671 static void
673  const struct GNUNET_PeerIdentity *new_peer)
674 {
675  struct OverlayConnectContext *occ = cls;
676  char *new_peer_str;
677  char *other_peer_str;
678 
679  LOG_DEBUG("Overlay connect notify\n");
680  if (0 ==
681  memcmp(new_peer, &occ->peer_identity,
682  sizeof(struct GNUNET_PeerIdentity)))
683  return;
684  new_peer_str = GNUNET_strdup(GNUNET_i2s(new_peer));
685  other_peer_str = GNUNET_strdup(GNUNET_i2s(&occ->other_peer_identity));
686  if (0 !=
687  memcmp(new_peer,
688  &occ->other_peer_identity,
689  sizeof(struct GNUNET_PeerIdentity)))
690  {
691  LOG_DEBUG("Unexpected peer %s connected when expecting peer %s\n",
692  new_peer_str,
693  other_peer_str);
694  GNUNET_free(new_peer_str);
695  GNUNET_free(other_peer_str);
696  return;
697  }
698  GNUNET_free(new_peer_str);
699  LOG_DEBUG("0x%llx: Peer %s connected to peer %s\n",
700  occ->op_id,
701  other_peer_str,
702  GNUNET_i2s(&occ->peer_identity));
703  GNUNET_free(other_peer_str);
704  if (NULL != occ->send_hello_task)
705  {
707  occ->send_hello_task = NULL;
708  }
709  GNUNET_assert(NULL != occ->timeout_task);
711  occ->timeout_task = NULL;
712  switch (occ->type)
713  {
714  case OCC_TYPE_LOCAL:
716  break;
717 
721  break;
722  }
724  occ->emsg = NULL;
727  occ);
728 }
729 
730 
741 static void
743  struct GNUNET_CORE_Handle *ch,
744  struct GNUNET_TRANSPORT_CoreHandle *th,
746  const struct GNUNET_PeerIdentity *my_identity,
747  const struct GNUNET_CONFIGURATION_Handle *cfg)
748 {
749  struct OverlayConnectContext *occ = cls;
750  struct LocalPeer2Context *lp2c;
751 
753  GNUNET_assert(NULL != occ->timeout_task);
755  if (NULL == ac)
756  {
757  GNUNET_asprintf(&occ->emsg,
758  "0x%llx: Failed to connect to ATS of peer with id: %u",
759  occ->op_id,
760  occ->peer->id);
762  occ->timeout_task =
764  occ);
765  return;
766  }
767  occ->emsg = NULL;
768 
769  GNUNET_asprintf(&occ->emsg,
770  "0x%llx: Timeout during GNUNET_ATS_connectivity_suggest() at peer %s",
771  occ->op_id,
773 
774  lp2c = &occ->p2ctx.local;
775  lp2c->tcc.csh =
777  &occ->peer_identity,
778  1);
779 }
780 
781 
791 static void
793  struct GNUNET_CORE_Handle *ch,
794  struct GNUNET_TRANSPORT_CoreHandle *th,
796  const struct GNUNET_PeerIdentity *my_identity,
797  const struct GNUNET_CONFIGURATION_Handle *cfg)
798 {
799  struct RemoteOverlayConnectCtx *rocc = cls;
800 
801  rocc->tcc.csh =
803  &rocc->a_id,
804  1);
805 }
806 
807 
814 static void
815 send_hello(void *cls);
816 
817 
825 static void
827 {
828  struct OverlayConnectContext *occ = cls;
829  struct LocalPeer2Context *lp2c;
830  struct Peer *peer2;
831 
833  GNUNET_assert(NULL != occ->timeout_task);
834  lp2c = &occ->p2ctx.local;
835  lp2c->ohh = NULL;
836 
837  GNUNET_assert(NULL == occ->send_hello_task);
839 
840  GNUNET_asprintf(&occ->emsg,
841  "0x%llx: Timeout while acquiring ATS of %s from cache",
842  occ->op_id,
844  GNUNET_assert(NULL != (peer2 = GST_peer_list[occ->other_peer_id]));
845  lp2c->tcc.cgh_p2_ats =
847  peer2->details.local.cfg,
850  occ, NULL, NULL, NULL);
851 }
852 
853 
861 static void
863 {
865  char *other_peer_str;
866  uint16_t msize;
867  uint16_t hello_size;
868 
870  GNUNET_assert(NULL != occ->hello);
871  other_peer_str = GNUNET_strdup(GNUNET_i2s(&occ->other_peer_identity));
872  LOG_DEBUG("0x%llx: Offering HELLO of %s (size: %u) to %s via Remote Overlay Request\n",
873  occ->op_id,
874  GNUNET_i2s(&occ->peer_identity),
875  ntohs(occ->hello->size),
876  other_peer_str);
877  GNUNET_free(other_peer_str);
878  hello_size = ntohs(occ->hello->size);
879  msize = sizeof(struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hello_size;
880  msg = GNUNET_malloc(msize);
881  msg->header.type =
883  msg->header.size = htons(msize);
884  msg->peer = htonl(occ->other_peer_id);
885  msg->operation_id = GNUNET_htonll(occ->op_id);
886  msg->peer_identity = occ->peer_identity;
887  GNUNET_memcpy(msg->hello,
888  occ->hello,
889  hello_size);
891  &msg->header);
892 }
893 
894 
902 static void
903 send_hello(void *cls)
904 {
905  struct OverlayConnectContext *occ = cls;
906  struct LocalPeer2Context *lp2c;
907  char *other_peer_str;
908 
909  occ->send_hello_task = NULL;
910  GNUNET_assert(NULL != occ->timeout_task);
911  GNUNET_assert(NULL != occ->hello);
912  if (OCC_TYPE_LOCAL != occ->type)
913  {
915  return;
916  }
917  lp2c = &occ->p2ctx.local;
918  other_peer_str = GNUNET_strdup(GNUNET_i2s(&occ->other_peer_identity));
919  LOG_DEBUG("0x%llx: Offering HELLO of %s to %s\n",
920  occ->op_id,
921  GNUNET_i2s(&occ->peer_identity),
922  other_peer_str);
923  GNUNET_free(other_peer_str);
924  lp2c->ohh =
926  occ->hello,
928  occ);
929  if (NULL == lp2c->ohh)
930  {
931  GNUNET_break(0);
932  occ->send_hello_task =
935  100 +
938  &send_hello, occ);
939  }
940 }
941 
942 
953 static void
955  struct GNUNET_CORE_Handle *ch,
956  struct GNUNET_TRANSPORT_CoreHandle *th,
958  const struct GNUNET_PeerIdentity *ignore_,
959  const struct GNUNET_CONFIGURATION_Handle *cfg)
960 {
961  struct OverlayConnectContext *occ = cls;
962 
964  if (NULL == th)
965  {
966  GNUNET_asprintf(&occ->emsg,
967  "0x%llx: Cannot connect to TRANSPORT of %s",
968  occ->op_id,
971  occ->timeout_task =
973  return;
974  }
975  occ->p2ctx.local.tcc.th_ = th;
976  occ->p2ctx.local.tcc.cfg = cfg;
977  GNUNET_asprintf(&occ->emsg,
978  "0x%llx: Timeout while offering HELLO to %s",
979  occ->op_id,
982 }
983 
984 
991 static void
993 {
994  struct Peer *peer2;
995 
996  /* HUH? Why to *obtain* HELLO? Seems we use this to *SEND* the
997  HELLO! */
999  "Connecting to transport of peer %s to obtain HELLO\n",
1001  GNUNET_assert(NULL == occ->emsg);
1002  GNUNET_assert(NULL != occ->hello);
1003  GNUNET_assert(NULL == occ->ghh);
1004  GNUNET_assert(NULL == occ->p1th_);
1005  GNUNET_assert(NULL == occ->cgh_p1th);
1006  if (OCC_TYPE_LOCAL == occ->type)
1007  {
1008  GNUNET_assert(NULL != (peer2 = GST_peer_list[occ->other_peer_id]));
1009  occ->p2ctx.local.tcc.cgh_p2_th =
1011  peer2->details.local.cfg,
1014  occ, NULL, NULL, NULL);
1015  return;
1016  }
1017  GNUNET_asprintf(&occ->emsg,
1018  "0x%llx: Timeout while offering HELLO to %s",
1019  occ->op_id,
1022 }
1023 
1024 
1033 static int
1034 test_address(void *cls,
1035  const struct GNUNET_HELLO_Address *address,
1037 {
1038  int *empty = cls;
1039 
1040  *empty = GNUNET_NO;
1041  return GNUNET_OK;
1042 }
1043 
1044 
1053 static void
1055  const struct GNUNET_MessageHeader *hello)
1056 {
1057  struct OverlayConnectContext *occ = cls;
1058  int empty;
1059  uint16_t msize;
1060 
1061  msize = ntohs(hello->size);
1062  empty = GNUNET_YES;
1064  hello, GNUNET_NO,
1065  &test_address,
1066  &empty);
1067  if (GNUNET_YES == empty)
1068  {
1069  LOG_DEBUG("0x%llx: HELLO of %s is empty\n",
1070  occ->op_id,
1071  GNUNET_i2s(&occ->peer_identity));
1072  return;
1073  }
1074  LOG_DEBUG("0x%llx: Received HELLO of %s\n",
1075  occ->op_id,
1076  GNUNET_i2s(&occ->peer_identity));
1077  occ->hello = GNUNET_malloc(msize);
1078  GST_cache_add_hello(occ->peer->id, hello);
1079  GNUNET_memcpy(occ->hello, hello, msize);
1081  occ->ghh = NULL;
1083  occ->cgh_p1th = NULL;
1084  occ->p1th_ = NULL;
1085  GNUNET_free_non_null(occ->emsg);
1086  occ->emsg = NULL;
1087  p2_transport_connect(occ);
1088 }
1089 
1090 
1100 static void
1102  struct GNUNET_CORE_Handle *ch,
1103  struct GNUNET_TRANSPORT_CoreHandle *th,
1105  const struct GNUNET_PeerIdentity *ignore_,
1106  const struct GNUNET_CONFIGURATION_Handle *cfg)
1107 {
1108  struct OverlayConnectContext *occ = cls;
1109 
1110  GNUNET_free_non_null(occ->emsg);
1111  occ->emsg = NULL;
1112  if (NULL == th)
1113  {
1114  GNUNET_asprintf(&occ->emsg,
1115  "0x%llx: Cannot connect to TRANSPORT of %s",
1116  occ->op_id,
1117  GNUNET_i2s(&occ->peer_identity));
1119  occ->timeout_task =
1121  return;
1122  }
1123  GNUNET_assert(NULL == occ->p1th_);
1124  GNUNET_assert(NULL != occ->cgh_p1th);
1125  occ->p1th_ = th;
1126  GNUNET_asprintf(&occ->emsg,
1127  "0x%llx: Timeout while acquiring HELLO of peer %s",
1128  occ->op_id,
1129  GNUNET_i2s(&occ->peer_identity));
1130  occ->ghh = GNUNET_TRANSPORT_hello_get(cfg,
1132  &hello_update_cb,
1133  occ);
1134 }
1135 
1136 
1146 static void
1148  struct GNUNET_CORE_Handle *ch,
1149  struct GNUNET_TRANSPORT_CoreHandle *th,
1151  const struct GNUNET_PeerIdentity *my_identity,
1152  const struct GNUNET_CONFIGURATION_Handle *cfg)
1153 {
1154  struct OverlayConnectContext *occ = cls;
1155  const struct GNUNET_MessageHeader *hello;
1156 
1157  GNUNET_assert(NULL != occ->timeout_task);
1158  GNUNET_free_non_null(occ->emsg);
1159  if ((NULL == ch) || (NULL == my_identity))
1160  {
1161  GNUNET_asprintf(&occ->emsg,
1162  "0x%llx: Failed to connect to CORE of peer with "
1163  "id: %u",
1164  occ->op_id,
1165  occ->peer->id);
1167  occ->timeout_task =
1169  return;
1170  }
1171  occ->emsg = NULL;
1172  if (NULL !=
1173  GNUNET_CORE_get_mq(ch,
1174  &occ->other_peer_identity))
1175  {
1176  LOG_DEBUG("0x%llx: Target peer already connected\n",
1177  occ->op_id);
1179  occ->timeout_task = NULL;
1182  return;
1183  }
1184  occ->peer_identity = *my_identity;
1185  LOG_DEBUG("0x%llx: Acquiring HELLO of peer %s\n",
1186  occ->op_id,
1187  GNUNET_i2s(&occ->peer_identity));
1188  /* Lookup for HELLO in hello cache */
1189  if (NULL != (hello = GST_cache_lookup_hello(occ->peer->id)))
1190  {
1191  LOG_DEBUG("0x%llx: HELLO of peer %s found in cache\n",
1192  occ->op_id,
1193  GNUNET_i2s(&occ->peer_identity));
1194  occ->hello = GNUNET_copy_message(hello);
1195  p2_transport_connect(occ);
1196  return;
1197  }
1198  GNUNET_asprintf(&occ->emsg,
1199  "0x%llx: Timeout while acquiring TRANSPORT of %s from cache",
1200  occ->op_id,
1201  GNUNET_i2s(&occ->peer_identity));
1202  occ->cgh_p1th =
1204  occ->peer->details.local.cfg,
1207  occ,
1208  NULL, NULL, NULL);
1209 }
1210 
1211 
1220 static void
1222  const struct GNUNET_MessageHeader *msg)
1223 {
1224  struct OverlayConnectContext *occ = cls;
1225  struct RemotePeer2Context *rp2c;
1227 
1229  rp2c = &occ->p2ctx.remote;
1230  rp2c->opc = NULL;
1231  GNUNET_assert(NULL != occ->timeout_task);
1233  {
1235  occ->timeout_task =
1237  }
1238  cmsg =
1240  occ->other_peer_identity = cmsg->peer_identity;
1241  GNUNET_free_non_null(occ->emsg);
1242  GNUNET_asprintf(&occ->emsg,
1243  "0x%llx: Timeout while connecting to CORE of peer with "
1244  "id: %u",
1245  occ->op_id,
1246  occ->peer->id);
1247  occ->cgh_ch =
1249  occ->peer->details.local.cfg,
1252  occ,
1253  &occ->other_peer_identity,
1255  occ);
1256  return;
1257 }
1258 
1259 
1266 static void
1267 host_registration_comp(void *cls, const char *emsg)
1268 {
1269  struct RegisteredHostContext *rhc = cls;
1270 
1271  rhc->state = RHC_DONE;
1272  GST_process_next_focc(rhc);
1273 }
1274 
1275 
1286 static int
1288  const struct GNUNET_HashCode *key,
1289  void *value)
1290 {
1291  struct RegisteredHostContext **rh = cls;
1292  struct RegisteredHostContext *rh_val = value;
1293 
1294  if ((rh_val->host == (*rh)->host) && (rh_val->reg_host == (*rh)->reg_host))
1295  {
1296  GNUNET_free(*rh);
1297  *rh = rh_val;
1298  return GNUNET_NO;
1299  }
1300  return GNUNET_YES;
1301 }
1302 
1303 
1311 static struct GNUNET_HashCode
1313  struct GNUNET_TESTBED_Host *host)
1314 {
1315  struct GNUNET_HashCode hash;
1316  uint32_t host_ids[2];
1317 
1318  host_ids[0] = GNUNET_TESTBED_host_get_id_(reg_host);
1319  host_ids[1] = GNUNET_TESTBED_host_get_id_(host);
1320  GNUNET_CRYPTO_hash(host_ids, sizeof(host_ids), &hash);
1321  return hash;
1322 }
1323 
1324 
1338 static struct RegisteredHostContext *
1339 register_host(struct Slave *slave,
1340  struct GNUNET_TESTBED_Host *host)
1341 {
1342  struct GNUNET_HashCode hash;
1343  struct RegisteredHostContext *rhc;
1344 
1345  rhc = GNUNET_new(struct RegisteredHostContext);
1346  rhc->reg_host = host;
1347  rhc->host = GST_host_list[slave->host_id];
1348  GNUNET_assert(NULL != rhc->reg_host);
1349  GNUNET_assert(NULL != rhc->host);
1350  rhc->state = RHC_INIT;
1351  hash = hash_hosts(rhc->reg_host, rhc->host);
1352  if ((GNUNET_NO ==
1354  &hash)) ||
1355  (GNUNET_SYSERR !=
1357  &hash,
1359  &rhc)))
1360  {
1361  /* create and add a new registerd host context */
1362  /* add the focc to its queue */
1364  &hash,
1365  rhc,
1369  rhc,
1370  rhc->reg_host);
1371  }
1372  else
1373  {
1374  /* rhc is now set to the existing one from the hash map by
1375  * reghost_match_iterator() */
1376  /* if queue is empty then ignore creating focc and proceed with normal
1377  * forwarding */
1378  if (RHC_DONE == rhc->state)
1379  return NULL;
1380  }
1381  return rhc;
1382 }
1383 
1384 
1394 static void
1396  struct GNUNET_SERVICE_Client *client)
1397 {
1398  struct ForwardedOperationContext *fopc;
1399  struct Route *route_to_peer2_host;
1400  struct Route *route_to_peer1_host;
1401  struct Peer *peer;
1402  struct RegisteredHostContext *rhc;
1403  struct ForwardedOverlayConnectContext *focc;
1404  uint64_t op_id;
1405  uint32_t peer2_host_id;
1406  uint32_t p1;
1407  uint32_t p2;
1408 
1409  p1 = ntohl(msg->peer1);
1410  p2 = ntohl(msg->peer2);
1411  op_id = GNUNET_ntohll(msg->operation_id);
1412  peer2_host_id = ntohl(msg->peer2_host_id);
1414  GNUNET_assert(VALID_HOST_ID(peer2_host_id));
1415  peer = GST_peer_list[p1];
1417  LOG_DEBUG("0x%llx: Forwarding overlay connect\n", op_id);
1418  route_to_peer2_host = GST_find_dest_route(peer2_host_id);
1419  route_to_peer1_host = GST_find_dest_route
1420  (peer->details.remote.remote_host_id);
1421  GNUNET_assert(NULL != route_to_peer1_host);
1422  if ((NULL != route_to_peer2_host) &&
1423  (route_to_peer1_host->dest == route_to_peer2_host->dest))
1424  goto forward;
1425  /* Peer2 is either with us OR peer1 and peer2 can be reached through
1426  different subtrees OR peer2 is on a subtree unknown to us */
1427  if (NULL != (rhc = register_host(peer->details.remote.slave,
1428  GST_host_list[peer2_host_id])))
1429  {
1430  LOG_DEBUG("Queueing forwarding FOCC for connecting peers %u and %u\n", p1, p2);
1432  focc->rhc = rhc;
1433  focc->peer1 = p1;
1434  focc->peer2 = p2;
1435  focc->peer2_host_id = peer2_host_id;
1436  focc->orig_msg = GNUNET_copy_message(&msg->header);
1437  focc->operation_id = op_id;
1438  focc->client = client;
1440  rhc->focc_dll_tail,
1441  focc);
1442  return;
1443  }
1444 
1445 forward:
1446  LOG_DEBUG("Forwarding without FOCC for connecting peers %u and %u\n", p1, p2);
1447  fopc = GNUNET_new(struct ForwardedOperationContext);
1448  fopc->client = client;
1449  fopc->operation_id = op_id;
1450  fopc->type = OP_OVERLAY_CONNECT;
1451  fopc->opc =
1453  slave->controller, op_id,
1454  &msg->header,
1456  fopc);
1457  fopc->timeout_task =
1460  fopc);
1462  fopcq_tail,
1463  fopc);
1464 }
1465 
1466 
1474 static void
1476  struct GNUNET_TESTBED_Controller *c)
1477 {
1478  struct OverlayConnectContext *occ = cls;
1479  struct RemotePeer2Context *rp2c;
1481 
1483  rp2c = &occ->p2ctx.remote;
1484  rp2c->ncn = NULL;
1485  rp2c->p2c = c;
1486  cmsg.header.size =
1487  htons(sizeof(struct GNUNET_TESTBED_PeerGetConfigurationMessage));
1488  cmsg.header.type =
1490  cmsg.peer_id = htonl(occ->other_peer_id);
1491  cmsg.operation_id = GNUNET_htonll(occ->op_id);
1492  rp2c->opc =
1494  occ->op_id,
1495  &cmsg.header,
1497  occ);
1498  GNUNET_free_non_null(occ->emsg);
1499  GNUNET_asprintf(&occ->emsg,
1500  "0x%llx: Timeout while getting peer identity of peer "
1501  "with id: %u",
1502  occ->op_id,
1503  occ->other_peer_id);
1504 }
1505 
1506 
1513 void
1516 {
1517  struct GNUNET_SERVICE_Client *client = cls;
1518  struct Peer *peer;
1519  struct Peer *peer2;
1520  struct OverlayConnectContext *occ;
1521  struct Neighbour *p2n;
1522  uint64_t operation_id;
1523  uint32_t p1;
1524  uint32_t p2;
1525  uint32_t peer2_host_id;
1526 
1527  p1 = ntohl(msg->peer1);
1528  p2 = ntohl(msg->peer2);
1529  if (!VALID_PEER_ID(p1))
1530  {
1531  GNUNET_break(0);
1533  return;
1534  }
1535  peer = GST_peer_list[p1];
1536  operation_id = GNUNET_ntohll(msg->operation_id);
1537  LOG_DEBUG
1538  ("Received overlay connect for peers %u and %u with op id: 0x%llx\n",
1539  p1,
1540  p2,
1541  operation_id);
1542  peer2_host_id = ntohl(msg->peer2_host_id);
1543  if (GNUNET_YES == peer->is_remote)
1544  {
1545  if (!VALID_HOST_ID(peer2_host_id))
1546  {
1547  GNUNET_break(0);
1549  return;
1550  }
1551  forward_overlay_connect(msg, client);
1553  return;
1554  }
1555  p2n = NULL;
1556  occ = GNUNET_new(struct OverlayConnectContext);
1557  occ->type = OCC_TYPE_LOCAL;
1558  if (!VALID_PEER_ID(p2)) /* May be peer2 is on a another controller */
1559  {
1560  if (NULL == (p2n = GST_get_neighbour(peer2_host_id)))
1561  {
1562  if (!VALID_HOST_ID(peer2_host_id))
1563  {
1564  GNUNET_break(0);
1566  "0x%llx: Peer %u's host not in our neighbours list\n",
1567  operation_id, p2);
1569  GNUNET_free(occ);
1570  return;
1571  }
1572  p2n = GST_create_neighbour(GST_host_list[peer2_host_id]);
1573  }
1575  occ->p2ctx.remote.p2n = p2n;
1576  }
1577  else if (GNUNET_YES == GST_peer_list[p2]->is_remote)
1578  {
1579  occ->type = OCC_TYPE_REMOTE_SLAVE;
1580  occ->p2ctx.remote.p2c = GST_peer_list[p2]->details.remote.slave->controller;
1581  }
1583  occq_tail,
1584  occ);
1585  occ->client = client;
1586  occ->other_peer_id = p2;
1588  occ->peer = GST_peer_list[p1];
1589  occ->op_id = operation_id;
1590  GNUNET_assert(NULL == occ->timeout_task);
1591  occ->timeout_task =
1594  occ);
1595  switch (occ->type)
1596  {
1598  GNUNET_asprintf(&occ->emsg,
1599  "0x%llx: Timeout while acquiring connection to peer %u's "
1600  "host: %u\n",
1601  occ->op_id,
1602  occ->other_peer_id,
1603  peer2_host_id);
1604  occ->p2ctx.remote.ncn
1607  occ);
1608  break;
1609 
1610  case OCC_TYPE_REMOTE_SLAVE:
1612  occ->p2ctx.remote.p2c);
1613  break;
1614 
1615  case OCC_TYPE_LOCAL:
1616  peer2 = GST_peer_list[occ->other_peer_id];
1617  peer2->reference_cnt++;
1619  &occ->other_peer_identity);
1620  GNUNET_asprintf(&occ->emsg,
1621  "0x%llx: Timeout while connecting to CORE of peer with "
1622  "id: %u",
1623  occ->op_id,
1624  occ->peer->id);
1625  occ->cgh_ch =
1627  occ->peer->details.local.cfg,
1630  &occ->other_peer_identity,
1631  &overlay_connect_notify, occ);
1632  break;
1633  }
1635 }
1636 
1637 
1644 static void
1646 {
1647  LOG_DEBUG("0x%llx: Cleaning up rocc\n",
1648  rocc->op_id);
1649  if (NULL != rocc->attempt_connect_task_id)
1651  if (NULL != rocc->timeout_rocc_task_id)
1653  if (NULL != rocc->ohh)
1655  if (NULL != rocc->tcc.csh)
1659  GNUNET_assert(rocc->peer->reference_cnt > 0);
1660  rocc->peer->reference_cnt--;
1661  if ((GNUNET_YES == rocc->peer->destroy_flag) &&
1662  (0 == rocc->peer->reference_cnt))
1663  GST_destroy_peer(rocc->peer);
1664  GNUNET_free_non_null(rocc->hello);
1665  GNUNET_CONTAINER_DLL_remove(roccq_head,
1666  roccq_tail,
1667  rocc);
1668  GNUNET_free(rocc);
1669 }
1670 
1671 
1677 static void
1679 {
1680  struct RemoteOverlayConnectCtx *rocc = cls;
1681 
1682  GNUNET_assert(rocc->timeout_rocc_task_id != NULL);
1683  rocc->timeout_rocc_task_id = NULL;
1684  LOG_DEBUG("0x%llx: rocc timed out\n",
1685  rocc->op_id);
1686  cleanup_rocc(rocc);
1687 }
1688 
1689 
1697 static void
1699  const struct GNUNET_PeerIdentity *new_peer)
1700 {
1701  struct RemoteOverlayConnectCtx *rocc = cls;
1702 
1703  LOG_DEBUG("0x%llx: Request Overlay connect notify\n",
1704  rocc->op_id);
1705  GNUNET_assert(0 ==
1706  memcmp(new_peer, &rocc->a_id,
1707  sizeof(struct GNUNET_PeerIdentity)));
1708  LOG_DEBUG("0x%llx: Peer %s connected\n",
1709  rocc->op_id,
1710  GNUNET_i2s(&rocc->a_id));
1711  cleanup_rocc(rocc);
1712 }
1713 
1714 
1721 static void
1722 attempt_connect_task(void *cls);
1723 
1724 
1732 static void
1734 {
1735  struct RemoteOverlayConnectCtx *rocc = cls;
1736 
1737  rocc->ohh = NULL;
1738  GNUNET_assert(NULL == rocc->attempt_connect_task_id);
1739  LOG_DEBUG("0x%llx: HELLO of peer %s delivered to local peer with id: %u\n",
1740  rocc->op_id,
1741  GNUNET_i2s(&rocc->a_id),
1742  rocc->peer->id);
1743  rocc->tcc.cgh_p2_ats =
1745  rocc->peer->details.local.cfg,
1748  rocc, NULL, NULL, NULL);
1749 }
1750 
1751 
1758 static void
1760 {
1761  struct RemoteOverlayConnectCtx *rocc = cls;
1762 
1763  GNUNET_assert(NULL != rocc->attempt_connect_task_id);
1764  rocc->attempt_connect_task_id = NULL;
1765  LOG_DEBUG("0x%llx: Offering HELLO of peer %s to remote peer with id: %u\n",
1766  rocc->op_id,
1767  GNUNET_i2s(&rocc->a_id),
1768  rocc->peer->id);
1769  rocc->ohh =
1771  rocc->hello,
1773  rocc);
1774  if (NULL == rocc->ohh)
1775  rocc->attempt_connect_task_id =
1778  100 +
1781  &attempt_connect_task, rocc);
1782 }
1783 
1784 
1794 static void
1796  struct GNUNET_CORE_Handle *ch,
1797  struct GNUNET_TRANSPORT_CoreHandle *th,
1799  const struct GNUNET_PeerIdentity *ignore_,
1800  const struct GNUNET_CONFIGURATION_Handle *cfg)
1801 {
1802  struct RemoteOverlayConnectCtx *rocc = cls;
1803 
1804  if (NULL == th)
1805  {
1806  rocc->timeout_rocc_task_id =
1808  return;
1809  }
1810  rocc->tcc.th_ = th;
1811  rocc->tcc.cfg = cfg;
1812  if (NULL !=
1814  &rocc->a_id))
1815  {
1816  LOG_DEBUG("0x%llx: Target peer %s already connected to local peer: %u\n",
1817  rocc->op_id,
1818  GNUNET_i2s(&rocc->a_id),
1819  rocc->peer->id);
1820  cleanup_rocc(rocc);
1821  return;
1822  }
1823  rocc->attempt_connect_task_id =
1825 }
1826 
1827 
1835 int
1838 {
1839  uint32_t peer_id;
1840  uint16_t msize;
1841  uint16_t hsize;
1842 
1843  msize = ntohs(msg->header.size);
1844  if (GNUNET_MESSAGE_TYPE_HELLO != ntohs(msg->hello->type))
1845  {
1846  GNUNET_break(0);
1847  return GNUNET_SYSERR;
1848  }
1849  hsize = ntohs(msg->hello->size);
1850  if ((sizeof(struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hsize) != msize)
1851  {
1852  GNUNET_break(0);
1853  return GNUNET_SYSERR;
1854  }
1855  peer_id = ntohl(msg->peer);
1856  if ((peer_id >= GST_peer_list_size) ||
1857  (NULL == GST_peer_list[peer_id]))
1858  {
1859  GNUNET_break_op(0);
1860  return GNUNET_SYSERR;
1861  }
1862  return GNUNET_OK;
1863 }
1864 
1865 
1872 void
1875 {
1876  struct GNUNET_SERVICE_Client *client = cls;
1877  struct RemoteOverlayConnectCtx *rocc;
1878  struct Peer *peer;
1879  struct GNUNET_PeerIdentity pid;
1880  static char pid_str[16];
1881  uint32_t peer_id;
1882  uint16_t hsize;
1883 
1884  hsize = ntohs(msg->hello->size);
1885  peer_id = ntohl(msg->peer);
1886  peer = GST_peer_list[peer_id];
1887  if (GNUNET_YES == peer->is_remote)
1888  {
1889  struct GNUNET_MessageHeader *msg2;
1890 
1891  msg2 = GNUNET_copy_message(&msg->header);
1892  GNUNET_TESTBED_queue_message_(peer->details.remote.slave->controller,
1893  msg2);
1895  return;
1896  }
1897  rocc = GNUNET_new(struct RemoteOverlayConnectCtx);
1898  rocc->op_id = GNUNET_ntohll(msg->operation_id);
1900  roccq_tail,
1901  rocc);
1902  rocc->a_id = msg->peer_identity;
1904  &pid);
1905  (void)GNUNET_strlcpy(pid_str,
1906  GNUNET_i2s(&pid),
1907  sizeof(pid_str));
1908  LOG_DEBUG("0x%llx: Remote overlay connect %s to peer %s with hello size: %u\n",
1909  rocc->op_id,
1910  pid_str,
1911  GNUNET_i2s(&rocc->a_id),
1912  hsize);
1913  rocc->peer = peer;
1914  rocc->peer->reference_cnt++;
1915  rocc->hello = GNUNET_malloc(hsize);
1916  GNUNET_memcpy(rocc->hello,
1917  msg->hello,
1918  hsize);
1919  rocc->tcc.cgh_p2_th =
1921  rocc->peer->details.local.cfg,
1924  rocc,
1925  &rocc->a_id,
1927  rocc);
1928  rocc->timeout_rocc_task_id =
1931  rocc);
1933 }
1934 
1935 
1939 void
1941 {
1942  struct OverlayConnectContext *occ;
1943 
1944  while (NULL != (occ = occq_head))
1945  cleanup_occ(occ);
1946 }
1947 
1948 
1952 void
1954 {
1955  struct RemoteOverlayConnectCtx *rocc;
1956 
1957  while (NULL != (rocc = roccq_head))
1958  cleanup_rocc(rocc);
1959 }
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:461
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:396
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:191
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:76
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:2424
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:563
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:584
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:378
#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:420
#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:572
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:415
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:246
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:383
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:1237
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
struct Peer::@69::@70 local
uint32_t peer
The Unique ID of B.
Definition: testbed.h:405
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:373
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:577
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:252
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:1399
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION.
Definition: testbed.h:567
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:1264
uint32_t peer2
Second peer.
Definition: testbed.h:481
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:388
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:410
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:486
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:440
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:603
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:2315
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:76
uint32_t peer1
First peer.
Definition: testbed.h:476
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:1328
Overlay connection operation.
Definition: testbed_api.h:78
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:1362
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:471
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:759
Allow multiple values with the same key.
Message sent from client to testing service to connect two peers.
Definition: testbed.h:364
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:368
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:83
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:131
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:1333
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:77
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:351
static 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:2234
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:135
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT.
Definition: testbed.h:400
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:956
struct ConnectivitySuggestContext tcc
The transport ConnectivitySuggestContext.