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
50 * Convert a short hash to a string (for printing debug messages).
51 * This is one of the very few calls in the entire API that is
54 * @param hc the short hash code
55 * @return string form; will be overwritten by next call to GNUNET_h2s.
58 GNUNET_short_h2s (const struct GNUNET_CRYPTO_ShortHashCode * hc);
61 * Sign name and records
63 * @param key the private key
64 * @param expire block expiration
65 * @param name the name
66 * @param rd record data
67 * @param rd_count number of records
69 * @return the signature
71 struct GNUNET_CRYPTO_RsaSignature *
72 GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
73 struct GNUNET_TIME_Absolute expire,
75 const struct GNUNET_NAMESTORE_RecordData *rd,
76 unsigned int rd_count);
79 * Compares if two records are equal
84 * @return GNUNET_YES or GNUNET_NO
87 GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a,
88 const struct GNUNET_NAMESTORE_RecordData *b);
91 GNUNET_NETWORK_STRUCT_BEGIN
93 * A GNS record serialized for network transmission.
95 * Layout is [struct GNUNET_NAMESTORE_NetworkRecord][char[data_size] data]
97 struct GNUNET_NAMESTORE_NetworkRecord
100 * Expiration time for the DNS record.
102 struct GNUNET_TIME_AbsoluteNBO expiration;
105 * Number of bytes in 'data'.
110 * Type of the GNS/DNS record.
112 uint32_t record_type;
115 * Flags for the record.
123 * Connect to namestore service. FIXME: UNNECESSARY.
129 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_START
131 struct GNUNET_MessageHeader header;
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 * Lookup a name in the namestore
157 struct LookupNameMessage
159 struct GNUNET_NAMESTORE_Header gns_header;
164 struct GNUNET_CRYPTO_ShortHashCode zone;
167 * Requested record type
169 uint32_t record_type;
176 /* 0-terminated name here */
183 struct LookupNameResponseMessage
186 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE
188 struct GNUNET_NAMESTORE_Header gns_header;
193 struct GNUNET_TIME_AbsoluteNBO expire;
202 * Bytes of serialized record data
207 * Number of records contained
212 * Is the signature valid
213 * GNUNET_YES or GNUNET_NO
215 int16_t contains_sig;
218 * All zeros if 'contains_sig' is GNUNET_NO.
220 struct GNUNET_CRYPTO_RsaSignature signature;
223 * The public key for the name
225 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
227 /* 0-terminated name and serialized record data */
228 /* rd_len bytes serialized record data */
233 * Put a record to the namestore
235 struct RecordPutMessage
238 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_RECORD_PUT
240 struct GNUNET_NAMESTORE_Header gns_header;
245 struct GNUNET_TIME_AbsoluteNBO expire;
253 * Length of serialized record data
258 * Number of records contained
263 * always zero (for alignment)
270 struct GNUNET_CRYPTO_RsaSignature signature;
275 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
277 /* name (0-terminated) followed by "rd_count" serialized records */
283 * Put a record to the namestore response
285 struct RecordPutResponseMessage
288 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE
290 struct GNUNET_NAMESTORE_Header gns_header;
294 * GNUNET_SYSERR on failure
295 * GNUNET_OK on success
302 * Create a record and put it to the namestore
305 struct RecordCreateMessage
308 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE
310 struct GNUNET_NAMESTORE_Header gns_header;
312 struct GNUNET_TIME_AbsoluteNBO expire;
320 * Length of serialized record data
335 * GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded private key with length pkey_len
336 * name with length name_len
337 * serialized record data with length rd_len
343 * Create a record to the namestore response
345 struct RecordCreateResponseMessage
348 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE
350 struct GNUNET_NAMESTORE_Header gns_header;
353 * name length: GNUNET_NO already exists, GNUNET_YES on success, GNUNET_SYSERR error
360 * Remove a record from the namestore
363 struct RecordRemoveMessage
366 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE
368 struct GNUNET_NAMESTORE_Header gns_header;
376 * Length of serialized rd data
381 * Number of records contained
386 * Length of private key
391 * GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded private key with length pkey_len
392 * name with length name_len
393 * serialized record data with length rd_len
399 * Remove a record from the namestore response
401 struct RecordRemoveResponseMessage
404 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE
406 struct GNUNET_NAMESTORE_Header gns_header;
411 * 1 : no records for entry
412 * 2 : Could not find record to remove
413 * 3 : Failed to create new signature
414 * 4 : Failed to put new set of records in database
421 * Lookup a name for a zone hash
423 struct ZoneToNameMessage
426 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
428 struct GNUNET_NAMESTORE_Header gns_header;
431 * The hash of public key of the zone to look up in
433 struct GNUNET_CRYPTO_ShortHashCode zone;
436 * The hash of the public key of the target zone
438 struct GNUNET_CRYPTO_ShortHashCode value_zone;
442 * Respone for zone to name lookup
444 struct ZoneToNameResponseMessage
447 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
449 struct GNUNET_NAMESTORE_Header gns_header;
452 * Record block expiration
454 struct GNUNET_TIME_AbsoluteNBO expire;
462 * Length of serialized record data
467 * Number of records contained
471 /* result in NBO: GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error */
477 struct GNUNET_CRYPTO_RsaSignature signature;
482 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key;
489 * Start a zone iteration for the given zone
491 struct ZoneIterationStartMessage
494 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
496 struct GNUNET_NAMESTORE_Header gns_header;
501 struct GNUNET_CRYPTO_ShortHashCode zone;
504 * Which flags must be included
506 uint16_t must_have_flags;
509 * Which flags must not be included
511 uint16_t must_not_have_flags;
516 * Ask for next result of zone iteration for the given operation
518 struct ZoneIterationNextMessage
521 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
523 struct GNUNET_NAMESTORE_Header gns_header;
528 * Stop zone iteration for the given operation
530 struct ZoneIterationStopMessage
533 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
535 struct GNUNET_NAMESTORE_Header gns_header;
539 * Next result of zone iteration for the given operation
540 * // FIXME: use 'struct LookupResponseMessage' instead? (identical except
541 * for having 'contains_sig' instead of 'reserved', but fully compatible otherwise).
543 struct ZoneIterationResponseMessage
546 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE
548 struct GNUNET_NAMESTORE_Header gns_header;
550 struct GNUNET_TIME_AbsoluteNBO expire;
554 /* Record data length */
558 * Number of records contained
563 * always zero (for alignment)
568 * All zeros if 'contains_sig' is GNUNET_NO.
570 struct GNUNET_CRYPTO_RsaSignature signature;
575 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
580 GNUNET_NETWORK_STRUCT_END
583 /* end of namestore.h */