diff options
-rw-r--r-- | src/identity/identity.h | 196 | ||||
-rw-r--r-- | src/identity/identity_api.c | 147 |
2 files changed, 332 insertions, 11 deletions
diff --git a/src/identity/identity.h b/src/identity/identity.h index 04cfc110f..e563cdd34 100644 --- a/src/identity/identity.h +++ b/src/identity/identity.h | |||
@@ -37,21 +37,203 @@ | |||
37 | 37 | ||
38 | GNUNET_NETWORK_STRUCT_BEGIN | 38 | GNUNET_NETWORK_STRUCT_BEGIN |
39 | 39 | ||
40 | |||
40 | /** | 41 | /** |
41 | * Network size estimate sent from the service | 42 | * Answer from service to client about last operation; |
42 | * to clients. Contains the current size estimate | 43 | * GET_DEFAULT maybe answered with this message on failure; |
43 | * (or 0 if none has been calculated) and the | 44 | * CREATE and RENAME will always be answered with this message. |
44 | * standard deviation of known estimates. | ||
45 | * | ||
46 | */ | 45 | */ |
47 | struct GNUNET_IDENTITY_XXXMessage | 46 | struct GNUNET_IDENTITY_ResultCodeMessage |
48 | { | 47 | { |
49 | /** | 48 | /** |
50 | * Type: GNUNET_MESSAGE_TYPE_IDENTITY_XXX | 49 | * Type: GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE |
51 | */ | 50 | */ |
52 | struct GNUNET_MessageHeader header; | 51 | struct GNUNET_MessageHeader header; |
53 | 52 | ||
53 | /** | ||
54 | * Status code for the last operation, in NBO. | ||
55 | */ | ||
56 | uint32_t result_code GNUNET_PACKED; | ||
57 | |||
58 | /* followed by 0-terminated error message (on error) */ | ||
59 | |||
54 | }; | 60 | }; |
61 | |||
62 | |||
63 | /** | ||
64 | * Service informs client about status of a pseudonym. | ||
65 | */ | ||
66 | struct GNUNET_IDENTITY_UpdateMessage | ||
67 | { | ||
68 | /** | ||
69 | * Type: GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE | ||
70 | */ | ||
71 | struct GNUNET_MessageHeader header; | ||
72 | |||
73 | /** | ||
74 | * Number of bytes in identity name string including 0-termination, in NBO; | ||
75 | * 0 if the identity was deleted. | ||
76 | */ | ||
77 | uint16_t name_len GNUNET_PACKED; | ||
78 | |||
79 | /** | ||
80 | * Always zero. | ||
81 | */ | ||
82 | uint16_t reserved GNUNET_PACKED; | ||
83 | |||
84 | /** | ||
85 | * Public key of the identity that we provide an update about. | ||
86 | */ | ||
87 | struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded private_key; | ||
88 | |||
89 | /* followed by 0-terminated identity name */ | ||
90 | |||
91 | }; | ||
92 | |||
93 | |||
94 | |||
95 | /** | ||
96 | * Client requests knowledge about default identity for | ||
97 | * a subsystem from identity service. | ||
98 | */ | ||
99 | struct GNUNET_IDENTITY_GetDefaultMessage | ||
100 | { | ||
101 | /** | ||
102 | * Type: GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT | ||
103 | */ | ||
104 | struct GNUNET_MessageHeader header; | ||
105 | |||
106 | /** | ||
107 | * Number of bytes in service name string including 0-termination, in NBO. | ||
108 | */ | ||
109 | uint16_t name_len GNUNET_PACKED; | ||
110 | |||
111 | /** | ||
112 | * Always zero. | ||
113 | */ | ||
114 | uint16_t reserved GNUNET_PACKED; | ||
115 | |||
116 | |||
117 | /* followed by 0-terminated service name */ | ||
118 | |||
119 | }; | ||
120 | |||
121 | |||
122 | /** | ||
123 | * Used from service to client as a result to the GET_DEFAULT | ||
124 | * message, used from client to service to SET_DEFAULT. | ||
125 | */ | ||
126 | struct GNUNET_IDENTITY_SetDefaultMessage | ||
127 | { | ||
128 | /** | ||
129 | * Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT | ||
130 | */ | ||
131 | struct GNUNET_MessageHeader header; | ||
132 | |||
133 | /** | ||
134 | * Number of bytes in service name string including 0-termination, in NBO. | ||
135 | */ | ||
136 | uint16_t name_len GNUNET_PACKED; | ||
137 | |||
138 | /** | ||
139 | * Always zero. | ||
140 | */ | ||
141 | uint16_t reserved GNUNET_PACKED; | ||
142 | |||
143 | /** | ||
144 | * Public key of the identity to use. | ||
145 | */ | ||
146 | struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded private_key; | ||
147 | |||
148 | /* followed by 0-terminated service name */ | ||
149 | |||
150 | }; | ||
151 | |||
152 | |||
153 | /** | ||
154 | * Client requests creation of an identity. Service | ||
155 | * will respond with a result code. | ||
156 | */ | ||
157 | struct GNUNET_IDENTITY_CreateRequestMessage | ||
158 | { | ||
159 | /** | ||
160 | * Type: GNUNET_MESSAGE_TYPE_IDENTITY_CREATE | ||
161 | */ | ||
162 | struct GNUNET_MessageHeader header; | ||
163 | |||
164 | /** | ||
165 | * Number of bytes in identity name string including 0-termination, in NBO. | ||
166 | */ | ||
167 | uint16_t name_len GNUNET_PACKED; | ||
168 | |||
169 | /** | ||
170 | * Always zero. | ||
171 | */ | ||
172 | uint16_t reserved GNUNET_PACKED; | ||
173 | |||
174 | /** | ||
175 | * Public key of the identity to use. | ||
176 | */ | ||
177 | struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded private_key; | ||
178 | |||
179 | /* followed by 0-terminated identity name */ | ||
180 | |||
181 | }; | ||
182 | |||
183 | |||
184 | /** | ||
185 | * Client requests renaming of an identity. Service | ||
186 | * will respond with a result code. | ||
187 | */ | ||
188 | struct GNUNET_IDENTITY_RenameMessage | ||
189 | { | ||
190 | /** | ||
191 | * Type: GNUNET_MESSAGE_TYPE_IDENTITY_RENAME | ||
192 | */ | ||
193 | struct GNUNET_MessageHeader header; | ||
194 | |||
195 | /** | ||
196 | * Number of characters in the old name including 0-termination, in NBO. | ||
197 | */ | ||
198 | uint16_t old_name_len GNUNET_PACKED; | ||
199 | |||
200 | /** | ||
201 | * Number of characters in the new name including 0-termination, in NBO. | ||
202 | */ | ||
203 | uint16_t new_name_len GNUNET_PACKED; | ||
204 | |||
205 | /* followed by 0-terminated old name */ | ||
206 | /* followed by 0-terminated new name */ | ||
207 | }; | ||
208 | |||
209 | |||
210 | /** | ||
211 | * Client requests deletion of an identity. Service | ||
212 | * will respond with a result code. | ||
213 | */ | ||
214 | struct GNUNET_IDENTITY_DeleteMessage | ||
215 | { | ||
216 | /** | ||
217 | * Type: GNUNET_MESSAGE_TYPE_IDENTITY_DELETE | ||
218 | */ | ||
219 | struct GNUNET_MessageHeader header; | ||
220 | |||
221 | /** | ||
222 | * Number of characters in the name including 0-termination, in NBO. | ||
223 | */ | ||
224 | uint16_t name_len GNUNET_PACKED; | ||
225 | |||
226 | /** | ||
227 | * Always zero. | ||
228 | */ | ||
229 | uint16_t reserved GNUNET_PACKED; | ||
230 | |||
231 | /* followed by 0-terminated name */ | ||
232 | |||
233 | }; | ||
234 | |||
235 | |||
236 | |||
55 | GNUNET_NETWORK_STRUCT_END | 237 | GNUNET_NETWORK_STRUCT_END |
56 | 238 | ||
57 | #endif | 239 | #endif |
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index 091a1d60c..81f66ca0d 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c | |||
@@ -37,6 +37,14 @@ | |||
37 | 37 | ||
38 | #define LOG(kind,...) GNUNET_log_from (kind, "identity-api",__VA_ARGS__) | 38 | #define LOG(kind,...) GNUNET_log_from (kind, "identity-api",__VA_ARGS__) |
39 | 39 | ||
40 | /** | ||
41 | * Handle for a pseudonym. | ||
42 | */ | ||
43 | struct GNUNET_IDENTITY_Pseudonym | ||
44 | { | ||
45 | }; | ||
46 | |||
47 | |||
40 | /** | 48 | /** |
41 | * Handle for the service. | 49 | * Handle for the service. |
42 | */ | 50 | */ |
@@ -77,7 +85,8 @@ struct GNUNET_IDENTITY_Handle | |||
77 | * @param tc scheduler context | 85 | * @param tc scheduler context |
78 | */ | 86 | */ |
79 | static void | 87 | static void |
80 | reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 88 | reconnect (void *cls, |
89 | const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
81 | 90 | ||
82 | 91 | ||
83 | /** | 92 | /** |
@@ -88,7 +97,8 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | |||
88 | * @param msg message received, NULL on timeout or fatal error | 97 | * @param msg message received, NULL on timeout or fatal error |
89 | */ | 98 | */ |
90 | static void | 99 | static void |
91 | message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | 100 | message_handler (void *cls, |
101 | const struct GNUNET_MessageHeader *msg) | ||
92 | { | 102 | { |
93 | struct GNUNET_IDENTITY_Handle *h = cls; | 103 | struct GNUNET_IDENTITY_Handle *h = cls; |
94 | const struct GNUNET_IDENTITY_ClientMessage *client_msg; | 104 | const struct GNUNET_IDENTITY_ClientMessage *client_msg; |
@@ -148,9 +158,11 @@ reschedule_connect (struct GNUNET_IDENTITY_Handle *h) | |||
148 | * @return number of bytes copied to buf | 158 | * @return number of bytes copied to buf |
149 | */ | 159 | */ |
150 | static size_t | 160 | static size_t |
151 | send_start (void *cls, size_t size, void *buf) | 161 | send_start (void *cls, |
162 | size_t size, | ||
163 | void *buf) | ||
152 | { | 164 | { |
153 | return sizeof (struct GNUNET_MessageHeader); | 165 | return 0; |
154 | } | 166 | } |
155 | 167 | ||
156 | 168 | ||
@@ -210,6 +222,133 @@ GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
210 | 222 | ||
211 | 223 | ||
212 | /** | 224 | /** |
225 | * Obtain the ECC key associated with a pseudonym. | ||
226 | * | ||
227 | * @param pseudonym the pseudonym | ||
228 | * @return associated ECC key, valid as long as the pseudonym is valid | ||
229 | */ | ||
230 | const struct GNUNET_CRYPTO_EccPrivateKey * | ||
231 | GNUNET_IDENTITY_pseudonym_get_key (struct GNUNET_IDENTITY_Pseudonym *pseudonym) | ||
232 | { | ||
233 | return NULL; | ||
234 | } | ||
235 | |||
236 | |||
237 | /** | ||
238 | * Obtain the identity that is currently preferred/default | ||
239 | * for a service. | ||
240 | * | ||
241 | * @param id identity service to query | ||
242 | * @param service_name for which service is an identity wanted | ||
243 | * @param cb function to call with the result (will only be called once) | ||
244 | * @param cb_cls closure for cb | ||
245 | * @return handle to abort the operation | ||
246 | */ | ||
247 | struct GNUNET_IDENTITY_Operation * | ||
248 | GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *id, | ||
249 | const char *service_name, | ||
250 | GNUNET_IDENTITY_Callback cb, | ||
251 | void *cb_cls) | ||
252 | { | ||
253 | return NULL; | ||
254 | } | ||
255 | |||
256 | |||
257 | /** | ||
258 | * Set the preferred/default identity for a service. | ||
259 | * | ||
260 | * @param id identity service to inform | ||
261 | * @param service_name for which service is an identity set | ||
262 | * @param pseu new default identity to be set for this service | ||
263 | * @param cont function to call once the operation finished | ||
264 | * @param cont_cls closure for cont | ||
265 | * @return handle to abort the operation | ||
266 | */ | ||
267 | struct GNUNET_IDENTITY_Operation * | ||
268 | GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *id, | ||
269 | const char *service_name, | ||
270 | struct GNUNET_IDENTITY_Pseudonym *pseu, | ||
271 | GNUNET_IDENTITY_Continuation cont, | ||
272 | void *cont_cls) | ||
273 | { | ||
274 | return NULL; | ||
275 | } | ||
276 | |||
277 | |||
278 | /** | ||
279 | * Create a new identity with the given identifier. | ||
280 | * | ||
281 | * @param id identity service to use | ||
282 | * @param identifier desired identifier | ||
283 | * @param cb function to call with the result (will only be called once) | ||
284 | * @param cb_cls closure for cb | ||
285 | * @return handle to abort the operation | ||
286 | */ | ||
287 | struct GNUNET_IDENTITY_Operation * | ||
288 | GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id, | ||
289 | const char *identifier, | ||
290 | GNUNET_IDENTITY_Callback cb, | ||
291 | void *cb_cls) | ||
292 | { | ||
293 | return NULL; | ||
294 | } | ||
295 | |||
296 | |||
297 | /** | ||
298 | * Renames an existing identity. | ||
299 | * | ||
300 | * @param id identity service to use | ||
301 | * @param old_identifier old identifier | ||
302 | * @param new_identifier desired new identifier | ||
303 | * @param cb function to call with the result (will only be called once) | ||
304 | * @param cb_cls closure for cb | ||
305 | * @return handle to abort the operation | ||
306 | */ | ||
307 | struct GNUNET_IDENTITY_Operation * | ||
308 | GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id, | ||
309 | const char *old_identifier, | ||
310 | const char *new_identifier, | ||
311 | GNUNET_IDENTITY_Continuation cb, | ||
312 | void *cb_cls) | ||
313 | { | ||
314 | return NULL; | ||
315 | } | ||
316 | |||
317 | |||
318 | /** | ||
319 | * Delete an existing identity. | ||
320 | * | ||
321 | * @param id identity service to use | ||
322 | * @param identifier identifier of the identity to delete | ||
323 | * @param cb function to call with the result (will only be called once) | ||
324 | * @param cb_cls closure for cb | ||
325 | * @return handle to abort the operation | ||
326 | */ | ||
327 | struct GNUNET_IDENTITY_Operation * | ||
328 | GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id, | ||
329 | const char *identifier, | ||
330 | GNUNET_IDENTITY_Continuation cb, | ||
331 | void *cb_cls) | ||
332 | { | ||
333 | return NULL; | ||
334 | } | ||
335 | |||
336 | |||
337 | /** | ||
338 | * Cancel an identity operation. Note that the operation MAY still | ||
339 | * be executed; this merely cancels the continuation; if the request | ||
340 | * was already transmitted, the service may still choose to complete | ||
341 | * the operation. | ||
342 | * | ||
343 | * @param op operation to cancel | ||
344 | */ | ||
345 | void | ||
346 | GNUNET_IDENITY_cancel (struct GNUNET_IDENTITY_Operation *op) | ||
347 | { | ||
348 | } | ||
349 | |||
350 | |||
351 | /** | ||
213 | * Disconnect from identity service | 352 | * Disconnect from identity service |
214 | * | 353 | * |
215 | * @param h handle to destroy | 354 | * @param h handle to destroy |