-remove debug message
[oweals/gnunet.git] / src / namestore / namestore.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2011-2013 GNUnet e.V.
4
5      GNUnet is free software: you can redistribute it and/or modify it
6      under the terms of the GNU Affero General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your 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      Affero General Public License for more details.
14
15      You should have received a copy of the GNU Affero General Public License
16      along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18      SPDX-License-Identifier: AGPL3.0-or-later
19  */
20
21 /**
22  * @file namestore/namestore.h
23  * @brief common internal definitions for namestore service
24  * @author Matthias Wachs
25  * @author Christian Grothoff
26  */
27 #ifndef NAMESTORE_H
28 #define NAMESTORE_H
29
30 /**
31  * Maximum length of any name, including 0-termination.
32  */
33 #define MAX_NAME_LEN 256
34
35 GNUNET_NETWORK_STRUCT_BEGIN
36
37 /**
38  * Generic namestore message with op id
39  */
40 struct GNUNET_NAMESTORE_Header
41 {
42   /**
43    * header.type will be GNUNET_MESSAGE_TYPE_NAMESTORE_*
44    * header.size will be message size
45    */
46   struct GNUNET_MessageHeader header;
47
48   /**
49    * Request ID in NBO
50    */
51   uint32_t r_id GNUNET_PACKED;
52 };
53
54
55 /**
56  * Store a record to the namestore (as authority).
57  */
58 struct RecordStoreMessage
59 {
60   /**
61    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE
62    */
63   struct GNUNET_NAMESTORE_Header gns_header;
64
65   /**
66    * Expiration time
67    */
68   struct GNUNET_TIME_AbsoluteNBO expire;
69
70   /**
71    * Name length
72    */
73   uint16_t name_len GNUNET_PACKED;
74
75   /**
76    * Length of serialized record data
77    */
78   uint16_t rd_len GNUNET_PACKED;
79
80   /**
81    * Number of records contained
82    */
83   uint16_t rd_count GNUNET_PACKED;
84
85   /**
86    * always zero (for alignment)
87    */
88   uint16_t reserved GNUNET_PACKED;
89
90   /**
91    * The private key of the authority.
92    */
93   struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
94
95   /* followed by:
96    * name with length name_len
97    * serialized record data with rd_count records
98    */
99 };
100
101
102 /**
103  * Response to a record storage request.
104  */
105 struct RecordStoreResponseMessage
106 {
107   /**
108    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE
109    */
110   struct GNUNET_NAMESTORE_Header gns_header;
111
112   /**
113    * #GNUNET_SYSERR on failure, #GNUNET_OK on success
114    */
115   int32_t op_result GNUNET_PACKED;
116 };
117
118
119 /**
120  * Lookup a label
121  */
122 struct LabelLookupMessage
123 {
124   /**
125    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP
126    */
127   struct GNUNET_NAMESTORE_Header gns_header;
128
129   /**
130    * Length of the name
131    */
132   uint32_t label_len GNUNET_PACKED;
133
134   /**
135    * The private key of the zone to look up in
136    */
137   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
138
139   /* followed by:
140    * name with length name_len
141    */
142 };
143
144
145 /**
146  * Lookup a label
147  */
148 struct LabelLookupResponseMessage
149 {
150   /**
151    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE
152    */
153   struct GNUNET_NAMESTORE_Header gns_header;
154
155   /**
156    * Name length
157    */
158   uint16_t name_len GNUNET_PACKED;
159
160   /**
161    * Length of serialized record data
162    */
163   uint16_t rd_len GNUNET_PACKED;
164
165   /**
166    * Number of records contained
167    */
168   uint16_t rd_count GNUNET_PACKED;
169
170   /**
171    * Was the label found in the database??
172    * #GNUNET_YES or #GNUNET_NO
173    */
174   uint16_t found GNUNET_PACKED;
175
176   /**
177    * The private key of the authority.
178    */
179   struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
180
181   /* followed by:
182    * name with length name_len
183    * serialized record data with rd_count records
184    */
185 };
186
187
188 /**
189  * Lookup a name for a zone hash
190  */
191 struct ZoneToNameMessage
192 {
193   /**
194    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
195    */
196   struct GNUNET_NAMESTORE_Header gns_header;
197
198   /**
199    * The private key of the zone to look up in
200    */
201   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
202
203   /**
204    * The public key of the target zone
205    */
206   struct GNUNET_CRYPTO_EcdsaPublicKey value_zone;
207 };
208
209
210 /**
211  * Respone for zone to name lookup
212  */
213 struct ZoneToNameResponseMessage
214 {
215   /**
216    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
217    */
218   struct GNUNET_NAMESTORE_Header gns_header;
219
220   /**
221    * Length of the name
222    */
223   uint16_t name_len GNUNET_PACKED;
224
225   /**
226    * Length of serialized record data
227    */
228   uint16_t rd_len GNUNET_PACKED;
229
230   /**
231    * Number of records contained
232    */
233   uint16_t rd_count GNUNET_PACKED;
234
235   /**
236    * result in NBO: #GNUNET_OK on success, #GNUNET_NO if there were no
237    * results, #GNUNET_SYSERR on error
238    */
239   int16_t res GNUNET_PACKED;
240
241   /**
242    * The private key of the zone that contained the name.
243    */
244   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
245
246   /* followed by:
247    * name with length name_len
248    * serialized record data with rd_count records
249    */
250 };
251
252
253 /**
254  * Record is returned from the namestore (as authority).
255  */
256 struct RecordResultMessage
257 {
258   /**
259    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT
260    */
261   struct GNUNET_NAMESTORE_Header gns_header;
262
263   /**
264    * Name length
265    */
266   uint16_t name_len GNUNET_PACKED;
267
268   /**
269    * Length of serialized record data
270    */
271   uint16_t rd_len GNUNET_PACKED;
272
273   /**
274    * Number of records contained
275    */
276   uint16_t rd_count GNUNET_PACKED;
277
278   /**
279    * always zero (for alignment)
280    */
281   uint16_t reserved GNUNET_PACKED;
282
283   /**
284    * The private key of the authority.
285    */
286   struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
287
288   /* followed by:
289    * name with length name_len
290    * serialized record data with rd_count records
291    */
292 };
293
294
295 /**
296  * Start monitoring a zone.
297  */
298 struct ZoneMonitorStartMessage
299 {
300   /**
301    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START
302    */
303   struct GNUNET_MessageHeader header;
304
305   /**
306    * #GNUNET_YES to first iterate over all records,
307    * #GNUNET_NO to only monitor changes.o
308    */
309   uint32_t iterate_first GNUNET_PACKED;
310
311   /**
312    * Zone key.
313    */
314   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
315 };
316
317
318 /**
319  * Ask for next result of zone iteration for the given operation
320  */
321 struct ZoneMonitorNextMessage
322 {
323   /**
324    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT
325    */
326   struct GNUNET_MessageHeader header;
327
328   /**
329    * Always zero.
330    */
331   uint32_t reserved;
332
333   /**
334    * Number of records to return to the iterator in one shot
335    * (before #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_MONITOR_NEXT
336    * should be send again). In NBO.
337    */
338   uint64_t limit;
339 };
340
341
342 /**
343  * Start a zone iteration for the given zone
344  */
345 struct ZoneIterationStartMessage
346 {
347   /**
348    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
349    */
350   struct GNUNET_NAMESTORE_Header gns_header;
351
352   /**
353    * Zone key.  All zeros for "all zones".
354    */
355   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
356 };
357
358
359 /**
360  * Ask for next result of zone iteration for the given operation
361  */
362 struct ZoneIterationNextMessage
363 {
364   /**
365    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
366    */
367   struct GNUNET_NAMESTORE_Header gns_header;
368
369   /**
370    * Number of records to return to the iterator in one shot
371    * (before #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
372    * should be send again). In NBO.
373    */
374   uint64_t limit;
375 };
376
377
378 /**
379  * Stop zone iteration for the given operation
380  */
381 struct ZoneIterationStopMessage
382 {
383   /**
384    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
385    */
386   struct GNUNET_NAMESTORE_Header gns_header;
387 };
388
389
390 GNUNET_NETWORK_STRUCT_END
391
392
393 /* end of namestore.h */
394 #endif