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