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_START 430
33 #define GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME 431
34 #define GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE 432
35 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT 433
36 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE 434
37 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE 435
38 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE 436
39 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE 437
40 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE 438
41 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME 439
42 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE 440
44 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START 445
45 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE 446
46 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT 447
47 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP 448
51 * Convert a short hash to a string (for printing debug messages).
52 * This is one of the very few calls in the entire API that is
55 * @param hc the short hash code
56 * @return string form; will be overwritten by next call to GNUNET_h2s.
59 GNUNET_short_h2s (const struct GNUNET_CRYPTO_ShortHashCode * hc);
63 * Sign name and records
65 * @param key the private key
66 * @param expire block expiration
67 * @param name the name
68 * @param rd record data
69 * @param rd_count number of records
71 * @return the signature
73 struct GNUNET_CRYPTO_RsaSignature *
74 GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
75 struct GNUNET_TIME_Absolute expire,
77 const struct GNUNET_NAMESTORE_RecordData *rd,
78 unsigned int rd_count);
81 * Compares if two records are equal
86 * @return GNUNET_YES or GNUNET_NO
89 GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a,
90 const struct GNUNET_NAMESTORE_RecordData *b);
93 GNUNET_NETWORK_STRUCT_BEGIN
95 * A GNS record serialized for network transmission.
97 * Layout is [struct GNUNET_NAMESTORE_NetworkRecord][char[data_size] data]
99 struct GNUNET_NAMESTORE_NetworkRecord
102 * Expiration time for the DNS record.
104 struct GNUNET_TIME_AbsoluteNBO expiration;
107 * Number of bytes in 'data'.
112 * Type of the GNS/DNS record.
114 uint32_t record_type;
117 * Flags for the record.
125 * Connect to namestore service. FIXME: UNNECESSARY.
131 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_START
133 struct GNUNET_MessageHeader header;
139 * Generic namestore message with op id
141 struct GNUNET_NAMESTORE_Header
144 * header.type will be GNUNET_MESSAGE_TYPE_NAMESTORE_*
145 * header.size will be message size
147 struct GNUNET_MessageHeader header;
157 * Lookup a name in the namestore
159 struct LookupNameMessage
161 struct GNUNET_NAMESTORE_Header gns_header;
166 struct GNUNET_CRYPTO_ShortHashCode zone;
169 * Requested record type
171 uint32_t record_type;
178 /* 0-terminated name here */
185 struct LookupNameResponseMessage
188 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE
190 struct GNUNET_NAMESTORE_Header gns_header;
195 struct GNUNET_TIME_AbsoluteNBO expire;
204 * Bytes of serialized record data
209 * Number of records contained
214 * Is the signature valid
215 * GNUNET_YES or GNUNET_NO
217 int16_t contains_sig;
220 * All zeros if 'contains_sig' is GNUNET_NO.
222 struct GNUNET_CRYPTO_RsaSignature signature;
225 * The public key for the name
227 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
229 /* 0-terminated name and serialized record data */
230 /* rd_len bytes serialized record data */
235 * Put a record to the namestore
237 struct RecordPutMessage
240 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_RECORD_PUT
242 struct GNUNET_NAMESTORE_Header gns_header;
247 struct GNUNET_TIME_AbsoluteNBO expire;
255 * Length of serialized record data
260 * Number of records contained
265 * always zero (for alignment)
272 struct GNUNET_CRYPTO_RsaSignature signature;
277 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
279 /* name (0-terminated) followed by "rd_count" serialized records */
285 * Put a record to the namestore response
287 struct RecordPutResponseMessage
290 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE
292 struct GNUNET_NAMESTORE_Header gns_header;
296 * GNUNET_SYSERR on failure
297 * GNUNET_OK on success
304 * Create a record and put it to the namestore
307 struct RecordCreateMessage
310 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE
312 struct GNUNET_NAMESTORE_Header gns_header;
314 struct GNUNET_TIME_AbsoluteNBO expire;
322 * Length of serialized record data
337 * GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded private key with length pkey_len
338 * name with length name_len
339 * serialized record data with length rd_len
345 * Create a record to the namestore response
347 struct RecordCreateResponseMessage
350 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE
352 struct GNUNET_NAMESTORE_Header gns_header;
355 * name length: GNUNET_NO already exists, GNUNET_YES on success, GNUNET_SYSERR error
362 * Remove a record from the namestore
365 struct RecordRemoveMessage
368 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE
370 struct GNUNET_NAMESTORE_Header gns_header;
378 * Length of serialized rd data
383 * Number of records contained
388 * Length of private key
393 * GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded private key with length pkey_len
394 * name with length name_len
395 * serialized record data with length rd_len
401 * Remove a record from the namestore response
403 struct RecordRemoveResponseMessage
406 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE
408 struct GNUNET_NAMESTORE_Header gns_header;
413 * 1 : no records for entry
414 * 2 : Could not find record to remove
415 * 3 : Failed to create new signature
416 * 4 : Failed to put new set of records in database
423 * Lookup a name for a zone hash
425 struct ZoneToNameMessage
428 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
430 struct GNUNET_NAMESTORE_Header gns_header;
433 * The hash of public key of the zone to look up in
435 struct GNUNET_CRYPTO_ShortHashCode zone;
438 * The hash of the public key of the target zone
440 struct GNUNET_CRYPTO_ShortHashCode value_zone;
444 * Respone for zone to name lookup
446 struct ZoneToNameResponseMessage
449 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
451 struct GNUNET_NAMESTORE_Header gns_header;
454 * Record block expiration
456 struct GNUNET_TIME_AbsoluteNBO expire;
464 * Length of serialized record data
469 * Number of records contained
473 /* result in NBO: GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error */
479 struct GNUNET_CRYPTO_RsaSignature signature;
484 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key;
491 * Start a zone iteration for the given zone
493 struct ZoneIterationStartMessage
496 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
498 struct GNUNET_NAMESTORE_Header gns_header;
503 struct GNUNET_CRYPTO_ShortHashCode zone;
506 * Which flags must be included
508 uint16_t must_have_flags;
511 * Which flags must not be included
513 uint16_t must_not_have_flags;
518 * Ask for next result of zone iteration for the given operation
520 struct ZoneIterationNextMessage
523 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
525 struct GNUNET_NAMESTORE_Header gns_header;
530 * Stop zone iteration for the given operation
532 struct ZoneIterationStopMessage
535 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
537 struct GNUNET_NAMESTORE_Header gns_header;
541 * Next result of zone iteration for the given operation
542 * // FIXME: use 'struct LookupResponseMessage' instead? (identical except
543 * for having 'contains_sig' instead of 'reserved', but fully compatible otherwise).
545 struct ZoneIterationResponseMessage
548 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE
550 struct GNUNET_NAMESTORE_Header gns_header;
552 struct GNUNET_TIME_AbsoluteNBO expire;
556 /* Record data length */
560 * Number of records contained
565 * always zero (for alignment)
570 * All zeros if 'contains_sig' is GNUNET_NO.
572 struct GNUNET_CRYPTO_RsaSignature signature;
577 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
582 GNUNET_NETWORK_STRUCT_END
585 /* end of namestore.h */