- fix use of uninitialized memory
[oweals/gnunet.git] / src / namecache / namecache.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2011-2013 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, USA.
19 */
20
21 /**
22  * @file namecache/namecache.h
23  * @brief common internal definitions for namecache service
24  * @author Matthias Wachs
25  * @author Christian Grothoff
26  */
27 #ifndef NAMECACHE_H
28 #define NAMECACHE_H
29
30 /**
31  * Maximum length of any name, including 0-termination.
32  */
33 #define MAX_NAME_LEN 256
34
35 GNUNET_NETWORK_STRUCT_BEGIN
36
37 /**
38  * Generic namecache message with op id
39  */
40 struct GNUNET_NAMECACHE_Header
41 {
42   /**
43    * header.type will be GNUNET_MESSAGE_TYPE_NAMECACHE_*
44    * header.size will be message size
45    */
46   struct GNUNET_MessageHeader header;
47
48   /**
49    * Request ID in NBO
50    */
51   uint32_t r_id GNUNET_PACKED;
52 };
53
54
55 /**
56  * Lookup a block in the namecache
57  */
58 struct LookupBlockMessage
59 {
60   /**
61    * Type will be #GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK
62    */
63   struct GNUNET_NAMECACHE_Header gns_header;
64
65   /**
66    * The query.
67    */
68   struct GNUNET_HashCode query GNUNET_PACKED;
69
70 };
71
72
73 /**
74  * Lookup response
75  */
76 struct LookupBlockResponseMessage
77 {
78   /**
79    * Type will be #GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK_RESPONSE
80    */
81   struct GNUNET_NAMECACHE_Header gns_header;
82
83   /**
84    * Expiration time
85    */
86   struct GNUNET_TIME_AbsoluteNBO expire;
87
88   /**
89    * Signature.
90    */
91   struct GNUNET_CRYPTO_EcdsaSignature signature;
92
93   /**
94    * Derived public key.
95    */
96   struct GNUNET_CRYPTO_EcdsaPublicKey derived_key;
97
98   /* follwed by encrypted block data */
99 };
100
101
102 /**
103  * Cache a record in the namecache.
104  */
105 struct BlockCacheMessage
106 {
107   /**
108    * Type will be #GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE
109    */
110   struct GNUNET_NAMECACHE_Header gns_header;
111
112   /**
113    * Expiration time
114    */
115   struct GNUNET_TIME_AbsoluteNBO expire;
116
117   /**
118    * Signature.
119    */
120   struct GNUNET_CRYPTO_EcdsaSignature signature;
121
122   /**
123    * Derived public key.
124    */
125   struct GNUNET_CRYPTO_EcdsaPublicKey derived_key;
126
127   /* follwed by encrypted block data */
128 };
129
130
131 /**
132  * Response to a request to cache a block.
133  */
134 struct BlockCacheResponseMessage
135 {
136   /**
137    * Type will be #GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE_RESPONSE
138    */
139   struct GNUNET_NAMECACHE_Header gns_header;
140
141   /**
142    * #GNUNET_OK on success, #GNUNET_SYSERR error
143    */
144   int32_t op_result GNUNET_PACKED;
145 };
146
147
148 GNUNET_NETWORK_STRUCT_END
149
150
151 /* end of namecache.h */
152 #endif