gnunet-service-transport_manipulation.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2010-2015 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file transport/gnunet-service-transport_neighbours.h
  18. * @brief neighbour manipulation API, allows manipulation of
  19. * performance metrics (delay and towards ATS)
  20. * @author Christian Grothoff
  21. */
  22. #ifndef GNUNET_SERVICE_TRANSPORT_MANIPULATION_H
  23. #define GNUNET_SERVICE_TRANSPORT_MANIPULATION_H
  24. #include "platform.h"
  25. #include "gnunet-service-transport_hello.h"
  26. #include "gnunet-service-transport_neighbours.h"
  27. #include "gnunet-service-transport_plugins.h"
  28. #include "gnunet-service-transport_validation.h"
  29. #include "gnunet-service-transport.h"
  30. #include "transport.h"
  31. /**
  32. * Set traffic metric to manipulate
  33. *
  34. * @param message containing information
  35. */
  36. void
  37. GST_manipulation_set_metric (const struct TrafficMetricMessage *tm);
  38. /**
  39. * Adapter function between transport's send function and transport plugins
  40. *
  41. * @param target the peer the message to send to
  42. * @param msg the message received
  43. * @param msg_size message size
  44. * @param timeout timeout
  45. * @param cont the continuation to call after sending
  46. * @param cont_cls cls for continuation
  47. */
  48. void
  49. GST_manipulation_send (const struct GNUNET_PeerIdentity *target,
  50. const void *msg,
  51. size_t msg_size,
  52. struct GNUNET_TIME_Relative timeout,
  53. GST_NeighbourSendContinuation cont,
  54. void *cont_cls);
  55. /**
  56. * Adapter function between transport plugins and transport receive function
  57. * manipulation delays for next send.
  58. *
  59. * @param cls the closure for transport
  60. * @param address the address and the peer the message was received from
  61. * @param message the message received
  62. * @param session the session the message was received on
  63. * @return manipulated delay for next receive
  64. */
  65. struct GNUNET_TIME_Relative
  66. GST_manipulation_recv (void *cls,
  67. const struct GNUNET_HELLO_Address *address,
  68. struct GNUNET_ATS_Session *session,
  69. const struct GNUNET_MessageHeader *message);
  70. /**
  71. * Function that will be called to manipulate ATS information according to
  72. * current manipulation settings
  73. *
  74. * @param address binary address
  75. * @param session the session
  76. * @param prop[IN|OUT] metrics to modify
  77. */
  78. void
  79. GST_manipulation_manipulate_metrics (const struct GNUNET_HELLO_Address *address,
  80. struct GNUNET_ATS_Session *session,
  81. struct GNUNET_ATS_Properties *prop);
  82. /**
  83. * Notify manipulation about disconnect so it can discard queued messages
  84. *
  85. * @param peer the disconnecting peer
  86. */
  87. void
  88. GST_manipulation_peer_disconnect (const struct GNUNET_PeerIdentity *peer);
  89. /**
  90. * Initialize traffic manipulation
  91. */
  92. void
  93. GST_manipulation_init (void);
  94. /**
  95. * Stop traffic manipulation
  96. */
  97. void
  98. GST_manipulation_stop (void);
  99. #endif
  100. /* end of file gnunet-service-transport_neighbours.h */