gnunet-service-xdht_routing.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. This file is part of GNUnet.
  3. (C) 2011 - 2014 Christian Grothoff (and other contributing authors)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. 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. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA.
  16. */
  17. /**
  18. * @file dht/gnunet-service-xdht_routing.h
  19. * @brief GNUnet DHT tracking of requests for routing replies
  20. * @author Christian Grothoff
  21. */
  22. #ifndef GNUNET_SERVICE_XDHT_ROUTING_H
  23. #define GNUNET_SERVICE_XDHT_ROUTING_H
  24. #include "gnunet_util_lib.h"
  25. #include "gnunet_block_lib.h"
  26. #include "gnunet_dht_service.h"
  27. /**
  28. * To understand the direction in which trial should be read.
  29. */
  30. enum GDS_ROUTING_trail_direction
  31. {
  32. GDS_ROUTING_SRC_TO_DEST,
  33. GDS_ROUTING_DEST_TO_SRC
  34. };
  35. /**
  36. * Update the prev. hop of the trail. Call made by trail teardown where
  37. * if you are the first friend now in the trail then you need to update
  38. * your prev. hop.
  39. * @param trail_id
  40. * @return #GNUNET_OK success
  41. * #GNUNET_SYSERR in case no matching entry found in routing table.
  42. */
  43. int
  44. GDS_ROUTING_update_trail_prev_hop (struct GNUNET_HashCode trail_id,
  45. struct GNUNET_PeerIdentity prev_hop);
  46. /**
  47. * Update the next hop of the trail. Call made by trail compression where
  48. * if you are source of the trail and now you have a new first friend, then
  49. * you should update the trail.
  50. * @param trail_id
  51. * @return #GNUNET_OK success
  52. * #GNUNET_SYSERR in case no matching entry found in routing table.
  53. */
  54. int
  55. GDS_ROUTING_update_trail_next_hop (const struct GNUNET_HashCode trail_id,
  56. struct GNUNET_PeerIdentity next_hop);
  57. /**
  58. * Get the next hop for trail corresponding to trail_id
  59. * @param trail_id Trail id to be searched.
  60. * @return Next_hop if found
  61. * NULL If next hop not found.
  62. */
  63. struct GNUNET_PeerIdentity *
  64. GDS_ROUTING_get_next_hop (struct GNUNET_HashCode trail_id,
  65. enum GDS_ROUTING_trail_direction trail_direction);
  66. /**
  67. * Remove every trail where peer is either next_hop or prev_hop
  68. * @param peer Peer to be searched.
  69. */
  70. int
  71. GDS_ROUTING_remove_trail_by_peer (const struct GNUNET_PeerIdentity *peer);
  72. /**
  73. * Remove trail with trail_id
  74. * @param trail_id Trail id to be removed
  75. * @return #GNUNET_YES success
  76. * #GNUNET_NO if entry not found.
  77. */
  78. int
  79. GDS_ROUTING_remove_trail (struct GNUNET_HashCode remove_trail_id);
  80. /**
  81. * Add a new entry in routing table
  82. * @param new_trail_id
  83. * @param prev_hop
  84. * @param next_hop
  85. * @return #GNUNET_OK success
  86. * #GNUNET_SYSERR in case new_trail_id already exists in the network
  87. * but with different prev_hop/next_hop
  88. */
  89. int
  90. GDS_ROUTING_add (struct GNUNET_HashCode new_trail_id,
  91. struct GNUNET_PeerIdentity prev_hop,
  92. struct GNUNET_PeerIdentity next_hop);
  93. /**
  94. * Check if the size of routing table has crossed threshold.
  95. * @return #GNUNET_YES, if threshold crossed
  96. * #GNUNET_NO, if size is within threshold
  97. */
  98. int
  99. GDS_ROUTING_threshold_reached (void);
  100. #if 0
  101. /**
  102. * Test function. Remove afterwards.
  103. */
  104. void
  105. GDS_ROUTING_test_print (void);
  106. #endif
  107. /**
  108. * Initialize routing subsystem.
  109. */
  110. void
  111. GDS_ROUTING_init (void);
  112. /**
  113. * Shutdown routing subsystem.
  114. */
  115. void
  116. GDS_ROUTING_done (void);
  117. #endif