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 
69 
74 
79 
84 
89 };
90 
91 
95 enum ClientType {
99  CT_NONE = 0,
100 
104  CT_CORE = 1,
105 
110 
115 
120 };
121 
122 
126 struct GST_BlacklistCheck;
127 
131 struct TransportClient {
135  struct TransportClient *next;
136 
140  struct TransportClient *prev;
141 
145  struct GNUNET_SERVICE_Client *client;
146 
150  struct GNUNET_MQ_Handle *mq;
151 
155  enum ClientType type;
156 
157  union {
163  struct GNUNET_PeerIdentity monitor_peer;
164 
168  struct {
174 
179 
184  } blacklist;
185  } details;
186 };
187 
188 
197 
202 
207 
212 
216  void *cont_cls;
217 
222 
227 
232 
237 };
238 
239 
248 
253 
258 };
259 
260 
269 
273  struct GNUNET_PeerIdentity target;
274 
278  struct GNUNET_TIME_Absolute send_time;
279 
283  unsigned long long uuid;
284 
290  int down;
291 };
292 
293 
298 
303 
311 
316 
321 
326 
331 
337 
343 
349 
355 
360 
365 
370 
375 
380 
385 
390 
395 
400 
405 
410 
418 static void
420  const struct GNUNET_MessageHeader *msg,
421  int may_drop)
422 {
423  struct GNUNET_MQ_Envelope *env;
424 
425  if ((GNUNET_MQ_get_length(tc->mq) >= MAX_PENDING) &&
426  (GNUNET_YES == may_drop))
427  {
428  GNUNET_log(
430  "Dropping message of type %u and size %u, have %u/%u messages pending\n",
431  ntohs(msg->type),
432  ntohs(msg->size),
434  MAX_PENDING);
435  GNUNET_STATISTICS_update(GST_stats,
436  gettext_noop(
437  "# messages dropped due to slow client"),
438  1,
439  GNUNET_NO);
440  return;
441  }
442  env = GNUNET_MQ_msg_copy(msg);
443  GNUNET_MQ_send(tc->mq, env);
444 }
445 
446 
456 static void *
458  struct GNUNET_SERVICE_Client *client,
459  struct GNUNET_MQ_Handle *mq)
460 {
461  struct TransportClient *tc;
462 
463  tc = GNUNET_new(struct TransportClient);
464  tc->client = client;
465  tc->mq = mq;
466  GNUNET_CONTAINER_DLL_insert(clients_head, clients_tail, tc);
467  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", tc);
468  return tc;
469 }
470 
471 
477 static void
478 do_blacklist_check(void *cls);
479 
480 
490 static int
491 mark_match_down(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
492 {
493  struct TransportClient *tc = cls;
494  struct SendTransmitContinuationContext *stcc = value;
495 
496  if (tc == stcc->tc)
497  {
498  stcc->down = GNUNET_YES;
499  stcc->tc = NULL;
500  }
501  return GNUNET_OK;
502 }
503 
504 
513 static void
515  struct GNUNET_SERVICE_Client *client,
516  void *app_ctx)
517 {
518  struct TransportClient *tc = app_ctx;
519  struct GST_BlacklistCheck *bc;
520 
522  "Client %p disconnected, cleaning up.\n",
523  tc);
525  for (struct AddressToStringContext *cur = a2s_head; NULL != cur;
526  cur = cur->next)
527  {
528  if (cur->tc == tc)
529  cur->tc = NULL;
530  }
531  GNUNET_CONTAINER_DLL_remove(clients_head, clients_tail, tc);
532  switch (tc->type)
533  {
534  case CT_NONE:
535  break;
536 
537  case CT_CORE:
538  break;
539 
540  case CT_MONITOR:
541  break;
542 
543  case CT_BLACKLIST:
544  for (bc = bc_head; NULL != bc; bc = bc->next)
545  {
546  if (bc->bl_pos != tc)
547  continue;
548  bc->bl_pos = tc->next;
549  if (NULL == bc->task)
551  }
552  break;
553 
554  case CT_CORE_NO_HANDLERS:
555  break;
556  }
557  GNUNET_free(tc);
558 }
559 
560 
573 static void
575  const struct GNUNET_PeerIdentity *peer,
576  const struct GNUNET_HELLO_Address *address,
578  struct GNUNET_TIME_Absolute state_timeout,
579  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
580  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
581 {
582  struct TransportClient *tc = cls;
583  struct ConnectInfoMessage cim;
584 
586  return;
587  cim.header.size = htons(sizeof(struct ConnectInfoMessage));
589  cim.id = *peer;
590  cim.quota_out = bandwidth_out;
591  unicast(tc, &cim.header, GNUNET_NO);
592 }
593 
594 
603 static void
604 handle_client_start(void *cls, const struct StartMessage *start)
605 {
606  struct TransportClient *tc = cls;
607  const struct GNUNET_MessageHeader *hello;
608  uint32_t options;
609 
610  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Client %p sent START\n", tc);
611  options = ntohl(start->options);
612  if ((0 != (1 & options)) &&
613  (0 != memcmp(&start->self,
615  sizeof(struct GNUNET_PeerIdentity))))
616  {
617  /* client thinks this is a different peer, reject */
618  GNUNET_break(0);
620  return;
621  }
622  if (CT_NONE != tc->type)
623  {
624  GNUNET_break(0);
626  return;
627  }
628  if (0 != (2 & options))
629  tc->type = CT_CORE;
630  else
632  hello = GST_hello_get();
633  if (NULL != hello)
634  unicast(tc, hello, GNUNET_NO);
637 }
638 
639 
646 static int
647 check_client_hello(void *cls, const struct GNUNET_MessageHeader *message)
648 {
649  return GNUNET_OK; /* FIXME: check here? */
650 }
651 
652 
659 static void
660 handle_client_hello(void *cls, const struct GNUNET_MessageHeader *message)
661 {
662  struct TransportClient *tc = cls;
663 
664  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Received HELLO message\n");
667 }
668 
669 
679 static void
681  int success,
682  size_t bytes_payload,
683  size_t bytes_on_wire)
684 {
685  struct SendTransmitContinuationContext *stcc = cls;
686  struct SendOkMessage send_ok_msg;
687  struct GNUNET_TIME_Relative delay;
688  const struct GNUNET_HELLO_Address *addr;
689 
692  if (delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us)
694  "It took us %s to send %u/%u bytes to %s (%d, %s)\n",
696  (unsigned int)bytes_payload,
697  (unsigned int)bytes_on_wire,
698  GNUNET_i2s(&stcc->target),
699  success,
700  (NULL != addr) ? addr->transport_name : "%");
701  else
703  "It took us %s to send %u/%u bytes to %s (%d, %s)\n",
705  (unsigned int)bytes_payload,
706  (unsigned int)bytes_on_wire,
707  GNUNET_i2s(&stcc->target),
708  success,
709  (NULL != addr) ? addr->transport_name : "%");
710 
711  if (GNUNET_NO == stcc->down)
712  {
713  /* Only send confirmation if we are still connected */
715  "Sending SEND_OK for transmission request %llu\n",
716  stcc->uuid);
717  send_ok_msg.header.size = htons(sizeof(send_ok_msg));
719  send_ok_msg.bytes_msg = htonl(bytes_payload);
720  send_ok_msg.bytes_physical = htonl(bytes_on_wire);
721  send_ok_msg.success = htonl(success);
722  send_ok_msg.peer = stcc->target;
723  unicast(stcc->tc, &send_ok_msg.header, GNUNET_NO);
724  }
726  GNUNET_OK ==
727  GNUNET_CONTAINER_multipeermap_remove(active_stccs, &stcc->target, stcc));
728  GNUNET_free(stcc);
729 }
730 
731 
738 static int
739 check_client_send(void *cls, const struct OutboundMessage *obm)
740 {
741  uint16_t size;
742  const struct GNUNET_MessageHeader *obmm;
743 
744  size = ntohs(obm->header.size) - sizeof(struct OutboundMessage);
745  if (size < sizeof(struct GNUNET_MessageHeader))
746  {
747  GNUNET_break(0);
748  return GNUNET_SYSERR;
749  }
750  obmm = (const struct GNUNET_MessageHeader *)&obm[1];
751  if (size != ntohs(obmm->size))
752  {
753  GNUNET_break(0);
754  return GNUNET_SYSERR;
755  }
756  return GNUNET_OK;
757 }
758 
759 
766 static void
767 handle_client_send(void *cls, const struct OutboundMessage *obm)
768 {
769  static unsigned long long uuid_gen;
770  struct TransportClient *tc = cls;
771  const struct GNUNET_MessageHeader *obmm;
772  struct SendTransmitContinuationContext *stcc;
773 
774  obmm = (const struct GNUNET_MessageHeader *)&obm[1];
776  {
777  /* not connected, not allowed to send; can happen due to asynchronous operations */
779  "Could not send message to peer `%s': not connected\n",
780  GNUNET_i2s(&obm->peer));
782  GST_stats,
783  gettext_noop("# bytes payload dropped (other peer was not connected)"),
784  ntohs(obmm->size),
785  GNUNET_NO);
787  return;
788  }
789  GNUNET_log(
791  "Received SEND request %llu for `%s' and first message of type %u and total size %u\n",
792  uuid_gen,
793  GNUNET_i2s(&obm->peer),
794  ntohs(obmm->type),
795  ntohs(obmm->size));
797 
799  stcc->target = obm->peer;
800  stcc->tc = tc;
802  stcc->uuid = uuid_gen++;
804  active_stccs,
805  &stcc->target,
806  stcc,
809  obmm,
810  ntohs(obmm->size),
813  stcc);
814 }
815 
816 
831 static void
832 transmit_address_to_client(void *cls, const char *buf, int res)
833 {
834  struct AddressToStringContext *actx = cls;
835  struct GNUNET_MQ_Envelope *env;
836  struct AddressToStringResultMessage *atsm;
837  size_t slen;
838 
839  GNUNET_assert((GNUNET_OK == res) || (GNUNET_SYSERR == res));
840  if (NULL == actx->tc)
841  return;
842  if (NULL == buf)
843  {
844  env = GNUNET_MQ_msg(atsm,
846  if (GNUNET_OK == res)
847  {
848  /* this was the last call, transmit */
849  atsm->res = htonl(GNUNET_OK);
850  atsm->addr_len = htonl(0);
851  GNUNET_MQ_send(actx->tc->mq, env);
852  GNUNET_CONTAINER_DLL_remove(a2s_head, a2s_tail, actx);
853  GNUNET_free(actx);
854  return;
855  }
856  if (GNUNET_SYSERR == res)
857  {
858  /* address conversion failed, but there will be more callbacks */
859  atsm->res = htonl(GNUNET_SYSERR);
860  atsm->addr_len = htonl(0);
861  GNUNET_MQ_send(actx->tc->mq, env);
862  return;
863  }
864  }
865  GNUNET_assert(GNUNET_OK == res);
866  /* succesful conversion, append*/
867  slen = strlen(buf) + 1;
868  env =
869  GNUNET_MQ_msg_extra(atsm,
870  slen,
872  atsm->res = htonl(GNUNET_YES);
873  atsm->addr_len = htonl(slen);
874  GNUNET_memcpy(&atsm[1], buf, slen);
875  GNUNET_MQ_send(actx->tc->mq, env);
876 }
877 
878 
886 static int
888  const struct AddressLookupMessage *alum)
889 {
890  const char *plugin_name;
891  const char *address;
892  uint32_t address_len;
893  uint16_t size;
894 
895  size = ntohs(alum->header.size);
896  address_len = ntohs(alum->addrlen);
897  if (size <= sizeof(struct AddressLookupMessage) + address_len)
898  {
899  GNUNET_break(0);
900  return GNUNET_SYSERR;
901  }
902  address = (const char *)&alum[1];
903  plugin_name = (const char *)&address[address_len];
904  if ('\0' != plugin_name[size - sizeof(struct AddressLookupMessage) -
905  address_len - 1])
906  {
907  GNUNET_break(0);
908  return GNUNET_SYSERR;
909  }
910  return GNUNET_OK;
911 }
912 
913 
920 static void
922  const struct AddressLookupMessage *alum)
923 {
924  struct TransportClient *tc = cls;
926  const char *plugin_name;
927  const char *address;
928  uint32_t address_len;
929  struct AddressToStringContext *actx;
930  struct GNUNET_MQ_Envelope *env;
931  struct AddressToStringResultMessage *atsm;
932  struct GNUNET_TIME_Relative rtimeout;
933  int32_t numeric;
934 
935  address_len = ntohs(alum->addrlen);
936  address = (const char *)&alum[1];
937  plugin_name = (const char *)&address[address_len];
938  rtimeout = GNUNET_TIME_relative_ntoh(alum->timeout);
939  numeric = ntohs(alum->numeric_only);
940  papi = GST_plugins_printer_find(plugin_name);
941  if (NULL == papi)
942  {
944  "Failed to find plugin `%s'\n",
945  plugin_name);
946  env = GNUNET_MQ_msg(atsm,
948  atsm->res = htonl(GNUNET_SYSERR);
949  atsm->addr_len = htonl(0);
950  GNUNET_MQ_send(tc->mq, env);
951  env = GNUNET_MQ_msg(atsm,
953  atsm->res = htonl(GNUNET_OK);
954  atsm->addr_len = htonl(0);
955  GNUNET_MQ_send(tc->mq, env);
956  return;
957  }
958  actx = GNUNET_new(struct AddressToStringContext);
959  actx->tc = tc;
960  GNUNET_CONTAINER_DLL_insert(a2s_head, a2s_tail, actx);
963  "Pretty-printing address of %u bytes using plugin `%s'\n",
964  address_len,
965  plugin_name);
966  papi->address_pretty_printer(papi->cls,
967  plugin_name,
968  address,
969  address_len,
970  numeric,
971  rtimeout,
973  actx);
974 }
975 
976 
984 static struct PeerIterateResponseMessage *
986  const struct GNUNET_PeerIdentity *peer,
987  const struct GNUNET_HELLO_Address *address)
988 {
990  size_t size;
991  size_t tlen;
992  size_t alen;
993  char *addr;
994 
995  GNUNET_assert(NULL != peer);
996  if (NULL != address)
997  {
998  tlen = strlen(address->transport_name) + 1;
999  alen = address->address_length;
1000  }
1001  else
1002  {
1003  tlen = 0;
1004  alen = 0;
1005  }
1006  size = (sizeof(struct PeerIterateResponseMessage) + alen + tlen);
1007  msg = GNUNET_malloc(size);
1008  msg->header.size = htons(size);
1009  msg->header.type =
1011  msg->reserved = htonl(0);
1012  msg->peer = *peer;
1013  msg->addrlen = htonl(alen);
1014  msg->pluginlen = htonl(tlen);
1015 
1016  if (NULL != address)
1017  {
1018  msg->local_address_info = htonl((uint32_t)address->local_info);
1019  addr = (char *)&msg[1];
1020  GNUNET_memcpy(addr, address->address, alen);
1021  GNUNET_memcpy(&addr[alen], address->transport_name, tlen);
1022  }
1023  return msg;
1024 }
1025 
1026 
1031 struct IterationContext {
1036 
1041 
1045  int all;
1046 };
1047 
1048 
1060 static void
1062  const struct GNUNET_PeerIdentity *peer,
1063  const struct GNUNET_HELLO_Address *address,
1065  struct GNUNET_TIME_Absolute state_timeout,
1066  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
1067  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
1068 {
1069  struct IterationContext *pc = cls;
1070  struct GNUNET_MQ_Envelope *env;
1072 
1073  if ((GNUNET_YES != pc->all) && (0 != memcmp(peer, &pc->id, sizeof(pc->id))))
1074  return;
1076  "Sending information about `%s' using address `%s' in state `%s'\n",
1077  GNUNET_i2s(peer),
1078  (NULL != address) ? GST_plugins_a2s(address) : "<none>",
1079  GNUNET_TRANSPORT_ps2s(state));
1080  msg = compose_address_iterate_response_message(peer, address);
1081  msg->state = htonl(state);
1082  msg->state_timeout = GNUNET_TIME_absolute_hton(state_timeout);
1083  env = GNUNET_MQ_msg_copy(&msg->header);
1084  GNUNET_free(msg);
1085  GNUNET_MQ_send(pc->tc->mq, env);
1086 }
1087 
1088 
1096 static void
1098 {
1099  struct TransportClient *tc = cls;
1100  struct IterationContext pc;
1101 
1102  if (CT_NONE != tc->type)
1103  {
1104  GNUNET_break(0);
1106  return;
1107  }
1110 
1111  /* Send initial list */
1112  pc.tc = tc;
1113  if (0 == memcmp(&msg->peer, &all_zeros, sizeof(struct GNUNET_PeerIdentity)))
1114  {
1115  /* iterate over all neighbours */
1116  pc.all = GNUNET_YES;
1117  pc.id = msg->peer;
1118  }
1119  else
1120  {
1121  /* just return one neighbour */
1122  pc.all = GNUNET_NO;
1123  pc.id = msg->peer;
1124  }
1126 
1127  if (GNUNET_YES != ntohl(msg->one_shot))
1128  {
1129  tc->details.monitor_peer = msg->peer;
1130  tc->type = CT_MONITOR;
1131  if (0 !=
1132  memcmp(&msg->peer, &all_zeros, sizeof(struct GNUNET_PeerIdentity)))
1134  "Client %p started monitoring of the peer `%s'\n",
1135  tc,
1136  GNUNET_i2s(&msg->peer));
1137  else
1139  "Client %p started monitoring all peers\n",
1140  tc);
1141  }
1142  else
1143  {
1144  struct GNUNET_MessageHeader *msg;
1145  struct GNUNET_MQ_Envelope *env;
1146 
1147  env =
1148  GNUNET_MQ_msg(msg,
1150  GNUNET_MQ_send(tc->mq, env);
1151  }
1152 }
1153 
1154 
1167 static void
1169  struct GNUNET_ATS_Session *session,
1170  const struct GNUNET_TRANSPORT_SessionInfo *info)
1171 {
1172  struct GNUNET_MQ_Envelope *env;
1174  struct GNUNET_MessageHeader *sync;
1175  size_t size;
1176  size_t slen;
1177  uint16_t alen;
1178  char *name;
1179  char *addr;
1180 
1181  if (0 == GNUNET_notification_context_get_size(plugin_nc))
1182  {
1183  GST_plugins_monitor_subscribe(NULL, NULL);
1184  return;
1185  }
1186  if ((NULL == info) && (NULL == session))
1187  {
1188  /* end of initial iteration */
1189  if (NULL != sync_client)
1190  {
1191  env =
1193  GNUNET_MQ_send(sync_client->mq, env);
1194  sync_client = NULL;
1195  }
1196  return;
1197  }
1198  GNUNET_assert(NULL != info);
1200  "Plugin event for peer %s on transport %s\n",
1201  GNUNET_i2s(&info->address->peer),
1202  info->address->transport_name);
1203  slen = strlen(info->address->transport_name) + 1;
1204  alen = info->address->address_length;
1205  size = sizeof(struct TransportPluginMonitorMessage) + slen + alen;
1206  if (size > UINT16_MAX)
1207  {
1208  GNUNET_break(0);
1209  return;
1210  }
1211  msg = GNUNET_malloc(size);
1212  msg->header.size = htons(size);
1214  msg->session_state = htons((uint16_t)info->state);
1215  msg->is_inbound = htons((int16_t)info->is_inbound);
1216  msg->msgs_pending = htonl(info->num_msg_pending);
1217  msg->bytes_pending = htonl(info->num_bytes_pending);
1220  msg->peer = info->address->peer;
1221  msg->session_id = (uint64_t)(intptr_t)session;
1222  msg->plugin_name_len = htons(slen);
1223  msg->plugin_address_len = htons(alen);
1224  name = (char *)&msg[1];
1225  GNUNET_memcpy(name, info->address->transport_name, slen);
1226  addr = &name[slen];
1227  GNUNET_memcpy(addr, info->address->address, alen);
1228  if (NULL != sync_client)
1229  {
1230  struct GNUNET_MQ_Envelope *env;
1231 
1232  env = GNUNET_MQ_msg_copy(&msg->header);
1233  GNUNET_MQ_send(sync_client->mq, env);
1234  }
1235  else
1236  {
1238  }
1239  GNUNET_free(msg);
1240 }
1241 
1242 
1249 static void
1251  const struct GNUNET_MessageHeader *message)
1252 {
1253  struct TransportClient *tc = cls;
1254 
1257  GNUNET_notification_context_add(plugin_nc, tc->mq);
1258  GNUNET_assert(NULL == sync_client);
1259  sync_client = tc;
1261 }
1262 
1263 
1270 void
1271 GST_clients_broadcast(const struct GNUNET_MessageHeader *msg, int may_drop)
1272 {
1273  int done;
1274 
1276  "Asked to broadcast message of type %u with %u bytes\n",
1277  (unsigned int)ntohs(msg->type),
1278  (unsigned int)ntohs(msg->size));
1279  done = GNUNET_NO;
1280  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
1281  {
1282  if (CT_NONE == tc->type)
1283  continue; /* client not yet ready */
1284  if ((GNUNET_YES == may_drop) && (CT_CORE != tc->type))
1285  continue; /* skip, this client does not care about payload */
1286  unicast(tc, msg, may_drop);
1287  done = GNUNET_YES;
1288  }
1289  if (GNUNET_NO == done)
1291  "Message of type %u not delivered, is CORE service up?\n",
1292  ntohs(msg->type));
1293 }
1294 
1295 
1304 void
1306  const struct GNUNET_PeerIdentity *peer,
1307  const struct GNUNET_HELLO_Address *address,
1309  struct GNUNET_TIME_Absolute state_timeout)
1310 {
1311  struct GNUNET_MQ_Envelope *env;
1313 
1314  msg = compose_address_iterate_response_message(peer, address);
1315  msg->state = htonl(state);
1316  msg->state_timeout = GNUNET_TIME_absolute_hton(state_timeout);
1317  for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
1318  {
1319  if (CT_MONITOR != tc->type)
1320  continue;
1321  if ((0 == memcmp(&tc->details.monitor_peer,
1322  &all_zeros,
1323  sizeof(struct GNUNET_PeerIdentity))) ||
1324  (0 == memcmp(&tc->details.monitor_peer,
1325  peer,
1326  sizeof(struct GNUNET_PeerIdentity))))
1327  {
1328  env = GNUNET_MQ_msg_copy(&msg->header);
1329  GNUNET_MQ_send(tc->mq, env);
1330  }
1331  }
1332  GNUNET_free(msg);
1333 }
1334 
1335 
1345 static int
1346 mark_peer_down(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
1347 {
1348  struct SendTransmitContinuationContext *stcc = value;
1349 
1350  stcc->down = GNUNET_YES;
1351  return GNUNET_OK;
1352 }
1353 
1354 
1361 void
1363 {
1364  struct DisconnectInfoMessage disconnect_msg;
1365 
1367  peer,
1368  &mark_peer_down,
1369  NULL);
1370  disconnect_msg.header.size = htons(sizeof(struct DisconnectInfoMessage));
1371  disconnect_msg.header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
1372  disconnect_msg.reserved = htonl(0);
1373  disconnect_msg.peer = *peer;
1374  GST_clients_broadcast(&disconnect_msg.header, GNUNET_NO);
1375 }
1376 
1377 
1389 static void
1391  const struct GNUNET_PeerIdentity *peer,
1392  const struct GNUNET_HELLO_Address *address,
1394  struct GNUNET_TIME_Absolute state_timeout,
1395  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
1396  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
1397 {
1398  const struct GNUNET_MessageHeader *hello = cls;
1399 
1400  if (0 == memcmp(peer, &GST_my_identity, sizeof(struct GNUNET_PeerIdentity)))
1401  return; /* not to ourselves */
1403  return;
1404 
1405  GST_neighbours_send(peer,
1406  hello,
1407  ntohs(hello->size),
1409  NULL,
1410  NULL);
1411 }
1412 
1413 
1420 static void
1421 process_hello_update(void *cls, const struct GNUNET_MessageHeader *hello)
1422 {
1423  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Broadcasting HELLO to clients\n");
1425  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Broadcasting HELLO to neighbours\n");
1426  GST_neighbours_iterate(&transmit_our_hello, (void *)hello);
1427 }
1428 
1429 
1440 static struct GNUNET_TIME_Relative
1442  struct GNUNET_ATS_Session *session,
1443  const struct GNUNET_MessageHeader *message)
1444 {
1445  struct GNUNET_TIME_Relative ret;
1446  int do_forward;
1447  struct InboundMessage *im;
1448  size_t msg_size = ntohs(message->size);
1449  size_t size = sizeof(struct InboundMessage) + msg_size;
1450  char buf[size] GNUNET_ALIGN;
1451 
1452  do_forward = GNUNET_SYSERR;
1453  ret = GST_neighbours_calculate_receive_delay(&address->peer,
1454  msg_size,
1455  &do_forward);
1456  if (!GST_neighbours_test_connected(&address->peer))
1457  {
1459  "Discarded %u bytes type %u payload from peer `%s'\n",
1460  (unsigned int)msg_size,
1461  ntohs(message->type),
1462  GNUNET_i2s(&address->peer));
1464  GST_stats,
1465  gettext_noop("# bytes payload discarded due to not connected peer"),
1466  msg_size,
1467  GNUNET_NO);
1468  return ret;
1469  }
1470 
1471  if (GNUNET_YES != do_forward)
1472  return ret;
1473  im = (struct InboundMessage *)buf;
1474  im->header.size = htons(size);
1476  im->peer = address->peer;
1477  GNUNET_memcpy(&im[1], message, ntohs(message->size));
1479  return ret;
1480 }
1481 
1482 
1488 static void
1490 {
1491  struct GNUNET_ATS_SessionKiller *sk = cls;
1492 
1493  sk->task = NULL;
1494  GNUNET_CONTAINER_DLL_remove(sk_head, sk_tail, sk);
1495  sk->plugin->disconnect_session(sk->plugin->cls, sk->session);
1496  GNUNET_free(sk);
1497 }
1498 
1499 
1507 static void
1508 kill_session(const char *plugin_name, struct GNUNET_ATS_Session *session)
1509 {
1511  struct GNUNET_ATS_SessionKiller *sk;
1512 
1513  for (sk = sk_head; NULL != sk; sk = sk->next)
1514  if (sk->session == session)
1515  return;
1516  plugin = GST_plugins_find(plugin_name);
1517  if (NULL == plugin)
1518  {
1519  GNUNET_break(0);
1520  return;
1521  }
1522  /* need to issue disconnect asynchronously */
1523  sk = GNUNET_new(struct GNUNET_ATS_SessionKiller);
1524  sk->session = session;
1525  sk->plugin = plugin;
1527  GNUNET_CONTAINER_DLL_insert(sk_head, sk_tail, sk);
1528 }
1529 
1530 
1541 static void
1543  const struct GNUNET_PeerIdentity *peer,
1544  const struct GNUNET_HELLO_Address *address,
1545  struct GNUNET_ATS_Session *session,
1546  int result)
1547 {
1548  struct GNUNET_MessageHeader *msg = cls;
1549 
1550  if (GNUNET_OK == result)
1551  {
1552  /* Blacklist allows to speak to this peer, forward SYN to neighbours */
1554  "Received SYN message from peer `%s' at `%s'\n",
1555  GNUNET_i2s(peer),
1556  GST_plugins_a2s(address));
1557  if (GNUNET_OK != GST_neighbours_handle_session_syn(msg, peer))
1558  {
1559  GST_blacklist_abort_matching(address, session);
1560  kill_session(address->transport_name, session);
1561  }
1562  GNUNET_free(msg);
1563  return;
1564  }
1565  GNUNET_free(msg);
1566  if (GNUNET_SYSERR == result)
1567  return; /* check was aborted, session destroyed */
1568  /* Blacklist denies to speak to this peer */
1570  "Discarding SYN message from `%s' due to denied blacklist check\n",
1571  GNUNET_i2s(peer));
1572  kill_session(address->transport_name, session);
1573 }
1574 
1575 
1589 struct GNUNET_TIME_Relative
1591  const struct GNUNET_HELLO_Address *address,
1592  struct GNUNET_ATS_Session *session,
1593  const struct GNUNET_MessageHeader *message)
1594 {
1595  const char *plugin_name = cls;
1596  struct GNUNET_TIME_Relative ret;
1597  uint16_t type;
1598 
1599  ret = GNUNET_TIME_UNIT_ZERO;
1600  if (NULL == message)
1601  goto end;
1602  type = ntohs(message->type);
1604  "Received message with type %u from peer `%s' at %s\n",
1605  type,
1606  GNUNET_i2s(&address->peer),
1607  GST_plugins_a2s(address));
1608 
1609  GNUNET_STATISTICS_update(GST_stats,
1610  gettext_noop("# bytes total received"),
1611  ntohs(message->size),
1612  GNUNET_NO);
1613  GST_neighbours_notify_data_recv(address, message);
1614  switch (type)
1615  {
1617  /* Legacy HELLO message, discard */
1618  return ret;
1619 
1621  if (GNUNET_OK != GST_validation_handle_hello(message))
1622  {
1623  GNUNET_break_op(0);
1624  GST_blacklist_abort_matching(address, session);
1625  }
1626  return ret;
1627 
1630  "Processing PING from `%s'\n",
1631  GST_plugins_a2s(address));
1632  if (GNUNET_OK !=
1633  GST_validation_handle_ping(&address->peer, message, address, session))
1634  {
1635  GST_blacklist_abort_matching(address, session);
1636  kill_session(plugin_name, session);
1637  }
1638  break;
1639 
1642  "Processing PONG from `%s'\n",
1643  GST_plugins_a2s(address));
1644  if (GNUNET_OK != GST_validation_handle_pong(&address->peer, message))
1645  {
1646  GNUNET_break_op(0);
1647  GST_blacklist_abort_matching(address, session);
1648  kill_session(plugin_name, session);
1649  }
1650  break;
1651 
1653  /* Do blacklist check if communication with this peer is allowed */
1654  (void)GST_blacklist_test_allowed(&address->peer,
1655  NULL,
1657  GNUNET_copy_message(message),
1658  address,
1659  session);
1660  break;
1661 
1663  if (GNUNET_OK !=
1664  GST_neighbours_handle_session_syn_ack(message, address, session))
1665  {
1666  GST_blacklist_abort_matching(address, session);
1667  kill_session(plugin_name, session);
1668  }
1669  break;
1670 
1672  if (GNUNET_OK !=
1673  GST_neighbours_handle_session_ack(message, address, session))
1674  {
1675  GNUNET_break_op(0);
1676  GST_blacklist_abort_matching(address, session);
1677  kill_session(plugin_name, session);
1678  }
1679  break;
1680 
1682  GST_neighbours_handle_disconnect_message(&address->peer, message);
1683  break;
1684 
1686  GST_neighbours_handle_quota_message(&address->peer, message);
1687  break;
1688 
1690  GST_neighbours_keepalive(&address->peer, message);
1691  break;
1692 
1694  GST_neighbours_keepalive_response(&address->peer, message);
1695  break;
1696 
1697  default:
1698  /* should be payload */
1699  GNUNET_STATISTICS_update(GST_stats,
1700  gettext_noop("# bytes payload received"),
1701  ntohs(message->size),
1702  GNUNET_NO);
1703  ret = process_payload(address, session, message);
1704  break;
1705  }
1706 end:
1708  "Allowing receive from peer %s to continue in %s\n",
1709  GNUNET_i2s(&address->peer),
1711  return ret;
1712 }
1713 
1714 
1724 static void
1726  void *cls,
1727  int add_remove,
1728  const struct GNUNET_HELLO_Address *address)
1729 {
1730  static int addresses = 0;
1731 
1732  if (GNUNET_YES == add_remove)
1733  {
1734  addresses++;
1735  GNUNET_STATISTICS_update(GST_stats, "# transport addresses", 1, GNUNET_NO);
1736  }
1737  else if (GNUNET_NO == add_remove)
1738  {
1739  if (0 == addresses)
1740  {
1741  GNUNET_break(0);
1742  }
1743  else
1744  {
1745  addresses--;
1746  GNUNET_STATISTICS_update(GST_stats,
1747  "# transport addresses",
1748  -1,
1749  GNUNET_NO);
1750  }
1751  }
1753  "Transport now has %u addresses to communicate\n",
1754  addresses);
1755  GST_hello_modify_addresses(add_remove, address);
1756 }
1757 
1758 
1772 static void
1774  const struct GNUNET_HELLO_Address *address,
1775  struct GNUNET_ATS_Session *session)
1776 {
1777  struct GNUNET_ATS_SessionKiller *sk;
1778 
1779  if (NULL == address)
1780  {
1781  GNUNET_break(0);
1782  return;
1783  }
1784  if (NULL == session)
1785  {
1786  GNUNET_break(0);
1787  return;
1788  }
1789  GNUNET_assert(strlen(address->transport_name) > 0);
1790 
1791  GNUNET_log(
1793  "Notification from plugin about terminated session %p from peer `%s' address `%s'\n",
1794  session,
1795  GNUNET_i2s(&address->peer),
1796  GST_plugins_a2s(address));
1797 
1798  GST_neighbours_session_terminated(&address->peer, session);
1799  GST_ats_del_session(address, session);
1800  GST_blacklist_abort_matching(address, session);
1801 
1802  for (sk = sk_head; NULL != sk; sk = sk->next)
1803  {
1804  if (sk->session == session)
1805  {
1806  GNUNET_CONTAINER_DLL_remove(sk_head, sk_tail, sk);
1808  GNUNET_free(sk);
1809  break;
1810  }
1811  }
1812 }
1813 
1814 
1826 static void
1828  void *cls,
1829  const struct GNUNET_PeerIdentity *peer,
1830  const struct GNUNET_HELLO_Address *address,
1831  struct GNUNET_ATS_Session *session,
1832  int result)
1833 {
1834  if (GNUNET_OK != result)
1835  {
1836  kill_session(address->transport_name, session);
1837  return;
1838  }
1839  if (GNUNET_YES !=
1842  {
1844  "Informing verifier about inbound session's address `%s'\n",
1845  GST_plugins_a2s(address));
1847  }
1848 }
1849 
1850 
1859 static void
1861  const struct GNUNET_HELLO_Address *address,
1862  struct GNUNET_ATS_Session *session,
1864 {
1865  struct GNUNET_ATS_Properties prop;
1866 
1867  if (NULL == address)
1868  {
1869  GNUNET_break(0);
1870  return;
1871  }
1872  if (NULL == session)
1873  {
1874  GNUNET_break(0);
1875  return;
1876  }
1877  GNUNET_log(
1879  "Notification from plugin `%s' about new session from peer `%s' address `%s'\n",
1880  address->transport_name,
1881  GNUNET_i2s(&address->peer),
1882  GST_plugins_a2s(address));
1883  if (GNUNET_YES ==
1886  {
1887  /* inbound is always new, but outbound MAY already be known, but
1888  for example for UNIX, we have symmetric connections and thus we
1889  may not know the address yet; add if necessary! */
1890  /* FIXME: maybe change API here so we just pass scope? */
1891  memset(&prop, 0, sizeof(prop));
1893  prop.scope = scope;
1894  GST_ats_add_inbound_address(address, session, &prop);
1895  }
1896  /* Do blacklist check if communication with this peer is allowed */
1897  (void)GST_blacklist_test_allowed(&address->peer,
1898  address->transport_name,
1900  NULL,
1901  address,
1902  session);
1903 }
1904 
1905 
1924 static void
1926  const struct GNUNET_PeerIdentity *peer,
1927  const struct GNUNET_HELLO_Address *address,
1928  struct GNUNET_ATS_Session *session,
1929  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
1930  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
1931 {
1932  uint32_t bw_in = ntohl(bandwidth_in.value__);
1933  uint32_t bw_out = ntohl(bandwidth_out.value__);
1934 
1935  if (NULL == peer)
1936  {
1937  /* ATS service died, all suggestions become invalid!
1938  (but we'll keep using the allocations for a little
1939  while, to keep going while ATS restarts) */
1940  /* FIXME: We should drop all
1941  connections now, as ATS won't explicitly tell
1942  us and be unaware of ongoing resource allocations! */
1943  return;
1944  }
1945  /* ATS tells me to disconnect from peer */
1946  if ((0 == bw_in) && (0 == bw_out))
1947  {
1949  "ATS tells me to disconnect from peer `%s'\n",
1950  GNUNET_i2s(peer));
1952  return;
1953  }
1954  GNUNET_assert(NULL != address);
1955  GNUNET_STATISTICS_update(GST_stats,
1956  "# ATS suggestions received",
1957  1,
1958  GNUNET_NO);
1960  session,
1961  bandwidth_in,
1962  bandwidth_out);
1963 }
1964 
1965 
1973  int first;
1974 
1979 };
1980 
1981 
1993 static void
1995  const struct GNUNET_PeerIdentity *peer,
1996  const struct GNUNET_HELLO_Address *address,
1997  struct GNUNET_ATS_Session *session,
1998  int allowed)
1999 {
2000  if (GNUNET_OK == allowed)
2001  return; /* we're done */
2002  GNUNET_STATISTICS_update(GST_stats,
2003  gettext_noop("# disconnects due to blacklist"),
2004  1,
2005  GNUNET_NO);
2007 }
2008 
2009 
2022 static void
2024  const struct GNUNET_PeerIdentity *peer,
2025  const struct GNUNET_HELLO_Address *address,
2027  struct GNUNET_TIME_Absolute state_timeout,
2028  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
2029  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
2030 {
2031  struct TestConnectionContext *tcc = cls;
2032  struct GST_BlacklistCheck *bc;
2033 
2034  bc = GNUNET_new(struct GST_BlacklistCheck);
2035  GNUNET_CONTAINER_DLL_insert(bc_head, bc_tail, bc);
2036  bc->peer = *peer;
2037  bc->address = GNUNET_HELLO_address_copy(address);
2039  bc->cont_cls = NULL;
2040  bc->bl_pos = tcc->tc;
2041  if (GNUNET_YES == tcc->first)
2042  {
2043  /* all would wait for the same client, no need to
2044  * create more than just the first task right now */
2046  tcc->first = GNUNET_NO;
2047  }
2048 }
2049 
2050 
2059 static void
2061  const struct GNUNET_MessageHeader *message)
2062 {
2063  struct TransportClient *tc = cls;
2064  struct TestConnectionContext tcc;
2065 
2066  if (CT_NONE != tc->type)
2067  {
2068  GNUNET_break(0);
2070  return;
2071  }
2073  tc->type = CT_BLACKLIST;
2074  tc->details.blacklist.call_receive_done = GNUNET_YES;
2075  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "New blacklist client %p\n", tc);
2076  /* confirm that all existing connections are OK! */
2077  tcc.tc = tc;
2078  tcc.first = GNUNET_YES;
2080 }
2081 
2082 
2091 static int
2093  const struct GNUNET_PeerIdentity *key,
2094  void *value)
2095 {
2096  char *be = value;
2097 
2099  return GNUNET_OK;
2100 }
2101 
2102 
2109 static void
2111 {
2112  struct TransportClient *tc = cls;
2113 
2116 }
2117 
2118 
2125 static void
2126 shutdown_task(void *cls)
2127 {
2128  struct AddressToStringContext *cur;
2129 
2133  GST_ats_done();
2134  GNUNET_ATS_scheduling_done(GST_ats);
2135  GST_ats = NULL;
2136  GNUNET_ATS_connectivity_done(GST_ats_connect);
2137  GST_ats_connect = NULL;
2138  GNUNET_NT_scanner_done(GST_is);
2139  GST_is = NULL;
2140  while (NULL != (cur = a2s_head))
2141  {
2142  GNUNET_CONTAINER_DLL_remove(a2s_head, a2s_tail, cur);
2143  GNUNET_free(cur);
2144  }
2145  if (NULL != plugin_nc)
2146  {
2148  plugin_nc = NULL;
2149  }
2151  active_stccs = NULL;
2152  if (NULL != blacklist)
2153  {
2156  NULL);
2158  blacklist = NULL;
2159  }
2160  GST_hello_stop();
2162 
2163  if (NULL != GST_peerinfo)
2164  {
2165  GNUNET_PEERINFO_disconnect(GST_peerinfo);
2166  GST_peerinfo = NULL;
2167  }
2168  if (NULL != GST_stats)
2169  {
2171  GST_stats = NULL;
2172  }
2173  if (NULL != GST_my_private_key)
2174  {
2175  GNUNET_free(GST_my_private_key);
2176  GST_my_private_key = NULL;
2177  }
2178 }
2179 
2180 
2186 static void
2188 {
2189  struct GST_BlacklistCheck *bc = cls;
2190  struct TransportClient *tc;
2191  struct GNUNET_MQ_Envelope *env;
2192  struct BlacklistMessage *bm;
2193 
2194  bc->task = NULL;
2195  while (NULL != (tc = bc->bl_pos))
2196  {
2197  if (CT_BLACKLIST == tc->type)
2198  break;
2199  bc->bl_pos = tc->next;
2200  }
2201  if (NULL == tc)
2202  {
2204  "No other blacklist clients active, will allow neighbour `%s'\n",
2205  GNUNET_i2s(&bc->peer));
2206 
2207  bc->cont(bc->cont_cls, &bc->peer, bc->address, bc->session, GNUNET_OK);
2209  return;
2210  }
2211  if ((NULL != tc->details.blacklist.bc) ||
2212  (GNUNET_NO != tc->details.blacklist.waiting_for_reply))
2213  return; /* someone else busy with this client */
2214  tc->details.blacklist.bc = bc;
2216  bm->is_allowed = htonl(0);
2217  bm->peer = bc->peer;
2218  GNUNET_MQ_send(tc->mq, env);
2219  if (GNUNET_YES == tc->details.blacklist.call_receive_done)
2220  {
2221  tc->details.blacklist.call_receive_done = GNUNET_NO;
2223  }
2224  tc->details.blacklist.waiting_for_reply = GNUNET_YES;
2225 }
2226 
2227 
2234 static void
2236 {
2237  struct TransportClient *tc = cls;
2238  struct GST_BlacklistCheck *bc;
2239 
2240  if (CT_BLACKLIST != tc->type)
2241  {
2242  GNUNET_break(0);
2244  return;
2245  }
2247  "Blacklist client %p sent reply for `%s'\n",
2248  tc,
2249  GNUNET_i2s(&msg->peer));
2250  bc = tc->details.blacklist.bc;
2251  tc->details.blacklist.bc = NULL;
2252  tc->details.blacklist.waiting_for_reply = GNUNET_NO;
2253  tc->details.blacklist.call_receive_done = GNUNET_YES;
2254  if (NULL != bc)
2255  {
2256  /* only run this if the blacklist check has not been
2257  * cancelled in the meantime... */
2258  GNUNET_assert(bc->bl_pos == tc);
2259  if (ntohl(msg->is_allowed) == GNUNET_SYSERR)
2260  {
2262  "Blacklist check failed, peer not allowed\n");
2263  /* For the duration of the continuation, make the ongoing
2264  check invisible (to avoid double-cancellation); then
2265  add it back again so we can re-use GST_blacklist_test_cancel() */
2266  GNUNET_CONTAINER_DLL_remove(bc_head, bc_tail, bc);
2267  bc->cont(bc->cont_cls, &bc->peer, bc->address, bc->session, GNUNET_NO);
2268  GNUNET_CONTAINER_DLL_insert(bc_head, bc_tail, bc);
2270  tc->details.blacklist.call_receive_done = GNUNET_NO;
2272  return;
2273  }
2274  else
2275  {
2277  "Blacklist check succeeded, continuing with checks\n");
2278  tc->details.blacklist.call_receive_done = GNUNET_NO;
2280  bc->bl_pos = tc->next;
2282  }
2283  }
2284  /* check if any other blacklist checks are waiting for this blacklister */
2285  for (bc = bc_head; bc != NULL; bc = bc->next)
2286  if ((bc->bl_pos == tc) && (NULL == bc->task))
2287  {
2289  break;
2290  }
2291 }
2292 
2293 
2300 void
2302  const char *transport_name)
2303 {
2304  char *transport = NULL;
2305 
2306  if (NULL != transport_name)
2307  {
2309  "Adding peer `%s' with plugin `%s' to blacklist\n",
2310  GNUNET_i2s(peer),
2311  transport_name);
2312  transport = GNUNET_strdup(transport_name);
2313  }
2314  else
2316  "Adding peer `%s' with all plugins to blacklist\n",
2317  GNUNET_i2s(peer));
2318  if (NULL == blacklist)
2319  blacklist =
2321  GNUNET_NO);
2322 
2324  peer,
2325  transport,
2327 }
2328 
2329 
2336 void
2338  struct GNUNET_ATS_Session *session)
2339 {
2340  struct GST_BlacklistCheck *bc;
2341  struct GST_BlacklistCheck *n;
2342 
2343  n = bc_head;
2344  while (NULL != (bc = n))
2345  {
2346  n = bc->next;
2347  if ((bc->session == session) &&
2348  (0 == GNUNET_HELLO_address_cmp(bc->address, address)))
2349  {
2350  bc->cont(bc->cont_cls,
2351  &bc->peer,
2352  bc->address,
2353  bc->session,
2354  GNUNET_SYSERR);
2356  }
2357  }
2358 }
2359 
2360 
2370 static int
2371 test_blacklisted(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
2372 {
2373  const char *transport_name = cls;
2374  char *be = value;
2375 
2376  /* Blacklist entry be:
2377  * (NULL == be): peer is blacklisted with all plugins
2378  * (NULL != be): peer is blacklisted for a specific plugin
2379  *
2380  * If (NULL != transport_name) we look for a transport specific entry:
2381  * if (transport_name == be) forbidden
2382  *
2383  */
2384 
2386  "Comparing BL request for peer `%4s':`%s' with BL entry: `%s'\n",
2387  GNUNET_i2s(key),
2388  (NULL == transport_name) ? "unspecified" : transport_name,
2389  (NULL == be) ? "all plugins" : be);
2390  /* all plugins for this peer were blacklisted: disallow */
2391  if (NULL == value)
2392  return GNUNET_NO;
2393 
2394  /* blacklist check for specific transport */
2395  if ((NULL != transport_name) && (NULL != value))
2396  {
2397  if (0 == strcmp(transport_name, be))
2398  return GNUNET_NO; /* plugin is blacklisted! */
2399  }
2400  return GNUNET_OK;
2401 }
2402 
2403 
2416 struct GST_BlacklistCheck *
2418  const char *transport_name,
2420  void *cont_cls,
2421  const struct GNUNET_HELLO_Address *address,
2422  struct GNUNET_ATS_Session *session)
2423 {
2424  struct GST_BlacklistCheck *bc;
2425  struct TransportClient *tc;
2426 
2427  GNUNET_assert(NULL != peer);
2429  "Blacklist check for peer `%s':%s\n",
2430  GNUNET_i2s(peer),
2431  (NULL != transport_name) ? transport_name : "unspecified");
2432 
2433  /* Check local blacklist by iterating over hashmap
2434  * If iteration is aborted, we found a matching blacklist entry */
2435  if ((NULL != blacklist) &&
2436  (GNUNET_SYSERR ==
2438  peer,
2440  (void *)transport_name)))
2441  {
2442  /* Disallowed by config, disapprove instantly */
2443  GNUNET_STATISTICS_update(GST_stats,
2444  gettext_noop("# disconnects due to blacklist"),
2445  1,
2446  GNUNET_NO);
2448  _("Disallowing connection to peer `%s' on transport %s\n"),
2449  GNUNET_i2s(peer),
2450  (NULL != transport_name) ? transport_name : "unspecified");
2451  if (NULL != cont)
2452  cont(cont_cls, peer, address, session, GNUNET_NO);
2453  return NULL;
2454  }
2455 
2456  for (tc = clients_head; NULL != tc; tc = tc->next)
2457  if (CT_BLACKLIST == tc->type)
2458  break;
2459  if (NULL == tc)
2460  {
2461  /* no blacklist clients, approve instantly */
2462  if (NULL != cont)
2463  cont(cont_cls, peer, address, session, GNUNET_OK);
2465  "Allowing connection to peer `%s' %s\n",
2466  GNUNET_i2s(peer),
2467  (NULL != transport_name) ? transport_name : "");
2468  return NULL;
2469  }
2470 
2471  /* need to query blacklist clients */
2472  bc = GNUNET_new(struct GST_BlacklistCheck);
2473  GNUNET_CONTAINER_DLL_insert(bc_head, bc_tail, bc);
2474  bc->peer = *peer;
2475  bc->address = GNUNET_HELLO_address_copy(address);
2476  bc->session = session;
2477  bc->cont = cont;
2478  bc->cont_cls = cont_cls;
2479  bc->bl_pos = tc;
2481  return bc;
2482 }
2483 
2484 
2490 void
2492 {
2493  GNUNET_CONTAINER_DLL_remove(bc_head, bc_tail, bc);
2494  if (NULL != bc->bl_pos)
2495  {
2496  if ((CT_BLACKLIST == bc->bl_pos->type) &&
2497  (bc->bl_pos->details.blacklist.bc == bc))
2498  {
2499  /* we're at the head of the queue, remove us! */
2500  bc->bl_pos->details.blacklist.bc = NULL;
2501  }
2502  }
2503  if (NULL != bc->task)
2504  {
2506  bc->task = NULL;
2507  }
2509  GNUNET_free(bc);
2510 }
2511 
2512 
2521 static void
2523  const char *section,
2524  const char *option,
2525  const char *value)
2526 {
2527  unsigned int *res = cls;
2528  struct GNUNET_PeerIdentity peer;
2529  char *plugs;
2530  char *pos;
2531 
2532  if (GNUNET_OK !=
2534  strlen(option),
2535  &peer.public_key))
2536  return;
2537 
2538  if ((NULL == value) || (0 == strcmp(value, "")))
2539  {
2540  /* Blacklist whole peer */
2541  GST_blacklist_add_peer(&peer, NULL);
2543  _("Adding blacklisting entry for peer `%s'\n"),
2544  GNUNET_i2s(&peer));
2545  }
2546  else
2547  {
2548  plugs = GNUNET_strdup(value);
2549  for (pos = strtok(plugs, " "); pos != NULL; pos = strtok(NULL, " "))
2550  {
2552  _("Adding blacklisting entry for peer `%s':`%s'\n"),
2553  GNUNET_i2s(&peer),
2554  pos);
2555  GST_blacklist_add_peer(&peer, pos);
2556  }
2557  GNUNET_free(plugs);
2558  }
2559  (*res)++;
2560 }
2561 
2562 
2569 static void
2571  const struct GNUNET_PeerIdentity *my_id)
2572 {
2573  char cfg_sect[512];
2574  unsigned int res = 0;
2575 
2576  GNUNET_snprintf(cfg_sect,
2577  sizeof(cfg_sect),
2578  "transport-blacklist-%s",
2579  GNUNET_i2s_full(my_id));
2581  cfg_sect,
2583  &res);
2585  "Loaded %u blacklisting entries from configuration\n",
2586  res);
2587 }
2588 
2589 
2597 static void
2598 run(void *cls,
2599  const struct GNUNET_CONFIGURATION_Handle *c,
2601 {
2602  char *keyfile;
2604  long long unsigned int max_fd_cfg;
2605  int max_fd_rlimit;
2606  int max_fd;
2607  int friend_only;
2608 
2609  /* setup globals */
2610  GST_cfg = c;
2612  "PEER",
2613  "PRIVATE_KEY",
2614  &keyfile))
2615  {
2616  GNUNET_log(
2618  _(
2619  "Transport service is lacking key configuration settings. Exiting.\n"));
2621  return;
2622  }
2624  "transport",
2625  "HELLO_EXPIRATION",
2626  &hello_expiration))
2627  {
2629  }
2631  GNUNET_free(keyfile);
2632  GNUNET_assert(NULL != pk);
2633  GST_my_private_key = pk;
2634 
2635  GST_stats = GNUNET_STATISTICS_create("transport", GST_cfg);
2636  GST_peerinfo = GNUNET_PEERINFO_connect(GST_cfg);
2637  GNUNET_CRYPTO_eddsa_key_get_public(GST_my_private_key,
2639  GNUNET_assert(NULL != GST_my_private_key);
2640 
2642  "My identity is `%s'\n",
2644 
2646  if (NULL == GST_peerinfo)
2647  {
2649  _("Could not access PEERINFO service. Exiting.\n"));
2651  return;
2652  }
2653 
2654  max_fd_rlimit = 0;
2655 #if HAVE_GETRLIMIT
2656  {
2657  struct rlimit r_file;
2658 
2659  if (0 == getrlimit(RLIMIT_NOFILE, &r_file))
2660  {
2661  max_fd_rlimit = r_file.rlim_cur;
2663  "Maximum number of open files was: %u/%u\n",
2664  (unsigned int)r_file.rlim_cur,
2665  (unsigned int)r_file.rlim_max);
2666  }
2667  max_fd_rlimit =
2668  (9 * max_fd_rlimit) / 10; /* Keep 10% for rest of transport */
2669  }
2670 #endif
2672  "transport",
2673  "MAX_FD",
2674  &max_fd_cfg))
2675  max_fd_cfg = max_fd_rlimit;
2676 
2677  if (max_fd_cfg > max_fd_rlimit)
2678  max_fd = max_fd_cfg;
2679  else
2680  max_fd = max_fd_rlimit;
2681  if (max_fd < DEFAULT_MAX_FDS)
2682  max_fd = DEFAULT_MAX_FDS;
2683 
2685  "Limiting number of sockets to %u: validation %u, neighbors: %u\n",
2686  max_fd,
2687  (max_fd / 3),
2688  (max_fd / 3) * 2);
2689 
2690  friend_only =
2691  GNUNET_CONFIGURATION_get_value_yesno(GST_cfg, "topology", "FRIENDS-ONLY");
2692  if (GNUNET_SYSERR == friend_only)
2693  friend_only = GNUNET_NO; /* According to topology defaults */
2694  /* start subsystems */
2695  /* Disable DSTJ peer */
2696  {
2697  struct GNUNET_PeerIdentity dstj;
2698  const char *ds = "DSTJBRRKZ8TBW3FGK6B0M5QXWT9WYNZ45H5MCV4HY7ST64Q8T9F0";
2699 
2700  GNUNET_assert(
2701  GNUNET_OK ==
2703  strlen(ds),
2704  &dstj.public_key));
2705  GST_blacklist_add_peer(&dstj, NULL);
2706  }
2708  GST_is = GNUNET_NT_scanner_init();
2709  GST_ats_connect = GNUNET_ATS_connectivity_init(GST_cfg);
2710  GST_ats =
2712  GST_ats_init();
2718  GST_hello_start(friend_only, &process_hello_update, NULL);
2719  GST_neighbours_start((max_fd / 3) * 2);
2720  active_stccs = GNUNET_CONTAINER_multipeermap_create(128, GNUNET_YES);
2721  plugin_nc = GNUNET_notification_context_create(0);
2722  GST_validation_start((max_fd / 3));
2723 }
2724 
2725 
2730  "transport",
2732  &run,
2735  NULL,
2738  struct StartMessage,
2739  NULL),
2740  GNUNET_MQ_hd_var_size(client_hello,
2742  struct GNUNET_MessageHeader,
2743  NULL),
2746  struct OutboundMessage,
2747  NULL),
2748  GNUNET_MQ_hd_var_size(client_address_to_string,
2750  struct AddressLookupMessage,
2751  NULL),
2752  GNUNET_MQ_hd_fixed_size(client_monitor_peers,
2754  struct PeerMonitorMessage,
2755  NULL),
2756  GNUNET_MQ_hd_fixed_size(client_blacklist_init,
2758  struct GNUNET_MessageHeader,
2759  NULL),
2760  GNUNET_MQ_hd_fixed_size(client_blacklist_reply,
2762  struct BlacklistMessage,
2763  NULL),
2764  GNUNET_MQ_hd_fixed_size(client_set_metric,
2766  struct TrafficMetricMessage,
2767  NULL),
2768  GNUNET_MQ_hd_fixed_size(client_monitor_plugins,
2770  struct GNUNET_MessageHeader,
2771  NULL),
2773 
2774 
2775 /* 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:215
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:108
struct GNUNET_PeerIdentity id
Identity of the new neighbour.
Definition: transport.h:139
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:315
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:651
void GST_neighbours_iterate(GST_NeighbourIterator cb, void *cb_cls)
Iterate over all connected neighbours.
Handle to the peerinfo service.
Definition: peerinfo_api.c:83
The notification context is the key datastructure for a convenience API used for transmission of noti...
Definition: nc.c:74
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:281
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:586
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:330
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:114
struct GNUNET_PEERINFO_Handle * GNUNET_PEERINFO_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the peerinfo service.
Definition: peerinfo_api.c:128
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:547
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:1284
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:612
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:120
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:581
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:300
struct GNUNET_PeerIdentity peer
Which peer is this connection for?
Definition: transport.h:637
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:133
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:410
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:542
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_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#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:523
#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:78
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:75
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:108
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:517
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:557
#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:158
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:181
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:246
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:552
#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:570
uint16_t success
GNUNET_OK if the transmission succeeded, GNUNET_SYSERR if it failed (i.e.
Definition: transport.h:228
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:325
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:156
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...
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:333
#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:213
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:1264
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:458
struct GNUNET_PeerIdentity peer
The identity of the peer to look up.
Definition: transport.h:472
uint16_t plugin_name_len
Length of the plugin name in bytes, including 0-termination.
Definition: transport.h:647
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:686
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:239
uint32_t options
0: no options 1: The self field should be checked 2: this client is interested in payload traffic ...
Definition: transport.h:102
#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:652
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:116
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:617
struct GNUNET_TIME_RelativeNBO timeout
Allowed delay.
Definition: transport.h:294
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:480
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:2394
#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:639
int16_t numeric_only
Should the conversion use numeric IP addresses (otherwise a reverse DNS lookup is OK – if applicable...
Definition: transport.h:349
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:2315
#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:627
void GNUNET_NT_scanner_done(struct GNUNET_NT_InterfaceScanner *is)
Terminate interface scanner.
Definition: nt.c:419
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:277
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:151
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:76
static unsigned int size
Size of the "table".
Definition: peer.c:66
struct GNUNET_PeerIdentity peer
Which peer sent the message?
Definition: transport.h:203
struct GNUNET_MQ_Handle * mq
Message queue to the client.
Transport-level connection status update.
Definition: transport.h:593
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:147
const char * name
struct GNUNET_TIME_RelativeNBO timeout
timeout to give up (for DNS resolution timeout mostly)
Definition: transport.h:359
struct GNUNET_NT_InterfaceScanner * GNUNET_NT_scanner_init(void)
Initialize the address characterization client handle.
Definition: nt.c:399
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:622
uint16_t bytes_msg
Size of message sent.
Definition: transport.h:233
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:119
Message from the library to the transport service asking for converting a transport address to a huma...
Definition: transport.h:339
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:84
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:532
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:642
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:187
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:211
struct GNUNET_PeerIdentity peer
Which peer can send more now?
Definition: transport.h:245
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:602
configuration data
Definition: configuration.c:83
struct GNUNET_TIME_AbsoluteNBO delay
Until how long is this plugin currently blocked from reading?
Definition: transport.h:632
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:467
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:343
struct GNUNET_PeerIdentity peer
Who got disconnected?
Definition: transport.h:161
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:131
#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:154
struct GNUNET_PeerIdentity peer
Peer identity.
Definition: transport.h:537
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:527
#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:77
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:135
uint16_t addrlen
Length of the (binary) address in bytes, in big-endian.
Definition: transport.h:354
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:351
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:562
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:198
#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:2258
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:655
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:2234
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:194
#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:39
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_EVENT.
Definition: transport.h:597
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:956