namecache.h 3.0 KB

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