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 * Sign 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, const char *name, struct GNUNET_NAMESTORE_RecordData *rd, unsigned int rd_count);
63 * Compares if two records are equal
68 * @return GNUNET_YES or GNUNET_NO
71 GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a,
72 const struct GNUNET_NAMESTORE_RecordData *b);
74 GNUNET_NETWORK_STRUCT_BEGIN
76 * A GNS record serialized for network transmission.
77 * layout is [struct GNUNET_NAMESTORE_NetworkRecord][char[data_size] data]
79 struct GNUNET_NAMESTORE_NetworkRecord
82 * Expiration time for the DNS record.
84 struct GNUNET_TIME_AbsoluteNBO expiration;
87 * Number of bytes in 'data'.
92 * Type of the GNS/DNS record.
97 * Flags for the record.
105 * Connect to namestore service. FIXME: UNNECESSARY.
111 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_START
113 struct GNUNET_MessageHeader header;
118 * Connect to namestore service. FIXME: UNNECESSARY.
120 struct DisconnectMessage
124 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT
126 struct GNUNET_MessageHeader header;
130 * GNUNET_YES or _NO in NBO
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 * Connect to namestore service
157 struct LookupNameMessage
159 struct GNUNET_NAMESTORE_Header gns_header;
162 GNUNET_HashCode zone;
164 /* Requested record type */
165 uint32_t record_type;
167 /* Requested record type */
175 * [struct LookupNameResponseMessage][struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData][struct GNUNET_CRYPTO_RsaSignature]
177 struct LookupNameResponseMessage
180 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE
182 struct GNUNET_NAMESTORE_Header gns_header;
184 struct GNUNET_TIME_AbsoluteNBO expire;
192 int32_t contains_sig;
194 /* Requested record type */
199 * Put a record to the namestore
201 * [struct RecordPutMessage][struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData]
203 struct RecordPutMessage
206 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_RECORD_PUT
208 struct GNUNET_NAMESTORE_Header gns_header;
210 /* Contenct starts here */
215 /* Length of serialized rd data */
218 /* Number of records contained */
221 /* Length of pubkey */
224 struct GNUNET_TIME_AbsoluteNBO expire;
226 struct GNUNET_CRYPTO_RsaSignature signature;
231 * Put a record to the namestore response
233 struct RecordPutResponseMessage
236 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE
238 struct GNUNET_MessageHeader header;
241 * Operation ID in NBO
245 /* Contenct starts here */
248 * name length: GNUNET_NO (0) on error, GNUNET_OK (1) on success
255 * Create a record and put it to the namestore
257 * [struct RecordCreateMessage][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData]
259 struct RecordCreateMessage
262 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE
264 struct GNUNET_NAMESTORE_Header gns_header;
266 /* Contenct starts here */
271 /* Record data length */
277 /* private key length */
283 * Create a record to the namestore response
286 struct RecordCreateResponseMessage
289 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE
291 struct GNUNET_NAMESTORE_Header gns_header;
293 /* Contenct starts here */
296 * name length: GNUNET_NO already existsw, GNUNET_YES on success, GNUNET_SYSERR error
305 * Remove a record from the namestore
307 * [struct RecordRemoveMessage][char *name][struct GNUNET_NAMESTORE_RecordData]
309 struct RecordRemoveMessage
312 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE
314 struct GNUNET_NAMESTORE_Header gns_header;
316 /* Contenct starts here */
321 /* Length of serialized rd data */
324 /* Number of records contained */
327 /* Length of pubkey */
333 * Remove a record from the namestore response
335 struct RecordRemoveResponseMessage
338 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE
340 struct GNUNET_NAMESTORE_Header gns_header;
342 /* Contenct starts here */
347 * 1 : no records for entry
348 * 2 : Could not find record to remove
349 * 3 : Failed to create new signature
350 * 4 : Failed to put new set of records in database
357 * Connect to namestore service
359 struct ZoneToNameMessage
361 struct GNUNET_NAMESTORE_Header gns_header;
363 /* The hash of public key of the zone to look up in */
364 GNUNET_HashCode zone;
366 /* The hash of the public key of the target zone */
367 GNUNET_HashCode value_zone;
371 * Connect to namestore service
373 struct ZoneToNameResponseMessage
375 struct GNUNET_NAMESTORE_Header gns_header;
377 struct GNUNET_TIME_AbsoluteNBO expire;
385 int32_t contains_sig;
387 /* result in NBO: GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error */
390 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key;
397 * Start a zone iteration for the given zone
399 struct ZoneIterationStartMessage
402 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
404 struct GNUNET_NAMESTORE_Header gns_header;
406 /* Contenct starts here */
408 uint16_t must_have_flags;
409 uint16_t must_not_have_flags;
411 GNUNET_HashCode zone;
416 * Ask for next result of zone iteration for the given operation
418 struct ZoneIterationNextMessage
421 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
423 struct GNUNET_NAMESTORE_Header gns_header;
428 * Stop zone iteration for the given operation
430 struct ZoneIterationStopMessage
433 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
435 struct GNUNET_NAMESTORE_Header gns_header;
439 * Ask for next result of zone iteration for the given operation
441 struct ZoneIterationResponseMessage
444 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE
446 struct GNUNET_NAMESTORE_Header gns_header;
448 struct GNUNET_TIME_AbsoluteNBO expire;
452 uint16_t contains_sig;
454 /* Record data length */
458 GNUNET_NETWORK_STRUCT_END
461 /* end of namestore.h */