fix gnunet-gns performance issue for many egos
[oweals/gnunet.git] / src / identity / identity.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 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      SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21 /**
22  * @author Christian Grothoff
23  * @file identity/identity.h
24  *
25  * @brief Common type definitions for the identity
26  *        service and API.
27  */
28 #ifndef IDENTITY_H
29 #define IDENTITY_H
30
31 #include "gnunet_common.h"
32
33
34 GNUNET_NETWORK_STRUCT_BEGIN
35
36
37 /**
38  * Answer from service to client about last operation;
39  * GET_DEFAULT maybe answered with this message on failure;
40  * CREATE and RENAME will always be answered with this message.
41  */
42 struct ResultCodeMessage
43 {
44   /**
45    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE
46    */
47   struct GNUNET_MessageHeader header;
48
49   /**
50    * Status code for the last operation, in NBO.
51    * (currently not used).
52    */
53   uint32_t result_code GNUNET_PACKED;
54
55   /* followed by 0-terminated error message (on error) */
56 };
57
58
59 /**
60  * Client informs service about desire to lookup a (single) pseudonym.
61  */
62 struct LookupMessage
63 {
64   /**
65    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP or
66    * #GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX
67    */
68   struct GNUNET_MessageHeader header;
69
70   /* followed by 0-terminated ego name */
71 };
72
73
74 /**
75  * Service informs client about status of a pseudonym.
76  */
77 struct UpdateMessage
78 {
79   /**
80    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
81    */
82   struct GNUNET_MessageHeader header;
83
84   /**
85    * Number of bytes in ego name string including 0-termination, in NBO;
86    * 0 if the ego was deleted.
87    */
88   uint16_t name_len GNUNET_PACKED;
89
90   /**
91    * Usually #GNUNET_NO, #GNUNET_YES to signal end of list.
92    */
93   uint16_t end_of_list GNUNET_PACKED;
94
95   /**
96    * The private key
97    */
98   struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
99
100   /* followed by 0-terminated ego name */
101 };
102
103
104 /**
105  * Client requests knowledge about default identity for
106  * a subsystem from identity service.
107  */
108 struct GetDefaultMessage
109 {
110   /**
111    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT
112    */
113   struct GNUNET_MessageHeader header;
114
115   /**
116    * Number of bytes in service name string including 0-termination, in NBO.
117    */
118   uint16_t name_len GNUNET_PACKED;
119
120   /**
121    * Always zero.
122    */
123   uint16_t reserved GNUNET_PACKED;
124
125
126   /* followed by 0-terminated service name */
127 };
128
129
130 /**
131  * Used from service to client as a result to the GET_DEFAULT
132  * message, used from client to service to SET_DEFAULT.
133  */
134 struct SetDefaultMessage
135 {
136   /**
137    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT
138    */
139   struct GNUNET_MessageHeader header;
140
141   /**
142    * Number of bytes in service name string including 0-termination, in NBO.
143    */
144   uint16_t name_len GNUNET_PACKED;
145
146   /**
147    * Always zero.
148    */
149   uint16_t reserved GNUNET_PACKED;
150
151   /**
152    * The private key
153    */
154   struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
155
156   /* followed by 0-terminated service name */
157 };
158
159
160 /**
161  * Client requests creation of an identity.  Service
162  * will respond with a result code.
163  */
164 struct CreateRequestMessage
165 {
166   /**
167    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_CREATE
168    */
169   struct GNUNET_MessageHeader header;
170
171   /**
172    * Number of bytes in identity name string including 0-termination, in NBO.
173    */
174   uint16_t name_len GNUNET_PACKED;
175
176   /**
177    * Always zero.
178    */
179   uint16_t reserved GNUNET_PACKED;
180
181   /**
182    * The private key
183    */
184   struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
185
186   /* followed by 0-terminated identity name */
187 };
188
189
190 /**
191  * Client requests renaming of an identity.  Service
192  * will respond with a result code.
193  */
194 struct RenameMessage
195 {
196   /**
197    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_RENAME
198    */
199   struct GNUNET_MessageHeader header;
200
201   /**
202    * Number of characters in the old name including 0-termination, in NBO.
203    */
204   uint16_t old_name_len GNUNET_PACKED;
205
206   /**
207    * Number of characters in the new name including 0-termination, in NBO.
208    */
209   uint16_t new_name_len GNUNET_PACKED;
210
211   /* followed by 0-terminated old name */
212   /* followed by 0-terminated new name */
213 };
214
215
216 /**
217  * Client requests deletion of an identity.  Service
218  * will respond with a result code.
219  */
220 struct DeleteMessage
221 {
222   /**
223    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_DELETE
224    */
225   struct GNUNET_MessageHeader header;
226
227   /**
228    * Number of characters in the name including 0-termination, in NBO.
229    */
230   uint16_t name_len GNUNET_PACKED;
231
232   /**
233    * Always zero.
234    */
235   uint16_t reserved GNUNET_PACKED;
236
237   /* followed by 0-terminated name */
238 };
239
240 GNUNET_NETWORK_STRUCT_END
241
242 /**
243  * Handle for an ego.
244  */
245 struct GNUNET_IDENTITY_Ego
246 {
247   /**
248    * Private key associated with this ego.
249    */
250   struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
251
252   /**
253    * Current name associated with this ego.
254    */
255   char *name;
256
257   /**
258    * Client context associated with this ego.
259    */
260   void *ctx;
261
262   /**
263    * Hash of the public key of this ego.
264    */
265   struct GNUNET_HashCode id;
266 };
267
268
269 #endif