rehash.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /* rehash --- a decentralised hash<->hash store
  2. Copyright © 2020 Maxime Devos <maxime.devos@student.kuleuven.be>
  3. This file is part of rehash.
  4. rehash is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or (at
  7. your option) any later version.
  8. rehash 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
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with rehash. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef _REHASH_REHASH_H
  15. #define _REHASH_REHASH_H
  16. #include <gnunet/gnunet_time_lib.h>
  17. /* TODO: are response id's required?
  18. See GNUNET_DHT_*.
  19. TODO: replication level? */.
  20. GNUNET_NETWORK_STRUCT_BEGIN
  21. /**
  22. * Message from client to rehash service to lookup hash->hash mappings
  23. */
  24. struct REHASH_GetMessage
  25. {
  26. /**
  27. * Header of type #GNUNET_MESSAGE_TYPE_REHASH_GET
  28. */
  29. struct GNUNET_MessageHeader header;
  30. /**
  31. * request / response relation
  32. */
  33. uint32_t request_id;
  34. uint32_t options; /* NBO, enum GNUNET_FS_SearchOptions */
  35. /**
  36. * Requested anonymity level, NBO
  37. */
  38. uint32_t anonymity_level;
  39. /**
  40. * Hash type to search with,
  41. * enum REHASH_Hash_Type in NBO.
  42. */
  43. uint32_t in_type;
  44. /**
  45. * Hash type to search for,
  46. * enum REHASH_Hash_Type in NBO.
  47. */
  48. uint32_t out_type;
  49. /**
  50. * Length of input hash, NBO
  51. */
  52. uint32_t input_length;
  53. /* Followed by input_length bytes */
  54. };
  55. /**
  56. * Message from rehash service to client to return hash->hash mappings
  57. */
  58. struct REHASH_ResultMessage
  59. {
  60. /**
  61. * Header of type #GNUNET_MESSAGE_TYPE_REHASH_RESULT
  62. */
  63. struct GNUNET_MessageHeader header;
  64. /**
  65. * When will this mapping expire?
  66. */
  67. struct GNUNET_TIME_AbsoluteNBO exp;
  68. /**
  69. * To which REHASH_GetMessage
  70. * does this answer correspond?
  71. */
  72. uint32_t request_id;
  73. /**
  74. * Length of output hash, in NBO
  75. */
  76. uint32_t output_length;
  77. /* Followed by output_length bytes */
  78. };
  79. /**
  80. * Message from client to rehash service to stop a hash->hash lookup
  81. * request
  82. */
  83. struct REHASH_GetStopMessage
  84. {
  85. /**
  86. * Header of type #GNUNET_MESSAGE_TYPE_REHASH_RESULT
  87. */
  88. struct GNUNET_MessageHeader header;
  89. /**
  90. * Which REHASH_GetMessage should be stopped?
  91. */
  92. uint32_t request_id;
  93. };
  94. /**
  95. * Message from client to rehash service to insert a hash->hash
  96. * mapping
  97. */
  98. struct REHASH_PutMessage {
  99. struct GNUNET_MessageHeader header;
  100. struct GNUNET_TIME_AbsoluteNBO expiration_time;
  101. /** for cancelling (TODO for progress?) */
  102. uint32_t request_id;
  103. /** NBO */
  104. uint32_t anonymity_level;
  105. /** NBO */
  106. uint32_t content_priority;
  107. /** NBO */
  108. uint32_t replication_level;
  109. /**
  110. * Hash type to search with,
  111. * enum REHASH_Hash_Type in NBO.
  112. */
  113. uint32_t in_type;
  114. /**
  115. * Hash type to search for,
  116. * enum REHASH_Hash_Type in NBO.
  117. */
  118. uint32_t out_type;
  119. /**
  120. * Length of hash to search with, NBO
  121. */
  122. uint32_t input_length;
  123. /**
  124. * Length of hash to search for, NBO
  125. */
  126. uint32_t output_length;
  127. /* Followed by input_length bytes
  128. for the input hash, and output_length bytes
  129. for output hash */
  130. };
  131. enum REHASH_PutStatus
  132. {
  133. /* The rehash service considers this insertion
  134. to be completed. Don't pester rehash about
  135. it anymore. */
  136. REHASH_PUT_COMPLETED = 1 << 0,
  137. /* flags 1 << i with i >= 15 may be ignored
  138. if unrecognised. Others must not. */
  139. };
  140. /**
  141. * Message from rehash service to client
  142. * for status updates on a hash-hash insertion. */
  143. struct REHASH_PutStatusMessage {
  144. /**
  145. * Type: #GNUNET_MESSAGE_TYPE_REHASH_PUT_DONE
  146. */
  147. struct GNUNET_MessageHeader header;
  148. /**
  149. * If REHASH_PUT_DONE is set,
  150. * the service now has forgotten about
  151. * this request.
  152. */
  153. uint32_t request_id GNUNET_PACKED;
  154. /** enum REHASH_PUT_STATUS,
  155. in network byte-order. */
  156. uint32_t flags GNUNET_PACKED;
  157. };
  158. GNUNET_NETWORK_STRUCT_END
  159. #endif