GNUnet  0.11.x
gnunet-service-transport.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2010-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  */
25 #include "platform.h"
26 #include "gnunet_util_lib.h"
27 #include "gnunet_hello_lib.h"
31 #include "gnunet_ats_service.h"
39 #include "transport.h"
40 
44 #define TRANSPORT_BLACKLIST_HT_SIZE 64
45 
58 #define MAX_PENDING (128 * 1024)
59 
60 
65 {
70 
75 
80 
85 
90 };
91 
92 
97 {
101  CT_NONE = 0,
102 
106  CT_CORE = 1,
107 
112 
117 
122 };
123 
124 
128 struct GST_BlacklistCheck;
129 
133 struct TransportClient
134 {
138  struct TransportClient *next;
139 
143  struct TransportClient *prev;
144 
149 
154 
158  enum ClientType type;
159 
160  union
161  {
168 
172  struct
173  {
179 
184 
191 };
192 
193 
198 {
203 
208 
212  struct GNUNET_PeerIdentity peer;
213 
218 
222  void *cont_cls;
223 
228 
233 
238 
243 };
244 
245 
250 {
255 
260 
265 };
266 
267 
272 {
277 
282 
287 
291  unsigned long long uuid;
292 
298  int down;
299 };
300 
301 
306 
311 
319 
324 
329 
334 
339 
345 
351 
357 
362 static struct GNUNET_PeerIdentity all_zeros;
363 
368 
373 
378 
383 
388 
393 
398 
403 
408 
413 
418 
426 static void
428  const struct GNUNET_MessageHeader *msg,
429  int may_drop)
430 {
431  struct GNUNET_MQ_Envelope *env;
432 
433  if ((GNUNET_MQ_get_length (tc->mq) >= MAX_PENDING) &&
434  (GNUNET_YES == may_drop))
435  {
436  GNUNET_log (
438  "Dropping message of type %u and size %u, have %u/%u messages pending\n",
439  ntohs (msg->type),
440  ntohs (msg->size),
441  GNUNET_MQ_get_length (tc->mq),
442  MAX_PENDING);
444  gettext_noop (
445  "# messages dropped due to slow client"),
446  1,
447  GNUNET_NO);
448  return;
449  }
451  GNUNET_MQ_send (tc->mq, env);
452 }
453 
454 
464 static void *
465 client_connect_cb (void *cls,
466  struct GNUNET_SERVICE_Client *client,
467  struct GNUNET_MQ_Handle *mq)
468 {
469  struct TransportClient *tc;
470 
471  tc = GNUNET_new (struct TransportClient);
472  tc->client = client;
473  tc->mq = mq;
475  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", tc);
476  return tc;
477 }
478 
479 
485 static void
486 do_blacklist_check (void *cls);
487 
488 
498 static int
499 mark_match_down (void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
500 {
501  struct TransportClient *tc = cls;
502  struct SendTransmitContinuationContext *stcc = value;
503 
504  if (tc == stcc->tc)
505  {
506  stcc->down = GNUNET_YES;
507  stcc->tc = NULL;
508  }
509  return GNUNET_OK;
510 }
511 
512 
521 static void
523  struct GNUNET_SERVICE_Client *client,
524  void *app_ctx)
525 {
526  struct TransportClient *tc = app_ctx;
527  struct GST_BlacklistCheck *bc;
528 
530  "Client %p disconnected, cleaning up.\n",
531  tc);
532  if (NULL != active_stccs)
535  tc);
536  for (struct AddressToStringContext *cur = a2s_head; NULL != cur;
537  cur = cur->next)
538  {
539  if (cur->tc == tc)
540  cur->tc = NULL;
541  }
543  switch (tc->type)
544  {
545  case CT_NONE:
546  break;
547 
548  case CT_CORE:
549  break;
550 
551  case CT_MONITOR:
552  break;
553 
554  case CT_BLACKLIST:
555  for (bc = bc_head; NULL != bc; bc = bc->next)
556  {
557  if (bc->bl_pos != tc)
558  continue;
559  bc->bl_pos = tc->next;
560  if (NULL == bc->task)
562  }
563  break;
564 
565  case CT_CORE_NO_HANDLERS:
566  break;
567  }
568  GNUNET_free (tc);
569 }
570 
571 
584 static void
586  const struct GNUNET_PeerIdentity *peer,
587  const struct GNUNET_HELLO_Address *address,
589  struct GNUNET_TIME_Absolute state_timeout,
590  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
591  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
592 {
593  struct TransportClient *tc = cls;
594  struct ConnectInfoMessage cim;
595 
597  return;
598  cim.header.size = htons (sizeof(struct ConnectInfoMessage));
600  cim.id = *peer;
601  cim.quota_out = bandwidth_out;
602  unicast (tc, &cim.header, GNUNET_NO);
603 }
604 
605 
614 static void
615 handle_client_start (void *cls, const struct StartMessage *start)
616 {
617  struct TransportClient *tc = cls;
618  const struct GNUNET_MessageHeader *hello;
619  uint32_t options;
620 
621  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p sent START\n", tc);
622  options = ntohl (start->options);
623  if ((0 != (1 & options)) &&
624  (0 != memcmp (&start->self,
626  sizeof(struct GNUNET_PeerIdentity))))
627  {
628  /* client thinks this is a different peer, reject */
629  GNUNET_break (0);
630  GNUNET_SERVICE_client_drop (tc->client);
631  return;
632  }
633  if (CT_NONE != tc->type)
634  {
635  GNUNET_break (0);
636  GNUNET_SERVICE_client_drop (tc->client);
637  return;
638  }
639  if (0 != (2 & options))
640  tc->type = CT_CORE;
641  else
642  tc->type = CT_CORE_NO_HANDLERS;
643  hello = GST_hello_get ();
644  if (NULL != hello)
645  unicast (tc, hello, GNUNET_NO);
648 }
649 
650 
657 static int
658 check_client_hello (void *cls, const struct GNUNET_MessageHeader *message)
659 {
660  return GNUNET_OK; /* FIXME: check here? */
661 }
662 
663 
670 static void
671 handle_client_hello (void *cls, const struct GNUNET_MessageHeader *message)
672 {
673  struct TransportClient *tc = cls;
674 
675  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received HELLO message\n");
676  GST_validation_handle_hello (message);
678 }
679 
680 
690 static void
692  int success,
693  size_t bytes_payload,
694  size_t bytes_on_wire)
695 {
696  struct SendTransmitContinuationContext *stcc = cls;
697  struct SendOkMessage send_ok_msg;
698 #ifdef ENABLE_TTD
700  const struct GNUNET_HELLO_Address *addr;
701 
704 
707  "It took us %s to send %u/%u bytes to %s (%d, %s)\n",
709  (unsigned int) bytes_payload,
710  (unsigned int) bytes_on_wire,
711  GNUNET_i2s (&stcc->target),
712  success,
713  (NULL != addr) ? addr->transport_name : "%");
714  else
716  "It took us %s to send %u/%u bytes to %s (%d, %s)\n",
718  (unsigned int) bytes_payload,
719  (unsigned int) bytes_on_wire,
720  GNUNET_i2s (&stcc->target),
721  success,
722  (NULL != addr) ? addr->transport_name : "%");
723 #endif
724 
725  if (GNUNET_NO == stcc->down)
726  {
727  /* Only send confirmation if we are still connected */
729  "Sending SEND_OK for transmission request %llu\n",
730  stcc->uuid);
731  send_ok_msg.header.size = htons (sizeof(send_ok_msg));
732  send_ok_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK);
733  send_ok_msg.bytes_msg = htons (bytes_payload);
734  send_ok_msg.bytes_physical = htonl (bytes_on_wire);
735  send_ok_msg.success = htons (success);
736  send_ok_msg.peer = stcc->target;
737  unicast (stcc->tc, &send_ok_msg.header, GNUNET_NO);
738  }
739  GNUNET_assert (
740  GNUNET_OK ==
742  GNUNET_free (stcc);
743 }
744 
745 
752 static int
753 check_client_send (void *cls, const struct OutboundMessage *obm)
754 {
755  uint16_t size;
756  const struct GNUNET_MessageHeader *obmm;
757 
758  size = ntohs (obm->header.size) - sizeof(struct OutboundMessage);
759  if (size < sizeof(struct GNUNET_MessageHeader))
760  {
761  GNUNET_break (0);
762  return GNUNET_SYSERR;
763  }
764  obmm = (const struct GNUNET_MessageHeader *) &obm[1];
765  if (size != ntohs (obmm->size))
766  {
767  GNUNET_break (0);
768  return GNUNET_SYSERR;
769  }
770  return GNUNET_OK;
771 }
772 
773 
780 static void
781 handle_client_send (void *cls, const struct OutboundMessage *obm)
782 {
783  static unsigned long long uuid_gen;
784  struct TransportClient *tc = cls;
785  const struct GNUNET_MessageHeader *obmm;
786  struct SendTransmitContinuationContext *stcc;
787 
788  obmm = (const struct GNUNET_MessageHeader *) &obm[1];
790  {
791  /* not connected, not allowed to send; can happen due to asynchronous operations */
793  "Could not send message to peer `%s': not connected\n",
794  GNUNET_i2s (&obm->peer));
796  GST_stats,
797  gettext_noop ("# bytes payload dropped (other peer was not connected)"),
798  ntohs (obmm->size),
799  GNUNET_NO);
801  return;
802  }
803  GNUNET_log (
805  "Received SEND request %llu for `%s' and first message of type %u and total size %u\n",
806  uuid_gen,
807  GNUNET_i2s (&obm->peer),
808  ntohs (obmm->type),
809  ntohs (obmm->size));
811 
813  stcc->target = obm->peer;
814  stcc->tc = tc;
816  stcc->uuid = uuid_gen++;
818  active_stccs,
819  &stcc->target,
820  stcc,
823  obmm,
824  ntohs (obmm->size),
827  stcc);
828 }
829 
830 
845 static void
846 transmit_address_to_client (void *cls, const char *buf, int res)
847 {
848  struct AddressToStringContext *actx = cls;
849  struct GNUNET_MQ_Envelope *env;
850  struct AddressToStringResultMessage *atsm;
851  size_t slen;
852 
854  if (NULL == actx->tc)
855  return;
856  if (NULL == buf)
857  {
858  env = GNUNET_MQ_msg (atsm,
860  if (GNUNET_OK == res)
861  {
862  /* this was the last call, transmit */
863  atsm->res = htonl (GNUNET_OK);
864  atsm->addr_len = htonl (0);
865  GNUNET_MQ_send (actx->tc->mq, env);
867  GNUNET_free (actx);
868  return;
869  }
870  if (GNUNET_SYSERR == res)
871  {
872  /* address conversion failed, but there will be more callbacks */
873  atsm->res = htonl (GNUNET_SYSERR);
874  atsm->addr_len = htonl (0);
875  GNUNET_MQ_send (actx->tc->mq, env);
876  return;
877  }
878  }
880  /* successful conversion, append*/
881  slen = strlen (buf) + 1;
882  env =
883  GNUNET_MQ_msg_extra (atsm,
884  slen,
886  atsm->res = htonl (GNUNET_YES);
887  atsm->addr_len = htonl (slen);
888  GNUNET_memcpy (&atsm[1], buf, slen);
889  GNUNET_MQ_send (actx->tc->mq, env);
890 }
891 
892 
900 static int
902  const struct AddressLookupMessage *alum)
903 {
904  const char *plugin_name;
905  const char *address;
906  uint32_t address_len;
907  uint16_t size;
908 
909  size = ntohs (alum->header.size);
910  address_len = ntohs (alum->addrlen);
911  if (size <= sizeof(struct AddressLookupMessage) + address_len)
912  {
913  GNUNET_break (0);
914  return GNUNET_SYSERR;
915  }
916  address = (const char *) &alum[1];
917  plugin_name = (const char *) &address[address_len];
918  if ('\0' != plugin_name[size - sizeof(struct AddressLookupMessage)
919  - address_len - 1])
920  {
921  GNUNET_break (0);
922  return GNUNET_SYSERR;
923  }
924  return GNUNET_OK;
925 }
926 
927 
934 static void
936  const struct AddressLookupMessage *alum)
937 {
938  struct TransportClient *tc = cls;
940  const char *plugin_name;
941  const char *address;
942  uint32_t address_len;
943  struct AddressToStringContext *actx;
944  struct GNUNET_MQ_Envelope *env;
945  struct AddressToStringResultMessage *atsm;
946  struct GNUNET_TIME_Relative rtimeout;
947  int32_t numeric;
948 
949  address_len = ntohs (alum->addrlen);
950  address = (const char *) &alum[1];
951  plugin_name = (const char *) &address[address_len];
952  rtimeout = GNUNET_TIME_relative_ntoh (alum->timeout);
953  numeric = ntohs (alum->numeric_only);
955  if (NULL == papi)
956  {
958  "Failed to find plugin `%s'\n",
959  plugin_name);
960  env = GNUNET_MQ_msg (atsm,
962  atsm->res = htonl (GNUNET_SYSERR);
963  atsm->addr_len = htonl (0);
964  GNUNET_MQ_send (tc->mq, env);
965  env = GNUNET_MQ_msg (atsm,
967  atsm->res = htonl (GNUNET_OK);
968  atsm->addr_len = htonl (0);
969  GNUNET_MQ_send (tc->mq, env);
970  return;
971  }
972  actx = GNUNET_new (struct AddressToStringContext);
973  actx->tc = tc;
977  "Pretty-printing address of %u bytes using plugin `%s'\n",
978  address_len,
979  plugin_name);
980  papi->address_pretty_printer (papi->cls,
981  plugin_name,
982  address,
983  address_len,
984  numeric,
985  rtimeout,
987  actx);
988 }
989 
990 
998 static struct PeerIterateResponseMessage *
1000  const struct GNUNET_PeerIdentity *peer,
1001  const struct GNUNET_HELLO_Address *address)
1002 {
1004  size_t size;
1005  size_t tlen;
1006  size_t alen;
1007  char *addr;
1008 
1009  GNUNET_assert (NULL != peer);
1010  if (NULL != address)
1011  {
1012  tlen = strlen (address->transport_name) + 1;
1013  alen = address->address_length;
1014  }
1015  else
1016  {
1017  tlen = 0;
1018  alen = 0;
1019  }
1020  size = (sizeof(struct PeerIterateResponseMessage) + alen + tlen);
1021  msg = GNUNET_malloc (size);
1022  msg->header.size = htons (size);
1023  msg->header.type =
1025  msg->reserved = htonl (0);
1026  msg->peer = *peer;
1027  msg->addrlen = htonl (alen);
1028  msg->pluginlen = htonl (tlen);
1029 
1030  if (NULL != address)
1031  {
1032  msg->local_address_info = htonl ((uint32_t) address->local_info);
1033  addr = (char *) &msg[1];
1034  GNUNET_memcpy (addr, address->address, alen);
1035  GNUNET_memcpy (&addr[alen], address->transport_name, tlen);
1036  }
1037  return msg;
1038 }
1039 
1040 
1045 struct IterationContext
1046 {
1051 
1055  struct GNUNET_PeerIdentity id;
1056 
1060  int all;
1061 };
1062 
1063 
1075 static void
1077  const struct GNUNET_PeerIdentity *peer,
1078  const struct GNUNET_HELLO_Address *address,
1080  struct GNUNET_TIME_Absolute state_timeout,
1081  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
1082  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
1083 {
1084  struct IterationContext *pc = cls;
1085  struct GNUNET_MQ_Envelope *env;
1087 
1088  if ((GNUNET_YES != pc->all) && (0 != memcmp (peer, &pc->id, sizeof(pc->id))))
1089  return;
1091  "Sending information about `%s' using address `%s' in state `%s'\n",
1092  GNUNET_i2s (peer),
1093  (NULL != address) ? GST_plugins_a2s (address) : "<none>",
1096  msg->state = htonl (state);
1097  msg->state_timeout = GNUNET_TIME_absolute_hton (state_timeout);
1098  env = GNUNET_MQ_msg_copy (&msg->header);
1099  GNUNET_free (msg);
1100  GNUNET_MQ_send (pc->tc->mq, env);
1101 }
1102 
1103 
1111 static void
1113 {
1114  struct TransportClient *tc = cls;
1115  struct IterationContext pc;
1116 
1117  if (CT_NONE != tc->type)
1118  {
1119  GNUNET_break (0);
1120  GNUNET_SERVICE_client_drop (tc->client);
1121  return;
1122  }
1125 
1126  /* Send initial list */
1127  pc.tc = tc;
1128  if (0 == memcmp (&msg->peer, &all_zeros, sizeof(struct GNUNET_PeerIdentity)))
1129  {
1130  /* iterate over all neighbours */
1131  pc.all = GNUNET_YES;
1132  pc.id = msg->peer;
1133  }
1134  else
1135  {
1136  /* just return one neighbour */
1137  pc.all = GNUNET_NO;
1138  pc.id = msg->peer;
1139  }
1141 
1142  if (GNUNET_YES != ntohl (msg->one_shot))
1143  {
1144  tc->details.monitor_peer = msg->peer;
1145  tc->type = CT_MONITOR;
1146  if (0 !=
1147  memcmp (&msg->peer, &all_zeros, sizeof(struct GNUNET_PeerIdentity)))
1149  "Client %p started monitoring of the peer `%s'\n",
1150  tc,
1151  GNUNET_i2s (&msg->peer));
1152  else
1154  "Client %p started monitoring all peers\n",
1155  tc);
1156  }
1157  else
1158  {
1159  struct GNUNET_MessageHeader *msg;
1160  struct GNUNET_MQ_Envelope *env;
1161 
1162  env =
1163  GNUNET_MQ_msg (msg,
1165  GNUNET_MQ_send (tc->mq, env);
1166  }
1167 }
1168 
1169 
1182 static void
1184  struct GNUNET_ATS_Session *session,
1185  const struct GNUNET_TRANSPORT_SessionInfo *info)
1186 {
1187  struct GNUNET_MQ_Envelope *env;
1189  struct GNUNET_MessageHeader *sync;
1190  size_t size;
1191  size_t slen;
1192  uint16_t alen;
1193  char *name;
1194  char *addr;
1195 
1197  {
1198  GST_plugins_monitor_subscribe (NULL, NULL);
1199  return;
1200  }
1201  if ((NULL == info) && (NULL == session))
1202  {
1203  /* end of initial iteration */
1204  if (NULL != sync_client)
1205  {
1206  env =
1209  sync_client = NULL;
1210  }
1211  return;
1212  }
1213  GNUNET_assert (NULL != info);
1215  "Plugin event for peer %s on transport %s\n",
1216  GNUNET_i2s (&info->address->peer),
1217  info->address->transport_name);
1218  slen = strlen (info->address->transport_name) + 1;
1219  alen = info->address->address_length;
1220  size = sizeof(struct TransportPluginMonitorMessage) + slen + alen;
1221  if (size > UINT16_MAX)
1222  {
1223  GNUNET_break (0);
1224  return;
1225  }
1226  msg = GNUNET_malloc (size);
1227  msg->header.size = htons (size);
1229  msg->session_state = htons ((uint16_t) info->state);
1230  msg->is_inbound = htons ((int16_t) info->is_inbound);
1231  msg->msgs_pending = htonl (info->num_msg_pending);
1232  msg->bytes_pending = htonl (info->num_bytes_pending);
1233  msg->timeout = GNUNET_TIME_absolute_hton (info->session_timeout);
1234  msg->delay = GNUNET_TIME_absolute_hton (info->receive_delay);
1235  msg->peer = info->address->peer;
1236  msg->session_id = (uint64_t) (intptr_t) session;
1237  msg->plugin_name_len = htons (slen);
1238  msg->plugin_address_len = htons (alen);
1239  name = (char *) &msg[1];
1240  GNUNET_memcpy (name, info->address->transport_name, slen);
1241  addr = &name[slen];
1242  GNUNET_memcpy (addr, info->address->address, alen);
1243  if (NULL != sync_client)
1244  {
1245  struct GNUNET_MQ_Envelope *env;
1246 
1247  env = GNUNET_MQ_msg_copy (&msg->header);
1249  }
1250  else
1251  {
1253  }
1254  GNUNET_free (msg);
1255 }
1256 
1257 
1264 static void
1266  const struct GNUNET_MessageHeader *message)
1267 {
1268  struct TransportClient *tc = cls;
1269 
1273  GNUNET_assert (NULL == sync_client);
1274  sync_client = tc;
1276 }
1277 
1278 
1285 void
1286 GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, int may_drop)
1287 {
1288  int done;
1289 
1291  "Asked to broadcast message of type %u with %u bytes\n",
1292  (unsigned int) ntohs (msg->type),
1293  (unsigned int) ntohs (msg->size));
1294  done = GNUNET_NO;
1295  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
1296  {
1297  if (CT_NONE == tc->type)
1298  continue; /* client not yet ready */
1299  if ((GNUNET_YES == may_drop) && (CT_CORE != tc->type))
1300  continue; /* skip, this client does not care about payload */
1301  unicast (tc, msg, may_drop);
1302  done = GNUNET_YES;
1303  }
1304  if (GNUNET_NO == done)
1306  "Message of type %u not delivered, is CORE service up?\n",
1307  ntohs (msg->type));
1308 }
1309 
1310 
1319 void
1321  const struct GNUNET_PeerIdentity *peer,
1322  const struct GNUNET_HELLO_Address *address,
1324  struct GNUNET_TIME_Absolute state_timeout)
1325 {
1326  struct GNUNET_MQ_Envelope *env;
1328 
1330  msg->state = htonl (state);
1331  msg->state_timeout = GNUNET_TIME_absolute_hton (state_timeout);
1332  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
1333  {
1334  if (CT_MONITOR != tc->type)
1335  continue;
1336  if ((0 == memcmp (&tc->details.monitor_peer,
1337  &all_zeros,
1338  sizeof(struct GNUNET_PeerIdentity))) ||
1339  (0 == memcmp (&tc->details.monitor_peer,
1340  peer,
1341  sizeof(struct GNUNET_PeerIdentity))))
1342  {
1343  env = GNUNET_MQ_msg_copy (&msg->header);
1344  GNUNET_MQ_send (tc->mq, env);
1345  }
1346  }
1347  GNUNET_free (msg);
1348 }
1349 
1350 
1360 static int
1361 mark_peer_down (void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
1362 {
1363  struct SendTransmitContinuationContext *stcc = value;
1364 
1365  stcc->down = GNUNET_YES;
1366  return GNUNET_OK;
1367 }
1368 
1369 
1376 void
1378 {
1379  struct DisconnectInfoMessage disconnect_msg;
1380 
1382  peer,
1383  &mark_peer_down,
1384  NULL);
1385  disconnect_msg.header.size = htons (sizeof(struct DisconnectInfoMessage));
1386  disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
1387  disconnect_msg.reserved = htonl (0);
1388  disconnect_msg.peer = *peer;
1389  GST_clients_broadcast (&disconnect_msg.header, GNUNET_NO);
1390 }
1391 
1392 
1404 static void
1406  const struct GNUNET_PeerIdentity *peer,
1407  const struct GNUNET_HELLO_Address *address,
1409  struct GNUNET_TIME_Absolute state_timeout,
1410  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
1411  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
1412 {
1413  const struct GNUNET_MessageHeader *hello = cls;
1414 
1415  if (0 == memcmp (peer, &GST_my_identity, sizeof(struct GNUNET_PeerIdentity)))
1416  return; /* not to ourselves */
1418  return;
1419 
1421  hello,
1422  ntohs (hello->size),
1424  NULL,
1425  NULL);
1426 }
1427 
1428 
1435 static void
1436 process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello)
1437 {
1438  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Broadcasting HELLO to clients\n");
1440  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Broadcasting HELLO to neighbours\n");
1441  GST_neighbours_iterate (&transmit_our_hello, (void *) hello);
1442 }
1443 
1444 
1455 static struct GNUNET_TIME_Relative
1457  struct GNUNET_ATS_Session *session,
1458  const struct GNUNET_MessageHeader *message)
1459 {
1460  struct GNUNET_TIME_Relative ret;
1461  int do_forward;
1462  struct InboundMessage *im;
1463  size_t msg_size = ntohs (message->size);
1464  size_t size = sizeof(struct InboundMessage) + msg_size;
1465  char buf[size] GNUNET_ALIGN;
1466 
1467  do_forward = GNUNET_SYSERR;
1469  msg_size,
1470  &do_forward);
1471  if (! GST_neighbours_test_connected (&address->peer))
1472  {
1474  "Discarded %u bytes type %u payload from peer `%s'\n",
1475  (unsigned int) msg_size,
1476  ntohs (message->type),
1477  GNUNET_i2s (&address->peer));
1479  GST_stats,
1480  gettext_noop ("# bytes payload discarded due to not connected peer"),
1481  msg_size,
1482  GNUNET_NO);
1483  return ret;
1484  }
1485 
1486  if (GNUNET_YES != do_forward)
1487  return ret;
1488  im = (struct InboundMessage *) buf;
1489  im->header.size = htons (size);
1491  im->peer = address->peer;
1492  GNUNET_memcpy (&im[1], message, ntohs (message->size));
1494  return ret;
1495 }
1496 
1497 
1503 static void
1505 {
1506  struct GNUNET_ATS_SessionKiller *sk = cls;
1507 
1508  sk->task = NULL;
1510  sk->plugin->disconnect_session (sk->plugin->cls, sk->session);
1511  GNUNET_free (sk);
1512 }
1513 
1514 
1522 static void
1524 {
1526  struct GNUNET_ATS_SessionKiller *sk;
1527 
1528  for (sk = sk_head; NULL != sk; sk = sk->next)
1529  if (sk->session == session)
1530  return;
1532  if (NULL == plugin)
1533  {
1534  GNUNET_break (0);
1535  return;
1536  }
1537  /* need to issue disconnect asynchronously */
1538  sk = GNUNET_new (struct GNUNET_ATS_SessionKiller);
1539  sk->session = session;
1540  sk->plugin = plugin;
1543 }
1544 
1545 
1556 static void
1558  const struct GNUNET_PeerIdentity *peer,
1559  const struct GNUNET_HELLO_Address *address,
1560  struct GNUNET_ATS_Session *session,
1561  int result)
1562 {
1563  struct GNUNET_MessageHeader *msg = cls;
1564 
1565  if (GNUNET_OK == result)
1566  {
1567  /* Blacklist allows to speak to this peer, forward SYN to neighbours */
1569  "Received SYN message from peer `%s' at `%s'\n",
1570  GNUNET_i2s (peer),
1573  {
1575  kill_session (address->transport_name, session);
1576  }
1577  GNUNET_free (msg);
1578  return;
1579  }
1580  GNUNET_free (msg);
1581  if (GNUNET_SYSERR == result)
1582  return; /* check was aborted, session destroyed */
1583  /* Blacklist denies to speak to this peer */
1585  "Discarding SYN message from `%s' due to denied blacklist check\n",
1586  GNUNET_i2s (peer));
1587  kill_session (address->transport_name, session);
1588 }
1589 
1590 
1604 struct GNUNET_TIME_Relative
1605 GST_receive_callback (void *cls,
1606  const struct GNUNET_HELLO_Address *address,
1607  struct GNUNET_ATS_Session *session,
1608  const struct GNUNET_MessageHeader *message)
1609 {
1610  const char *plugin_name = cls;
1611  struct GNUNET_TIME_Relative ret;
1612  uint16_t type;
1613 
1615  if (NULL == message)
1616  goto end;
1617  type = ntohs (message->type);
1619  "Received message with type %u from peer `%s' at %s\n",
1620  type,
1621  GNUNET_i2s (&address->peer),
1623 
1625  gettext_noop ("# bytes total received"),
1626  ntohs (message->size),
1627  GNUNET_NO);
1629  switch (type)
1630  {
1632  /* Legacy HELLO message, discard */
1633  return ret;
1634 
1636  if (GNUNET_OK != GST_validation_handle_hello (message))
1637  {
1638  GNUNET_break_op (0);
1640  }
1641  return ret;
1642 
1645  "Processing PING from `%s'\n",
1647  if (GNUNET_OK !=
1648  GST_validation_handle_ping (&address->peer, message, address, session))
1649  {
1651  kill_session (plugin_name, session);
1652  }
1653  break;
1654 
1657  "Processing PONG from `%s'\n",
1659  if (GNUNET_OK != GST_validation_handle_pong (&address->peer, message))
1660  {
1661  GNUNET_break_op (0);
1663  kill_session (plugin_name, session);
1664  }
1665  break;
1666 
1668  /* Do blacklist check if communication with this peer is allowed */
1669  (void) GST_blacklist_test_allowed (&address->peer,
1670  NULL,
1672  GNUNET_copy_message (message),
1673  address,
1674  session);
1675  break;
1676 
1678  if (GNUNET_OK !=
1679  GST_neighbours_handle_session_syn_ack (message, address, session))
1680  {
1682  kill_session (plugin_name, session);
1683  }
1684  break;
1685 
1687  if (GNUNET_OK !=
1688  GST_neighbours_handle_session_ack (message, address, session))
1689  {
1690  GNUNET_break_op (0);
1692  kill_session (plugin_name, session);
1693  }
1694  break;
1695 
1698  break;
1699 
1701  GST_neighbours_handle_quota_message (&address->peer, message);
1702  break;
1703 
1705  GST_neighbours_keepalive (&address->peer, message);
1706  break;
1707 
1709  GST_neighbours_keepalive_response (&address->peer, message);
1710  break;
1711 
1712  default:
1713  /* should be payload */
1715  gettext_noop ("# bytes payload received"),
1716  ntohs (message->size),
1717  GNUNET_NO);
1718  ret = process_payload (address, session, message);
1719  break;
1720  }
1721 end:
1723  "Allowing receive from peer %s to continue in %s\n",
1724  GNUNET_i2s (&address->peer),
1726  return ret;
1727 }
1728 
1729 
1739 static void
1741  void *cls,
1742  int add_remove,
1743  const struct GNUNET_HELLO_Address *address)
1744 {
1745  static int addresses = 0;
1746 
1747  if (GNUNET_YES == add_remove)
1748  {
1749  addresses++;
1750  GNUNET_STATISTICS_update (GST_stats, "# transport addresses", 1, GNUNET_NO);
1751  }
1752  else if (GNUNET_NO == add_remove)
1753  {
1754  if (0 == addresses)
1755  {
1756  GNUNET_break (0);
1757  }
1758  else
1759  {
1760  addresses--;
1762  "# transport addresses",
1763  -1,
1764  GNUNET_NO);
1765  }
1766  }
1768  "Transport now has %u addresses to communicate\n",
1769  addresses);
1770  GST_hello_modify_addresses (add_remove, address);
1771 }
1772 
1773 
1787 static void
1789  const struct GNUNET_HELLO_Address *address,
1790  struct GNUNET_ATS_Session *session)
1791 {
1792  struct GNUNET_ATS_SessionKiller *sk;
1793 
1794  if (NULL == address)
1795  {
1796  GNUNET_break (0);
1797  return;
1798  }
1799  if (NULL == session)
1800  {
1801  GNUNET_break (0);
1802  return;
1803  }
1804  GNUNET_assert (strlen (address->transport_name) > 0);
1805 
1806  GNUNET_log (
1808  "Notification from plugin about terminated session %p from peer `%s' address `%s'\n",
1809  session,
1810  GNUNET_i2s (&address->peer),
1812 
1816 
1817  for (sk = sk_head; NULL != sk; sk = sk->next)
1818  {
1819  if (sk->session == session)
1820  {
1823  GNUNET_free (sk);
1824  break;
1825  }
1826  }
1827 }
1828 
1829 
1841 static void
1843  void *cls,
1844  const struct GNUNET_PeerIdentity *peer,
1845  const struct GNUNET_HELLO_Address *address,
1846  struct GNUNET_ATS_Session *session,
1847  int result)
1848 {
1849  if (GNUNET_OK != result)
1850  {
1851  kill_session (address->transport_name, session);
1852  return;
1853  }
1854  if (GNUNET_YES !=
1857  {
1859  "Informing verifier about inbound session's address `%s'\n",
1862  }
1863 }
1864 
1865 
1874 static void
1876  const struct GNUNET_HELLO_Address *address,
1877  struct GNUNET_ATS_Session *session,
1879 {
1880  struct GNUNET_ATS_Properties prop;
1881 
1882  if (NULL == address)
1883  {
1884  GNUNET_break (0);
1885  return;
1886  }
1887  if (NULL == session)
1888  {
1889  GNUNET_break (0);
1890  return;
1891  }
1892  GNUNET_log (
1894  "Notification from plugin `%s' about new session from peer `%s' address `%s'\n",
1895  address->transport_name,
1896  GNUNET_i2s (&address->peer),
1898  if (GNUNET_YES ==
1901  {
1902  /* inbound is always new, but outbound MAY already be known, but
1903  for example for UNIX, we have symmetric connections and thus we
1904  may not know the address yet; add if necessary! */
1905  /* FIXME: maybe change API here so we just pass scope? */
1906  memset (&prop, 0, sizeof(prop));
1908  prop.scope = scope;
1909  GST_ats_add_inbound_address (address, session, &prop);
1910  }
1911  /* Do blacklist check if communication with this peer is allowed */
1912  (void) GST_blacklist_test_allowed (&address->peer,
1913  address->transport_name,
1915  NULL,
1916  address,
1917  session);
1918 }
1919 
1920 
1939 static void
1941  const struct GNUNET_PeerIdentity *peer,
1942  const struct GNUNET_HELLO_Address *address,
1943  struct GNUNET_ATS_Session *session,
1944  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
1945  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
1946 {
1947  uint32_t bw_in = ntohl (bandwidth_in.value__);
1948  uint32_t bw_out = ntohl (bandwidth_out.value__);
1949 
1950  if (NULL == peer)
1951  {
1952  /* ATS service died, all suggestions become invalid!
1953  (but we'll keep using the allocations for a little
1954  while, to keep going while ATS restarts) */
1955  /* FIXME: We should drop all
1956  connections now, as ATS won't explicitly tell
1957  us and be unaware of ongoing resource allocations! */
1958  return;
1959  }
1960  /* ATS tells me to disconnect from peer */
1961  if ((0 == bw_in) && (0 == bw_out))
1962  {
1964  "ATS tells me to disconnect from peer `%s'\n",
1965  GNUNET_i2s (peer));
1967  return;
1968  }
1969  GNUNET_assert (NULL != address);
1971  "# ATS suggestions received",
1972  1,
1973  GNUNET_NO);
1975  session,
1976  bandwidth_in,
1977  bandwidth_out);
1978 }
1979 
1980 
1985 {
1989  int first;
1990 
1995 };
1996 
1997 
2009 static void
2011  const struct GNUNET_PeerIdentity *peer,
2012  const struct GNUNET_HELLO_Address *address,
2013  struct GNUNET_ATS_Session *session,
2014  int allowed)
2015 {
2016  if (GNUNET_OK == allowed)
2017  return; /* we're done */
2019  gettext_noop ("# disconnects due to blacklist"),
2020  1,
2021  GNUNET_NO);
2023 }
2024 
2025 
2038 static void
2040  const struct GNUNET_PeerIdentity *peer,
2041  const struct GNUNET_HELLO_Address *address,
2043  struct GNUNET_TIME_Absolute state_timeout,
2044  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
2045  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
2046 {
2047  struct TestConnectionContext *tcc = cls;
2048  struct GST_BlacklistCheck *bc;
2049 
2050  bc = GNUNET_new (struct GST_BlacklistCheck);
2052  bc->peer = *peer;
2055  bc->cont_cls = NULL;
2056  bc->bl_pos = tcc->tc;
2057  if (GNUNET_YES == tcc->first)
2058  {
2059  /* all would wait for the same client, no need to
2060  * create more than just the first task right now */
2062  tcc->first = GNUNET_NO;
2063  }
2064 }
2065 
2066 
2075 static void
2077  const struct GNUNET_MessageHeader *message)
2078 {
2079  struct TransportClient *tc = cls;
2080  struct TestConnectionContext tcc;
2081 
2082  if (CT_NONE != tc->type)
2083  {
2084  GNUNET_break (0);
2085  GNUNET_SERVICE_client_drop (tc->client);
2086  return;
2087  }
2089  tc->type = CT_BLACKLIST;
2090  tc->details.blacklist.call_receive_done = GNUNET_YES;
2091  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New blacklist client %p\n", tc);
2092  /* confirm that all existing connections are OK! */
2093  tcc.tc = tc;
2094  tcc.first = GNUNET_YES;
2096 }
2097 
2098 
2107 static int
2109  const struct GNUNET_PeerIdentity *key,
2110  void *value)
2111 {
2112  char *be = value;
2113 
2114  GNUNET_free (be);
2115  return GNUNET_OK;
2116 }
2117 
2118 
2125 static void
2126 handle_client_set_metric (void *cls, const struct TrafficMetricMessage *tm)
2127 {
2128  struct TransportClient *tc = cls;
2129 
2132 }
2133 
2134 
2141 static void
2142 shutdown_task (void *cls)
2143 {
2144  struct AddressToStringContext *cur;
2145 
2147  GST_plugins_unload ();
2149  GST_ats_done ();
2151  GST_ats = NULL;
2153  GST_ats_connect = NULL;
2155  GST_is = NULL;
2156  while (NULL != (cur = a2s_head))
2157  {
2159  GNUNET_free (cur);
2160  }
2161  if (NULL != plugin_nc)
2162  {
2164  plugin_nc = NULL;
2165  }
2167  active_stccs = NULL;
2168  if (NULL != blacklist)
2169  {
2172  NULL);
2174  blacklist = NULL;
2175  }
2176  GST_hello_stop ();
2178 
2179  if (NULL != GST_peerinfo)
2180  {
2182  GST_peerinfo = NULL;
2183  }
2184  if (NULL != GST_stats)
2185  {
2187  GST_stats = NULL;
2188  }
2189 }
2190 
2191 
2197 static void
2199 {
2200  struct GST_BlacklistCheck *bc = cls;
2201  struct TransportClient *tc;
2202  struct GNUNET_MQ_Envelope *env;
2203  struct BlacklistMessage *bm;
2204 
2205  bc->task = NULL;
2206  while (NULL != (tc = bc->bl_pos))
2207  {
2208  if (CT_BLACKLIST == tc->type)
2209  break;
2210  bc->bl_pos = tc->next;
2211  }
2212  if (NULL == tc)
2213  {
2215  "No other blacklist clients active, will allow neighbour `%s'\n",
2216  GNUNET_i2s (&bc->peer));
2217 
2218  bc->cont (bc->cont_cls, &bc->peer, bc->address, bc->session, GNUNET_OK);
2220  return;
2221  }
2222  if ((NULL != tc->details.blacklist.bc) ||
2223  (GNUNET_NO != tc->details.blacklist.waiting_for_reply))
2224  return; /* someone else busy with this client */
2225  tc->details.blacklist.bc = bc;
2227  bm->is_allowed = htonl (0);
2228  bm->peer = bc->peer;
2229  GNUNET_MQ_send (tc->mq, env);
2230  if (GNUNET_YES == tc->details.blacklist.call_receive_done)
2231  {
2232  tc->details.blacklist.call_receive_done = GNUNET_NO;
2234  }
2235  tc->details.blacklist.waiting_for_reply = GNUNET_YES;
2236 }
2237 
2238 
2245 static void
2247 {
2248  struct TransportClient *tc = cls;
2249  struct GST_BlacklistCheck *bc;
2250 
2251  if (CT_BLACKLIST != tc->type)
2252  {
2253  GNUNET_break (0);
2254  GNUNET_SERVICE_client_drop (tc->client);
2255  return;
2256  }
2258  "Blacklist client %p sent reply for `%s'\n",
2259  tc,
2260  GNUNET_i2s (&msg->peer));
2261  bc = tc->details.blacklist.bc;
2262  tc->details.blacklist.bc = NULL;
2263  tc->details.blacklist.waiting_for_reply = GNUNET_NO;
2264  tc->details.blacklist.call_receive_done = GNUNET_YES;
2265  if (NULL != bc)
2266  {
2267  /* only run this if the blacklist check has not been
2268  * cancelled in the meantime... */
2269  GNUNET_assert (bc->bl_pos == tc);
2270  if (ntohl (msg->is_allowed) == GNUNET_SYSERR)
2271  {
2273  "Blacklist check failed, peer not allowed\n");
2274  /* For the duration of the continuation, make the ongoing
2275  check invisible (to avoid double-cancellation); then
2276  add it back again so we can re-use GST_blacklist_test_cancel() */
2278  bc->cont (bc->cont_cls, &bc->peer, bc->address, bc->session, GNUNET_NO);
2281  tc->details.blacklist.call_receive_done = GNUNET_NO;
2283  return;
2284  }
2285  else
2286  {
2288  "Blacklist check succeeded, continuing with checks\n");
2289  tc->details.blacklist.call_receive_done = GNUNET_NO;
2291  bc->bl_pos = tc->next;
2293  }
2294  }
2295  /* check if any other blacklist checks are waiting for this blacklister */
2296  for (bc = bc_head; bc != NULL; bc = bc->next)
2297  if ((bc->bl_pos == tc) && (NULL == bc->task))
2298  {
2300  break;
2301  }
2302 }
2303 
2304 
2311 void
2313  const char *transport_name)
2314 {
2315  char *transport = NULL;
2316 
2317  if (NULL != transport_name)
2318  {
2320  "Adding peer `%s' with plugin `%s' to blacklist\n",
2321  GNUNET_i2s (peer),
2322  transport_name);
2323  transport = GNUNET_strdup (transport_name);
2324  }
2325  else
2327  "Adding peer `%s' with all plugins to blacklist\n",
2328  GNUNET_i2s (peer));
2329  if (NULL == blacklist)
2330  blacklist =
2332  GNUNET_NO);
2333 
2335  peer,
2336  transport,
2338 }
2339 
2340 
2347 void
2349  struct GNUNET_ATS_Session *session)
2350 {
2351  struct GST_BlacklistCheck *bc;
2352  struct GST_BlacklistCheck *n;
2353 
2354  n = bc_head;
2355  while (NULL != (bc = n))
2356  {
2357  n = bc->next;
2358  if ((bc->session == session) &&
2360  {
2361  bc->cont (bc->cont_cls,
2362  &bc->peer,
2363  bc->address,
2364  bc->session,
2365  GNUNET_SYSERR);
2367  }
2368  }
2369 }
2370 
2371 
2381 static int
2382 test_blacklisted (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
2383 {
2384  const char *transport_name = cls;
2385  char *be = value;
2386 
2387  /* Blacklist entry be:
2388  * (NULL == be): peer is blacklisted with all plugins
2389  * (NULL != be): peer is blacklisted for a specific plugin
2390  *
2391  * If (NULL != transport_name) we look for a transport specific entry:
2392  * if (transport_name == be) forbidden
2393  *
2395  "Comparing BL request for peer `%4s':`%s' with BL entry: `%s'\n",
2396  GNUNET_i2s (key),
2397  (NULL == transport_name) ? "unspecified" : transport_name,
2398  (NULL == be) ? "all plugins" : be);
2399  /* all plugins for this peer were blacklisted: disallow */
2400  if (NULL == value)
2401  return GNUNET_NO;
2402 
2403  /* blacklist check for specific transport */
2404  if ((NULL != transport_name) && (NULL != value))
2405  {
2406  if (0 == strcmp (transport_name, be))
2407  return GNUNET_NO; /* plugin is blacklisted! */
2408  }
2409  return GNUNET_OK;
2410 }
2411 
2412 
2425 struct GST_BlacklistCheck *
2427  const char *transport_name,
2429  void *cont_cls,
2430  const struct GNUNET_HELLO_Address *address,
2431  struct GNUNET_ATS_Session *session)
2432 {
2433  struct GST_BlacklistCheck *bc;
2434  struct TransportClient *tc;
2435 
2436  GNUNET_assert (NULL != peer);
2438  "Blacklist check for peer `%s':%s\n",
2439  GNUNET_i2s (peer),
2440  (NULL != transport_name) ? transport_name : "unspecified");
2441 
2442  /* Check local blacklist by iterating over hashmap
2443  * If iteration is aborted, we found a matching blacklist entry */
2444  if ((NULL != blacklist) &&
2445  (GNUNET_SYSERR ==
2447  peer,
2449  (void *) transport_name)))
2450  {
2451  /* Disallowed by config, disapprove instantly */
2453  gettext_noop ("# disconnects due to blacklist"),
2454  1,
2455  GNUNET_NO);
2457  _ ("Disallowing connection to peer `%s' on transport %s\n"),
2458  GNUNET_i2s (peer),
2459  (NULL != transport_name) ? transport_name : "unspecified");
2460  if (NULL != cont)
2461  cont (cont_cls, peer, address, session, GNUNET_NO);
2462  return NULL;
2463  }
2464 
2465  for (tc = clients_head; NULL != tc; tc = tc->next)
2466  if (CT_BLACKLIST == tc->type)
2467  break;
2468  if (NULL == tc)
2469  {
2470  /* no blacklist clients, approve instantly */
2471  if (NULL != cont)
2472  cont (cont_cls, peer, address, session, GNUNET_OK);
2474  "Allowing connection to peer `%s' %s\n",
2475  GNUNET_i2s (peer),
2476  (NULL != transport_name) ? transport_name : "");
2477  return NULL;
2478  }
2479 
2480  /* need to query blacklist clients */
2481  bc = GNUNET_new (struct GST_BlacklistCheck);
2483  bc->peer = *peer;
2485  bc->session = session;
2486  bc->cont = cont;
2487  bc->cont_cls = cont_cls;
2488  bc->bl_pos = tc;
2490  return bc;
2491 }
2492 
2493 
2499 void
2501 {
2503  if (NULL != bc->bl_pos)
2504  {
2505  if ((CT_BLACKLIST == bc->bl_pos->type) &&
2506  (bc->bl_pos->details.blacklist.bc == bc))
2507  {
2508  /* we're at the head of the queue, remove us! */
2509  bc->bl_pos->details.blacklist.bc = NULL;
2510  }
2511  }
2512  if (NULL != bc->task)
2513  {
2515  bc->task = NULL;
2516  }
2517  GNUNET_free (bc->address);
2518  GNUNET_free (bc);
2519 }
2520 
2521 
2530 static void
2532  const char *section,
2533  const char *option,
2534  const char *value)
2535 {
2536  unsigned int *res = cls;
2537  struct GNUNET_PeerIdentity peer;
2538  char *plugs;
2539  char *pos;
2540 
2541  if (GNUNET_OK !=
2543  strlen (option),
2544  &peer.public_key))
2545  return;
2546 
2547  if ((NULL == value) || (0 == strcmp (value, "")))
2548  {
2549  /* Blacklist whole peer */
2550  GST_blacklist_add_peer (&peer, NULL);
2552  _ ("Adding blacklisting entry for peer `%s'\n"),
2553  GNUNET_i2s (&peer));
2554  }
2555  else
2556  {
2557  plugs = GNUNET_strdup (value);
2558  for (pos = strtok (plugs, " "); pos != NULL; pos = strtok (NULL, " "))
2559  {
2561  _ ("Adding blacklisting entry for peer `%s':`%s'\n"),
2562  GNUNET_i2s (&peer),
2563  pos);
2564  GST_blacklist_add_peer (&peer, pos);
2565  }
2566  GNUNET_free (plugs);
2567  }
2568  (*res)++;
2569 }
2570 
2571 
2578 static void
2580  const struct GNUNET_PeerIdentity *my_id)
2581 {
2582  char cfg_sect[512];
2583  unsigned int res = 0;
2584 
2585  GNUNET_snprintf (cfg_sect,
2586  sizeof(cfg_sect),
2587  "transport-blacklist-%s",
2588  GNUNET_i2s_full (my_id));
2590  cfg_sect,
2592  &res);
2594  "Loaded %u blacklisting entries from configuration\n",
2595  res);
2596 }
2597 
2598 
2606 static void
2607 run (void *cls,
2608  const struct GNUNET_CONFIGURATION_Handle *c,
2610 {
2611  char *keyfile;
2612  long long unsigned int max_fd_cfg;
2613  int max_fd_rlimit;
2614  int max_fd;
2615  int friend_only;
2616 
2617  /* setup globals */
2618  GST_cfg = c;
2620  "PEER",
2621  "PRIVATE_KEY",
2622  &keyfile))
2623  {
2624  GNUNET_log (
2626  _ (
2627  "Transport service is lacking key configuration settings. Exiting.\n"));
2629  return;
2630  }
2632  "transport",
2633  "HELLO_EXPIRATION",
2634  &hello_expiration))
2635  {
2637  }
2638  if (GNUNET_SYSERR ==
2640  GNUNET_YES,
2642  {
2644  "Failed to setup peer's private key\n");
2646  GNUNET_free (keyfile);
2647  return;
2648  }
2649  GNUNET_free (keyfile);
2650  GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg);
2655  "My identity is `%s'\n",
2657 
2659  if (NULL == GST_peerinfo)
2660  {
2662  _ ("Could not access PEERINFO service. Exiting.\n"));
2664  return;
2665  }
2666 
2667  max_fd_rlimit = 0;
2668 #if HAVE_GETRLIMIT
2669  {
2670  struct rlimit r_file;
2671 
2672  if (0 == getrlimit (RLIMIT_NOFILE, &r_file))
2673  {
2674  max_fd_rlimit = r_file.rlim_cur;
2676  "Maximum number of open files was: %u/%u\n",
2677  (unsigned int) r_file.rlim_cur,
2678  (unsigned int) r_file.rlim_max);
2679  }
2680  max_fd_rlimit =
2681  (9 * max_fd_rlimit) / 10; /* Keep 10% for rest of transport */
2682  }
2683 #endif
2685  "transport",
2686  "MAX_FD",
2687  &max_fd_cfg))
2688  max_fd_cfg = max_fd_rlimit;
2689 
2690  if (max_fd_cfg > max_fd_rlimit)
2691  max_fd = max_fd_cfg;
2692  else
2693  max_fd = max_fd_rlimit;
2694  if (max_fd < DEFAULT_MAX_FDS)
2695  max_fd = DEFAULT_MAX_FDS;
2696 
2698  "Limiting number of sockets to %u: validation %u, neighbors: %u\n",
2699  max_fd,
2700  (max_fd / 3),
2701  (max_fd / 3) * 2);
2702 
2703  friend_only =
2704  GNUNET_CONFIGURATION_get_value_yesno (GST_cfg, "topology", "FRIENDS-ONLY");
2705  if (GNUNET_SYSERR == friend_only)
2706  friend_only = GNUNET_NO; /* According to topology defaults */
2707  /* start subsystems */
2708  /* Disable DSTJ peer */
2709  {
2710  struct GNUNET_PeerIdentity dstj;
2711  const char *ds = "DSTJBRRKZ8TBW3FGK6B0M5QXWT9WYNZ45H5MCV4HY7ST64Q8T9F0";
2712 
2713  GNUNET_assert (
2714  GNUNET_OK ==
2716  strlen (ds),
2717  &dstj.public_key));
2718  GST_blacklist_add_peer (&dstj, NULL);
2719  }
2723  GST_ats =
2725  GST_ats_init ();
2731  GST_hello_start (friend_only, &process_hello_update, NULL);
2732  GST_neighbours_start ((max_fd / 3) * 2);
2735  GST_validation_start ((max_fd / 3));
2736 }
2737 
2738 
2743  "transport",
2745  &run,
2748  NULL,
2751  struct StartMessage,
2752  NULL),
2753  GNUNET_MQ_hd_var_size (client_hello,
2755  struct GNUNET_MessageHeader,
2756  NULL),
2759  struct OutboundMessage,
2760  NULL),
2761  GNUNET_MQ_hd_var_size (client_address_to_string,
2763  struct AddressLookupMessage,
2764  NULL),
2765  GNUNET_MQ_hd_fixed_size (client_monitor_peers,
2767  struct PeerMonitorMessage,
2768  NULL),
2769  GNUNET_MQ_hd_fixed_size (client_blacklist_init,
2771  struct GNUNET_MessageHeader,
2772  NULL),
2773  GNUNET_MQ_hd_fixed_size (client_blacklist_reply,
2775  struct BlacklistMessage,
2776  NULL),
2777  GNUNET_MQ_hd_fixed_size (client_set_metric,
2779  struct TrafficMetricMessage,
2780  NULL),
2781  GNUNET_MQ_hd_fixed_size (client_monitor_plugins,
2783  struct GNUNET_MessageHeader,
2784  NULL),
2786 
2787 
2788 /* end of file gnunet-service-transport.c */
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define gettext_noop(String)
Definition: gettext.h:69
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
static int res
static void done()
static struct GNUNET_CONTAINER_MultiPeerMap * addresses
Hashmap to store addresses.
Definition: gnunet-ats.c:146
struct Plugin * plugin
The process handle to the testbed service.
static char * address
GNS address for this phone.
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.
static struct GNUNET_FS_DirScanner * ds
Handle to the directory scanner (for recursive insertions).
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
enum State state
current state of profiling
static int result
Global testing status.
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static struct GNUNET_TRANSPORT_CoreHandle * transport
Transport service.
static char * plugin_name
Name of our plugin.
static char buf[2048]
ClientType
What type of client is the struct TransportClient about?
static void read_blacklist_configuration(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *my_id)
Read blacklist configuration.
struct GNUNET_TIME_Relative GST_receive_callback(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, const struct GNUNET_MessageHeader *message)
Function called by the transport for each received message.
static void handle_client_hello(void *cls, const struct GNUNET_MessageHeader *message)
Client sent us a HELLO.
static void ats_request_address_change(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
Function called by ATS to notify the callee that the assigned bandwidth or address for a given peer w...
void GST_blacklist_test_cancel(struct GST_BlacklistCheck *bc)
Cancel a blacklist check.
static void plugin_session_info_cb(void *cls, struct GNUNET_ATS_Session *session, const struct GNUNET_TRANSPORT_SessionInfo *info)
Function called by the plugin with information about the current sessions managed by the plugin (for ...
static struct GNUNET_ATS_SessionKiller * sk_tail
Tail of DLL of asynchronous tasks to kill sessions.
struct GNUNET_PeerIdentity GST_my_identity
Configuration handle.
static int test_blacklisted(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Test if the given blacklist entry matches.
static void unicast(struct TransportClient *tc, const struct GNUNET_MessageHeader *msg, int may_drop)
Queue the given message for transmission to the given client.
void GST_blacklist_abort_matching(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Abort blacklist if address and session match.
static void plugin_env_session_end(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Function that will be called whenever the plugin internally cleans up a session pointer and hence the...
static void kill_session(const char *plugin_name, struct GNUNET_ATS_Session *session)
Force plugin to terminate session due to communication issue.
static void handle_client_blacklist_reply(void *cls, const struct BlacklistMessage *msg)
A blacklisting client has sent us reply.
struct GNUNET_ATS_ConnectivityHandle * GST_ats_connect
ATS connectivity handle.
static void handle_client_start(void *cls, const struct StartMessage *start)
Initialize a normal client.
struct GST_BlacklistCheck * GST_blacklist_test_allowed(const struct GNUNET_PeerIdentity *peer, const char *transport_name, GST_BlacklistTestContinuation cont, void *cont_cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Test if a peer/transport combination is blacklisted.
static int check_client_address_to_string(void *cls, const struct AddressLookupMessage *alum)
Client asked to resolve an address.
static void plugin_env_address_change_notification(void *cls, int add_remove, const struct GNUNET_HELLO_Address *address)
Function that will be called for each address the transport is aware that it might be reachable under...
static void handle_client_send(void *cls, const struct OutboundMessage *obm)
Client asked for transmission to a peer.
static struct GST_BlacklistCheck * bc_tail
Tail of DLL of active blacklisting queries.
static struct TransportClient * clients_head
Head of linked list of all clients to this service.
static void shutdown_task(void *cls)
Function called when the service shuts down.
struct GNUNET_TIME_Relative hello_expiration
Hello address expiration.
static void process_hello_update(void *cls, const struct GNUNET_MessageHeader *hello)
My HELLO has changed.
void GST_blacklist_add_peer(const struct GNUNET_PeerIdentity *peer, const char *transport_name)
Add the given peer to the blacklist (for the given transport).
static void handle_client_blacklist_init(void *cls, const struct GNUNET_MessageHeader *message)
Initialize a blacklisting client.
static int check_client_hello(void *cls, const struct GNUNET_MessageHeader *message)
Client sent us a HELLO.
static void handle_client_set_metric(void *cls, const struct TrafficMetricMessage *tm)
Set traffic metric to manipulate.
static struct AddressToStringContext * a2s_tail
Tail of linked list of all pending address iterations.
struct GNUNET_ATS_SchedulingHandle * GST_ats
ATS scheduling handle.
static void send_peer_information(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
Output information of neighbours to the given client.
static void handle_client_monitor_peers(void *cls, const struct PeerMonitorMessage *msg)
Client asked to obtain information about a specific or all peers Process the request.
static void notify_client_about_neighbour(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
Function called for each of our connected neighbours.
static int free_blacklist_entry(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Free the given entry in the blacklist.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
Initiate transport service.
struct GNUNET_NT_InterfaceScanner * GST_is
Interface scanner determines our LAN address range(s).
static struct GNUNET_NotificationContext * plugin_nc
Notification context, to send updates on changes to active plugin connections.
static int mark_match_down(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Mark the peer as down so we don't call the continuation context in the future.
static int mark_peer_down(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Mark the peer as down so we don't call the continuation context in the future.
struct GNUNET_CRYPTO_EddsaPrivateKey GST_my_private_key
Our private key.
#define MAX_PENDING
How many messages can we have pending for a given client process before we start to drop incoming mes...
GNUNET_SERVICE_MAIN("transport", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(client_start, GNUNET_MESSAGE_TYPE_TRANSPORT_START, struct StartMessage, NULL), GNUNET_MQ_hd_var_size(client_hello, GNUNET_MESSAGE_TYPE_HELLO, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_var_size(client_send, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, struct OutboundMessage, NULL), GNUNET_MQ_hd_var_size(client_address_to_string, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING, struct AddressLookupMessage, NULL), GNUNET_MQ_hd_fixed_size(client_monitor_peers, GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST, struct PeerMonitorMessage, NULL), GNUNET_MQ_hd_fixed_size(client_blacklist_init, GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_fixed_size(client_blacklist_reply, GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY, struct BlacklistMessage, NULL), GNUNET_MQ_hd_fixed_size(client_set_metric, GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC, struct TrafficMetricMessage, NULL), GNUNET_MQ_hd_fixed_size(client_monitor_plugins, GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_START, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
static void blacklist_cfg_iter(void *cls, const char *section, const char *option, const char *value)
Function to iterate over options in the blacklisting section for a peer.
static struct GNUNET_PeerIdentity all_zeros
Peer identity that is all zeros, used as a way to indicate "all peers".
static void handle_send_transmit_continuation(void *cls, int success, size_t bytes_payload, size_t bytes_on_wire)
Function called after the transmission is done.
const struct GNUNET_CONFIGURATION_Handle * GST_cfg
Configuration handle.
static void plugin_env_session_start_bl_check_cont(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, int result)
Black list check result from blacklist check triggered when a plugin gave us a new session in plugin_...
static struct PeerIterateResponseMessage * compose_address_iterate_response_message(const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address)
Compose PeerIterateResponseMessage using the given peer and address.
static struct GNUNET_CONTAINER_MultiPeerMap * blacklist
Hashmap of blacklisted peers.
static void transmit_our_hello(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
Transmit our HELLO message to the given (connected) neighbour.
static void do_blacklist_check(void *cls)
Perform next action in the blacklist check.
void GST_clients_broadcast(const struct GNUNET_MessageHeader *msg, int may_drop)
Broadcast the given message to all of our clients.
struct GNUNET_PEERINFO_Handle * GST_peerinfo
Handle to peerinfo service.
static int check_client_send(void *cls, const struct OutboundMessage *obm)
Client asked for transmission to a peer.
static struct TransportClient * clients_tail
Tail of linked list of all clients to this service.
struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
static struct AddressToStringContext * a2s_head
Head of linked list of all pending address iterations.
static void kill_session_task(void *cls)
Task to asynchronously terminate a session.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Called whenever a client connects.
static struct TransportClient * sync_client
Plugin monitoring client we are currently syncing, NULL if all monitoring clients are in sync.
#define TRANSPORT_BLACKLIST_HT_SIZE
Size of the blacklist hash map.
static void test_connection_ok(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
Test if an existing connection is still acceptable given a new blacklisting client.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
Called whenever a client is disconnected.
static void handle_client_address_to_string(void *cls, const struct AddressLookupMessage *alum)
Client asked to resolve an address.
void GST_clients_broadcast_disconnect(const struct GNUNET_PeerIdentity *peer)
Notify all clients about a disconnect, and cancel pending SEND_OK messages for this peer.
static void plugin_env_session_start(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, enum GNUNET_NetworkType scope)
Plugin tells transport service about a new inbound session.
void GST_clients_broadcast_peer_notification(const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)
Broadcast the new active address to all clients monitoring the peer.
static void confirm_or_drop_neighbour(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, int allowed)
Got the result about an existing connection from a new blacklister.
static struct GNUNET_CONTAINER_MultiPeerMap * active_stccs
Map of peer identities to active send transmit continuation contexts.
static struct GNUNET_ATS_SessionKiller * sk_head
Head of DLL of asynchronous tasks to kill sessions.
static void transmit_address_to_client(void *cls, const char *buf, int res)
Take the given address and append it to the set of results sent back to the client.
@ CT_CORE_NO_HANDLERS
CORE client without any handlers.
@ CT_BLACKLIST
It is a blacklist, query about allowed connections.
@ CT_MONITOR
It is a monitor, forward monitor data.
@ CT_NONE
We do not know yet (client is fresh).
@ CT_CORE
Is the CORE service, we need to forward traffic to it.
static void handle_client_monitor_plugins(void *cls, const struct GNUNET_MessageHeader *message)
Client asked to obtain information about all plugin connections.
static struct GST_BlacklistCheck * bc_head
Head of DLL of active blacklisting queries.
static struct GNUNET_TIME_Relative process_payload(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, const struct GNUNET_MessageHeader *message)
We received some payload.
static void connect_bl_check_cont(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, int result)
Black list check result for try_connect call If connection to the peer is allowed request address and...
void(* GST_BlacklistTestContinuation)(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, int result)
Continuation called from a blacklist test.
void GST_ats_add_inbound_address(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, const struct GNUNET_ATS_Properties *prop)
Notify ATS about a new inbound address.
void GST_ats_init()
Initialize ATS subsystem.
void GST_ats_del_session(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Notify ATS that the session (but not the address) of a given address is no longer relevant.
void GST_ats_done()
Shutdown ATS subsystem.
interfacing between transport and ATS service
void GST_hello_stop()
Shutdown the HELLO module.
void GST_hello_modify_addresses(int addremove, const struct GNUNET_HELLO_Address *address)
Add or remove an address from this peer's HELLO message.
void GST_hello_start(int friend_only, GST_HelloCallback cb, void *cb_cls)
Initialize the HELLO module.
const struct GNUNET_MessageHeader * GST_hello_get()
Obtain this peers HELLO message.
void GST_manipulation_init()
Initialize traffic manipulation.
void GST_manipulation_stop()
Stop traffic manipulation.
void GST_manipulation_set_metric(const struct TrafficMetricMessage *tm)
Set traffic metric to manipulate.
void GST_manipulation_send(const struct GNUNET_PeerIdentity *target, const void *msg, size_t msg_size, struct GNUNET_TIME_Relative timeout, GST_NeighbourSendContinuation cont, void *cont_cls)
Adapter function between transport's send function and transport plugins.
struct GNUNET_TIME_Relative GST_manipulation_recv(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, const struct GNUNET_MessageHeader *message)
Adapter function between transport plugins and transport receive function manipulation delays for nex...
void GST_neighbours_switch_to_address(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
For the given peer, switch to this address.
void GST_neighbours_notify_data_recv(const struct GNUNET_HELLO_Address *address, const struct GNUNET_MessageHeader *message)
Track information about data we received from the given address (used to notify ATS about our utiliza...
void GST_neighbours_keepalive_response(const struct GNUNET_PeerIdentity *neighbour, const struct GNUNET_MessageHeader *m)
We received a KEEP_ALIVE_RESPONSE message and use this to calculate latency to this peer.
const struct GNUNET_HELLO_Address * GST_neighbour_get_current_address(const struct GNUNET_PeerIdentity *peer)
Obtain current address information for the given neighbour.
void GST_neighbours_handle_disconnect_message(const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *msg)
We received a disconnect message from the given peer, validate and process.
int GST_neighbours_handle_session_syn(const struct GNUNET_MessageHeader *message, const struct GNUNET_PeerIdentity *peer)
We received a 'SYN' message from the other peer.
struct GNUNET_TIME_Relative GST_neighbours_calculate_receive_delay(const struct GNUNET_PeerIdentity *sender, ssize_t size, int *do_forward)
We have received a message from the given sender.
int GST_neighbours_handle_session_ack(const struct GNUNET_MessageHeader *message, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
We received a 'ACK' message from the other peer.
int GST_neighbours_handle_session_syn_ack(const struct GNUNET_MessageHeader *message, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
We received a 'SESSION_SYN_ACK' message from the other peer.
int GST_neighbours_session_terminated(const struct GNUNET_PeerIdentity *peer, struct GNUNET_ATS_Session *session)
A session was terminated.
void GST_neighbours_keepalive(const struct GNUNET_PeerIdentity *neighbour, const struct GNUNET_MessageHeader *m)
Keep the connection to the given neighbour alive longer, we received a KEEPALIVE (or equivalent); sen...
void GST_neighbours_force_disconnect(const struct GNUNET_PeerIdentity *target)
If we have an active connection to the given target, it must be shutdown.
void GST_neighbours_send(const struct GNUNET_PeerIdentity *target, const void *msg, size_t msg_size, struct GNUNET_TIME_Relative timeout, GST_NeighbourSendContinuation cont, void *cont_cls)
Transmit a message to the given target using the active connection.
void GST_neighbours_stop()
Cleanup the neighbours subsystem.
int GST_neighbours_test_connected(const struct GNUNET_PeerIdentity *target)
Test if we're connected to the given peer.
void GST_neighbours_iterate(GST_NeighbourIterator cb, void *cb_cls)
Iterate over all connected neighbours.
void GST_neighbours_start(unsigned int max_fds)
Initialize the neighbours subsystem.
void GST_neighbours_handle_quota_message(const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *msg)
We received a quota message from the given peer, validate and process.
neighbour manipulation API, allows manipulation of performance metrics (delay and towards ATS)
void GST_plugins_unload()
Unload all plugins.
struct GNUNET_TRANSPORT_PluginFunctions * GST_plugins_find(const char *name)
Obtain the plugin API based on a plugin name.
void GST_plugins_load(GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, GNUNET_TRANSPORT_AddressNotification address_cb, GNUNET_TRANSPORT_SessionStart session_start_cb, GNUNET_TRANSPORT_SessionEnd session_end_cb)
Load and initialize all plugins.
struct GNUNET_TRANSPORT_PluginFunctions * GST_plugins_printer_find(const char *name)
Obtain the plugin API based on a the stripped plugin name after the underscore.
void GST_plugins_monitor_subscribe(GNUNET_TRANSPORT_SessionInfoCallback cb, void *cb_cls)
Register callback with all plugins to monitor their status.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
int GST_validation_handle_ping(const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *hdr, const struct GNUNET_HELLO_Address *sender_address, struct GNUNET_ATS_Session *session)
We've received a PING.
int GST_validation_handle_hello(const struct GNUNET_MessageHeader *hello)
We've received a HELLO, check which addresses are new and trigger validation.
void GST_validation_start(unsigned int max_fds)
Start the validation subsystem.
void GST_validation_handle_address(const struct GNUNET_HELLO_Address *address)
Validate an individual address.
void GST_validation_stop()
Stop the validation subsystem.
int GST_validation_handle_pong(const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *hdr)
We've received a PONG.
static int numeric
Option -n.
Automatic transport selection and outbound bandwidth determination.
#define GNUNET_log(kind,...)
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_NO
Definition: gnunet_common.h:94
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a string representing a public key to a public key.
Definition: crypto_ecc.c:357
struct GNUNET_ATS_SchedulingHandle * GNUNET_ATS_scheduling_init(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ATS_AddressSuggestionCallback suggest_cb, void *suggest_cb_cls)
Initialize the ATS subsystem.
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
void GNUNET_ATS_scheduling_done(struct GNUNET_ATS_SchedulingHandle *sh)
Client is done with ATS scheduling, release resources.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
void GNUNET_CONFIGURATION_iterate_section_values(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
Iterate over values of a section in the configuration.
#define GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION
After how long do we expire an address in a HELLO that we just validated? This value is also used for...
#define GNUNET_CONSTANTS_LATENCY_WARN
After what amount of latency for a message do we print a warning?
int GNUNET_CRYPTO_eddsa_key_from_file(const char *filename, int do_create, struct GNUNET_CRYPTO_EddsaPrivateKey *pkey)
Create a new private key by reading it from a file.
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:197
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
int GNUNET_CONTAINER_multipeermap_get_multiple(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:109
int GNUNET_HELLO_address_check_option(const struct GNUNET_HELLO_Address *address, enum GNUNET_HELLO_AddressInfo option)
Check if an address has a local option set.
Definition: address.c:39
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
Definition: address.c:130
@ GNUNET_HELLO_ADDRESS_INFO_INBOUND
This is an inbound address and cannot be used to initiate an outbound connection to another peer.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_notification_context_destroy(struct GNUNET_NotificationContext *nc)
Destroy the context, force disconnect for all subscribers.
Definition: nc.c:137
unsigned int GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq)
Obtain the current length of the message queue.
Definition: mq.c:337
unsigned int GNUNET_notification_context_get_size(struct GNUNET_NotificationContext *nc)
Return active number of subscribers in this context.
Definition: nc.c:215
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:355
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:52
void GNUNET_notification_context_broadcast(struct GNUNET_NotificationContext *nc, const struct GNUNET_MessageHeader *msg, int can_drop)
Send a message to all subscribers of this context.
Definition: nc.c:189
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
Definition: mq.c:666
struct GNUNET_NotificationContext * GNUNET_notification_context_create(unsigned int queue_length)
Create a new notification context.
Definition: nc.c:121
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_notification_context_add(struct GNUNET_NotificationContext *nc, struct GNUNET_MQ_Handle *mq)
Add a subscriber to the notification context.
Definition: nc.c:160
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Definition: gnunet_nt_lib.h:36
void GNUNET_NT_scanner_done(struct GNUNET_NT_InterfaceScanner *is)
Terminate interface scanner.
Definition: nt.c:433
struct GNUNET_NT_InterfaceScanner * GNUNET_NT_scanner_init(void)
Initialize the address characterization client handle.
Definition: nt.c:412
@ GNUNET_NT_UNSPECIFIED
Category of last resort.
Definition: gnunet_nt_lib.h:40
struct GNUNET_PEERINFO_Handle * GNUNET_PEERINFO_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the peerinfo service.
Definition: peerinfo_api.c:130
void GNUNET_PEERINFO_disconnect(struct GNUNET_PEERINFO_Handle *h)
Disconnect from the peerinfo service.
Definition: peerinfo_api.c:156
#define GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
Message from TRANSPORT notifying about a client that connected to us.
#define GNUNET_MESSAGE_TYPE_HELLO_LEGACY
Previously used for HELLO messages used for communicating peer addresses.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA
Message exchanged between transport services to indicate that the sender should limit its transmissio...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_EVENT
Monitoring event about the connection state of plugins, generated in response to a subscription initi...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE
Message send by a peer to notify the other to keep the session alive and measure latency in a regular...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_START
Message from the core saying that the transport server should start giving it messages.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
Message from TRANSPORT notifying about a message that was received.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE
Response to a GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE message to measure latency in a regular...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
Message from TRANSPORT notifying about a client that disconnected from us.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_PONG
Transport PONG message.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY
Response to the address lookup request.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY
Reply from blacklisting client (answer to blacklist query).
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST
Request to monitor addresses used by a peer or all peers.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK
Transport ACK message exchanged between transport services to indicate that a SYN_ACK message was acc...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE
Response to GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST request to iterate over all known addr...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_START
Request to start monitoring the connection state of plugins.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_SYNC
Monitoring event notifying client that the initial iteration is now completed and we are in sync with...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT
Register a client that wants to do blacklisting.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT
Transport DISCONNECT message exchanged between transport services to indicate that a connection shoul...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE_END
Response to GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE_END terminating list of replies.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC
Message containing traffic metrics for transport service.
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_PING
Transport PING message.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING
Request to look addresses of peers in server.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN
Transport SYN message exchanged between transport services to indicate that a session should be marke...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND
Request to TRANSPORT to transmit a message.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
Confirmation from TRANSPORT that message for transmission has been queued (and that the next message ...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK
Transport SYN_ACK message exchanged between transport services to indicate that a SYN message was acc...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY
Query to a blacklisting client (is this peer blacklisted)?
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531
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:1296
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1331
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
void GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c)
Set the 'monitor' flag on this client.
Definition: service.c:2408
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2325
void GNUNET_SERVICE_client_disable_continue_warning(struct GNUNET_SERVICE_Client *c)
Disable the warning the server issues if a message is not acknowledged in a timely fashion.
Definition: service.c:2268
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2244
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:454
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:263
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:86
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:557
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:464
const char * GNUNET_TRANSPORT_ps2s(enum GNUNET_TRANSPORT_PeerState state)
Convert a transport state to a human readable string.
GNUNET_TRANSPORT_PeerState
Possible state of a neighbour.
static unsigned int size
Size of the "table".
Definition: peer.c:67
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
const char * name
int client_start(struct Plugin *plugin)
int client_send(struct GNUNET_ATS_Session *s, struct HTTP_Message *msg)
static enum GNUNET_NetworkType scope
Which network scope do we belong to?
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:423
Message from the library to the transport service asking for converting a transport address to a huma...
Definition: transport.h:349
uint16_t addrlen
Length of the (binary) address in bytes, in big-endian.
Definition: transport.h:364
int16_t numeric_only
Should the conversion use numeric IP addresses (otherwise a reverse DNS lookup is OK – if applicable)...
Definition: transport.h:359
struct GNUNET_TIME_RelativeNBO timeout
timeout to give up (for DNS resolution timeout mostly)
Definition: transport.h:369
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING.
Definition: transport.h:353
Context for address to string operations.
struct AddressToStringContext * prev
This is a doubly-linked list.
struct TransportClient * tc
Client that made the request.
struct AddressToStringContext * next
This is a doubly-linked list.
Message used to notify the transport API about an address to string conversion.
Definition: transport.h:324
uint32_t addr_len
Length of the following string, zero if is GNUNET_SYSERR.
Definition: transport.h:339
uint32_t res
GNUNET_OK if the conversion succeeded, GNUNET_SYSERR if it failed
Definition: transport.h:334
Change in blacklisting (either request or notification, depending on which direction it is going).
Definition: transport.h:586
uint32_t is_allowed
0 for the query, GNUNET_OK (allowed) or GNUNET_SYSERR (disallowed) for the response.
Definition: transport.h:597
struct GNUNET_PeerIdentity peer
Which peer is being blacklisted or queried?
Definition: transport.h:602
Message from the transport service to the library informing about neighbors.
Definition: transport.h:118
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT.
Definition: transport.h:122
struct GNUNET_PeerIdentity id
Identity of the new neighbour.
Definition: transport.h:141
struct GNUNET_BANDWIDTH_Value32NBO quota_out
Current outbound quota for this peer.
Definition: transport.h:135
Message from the transport service to the library informing about disconnects.
Definition: transport.h:150
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT.
Definition: transport.h:154
uint32_t reserved
Reserved, always zero.
Definition: transport.h:159
struct GNUNET_PeerIdentity peer
Who got disconnected?
Definition: transport.h:164
Handle to the ATS subsystem for connectivity management.
ATS performance characteristics for an address.
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change.
Handle to the ATS subsystem for bandwidth/transport scheduling information.
Information we need for an asynchronous session kill.
struct GNUNET_ATS_Session * session
Session to kill.
struct GNUNET_ATS_SessionKiller * prev
Kept in a DLL.
struct GNUNET_TRANSPORT_PluginFunctions * plugin
Plugin for the session.
struct GNUNET_ATS_SessionKiller * next
Kept in a DLL.
struct GNUNET_SCHEDULER_Task * task
The kill task.
Session handle for connections.
32-bit bandwidth used for network exchange by GNUnet, in bytes per second.
uint32_t value__
The actual value (bytes per second).
Internal representation of the hash map.
Private ECC key encoded for transmission.
struct GNUNET_MQ_Handle * mq
Our own message queue for the FS service; only briefly used when we start to index a file,...
Definition: fs_api.h:1220
An address for communicating with a peer.
const char * transport_name
Name of the transport plugin enabling the communication using this address.
size_t address_length
Number of bytes in address.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
const void * address
Binary representation of the address (plugin-specific).
Handle to a message queue.
Definition: mq.c:86
Header for all communications.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
Handle to the interface scanner.
Definition: nt.c:111
The notification context is the key datastructure for a convenience API used for transmission of noti...
Definition: nc.c:76
Handle to the peerinfo service.
Definition: peerinfo_api.c:85
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Entry in list of pending tasks.
Definition: scheduler.c:135
Handle to a client that is connected to a service.
Definition: service.c:251
Handle to a service.
Definition: service.c:117
Handle for the service.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
void * cls
Closure for all of the callbacks.
GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
GNUNET_TRANSPORT_AddressPrettyPrinter address_pretty_printer
Function to pretty-print addresses.
Information about a plugin's session.
struct GNUNET_TIME_Absolute receive_delay
Until when does this plugin refuse to receive to manage staying within the inbound quota?...
const struct GNUNET_HELLO_Address * address
Address used by the session.
int is_inbound
GNUNET_YES if this is an inbound connection, GNUNET_NO if this is an outbound connection,...
struct GNUNET_TIME_Absolute session_timeout
At what time will this session timeout (unless activity happens)?
uint32_t num_bytes_pending
Number of bytes pending transmission for this session.
enum GNUNET_TRANSPORT_SessionState state
New state of the session.
uint32_t num_msg_pending
Number of messages pending transmission for this session.
Context we use when performing a blacklist check.
struct GNUNET_SCHEDULER_Task * task
Current task performing the check.
struct GST_BlacklistCheck * prev
This is a linked list.
GST_BlacklistTestContinuation cont
Continuation to call with the result.
struct GNUNET_ATS_Session * session
Session for GST_blacklist_abort_matching(), can be NULL.
struct GNUNET_PeerIdentity peer
Peer being checked.
struct GNUNET_HELLO_Address * address
Address for GST_blacklist_abort_matching(), can be NULL.
struct TransportClient * bl_pos
Our current position in the blacklisters list.
void * cont_cls
Closure for cont.
struct GST_BlacklistCheck * next
This is a linked list.
Message used to notify the transport API about a message received from the network.
Definition: transport.h:199
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV.
Definition: transport.h:203
struct GNUNET_PeerIdentity peer
Which peer sent the message?
Definition: transport.h:208
Closure for call_iterator().
int all
GNUNET_YES if id should be ignored because we want all peers.
struct GNUNET_PeerIdentity id
Which peers do we care about?
struct TransportClient * tc
Context to use for the transmission.
Message used to notify the transport service about a message to be transmitted to another peer.
Definition: transport.h:285
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND.
Definition: transport.h:289
struct GNUNET_PeerIdentity peer
Which peer should receive the message?
Definition: transport.h:308
struct GNUNET_TIME_RelativeNBO timeout
Allowed delay.
Definition: transport.h:302
Message from the transport service to the library containing information about a peer.
Definition: transport.h:538
struct GNUNET_TIME_AbsoluteNBO state_timeout
Timeout for the state this peer is in.
Definition: transport.h:557
Message from the library to the transport service asking for binary addresses known for a peer.
Definition: transport.h:471
Message used to notify the transport API that it can send another message to the transport service.
Definition: transport.h:217
uint16_t success
GNUNET_OK if the transmission succeeded, GNUNET_SYSERR if it failed (i.e.
Definition: transport.h:234
uint16_t bytes_msg
Size of message sent.
Definition: transport.h:239
uint32_t bytes_physical
Size of message sent over wire.
Definition: transport.h:245
struct GNUNET_PeerIdentity peer
Which peer can send more now?
Definition: transport.h:251
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK.
Definition: transport.h:221
Closure for handle_send_transmit_continuation()
unsigned long long uuid
Unique ID, for logging.
struct GNUNET_PeerIdentity target
Peer that was the target.
int down
Set to GNUNET_YES if the connection for target goes down and we thus must no longer send the GNUNET_M...
struct TransportClient * tc
Client that made the request.
struct GNUNET_TIME_Absolute send_time
At what time did we receive the message?
Message from the transport service to the library asking to check if both processes agree about this ...
Definition: transport.h:92
Closure for test_connection_ok().
struct TransportClient * tc
Handle to the blacklisting client we need to ask.
int first
Is this the first neighbour we're checking?
Message from the library to the transport service asking for binary addresses known for a peer.
Definition: transport.h:494
Client connected to the transport service.
enum ClientType type
What type of client is this?
struct GST_BlacklistCheck * bc
Blacklist check that we're currently performing (or NULL if we're performing one that has been cancel...
struct TransportClient::@68::@69 blacklist
Additional details if type is CT_BLACKLIST.
struct GNUNET_MQ_Handle * mq
Message queue to the client.
int waiting_for_reply
Set to GNUNET_YES if we're currently waiting for a reply.
struct TransportClient * next
Kept in a DLL.
struct GNUNET_SERVICE_Client * client
Handle to the client.
struct TransportClient * prev
Kept in a DLL.
struct GNUNET_PeerIdentity monitor_peer
Peer identity to monitor the addresses of.
union TransportClient::@62 details
int call_receive_done
GNUNET_YES if we have to call receive_done for this client
Transport-level connection status update.
Definition: transport.h:610
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
common internal definitions for transport service
#define DEFAULT_MAX_FDS
What's the maximum number of sockets transport uses for validation and neighbors.
Definition: transport.h:52