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 * Sign name and records
52 * @param key the private key
53 * @param expire block expiration
54 * @param name the name
55 * @param rd record data
56 * @param rd_count number of records
58 * @return the signature
60 struct GNUNET_CRYPTO_RsaSignature *
61 GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
62 struct GNUNET_TIME_Absolute expire,
64 const struct GNUNET_NAMESTORE_RecordData *rd,
65 unsigned int rd_count);
68 * Compares if two records are equal
73 * @return GNUNET_YES or GNUNET_NO
76 GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a,
77 const struct GNUNET_NAMESTORE_RecordData *b);
80 GNUNET_NETWORK_STRUCT_BEGIN
82 * A GNS record serialized for network transmission.
84 * Layout is [struct GNUNET_NAMESTORE_NetworkRecord][char[data_size] data]
86 struct GNUNET_NAMESTORE_NetworkRecord
89 * Expiration time for the DNS record.
91 struct GNUNET_TIME_AbsoluteNBO expiration;
94 * Number of bytes in 'data'.
99 * Type of the GNS/DNS record.
101 uint32_t record_type;
104 * Flags for the record.
112 * Connect to namestore service. FIXME: UNNECESSARY.
118 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_START
120 struct GNUNET_MessageHeader header;
126 * Generic namestore message with op id
128 struct GNUNET_NAMESTORE_Header
131 * header.type will be GNUNET_MESSAGE_TYPE_NAMESTORE_*
132 * header.size will be message size
134 struct GNUNET_MessageHeader header;
144 * Lookup a name in the namestore
146 struct LookupNameMessage
148 struct GNUNET_NAMESTORE_Header gns_header;
153 GNUNET_HashCode zone;
156 * Requested record type
158 uint32_t record_type;
165 /* 0-terminated name here */
172 struct LookupNameResponseMessage
175 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE
177 struct GNUNET_NAMESTORE_Header gns_header;
182 struct GNUNET_TIME_AbsoluteNBO expire;
191 * Bytes of serialized record data
196 * Number of records contained
201 * Is the signature valid
202 * GNUNET_YES or GNUNET_NO
204 int16_t contains_sig;
207 * All zeros if 'contains_sig' is GNUNET_NO.
209 struct GNUNET_CRYPTO_RsaSignature signature;
212 * The public key for the name
214 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
216 /* 0-terminated name and serialized record data */
217 /* rd_len bytes serialized record data */
222 * Put a record to the namestore
224 struct RecordPutMessage
227 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_RECORD_PUT
229 struct GNUNET_NAMESTORE_Header gns_header;
234 struct GNUNET_TIME_AbsoluteNBO expire;
242 * Length of serialized record data
247 * Number of records contained
252 * always zero (for alignment)
259 struct GNUNET_CRYPTO_RsaSignature signature;
264 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
266 /* name (0-terminated) followed by "rd_count" serialized records */
272 * Put a record to the namestore response
274 struct RecordPutResponseMessage
277 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE
279 struct GNUNET_NAMESTORE_Header gns_header;
283 * GNUNET_SYSERR on failure
284 * GNUNET_OK on success
291 * Create a record and put it to the namestore
294 struct RecordCreateMessage
297 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE
299 struct GNUNET_NAMESTORE_Header gns_header;
301 struct GNUNET_TIME_AbsoluteNBO expire;
309 * Length of serialized record data
324 * GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded private key with length pkey_len
325 * name with length name_len
326 * serialized record data with length rd_len
332 * Create a record to the namestore response
334 struct RecordCreateResponseMessage
337 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE
339 struct GNUNET_NAMESTORE_Header gns_header;
342 * name length: GNUNET_NO already exists, GNUNET_YES on success, GNUNET_SYSERR error
349 * Remove a record from the namestore
352 struct RecordRemoveMessage
355 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE
357 struct GNUNET_NAMESTORE_Header gns_header;
365 * Length of serialized rd data
370 * Number of records contained
375 * Length of private key
380 * GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded private key with length pkey_len
381 * name with length name_len
382 * serialized record data with length rd_len
388 * Remove a record from the namestore response
390 struct RecordRemoveResponseMessage
393 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE
395 struct GNUNET_NAMESTORE_Header gns_header;
400 * 1 : no records for entry
401 * 2 : Could not find record to remove
402 * 3 : Failed to create new signature
403 * 4 : Failed to put new set of records in database
410 * Lookup a name for a zone hash
412 struct ZoneToNameMessage
415 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
417 struct GNUNET_NAMESTORE_Header gns_header;
420 * The hash of public key of the zone to look up in
422 GNUNET_HashCode zone;
425 * The hash of the public key of the target zone
427 GNUNET_HashCode value_zone;
431 * Respone for zone to name lookup
433 struct ZoneToNameResponseMessage
436 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
438 struct GNUNET_NAMESTORE_Header gns_header;
441 * Record block expiration
443 struct GNUNET_TIME_AbsoluteNBO expire;
451 * Length of serialized record data
456 * Number of records contained
460 /* result in NBO: GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error */
466 struct GNUNET_CRYPTO_RsaSignature signature;
471 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key;
478 * Start a zone iteration for the given zone
480 struct ZoneIterationStartMessage
483 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
485 struct GNUNET_NAMESTORE_Header gns_header;
490 GNUNET_HashCode zone;
493 * Which flags must be included
495 uint16_t must_have_flags;
498 * Which flags must not be included
500 uint16_t must_not_have_flags;
505 * Ask for next result of zone iteration for the given operation
507 struct ZoneIterationNextMessage
510 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
512 struct GNUNET_NAMESTORE_Header gns_header;
517 * Stop zone iteration for the given operation
519 struct ZoneIterationStopMessage
522 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
524 struct GNUNET_NAMESTORE_Header gns_header;
528 * Next result of zone iteration for the given operation
529 * // FIXME: use 'struct LookupResponseMessage' instead? (identical except
530 * for having 'contains_sig' instead of 'reserved', but fully compatible otherwise).
532 struct ZoneIterationResponseMessage
535 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE
537 struct GNUNET_NAMESTORE_Header gns_header;
539 struct GNUNET_TIME_AbsoluteNBO expire;
543 /* Record data length */
547 * Number of records contained
552 * always zero (for alignment)
557 * All zeros if 'contains_sig' is GNUNET_NO.
559 struct GNUNET_CRYPTO_RsaSignature signature;
564 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
569 GNUNET_NETWORK_STRUCT_END
572 /* end of namestore.h */