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_LOOKUP_NAME 431
33 #define GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE 432
34 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT 433
35 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE 434
36 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE 435
37 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE 436
38 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE 437
39 #define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE 438
40 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME 439
41 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE 440
43 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START 445
44 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE 446
45 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT 447
46 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP 448
47 #define GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT 449
50 * Create a signature based on name and records
52 * @param key the private key
53 * @param name the name
54 * @param rd record data
55 * @param rd_count number of records
57 * @return the signature
59 struct GNUNET_CRYPTO_RsaSignature *
60 GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
62 const struct GNUNET_NAMESTORE_RecordData *rd,
63 unsigned int rd_count);
66 * Compares if two records are equal
71 * @return GNUNET_YES or GNUNET_NO
74 GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a,
75 const struct GNUNET_NAMESTORE_RecordData *b);
78 GNUNET_NETWORK_STRUCT_BEGIN
80 * A GNS record serialized for network transmission.
82 * Layout is [struct GNUNET_NAMESTORE_NetworkRecord][char[data_size] data]
84 struct GNUNET_NAMESTORE_NetworkRecord
87 * Expiration time for the DNS record.
89 struct GNUNET_TIME_AbsoluteNBO expiration;
92 * Number of bytes in 'data'.
97 * Type of the GNS/DNS record.
102 * Flags for the record.
110 * Connect to namestore service. FIXME: UNNECESSARY.
116 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_START
118 struct GNUNET_MessageHeader header;
124 * Generic namestore message with op id
126 struct GNUNET_NAMESTORE_Header
129 * header.type will be GNUNET_MESSAGE_TYPE_NAMESTORE_*
130 * header.size will be message size
132 struct GNUNET_MessageHeader header;
142 * Lookup a name in the namestore
144 struct LookupNameMessage
146 struct GNUNET_NAMESTORE_Header gns_header;
151 GNUNET_HashCode zone;
154 * Requested record type
156 uint32_t record_type;
163 /* 0-terminated name here */
170 struct LookupNameResponseMessage
173 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE
175 struct GNUNET_NAMESTORE_Header gns_header;
180 struct GNUNET_TIME_AbsoluteNBO expire;
189 * Bytes of serialized record data
194 * Number of records contained
199 * Is the signature valid
200 * GNUNET_YES or GNUNET_NO
202 int16_t contains_sig;
205 * All zeros if 'contains_sig' is GNUNET_NO.
207 struct GNUNET_CRYPTO_RsaSignature signature;
210 * The public key for the name
212 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
214 /* 0-terminated name and serialized record data */
215 /* rd_len bytes serialized record data */
220 * Put a record to the namestore
222 struct RecordPutMessage
225 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_RECORD_PUT
227 struct GNUNET_NAMESTORE_Header gns_header;
232 struct GNUNET_TIME_AbsoluteNBO expire;
240 * Length of serialized record data
245 * Number of records contained
250 * always zero (for alignment)
257 struct GNUNET_CRYPTO_RsaSignature signature;
262 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
264 /* name (0-terminated) followed by "rd_count" serialized records */
270 * Put a record to the namestore response
272 struct RecordPutResponseMessage
275 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE
277 struct GNUNET_NAMESTORE_Header gns_header;
280 * name length: GNUNET_NO (0) on error, GNUNET_OK (1) on success
287 * Create a record and put it to the namestore
289 * [struct RecordCreateMessage][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData]
291 struct RecordCreateMessage
294 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE
296 struct GNUNET_NAMESTORE_Header gns_header;
298 struct GNUNET_TIME_AbsoluteNBO expire;
306 * Length of serialized record data
321 * GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded private key with length pkey_len
322 * name with length name_len
323 * serialized record data with length rd_len
329 * Create a record to the namestore response
331 struct RecordCreateResponseMessage
334 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE
336 struct GNUNET_NAMESTORE_Header gns_header;
339 * name length: GNUNET_NO already exists, GNUNET_YES on success, GNUNET_SYSERR error
346 * Remove a record from the namestore
349 struct RecordRemoveMessage
352 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE
354 struct GNUNET_NAMESTORE_Header gns_header;
362 * Length of serialized rd data
367 * Number of records contained
372 * Length of private key
377 * GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded private key with length pkey_len
378 * name with length name_len
379 * serialized record data with length rd_len
385 * Remove a record from the namestore response
387 struct RecordRemoveResponseMessage
390 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE
392 struct GNUNET_NAMESTORE_Header gns_header;
397 * 1 : no records for entry
398 * 2 : Could not find record to remove
399 * 3 : Failed to create new signature
400 * 4 : Failed to put new set of records in database
407 * Lookup a name for a zone hash
409 struct ZoneToNameMessage
412 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
414 struct GNUNET_NAMESTORE_Header gns_header;
417 * The hash of public key of the zone to look up in
419 GNUNET_HashCode zone;
422 * The hash of the public key of the target zone
424 GNUNET_HashCode value_zone;
428 * Respone for zone to name lookup
430 struct ZoneToNameResponseMessage
433 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
435 struct GNUNET_NAMESTORE_Header gns_header;
438 * Record block expiration
440 struct GNUNET_TIME_AbsoluteNBO expire;
448 * Length of serialized record data
453 * Number of records contained
457 /* result in NBO: GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error */
463 struct GNUNET_CRYPTO_RsaSignature signature;
468 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key;
475 * Start a zone iteration for the given zone
477 struct ZoneIterationStartMessage
480 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
482 struct GNUNET_NAMESTORE_Header gns_header;
487 GNUNET_HashCode zone;
490 * Which flags must be included
492 uint16_t must_have_flags;
495 * Which flags must not be included
497 uint16_t must_not_have_flags;
502 * Ask for next result of zone iteration for the given operation
504 struct ZoneIterationNextMessage
507 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
509 struct GNUNET_NAMESTORE_Header gns_header;
514 * Stop zone iteration for the given operation
516 struct ZoneIterationStopMessage
519 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
521 struct GNUNET_NAMESTORE_Header gns_header;
525 * Next result of zone iteration for the given operation
526 * // FIXME: use 'struct LookupResponseMessage' instead? (identical except
527 * for having 'contains_sig' instead of 'reserved', but fully compatible otherwise).
529 struct ZoneIterationResponseMessage
532 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE
534 struct GNUNET_NAMESTORE_Header gns_header;
536 struct GNUNET_TIME_AbsoluteNBO expire;
540 /* Record data length */
544 * Number of records contained
549 * always zero (for alignment)
554 * All zeros if 'contains_sig' is GNUNET_NO.
556 struct GNUNET_CRYPTO_RsaSignature signature;
561 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
566 GNUNET_NETWORK_STRUCT_END
569 /* end of namestore.h */