GNUnet  0.10.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 {
135 
139  struct TransportClient *next;
140 
144  struct TransportClient *prev;
145 
149  struct GNUNET_SERVICE_Client *client;
150 
154  struct GNUNET_MQ_Handle *mq;
155 
159  enum ClientType type;
160 
161  union
162  {
163 
169  struct GNUNET_PeerIdentity monitor_peer;
170 
174  struct
175  {
176 
182 
187 
192 
193  } blacklist;
194 
195  } details;
196 };
197 
198 
203 {
204 
209 
214 
219 
224 
228  void *cont_cls;
229 
234 
239 
244 
249 };
250 
251 
256 {
261 
266 
271 };
272 
273 
278 {
279 
284 
288  struct GNUNET_PeerIdentity target;
289 
293  struct GNUNET_TIME_Absolute send_time;
294 
298  unsigned long long uuid;
299 
305  int down;
306 };
307 
308 
313 
318 
326 
331 
336 
341 
346 
352 
358 
364 
370 
375 
380 
385 
390 
395 
400 
405 
410 
415 
420 
425 
433 static void
435  const struct GNUNET_MessageHeader *msg,
436  int may_drop)
437 {
438  struct GNUNET_MQ_Envelope *env;
439 
440  if ((GNUNET_MQ_get_length (tc->mq) >= MAX_PENDING) &&
441  (GNUNET_YES == may_drop))
442  {
443  GNUNET_log (
445  "Dropping message of type %u and size %u, have %u/%u messages pending\n",
446  ntohs (msg->type),
447  ntohs (msg->size),
448  GNUNET_MQ_get_length (tc->mq),
449  MAX_PENDING);
450  GNUNET_STATISTICS_update (GST_stats,
451  gettext_noop (
452  "# messages dropped due to slow client"),
453  1,
454  GNUNET_NO);
455  return;
456  }
457  env = GNUNET_MQ_msg_copy (msg);
458  GNUNET_MQ_send (tc->mq, env);
459 }
460 
461 
471 static void *
472 client_connect_cb (void *cls,
473  struct GNUNET_SERVICE_Client *client,
474  struct GNUNET_MQ_Handle *mq)
475 {
476  struct TransportClient *tc;
477 
478  tc = GNUNET_new (struct TransportClient);
479  tc->client = client;
480  tc->mq = mq;
481  GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc);
482  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", tc);
483  return tc;
484 }
485 
486 
492 static void
493 do_blacklist_check (void *cls);
494 
495 
505 static int
506 mark_match_down (void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
507 {
508  struct TransportClient *tc = cls;
509  struct SendTransmitContinuationContext *stcc = value;
510 
511  if (tc == stcc->tc)
512  {
513  stcc->down = GNUNET_YES;
514  stcc->tc = NULL;
515  }
516  return GNUNET_OK;
517 }
518 
519 
528 static void
530  struct GNUNET_SERVICE_Client *client,
531  void *app_ctx)
532 {
533  struct TransportClient *tc = app_ctx;
534  struct GST_BlacklistCheck *bc;
535 
537  "Client %p disconnected, cleaning up.\n",
538  tc);
540  for (struct AddressToStringContext *cur = a2s_head; NULL != cur;
541  cur = cur->next)
542  {
543  if (cur->tc == tc)
544  cur->tc = NULL;
545  }
546  GNUNET_CONTAINER_DLL_remove (clients_head, clients_tail, tc);
547  switch (tc->type)
548  {
549  case CT_NONE:
550  break;
551  case CT_CORE:
552  break;
553  case CT_MONITOR:
554  break;
555  case CT_BLACKLIST:
556  for (bc = bc_head; NULL != bc; bc = bc->next)
557  {
558  if (bc->bl_pos != tc)
559  continue;
560  bc->bl_pos = tc->next;
561  if (NULL == bc->task)
563  }
564  break;
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);
631  return;
632  }
633  if (CT_NONE != tc->type)
634  {
635  GNUNET_break (0);
637  return;
638  }
639  if (0 != (2 & options))
640  tc->type = CT_CORE;
641  else
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  struct GNUNET_TIME_Relative delay;
699  const struct GNUNET_HELLO_Address *addr;
700 
703  if (delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us)
705  "It took us %s to send %u/%u bytes to %s (%d, %s)\n",
707  (unsigned int) bytes_payload,
708  (unsigned int) bytes_on_wire,
709  GNUNET_i2s (&stcc->target),
710  success,
711  (NULL != addr) ? addr->transport_name : "%");
712  else
714  "It took us %s to send %u/%u bytes to %s (%d, %s)\n",
716  (unsigned int) bytes_payload,
717  (unsigned int) bytes_on_wire,
718  GNUNET_i2s (&stcc->target),
719  success,
720  (NULL != addr) ? addr->transport_name : "%");
721 
722  if (GNUNET_NO == stcc->down)
723  {
724  /* Only send confirmation if we are still connected */
726  "Sending SEND_OK for transmission request %llu\n",
727  stcc->uuid);
728  send_ok_msg.header.size = htons (sizeof (send_ok_msg));
729  send_ok_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK);
730  send_ok_msg.bytes_msg = htonl (bytes_payload);
731  send_ok_msg.bytes_physical = htonl (bytes_on_wire);
732  send_ok_msg.success = htonl (success);
733  send_ok_msg.peer = stcc->target;
734  unicast (stcc->tc, &send_ok_msg.header, GNUNET_NO);
735  }
736  GNUNET_assert (
737  GNUNET_OK ==
738  GNUNET_CONTAINER_multipeermap_remove (active_stccs, &stcc->target, stcc));
739  GNUNET_free (stcc);
740 }
741 
742 
749 static int
750 check_client_send (void *cls, const struct OutboundMessage *obm)
751 {
752  uint16_t size;
753  const struct GNUNET_MessageHeader *obmm;
754 
755  size = ntohs (obm->header.size) - sizeof (struct OutboundMessage);
756  if (size < sizeof (struct GNUNET_MessageHeader))
757  {
758  GNUNET_break (0);
759  return GNUNET_SYSERR;
760  }
761  obmm = (const struct GNUNET_MessageHeader *) &obm[1];
762  if (size != ntohs (obmm->size))
763  {
764  GNUNET_break (0);
765  return GNUNET_SYSERR;
766  }
767  return GNUNET_OK;
768 }
769 
770 
777 static void
778 handle_client_send (void *cls, const struct OutboundMessage *obm)
779 {
780  static unsigned long long uuid_gen;
781  struct TransportClient *tc = cls;
782  const struct GNUNET_MessageHeader *obmm;
783  struct SendTransmitContinuationContext *stcc;
784 
785  obmm = (const struct GNUNET_MessageHeader *) &obm[1];
787  {
788  /* not connected, not allowed to send; can happen due to asynchronous operations */
790  "Could not send message to peer `%s': not connected\n",
791  GNUNET_i2s (&obm->peer));
793  GST_stats,
794  gettext_noop ("# bytes payload dropped (other peer was not connected)"),
795  ntohs (obmm->size),
796  GNUNET_NO);
798  return;
799  }
800  GNUNET_log (
802  "Received SEND request %llu for `%s' and first message of type %u and total size %u\n",
803  uuid_gen,
804  GNUNET_i2s (&obm->peer),
805  ntohs (obmm->type),
806  ntohs (obmm->size));
808 
810  stcc->target = obm->peer;
811  stcc->tc = tc;
813  stcc->uuid = uuid_gen++;
815  active_stccs,
816  &stcc->target,
817  stcc,
820  obmm,
821  ntohs (obmm->size),
824  stcc);
825 }
826 
827 
842 static void
843 transmit_address_to_client (void *cls, const char *buf, int res)
844 {
845  struct AddressToStringContext *actx = cls;
846  struct GNUNET_MQ_Envelope *env;
847  struct AddressToStringResultMessage *atsm;
848  size_t slen;
849 
850  GNUNET_assert ((GNUNET_OK == res) || (GNUNET_SYSERR == res));
851  if (NULL == actx->tc)
852  return;
853  if (NULL == buf)
854  {
855  env = GNUNET_MQ_msg (atsm,
857  if (GNUNET_OK == res)
858  {
859  /* this was the last call, transmit */
860  atsm->res = htonl (GNUNET_OK);
861  atsm->addr_len = htonl (0);
862  GNUNET_MQ_send (actx->tc->mq, env);
863  GNUNET_CONTAINER_DLL_remove (a2s_head, a2s_tail, actx);
864  GNUNET_free (actx);
865  return;
866  }
867  if (GNUNET_SYSERR == res)
868  {
869  /* address conversion failed, but there will be more callbacks */
870  atsm->res = htonl (GNUNET_SYSERR);
871  atsm->addr_len = htonl (0);
872  GNUNET_MQ_send (actx->tc->mq, env);
873  return;
874  }
875  }
876  GNUNET_assert (GNUNET_OK == res);
877  /* succesful conversion, append*/
878  slen = strlen (buf) + 1;
879  env =
880  GNUNET_MQ_msg_extra (atsm,
881  slen,
883  atsm->res = htonl (GNUNET_YES);
884  atsm->addr_len = htonl (slen);
885  GNUNET_memcpy (&atsm[1], buf, slen);
886  GNUNET_MQ_send (actx->tc->mq, env);
887 }
888 
889 
897 static int
899  const struct AddressLookupMessage *alum)
900 {
901  const char *plugin_name;
902  const char *address;
903  uint32_t address_len;
904  uint16_t size;
905 
906  size = ntohs (alum->header.size);
907  address_len = ntohs (alum->addrlen);
908  if (size <= sizeof (struct AddressLookupMessage) + address_len)
909  {
910  GNUNET_break (0);
911  return GNUNET_SYSERR;
912  }
913  address = (const char *) &alum[1];
914  plugin_name = (const char *) &address[address_len];
915  if ('\0' != plugin_name[size - sizeof (struct AddressLookupMessage) -
916  address_len - 1])
917  {
918  GNUNET_break (0);
919  return GNUNET_SYSERR;
920  }
921  return GNUNET_OK;
922 }
923 
924 
931 static void
933  const struct AddressLookupMessage *alum)
934 {
935  struct TransportClient *tc = cls;
937  const char *plugin_name;
938  const char *address;
939  uint32_t address_len;
940  struct AddressToStringContext *actx;
941  struct GNUNET_MQ_Envelope *env;
942  struct AddressToStringResultMessage *atsm;
943  struct GNUNET_TIME_Relative rtimeout;
944  int32_t numeric;
945 
946  address_len = ntohs (alum->addrlen);
947  address = (const char *) &alum[1];
948  plugin_name = (const char *) &address[address_len];
949  rtimeout = GNUNET_TIME_relative_ntoh (alum->timeout);
950  numeric = ntohs (alum->numeric_only);
951  papi = GST_plugins_printer_find (plugin_name);
952  if (NULL == papi)
953  {
955  "Failed to find plugin `%s'\n",
956  plugin_name);
957  env = GNUNET_MQ_msg (atsm,
959  atsm->res = htonl (GNUNET_SYSERR);
960  atsm->addr_len = htonl (0);
961  GNUNET_MQ_send (tc->mq, env);
962  env = GNUNET_MQ_msg (atsm,
964  atsm->res = htonl (GNUNET_OK);
965  atsm->addr_len = htonl (0);
966  GNUNET_MQ_send (tc->mq, env);
967  return;
968  }
969  actx = GNUNET_new (struct AddressToStringContext);
970  actx->tc = tc;
971  GNUNET_CONTAINER_DLL_insert (a2s_head, a2s_tail, actx);
974  "Pretty-printing address of %u bytes using plugin `%s'\n",
975  address_len,
976  plugin_name);
977  papi->address_pretty_printer (papi->cls,
978  plugin_name,
979  address,
980  address_len,
981  numeric,
982  rtimeout,
984  actx);
985 }
986 
987 
995 static struct PeerIterateResponseMessage *
997  const struct GNUNET_PeerIdentity *peer,
998  const struct GNUNET_HELLO_Address *address)
999 {
1001  size_t size;
1002  size_t tlen;
1003  size_t alen;
1004  char *addr;
1005 
1006  GNUNET_assert (NULL != peer);
1007  if (NULL != address)
1008  {
1009  tlen = strlen (address->transport_name) + 1;
1010  alen = address->address_length;
1011  }
1012  else
1013  {
1014  tlen = 0;
1015  alen = 0;
1016  }
1017  size = (sizeof (struct PeerIterateResponseMessage) + alen + tlen);
1018  msg = GNUNET_malloc (size);
1019  msg->header.size = htons (size);
1020  msg->header.type =
1022  msg->reserved = htonl (0);
1023  msg->peer = *peer;
1024  msg->addrlen = htonl (alen);
1025  msg->pluginlen = htonl (tlen);
1026 
1027  if (NULL != address)
1028  {
1029  msg->local_address_info = htonl ((uint32_t) address->local_info);
1030  addr = (char *) &msg[1];
1031  GNUNET_memcpy (addr, address->address, alen);
1032  GNUNET_memcpy (&addr[alen], address->transport_name, tlen);
1033  }
1034  return msg;
1035 }
1036 
1037 
1042 struct IterationContext
1043 {
1048 
1053 
1057  int all;
1058 };
1059 
1060 
1072 static void
1074  const struct GNUNET_PeerIdentity *peer,
1075  const struct GNUNET_HELLO_Address *address,
1077  struct GNUNET_TIME_Absolute state_timeout,
1078  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
1079  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
1080 {
1081  struct IterationContext *pc = cls;
1082  struct GNUNET_MQ_Envelope *env;
1084 
1085  if ((GNUNET_YES != pc->all) && (0 != memcmp (peer, &pc->id, sizeof (pc->id))))
1086  return;
1088  "Sending information about `%s' using address `%s' in state `%s'\n",
1089  GNUNET_i2s (peer),
1090  (NULL != address) ? GST_plugins_a2s (address) : "<none>",
1091  GNUNET_TRANSPORT_ps2s (state));
1092  msg = compose_address_iterate_response_message (peer, address);
1093  msg->state = htonl (state);
1094  msg->state_timeout = GNUNET_TIME_absolute_hton (state_timeout);
1095  env = GNUNET_MQ_msg_copy (&msg->header);
1096  GNUNET_free (msg);
1097  GNUNET_MQ_send (pc->tc->mq, env);
1098 }
1099 
1100 
1108 static void
1110 {
1111  struct TransportClient *tc = cls;
1112  struct IterationContext pc;
1113 
1114  if (CT_NONE != tc->type)
1115  {
1116  GNUNET_break (0);
1118  return;
1119  }
1122 
1123  /* Send initial list */
1124  pc.tc = tc;
1125  if (0 == memcmp (&msg->peer, &all_zeros, sizeof (struct GNUNET_PeerIdentity)))
1126  {
1127  /* iterate over all neighbours */
1128  pc.all = GNUNET_YES;
1129  pc.id = msg->peer;
1130  }
1131  else
1132  {
1133  /* just return one neighbour */
1134  pc.all = GNUNET_NO;
1135  pc.id = msg->peer;
1136  }
1138 
1139  if (GNUNET_YES != ntohl (msg->one_shot))
1140  {
1141  tc->details.monitor_peer = msg->peer;
1142  tc->type = CT_MONITOR;
1143  if (0 !=
1144  memcmp (&msg->peer, &all_zeros, sizeof (struct GNUNET_PeerIdentity)))
1146  "Client %p started monitoring of the peer `%s'\n",
1147  tc,
1148  GNUNET_i2s (&msg->peer));
1149  else
1151  "Client %p started monitoring all peers\n",
1152  tc);
1153  }
1154  else
1155  {
1156  struct GNUNET_MessageHeader *msg;
1157  struct GNUNET_MQ_Envelope *env;
1158 
1159  env =
1160  GNUNET_MQ_msg (msg,
1162  GNUNET_MQ_send (tc->mq, env);
1163  }
1164 }
1165 
1166 
1179 static void
1181  struct GNUNET_ATS_Session *session,
1182  const struct GNUNET_TRANSPORT_SessionInfo *info)
1183 {
1184  struct GNUNET_MQ_Envelope *env;
1186  struct GNUNET_MessageHeader *sync;
1187  size_t size;
1188  size_t slen;
1189  uint16_t alen;
1190  char *name;
1191  char *addr;
1192 
1193  if (0 == GNUNET_notification_context_get_size (plugin_nc))
1194  {
1195  GST_plugins_monitor_subscribe (NULL, NULL);
1196  return;
1197  }
1198  if ((NULL == info) && (NULL == session))
1199  {
1200  /* end of initial iteration */
1201  if (NULL != sync_client)
1202  {
1203  env =
1205  GNUNET_MQ_send (sync_client->mq, env);
1206  sync_client = NULL;
1207  }
1208  return;
1209  }
1210  GNUNET_assert (NULL != info);
1212  "Plugin event for peer %s on transport %s\n",
1213  GNUNET_i2s (&info->address->peer),
1214  info->address->transport_name);
1215  slen = strlen (info->address->transport_name) + 1;
1216  alen = info->address->address_length;
1217  size = sizeof (struct TransportPluginMonitorMessage) + slen + alen;
1218  if (size > UINT16_MAX)
1219  {
1220  GNUNET_break (0);
1221  return;
1222  }
1223  msg = GNUNET_malloc (size);
1224  msg->header.size = htons (size);
1226  msg->session_state = htons ((uint16_t) info->state);
1227  msg->is_inbound = htons ((int16_t) info->is_inbound);
1228  msg->msgs_pending = htonl (info->num_msg_pending);
1229  msg->bytes_pending = htonl (info->num_bytes_pending);
1232  msg->peer = info->address->peer;
1233  msg->session_id = (uint64_t) (intptr_t) session;
1234  msg->plugin_name_len = htons (slen);
1235  msg->plugin_address_len = htons (alen);
1236  name = (char *) &msg[1];
1237  GNUNET_memcpy (name, info->address->transport_name, slen);
1238  addr = &name[slen];
1239  GNUNET_memcpy (addr, info->address->address, alen);
1240  if (NULL != sync_client)
1241  {
1242  struct GNUNET_MQ_Envelope *env;
1243 
1244  env = GNUNET_MQ_msg_copy (&msg->header);
1245  GNUNET_MQ_send (sync_client->mq, env);
1246  }
1247  else
1248  {
1250  }
1251  GNUNET_free (msg);
1252 }
1253 
1254 
1261 static void
1263  const struct GNUNET_MessageHeader *message)
1264 {
1265  struct TransportClient *tc = cls;
1266 
1269  GNUNET_notification_context_add (plugin_nc, tc->mq);
1270  GNUNET_assert (NULL == sync_client);
1271  sync_client = tc;
1273 }
1274 
1275 
1282 void
1283 GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, int may_drop)
1284 {
1285  int done;
1286 
1288  "Asked to broadcast message of type %u with %u bytes\n",
1289  (unsigned int) ntohs (msg->type),
1290  (unsigned int) ntohs (msg->size));
1291  done = GNUNET_NO;
1292  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
1293  {
1294  if (CT_NONE == tc->type)
1295  continue; /* client not yet ready */
1296  if ((GNUNET_YES == may_drop) && (CT_CORE != tc->type))
1297  continue; /* skip, this client does not care about payload */
1298  unicast (tc, msg, may_drop);
1299  done = GNUNET_YES;
1300  }
1301  if (GNUNET_NO == done)
1303  "Message of type %u not delivered, is CORE service up?\n",
1304  ntohs (msg->type));
1305 }
1306 
1307 
1316 void
1318  const struct GNUNET_PeerIdentity *peer,
1319  const struct GNUNET_HELLO_Address *address,
1321  struct GNUNET_TIME_Absolute state_timeout)
1322 {
1323  struct GNUNET_MQ_Envelope *env;
1325 
1326  msg = compose_address_iterate_response_message (peer, address);
1327  msg->state = htonl (state);
1328  msg->state_timeout = GNUNET_TIME_absolute_hton (state_timeout);
1329  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
1330  {
1331  if (CT_MONITOR != tc->type)
1332  continue;
1333  if ((0 == memcmp (&tc->details.monitor_peer,
1334  &all_zeros,
1335  sizeof (struct GNUNET_PeerIdentity))) ||
1336  (0 == memcmp (&tc->details.monitor_peer,
1337  peer,
1338  sizeof (struct GNUNET_PeerIdentity))))
1339  {
1340  env = GNUNET_MQ_msg_copy (&msg->header);
1341  GNUNET_MQ_send (tc->mq, env);
1342  }
1343  }
1344  GNUNET_free (msg);
1345 }
1346 
1347 
1357 static int
1358 mark_peer_down (void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
1359 {
1360  struct SendTransmitContinuationContext *stcc = value;
1361 
1362  stcc->down = GNUNET_YES;
1363  return GNUNET_OK;
1364 }
1365 
1366 
1373 void
1375 {
1376  struct DisconnectInfoMessage disconnect_msg;
1377 
1379  peer,
1380  &mark_peer_down,
1381  NULL);
1382  disconnect_msg.header.size = htons (sizeof (struct DisconnectInfoMessage));
1383  disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
1384  disconnect_msg.reserved = htonl (0);
1385  disconnect_msg.peer = *peer;
1386  GST_clients_broadcast (&disconnect_msg.header, GNUNET_NO);
1387 }
1388 
1389 
1401 static void
1403  const struct GNUNET_PeerIdentity *peer,
1404  const struct GNUNET_HELLO_Address *address,
1406  struct GNUNET_TIME_Absolute state_timeout,
1407  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
1408  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
1409 {
1410  const struct GNUNET_MessageHeader *hello = cls;
1411 
1412  if (0 == memcmp (peer, &GST_my_identity, sizeof (struct GNUNET_PeerIdentity)))
1413  return; /* not to ourselves */
1415  return;
1416 
1417  GST_neighbours_send (peer,
1418  hello,
1419  ntohs (hello->size),
1421  NULL,
1422  NULL);
1423 }
1424 
1425 
1432 static void
1433 process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello)
1434 {
1435  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Broadcasting HELLO to clients\n");
1437  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Broadcasting HELLO to neighbours\n");
1438  GST_neighbours_iterate (&transmit_our_hello, (void *) hello);
1439 }
1440 
1441 
1452 static struct GNUNET_TIME_Relative
1454  struct GNUNET_ATS_Session *session,
1455  const struct GNUNET_MessageHeader *message)
1456 {
1457  struct GNUNET_TIME_Relative ret;
1458  int do_forward;
1459  struct InboundMessage *im;
1460  size_t msg_size = ntohs (message->size);
1461  size_t size = sizeof (struct InboundMessage) + msg_size;
1462  char buf[size] GNUNET_ALIGN;
1463 
1464  do_forward = GNUNET_SYSERR;
1465  ret = GST_neighbours_calculate_receive_delay (&address->peer,
1466  msg_size,
1467  &do_forward);
1468  if (! GST_neighbours_test_connected (&address->peer))
1469  {
1471  "Discarded %u bytes type %u payload from peer `%s'\n",
1472  (unsigned int) msg_size,
1473  ntohs (message->type),
1474  GNUNET_i2s (&address->peer));
1476  GST_stats,
1477  gettext_noop ("# bytes payload discarded due to not connected peer"),
1478  msg_size,
1479  GNUNET_NO);
1480  return ret;
1481  }
1482 
1483  if (GNUNET_YES != do_forward)
1484  return ret;
1485  im = (struct InboundMessage *) buf;
1486  im->header.size = htons (size);
1488  im->peer = address->peer;
1489  GNUNET_memcpy (&im[1], message, ntohs (message->size));
1491  return ret;
1492 }
1493 
1494 
1500 static void
1502 {
1503  struct GNUNET_ATS_SessionKiller *sk = cls;
1504 
1505  sk->task = NULL;
1506  GNUNET_CONTAINER_DLL_remove (sk_head, sk_tail, sk);
1507  sk->plugin->disconnect_session (sk->plugin->cls, sk->session);
1508  GNUNET_free (sk);
1509 }
1510 
1511 
1519 static void
1520 kill_session (const char *plugin_name, struct GNUNET_ATS_Session *session)
1521 {
1523  struct GNUNET_ATS_SessionKiller *sk;
1524 
1525  for (sk = sk_head; NULL != sk; sk = sk->next)
1526  if (sk->session == session)
1527  return;
1528  plugin = GST_plugins_find (plugin_name);
1529  if (NULL == plugin)
1530  {
1531  GNUNET_break (0);
1532  return;
1533  }
1534  /* need to issue disconnect asynchronously */
1535  sk = GNUNET_new (struct GNUNET_ATS_SessionKiller);
1536  sk->session = session;
1537  sk->plugin = plugin;
1539  GNUNET_CONTAINER_DLL_insert (sk_head, sk_tail, sk);
1540 }
1541 
1542 
1553 static void
1555  const struct GNUNET_PeerIdentity *peer,
1556  const struct GNUNET_HELLO_Address *address,
1557  struct GNUNET_ATS_Session *session,
1558  int result)
1559 {
1560  struct GNUNET_MessageHeader *msg = cls;
1561 
1562  if (GNUNET_OK == result)
1563  {
1564  /* Blacklist allows to speak to this peer, forward SYN to neighbours */
1566  "Received SYN message from peer `%s' at `%s'\n",
1567  GNUNET_i2s (peer),
1568  GST_plugins_a2s (address));
1569  if (GNUNET_OK != GST_neighbours_handle_session_syn (msg, peer))
1570  {
1571  GST_blacklist_abort_matching (address, session);
1572  kill_session (address->transport_name, session);
1573  }
1574  GNUNET_free (msg);
1575  return;
1576  }
1577  GNUNET_free (msg);
1578  if (GNUNET_SYSERR == result)
1579  return; /* check was aborted, session destroyed */
1580  /* Blacklist denies to speak to this peer */
1582  "Discarding SYN message from `%s' due to denied blacklist check\n",
1583  GNUNET_i2s (peer));
1584  kill_session (address->transport_name, session);
1585 }
1586 
1587 
1601 struct GNUNET_TIME_Relative
1603  const struct GNUNET_HELLO_Address *address,
1604  struct GNUNET_ATS_Session *session,
1605  const struct GNUNET_MessageHeader *message)
1606 {
1607  const char *plugin_name = cls;
1608  struct GNUNET_TIME_Relative ret;
1609  uint16_t type;
1610 
1611  ret = GNUNET_TIME_UNIT_ZERO;
1612  if (NULL == message)
1613  goto end;
1614  type = ntohs (message->type);
1616  "Received message with type %u from peer `%s' at %s\n",
1617  type,
1618  GNUNET_i2s (&address->peer),
1619  GST_plugins_a2s (address));
1620 
1621  GNUNET_STATISTICS_update (GST_stats,
1622  gettext_noop ("# bytes total received"),
1623  ntohs (message->size),
1624  GNUNET_NO);
1625  GST_neighbours_notify_data_recv (address, message);
1626  switch (type)
1627  {
1629  /* Legacy HELLO message, discard */
1630  return ret;
1632  if (GNUNET_OK != GST_validation_handle_hello (message))
1633  {
1634  GNUNET_break_op (0);
1635  GST_blacklist_abort_matching (address, session);
1636  }
1637  return ret;
1640  "Processing PING from `%s'\n",
1641  GST_plugins_a2s (address));
1642  if (GNUNET_OK !=
1643  GST_validation_handle_ping (&address->peer, message, address, session))
1644  {
1645  GST_blacklist_abort_matching (address, session);
1646  kill_session (plugin_name, session);
1647  }
1648  break;
1651  "Processing PONG from `%s'\n",
1652  GST_plugins_a2s (address));
1653  if (GNUNET_OK != GST_validation_handle_pong (&address->peer, message))
1654  {
1655  GNUNET_break_op (0);
1656  GST_blacklist_abort_matching (address, session);
1657  kill_session (plugin_name, session);
1658  }
1659  break;
1661  /* Do blacklist check if communication with this peer is allowed */
1662  (void) GST_blacklist_test_allowed (&address->peer,
1663  NULL,
1665  GNUNET_copy_message (message),
1666  address,
1667  session);
1668  break;
1670  if (GNUNET_OK !=
1671  GST_neighbours_handle_session_syn_ack (message, address, session))
1672  {
1673  GST_blacklist_abort_matching (address, session);
1674  kill_session (plugin_name, session);
1675  }
1676  break;
1678  if (GNUNET_OK !=
1679  GST_neighbours_handle_session_ack (message, address, session))
1680  {
1681  GNUNET_break_op (0);
1682  GST_blacklist_abort_matching (address, session);
1683  kill_session (plugin_name, session);
1684  }
1685  break;
1687  GST_neighbours_handle_disconnect_message (&address->peer, message);
1688  break;
1690  GST_neighbours_handle_quota_message (&address->peer, message);
1691  break;
1693  GST_neighbours_keepalive (&address->peer, message);
1694  break;
1696  GST_neighbours_keepalive_response (&address->peer, message);
1697  break;
1698  default:
1699  /* should be payload */
1700  GNUNET_STATISTICS_update (GST_stats,
1701  gettext_noop ("# bytes payload received"),
1702  ntohs (message->size),
1703  GNUNET_NO);
1704  ret = process_payload (address, session, message);
1705  break;
1706  }
1707 end:
1709  "Allowing receive from peer %s to continue in %s\n",
1710  GNUNET_i2s (&address->peer),
1712  return ret;
1713 }
1714 
1715 
1725 static void
1727  void *cls,
1728  int add_remove,
1729  const struct GNUNET_HELLO_Address *address)
1730 {
1731  static int addresses = 0;
1732 
1733  if (GNUNET_YES == add_remove)
1734  {
1735  addresses++;
1736  GNUNET_STATISTICS_update (GST_stats, "# transport addresses", 1, GNUNET_NO);
1737  }
1738  else if (GNUNET_NO == add_remove)
1739  {
1740  if (0 == addresses)
1741  {
1742  GNUNET_break (0);
1743  }
1744  else
1745  {
1746  addresses--;
1747  GNUNET_STATISTICS_update (GST_stats,
1748  "# transport addresses",
1749  -1,
1750  GNUNET_NO);
1751  }
1752  }
1754  "Transport now has %u addresses to communicate\n",
1755  addresses);
1756  GST_hello_modify_addresses (add_remove, address);
1757 }
1758 
1759 
1773 static void
1775  const struct GNUNET_HELLO_Address *address,
1776  struct GNUNET_ATS_Session *session)
1777 {
1778  struct GNUNET_ATS_SessionKiller *sk;
1779 
1780  if (NULL == address)
1781  {
1782  GNUNET_break (0);
1783  return;
1784  }
1785  if (NULL == session)
1786  {
1787  GNUNET_break (0);
1788  return;
1789  }
1790  GNUNET_assert (strlen (address->transport_name) > 0);
1791 
1792  GNUNET_log (
1794  "Notification from plugin about terminated session %p from peer `%s' address `%s'\n",
1795  session,
1796  GNUNET_i2s (&address->peer),
1797  GST_plugins_a2s (address));
1798 
1799  GST_neighbours_session_terminated (&address->peer, session);
1800  GST_ats_del_session (address, session);
1801  GST_blacklist_abort_matching (address, session);
1802 
1803  for (sk = sk_head; NULL != sk; sk = sk->next)
1804  {
1805  if (sk->session == session)
1806  {
1807  GNUNET_CONTAINER_DLL_remove (sk_head, sk_tail, sk);
1809  GNUNET_free (sk);
1810  break;
1811  }
1812  }
1813 }
1814 
1815 
1827 static void
1829  void *cls,
1830  const struct GNUNET_PeerIdentity *peer,
1831  const struct GNUNET_HELLO_Address *address,
1832  struct GNUNET_ATS_Session *session,
1833  int result)
1834 {
1835  if (GNUNET_OK != result)
1836  {
1837  kill_session (address->transport_name, session);
1838  return;
1839  }
1840  if (GNUNET_YES !=
1843  {
1845  "Informing verifier about inbound session's address `%s'\n",
1846  GST_plugins_a2s (address));
1848  }
1849 }
1850 
1851 
1860 static void
1862  const struct GNUNET_HELLO_Address *address,
1863  struct GNUNET_ATS_Session *session,
1865 {
1866  struct GNUNET_ATS_Properties prop;
1867 
1868  if (NULL == address)
1869  {
1870  GNUNET_break (0);
1871  return;
1872  }
1873  if (NULL == session)
1874  {
1875  GNUNET_break (0);
1876  return;
1877  }
1878  GNUNET_log (
1880  "Notification from plugin `%s' about new session from peer `%s' address `%s'\n",
1881  address->transport_name,
1882  GNUNET_i2s (&address->peer),
1883  GST_plugins_a2s (address));
1884  if (GNUNET_YES ==
1887  {
1888  /* inbound is always new, but outbound MAY already be known, but
1889  for example for UNIX, we have symmetric connections and thus we
1890  may not know the address yet; add if necessary! */
1891  /* FIXME: maybe change API here so we just pass scope? */
1892  memset (&prop, 0, sizeof (prop));
1894  prop.scope = scope;
1895  GST_ats_add_inbound_address (address, session, &prop);
1896  }
1897  /* Do blacklist check if communication with this peer is allowed */
1898  (void) GST_blacklist_test_allowed (&address->peer,
1899  address->transport_name,
1901  NULL,
1902  address,
1903  session);
1904 }
1905 
1906 
1925 static void
1927  const struct GNUNET_PeerIdentity *peer,
1928  const struct GNUNET_HELLO_Address *address,
1929  struct GNUNET_ATS_Session *session,
1930  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
1931  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
1932 {
1933  uint32_t bw_in = ntohl (bandwidth_in.value__);
1934  uint32_t bw_out = ntohl (bandwidth_out.value__);
1935 
1936  if (NULL == peer)
1937  {
1938  /* ATS service died, all suggestions become invalid!
1939  (but we'll keep using the allocations for a little
1940  while, to keep going while ATS restarts) */
1941  /* FIXME: We should drop all
1942  connections now, as ATS won't explicitly tell
1943  us and be unaware of ongoing resource allocations! */
1944  return;
1945  }
1946  /* ATS tells me to disconnect from peer */
1947  if ((0 == bw_in) && (0 == bw_out))
1948  {
1950  "ATS tells me to disconnect from peer `%s'\n",
1951  GNUNET_i2s (peer));
1953  return;
1954  }
1955  GNUNET_assert (NULL != address);
1956  GNUNET_STATISTICS_update (GST_stats,
1957  "# ATS suggestions received",
1958  1,
1959  GNUNET_NO);
1961  session,
1962  bandwidth_in,
1963  bandwidth_out);
1964 }
1965 
1966 
1971 {
1975  int first;
1976 
1981 };
1982 
1983 
1995 static void
1997  const struct GNUNET_PeerIdentity *peer,
1998  const struct GNUNET_HELLO_Address *address,
1999  struct GNUNET_ATS_Session *session,
2000  int allowed)
2001 {
2002  if (GNUNET_OK == allowed)
2003  return; /* we're done */
2004  GNUNET_STATISTICS_update (GST_stats,
2005  gettext_noop ("# disconnects due to blacklist"),
2006  1,
2007  GNUNET_NO);
2009 }
2010 
2011 
2024 static void
2026  const struct GNUNET_PeerIdentity *peer,
2027  const struct GNUNET_HELLO_Address *address,
2029  struct GNUNET_TIME_Absolute state_timeout,
2030  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
2031  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
2032 {
2033  struct TestConnectionContext *tcc = cls;
2034  struct GST_BlacklistCheck *bc;
2035 
2036  bc = GNUNET_new (struct GST_BlacklistCheck);
2037  GNUNET_CONTAINER_DLL_insert (bc_head, bc_tail, bc);
2038  bc->peer = *peer;
2039  bc->address = GNUNET_HELLO_address_copy (address);
2041  bc->cont_cls = NULL;
2042  bc->bl_pos = tcc->tc;
2043  if (GNUNET_YES == tcc->first)
2044  {
2045  /* all would wait for the same client, no need to
2046  * create more than just the first task right now */
2048  tcc->first = GNUNET_NO;
2049  }
2050 }
2051 
2052 
2061 static void
2063  const struct GNUNET_MessageHeader *message)
2064 {
2065  struct TransportClient *tc = cls;
2066  struct TestConnectionContext tcc;
2067 
2068  if (CT_NONE != tc->type)
2069  {
2070  GNUNET_break (0);
2072  return;
2073  }
2075  tc->type = CT_BLACKLIST;
2076  tc->details.blacklist.call_receive_done = GNUNET_YES;
2077  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New blacklist client %p\n", tc);
2078  /* confirm that all existing connections are OK! */
2079  tcc.tc = tc;
2080  tcc.first = GNUNET_YES;
2082 }
2083 
2084 
2093 static int
2095  const struct GNUNET_PeerIdentity *key,
2096  void *value)
2097 {
2098  char *be = value;
2099 
2100  GNUNET_free_non_null (be);
2101  return GNUNET_OK;
2102 }
2103 
2104 
2111 static void
2112 handle_client_set_metric (void *cls, const struct TrafficMetricMessage *tm)
2113 {
2114  struct TransportClient *tc = cls;
2115 
2118 }
2119 
2120 
2127 static void
2128 shutdown_task (void *cls)
2129 {
2130  struct AddressToStringContext *cur;
2131 
2133  GST_plugins_unload ();
2135  GST_ats_done ();
2136  GNUNET_ATS_scheduling_done (GST_ats);
2137  GST_ats = NULL;
2138  GNUNET_ATS_connectivity_done (GST_ats_connect);
2139  GST_ats_connect = NULL;
2140  GNUNET_NT_scanner_done (GST_is);
2141  GST_is = NULL;
2142  while (NULL != (cur = a2s_head))
2143  {
2144  GNUNET_CONTAINER_DLL_remove (a2s_head, a2s_tail, cur);
2145  GNUNET_free (cur);
2146  }
2147  if (NULL != plugin_nc)
2148  {
2150  plugin_nc = NULL;
2151  }
2153  active_stccs = NULL;
2154  if (NULL != blacklist)
2155  {
2158  NULL);
2160  blacklist = NULL;
2161  }
2162  GST_hello_stop ();
2164 
2165  if (NULL != GST_peerinfo)
2166  {
2167  GNUNET_PEERINFO_disconnect (GST_peerinfo);
2168  GST_peerinfo = NULL;
2169  }
2170  if (NULL != GST_stats)
2171  {
2172  GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO);
2173  GST_stats = NULL;
2174  }
2175  if (NULL != GST_my_private_key)
2176  {
2177  GNUNET_free (GST_my_private_key);
2178  GST_my_private_key = NULL;
2179  }
2180 }
2181 
2182 
2188 static void
2190 {
2191  struct GST_BlacklistCheck *bc = cls;
2192  struct TransportClient *tc;
2193  struct GNUNET_MQ_Envelope *env;
2194  struct BlacklistMessage *bm;
2195 
2196  bc->task = NULL;
2197  while (NULL != (tc = bc->bl_pos))
2198  {
2199  if (CT_BLACKLIST == tc->type)
2200  break;
2201  bc->bl_pos = tc->next;
2202  }
2203  if (NULL == tc)
2204  {
2206  "No other blacklist clients active, will allow neighbour `%s'\n",
2207  GNUNET_i2s (&bc->peer));
2208 
2209  bc->cont (bc->cont_cls, &bc->peer, bc->address, bc->session, GNUNET_OK);
2211  return;
2212  }
2213  if ((NULL != tc->details.blacklist.bc) ||
2214  (GNUNET_NO != tc->details.blacklist.waiting_for_reply))
2215  return; /* someone else busy with this client */
2216  tc->details.blacklist.bc = bc;
2218  bm->is_allowed = htonl (0);
2219  bm->peer = bc->peer;
2220  GNUNET_MQ_send (tc->mq, env);
2221  if (GNUNET_YES == tc->details.blacklist.call_receive_done)
2222  {
2223  tc->details.blacklist.call_receive_done = GNUNET_NO;
2225  }
2226  tc->details.blacklist.waiting_for_reply = GNUNET_YES;
2227 }
2228 
2229 
2236 static void
2238 {
2239  struct TransportClient *tc = cls;
2240  struct GST_BlacklistCheck *bc;
2241 
2242  if (CT_BLACKLIST != tc->type)
2243  {
2244  GNUNET_break (0);
2246  return;
2247  }
2249  "Blacklist client %p sent reply for `%s'\n",
2250  tc,
2251  GNUNET_i2s (&msg->peer));
2252  bc = tc->details.blacklist.bc;
2253  tc->details.blacklist.bc = NULL;
2254  tc->details.blacklist.waiting_for_reply = GNUNET_NO;
2255  tc->details.blacklist.call_receive_done = GNUNET_YES;
2256  if (NULL != bc)
2257  {
2258  /* only run this if the blacklist check has not been
2259  * cancelled in the meantime... */
2260  GNUNET_assert (bc->bl_pos == tc);
2261  if (ntohl (msg->is_allowed) == GNUNET_SYSERR)
2262  {
2264  "Blacklist check failed, peer not allowed\n");
2265  /* For the duration of the continuation, make the ongoing
2266  check invisible (to avoid double-cancellation); then
2267  add it back again so we can re-use GST_blacklist_test_cancel() */
2268  GNUNET_CONTAINER_DLL_remove (bc_head, bc_tail, bc);
2269  bc->cont (bc->cont_cls, &bc->peer, bc->address, bc->session, GNUNET_NO);
2270  GNUNET_CONTAINER_DLL_insert (bc_head, bc_tail, bc);
2272  tc->details.blacklist.call_receive_done = GNUNET_NO;
2274  return;
2275  }
2276  else
2277  {
2279  "Blacklist check succeeded, continuing with checks\n");
2280  tc->details.blacklist.call_receive_done = GNUNET_NO;
2282  bc->bl_pos = tc->next;
2284  }
2285  }
2286  /* check if any other blacklist checks are waiting for this blacklister */
2287  for (bc = bc_head; bc != NULL; bc = bc->next)
2288  if ((bc->bl_pos == tc) && (NULL == bc->task))
2289  {
2291  break;
2292  }
2293 }
2294 
2295 
2302 void
2304  const char *transport_name)
2305 {
2306  char *transport = NULL;
2307 
2308  if (NULL != transport_name)
2309  {
2311  "Adding peer `%s' with plugin `%s' to blacklist\n",
2312  GNUNET_i2s (peer),
2313  transport_name);
2314  transport = GNUNET_strdup (transport_name);
2315  }
2316  else
2318  "Adding peer `%s' with all plugins to blacklist\n",
2319  GNUNET_i2s (peer));
2320  if (NULL == blacklist)
2321  blacklist =
2323  GNUNET_NO);
2324 
2326  peer,
2327  transport,
2329 }
2330 
2331 
2338 void
2340  struct GNUNET_ATS_Session *session)
2341 {
2342  struct GST_BlacklistCheck *bc;
2343  struct GST_BlacklistCheck *n;
2344 
2345  n = bc_head;
2346  while (NULL != (bc = n))
2347  {
2348  n = bc->next;
2349  if ((bc->session == session) &&
2350  (0 == GNUNET_HELLO_address_cmp (bc->address, address)))
2351  {
2352  bc->cont (bc->cont_cls,
2353  &bc->peer,
2354  bc->address,
2355  bc->session,
2356  GNUNET_SYSERR);
2358  }
2359  }
2360 }
2361 
2362 
2372 static int
2373 test_blacklisted (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
2374 {
2375  const char *transport_name = cls;
2376  char *be = value;
2377 
2378  /* Blacklist entry be:
2379  * (NULL == be): peer is blacklisted with all plugins
2380  * (NULL != be): peer is blacklisted for a specific plugin
2381  *
2382  * If (NULL != transport_name) we look for a transport specific entry:
2383  * if (transport_name == be) forbidden
2384  *
2385  */
2386 
2388  "Comparing BL request for peer `%4s':`%s' with BL entry: `%s'\n",
2389  GNUNET_i2s (key),
2390  (NULL == transport_name) ? "unspecified" : transport_name,
2391  (NULL == be) ? "all plugins" : be);
2392  /* all plugins for this peer were blacklisted: disallow */
2393  if (NULL == value)
2394  return GNUNET_NO;
2395 
2396  /* blacklist check for specific transport */
2397  if ((NULL != transport_name) && (NULL != value))
2398  {
2399  if (0 == strcmp (transport_name, be))
2400  return GNUNET_NO; /* plugin is blacklisted! */
2401  }
2402  return GNUNET_OK;
2403 }
2404 
2405 
2418 struct GST_BlacklistCheck *
2420  const char *transport_name,
2422  void *cont_cls,
2423  const struct GNUNET_HELLO_Address *address,
2424  struct GNUNET_ATS_Session *session)
2425 {
2426  struct GST_BlacklistCheck *bc;
2427  struct TransportClient *tc;
2428 
2429  GNUNET_assert (NULL != peer);
2431  "Blacklist check for peer `%s':%s\n",
2432  GNUNET_i2s (peer),
2433  (NULL != transport_name) ? transport_name : "unspecified");
2434 
2435  /* Check local blacklist by iterating over hashmap
2436  * If iteration is aborted, we found a matching blacklist entry */
2437  if ((NULL != blacklist) &&
2438  (GNUNET_SYSERR ==
2440  peer,
2442  (void *) transport_name)))
2443  {
2444  /* Disallowed by config, disapprove instantly */
2445  GNUNET_STATISTICS_update (GST_stats,
2446  gettext_noop ("# disconnects due to blacklist"),
2447  1,
2448  GNUNET_NO);
2450  _ ("Disallowing connection to peer `%s' on transport %s\n"),
2451  GNUNET_i2s (peer),
2452  (NULL != transport_name) ? transport_name : "unspecified");
2453  if (NULL != cont)
2454  cont (cont_cls, peer, address, session, GNUNET_NO);
2455  return NULL;
2456  }
2457 
2458  for (tc = clients_head; NULL != tc; tc = tc->next)
2459  if (CT_BLACKLIST == tc->type)
2460  break;
2461  if (NULL == tc)
2462  {
2463  /* no blacklist clients, approve instantly */
2464  if (NULL != cont)
2465  cont (cont_cls, peer, address, session, GNUNET_OK);
2467  "Allowing connection to peer `%s' %s\n",
2468  GNUNET_i2s (peer),
2469  (NULL != transport_name) ? transport_name : "");
2470  return NULL;
2471  }
2472 
2473  /* need to query blacklist clients */
2474  bc = GNUNET_new (struct GST_BlacklistCheck);
2475  GNUNET_CONTAINER_DLL_insert (bc_head, bc_tail, bc);
2476  bc->peer = *peer;
2477  bc->address = GNUNET_HELLO_address_copy (address);
2478  bc->session = session;
2479  bc->cont = cont;
2480  bc->cont_cls = cont_cls;
2481  bc->bl_pos = tc;
2483  return bc;
2484 }
2485 
2486 
2492 void
2494 {
2495  GNUNET_CONTAINER_DLL_remove (bc_head, bc_tail, bc);
2496  if (NULL != bc->bl_pos)
2497  {
2498  if ((CT_BLACKLIST == bc->bl_pos->type) &&
2499  (bc->bl_pos->details.blacklist.bc == bc))
2500  {
2501  /* we're at the head of the queue, remove us! */
2502  bc->bl_pos->details.blacklist.bc = NULL;
2503  }
2504  }
2505  if (NULL != bc->task)
2506  {
2508  bc->task = NULL;
2509  }
2511  GNUNET_free (bc);
2512 }
2513 
2514 
2523 static void
2525  const char *section,
2526  const char *option,
2527  const char *value)
2528 {
2529  unsigned int *res = cls;
2530  struct GNUNET_PeerIdentity peer;
2531  char *plugs;
2532  char *pos;
2533 
2534  if (GNUNET_OK !=
2536  strlen (option),
2537  &peer.public_key))
2538  return;
2539 
2540  if ((NULL == value) || (0 == strcmp (value, "")))
2541  {
2542  /* Blacklist whole peer */
2543  GST_blacklist_add_peer (&peer, NULL);
2545  _ ("Adding blacklisting entry for peer `%s'\n"),
2546  GNUNET_i2s (&peer));
2547  }
2548  else
2549  {
2550  plugs = GNUNET_strdup (value);
2551  for (pos = strtok (plugs, " "); pos != NULL; pos = strtok (NULL, " "))
2552  {
2554  _ ("Adding blacklisting entry for peer `%s':`%s'\n"),
2555  GNUNET_i2s (&peer),
2556  pos);
2557  GST_blacklist_add_peer (&peer, pos);
2558  }
2559  GNUNET_free (plugs);
2560  }
2561  (*res)++;
2562 }
2563 
2564 
2571 static void
2573  const struct GNUNET_PeerIdentity *my_id)
2574 {
2575  char cfg_sect[512];
2576  unsigned int res = 0;
2577 
2578  GNUNET_snprintf (cfg_sect,
2579  sizeof (cfg_sect),
2580  "transport-blacklist-%s",
2581  GNUNET_i2s_full (my_id));
2583  cfg_sect,
2585  &res);
2587  "Loaded %u blacklisting entries from configuration\n",
2588  res);
2589 }
2590 
2591 
2599 static void
2600 run (void *cls,
2601  const struct GNUNET_CONFIGURATION_Handle *c,
2603 {
2604  char *keyfile;
2606  long long unsigned int max_fd_cfg;
2607  int max_fd_rlimit;
2608  int max_fd;
2609  int friend_only;
2610 
2611  /* setup globals */
2612  GST_cfg = c;
2614  "PEER",
2615  "PRIVATE_KEY",
2616  &keyfile))
2617  {
2618  GNUNET_log (
2620  _ (
2621  "Transport service is lacking key configuration settings. Exiting.\n"));
2623  return;
2624  }
2626  "transport",
2627  "HELLO_EXPIRATION",
2628  &hello_expiration))
2629  {
2631  }
2633  GNUNET_free (keyfile);
2634  GNUNET_assert (NULL != pk);
2635  GST_my_private_key = pk;
2636 
2637  GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg);
2638  GST_peerinfo = GNUNET_PEERINFO_connect (GST_cfg);
2639  GNUNET_CRYPTO_eddsa_key_get_public (GST_my_private_key,
2641  GNUNET_assert (NULL != GST_my_private_key);
2642 
2644  "My identity is `%s'\n",
2646 
2648  if (NULL == GST_peerinfo)
2649  {
2651  _ ("Could not access PEERINFO service. Exiting.\n"));
2653  return;
2654  }
2655 
2656  max_fd_rlimit = 0;
2657 #if HAVE_GETRLIMIT
2658  {
2659  struct rlimit r_file;
2660 
2661  if (0 == getrlimit (RLIMIT_NOFILE, &r_file))
2662  {
2663  max_fd_rlimit = r_file.rlim_cur;
2665  "Maximum number of open files was: %u/%u\n",
2666  (unsigned int) r_file.rlim_cur,
2667  (unsigned int) r_file.rlim_max);
2668  }
2669  max_fd_rlimit =
2670  (9 * max_fd_rlimit) / 10; /* Keep 10% for rest of transport */
2671  }
2672 #endif
2674  "transport",
2675  "MAX_FD",
2676  &max_fd_cfg))
2677  max_fd_cfg = max_fd_rlimit;
2678 
2679  if (max_fd_cfg > max_fd_rlimit)
2680  max_fd = max_fd_cfg;
2681  else
2682  max_fd = max_fd_rlimit;
2683  if (max_fd < DEFAULT_MAX_FDS)
2684  max_fd = DEFAULT_MAX_FDS;
2685 
2687  "Limiting number of sockets to %u: validation %u, neighbors: %u\n",
2688  max_fd,
2689  (max_fd / 3),
2690  (max_fd / 3) * 2);
2691 
2692  friend_only =
2693  GNUNET_CONFIGURATION_get_value_yesno (GST_cfg, "topology", "FRIENDS-ONLY");
2694  if (GNUNET_SYSERR == friend_only)
2695  friend_only = GNUNET_NO; /* According to topology defaults */
2696  /* start subsystems */
2697  /* Disable DSTJ peer */
2698  {
2699  struct GNUNET_PeerIdentity dstj;
2700  const char *ds = "DSTJBRRKZ8TBW3FGK6B0M5QXWT9WYNZ45H5MCV4HY7ST64Q8T9F0";
2701 
2702  GNUNET_assert (
2703  GNUNET_OK ==
2705  strlen (ds),
2706  &dstj.public_key));
2707  GST_blacklist_add_peer (&dstj, NULL);
2708  }
2710  GST_is = GNUNET_NT_scanner_init ();
2711  GST_ats_connect = GNUNET_ATS_connectivity_init (GST_cfg);
2712  GST_ats =
2714  GST_ats_init ();
2720  GST_hello_start (friend_only, &process_hello_update, NULL);
2721  GST_neighbours_start ((max_fd / 3) * 2);
2722  active_stccs = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_YES);
2723  plugin_nc = GNUNET_notification_context_create (0);
2724  GST_validation_start ((max_fd / 3));
2725 }
2726 
2727 
2732  "transport",
2734  &run,
2737  NULL,
2740  struct StartMessage,
2741  NULL),
2742  GNUNET_MQ_hd_var_size (client_hello,
2744  struct GNUNET_MessageHeader,
2745  NULL),
2748  struct OutboundMessage,
2749  NULL),
2750  GNUNET_MQ_hd_var_size (client_address_to_string,
2752  struct AddressLookupMessage,
2753  NULL),
2754  GNUNET_MQ_hd_fixed_size (client_monitor_peers,
2756  struct PeerMonitorMessage,
2757  NULL),
2758  GNUNET_MQ_hd_fixed_size (client_blacklist_init,
2760  struct GNUNET_MessageHeader,
2761  NULL),
2762  GNUNET_MQ_hd_fixed_size (client_blacklist_reply,
2764  struct BlacklistMessage,
2765  NULL),
2766  GNUNET_MQ_hd_fixed_size (client_set_metric,
2768  struct TrafficMetricMessage,
2769  NULL),
2770  GNUNET_MQ_hd_fixed_size (client_monitor_plugins,
2772  struct GNUNET_MessageHeader,
2773  NULL),
2775 
2776 
2777 /* end of file gnunet-service-transport.c */
struct GNUNET_CRYPTO_EddsaPrivateKey * GST_my_private_key
Our private key.
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 ...
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK.
Definition: transport.h:229
struct GNUNET_HELLO_Address * address
Address for GST_blacklist_abort_matching(), can be NULL.
size_t address_length
Number of bytes in address.
Handle to the interface scanner.
Definition: nt.c:103
struct GNUNET_PeerIdentity id
Identity of the new neighbour.
Definition: transport.h:145
Closure for call_iterator().
enum GNUNET_HELLO_AddressInfo local_info
Extended information about address.
static void done()
Message used to notify the transport API about an address to string conversion.
Definition: transport.h:336
uint32_t num_bytes_pending
Number of bytes pending transmission for this session.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static struct GNUNET_CONTAINER_MultiPeerMap * active_stccs
Map of peer identities to active send transmit continuation contexts.
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
Definition: mq.c:653
void GST_neighbours_iterate(GST_NeighbourIterator cb, void *cb_cls)
Iterate over all connected neighbours.
Handle to the peerinfo service.
Definition: peerinfo_api.c:86
The notification context is the key datastructure for a convenience API used for transmission of noti...
Definition: nc.c:77
struct GNUNET_PeerIdentity monitor_peer
Peer identity to monitor the addresses of.
static struct GNUNET_CRYPTO_EddsaPrivateKey * pk
Private key of this peer.
struct TransportClient::@81::@82 blacklist
Additional details if type is CT_BLACKLIST.
int 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.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
It is a monitor, forward monitor data.
void GST_clients_broadcast(const struct GNUNET_MessageHeader *msg, int may_drop)
Broadcast the given message to all of our clients.
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.
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
struct TransportClient * tc
Handle to the blacklisting client we need to ask.
GNUNET_TRANSPORT_PeerState
Possible state of a neighbour.
uint64_t rel_value_us
The actual value.
Context we use when performing a blacklist check.
void GST_validation_start(unsigned int max_fds)
Start the validation subsystem.
static struct GNUNET_ATS_SessionKiller * sk_head
Head of DLL of asynchronous tasks to kill sessions.
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND.
Definition: transport.h:302
struct GNUNET_TIME_Absolute send_time
At what time did we receive the message?
const void * address
Binary representation of the address (plugin-specific).
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_EVENT
Monitoring event about the connection state of plugins, generated in response to a subscription initi...
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_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_PING
Transport PING message.
void GST_plugins_monitor_subscribe(GNUNET_TRANSPORT_SessionInfoCallback cb, void *cb_cls)
Register callback with all plugins to monitor their status.
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.
common internal definitions for transport service
struct GNUNET_PeerIdentity peer
Which peer is being blacklisted or queried?
Definition: transport.h:618
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.
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...
uint32_t addr_len
Length of the following string, zero if is GNUNET_SYSERR.
Definition: transport.h:353
void GST_ats_done()
Shutdown ATS subsystem.
struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
Handle to the ATS subsystem for bandwidth/transport scheduling information.
Handle to a service.
Definition: service.c:116
struct GNUNET_PEERINFO_Handle * GNUNET_PEERINFO_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the peerinfo service.
Definition: peerinfo_api.c:133
static void handle_client_blacklist_init(void *cls, const struct GNUNET_MessageHeader *message)
Initialize a blacklisting client.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...)
Like snprintf, just aborts if the buffer is of insufficient size.
struct GNUNET_PeerIdentity GST_my_identity
Configuration handle.
uint32_t local_address_info
Local info about the address.
Definition: transport.h:577
int GST_neighbours_handle_session_syn(const struct GNUNET_MessageHeader *message, const struct GNUNET_PeerIdentity *peer)
We received a &#39;SYN&#39; message from the other peer.
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 * plugin
Plugin for the session.
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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1293
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.
int16_t is_inbound
GNUNET_YES if this is an inbound connection, GNUNET_NO if this is an outbound connection, GNUNET_SYSERR if connections of this plugin are so fundamentally bidirectional that they have no &#39;initiator&#39; Value given in NBO.
Definition: transport.h:646
void GST_blacklist_abort_matching(const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Abort blacklist if address and session match.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT.
Definition: transport.h:124
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
int client_send(struct GNUNET_ATS_Session *s, struct HTTP_Message *msg)
uint32_t is_allowed
0 for the query, GNUNET_OK (allowed) or GNUNET_SYSERR (disallowed) for the response.
Definition: transport.h:613
static void handle_client_set_metric(void *cls, const struct TrafficMetricMessage *tm)
Set traffic metric to manipulate.
void GST_manipulation_stop()
Stop traffic manipulation.
int is_inbound
GNUNET_YES if this is an inbound connection, GNUNET_NO if this is an outbound connection, GNUNET_SYSERR if connections of this plugin are so fundamentally bidirectional that they have no &#39;initiator&#39;
int GST_neighbours_test_connected(const struct GNUNET_PeerIdentity *target)
Test if we&#39;re connected to the given peer.
struct GNUNET_PeerIdentity peer
Which peer should receive the message?
Definition: transport.h:321
struct GNUNET_PeerIdentity peer
Which peer is this connection for?
Definition: transport.h:671
enum GNUNET_TRANSPORT_SessionState state
New state of the session.
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&#39;ve received a PING.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA
Message exchanged between transport services to indicate that the sender should limit its transmissio...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_BANDWIDTH_Value32NBO quota_out
Current outbound quota for this peer.
Definition: transport.h:139
void GST_hello_start(int friend_only, GST_HelloCallback cb, void *cb_cls)
Initialize the HELLO module.
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 int free_blacklist_entry(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Free the given entry in the blacklist.
struct GNUNET_PeerIdentity target
Peer that was the target.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:417
GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
struct GNUNET_TIME_AbsoluteNBO state_timeout
Timeout for the state this peer is in.
Definition: transport.h:572
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.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
int GST_neighbours_session_terminated(const struct GNUNET_PeerIdentity *peer, struct GNUNET_ATS_Session *session)
A session was terminated.
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 struct GNUNET_TRANSPORT_CoreHandle * transport
Transport service.
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.
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 handle_send_transmit_continuation(void *cls, int success, size_t bytes_payload, size_t bytes_on_wire)
Function called after the transmission is done.
static int mark_match_down(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Mark the peer as down so we don&#39;t call the continuation context in the future.
void GNUNET_ATS_scheduling_done(struct GNUNET_ATS_SchedulingHandle *sh)
Client is done with ATS scheduling, release resources.
int client_start(struct Plugin *plugin)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
Message from the transport service to the library containing information about a peer.
Definition: transport.h:552
#define GNUNET_CONSTANTS_LATENCY_WARN
After what amount of latency for a message do we print a warning?
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.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
We do not know yet (client is fresh).
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.
interfacing between transport and ATS service
static int check_client_hello(void *cls, const struct GNUNET_MessageHeader *message)
Client sent us a HELLO.
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.
#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_NO
Definition: gnunet_common.h:81
static int numeric
Option -n.
static struct GNUNET_CONTAINER_MultiPeerMap * addresses
Hashmap to store addresses.
Definition: gnunet-ats.c:146
#define GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC
Message containing traffic metrics for transport service.
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_ATS_SessionKiller * next
Kept in a DLL.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
int GST_validation_handle_hello(const struct GNUNET_MessageHeader *hello)
We&#39;ve received a HELLO, check which addresses are new and trigger validation.
static void kill_session_task(void *cls)
Task to asynchronously terminate a session.
static void handle_client_monitor_plugins(void *cls, const struct GNUNET_MessageHeader *message)
Client asked to obtain information about all plugin connections.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
Closure for test_connection_ok().
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct TransportClient * clients_tail
Tail of linked list of all clients to this service.
struct GNUNET_PeerIdentity self
Identity we think we have.
Definition: transport.h:110
void GST_validation_stop()
Stop the validation subsystem.
struct GNUNET_PeerIdentity id
Which peers do we care about?
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.
static void do_blacklist_check(void *cls)
Perform next action in the blacklist check.
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...
struct GNUNET_SERVICE_Client * client
Handle to the client.
static struct TransportClient * clients_head
Head of linked list of all clients to this service.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
struct GNUNET_ATS_SchedulingHandle * GST_ats
ATS scheduling handle.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Called whenever a client connects.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
const struct GNUNET_HELLO_Address * address
Address used by the session.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
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).
static int ret
Final status code.
Definition: gnunet-arm.c:89
Handle for the service.
uint32_t addrlen
Address length.
Definition: transport.h:587
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
void GNUNET_notification_context_add(struct GNUNET_NotificationContext *nc, struct GNUNET_MQ_Handle *mq)
Add a subscriber to the notification context.
Definition: nc.c:164
ATS performance characteristics for an address.
struct GST_BlacklistCheck * next
This is a linked list.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Definition: gnunet_nt_lib.h:35
uint32_t num_msg_pending
Number of messages pending transmission for this session.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct TransportClient * sync_client
Plugin monitoring client we are currently syncing, NULL if all monitoring clients are in sync...
enum ClientType type
What type of client is this?
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE
Response to a GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE message to measure latency in a regular...
It is a blacklist, query about allowed connections.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND
Request to TRANSPORT to transmit a message.
struct GNUNET_TIME_Absolute receive_delay
Until when does this plugin refuse to receive to manage staying within the inbound quota...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
Message from TRANSPORT notifying about a client that connected to us.
uint32_t value__
The actual value (bytes per second).
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static char * section
Name of the section.
Definition: gnunet-config.c:33
#define MAX_PENDING
How many messages can we have pending for a given client process before we start to drop incoming mes...
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...
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 &#39;SESSION_SYN_ACK&#39; message from the other peer.
Handle to a client that is connected to a service.
Definition: service.c:249
static void read_blacklist_configuration(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *my_id)
Read blacklist configuration.
struct GNUNET_ATS_Session * session
Session for GST_blacklist_abort_matching(), can be NULL.
void GST_neighbours_start(unsigned int max_fds)
Initialize the neighbours subsystem.
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 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
static struct GST_BlacklistCheck * bc_head
Head of DLL of active blacklisting queries.
uint32_t state
State this peer is in as an enum GNUNET_TRANSPORT_PeerState
Definition: transport.h:582
#define GNUNET_MESSAGE_TYPE_HELLO_LEGACY
Previously used for HELLO messages used for communicating peer addresses.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE_END
Response to GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE_END terminating list of replies...
struct GNUNET_NT_InterfaceScanner * GST_is
Interface scanner determines our LAN address range(s).
Information about a plugin&#39;s session.
struct TransportClient * tc
Client that made the request.
Change in blacklisting (either request or notification, depending on which direction it is going)...
Definition: transport.h:600
uint16_t success
GNUNET_OK if the transmission succeeded, GNUNET_SYSERR if it failed (i.e.
Definition: transport.h:244
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...
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
Definition: address.c:130
#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
struct AddressToStringContext * next
This is a doubly-linked list.
uint32_t res
GNUNET_OK if the conversion succeeded, GNUNET_SYSERR if it failed
Definition: transport.h:348
int GST_validation_handle_pong(const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *hdr)
We&#39;ve received a PONG.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
struct TransportClient * tc
Client that made the request.
void GST_manipulation_set_metric(const struct TrafficMetricMessage *tm)
Set traffic metric to manipulate.
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 first
Is this the first neighbour we&#39;re checking?
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...
enum State state
current state of profiling
uint32_t reserved
Reserved, always zero.
Definition: transport.h:164
void * cls
Closure for all of the callbacks.
void GST_neighbours_stop()
Cleanup the neighbours subsystem.
#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_memcpy(dst, src, n)
const struct GNUNET_HELLO_Address * GST_neighbour_get_current_address(const struct GNUNET_PeerIdentity *peer)
Obtain current address information for the given neighbour.
static char * value
Value of the record to add/remove.
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 &#39;ACK&#39; message from the other peer.
static int mark_peer_down(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Mark the peer as down so we don&#39;t call the continuation context in the future.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY
Reply from blacklisting client (answer to blacklist query).
void GST_manipulation_init()
Initialize traffic manipulation.
static void kill_session(const char *plugin_name, struct GNUNET_ATS_Session *session)
Force plugin to terminate session due to communication issue.
Information about ongoing sessions of the transport client.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
struct GNUNET_ATS_Session * session
Session to kill.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
This is an inbound address and cannot be used to initiate an outbound connection to another peer...
unsigned int GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq)
Obtain the current length of the message queue.
Definition: mq.c:335
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE
Response to GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST request to iterate over all known addr...
static void handle_client_hello(void *cls, const struct GNUNET_MessageHeader *message)
Client sent us a HELLO.
struct GST_BlacklistCheck * bc
Blacklist check that we&#39;re currently performing (or NULL if we&#39;re performing one that has been cancel...
unsigned int GNUNET_notification_context_get_size(struct GNUNET_NotificationContext *nc)
Return active number of subscribers in this context.
Definition: nc.c:218
static void handle_client_blacklist_reply(void *cls, const struct BlacklistMessage *msg)
A blacklisting client has sent us reply.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
neighbour manipulation API, allows manipulation of performance metrics (delay and towards ATS) ...
static enum GNUNET_NetworkType scope
Which network scope do we belong to?
Message from the library to the transport service asking for binary addresses known for a peer...
Definition: transport.h:485
struct GNUNET_PeerIdentity peer
The identity of the peer to look up.
Definition: transport.h:500
uint16_t plugin_name_len
Length of the plugin name in bytes, including 0-termination.
Definition: transport.h:681
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
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.
uint32_t bytes_physical
Size of message sent over wire.
Definition: transport.h:255
uint32_t options
0: no options 1: The self field should be checked 2: this client is interested in payload traffic ...
Definition: transport.h:104
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY
Response to the address lookup request.
static char * option
Name of the option.
Definition: gnunet-config.c:38
static char buf[2048]
uint16_t plugin_address_len
Length of the plugin address in bytes.
Definition: transport.h:686
const char * transport_name
Name of the transport plugin enabling the communication using this address.
Message from the transport service to the library informing about neighbors.
Definition: transport.h:118
static int result
Global testing status.
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_...
uint32_t msgs_pending
Number of messages waiting transmission.
Definition: transport.h:651
struct GNUNET_TIME_RelativeNBO timeout
Allowed delay.
Definition: transport.h:315
struct GNUNET_TIME_Relative hello_expiration
Hello address expiration.
Message from the library to the transport service asking for binary addresses known for a peer...
Definition: transport.h:508
int down
Set to GNUNET_YES if the connection for target goes down and we thus must no longer send the GNUNET_M...
void GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c)
Set the &#39;monitor&#39; flag on this client.
Definition: service.c:2704
#define GNUNET_MESSAGE_TYPE_TRANSPORT_START
Message from the core saying that the transport server should start giving it messages.
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_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_clients_broadcast_disconnect(const struct GNUNET_PeerIdentity *peer)
Notify all clients about a disconnect, and cancel pending SEND_OK messages for this peer...
struct GNUNET_TIME_Absolute session_timeout
At what time will this session timeout (unless activity happens)?
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
static char * plugin_name
Solver plugin name as string.
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...
Internal representation of the hash map.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:638
int16_t numeric_only
Should the conversion use numeric IP addresses (otherwise a reverse DNS lookup is OK – if applicable...
Definition: transport.h:374
struct GNUNET_TRANSPORT_PluginFunctions * GST_plugins_find(const char *name)
Obtain the plugin API based on a plugin name.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST
Request to monitor addresses used by a peer or all peers.
int all
GNUNET_YES if id should be ignored because we want all peers.
static struct AddressToStringContext * a2s_tail
Tail of linked list of all pending address iterations.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2618
#define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_START
Request to start monitoring the connection state of plugins.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
Message from TRANSPORT notifying about a client that disconnected from us.
static int res
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
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&#39;s send function and transport plugins.
struct GNUNET_TIME_AbsoluteNBO timeout
When will this transport plugin session time out?
Definition: transport.h:661
void GNUNET_NT_scanner_done(struct GNUNET_NT_InterfaceScanner *is)
Terminate interface scanner.
Definition: nt.c:413
unsigned long long uuid
Unique ID, for logging.
const struct GNUNET_CONFIGURATION_Handle * GST_cfg
Configuration handle.
#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_SESSION_KEEPALIVE
Message send by a peer to notify the other to keep the session alive and measure latency in a regular...
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING
Request to look addresses of peers in server.
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).
Message used to notify the transport service about a message to be transmitted to another peer...
Definition: transport.h:296
static void handle_client_send(void *cls, const struct OutboundMessage *obm)
Client asked for transmission to a peer.
Message from the transport service to the library asking to check if both processes agree about this ...
Definition: transport.h:91
CORE client without any handlers.
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT.
Definition: transport.h:159
const char * GNUNET_TRANSPORT_ps2s(enum GNUNET_TRANSPORT_PeerState state)
Convert a transport state to a human readable string.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_PeerIdentity peer
Which peer sent the message?
Definition: transport.h:215
struct GNUNET_MQ_Handle * mq
Message queue to the client.
Transport-level connection status update.
Definition: transport.h:625
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.
int call_receive_done
GNUNET_YES if we have to call receive_done for this client
static struct GNUNET_ATS_SessionKiller * sk_tail
Tail of DLL of asynchronous tasks to kill sessions.
Message from the transport service to the library informing about disconnects.
Definition: transport.h:153
const char * name
struct GNUNET_TIME_RelativeNBO timeout
timeout to give up (for DNS resolution timeout mostly)
Definition: transport.h:384
struct GNUNET_NT_InterfaceScanner * GNUNET_NT_scanner_init(void)
Initialize the address characterization client handle.
Definition: nt.c:393
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
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_test_cancel(struct GST_BlacklistCheck *bc)
Cancel a blacklist check.
static void handle_client_start(void *cls, const struct StartMessage *start)
Initialize a normal client.
uint32_t bytes_pending
Number of bytes waiting for transmission.
Definition: transport.h:656
uint16_t bytes_msg
Size of message sent.
Definition: transport.h:249
GST_BlacklistTestContinuation cont
Continuation to call with the result.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
static void shutdown_task(void *cls)
Function called when the service shuts down.
32-bit bandwidth used for network exchange by GNUnet, in bytes per second.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
Confirmation from TRANSPORT that message for transmission has been queued (and that the next message ...
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
Called whenever a client is disconnected.
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.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT
Transport DISCONNECT message exchanged between transport services to indicate that a connection shoul...
static struct GNUNET_CONTAINER_MultiPeerMap * blacklist
Hashmap of blacklisted peers.
static int check_client_address_to_string(void *cls, const struct AddressLookupMessage *alum)
Client asked to resolve an address.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
struct GNUNET_ATS_ConnectivityHandle * GST_ats_connect
ATS connectivity handle.
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:272
#define GNUNET_MESSAGE_TYPE_TRANSPORT_PONG
Transport PONG message.
struct GNUNET_NotificationContext * GNUNET_notification_context_create(unsigned int queue_length)
Create a new notification context.
Definition: nc.c:125
Message from the library to the transport service asking for converting a transport address to a huma...
Definition: transport.h:362
static int test_blacklisted(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Test if the given blacklist entry matches.
struct TransportClient * next
Kept in a DLL.
void GST_neighbours_force_disconnect(const struct GNUNET_PeerIdentity *target)
If we have an active connection to the given target, it must be shutdown.
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
Allow multiple values with the same key.
struct AddressToStringContext * prev
This is a doubly-linked list.
Handle to a message queue.
Definition: mq.c:85
static struct GNUNET_PeerIdentity all_zeros
Peer identity that is all zeros, used as a way to indicate "all peers".
Information we need for an asynchronous session kill.
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.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN
Transport SYN message exchanged between transport services to indicate that a session should be marke...
uint32_t reserved
For alignment.
Definition: transport.h:562
struct GST_BlacklistCheck * prev
This is a linked list.
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
Private ECC key encoded for transmission.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
int 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:501
static struct AddressToStringContext * a2s_head
Head of linked list of all pending address iterations.
uint64_t session_id
Unique identifier for the session.
Definition: transport.h:676
const struct GNUNET_MessageHeader * GST_hello_get()
Obtain this peers HELLO message.
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:192
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
The identity of the host (wraps the signing key of the peer).
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.
Message used to notify the transport API that it can send another message to the transport service...
Definition: transport.h:223
struct GNUNET_PeerIdentity peer
Which peer can send more now?
Definition: transport.h:262
struct TransportClient * bl_pos
Our current position in the blacklisters list.
struct GNUNET_SCHEDULER_Task * task
The kill task.
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to &#39;struct&#39;s...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT
Register a client that wants to do blacklisting.
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 adddress an...
uint16_t session_state
An enum GNUNET_TRANSPORT_SessionState in NBO.
Definition: transport.h:636
configuration data
Definition: configuration.c:85
struct GNUNET_TIME_AbsoluteNBO delay
Until how long is this plugin currently blocked from reading?
Definition: transport.h:666
struct GNUNET_PEERINFO_Handle * GST_peerinfo
Handle to peerinfo service.
union TransportClient::@75 details
void GST_plugins_unload()
Unload all plugins.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
Message from TRANSPORT notifying about a message that was received.
uint32_t one_shot
One shot call or continous replies?
Definition: transport.h:495
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:373
struct GNUNET_SCHEDULER_Task * task
Current task performing the check.
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING.
Definition: transport.h:368
struct GNUNET_PeerIdentity peer
Who got disconnected?
Definition: transport.h:169
Closure for handle_send_transmit_continuation()
An address for communicating with a peer.
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.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:109
Automatic transport selection and outbound bandwidth determination.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
Client connected to the transport service.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
#define DEFAULT_MAX_FDS
What&#39;s the maximum number of sockets transport uses for validation and neighbors. ...
Definition: transport.h:52
static struct GNUNET_NotificationContext * plugin_nc
Notification context, to send updates on changes to active plugin connections.
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_CRYPTO_eddsa_key_create_from_file(const char *filename)
Create a new private key by reading it from a file.
int 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.
void GNUNET_PEERINFO_disconnect(struct GNUNET_PEERINFO_Handle *h)
Disconnect from the peerinfo service.
Definition: peerinfo_api.c:159
struct GNUNET_PeerIdentity peer
Peer identity.
Definition: transport.h:567
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_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.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE.
Definition: transport.h:557
#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_BLACKLIST_QUERY
Query to a blacklisting client (is this peer blacklisted)?
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.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
GNUNET_TRANSPORT_AddressPrettyPrinter address_pretty_printer
Function to pretty-print addresses.
Header for all communications.
#define TRANSPORT_BLACKLIST_HT_SIZE
Size of the blacklist hash map.
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:80
static struct GNUNET_FS_DirScanner * ds
Handle to the directory scanner (for recursive insertions).
void GNUNET_notification_context_destroy(struct GNUNET_NotificationContext *nc)
Destroy the context, force disconnect for all subscribers.
Definition: nc.c:141
uint16_t addrlen
Length of the (binary) address in bytes, in big-endian.
Definition: transport.h:379
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
struct TransportClient * tc
Context to use for the transmission.
int waiting_for_reply
Set to GNUNET_YES if we&#39;re currently waiting for a reply.
uint32_t pluginlen
Length of the plugin name.
Definition: transport.h:592
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
Initiate transport service.
struct GNUNET_PeerIdentity peer
Peer being checked.
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV.
Definition: transport.h:210
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
static void handle_client_address_to_string(void *cls, const struct AddressLookupMessage *alum)
Client asked to resolve an address.
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:2559
struct GNUNET_ATS_SessionKiller * prev
Kept in a DLL.
int 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".
ClientType
What type of client is this client?
void GST_hello_modify_addresses(int addremove, const struct GNUNET_HELLO_Address *address)
Add or remove an address from this peer&#39;s HELLO message.
Handle to the ATS subsystem for connectivity management.
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
void * cont_cls
Closure for cont.
Is the CORE service, we need to forward traffic to it.
Context for address to string operations.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:654
static char * address
GNS address for this phone.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
void GST_validation_handle_address(const struct GNUNET_HELLO_Address *address)
Validate an individual address.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
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.
void GST_hello_stop()
Shutdown the HELLO module.
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.
#define GNUNET_malloc(size)
Wrapper around malloc.
static void process_hello_update(void *cls, const struct GNUNET_MessageHeader *hello)
My HELLO has changed.
static int check_client_send(void *cls, const struct OutboundMessage *obm)
Client asked for transmission to a peer.
Message used to notify the transport API about a message received from the network.
Definition: transport.h:204
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_CRYPTO_EddsaPublicKey public_key
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
#define gettext_noop(String)
Definition: gettext.h:69
Category of last resort.
Definition: gnunet_nt_lib.h:40
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_EVENT.
Definition: transport.h:631
void GST_ats_init()
Initialize ATS subsystem.
static struct GST_BlacklistCheck * bc_tail
Tail of DLL of active blacklisting queries.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965