Merge branch 'master' of gnunet.org:gnunet
[oweals/gnunet.git] / src / namecache / namecache.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2011-2013 GNUnet e.V.
4
5      GNUnet is free software: you can redistribute it and/or modify it
6      under the terms of the GNU Affero General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your 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      Affero General Public License for more details.
14     
15      You should have received a copy of the GNU Affero General Public License
16      along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 /**
20  * @file namecache/namecache.h
21  * @brief common internal definitions for namecache service
22  * @author Matthias Wachs
23  * @author Christian Grothoff
24  */
25 #ifndef NAMECACHE_H
26 #define NAMECACHE_H
27
28 /**
29  * Maximum length of any name, including 0-termination.
30  */
31 #define MAX_NAME_LEN 256
32
33 GNUNET_NETWORK_STRUCT_BEGIN
34
35 /**
36  * Generic namecache message with op id
37  */
38 struct GNUNET_NAMECACHE_Header
39 {
40   /**
41    * header.type will be GNUNET_MESSAGE_TYPE_NAMECACHE_*
42    * header.size will be message size
43    */
44   struct GNUNET_MessageHeader header;
45
46   /**
47    * Request ID in NBO
48    */
49   uint32_t r_id GNUNET_PACKED;
50 };
51
52
53 /**
54  * Lookup a block in the namecache
55  */
56 struct LookupBlockMessage
57 {
58   /**
59    * Type will be #GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK
60    */
61   struct GNUNET_NAMECACHE_Header gns_header;
62
63   /**
64    * The query.
65    */
66   struct GNUNET_HashCode query GNUNET_PACKED;
67
68 };
69
70
71 /**
72  * Lookup response
73  */
74 struct LookupBlockResponseMessage
75 {
76   /**
77    * Type will be #GNUNET_MESSAGE_TYPE_NAMECACHE_LOOKUP_BLOCK_RESPONSE
78    */
79   struct GNUNET_NAMECACHE_Header gns_header;
80
81   /**
82    * Expiration time
83    */
84   struct GNUNET_TIME_AbsoluteNBO expire;
85
86   /**
87    * Signature.
88    */
89   struct GNUNET_CRYPTO_EcdsaSignature signature;
90
91   /**
92    * Derived public key.
93    */
94   struct GNUNET_CRYPTO_EcdsaPublicKey derived_key;
95
96   /* follwed by encrypted block data */
97 };
98
99
100 /**
101  * Cache a record in the namecache.
102  */
103 struct BlockCacheMessage
104 {
105   /**
106    * Type will be #GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE
107    */
108   struct GNUNET_NAMECACHE_Header gns_header;
109
110   /**
111    * Expiration time
112    */
113   struct GNUNET_TIME_AbsoluteNBO expire;
114
115   /**
116    * Signature.
117    */
118   struct GNUNET_CRYPTO_EcdsaSignature signature;
119
120   /**
121    * Derived public key.
122    */
123   struct GNUNET_CRYPTO_EcdsaPublicKey derived_key;
124
125   /* follwed by encrypted block data */
126 };
127
128
129 /**
130  * Response to a request to cache a block.
131  */
132 struct BlockCacheResponseMessage
133 {
134   /**
135    * Type will be #GNUNET_MESSAGE_TYPE_NAMECACHE_BLOCK_CACHE_RESPONSE
136    */
137   struct GNUNET_NAMECACHE_Header gns_header;
138
139   /**
140    * #GNUNET_OK on success, #GNUNET_SYSERR error
141    */
142   int32_t op_result GNUNET_PACKED;
143 };
144
145
146 GNUNET_NETWORK_STRUCT_END
147
148
149 /* end of namecache.h */
150 #endif