-fix crash observed on FreeBSD
[oweals/gnunet.git] / src / scalarproduct / scalarproduct.h
1 /*
2      This file is part of GNUnet.
3      (C) 2009, 2010, 2011, 2012, 2013 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file   scalarproduct.h
23  * @brief  Scalar Product Message Types
24  * @author Christian M. Fuchs
25  *
26  * Created on September 2, 2013, 3:43 PM
27  */
28
29 #ifndef SCALARPRODUCT_H
30 #define SCALARPRODUCT_H
31
32 #ifdef  __cplusplus
33 extern "C"
34 {
35 #endif
36
37 GNUNET_NETWORK_STRUCT_BEGIN
38
39 /**
40  * Log an error message at log-level 'level' that indicates
41  * a failure of the command 'cmd' with the message given
42  * by gcry_strerror(rc).
43  */
44 #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)
45
46
47 /**
48  * Message type passed from client to service
49  * to initiate a request or responder role
50  */
51 struct ComputationMessage
52 {
53   /**
54    * GNUNET message header
55    */
56   struct GNUNET_MessageHeader header;
57
58   /**
59    * how many elements the vector in payload contains
60    */
61   uint32_t element_count_total GNUNET_PACKED;
62
63   /**
64    * contained elements the vector in payload contains
65    */
66   uint32_t element_count_contained GNUNET_PACKED;
67
68   /**
69    * Always zero.
70    */
71   uint32_t reserved GNUNET_PACKED;
72
73   /**
74    * the transaction/session key used to identify a session
75    */
76   struct GNUNET_HashCode session_key;
77
78   /**
79    * the identity of a remote peer we want to communicate with
80    */
81   struct GNUNET_PeerIdentity peer;
82
83   /**
84    * followed by struct GNUNET_SCALARPRODUCT_Element[]
85    */
86 };
87
88
89 /**
90  * multipart messages following `struct ComputationMessage`
91  */
92 struct ComputationMultipartMessage
93 {
94   /**
95    * GNUNET message header
96    */
97   struct GNUNET_MessageHeader header;
98
99   /**
100    * contained elements the vector in payload contains
101    */
102   uint32_t element_count_contained GNUNET_PACKED;
103
104   /**
105    * followed by struct GNUNET_SCALARPRODUCT_Element[]
106    */
107 };
108
109
110 /**
111  * Message type passed from service client
112  * to finalize a session as requester or responder
113  */
114 struct ClientResponseMessage
115 {
116   /**
117    * GNUNET message header
118    */
119   struct GNUNET_MessageHeader header;
120
121   /**
122    * 0 if no product attached
123    */
124   uint32_t product_length GNUNET_PACKED;
125
126   /**
127    * status information about the outcome of this session
128    */
129   int32_t status GNUNET_PACKED;
130
131   /**
132    * Workaround for libgcrypt: -1 if negative, 0 if zero, else 1
133    */
134   int32_t range GNUNET_PACKED;
135
136   /**
137    * followed by product of length product_length (or nothing)
138    */
139 };
140
141 GNUNET_NETWORK_STRUCT_END
142
143 #ifdef  __cplusplus
144 }
145 #endif
146
147 #endif  /* SCALARPRODUCT_H */
148