namecache.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2011-2013 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 namecache/namecache.h
  18. * @brief common internal definitions for namecache service
  19. * @author Matthias Wachs
  20. * @author Christian Grothoff
  21. */
  22. #ifndef NAMECACHE_H
  23. #define NAMECACHE_H
  24. /**
  25. * Maximum length of any name, including 0-termination.
  26. */
  27. #define MAX_NAME_LEN 256
  28. GNUNET_NETWORK_STRUCT_BEGIN
  29. /**
  30. * Generic namecache message with op id
  31. */
  32. struct GNUNET_NAMECACHE_Header
  33. {
  34. /**
  35. * header.type will be GNUNET_MESSAGE_TYPE_NAMECACHE_*
  36. * header.size will be message size
  37. */
  38. struct GNUNET_MessageHeader header;
  39. /**
  40. * Request ID in NBO
  41. */
  42. uint32_t r_id GNUNET_PACKED;
  43. };
  44. /**
  45. * Lookup a block in the namecache
  46. */
  47. struct LookupBlockMessage
  48. {
  49. /**
  50. * Type will be #GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK
  51. */
  52. struct GNUNET_NAMECACHE_Header gns_header;
  53. /**
  54. * The query.
  55. */
  56. struct GNUNET_HashCode query GNUNET_PACKED;
  57. };
  58. /**
  59. * Lookup response
  60. */
  61. struct LookupBlockResponseMessage
  62. {
  63. /**
  64. * Type will be #GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK_RESPONSE
  65. */
  66. struct GNUNET_NAMECACHE_Header gns_header;
  67. /**
  68. * Expiration time
  69. */
  70. struct GNUNET_TIME_AbsoluteNBO expire;
  71. /**
  72. * Signature.
  73. */
  74. struct GNUNET_CRYPTO_EcdsaSignature signature;
  75. /**
  76. * Derived public key.
  77. */
  78. struct GNUNET_CRYPTO_EcdsaPublicKey derived_key;
  79. /* follwed by encrypted block data */
  80. };
  81. /**
  82. * Cache a record in the namecache.
  83. */
  84. struct BlockCacheMessage
  85. {
  86. /**
  87. * Type will be #GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE
  88. */
  89. struct GNUNET_NAMECACHE_Header gns_header;
  90. /**
  91. * Expiration time
  92. */
  93. struct GNUNET_TIME_AbsoluteNBO expire;
  94. /**
  95. * Signature.
  96. */
  97. struct GNUNET_CRYPTO_EcdsaSignature signature;
  98. /**
  99. * Derived public key.
  100. */
  101. struct GNUNET_CRYPTO_EcdsaPublicKey derived_key;
  102. /* follwed by encrypted block data */
  103. };
  104. /**
  105. * Response to a request to cache a block.
  106. */
  107. struct BlockCacheResponseMessage
  108. {
  109. /**
  110. * Type will be #GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE_RESPONSE
  111. */
  112. struct GNUNET_NAMECACHE_Header gns_header;
  113. /**
  114. * #GNUNET_OK on success, #GNUNET_SYSERR error
  115. */
  116. int32_t op_result GNUNET_PACKED;
  117. };
  118. GNUNET_NETWORK_STRUCT_END
  119. /* end of namecache.h */
  120. #endif