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