aboutsummaryrefslogtreecommitdiff
path: root/src/service/namestore/namestore.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/namestore/namestore.h')
-rw-r--r--src/service/namestore/namestore.h603
1 files changed, 603 insertions, 0 deletions
diff --git a/src/service/namestore/namestore.h b/src/service/namestore/namestore.h
new file mode 100644
index 000000000..2ace6a83e
--- /dev/null
+++ b/src/service/namestore/namestore.h
@@ -0,0 +1,603 @@
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
35GNUNET_NETWORK_STRUCT_BEGIN
36
37/**
38 * Generic namestore message with op id
39 */
40struct 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
54struct RecordSet
55{
56 /**
57 * Name length
58 */
59 uint16_t name_len GNUNET_PACKED;
60
61 /**
62 * Length of serialized record data
63 */
64 uint16_t rd_len GNUNET_PACKED;
65
66 /**
67 * Number of records contained
68 */
69 uint16_t rd_count GNUNET_PACKED;
70
71 /**
72 * Reserved for alignment.
73 */
74 uint16_t reserved GNUNET_PACKED;
75
76
77 /* followed by:
78 * name with length name_len
79 * serialized record data with rd_count records
80 */
81};
82
83/**
84 * Store a record to the namestore (as authority).
85 */
86struct RecordStoreMessage
87{
88 /**
89 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE
90 */
91 struct GNUNET_NAMESTORE_Header gns_header;
92
93 /**
94 * Number of record sets
95 */
96 uint16_t rd_set_count;
97
98 /**
99 * Length of the zone key
100 */
101 uint16_t key_len GNUNET_PACKED;
102
103 /**
104 * Followed by the private zone key
105 * Followed by rd_set_count RecordSets
106 */
107};
108
109
110/**
111 * Response to a record storage request.
112 */
113struct NamestoreResponseMessage
114{
115 /**
116 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_GENERIC_RESPONSE
117 */
118 struct GNUNET_NAMESTORE_Header gns_header;
119
120 /**
121 * GNUNET_ErrorCode
122 */
123 uint32_t ec GNUNET_PACKED;
124
125};
126
127/**
128 * Response to RecordSetEditMessage.
129 */
130struct EditRecordSetResponseMessage
131{
132 /**
133 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE
134 */
135 struct GNUNET_NAMESTORE_Header gns_header;
136
137 /**
138 * Length of the editor hint
139 */
140 uint16_t editor_hint_len GNUNET_PACKED;
141
142 /**
143 * Reserved
144 */
145 uint16_t ec GNUNET_PACKED;
146
147 /**
148 * Length of serialized record data
149 */
150 uint16_t rd_len GNUNET_PACKED;
151
152 /**
153 * Number of records contained
154 */
155 uint16_t rd_count GNUNET_PACKED;
156
157 /**
158 * Followed by editor hint
159 * Followed by record set
160 */
161};
162
163
164/**
165 * Lookup a label
166 */
167struct LabelLookupMessage
168{
169 /**
170 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP
171 */
172 struct GNUNET_NAMESTORE_Header gns_header;
173
174 /**
175 * Length of the name
176 */
177 uint16_t label_len GNUNET_PACKED;
178
179 /**
180 * Unused
181 */
182 uint16_t unused GNUNET_PACKED;
183
184 /**
185 * The record filter
186 */
187 uint16_t filter;
188
189 /**
190 * Length of the zone key
191 */
192 uint16_t key_len GNUNET_PACKED;
193
194 /* followed by:
195 * the private zone key
196 * name with length name_len
197 */
198};
199
200/**
201 * Edit a record set and set editor hint/advisory lock.
202 */
203struct EditRecordSetMessage
204{
205 /**
206 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_EDIT_RECORD_SET
207 */
208 struct GNUNET_NAMESTORE_Header gns_header;
209
210 /**
211 * Length of the name
212 */
213 uint16_t label_len GNUNET_PACKED;
214
215 /**
216 * Unused
217 */
218 uint16_t editor_hint_len GNUNET_PACKED;
219
220 /**
221 * Unused
222 */
223 uint16_t reserved GNUNET_PACKED;
224
225 /**
226 * Length of the zone key
227 */
228 uint16_t key_len GNUNET_PACKED;
229
230 /* followed by:
231 * the private zone key
232 * label with length label_len
233 * editor hint with length editor_hint_len
234 */
235};
236
237
238/**
239 * Edit a record set and set editor hint/advisory lock.
240 */
241struct EditRecordSetCancelMessage
242{
243 /**
244 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_EDIT_RECORD_SET_CANCEL
245 */
246 struct GNUNET_NAMESTORE_Header gns_header;
247
248 /**
249 * Length of the name
250 */
251 uint16_t label_len GNUNET_PACKED;
252
253 /**
254 * Unused
255 */
256 uint16_t editor_hint_len GNUNET_PACKED;
257
258 /**
259 * Unused
260 */
261 uint16_t editor_hint_replacement_len GNUNET_PACKED;
262
263 /**
264 * Length of the zone key
265 */
266 uint16_t key_len GNUNET_PACKED;
267
268 /* followed by:
269 * the private zone key
270 * label with length label_len
271 * editor hint with length editor_hint_len
272 * replacement editor hint with length editor_hint_replacement_len
273 */
274};
275
276
277/**
278 * Lookup a label
279 */
280struct LabelLookupResponseMessage
281{
282 /**
283 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE
284 */
285 struct GNUNET_NAMESTORE_Header gns_header;
286
287 /**
288 * Name length
289 */
290 uint16_t name_len GNUNET_PACKED;
291
292 /**
293 * Length of serialized record data
294 */
295 uint16_t rd_len GNUNET_PACKED;
296
297 /**
298 * Number of records contained
299 */
300 uint16_t rd_count GNUNET_PACKED;
301
302 /**
303 * Was the label found in the database??
304 * #GNUNET_YES or #GNUNET_NO
305 */
306 int16_t found GNUNET_PACKED;
307
308 /**
309 * Reserved (alignment)
310 */
311 uint16_t reserved GNUNET_PACKED;
312
313 /**
314 * Length of the zone key
315 */
316 uint16_t key_len GNUNET_PACKED;
317
318 /* followed by:
319 * the private zone key
320 * name with length name_len
321 * serialized record data with rd_count records
322 */
323};
324
325
326/**
327 * Lookup a name for a zone hash
328 */
329struct ZoneToNameMessage
330{
331 /**
332 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
333 */
334 struct GNUNET_NAMESTORE_Header gns_header;
335
336 /**
337 * Length of the zone key
338 */
339 uint16_t key_len GNUNET_PACKED;
340
341 /**
342 * Length of the public value zone key
343 */
344 uint16_t pkey_len GNUNET_PACKED;
345
346 /**
347 * Followed by
348 * - the private zone key to look up in
349 * - the public key of the target zone
350 */
351};
352
353
354/**
355 * Respone for zone to name lookup
356 */
357struct ZoneToNameResponseMessage
358{
359 /**
360 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
361 */
362 struct GNUNET_NAMESTORE_Header gns_header;
363
364 /**
365 * result in NBO: #GNUNET_EC_NONE on success,
366 * #GNUNET_EC_NAMESTORE_NO_RESULTS if there were no
367 * results.
368 * Other error messages on error.
369 */
370 int32_t ec GNUNET_PACKED;
371
372 /**
373 * Length of the name
374 */
375 uint16_t name_len GNUNET_PACKED;
376
377 /**
378 * Length of serialized record data
379 */
380 uint16_t rd_len GNUNET_PACKED;
381
382 /**
383 * Number of records contained
384 */
385 uint16_t rd_count GNUNET_PACKED;
386
387 /**
388 * Length of the zone key
389 */
390 uint16_t key_len GNUNET_PACKED;
391
392 /* followed by:
393 * the private zone key
394 * name with length name_len
395 * serialized record data with rd_count records
396 */
397};
398
399
400/**
401 * Record is returned from the namestore (as authority).
402 */
403struct RecordResultMessage
404{
405 /**
406 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT
407 */
408 struct GNUNET_NAMESTORE_Header gns_header;
409
410 /**
411 * Expiration time if the record result (if any).
412 * Takes TOMBSTONEs into account.
413 */
414 struct GNUNET_TIME_AbsoluteNBO expire;
415
416 /**
417 * Name length
418 */
419 uint16_t name_len GNUNET_PACKED;
420
421 /**
422 * Length of serialized record data
423 */
424 uint16_t rd_len GNUNET_PACKED;
425
426 /**
427 * Number of records contained
428 */
429 uint16_t rd_count GNUNET_PACKED;
430
431 /**
432 * Length of the zone key
433 */
434 uint16_t key_len GNUNET_PACKED;
435
436 /* followed by:
437 * the private key of the authority
438 * name with length name_len
439 * serialized record data with rd_count records
440 */
441};
442
443/**
444 * Send a transaction control message.
445 */
446struct TxControlMessage
447{
448 /**
449 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL
450 */
451 struct GNUNET_NAMESTORE_Header gns_header;
452
453 /**
454 * always zero (for alignment)
455 */
456 uint16_t reserved GNUNET_PACKED;
457
458 /**
459 * The type of control message to send
460 */
461 uint16_t control GNUNET_PACKED;
462
463};
464
465/**
466 * Result of a transaction control message.
467 */
468struct TxControlResultMessage
469{
470 /**
471 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT
472 */
473 struct GNUNET_NAMESTORE_Header gns_header;
474
475 /**
476 * Of type GNUNET_ErrorCode
477 */
478 uint32_t ec GNUNET_PACKED;
479
480};
481
482
483
484/**
485 * Start monitoring a zone.
486 */
487struct ZoneMonitorStartMessage
488{
489 /**
490 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START
491 */
492 struct GNUNET_MessageHeader header;
493
494 /**
495 * #GNUNET_YES to first iterate over all records,
496 * #GNUNET_NO to only monitor changes.o
497 */
498 uint32_t iterate_first GNUNET_PACKED;
499
500 /**
501 * Record set filter control flags.
502 * See GNUNET_NAMESTORE_Filter enum.
503 */
504 uint16_t filter;
505
506 /**
507 * Length of the zone key
508 */
509 uint16_t key_len GNUNET_PACKED;
510
511 /**
512 * Followed by the private zone key.
513 */
514};
515
516
517/**
518 * Ask for next result of zone iteration for the given operation
519 */
520struct ZoneMonitorNextMessage
521{
522 /**
523 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT
524 */
525 struct GNUNET_MessageHeader header;
526
527 /**
528 * Always zero.
529 */
530 uint32_t reserved;
531
532 /**
533 * Number of records to return to the iterator in one shot
534 * (before #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_MONITOR_NEXT
535 * should be send again). In NBO.
536 */
537 uint64_t limit;
538};
539
540
541/**
542 * Start a zone iteration for the given zone
543 */
544struct ZoneIterationStartMessage
545{
546 /**
547 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
548 */
549 struct GNUNET_NAMESTORE_Header gns_header;
550
551 /**
552 * Record set filter control flags.
553 * See GNUNET_NAMESTORE_Filter enum.
554 */
555 uint16_t filter;
556
557 /**
558 * Length of the zone key
559 */
560 uint16_t key_len GNUNET_PACKED;
561
562 /**
563 * Followed by the private zone key (optional)
564 */
565};
566
567
568/**
569 * Ask for next result of zone iteration for the given operation
570 */
571struct ZoneIterationNextMessage
572{
573 /**
574 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
575 */
576 struct GNUNET_NAMESTORE_Header gns_header;
577
578 /**
579 * Number of records to return to the iterator in one shot
580 * (before #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
581 * should be send again). In NBO.
582 */
583 uint64_t limit;
584};
585
586
587/**
588 * Stop zone iteration for the given operation
589 */
590struct ZoneIterationStopMessage
591{
592 /**
593 * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
594 */
595 struct GNUNET_NAMESTORE_Header gns_header;
596};
597
598
599GNUNET_NETWORK_STRUCT_END
600
601
602/* end of namestore.h */
603#endif