scalarproduct.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. This file is part of GNUnet.
  3. (C) 2009, 2010, 2011, 2012, 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 scalarproduct.h
  19. * @brief Scalar Product Message Types
  20. * @author Christian M. Fuchs
  21. *
  22. * Created on September 2, 2013, 3:43 PM
  23. */
  24. #ifndef SCALARPRODUCT_H
  25. #define SCALARPRODUCT_H
  26. #ifdef __cplusplus
  27. extern "C"
  28. {
  29. #endif
  30. GNUNET_NETWORK_STRUCT_BEGIN
  31. /**
  32. * Log an error message at log-level 'level' that indicates
  33. * a failure of the command 'cmd' with the message given
  34. * by gcry_strerror(rc).
  35. */
  36. #define LOG_GCRY(level, cmd, rc) do { LOG(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, gcry_strerror(rc)); } while(0)
  37. /**
  38. * Message type passed from client to service
  39. * to initiate a request or responder role
  40. */
  41. struct ComputationMessage
  42. {
  43. /**
  44. * GNUNET message header
  45. */
  46. struct GNUNET_MessageHeader header;
  47. /**
  48. * how many elements the vector in payload contains
  49. */
  50. uint32_t element_count_total GNUNET_PACKED;
  51. /**
  52. * contained elements the vector in payload contains
  53. */
  54. uint32_t element_count_contained GNUNET_PACKED;
  55. /**
  56. * Always zero.
  57. */
  58. uint32_t reserved GNUNET_PACKED;
  59. /**
  60. * the transaction/session key used to identify a session
  61. */
  62. struct GNUNET_HashCode session_key;
  63. /**
  64. * the identity of a remote peer we want to communicate with
  65. */
  66. struct GNUNET_PeerIdentity peer;
  67. /**
  68. * followed by struct GNUNET_SCALARPRODUCT_Element[]
  69. */
  70. };
  71. /**
  72. * multipart messages following `struct ComputationMessage`
  73. */
  74. struct ComputationMultipartMessage
  75. {
  76. /**
  77. * GNUNET message header
  78. */
  79. struct GNUNET_MessageHeader header;
  80. /**
  81. * contained elements the vector in payload contains
  82. */
  83. uint32_t element_count_contained GNUNET_PACKED;
  84. /**
  85. * followed by struct GNUNET_SCALARPRODUCT_Element[]
  86. */
  87. };
  88. /**
  89. * Message type passed from service client
  90. * to finalize a session as requester or responder
  91. */
  92. struct ClientResponseMessage
  93. {
  94. /**
  95. * GNUNET message header
  96. */
  97. struct GNUNET_MessageHeader header;
  98. /**
  99. * 0 if no product attached
  100. */
  101. uint32_t product_length GNUNET_PACKED;
  102. /**
  103. * status information about the outcome of this session
  104. */
  105. int32_t status GNUNET_PACKED;
  106. /**
  107. * Workaround for libgcrypt: -1 if negative, 0 if zero, else 1
  108. */
  109. int32_t range GNUNET_PACKED;
  110. /**
  111. * followed by product of length product_length (or nothing)
  112. */
  113. };
  114. GNUNET_NETWORK_STRUCT_END
  115. #ifdef __cplusplus
  116. }
  117. #endif
  118. #endif /* SCALARPRODUCT_H */