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
41 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START 439
42 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE 440
43 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT 441
44 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP 442
46 #define GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT 443
49 * Sign name and records
51 * @param key the private key
52 * @param name the name
53 * @param rd record data
54 * @param rd_count number of records
56 * @return the signature
58 struct GNUNET_CRYPTO_RsaSignature *
59 GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key, const char *name, struct GNUNET_NAMESTORE_RecordData *rd, unsigned int rd_count);
62 * Compares if two records are equal
67 * @return GNUNET_YES or GNUNET_NO
70 GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a,
71 const struct GNUNET_NAMESTORE_RecordData *b);
73 GNUNET_NETWORK_STRUCT_BEGIN
75 * A GNS record serialized for network transmission.
76 * layout is [struct GNUNET_NAMESTORE_NetworkRecord][char[data_size] data]
78 struct GNUNET_NAMESTORE_NetworkRecord
81 * Expiration time for the DNS record.
83 struct GNUNET_TIME_AbsoluteNBO expiration;
86 * Number of bytes in 'data'.
91 * Type of the GNS/DNS record.
96 * Flags for the record.
104 * Connect to namestore service. FIXME: UNNECESSARY.
110 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_START
112 struct GNUNET_MessageHeader header;
117 * Connect to namestore service. FIXME: UNNECESSARY.
119 struct DisconnectMessage
123 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT
125 struct GNUNET_MessageHeader header;
129 * GNUNET_YES or _NO in NBO
136 * Generic namestore message with op id
138 struct GNUNET_NAMESTORE_Header
141 * header.type will be GNUNET_MESSAGE_TYPE_NAMESTORE_*
142 * header.size will be message size
144 struct GNUNET_MessageHeader header;
154 * Connect to namestore service
156 struct LookupNameMessage
158 struct GNUNET_NAMESTORE_Header gns_header;
161 GNUNET_HashCode zone;
163 /* Requested record type */
164 uint32_t record_type;
166 /* Requested record type */
174 * [struct LookupNameResponseMessage][struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData][struct GNUNET_CRYPTO_RsaSignature]
176 struct LookupNameResponseMessage
179 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE
181 struct GNUNET_NAMESTORE_Header gns_header;
183 struct GNUNET_TIME_AbsoluteNBO expire;
191 int32_t contains_sig;
193 /* Requested record type */
198 * Put a record to the namestore
200 * [struct RecordPutMessage][struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData]
202 struct RecordPutMessage
205 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_RECORD_PUT
207 struct GNUNET_NAMESTORE_Header gns_header;
209 /* Contenct starts here */
214 /* Length of serialized rd data */
217 /* Number of records contained */
220 /* Length of pubkey */
223 struct GNUNET_TIME_AbsoluteNBO expire;
225 struct GNUNET_CRYPTO_RsaSignature signature;
230 * Put a record to the namestore response
232 struct RecordPutResponseMessage
235 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE
237 struct GNUNET_MessageHeader header;
240 * Operation ID in NBO
244 /* Contenct starts here */
247 * name length: GNUNET_NO (0) on error, GNUNET_OK (1) on success
254 * Create a record and put it to the namestore
256 * [struct RecordCreateMessage][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData]
258 struct RecordCreateMessage
261 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE
263 struct GNUNET_NAMESTORE_Header gns_header;
265 /* Contenct starts here */
270 /* Record data length */
276 /* private key length */
282 * Create a record to the namestore response
285 struct RecordCreateResponseMessage
288 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE
290 struct GNUNET_NAMESTORE_Header gns_header;
292 /* Contenct starts here */
295 * name length: GNUNET_NO already existsw, GNUNET_YES on success, GNUNET_SYSERR error
303 * Remove a record from the namestore
305 * [struct RecordRemoveMessage][char *name][struct GNUNET_NAMESTORE_RecordData]
307 struct RecordRemoveMessage
310 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE
312 struct GNUNET_NAMESTORE_Header gns_header;
314 /* Contenct starts here */
319 /* Length of serialized rd data */
322 /* Number of records contained */
325 /* Length of pubkey */
328 GNUNET_NETWORK_STRUCT_END
332 * Remove a record from the namestore response
334 GNUNET_NETWORK_STRUCT_BEGIN
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
354 GNUNET_NETWORK_STRUCT_END
358 * Start a zone iteration for the given zone
360 GNUNET_NETWORK_STRUCT_BEGIN
361 struct ZoneIterationStartMessage
364 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
366 struct GNUNET_NAMESTORE_Header gns_header;
368 /* Contenct starts here */
370 uint16_t must_have_flags;
371 uint16_t must_not_have_flags;
373 GNUNET_HashCode zone;
375 GNUNET_NETWORK_STRUCT_END
378 * Ask for next result of zone iteration for the given operation
380 GNUNET_NETWORK_STRUCT_BEGIN
381 struct ZoneIterationNextMessage
384 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
386 struct GNUNET_NAMESTORE_Header gns_header;
388 GNUNET_NETWORK_STRUCT_END
392 * Stop zone iteration for the given operation
394 GNUNET_NETWORK_STRUCT_BEGIN
395 struct ZoneIterationStopMessage
398 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
400 struct GNUNET_NAMESTORE_Header gns_header;
402 GNUNET_NETWORK_STRUCT_END
405 * Ask for next result of zone iteration for the given operation
407 GNUNET_NETWORK_STRUCT_BEGIN
408 struct ZoneIterationResponseMessage
411 * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE
413 struct GNUNET_NAMESTORE_Header gns_header;
415 struct GNUNET_TIME_AbsoluteNBO expire;
419 uint16_t contains_sig;
421 /* Record data length */
425 GNUNET_NETWORK_STRUCT_END
428 /* end of namestore.h */