diff options
Diffstat (limited to 'src/include/gnunet_hello_lib.h')
-rw-r--r-- | src/include/gnunet_hello_lib.h | 112 |
1 files changed, 54 insertions, 58 deletions
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h index 3b494f0a2..9fe158852 100644 --- a/src/include/gnunet_hello_lib.h +++ b/src/include/gnunet_hello_lib.h | |||
@@ -16,7 +16,7 @@ | |||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @author Christian Grothoff | 22 | * @author Christian Grothoff |
@@ -65,8 +65,7 @@ extern "C" { | |||
65 | * These information are only valid for the local peer and are not serialized | 65 | * These information are only valid for the local peer and are not serialized |
66 | * when a #GNUNET_HELLO_Message is created | 66 | * when a #GNUNET_HELLO_Message is created |
67 | */ | 67 | */ |
68 | enum GNUNET_HELLO_AddressInfo | 68 | enum GNUNET_HELLO_AddressInfo { |
69 | { | ||
70 | /** | 69 | /** |
71 | * No additional information | 70 | * No additional information |
72 | */ | 71 | */ |
@@ -86,9 +85,7 @@ enum GNUNET_HELLO_AddressInfo | |||
86 | * separated. This is NOT the format that would be used | 85 | * separated. This is NOT the format that would be used |
87 | * on the wire. | 86 | * on the wire. |
88 | */ | 87 | */ |
89 | struct GNUNET_HELLO_Address | 88 | struct GNUNET_HELLO_Address { |
90 | { | ||
91 | |||
92 | /** | 89 | /** |
93 | * For which peer is this an address? | 90 | * For which peer is this an address? |
94 | */ | 91 | */ |
@@ -135,11 +132,11 @@ struct GNUNET_HELLO_Address | |||
135 | * @return the address struct | 132 | * @return the address struct |
136 | */ | 133 | */ |
137 | struct GNUNET_HELLO_Address * | 134 | struct GNUNET_HELLO_Address * |
138 | GNUNET_HELLO_address_allocate (const struct GNUNET_PeerIdentity *peer, | 135 | GNUNET_HELLO_address_allocate(const struct GNUNET_PeerIdentity *peer, |
139 | const char *transport_name, | 136 | const char *transport_name, |
140 | const void *address, | 137 | const void *address, |
141 | size_t address_length, | 138 | size_t address_length, |
142 | enum GNUNET_HELLO_AddressInfo local_info); | 139 | enum GNUNET_HELLO_AddressInfo local_info); |
143 | 140 | ||
144 | 141 | ||
145 | /** | 142 | /** |
@@ -149,7 +146,7 @@ GNUNET_HELLO_address_allocate (const struct GNUNET_PeerIdentity *peer, | |||
149 | * @return a copy of the address struct | 146 | * @return a copy of the address struct |
150 | */ | 147 | */ |
151 | struct GNUNET_HELLO_Address * | 148 | struct GNUNET_HELLO_Address * |
152 | GNUNET_HELLO_address_copy (const struct GNUNET_HELLO_Address *address); | 149 | GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address); |
153 | 150 | ||
154 | 151 | ||
155 | /** | 152 | /** |
@@ -161,8 +158,8 @@ GNUNET_HELLO_address_copy (const struct GNUNET_HELLO_Address *address); | |||
161 | * @return 0 if the addresses are equal, -1 if @a a1< @a a2, 1 if @a a1> @a a2. | 158 | * @return 0 if the addresses are equal, -1 if @a a1< @a a2, 1 if @a a1> @a a2. |
162 | */ | 159 | */ |
163 | int | 160 | int |
164 | GNUNET_HELLO_address_cmp (const struct GNUNET_HELLO_Address *a1, | 161 | GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, |
165 | const struct GNUNET_HELLO_Address *a2); | 162 | const struct GNUNET_HELLO_Address *a2); |
166 | 163 | ||
167 | 164 | ||
168 | /** | 165 | /** |
@@ -172,7 +169,7 @@ GNUNET_HELLO_address_cmp (const struct GNUNET_HELLO_Address *a1, | |||
172 | * @return the size | 169 | * @return the size |
173 | */ | 170 | */ |
174 | size_t | 171 | size_t |
175 | GNUNET_HELLO_address_get_size (const struct GNUNET_HELLO_Address *address); | 172 | GNUNET_HELLO_address_get_size(const struct GNUNET_HELLO_Address *address); |
176 | 173 | ||
177 | 174 | ||
178 | /** | 175 | /** |
@@ -183,8 +180,8 @@ GNUNET_HELLO_address_get_size (const struct GNUNET_HELLO_Address *address); | |||
183 | * @return #GNUNET_YES or #GNUNET_NO | 180 | * @return #GNUNET_YES or #GNUNET_NO |
184 | */ | 181 | */ |
185 | int | 182 | int |
186 | GNUNET_HELLO_address_check_option (const struct GNUNET_HELLO_Address *address, | 183 | GNUNET_HELLO_address_check_option(const struct GNUNET_HELLO_Address *address, |
187 | enum GNUNET_HELLO_AddressInfo option); | 184 | enum GNUNET_HELLO_AddressInfo option); |
188 | 185 | ||
189 | 186 | ||
190 | /** | 187 | /** |
@@ -192,7 +189,7 @@ GNUNET_HELLO_address_check_option (const struct GNUNET_HELLO_Address *address, | |||
192 | * | 189 | * |
193 | * @param addr address to free | 190 | * @param addr address to free |
194 | */ | 191 | */ |
195 | #define GNUNET_HELLO_address_free(addr) GNUNET_free (addr) | 192 | #define GNUNET_HELLO_address_free(addr) GNUNET_free(addr) |
196 | 193 | ||
197 | 194 | ||
198 | GNUNET_NETWORK_STRUCT_BEGIN | 195 | GNUNET_NETWORK_STRUCT_BEGIN |
@@ -210,8 +207,7 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
210 | * unaligned!) | 207 | * unaligned!) |
211 | * 4) address (address-length bytes; possibly unaligned!) | 208 | * 4) address (address-length bytes; possibly unaligned!) |
212 | */ | 209 | */ |
213 | struct GNUNET_HELLO_Message | 210 | struct GNUNET_HELLO_Message { |
214 | { | ||
215 | /** | 211 | /** |
216 | * Type will be #GNUNET_MESSAGE_TYPE_HELLO. | 212 | * Type will be #GNUNET_MESSAGE_TYPE_HELLO. |
217 | */ | 213 | */ |
@@ -237,7 +233,7 @@ GNUNET_NETWORK_STRUCT_END | |||
237 | * @return #GNUNET_YES for friend-only or #GNUNET_NO otherwise | 233 | * @return #GNUNET_YES for friend-only or #GNUNET_NO otherwise |
238 | */ | 234 | */ |
239 | int | 235 | int |
240 | GNUNET_HELLO_is_friend_only (const struct GNUNET_HELLO_Message *h); | 236 | GNUNET_HELLO_is_friend_only(const struct GNUNET_HELLO_Message *h); |
241 | 237 | ||
242 | 238 | ||
243 | /** | 239 | /** |
@@ -252,10 +248,10 @@ GNUNET_HELLO_is_friend_only (const struct GNUNET_HELLO_Message *h); | |||
252 | * the target buffer was not big enough. | 248 | * the target buffer was not big enough. |
253 | */ | 249 | */ |
254 | size_t | 250 | size_t |
255 | GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address, | 251 | GNUNET_HELLO_add_address(const struct GNUNET_HELLO_Address *address, |
256 | struct GNUNET_TIME_Absolute expiration, | 252 | struct GNUNET_TIME_Absolute expiration, |
257 | char *target, | 253 | char *target, |
258 | size_t max); | 254 | size_t max); |
259 | 255 | ||
260 | 256 | ||
261 | /** | 257 | /** |
@@ -289,10 +285,10 @@ typedef ssize_t (*GNUNET_HELLO_GenerateAddressListCallback) (void *cls, | |||
289 | * @return the hello message | 285 | * @return the hello message |
290 | */ | 286 | */ |
291 | struct GNUNET_HELLO_Message * | 287 | struct GNUNET_HELLO_Message * |
292 | GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, | 288 | GNUNET_HELLO_create(const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, |
293 | GNUNET_HELLO_GenerateAddressListCallback addrgen, | 289 | GNUNET_HELLO_GenerateAddressListCallback addrgen, |
294 | void *addrgen_cls, | 290 | void *addrgen_cls, |
295 | int friend_only); | 291 | int friend_only); |
296 | 292 | ||
297 | 293 | ||
298 | /** | 294 | /** |
@@ -302,7 +298,7 @@ GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, | |||
302 | * @return the size, 0 if HELLO is invalid | 298 | * @return the size, 0 if HELLO is invalid |
303 | */ | 299 | */ |
304 | uint16_t | 300 | uint16_t |
305 | GNUNET_HELLO_size (const struct GNUNET_HELLO_Message *hello); | 301 | GNUNET_HELLO_size(const struct GNUNET_HELLO_Message *hello); |
306 | 302 | ||
307 | 303 | ||
308 | /** | 304 | /** |
@@ -315,8 +311,8 @@ GNUNET_HELLO_size (const struct GNUNET_HELLO_Message *hello); | |||
315 | * @return the combined hello message | 311 | * @return the combined hello message |
316 | */ | 312 | */ |
317 | struct GNUNET_HELLO_Message * | 313 | struct GNUNET_HELLO_Message * |
318 | GNUNET_HELLO_merge (const struct GNUNET_HELLO_Message *h1, | 314 | GNUNET_HELLO_merge(const struct GNUNET_HELLO_Message *h1, |
319 | const struct GNUNET_HELLO_Message *h2); | 315 | const struct GNUNET_HELLO_Message *h2); |
320 | 316 | ||
321 | 317 | ||
322 | /** | 318 | /** |
@@ -336,9 +332,9 @@ GNUNET_HELLO_merge (const struct GNUNET_HELLO_Message *h1, | |||
336 | * do not match at all | 332 | * do not match at all |
337 | */ | 333 | */ |
338 | struct GNUNET_TIME_Absolute | 334 | struct GNUNET_TIME_Absolute |
339 | GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1, | 335 | GNUNET_HELLO_equals(const struct GNUNET_HELLO_Message *h1, |
340 | const struct GNUNET_HELLO_Message *h2, | 336 | const struct GNUNET_HELLO_Message *h2, |
341 | struct GNUNET_TIME_Absolute now); | 337 | struct GNUNET_TIME_Absolute now); |
342 | 338 | ||
343 | 339 | ||
344 | /** | 340 | /** |
@@ -364,7 +360,7 @@ typedef int (*GNUNET_HELLO_AddressIterator) ( | |||
364 | * @return time the last address expires, 0 if there are no addresses in the HELLO | 360 | * @return time the last address expires, 0 if there are no addresses in the HELLO |
365 | */ | 361 | */ |
366 | struct GNUNET_TIME_Absolute | 362 | struct GNUNET_TIME_Absolute |
367 | GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg); | 363 | GNUNET_HELLO_get_last_expiration(const struct GNUNET_HELLO_Message *msg); |
368 | 364 | ||
369 | 365 | ||
370 | /** | 366 | /** |
@@ -380,10 +376,10 @@ GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg); | |||
380 | * @return the modified HELLO or NULL | 376 | * @return the modified HELLO or NULL |
381 | */ | 377 | */ |
382 | struct GNUNET_HELLO_Message * | 378 | struct GNUNET_HELLO_Message * |
383 | GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, | 379 | GNUNET_HELLO_iterate_addresses(const struct GNUNET_HELLO_Message *msg, |
384 | int return_modified, | 380 | int return_modified, |
385 | GNUNET_HELLO_AddressIterator it, | 381 | GNUNET_HELLO_AddressIterator it, |
386 | void *it_cls); | 382 | void *it_cls); |
387 | 383 | ||
388 | 384 | ||
389 | /** | 385 | /** |
@@ -400,7 +396,7 @@ GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, | |||
400 | * @param it_cls closure for @a it | 396 | * @param it_cls closure for @a it |
401 | */ | 397 | */ |
402 | void | 398 | void |
403 | GNUNET_HELLO_iterate_new_addresses ( | 399 | GNUNET_HELLO_iterate_new_addresses( |
404 | const struct GNUNET_HELLO_Message *new_hello, | 400 | const struct GNUNET_HELLO_Message *new_hello, |
405 | const struct GNUNET_HELLO_Message *old_hello, | 401 | const struct GNUNET_HELLO_Message *old_hello, |
406 | struct GNUNET_TIME_Absolute expiration_limit, | 402 | struct GNUNET_TIME_Absolute expiration_limit, |
@@ -416,8 +412,8 @@ GNUNET_HELLO_iterate_new_addresses ( | |||
416 | * @return #GNUNET_SYSERR if the HELLO was malformed | 412 | * @return #GNUNET_SYSERR if the HELLO was malformed |
417 | */ | 413 | */ |
418 | int | 414 | int |
419 | GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello, | 415 | GNUNET_HELLO_get_id(const struct GNUNET_HELLO_Message *hello, |
420 | struct GNUNET_PeerIdentity *peer); | 416 | struct GNUNET_PeerIdentity *peer); |
421 | 417 | ||
422 | 418 | ||
423 | /** | 419 | /** |
@@ -429,7 +425,7 @@ GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello, | |||
429 | * @return header or NULL if the HELLO was malformed | 425 | * @return header or NULL if the HELLO was malformed |
430 | */ | 426 | */ |
431 | struct GNUNET_MessageHeader * | 427 | struct GNUNET_MessageHeader * |
432 | GNUNET_HELLO_get_header (struct GNUNET_HELLO_Message *hello); | 428 | GNUNET_HELLO_get_header(struct GNUNET_HELLO_Message *hello); |
433 | 429 | ||
434 | 430 | ||
435 | /** | 431 | /** |
@@ -440,7 +436,7 @@ GNUNET_HELLO_get_header (struct GNUNET_HELLO_Message *hello); | |||
440 | * @return NULL if a plugin with name @a name is not known/loadable | 436 | * @return NULL if a plugin with name @a name is not known/loadable |
441 | */ | 437 | */ |
442 | typedef struct GNUNET_TRANSPORT_PluginFunctions *( | 438 | typedef struct GNUNET_TRANSPORT_PluginFunctions *( |
443 | *GNUNET_HELLO_TransportPluginsFind) (const char *name); | 439 | *GNUNET_HELLO_TransportPluginsFind) (const char *name); |
444 | 440 | ||
445 | 441 | ||
446 | /** | 442 | /** |
@@ -451,8 +447,8 @@ typedef struct GNUNET_TRANSPORT_PluginFunctions *( | |||
451 | * @return Hello URI string | 447 | * @return Hello URI string |
452 | */ | 448 | */ |
453 | char * | 449 | char * |
454 | GNUNET_HELLO_compose_uri (const struct GNUNET_HELLO_Message *hello, | 450 | GNUNET_HELLO_compose_uri(const struct GNUNET_HELLO_Message *hello, |
455 | GNUNET_HELLO_TransportPluginsFind plugins_find); | 451 | GNUNET_HELLO_TransportPluginsFind plugins_find); |
456 | 452 | ||
457 | 453 | ||
458 | /** | 454 | /** |
@@ -465,10 +461,10 @@ GNUNET_HELLO_compose_uri (const struct GNUNET_HELLO_Message *hello, | |||
465 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the URI was invalid, #GNUNET_NO on other errors | 461 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the URI was invalid, #GNUNET_NO on other errors |
466 | */ | 462 | */ |
467 | int | 463 | int |
468 | GNUNET_HELLO_parse_uri (const char *uri, | 464 | GNUNET_HELLO_parse_uri(const char *uri, |
469 | struct GNUNET_CRYPTO_EddsaPublicKey *pubkey, | 465 | struct GNUNET_CRYPTO_EddsaPublicKey *pubkey, |
470 | struct GNUNET_HELLO_Message **hello, | 466 | struct GNUNET_HELLO_Message **hello, |
471 | GNUNET_HELLO_TransportPluginsFind plugins_find); | 467 | GNUNET_HELLO_TransportPluginsFind plugins_find); |
472 | 468 | ||
473 | 469 | ||
474 | /* NG API */ | 470 | /* NG API */ |
@@ -486,7 +482,7 @@ GNUNET_HELLO_parse_uri (const char *uri, | |||
486 | * @param result_size[out] set to size of @a result | 482 | * @param result_size[out] set to size of @a result |
487 | */ | 483 | */ |
488 | void | 484 | void |
489 | GNUNET_HELLO_sign_address ( | 485 | GNUNET_HELLO_sign_address( |
490 | const char *address, | 486 | const char *address, |
491 | enum GNUNET_NetworkType nt, | 487 | enum GNUNET_NetworkType nt, |
492 | struct GNUNET_TIME_Absolute mono_time, | 488 | struct GNUNET_TIME_Absolute mono_time, |
@@ -506,11 +502,11 @@ GNUNET_HELLO_sign_address ( | |||
506 | * @return NULL on error, otherwise the address | 502 | * @return NULL on error, otherwise the address |
507 | */ | 503 | */ |
508 | char * | 504 | char * |
509 | GNUNET_HELLO_extract_address (const void *raw, | 505 | GNUNET_HELLO_extract_address(const void *raw, |
510 | size_t raw_size, | 506 | size_t raw_size, |
511 | const struct GNUNET_PeerIdentity *pid, | 507 | const struct GNUNET_PeerIdentity *pid, |
512 | enum GNUNET_NetworkType *nt, | 508 | enum GNUNET_NetworkType *nt, |
513 | struct GNUNET_TIME_Absolute *mono_time); | 509 | struct GNUNET_TIME_Absolute *mono_time); |
514 | 510 | ||
515 | 511 | ||
516 | /** | 512 | /** |
@@ -521,7 +517,7 @@ GNUNET_HELLO_extract_address (const void *raw, | |||
521 | * @return NULL if the address is mal-formed, otherwise the prefix | 517 | * @return NULL if the address is mal-formed, otherwise the prefix |
522 | */ | 518 | */ |
523 | char * | 519 | char * |
524 | GNUNET_HELLO_address_to_prefix (const char *address); | 520 | GNUNET_HELLO_address_to_prefix(const char *address); |
525 | 521 | ||
526 | 522 | ||
527 | #if 0 /* keep Emacsens' auto-indent happy */ | 523 | #if 0 /* keep Emacsens' auto-indent happy */ |