modify zoneimport to deal with non-TLD zones due to difference in zone cuts between...
[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
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., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, USA.
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 /**
190  * Lookup a name for a zone hash
191  */
192 struct ZoneToNameMessage
193 {
194   /**
195    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
196    */
197   struct GNUNET_NAMESTORE_Header gns_header;
198
199   /**
200    * The private key of the zone to look up in
201    */
202   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
203
204   /**
205    * The public key of the target zone
206    */
207   struct GNUNET_CRYPTO_EcdsaPublicKey value_zone;
208 };
209
210
211 /**
212  * Respone for zone to name lookup
213  */
214 struct ZoneToNameResponseMessage
215 {
216   /**
217    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
218    */
219   struct GNUNET_NAMESTORE_Header gns_header;
220
221   /**
222    * Length of the name
223    */
224   uint16_t name_len GNUNET_PACKED;
225
226   /**
227    * Length of serialized record data
228    */
229   uint16_t rd_len GNUNET_PACKED;
230
231   /**
232    * Number of records contained
233    */
234   uint16_t rd_count GNUNET_PACKED;
235
236   /**
237    * result in NBO: #GNUNET_OK on success, #GNUNET_NO if there were no
238    * results, #GNUNET_SYSERR on error
239    */
240   int16_t res GNUNET_PACKED;
241
242   /**
243    * The private key of the zone that contained the name.
244    */
245   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
246
247   /* followed by:
248    * name with length name_len
249    * serialized record data with rd_count records
250    */
251
252 };
253
254
255 /**
256  * Record is returned from the namestore (as authority).
257  */
258 struct RecordResultMessage
259 {
260   /**
261    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT
262    */
263   struct GNUNET_NAMESTORE_Header gns_header;
264
265   /**
266    * Name length
267    */
268   uint16_t name_len GNUNET_PACKED;
269
270   /**
271    * Length of serialized record data
272    */
273   uint16_t rd_len GNUNET_PACKED;
274
275   /**
276    * Number of records contained
277    */
278   uint16_t rd_count GNUNET_PACKED;
279
280   /**
281    * always zero (for alignment)
282    */
283   uint16_t reserved GNUNET_PACKED;
284
285   /**
286    * The private key of the authority.
287    */
288   struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
289
290   /* followed by:
291    * name with length name_len
292    * serialized record data with rd_count records
293    */
294 };
295
296
297 /**
298  * Start monitoring a zone.
299  */
300 struct ZoneMonitorStartMessage
301 {
302   /**
303    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START
304    */
305   struct GNUNET_MessageHeader header;
306
307   /**
308    * #GNUNET_YES to first iterate over all records,
309    * #GNUNET_NO to only monitor changes.o
310    */
311   uint32_t iterate_first GNUNET_PACKED;
312
313   /**
314    * Zone key.
315    */
316   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
317
318 };
319
320
321 /**
322  * Start a zone iteration for the given zone
323  */
324 struct ZoneIterationStartMessage
325 {
326   /**
327    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
328    */
329   struct GNUNET_NAMESTORE_Header gns_header;
330
331   /**
332    * Zone key.  All zeros for "all zones".
333    */
334   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
335
336 };
337
338
339 /**
340  * Ask for next result of zone iteration for the given operation
341  */
342 struct ZoneIterationNextMessage
343 {
344   /**
345    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
346    */
347   struct GNUNET_NAMESTORE_Header gns_header;
348 };
349
350
351 /**
352  * Stop zone iteration for the given operation
353  */
354 struct ZoneIterationStopMessage
355 {
356   /**
357    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
358    */
359   struct GNUNET_NAMESTORE_Header gns_header;
360 };
361
362
363 GNUNET_NETWORK_STRUCT_END
364
365
366 /* end of namestore.h */
367 #endif