-fix
[oweals/gnunet.git] / src / namestore / namestore.h
1 /*
2      This file is part of GNUnet.
3      (C) 2009 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 namestore/namestore.h
23  * @brief common internal definitions for namestore service
24  * @author Matthias Wachs
25  */
26 #ifndef NAMESTORE_H
27 #define NAMESTORE_H
28
29 /*
30  * Collect message types here, move to protocols later
31  */
32 #define GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME 431
33 #define GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE 432
34 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT 433
35 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE 434
36 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE 435
37 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE 436
38 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE 437
39 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE 438
40
41 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START 439
42 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE 440
43 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT 441
44 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP 442
45
46
47 GNUNET_NETWORK_STRUCT_BEGIN
48 /**
49  * Connect to namestore service
50  */
51 struct StartMessage
52 {
53
54   /**
55    * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_START
56    */
57   struct GNUNET_MessageHeader header;
58
59 };
60 GNUNET_NETWORK_STRUCT_END
61
62
63 GNUNET_NETWORK_STRUCT_BEGIN
64 /**
65  * Generic namestore message with op id
66  */
67 struct GenericMessage
68 {
69   /**
70    * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_*
71    */
72   struct GNUNET_MessageHeader header;
73
74   /**
75    * Operation ID in NBO
76    */
77   uint32_t op_id;
78 };
79 GNUNET_NETWORK_STRUCT_END
80
81
82 /**
83  * Connect to namestore service
84  */
85 GNUNET_NETWORK_STRUCT_BEGIN
86 struct LookupNameMessage
87 {
88   /**
89    * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME
90    */
91   struct GNUNET_MessageHeader header;
92
93   /**
94    * Operation ID in NBO
95    */
96   uint32_t op_id;
97
98   /* The zone */
99   GNUNET_HashCode zone;
100
101   /* Requested record type */
102   uint32_t record_type;
103
104   /* Requested record type */
105   uint32_t name_len;
106 };
107 GNUNET_NETWORK_STRUCT_END
108
109
110 /**
111  * Lookup response
112  * Memory layout:
113  * [struct LookupNameResponseMessage][struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData][struct GNUNET_CRYPTO_RsaSignature]
114  */
115 GNUNET_NETWORK_STRUCT_BEGIN
116 struct LookupNameResponseMessage
117 {
118   /**
119    * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE
120    */
121   struct GNUNET_MessageHeader header;
122
123   /**
124    * Operation ID in NBO
125    */
126   uint32_t op_id;
127
128   struct GNUNET_TIME_AbsoluteNBO expire;
129
130   uint16_t name_len;
131
132   uint16_t contains_sig;
133
134   /* Requested record type */
135   uint32_t rc_count;
136 };
137 GNUNET_NETWORK_STRUCT_END
138
139
140 /**
141  * Put a record to the namestore
142  * Memory layout:
143  * [struct RecordPutMessage][struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData]
144  */
145 GNUNET_NETWORK_STRUCT_BEGIN
146 struct RecordPutMessage
147 {
148   /**
149    * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_RECORD_PUT
150    */
151   struct GNUNET_MessageHeader header;
152
153   /**
154    * Operation ID in NBO
155    */
156   uint32_t op_id;
157
158   /* Contenct starts here */
159
160   /* name length */
161   uint16_t name_len;
162
163   /* Requested record type */
164   uint32_t rd_count;
165
166   struct GNUNET_TIME_AbsoluteNBO expire;
167
168   struct GNUNET_CRYPTO_RsaSignature signature;
169 };
170 GNUNET_NETWORK_STRUCT_END
171
172 /**
173  * Put a record to the namestore response
174  */
175 GNUNET_NETWORK_STRUCT_BEGIN
176 struct RecordPutResponseMessage
177 {
178   /**
179    * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE
180    */
181   struct GNUNET_MessageHeader header;
182
183   /**
184    * Operation ID in NBO
185    */
186   uint32_t op_id;
187
188   /* Contenct starts here */
189
190   /**
191    *  name length: GNUNET_NO (0) on error, GNUNET_OK (1) on success
192    */
193   uint16_t op_result;
194 };
195 GNUNET_NETWORK_STRUCT_END
196
197
198 /**
199  * Put a record to the namestore
200  * Memory layout:
201  * [struct RecordPutMessage][struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData]
202  */
203 GNUNET_NETWORK_STRUCT_BEGIN
204 struct RecordCreateMessage
205 {
206   /**
207    * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE
208    */
209   struct GNUNET_MessageHeader header;
210
211   /**
212    * Operation ID in NBO
213    */
214   uint32_t op_id;
215
216   /* Contenct starts here */
217
218   /* name length */
219   uint16_t name_len;
220
221   struct GNUNET_CRYPTO_RsaSignature signature;
222 };
223 GNUNET_NETWORK_STRUCT_END
224
225
226 /**
227  * Create a record to the namestore response
228  * Memory layout:
229  */
230 GNUNET_NETWORK_STRUCT_BEGIN
231 struct RecordCreateResponseMessage
232 {
233   /**
234    * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE
235    */
236   struct GNUNET_MessageHeader header;
237
238   /**
239    * Operation ID in NBO
240    */
241   uint32_t op_id;
242
243   /* Contenct starts here */
244
245   /**
246    *  name length: GNUNET_NO (0) on error, GNUNET_OK (1) on success
247    */
248   uint16_t op_result;
249 };
250 GNUNET_NETWORK_STRUCT_END
251
252 /**
253  * Remove a record from the namestore
254  * Memory layout:
255  * [struct RecordRemoveMessage][char *name][struct GNUNET_NAMESTORE_RecordData]
256  */
257 GNUNET_NETWORK_STRUCT_BEGIN
258 struct RecordRemoveMessage
259 {
260   /**
261    * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE
262    */
263   struct GNUNET_MessageHeader header;
264
265   /**
266    * Operation ID in NBO
267    */
268   uint32_t op_id;
269
270   /* Contenct starts here */
271
272   /* name length */
273   uint16_t name_len;
274
275   struct GNUNET_CRYPTO_RsaSignature signature;
276 };
277 GNUNET_NETWORK_STRUCT_END
278
279
280 /**
281  * Remove a record from the namestore response
282  */
283 GNUNET_NETWORK_STRUCT_BEGIN
284 struct RecordRemoveResponseMessage
285 {
286   /**
287    * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE
288    */
289   struct GNUNET_MessageHeader header;
290
291   /**
292    * Operation ID in NBO
293    */
294   uint32_t op_id;
295
296   /* Contenct starts here */
297
298   /**
299    *  name length: GNUNET_NO (0) on error, GNUNET_OK (1) on success
300    */
301   uint16_t op_result;
302 };
303 GNUNET_NETWORK_STRUCT_END
304
305
306 /**
307  * Start a zone iteration for the given zone
308  */
309 GNUNET_NETWORK_STRUCT_BEGIN
310 struct ZoneIterationStartMessage
311 {
312   /**
313    * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
314    */
315   struct GNUNET_MessageHeader header;
316
317   /**
318    * Operation ID in NBO
319    */
320   uint32_t op_id;
321
322   /* Contenct starts here */
323
324   uint16_t must_have_flags;
325   uint16_t must_not_have_flags;
326
327   GNUNET_HashCode zone;
328 };
329 GNUNET_NETWORK_STRUCT_END
330
331 /**
332  * Ask for next result of zone iteration for the given operation
333  */
334 GNUNET_NETWORK_STRUCT_BEGIN
335 struct ZoneIterationNextMessage
336 {
337   /**
338    * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
339    */
340   struct GNUNET_MessageHeader header;
341
342   /**
343    * Operation ID in NBO
344    */
345   uint32_t op_id;
346 };
347 GNUNET_NETWORK_STRUCT_END
348
349
350 /**
351  * Stop zone iteration for the given operation
352  */
353 GNUNET_NETWORK_STRUCT_BEGIN
354 struct ZoneIterationStopMessage
355 {
356   /**
357    * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
358    */
359   struct GNUNET_MessageHeader header;
360
361   /**
362    * Operation ID in NBO
363    */
364   uint32_t op_id;
365 };
366 GNUNET_NETWORK_STRUCT_END
367
368 /**
369  * Ask for next result of zone iteration for the given operation
370  */
371 GNUNET_NETWORK_STRUCT_BEGIN
372 struct ZoneIterationResponseMessage
373 {
374   /**
375    * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE
376    */
377   struct GNUNET_MessageHeader header;
378
379   /**
380    * Operation ID in NBO
381    */
382   uint32_t op_id;
383 };
384 GNUNET_NETWORK_STRUCT_END
385
386
387 /* end of namestore.h */
388 #endif