aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_bio_lib.h559
-rw-r--r--src/include/gnunet_buffer_lib.h13
-rw-r--r--src/include/gnunet_crypto_lib.h33
-rw-r--r--src/include/gnunet_identity_service.h2
-rw-r--r--src/include/gnunet_os_lib.h8
-rw-r--r--src/include/gnunet_protocols.h67
-rw-r--r--src/include/gnunet_signatures.h4
-rw-r--r--src/include/gnunet_transport_communication_service.h29
8 files changed, 568 insertions, 147 deletions
diff --git a/src/include/gnunet_bio_lib.h b/src/include/gnunet_bio_lib.h
index 2f715ec97..687334c1c 100644
--- a/src/include/gnunet_bio_lib.h
+++ b/src/include/gnunet_bio_lib.h
@@ -42,6 +42,8 @@ extern "C"
42#endif 42#endif
43#endif 43#endif
44 44
45/****************************** READING API *******************************/
46
45/** 47/**
46 * Handle for buffered reading. 48 * Handle for buffered reading.
47 */ 49 */
@@ -55,11 +57,22 @@ struct GNUNET_BIO_ReadHandle;
55 * @return IO handle on success, NULL on error 57 * @return IO handle on success, NULL on error
56 */ 58 */
57struct GNUNET_BIO_ReadHandle * 59struct GNUNET_BIO_ReadHandle *
58GNUNET_BIO_read_open (const char *fn); 60GNUNET_BIO_read_open_file (const char *fn);
61
62
63/**
64 * Create a handle from an existing allocated buffer.
65 *
66 * @param buffer the buffer to use as source
67 * @param size the total size in bytes of the buffer
68 * @return IO handle on sucess, NULL on error
69 */
70struct GNUNET_BIO_ReadHandle *
71GNUNET_BIO_read_open_buffer (void *buffer, size_t size);
59 72
60 73
61/** 74/**
62 * Close an open file. Reports if any errors reading 75 * Close an open handle. Reports if any errors reading
63 * from the file were encountered. 76 * from the file were encountered.
64 * 77 *
65 * @param h file handle 78 * @param h file handle
@@ -71,51 +84,40 @@ GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg);
71 84
72 85
73/** 86/**
74 * Read the contents of a binary file into a buffer. 87 * Read some contents into a buffer.
75 * 88 *
76 * @param h handle to an open file 89 * @param h the IO handle to read from
77 * @param what describes what is being read (for error message creation) 90 * @param what describes what is being read (for error message creation)
78 * @param result the buffer to write the result to 91 * @param result the buffer to write the result to
79 * @param len the number of bytes to read 92 * @param len the number of bytes to read
80 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 93 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
81 */ 94 */
82int 95int
83GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, const char *what, 96GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h,
84 void *result, size_t len); 97 const char *what,
98 void *result,
99 size_t len);
85 100
86 101
87/** 102/**
88 * Read the contents of a binary file into a buffer. 103 * Read 0-terminated string.
89 * 104 *
90 * @param h handle to an open file 105 * @param h the IO handle to read from
91 * @param file name of the source file
92 * @param line line number in the source file
93 * @param result the buffer to write the result to
94 * @param len the number of bytes to read
95 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
96 */
97int
98GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h,
99 const char *file, int line,
100 void *result, size_t len);
101
102/**
103 * Read 0-terminated string from a file.
104 *
105 * @param h handle to an open file
106 * @param what describes what is being read (for error message creation) 106 * @param what describes what is being read (for error message creation)
107 * @param result the buffer to store a pointer to the (allocated) string to 107 * @param result where to store the pointer to the (allocated) string
108 * (note that *result could be set to NULL as well) 108 * (note that *result could be set to NULL as well)
109 * @param max_length maximum allowed length for the string 109 * @param max_length maximum allowed length for the string
110 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 110 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
111 */ 111 */
112int 112int
113GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what, 113GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
114 char **result, size_t max_length); 114 const char *what,
115 char **result,
116 size_t max_length);
115 117
116 118
117/** 119/**
118 * Read metadata container from a file. 120 * Read a metadata container.
119 * 121 *
120 * @param h handle to an open file 122 * @param h handle to an open file
121 * @param what describes what is being read (for error message creation) 123 * @param what describes what is being read (for error message creation)
@@ -123,79 +125,69 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what,
123 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure 125 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
124 */ 126 */
125int 127int
126GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, const char *what, 128GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
129 const char *what,
127 struct GNUNET_CONTAINER_MetaData **result); 130 struct GNUNET_CONTAINER_MetaData **result);
128 131
129 132
130/** 133/**
131 * Read a float. 134 * Read a float.
132 * 135 *
133 * @param h hande to open file 136 * @param h the IO handle to read from
137 * @param what describes what is being read (for error message creation)
134 * @param f address of float to read 138 * @param f address of float to read
135 */ 139 */
136#define GNUNET_BIO_read_float(h, f) (GNUNET_BIO_read_fn (h, __FILE__, __LINE__, \ 140int
137 f, sizeof(float))) 141GNUNET_BIO_read_float(struct GNUNET_BIO_ReadHandle *h,
142 const char *what,
143 float *f);
138 144
139 145
140/** 146/**
141 * Read a double. 147 * Read a double.
142 * 148 *
143 * @param h hande to open file 149 * @param h the IO handle to read from
150 * @param what describes what is being read (for error message creation)
144 * @param f address of double to read 151 * @param f address of double to read
145 */ 152 */
146#define GNUNET_BIO_read_double(h, f) (GNUNET_BIO_read_fn (h, __FILE__, __LINE__, \ 153int
147 f, sizeof(double))) 154GNUNET_BIO_read_double(struct GNUNET_BIO_ReadHandle *h,
155 const char *what,
156 double *f);
157
148 158
149 159
150/** 160/**
151 * Read an (u)int32_t. 161 * Read an (u)int32_t.
152 * 162 *
153 * @param h hande to open file 163 * @param h the IO handle to read from
154 * @param file name of the source file 164 * @param what describes what is being read (for error message creation)
155 * @param line line number in the code 165 * @param i where to store the data
156 * @param i address of 32-bit integer to read
157 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 166 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
158 */ 167 */
159int 168int
160GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, const char *file, 169GNUNET_BIO_read_int32 (struct GNUNET_BIO_ReadHandle *h,
161 int line, int32_t *i); 170 const char *what,
162 171 int32_t *i);
163 172
164/**
165 * Read an (u)int32_t.
166 *
167 * @param h hande to open file
168 * @param i address of 32-bit integer to read
169 */
170#define GNUNET_BIO_read_int32(h, i) GNUNET_BIO_read_int32__ (h, __FILE__, \
171 __LINE__, \
172 (int32_t *) i)
173 173
174 174
175/** 175/**
176 * Read an (u)int64_t. 176 * Read an (u)int64_t.
177 * 177 *
178 * @param h hande to open file 178 * @param h the IO handle to read from
179 * @param file name of the source file 179 * @param what describes what is being read (for error message creation)
180 * @param line line number in the code 180 * @param i where to store the data
181 * @param i address of 64-bit integer to read
182 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 181 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
183 */ 182 */
184int 183int
185GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h, const char *file, 184GNUNET_BIO_read_int64 (struct GNUNET_BIO_ReadHandle *h,
186 int line, int64_t *i); 185 const char *what,
186 int64_t *i);
187 187
188 188
189/**
190 * Read an (u)int64_t.
191 *
192 * @param h hande to open file
193 * @param i address of 64-bit integer to read
194 */
195#define GNUNET_BIO_read_int64(h, i) GNUNET_BIO_read_int64__ (h, __FILE__, \
196 __LINE__, \
197 (int64_t *) i)
198 189
190/****************************** WRITING API *******************************/
199 191
200/** 192/**
201 * Handle for buffered writing. 193 * Handle for buffered writing.
@@ -205,108 +197,481 @@ struct GNUNET_BIO_WriteHandle;
205/** 197/**
206 * Open a file for writing. 198 * Open a file for writing.
207 * 199 *
208 * @param fn file name to be opened 200 * @param fn name of the file to be opened
209 * @return IO handle on success, NULL on error 201 * @return IO handle on success, NULL on error
210 */ 202 */
211struct GNUNET_BIO_WriteHandle * 203struct GNUNET_BIO_WriteHandle *
212GNUNET_BIO_write_open (const char *fn); 204GNUNET_BIO_write_open_file (const char *fn);
213 205
214 206
215/** 207/**
216 * Close an open file for writing. 208 * Create a handle backed by an in-memory buffer.
217 * 209 *
218 * @param h file handle 210 * @return IO handle on success, NULL on error
219 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 211 */
212struct GNUNET_BIO_WriteHandle *
213GNUNET_BIO_write_open_buffer (void);
214
215
216/**
217 * Force a file-based buffered writer to flush its buffer.
218 * If the handle does not use a file, this function returs #GNUNET_OK
219 * without doing anything.
220 *
221 * @param h the IO handle
222 * @return #GNUNET_OK upon success. Upon failure #GNUNET_SYSERR is returned
223 * and the file is closed
220 */ 224 */
221int 225int
222GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h); 226GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h);
223 227
224 228
225/** 229/**
226 * Write a buffer to a file. 230 * Get the IO handle's contents.
231 * If the handle doesn't use an in-memory buffer, this function returns
232 * #GNUNET_SYSERR.
227 * 233 *
228 * @param h handle to open file 234 * @param h the IO handle
229 * @param buffer the data to write 235 * @param emsg set to the (allocated) error message
230 * @param n number of bytes to write 236 * if the handle has an error message the return value is #GNUNET_SYSERR
231 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 237 * @param contents where to store the pointer to the handle's contents
238 * @param size where to store the size of @e contents
239 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
232 */ 240 */
233int 241int
234GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, const void *buffer, 242GNUNET_BIO_get_buffer_contents (struct GNUNET_BIO_WriteHandle *h,
235 size_t n); 243 char **emsg,
244 void **contents,
245 size_t *size);
246
247
248/**
249 * Close an IO handle.
250 * If the handle was using a file, the file will be closed.
251 *
252 * @param h file handle
253 * @param emsg set to the (allocated) error message
254 * if the handle has an error message, the return value is #GNUNET_SYSERR
255 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
256 */
257int
258GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h, char **emsg);
236 259
237 260
238/** 261/**
239 * Force a buffered writer to flush its buffer 262 * Write a buffer to a handle.
240 * 263 *
241 * @param h the writer handle 264 * @param h the IO handle to write to
242 * @return #GNUNET_OK upon success. Upon failure #GNUNET_SYSERR is returned and 265 * @param what what is being written (for error message creation)
243 * the file is closed 266 * @param buffer the data to write
267 * @param n number of bytes to write
268 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
244 */ 269 */
245int 270int
246GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h); 271GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h,
272 const char *what,
273 const void *buffer,
274 size_t n);
247 275
248 276
249/** 277/**
250 * Write a string to a file. 278 * Write a 0-terminated string.
251 * 279 *
252 * @param h handle to open file 280 * @param h the IO handle to write to
281 * @param what what is being written (for error message creation)
253 * @param s string to write (can be NULL) 282 * @param s string to write (can be NULL)
254 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 283 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
255 */ 284 */
256int 285int
257GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, const char *s); 286GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h,
287 const char *what,
288 const char *s);
258 289
259 290
260/** 291/**
261 * Write metadata container to a file. 292 * Write a metadata container.
262 * 293 *
263 * @param h handle to open file 294 * @param h the IO handle to write to
295 * @param what what is being written (for error message creation)
264 * @param m metadata to write 296 * @param m metadata to write
265 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 297 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
266 */ 298 */
267int 299int
268GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h, 300GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
301 const char *what,
269 const struct GNUNET_CONTAINER_MetaData *m); 302 const struct GNUNET_CONTAINER_MetaData *m);
270 303
271 304
272/** 305/**
273 * Write a float. 306 * Write a float.
274 * 307 *
275 * @param h hande to open file 308 * @param h the IO handle to write to
309 * @param what what is being written (for error message creation)
276 * @param f float to write (must be a variable) 310 * @param f float to write (must be a variable)
277 */ 311 */
278#define GNUNET_BIO_write_float(h, f) GNUNET_BIO_write (h, &f, sizeof(float)) 312int
279 313GNUNET_BIO_write_float(struct GNUNET_BIO_WriteHandle *h,
314 const char *what,
315 float f);
280 316
281/** 317/**
282 * Write a double. 318 * Write a double.
283 * 319 *
284 * @param h hande to open file 320 * @param h the IO handle to write to
321 * @param what what is being written (for error message creation)
285 * @param f double to write (must be a variable) 322 * @param f double to write (must be a variable)
286 */ 323 */
287#define GNUNET_BIO_write_double(h, f) GNUNET_BIO_write (h, &f, sizeof(double)) 324int
325GNUNET_BIO_write_double(struct GNUNET_BIO_WriteHandle *h,
326 const char *what,
327 double f);
288 328
289 329
290/** 330/**
291 * Write an (u)int32_t. 331 * Write an (u)int32_t.
292 * 332 *
293 * @param h hande to open file 333 * @param h the IO handle to write to
334 * @param what what is being written (for error message creation)
294 * @param i 32-bit integer to write 335 * @param i 32-bit integer to write
295 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 336 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
296 */ 337 */
297int 338int
298GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, int32_t i); 339GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h,
340 const char *what,
341 int32_t i);
299 342
300 343
301/** 344/**
302 * Write an (u)int64_t. 345 * Write an (u)int64_t.
303 * 346 *
304 * @param h hande to open file 347 * @param h the IO handle to write to
348 * @param what what is being written (for error message creation)
305 * @param i 64-bit integer to write 349 * @param i 64-bit integer to write
306 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 350 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
307 */ 351 */
308int 352int
309GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, int64_t i); 353GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h,
354 const char *what,
355 int64_t i);
356
357
358/****************************** READ SPEC API ***************************/
359
360
361/**
362 * Function used to deserialize data read from @a h and store it into @a
363 * target.
364 *
365 * @param cls closure (can be NULL)
366 * @param h the IO handle to read from
367 * @param what what is being read (for error message creation)
368 * @param target where to store the data
369 * @param target_size how many bytes can be written in @a target
370 * can be 0 if the size is unknown or is not fixed
371 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
372 */
373typedef int
374(*GNUNET_BIO_ReadHandler)(void *cls,
375 struct GNUNET_BIO_ReadHandle *h,
376 const char *what,
377 void *target,
378 size_t target_size);
379
380
381/**
382 * Structure specifying a reading operation on an IO handle.
383 */
384struct GNUNET_BIO_ReadSpec
385{
386 /**
387 * Function performing data deserialization.
388 */
389 GNUNET_BIO_ReadHandler rh;
390
391 /**
392 * Closure for @e rh. Can be NULL.
393 */
394 void *cls;
395
396 /**
397 * What is being read (for error message creation)
398 */
399 const char *what;
400
401 /**
402 * Destination buffer. Can also be a pointer to a pointer, especially for
403 * dynamically allocated structures.
404 */
405 void *target;
406
407 /**
408 * Size of @e target. Can be 0 if unknown or not fixed.
409 */
410 size_t size;
411};
412
413
414/**
415 * End of specifications marker.
416 */
417#define GNUNET_BIO_read_spec_end() \
418 { NULL, NULL, NULL, NULL, 0 }
419
420
421/**
422 * Create the specification to read a certain amount of bytes.
423 *
424 * @param what describes what is being read (for error message creation)
425 * @param result the buffer to write the result to
426 * @param len the number of bytes to read
427 * @return the read spec
428 */
429struct GNUNET_BIO_ReadSpec
430GNUNET_BIO_read_spec_object (const char *what,
431 void *result,
432 size_t size);
433
434
435/**
436 * Create the specification to read a 0-terminated string.
437 *
438 * @param what describes what is being read (for error message creation)
439 * @param result where to store the pointer to the (allocated) string
440 * (note that *result could be set to NULL as well)
441 * @param max_length maximum allowed length for the string
442 * @return the read spec
443 */
444struct GNUNET_BIO_ReadSpec
445GNUNET_BIO_read_spec_string (const char *what,
446 char **result,
447 size_t max_length);
448
449
450/**
451 * Create the specification to read a metadata container.
452 *
453 * @param what describes what is being read (for error message creation)
454 * @param result the buffer to store a pointer to the (allocated) metadata
455 * @return the read spec
456 */
457struct GNUNET_BIO_ReadSpec
458GNUNET_BIO_read_spec_meta_data (const char *what,
459 struct GNUNET_CONTAINER_MetaData **result);
460
461
462/**
463 * Create the specification to read an (u)int32_t.
464 *
465 * @param what describes what is being read (for error message creation)
466 * @param i where to store the data
467 * @return the read spec
468 */
469struct GNUNET_BIO_ReadSpec
470GNUNET_BIO_read_spec_int32 (const char *what,
471 int32_t *i);
472
473
474/**
475 * Create the specification to read an (u)int64_t.
476 *
477 * @param what describes what is being read (for error message creation)
478 * @param i where to store the data
479 * @return the read spec
480 */
481struct GNUNET_BIO_ReadSpec
482GNUNET_BIO_read_spec_int64 (const char *what,
483 int64_t *i);
484
485
486/**
487 * Create the specification to read a float.
488 *
489 * @param what describes what is being read (for error message creation)
490 * @param f address of float to read
491 */
492struct GNUNET_BIO_ReadSpec
493GNUNET_BIO_read_spec_float(const char *what, float *f);
494
495
496/**
497 * Create the specification to read a double.
498 *
499 * @param what describes what is being read (for error message creation)
500 * @param f address of double to read
501 */
502struct GNUNET_BIO_ReadSpec
503GNUNET_BIO_read_spec_double(const char *what, double *f);
504
505
506/**
507 * Execute the read specifications in order.
508 *
509 * @param h the IO handle to read from
510 * @param rs array of read specs
511 * the last element must be #GNUNET_BIO_read_spec_end
512 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
513 */
514int
515GNUNET_BIO_read_spec_commit (struct GNUNET_BIO_ReadHandle *h,
516 struct GNUNET_BIO_ReadSpec *rs);
517
518
519/******************************* WRITE SPEC API *****************************/
520
521
522/**
523 * Function used to serialize data from a buffer and write it to @a h.
524 *
525 * @param cls closure (can be NULL)
526 * @param h the IO handle to write to
527 * @param what what is being written (for error message creation)
528 * @param source the data to write
529 * @param source_size how many bytes should be written
530 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
531 */
532typedef int
533(*GNUNET_BIO_WriteHandler) (void *cls,
534 struct GNUNET_BIO_WriteHandle *h,
535 const char *what,
536 void *source,
537 size_t source_size);
538
539
540/**
541 * Structure specifying a writing operation on an IO handle.
542 */
543struct GNUNET_BIO_WriteSpec
544{
545 /**
546 * Function performing data serialization.
547 */
548 GNUNET_BIO_WriteHandler wh;
549
550 /**
551 * Closure for @e rh. Can be NULL.
552 */
553 void *cls;
554
555 /**
556 * What is being read (for error message creation)
557 */
558 const char *what;
559
560 /**
561 * Source buffer. The data in this buffer will be written to the handle.
562 */
563 void *source;
564
565 /**
566 * Size of @e source. If it's smaller than the real size of @e source, only
567 * this many bytes will be written.
568 */
569 size_t source_size;
570};
571
572
573/**
574 * End of specifications marker.
575 */
576#define GNUNET_BIO_write_spec_end() \
577 { NULL, NULL, NULL, NULL, 0 }
578
579
580/**
581 * Create the specification to read some bytes.
582 *
583 * @param what describes what is being written (for error message creation)
584 * @param source the data to write
585 * @param size how many bytes should be written
586 * @return the write spec
587 */
588struct GNUNET_BIO_WriteSpec
589GNUNET_BIO_write_spec_object (const char *what,
590 void *source,
591 size_t size);
592
593
594/**
595 * Create the specification to write a 0-terminated string.
596 *
597 * @param what describes what is being read (for error message creation)
598 * @param s string to write (can be NULL)
599 * @return the read spec
600 */
601struct GNUNET_BIO_WriteSpec
602GNUNET_BIO_write_spec_string (const char *what,
603 const char *s);
604
605
606/**
607 * Create the specification to write a metadata container.
608 *
609 * @param what what is being written (for error message creation)
610 * @param m metadata to write
611 * @return the write spec
612 */
613struct GNUNET_BIO_WriteSpec
614GNUNET_BIO_write_spec_meta_data (const char *what,
615 const struct GNUNET_CONTAINER_MetaData *m);
616
617
618/**
619 * Create the specification to write an (u)int32_t.
620 *
621 * @param what describes what is being written (for error message creation)
622 * @param i pointer to a 32-bit integer
623 * @return the write spec
624 */
625struct GNUNET_BIO_WriteSpec
626GNUNET_BIO_write_spec_int32 (const char *what,
627 int32_t *i);
628
629
630/**
631 * Create the specification to write an (u)int64_t.
632 *
633 * @param what describes what is being written (for error message creation)
634 * @param i pointer to a 64-bit integer
635 * @return the write spec
636 */
637struct GNUNET_BIO_WriteSpec
638GNUNET_BIO_write_spec_int64 (const char *what,
639 int64_t *i);
640
641
642/**
643 * Create the specification to write a float.
644 *
645 * @param what describes what is being written (for error message creation)
646 * @param f pointer to a float
647 * @return the write spec
648 */
649struct GNUNET_BIO_WriteSpec
650GNUNET_BIO_write_spec_float(const char *what, float *f);
651
652
653/**
654 * Create the specification to write an double.
655 *
656 * @param what describes what is being written (for error message creation)
657 * @param f pointer to a double
658 * @return the write spec
659 */
660struct GNUNET_BIO_WriteSpec
661GNUNET_BIO_write_spec_double(const char *what, double *f);
662
663
664/**
665 * Execute the write specifications in order.
666 *
667 * @param h the IO handle to write to
668 * @param ws array of write specs
669 * the last element must be #GNUNET_BIO_write_spec_end
670 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
671 */
672int
673GNUNET_BIO_write_spec_commit (struct GNUNET_BIO_WriteHandle *h,
674 struct GNUNET_BIO_WriteSpec *ws);
310 675
311 676
312#if 0 /* keep Emacsens' auto-indent happy */ 677#if 0 /* keep Emacsens' auto-indent happy */
diff --git a/src/include/gnunet_buffer_lib.h b/src/include/gnunet_buffer_lib.h
index c0ae06d77..e23536ab2 100644
--- a/src/include/gnunet_buffer_lib.h
+++ b/src/include/gnunet_buffer_lib.h
@@ -165,6 +165,19 @@ GNUNET_buffer_reap_str (struct GNUNET_Buffer *buf);
165 165
166 166
167/** 167/**
168 * Clear the buffer and return its contents.
169 * The caller is responsible to eventually #GNUNET_free
170 * the returned data.
171 *
172 * @param buf the buffer to reap the contents from
173 * @param size where to store the size of the returned data
174 * @returns the data contained in the string
175 */
176void *
177GNUNET_buffer_reap (struct GNUNET_Buffer *buf, size_t *size);
178
179
180/**
168 * Free the backing memory of the given buffer. 181 * Free the backing memory of the given buffer.
169 * Does not free the memory of the buffer control structure, 182 * Does not free the memory of the buffer control structure,
170 * which is typically stack-allocated. 183 * which is typically stack-allocated.
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index a5a50e749..d11c6b58c 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -659,7 +659,7 @@ GNUNET_CRYPTO_hash (const void *block,
659/** 659/**
660 * Calculate the 'proof-of-work' hash (an expensive hash). 660 * Calculate the 'proof-of-work' hash (an expensive hash).
661 * 661 *
662 * @param salt salt to use in pow calculation 662 * @param salt salt for the hash. Must be crypto_pwhash_argon2id_SALTBYTES long.
663 * @param buf data to hash 663 * @param buf data to hash
664 * @param buf_len number of bytes in @a buf 664 * @param buf_len number of bytes in @a buf
665 * @param result where to write the resulting hash 665 * @param result where to write the resulting hash
@@ -874,12 +874,25 @@ GNUNET_CRYPTO_hash_to_aes_key (
874 * Obtain a bit from a hashcode. 874 * Obtain a bit from a hashcode.
875 * 875 *
876 * @param code the `struct GNUNET_HashCode` to index bit-wise 876 * @param code the `struct GNUNET_HashCode` to index bit-wise
877 * @param bit index into the hashcode, [0...159] 877 * @param bit index into the hashcode, [0...159] where 0 is the leftmost bit
878 * (bytes in code interpreted big endian)
878 * @return Bit \a bit from hashcode \a code, -1 for invalid index 879 * @return Bit \a bit from hashcode \a code, -1 for invalid index
879 */ 880 */
880int 881int
881GNUNET_CRYPTO_hash_get_bit (const struct GNUNET_HashCode *code, 882GNUNET_CRYPTO_hash_get_bit_ltr (const struct GNUNET_HashCode *code,
882 unsigned int bit); 883 unsigned int bit);
884
885
886/**
887 * Obtain a bit from a hashcode.
888 * @param code the GNUNET_CRYPTO_hash to index bit-wise
889 * @param bit index into the hashcode, [0...511] where 0 is the rightmost bit
890 * (bytes in code interpreted little endian)
891 * @return Bit \a bit from hashcode \a code, -1 for invalid index
892 */
893int
894GNUNET_CRYPTO_hash_get_bit_rtl (const struct GNUNET_HashCode *code,
895 unsigned int bit);
883 896
884 897
885/** 898/**
@@ -2147,8 +2160,8 @@ GNUNET_CRYPTO_rsa_public_key_dup (const struct GNUNET_CRYPTO_RsaPublicKey *key);
2147 * @return 0 if the two are equal 2160 * @return 0 if the two are equal
2148 */ 2161 */
2149int 2162int
2150GNUNET_CRYPTO_rsa_signature_cmp (struct GNUNET_CRYPTO_RsaSignature *s1, 2163GNUNET_CRYPTO_rsa_signature_cmp (const struct GNUNET_CRYPTO_RsaSignature *s1,
2151 struct GNUNET_CRYPTO_RsaSignature *s2); 2164 const struct GNUNET_CRYPTO_RsaSignature *s2);
2152 2165
2153/** 2166/**
2154 * Compare the values of two private keys. 2167 * Compare the values of two private keys.
@@ -2158,8 +2171,8 @@ GNUNET_CRYPTO_rsa_signature_cmp (struct GNUNET_CRYPTO_RsaSignature *s1,
2158 * @return 0 if the two are equal 2171 * @return 0 if the two are equal
2159 */ 2172 */
2160int 2173int
2161GNUNET_CRYPTO_rsa_private_key_cmp (struct GNUNET_CRYPTO_RsaPrivateKey *p1, 2174GNUNET_CRYPTO_rsa_private_key_cmp (const struct GNUNET_CRYPTO_RsaPrivateKey *p1,
2162 struct GNUNET_CRYPTO_RsaPrivateKey *p2); 2175 const struct GNUNET_CRYPTO_RsaPrivateKey *p2);
2163 2176
2164 2177
2165/** 2178/**
@@ -2170,8 +2183,8 @@ GNUNET_CRYPTO_rsa_private_key_cmp (struct GNUNET_CRYPTO_RsaPrivateKey *p1,
2170 * @return 0 if the two are equal 2183 * @return 0 if the two are equal
2171 */ 2184 */
2172int 2185int
2173GNUNET_CRYPTO_rsa_public_key_cmp (struct GNUNET_CRYPTO_RsaPublicKey *p1, 2186GNUNET_CRYPTO_rsa_public_key_cmp (const struct GNUNET_CRYPTO_RsaPublicKey *p1,
2174 struct GNUNET_CRYPTO_RsaPublicKey *p2); 2187 const struct GNUNET_CRYPTO_RsaPublicKey *p2);
2175 2188
2176 2189
2177/** 2190/**
diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h
index 81af671e2..f4e653598 100644
--- a/src/include/gnunet_identity_service.h
+++ b/src/include/gnunet_identity_service.h
@@ -233,6 +233,7 @@ typedef void
233 * 233 *
234 * @param id identity service to use 234 * @param id identity service to use
235 * @param name desired name 235 * @param name desired name
236 * @param privkey desired private key or NULL to create one
236 * @param cont function to call with the result (will only be called once) 237 * @param cont function to call with the result (will only be called once)
237 * @param cont_cls closure for @a cont 238 * @param cont_cls closure for @a cont
238 * @return handle to abort the operation 239 * @return handle to abort the operation
@@ -240,6 +241,7 @@ typedef void
240struct GNUNET_IDENTITY_Operation * 241struct GNUNET_IDENTITY_Operation *
241GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id, 242GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
242 const char *name, 243 const char *name,
244 const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey,
243 GNUNET_IDENTITY_CreateContinuation cont, 245 GNUNET_IDENTITY_CreateContinuation cont,
244 void *cont_cls); 246 void *cont_cls);
245 247
diff --git a/src/include/gnunet_os_lib.h b/src/include/gnunet_os_lib.h
index a6188c1ca..b583cc493 100644
--- a/src/include/gnunet_os_lib.h
+++ b/src/include/gnunet_os_lib.h
@@ -287,6 +287,14 @@ struct GNUNET_OS_ProjectData
287 * If this field is NULL, the path is automatically inferred. 287 * If this field is NULL, the path is automatically inferred.
288 */ 288 */
289 char *gettext_path; 289 char *gettext_path;
290
291 /**
292 * URL pointing to the source code of the application. Required for AGPL.
293 * Setting this to NULL disables the built-in mechanism, but you must
294 * provide it in some other way. If non-NULL, message type 1 and 2 are
295 * reserved.
296 */
297 char *agpl_url;
290}; 298};
291 299
292 300
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index e67e35f38..0db6150aa 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -50,25 +50,29 @@ extern "C" {
50#endif 50#endif
51 51
52/******************************************************************************* 52/*******************************************************************************
53 * UTIL message types 53* Deprecated
54 ******************************************************************************/ 54* *****************************************************************************/
55 55
56/** 56/**
57 * Test if service is online. 57 * Test if service is online.
58 * 58 *
59 * @deprecated! 59 * @deprecated!
60 */ 60 */
61#define GNUNET_MESSAGE_TYPE_TEST 1 61#define GNUNET_MESSAGE_TYPE_TEST 0
62
63/*******************************************************************************
64* AGPL source code download
65* *****************************************************************************/
62 66
63/** 67/**
64 * Dummy messages for testing / benchmarking. 68 * Message to request source code link.
65 */ 69 */
66#define GNUNET_MESSAGE_TYPE_DUMMY 2 70#define GNUNET_MESSAGE_TYPE_REQUEST_AGPL 1
67 71
68/** 72/**
69 * Another dummy messages for testing / benchmarking. 73 * Source code link.
70 */ 74 */
71#define GNUNET_MESSAGE_TYPE_DUMMY2 3 75#define GNUNET_MESSAGE_TYPE_RESPONSE_AGPL 2
72 76
73/******************************************************************************* 77/*******************************************************************************
74 * RESOLVER message types 78 * RESOLVER message types
@@ -85,18 +89,18 @@ extern "C" {
85#define GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE 5 89#define GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE 5
86 90
87/******************************************************************************* 91/*******************************************************************************
88* AGPL source code download 92 * UTIL message types
89* *****************************************************************************/ 93 ******************************************************************************/
90 94
91/** 95/**
92 * Message to request source code link. 96 * Dummy messages for testing / benchmarking.
93 */ 97 */
94#define GNUNET_MESSAGE_TYPE_REQUEST_AGPL 6 98#define GNUNET_MESSAGE_TYPE_DUMMY 6
95 99
96/** 100/**
97 * Source code link. 101 * Another dummy messages for testing / benchmarking.
98 */ 102 */
99#define GNUNET_MESSAGE_TYPE_RESPONSE_AGPL 7 103#define GNUNET_MESSAGE_TYPE_DUMMY2 7
100 104
101 105
102/******************************************************************************* 106/*******************************************************************************
@@ -1648,29 +1652,8 @@ extern "C" {
1648 */ 1652 */
1649#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ELEMENTS_REPORT 545 1653#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ELEMENTS_REPORT 545
1650 1654
1651/*
1652 * Initialization message for consensus p2p communication.
1653 */
1654#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_HELLO 546
1655
1656/**
1657 * Report that the peer is synced with the partner after successfuly decoding
1658 * the invertible bloom filter.
1659 */
1660#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_SYNCED 547
1661
1662/**
1663 * Interaction os over, got synched and reported all elements
1664 */
1665#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_FIN 548
1666
1667/** 1655/**
1668 * Abort a round, don't send requested elements anymore 1656 * Provide context for a consensus round.
1669 */
1670#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ABORT 548
1671
1672/**
1673 * Abort a round, don't send requested elements anymore
1674 */ 1657 */
1675#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ROUND_CONTEXT 547 1658#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ROUND_CONTEXT 547
1676 1659
@@ -2751,9 +2734,8 @@ extern "C" {
2751 * 1000-1009 Connection-level Messages 2734 * 1000-1009 Connection-level Messages
2752 * 1010-1019 Channel-level Messages 2735 * 1010-1019 Channel-level Messages
2753 * 1020-1029 Local Client-Service 2736 * 1020-1029 Local Client-Service
2754 * 1030-1039 Local Service Monitoring 2737 * 1030-1049 Local Service Monitoring
2755 * 1040-1049 Application Data 2738 * 1050-1059 Application Data
2756 * 1050-1059 Reserved
2757 */ 2739 */
2758 2740
2759/******************************** Connection ********************************/ 2741/******************************** Connection ********************************/
@@ -2949,6 +2931,11 @@ extern "C" {
2949 */ 2931 */
2950#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS_END 1041 2932#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS_END 1041
2951 2933
2934/**
2935 * Request to drop a message of type X to peer y.
2936 */
2937#define GNUNET_MESSAGE_TYPE_CADET_DROP_CADET_MESSAGE 1042
2938
2952 2939
2953/******************************** Application *******************************/ 2940/******************************** Application *******************************/
2954 2941
@@ -3178,6 +3165,10 @@ extern "C" {
3178 */ 3165 */
3179#define GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL 1221 3166#define GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL 1221
3180 3167
3168/**
3169 * @brief inform transport that a queue was updated
3170 */
3171#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_UPDATE 1222
3181 3172
3182/** 3173/**
3183 * Message sent to indicate to the transport that a monitor 3174 * Message sent to indicate to the transport that a monitor
diff --git a/src/include/gnunet_signatures.h b/src/include/gnunet_signatures.h
index a00e0372d..503113770 100644
--- a/src/include/gnunet_signatures.h
+++ b/src/include/gnunet_signatures.h
@@ -241,6 +241,10 @@ extern "C"
241 */ 241 */
242#define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR 37 242#define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR 37
243 243
244/**
245 * Signature by a peer that like to create a connection.
246 */
247#define GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR 38
244 248
245#if 0 /* keep Emacsens' auto-indent happy */ 249#if 0 /* keep Emacsens' auto-indent happy */
246{ 250{
diff --git a/src/include/gnunet_transport_communication_service.h b/src/include/gnunet_transport_communication_service.h
index f4dfc8745..ea6b95e2d 100644
--- a/src/include/gnunet_transport_communication_service.h
+++ b/src/include/gnunet_transport_communication_service.h
@@ -50,6 +50,10 @@ extern "C" {
50 */ 50 */
51#define GNUNET_TRANSPORT_COMMUNICATION_VERSION 0x00000000 51#define GNUNET_TRANSPORT_COMMUNICATION_VERSION 0x00000000
52 52
53/**
54 * Queue length
55 */
56#define GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED UINT64_MAX
53 57
54/** 58/**
55 * Function called by the transport service to initialize a 59 * Function called by the transport service to initialize a
@@ -176,8 +180,9 @@ GNUNET_TRANSPORT_communicator_disconnect (
176 * @param success #GNUNET_SYSERR on failure (try to disconnect/reset connection) 180 * @param success #GNUNET_SYSERR on failure (try to disconnect/reset connection)
177 * #GNUNET_OK on success 181 * #GNUNET_OK on success
178 */ 182 */
179typedef void (*GNUNET_TRANSPORT_MessageCompletedCallback) (void *cls, 183typedef void
180 int success); 184(*GNUNET_TRANSPORT_MessageCompletedCallback) (void *cls,
185 int success);
181 186
182 187
183/** 188/**
@@ -251,6 +256,9 @@ enum GNUNET_TRANSPORT_ConnectionStatus
251 * @param address address in human-readable format, 0-terminated, UTF-8 256 * @param address address in human-readable format, 0-terminated, UTF-8
252 * @param mtu maximum message size supported by queue, 0 if 257 * @param mtu maximum message size supported by queue, 0 if
253 * sending is not supported, SIZE_MAX for no MTU 258 * sending is not supported, SIZE_MAX for no MTU
259 * @param q_len number of messages that can be send through this queue
260 * @param priority queue priority. Queues with highest priority should be
261 * used
254 * @param nt which network type does the @a address belong to? 262 * @param nt which network type does the @a address belong to?
255 * @param cs what is the connection status of the queue? 263 * @param cs what is the connection status of the queue?
256 * @param mq message queue of the @a peer 264 * @param mq message queue of the @a peer
@@ -262,10 +270,27 @@ GNUNET_TRANSPORT_communicator_mq_add (
262 const struct GNUNET_PeerIdentity *peer, 270 const struct GNUNET_PeerIdentity *peer,
263 const char *address, 271 const char *address,
264 uint32_t mtu, 272 uint32_t mtu,
273 uint64_t q_len,
274 uint32_t priority,
265 enum GNUNET_NetworkType nt, 275 enum GNUNET_NetworkType nt,
266 enum GNUNET_TRANSPORT_ConnectionStatus cs, 276 enum GNUNET_TRANSPORT_ConnectionStatus cs,
267 struct GNUNET_MQ_Handle *mq); 277 struct GNUNET_MQ_Handle *mq);
268 278
279/**
280 * Notify transport service that an MQ was updated
281 *
282 * @param ch connection to transport service
283 * @param qh the queue to update
284 * @param q_len number of messages that can be send through this queue
285 * @param priority queue priority. Queues with highest priority should be
286 * used
287 */
288void
289GNUNET_TRANSPORT_communicator_mq_update (
290 struct GNUNET_TRANSPORT_CommunicatorHandle *ch,
291 const struct GNUNET_TRANSPORT_QueueHandle *u_qh,
292 uint64_t q_len,
293 uint32_t priority);
269 294
270/** 295/**
271 * Notify transport service that an MQ became unavailable due to a 296 * Notify transport service that an MQ became unavailable due to a