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 * Maximum length of any name, including 0-termination.
32 #define MAX_NAME_LEN 256
37 * Collect message types here, move to protocols later
39 #define GNUNET_MESSAGE_TYPE_NAMESTORE_START 430
40 #define GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME 431
41 #define GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE 432
42 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT 433
43 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE 434
44 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE 435
45 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE 436
46 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE 437
47 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE 438
48 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME 439
49 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE 440
51 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START 445
52 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE 446
53 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT 447
54 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP 448
58 * Convert a short hash to a string (for printing debug messages).
59 * This is one of the very few calls in the entire API that is
62 * @param hc the short hash code
63 * @return string form; will be overwritten by next call to GNUNET_h2s.
66 GNUNET_short_h2s (const struct GNUNET_CRYPTO_ShortHashCode * hc);
70 * Sign name and records
72 * @param key the private key
73 * @param expire block expiration
74 * @param name the name
75 * @param rd record data
76 * @param rd_count number of records
78 * @return the signature
80 struct GNUNET_CRYPTO_RsaSignature *
81 GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
82 struct GNUNET_TIME_Absolute expire,
84 const struct GNUNET_NAMESTORE_RecordData *rd,
85 unsigned int rd_count);
89 * Compares if two records are equal
94 * @return GNUNET_YES or GNUNET_NO
97 GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a,
98 const struct GNUNET_NAMESTORE_RecordData *b);
101 GNUNET_NETWORK_STRUCT_BEGIN
103 * A GNS record serialized for network transmission.
105 * Layout is [struct GNUNET_NAMESTORE_NetworkRecord][char[data_size] data]
107 struct GNUNET_NAMESTORE_NetworkRecord
110 * Expiration time for the DNS record.
112 struct GNUNET_TIME_AbsoluteNBO expiration;
115 * Number of bytes in 'data'.
120 * Type of the GNS/DNS record.
122 uint32_t record_type;
125 * Flags for the record.
133 * Connect to namestore service. FIXME: UNNECESSARY.
139 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_START
141 struct GNUNET_MessageHeader header;
147 * Generic namestore message with op id
149 struct GNUNET_NAMESTORE_Header
152 * header.type will be GNUNET_MESSAGE_TYPE_NAMESTORE_*
153 * header.size will be message size
155 struct GNUNET_MessageHeader header;
165 * Lookup a name in the namestore
167 struct LookupNameMessage
169 struct GNUNET_NAMESTORE_Header gns_header;
174 struct GNUNET_CRYPTO_ShortHashCode zone;
177 * Requested record type
179 uint32_t record_type;
186 /* 0-terminated name here */
193 struct LookupNameResponseMessage
196 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE
198 struct GNUNET_NAMESTORE_Header gns_header;
203 struct GNUNET_TIME_AbsoluteNBO expire;
212 * Bytes of serialized record data
217 * Number of records contained
222 * Is the signature valid
223 * GNUNET_YES or GNUNET_NO
225 int16_t contains_sig;
228 * All zeros if 'contains_sig' is GNUNET_NO.
230 struct GNUNET_CRYPTO_RsaSignature signature;
233 * The public key for the name
235 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
237 /* 0-terminated name and serialized record data */
238 /* rd_len bytes serialized record data */
243 * Put a record to the namestore
245 struct RecordPutMessage
248 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_RECORD_PUT
250 struct GNUNET_NAMESTORE_Header gns_header;
255 struct GNUNET_TIME_AbsoluteNBO expire;
263 * Length of serialized record data
268 * Number of records contained
273 * always zero (for alignment)
280 struct GNUNET_CRYPTO_RsaSignature signature;
285 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
287 /* name (0-terminated) followed by "rd_count" serialized records */
293 * Put a record to the namestore response
295 struct RecordPutResponseMessage
298 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE
300 struct GNUNET_NAMESTORE_Header gns_header;
304 * GNUNET_SYSERR on failure
305 * GNUNET_OK on success
312 * Create a record and put it to the namestore
315 struct RecordCreateMessage
318 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE
320 struct GNUNET_NAMESTORE_Header gns_header;
322 struct GNUNET_TIME_AbsoluteNBO expire;
330 * Length of serialized record data
345 * GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded private key with length pkey_len
346 * name with length name_len
347 * serialized record data with length rd_len
353 * Create a record to the namestore response
355 struct RecordCreateResponseMessage
358 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE
360 struct GNUNET_NAMESTORE_Header gns_header;
363 * name length: GNUNET_NO already exists, GNUNET_YES on success, GNUNET_SYSERR error
370 * Remove a record from the namestore
373 struct RecordRemoveMessage
376 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE
378 struct GNUNET_NAMESTORE_Header gns_header;
386 * Length of serialized rd data
391 * Number of records contained
396 * Length of private key
401 * GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded private key with length pkey_len
402 * name with length name_len
403 * serialized record data with length rd_len
409 * Remove a record from the namestore response
411 struct RecordRemoveResponseMessage
414 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE
416 struct GNUNET_NAMESTORE_Header gns_header;
421 * 1 : no records for entry
422 * 2 : Could not find record to remove
423 * 3 : Failed to create new signature
424 * 4 : Failed to put new set of records in database
431 * Lookup a name for a zone hash
433 struct ZoneToNameMessage
436 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
438 struct GNUNET_NAMESTORE_Header gns_header;
441 * The hash of public key of the zone to look up in
443 struct GNUNET_CRYPTO_ShortHashCode zone;
446 * The hash of the public key of the target zone
448 struct GNUNET_CRYPTO_ShortHashCode value_zone;
452 * Respone for zone to name lookup
454 struct ZoneToNameResponseMessage
457 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
459 struct GNUNET_NAMESTORE_Header gns_header;
462 * Record block expiration
464 struct GNUNET_TIME_AbsoluteNBO expire;
472 * Length of serialized record data
477 * Number of records contained
481 /* result in NBO: GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error */
487 struct GNUNET_CRYPTO_RsaSignature signature;
492 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key;
499 * Start a zone iteration for the given zone
501 struct ZoneIterationStartMessage
504 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
506 struct GNUNET_NAMESTORE_Header gns_header;
511 struct GNUNET_CRYPTO_ShortHashCode zone;
514 * Which flags must be included
516 uint16_t must_have_flags;
519 * Which flags must not be included
521 uint16_t must_not_have_flags;
526 * Ask for next result of zone iteration for the given operation
528 struct ZoneIterationNextMessage
531 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
533 struct GNUNET_NAMESTORE_Header gns_header;
538 * Stop zone iteration for the given operation
540 struct ZoneIterationStopMessage
543 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
545 struct GNUNET_NAMESTORE_Header gns_header;
549 * Next result of zone iteration for the given operation
550 * // FIXME: use 'struct LookupResponseMessage' instead? (identical except
551 * for having 'contains_sig' instead of 'reserved', but fully compatible otherwise).
553 struct ZoneIterationResponseMessage
556 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE
558 struct GNUNET_NAMESTORE_Header gns_header;
560 struct GNUNET_TIME_AbsoluteNBO expire;
564 /* Record data length */
568 * Number of records contained
573 * always zero (for alignment)
578 * All zeros if 'contains_sig' is GNUNET_NO.
580 struct GNUNET_CRYPTO_RsaSignature signature;
585 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
590 GNUNET_NETWORK_STRUCT_END
593 /* end of namestore.h */