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);
82 * Compares if two records are equal
87 * @return GNUNET_YES or GNUNET_NO
90 GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a,
91 const struct GNUNET_NAMESTORE_RecordData *b);
94 GNUNET_NETWORK_STRUCT_BEGIN
96 * A GNS record serialized for network transmission.
98 * Layout is [struct GNUNET_NAMESTORE_NetworkRecord][char[data_size] data]
100 struct GNUNET_NAMESTORE_NetworkRecord
103 * Expiration time for the DNS record.
105 struct GNUNET_TIME_AbsoluteNBO expiration;
108 * Number of bytes in 'data'.
113 * Type of the GNS/DNS record.
115 uint32_t record_type;
118 * Flags for the record.
126 * Connect to namestore service. FIXME: UNNECESSARY.
132 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_START
134 struct GNUNET_MessageHeader header;
140 * Generic namestore message with op id
142 struct GNUNET_NAMESTORE_Header
145 * header.type will be GNUNET_MESSAGE_TYPE_NAMESTORE_*
146 * header.size will be message size
148 struct GNUNET_MessageHeader header;
158 * Lookup a name in the namestore
160 struct LookupNameMessage
162 struct GNUNET_NAMESTORE_Header gns_header;
167 struct GNUNET_CRYPTO_ShortHashCode zone;
170 * Requested record type
172 uint32_t record_type;
179 /* 0-terminated name here */
186 struct LookupNameResponseMessage
189 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE
191 struct GNUNET_NAMESTORE_Header gns_header;
196 struct GNUNET_TIME_AbsoluteNBO expire;
205 * Bytes of serialized record data
210 * Number of records contained
215 * Is the signature valid
216 * GNUNET_YES or GNUNET_NO
218 int16_t contains_sig;
221 * All zeros if 'contains_sig' is GNUNET_NO.
223 struct GNUNET_CRYPTO_RsaSignature signature;
226 * The public key for the name
228 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
230 /* 0-terminated name and serialized record data */
231 /* rd_len bytes serialized record data */
236 * Put a record to the namestore
238 struct RecordPutMessage
241 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_RECORD_PUT
243 struct GNUNET_NAMESTORE_Header gns_header;
248 struct GNUNET_TIME_AbsoluteNBO expire;
256 * Length of serialized record data
261 * Number of records contained
266 * always zero (for alignment)
273 struct GNUNET_CRYPTO_RsaSignature signature;
278 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
280 /* name (0-terminated) followed by "rd_count" serialized records */
286 * Put a record to the namestore response
288 struct RecordPutResponseMessage
291 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE
293 struct GNUNET_NAMESTORE_Header gns_header;
297 * GNUNET_SYSERR on failure
298 * GNUNET_OK on success
305 * Create a record and put it to the namestore
308 struct RecordCreateMessage
311 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE
313 struct GNUNET_NAMESTORE_Header gns_header;
315 struct GNUNET_TIME_AbsoluteNBO expire;
323 * Length of serialized record data
338 * GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded private key with length pkey_len
339 * name with length name_len
340 * serialized record data with length rd_len
346 * Create a record to the namestore response
348 struct RecordCreateResponseMessage
351 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE
353 struct GNUNET_NAMESTORE_Header gns_header;
356 * name length: GNUNET_NO already exists, GNUNET_YES on success, GNUNET_SYSERR error
363 * Remove a record from the namestore
366 struct RecordRemoveMessage
369 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE
371 struct GNUNET_NAMESTORE_Header gns_header;
379 * Length of serialized rd data
384 * Number of records contained
389 * Length of private key
394 * GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded private key with length pkey_len
395 * name with length name_len
396 * serialized record data with length rd_len
402 * Remove a record from the namestore response
404 struct RecordRemoveResponseMessage
407 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE
409 struct GNUNET_NAMESTORE_Header gns_header;
414 * 1 : no records for entry
415 * 2 : Could not find record to remove
416 * 3 : Failed to create new signature
417 * 4 : Failed to put new set of records in database
424 * Lookup a name for a zone hash
426 struct ZoneToNameMessage
429 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
431 struct GNUNET_NAMESTORE_Header gns_header;
434 * The hash of public key of the zone to look up in
436 struct GNUNET_CRYPTO_ShortHashCode zone;
439 * The hash of the public key of the target zone
441 struct GNUNET_CRYPTO_ShortHashCode value_zone;
445 * Respone for zone to name lookup
447 struct ZoneToNameResponseMessage
450 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
452 struct GNUNET_NAMESTORE_Header gns_header;
455 * Record block expiration
457 struct GNUNET_TIME_AbsoluteNBO expire;
465 * Length of serialized record data
470 * Number of records contained
474 /* result in NBO: GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error */
480 struct GNUNET_CRYPTO_RsaSignature signature;
485 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key;
492 * Start a zone iteration for the given zone
494 struct ZoneIterationStartMessage
497 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
499 struct GNUNET_NAMESTORE_Header gns_header;
504 struct GNUNET_CRYPTO_ShortHashCode zone;
507 * Which flags must be included
509 uint16_t must_have_flags;
512 * Which flags must not be included
514 uint16_t must_not_have_flags;
519 * Ask for next result of zone iteration for the given operation
521 struct ZoneIterationNextMessage
524 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
526 struct GNUNET_NAMESTORE_Header gns_header;
531 * Stop zone iteration for the given operation
533 struct ZoneIterationStopMessage
536 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
538 struct GNUNET_NAMESTORE_Header gns_header;
542 * Next result of zone iteration for the given operation
543 * // FIXME: use 'struct LookupResponseMessage' instead? (identical except
544 * for having 'contains_sig' instead of 'reserved', but fully compatible otherwise).
546 struct ZoneIterationResponseMessage
549 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE
551 struct GNUNET_NAMESTORE_Header gns_header;
553 struct GNUNET_TIME_AbsoluteNBO expire;
557 /* Record data length */
561 * Number of records contained
566 * always zero (for alignment)
571 * All zeros if 'contains_sig' is GNUNET_NO.
573 struct GNUNET_CRYPTO_RsaSignature signature;
578 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
583 GNUNET_NETWORK_STRUCT_END
586 /* end of namestore.h */