2 This file is part of GNUnet.
3 (C) 2009 Christian Grothoff (and other contributing authors)
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.
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.
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.
22 * @file namestore/namestore.h
23 * @brief common internal definitions for namestore service
24 * @author Matthias Wachs
30 * Collect message types here, move to protocols later
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 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME 439
41 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE 440
43 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START 445
44 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE 446
45 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT 447
46 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP 448
47 #define GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT 449
50 * Sign name and records
52 * @param key the private key
53 * @param name the name
54 * @param rd record data
55 * @param rd_count number of records
57 * @return the signature
59 struct GNUNET_CRYPTO_RsaSignature *
60 GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key, const char *name, struct GNUNET_NAMESTORE_RecordData *rd, unsigned int rd_count);
63 * Compares if two records are equal
68 * @return GNUNET_YES or GNUNET_NO
71 GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a,
72 const struct GNUNET_NAMESTORE_RecordData *b);
74 GNUNET_NETWORK_STRUCT_BEGIN
76 * A GNS record serialized for network transmission.
77 * layout is [struct GNUNET_NAMESTORE_NetworkRecord][char[data_size] data]
79 struct GNUNET_NAMESTORE_NetworkRecord
82 * Expiration time for the DNS record.
84 struct GNUNET_TIME_AbsoluteNBO expiration;
87 * Number of bytes in 'data'.
92 * Type of the GNS/DNS record.
97 * Flags for the record.
105 * Connect to namestore service. FIXME: UNNECESSARY.
111 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_START
113 struct GNUNET_MessageHeader header;
118 * Connect to namestore service. FIXME: UNNECESSARY.
120 struct DisconnectMessage
124 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT
126 struct GNUNET_MessageHeader header;
130 * GNUNET_YES or _NO in NBO
137 * Generic namestore message with op id
139 struct GNUNET_NAMESTORE_Header
142 * header.type will be GNUNET_MESSAGE_TYPE_NAMESTORE_*
143 * header.size will be message size
145 struct GNUNET_MessageHeader header;
155 * Connect to namestore service
157 struct LookupNameMessage
159 struct GNUNET_NAMESTORE_Header gns_header;
164 GNUNET_HashCode zone;
167 * Requested record type
169 uint32_t record_type;
176 /* 0-terminated name here */
183 * [struct LookupNameResponseMessage][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData]
185 struct LookupNameResponseMessage
188 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE
190 struct GNUNET_NAMESTORE_Header gns_header;
192 struct GNUNET_TIME_AbsoluteNBO expire;
200 int16_t contains_sig;
203 * All zeros if 'contains_sig' is GNUNET_NO.
205 struct GNUNET_CRYPTO_RsaSignature signature;
210 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
212 /* 0-terminated name and serialized record data */
217 * Put a record to the namestore
219 * [struct RecordPutMessage][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData]
221 struct RecordPutMessage
224 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_RECORD_PUT
226 struct GNUNET_NAMESTORE_Header gns_header;
231 struct GNUNET_TIME_AbsoluteNBO expire;
239 * Length of serialized rd data
244 * Number of records contained
249 * always zero (for alignment)
256 struct GNUNET_CRYPTO_RsaSignature signature;
261 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
263 /* name (0-terminated) followed by "rd_count" serialized records */
269 * Put a record to the namestore response
271 struct RecordPutResponseMessage
274 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE
276 struct GNUNET_NAMESTORE_Header gns_header;
279 * name length: GNUNET_NO (0) on error, GNUNET_OK (1) on success
286 * Create a record and put it to the namestore
288 * [struct RecordCreateMessage][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData]
290 struct RecordCreateMessage
293 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE
295 struct GNUNET_NAMESTORE_Header gns_header;
297 struct GNUNET_TIME_AbsoluteNBO expire;
319 /* followed by: name and serialized record data --- PK??? */
324 * Create a record to the namestore response
327 struct RecordCreateResponseMessage
330 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE
332 struct GNUNET_NAMESTORE_Header gns_header;
335 * name length: GNUNET_NO already exists, GNUNET_YES on success, GNUNET_SYSERR error
343 * Remove a record from the namestore
345 * [struct RecordRemoveMessage][char *name][struct GNUNET_NAMESTORE_RecordData]
347 struct RecordRemoveMessage
350 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE
352 struct GNUNET_NAMESTORE_Header gns_header;
360 * Length of serialized rd data
365 * Number of records contained
377 * Remove a record from the namestore response
379 struct RecordRemoveResponseMessage
382 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE
384 struct GNUNET_NAMESTORE_Header gns_header;
389 * 1 : no records for entry
390 * 2 : Could not find record to remove
391 * 3 : Failed to create new signature
392 * 4 : Failed to put new set of records in database
399 * Connect to namestore service
401 struct ZoneToNameMessage
403 struct GNUNET_NAMESTORE_Header gns_header;
406 * The hash of public key of the zone to look up in
408 GNUNET_HashCode zone;
411 * The hash of the public key of the target zone
413 GNUNET_HashCode value_zone;
417 * Connect to namestore service
419 struct ZoneToNameResponseMessage
421 struct GNUNET_NAMESTORE_Header gns_header;
423 struct GNUNET_TIME_AbsoluteNBO expire;
431 /* result in NBO: GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error */
437 struct GNUNET_CRYPTO_RsaSignature signature;
439 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key;
446 * Start a zone iteration for the given zone
448 struct ZoneIterationStartMessage
451 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
453 struct GNUNET_NAMESTORE_Header gns_header;
455 GNUNET_HashCode zone;
457 uint16_t must_have_flags;
459 uint16_t must_not_have_flags;
465 * Ask for next result of zone iteration for the given operation
467 struct ZoneIterationNextMessage
470 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
472 struct GNUNET_NAMESTORE_Header gns_header;
477 * Stop zone iteration for the given operation
479 struct ZoneIterationStopMessage
482 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
484 struct GNUNET_NAMESTORE_Header gns_header;
488 * Next result of zone iteration for the given operation
489 * // FIXME: use 'struct LookupResponseMessage' instead? (identical except
490 * for having 'contains_sig' instead of 'reserved', but fully compatible otherwise).
492 struct ZoneIterationResponseMessage
495 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE
497 struct GNUNET_NAMESTORE_Header gns_header;
499 struct GNUNET_TIME_AbsoluteNBO expire;
503 /* Record data length */
507 * Number of records contained
512 * always zero (for alignment)
517 * All zeros if 'contains_sig' is GNUNET_NO.
519 struct GNUNET_CRYPTO_RsaSignature signature;
524 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
529 GNUNET_NETWORK_STRUCT_END
532 /* end of namestore.h */