10119800d532becf8d7faff14d68a5051791cc60
[oweals/gnunet.git] / src / gns / gns.h
1 /*
2       This file is part of GNUnet
3       (C) 2012 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 2, 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., 59 Temple Place - Suite 330,
18       Boston, MA 02111-1307, USA.
19  */
20 /**
21  * @file gns/gns.h
22  * @brief IPC messages between GNS API and GNS service
23  * @author Martin Schanzenbach
24  */
25 #ifndef GNS_H
26 #define GNS_H
27
28 #include "gnunet_gns_service.h"
29
30 /**
31  * Name of the GADS TLD.
32  */
33 #define GNUNET_GNS_TLD "gads"
34
35 /**
36  * Name of the zone key TLD.
37  */
38 #define GNUNET_GNS_TLD_ZKEY "zkey"
39
40 /**
41  * TLD name used to indicate relative names.
42  */
43 #define GNUNET_GNS_TLD_PLUS "+"
44
45 /**
46  * Maximum length of a label in DNS.
47  */
48 #define MAX_DNS_LABEL_LENGTH 63
49
50 /**
51  * Maximum length of a name in DNS.
52  */
53 #define MAX_DNS_NAME_LENGTH 253
54
55
56 GNUNET_NETWORK_STRUCT_BEGIN
57
58 /**
59  * Message from client to GNS service to lookup records.
60  */
61 struct GNUNET_GNS_ClientLookupMessage
62 {
63   /**
64    * Header of type GNUNET_MESSAGE_TYPE_GNS_CLIENT_LOOKUP
65    */
66   struct GNUNET_MessageHeader header;
67
68   /**
69    * Unique identifier for this request (for key collisions).
70    */
71   uint32_t id GNUNET_PACKED;
72
73   /**
74    * If use_default_zone is empty this zone is used for lookup
75    */
76   struct GNUNET_CRYPTO_ShortHashCode zone;
77
78   /**
79    * Only check cached results
80    */
81   uint32_t only_cached GNUNET_PACKED;
82
83   /**
84    * Should we look up in the default zone?
85    */
86   uint32_t use_default_zone GNUNET_PACKED;
87
88   /**
89    * Is a shorten key attached?
90    */
91   uint32_t have_key GNUNET_PACKED;
92
93   /**
94    * the type of record to look up
95    */
96   /* enum GNUNET_GNS_RecordType */ uint32_t type;
97
98   /* Followed by the key for shorten (optional) see have_key */
99
100   /* Followed by the name to look up */
101 };
102
103
104 /**
105  * Message from GNS service to client: new results.
106  */
107 struct GNUNET_GNS_ClientLookupResultMessage
108 {
109   /**
110     * Header of type GNUNET_MESSAGE_TYPE_GNS_CLIENT_RESULT
111    */
112   struct GNUNET_MessageHeader header;
113
114   /**
115    * Unique identifier for this request (for key collisions).
116    */
117   uint32_t id GNUNET_PACKED;
118
119   /**
120    * The number of records contained in response
121    */  
122   uint32_t rd_count;
123
124   /* followed by rd_count GNUNET_NAMESTORE_RecordData structs*/
125
126 };
127
128
129 /**
130  * Message from client to GNS service to shorten names.
131  */
132 struct GNUNET_GNS_ClientShortenMessage
133 {
134   /**
135    * Header of type GNUNET_MESSAGE_TYPE_GNS_CLIENT_SHORTEN
136    */
137   struct GNUNET_MessageHeader header;
138
139   /**
140    * Unique identifier for this request
141    */
142   uint32_t id GNUNET_PACKED;
143
144   /**
145    * If use_default_zone is empty this zone is used for lookup
146    */
147   struct GNUNET_CRYPTO_ShortHashCode zone;
148
149   /**
150    * Shorten zone
151    */
152   struct GNUNET_CRYPTO_ShortHashCode shorten_zone;
153
154   /**
155    * Private zone
156    */
157   struct GNUNET_CRYPTO_ShortHashCode private_zone;
158
159   /**
160    * Should we look up in the default zone?
161    */
162   uint32_t use_default_zone GNUNET_PACKED;
163   
164   /* Followed by the name to shorten up */
165 };
166
167
168 /**
169  * Message from GNS service to client: shorten result.
170  */
171 struct GNUNET_GNS_ClientShortenResultMessage
172 {
173   /**
174    * Header of type GNUNET_MESSAGE_TYPE_GNS_CLIENT_SHORTEN_RESULT
175    */
176   struct GNUNET_MessageHeader header;
177
178   /**
179    * Unique identifier for this request (for key collisions).
180    */
181   uint32_t id GNUNET_PACKED;
182
183   /* followed by the shortened name or '\0' for no result*/
184
185 };
186
187
188 /**
189  * Message from client to GNS service to lookup an authority of a name.
190  */
191 struct GNUNET_GNS_ClientGetAuthMessage
192 {
193   /**
194    * Header of type GNUNET_MESSAGE_TYPE_GNS_CLIENT_GET_AUTH
195    */
196   struct GNUNET_MessageHeader header;
197
198   /**
199    * Unique identifier for this request
200    */
201   uint32_t id GNUNET_PACKED;
202
203   /* Followed by the name to get authority for */
204 };
205
206
207 /**
208  * Message from GNS service to client: authority result.
209  */
210 struct GNUNET_GNS_ClientGetAuthResultMessage
211 {
212   /**
213    * Header of type GNUNET_MESSAGE_TYPE_GNS_CLIENT_GET_AUTH_RESULT
214    */
215   struct GNUNET_MessageHeader header;
216
217   /**
218    * Unique identifier for this request (for key collisions).
219    */
220   uint32_t id GNUNET_PACKED;
221
222   /* followed by the authority part of the name or '\0' for no result*/
223
224 };
225
226 GNUNET_NETWORK_STRUCT_END
227
228 #endif