summaryrefslogtreecommitdiff
path: root/src/include/gnunet_hello_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_hello_lib.h')
-rw-r--r--src/include/gnunet_hello_lib.h112
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 */
68enum GNUNET_HELLO_AddressInfo 68enum 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 */
89struct GNUNET_HELLO_Address 88struct 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 */
137struct GNUNET_HELLO_Address * 134struct GNUNET_HELLO_Address *
138GNUNET_HELLO_address_allocate (const struct GNUNET_PeerIdentity *peer, 135GNUNET_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 */
151struct GNUNET_HELLO_Address * 148struct GNUNET_HELLO_Address *
152GNUNET_HELLO_address_copy (const struct GNUNET_HELLO_Address *address); 149GNUNET_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 */
163int 160int
164GNUNET_HELLO_address_cmp (const struct GNUNET_HELLO_Address *a1, 161GNUNET_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 */
174size_t 171size_t
175GNUNET_HELLO_address_get_size (const struct GNUNET_HELLO_Address *address); 172GNUNET_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 */
185int 182int
186GNUNET_HELLO_address_check_option (const struct GNUNET_HELLO_Address *address, 183GNUNET_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
198GNUNET_NETWORK_STRUCT_BEGIN 195GNUNET_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 */
213struct GNUNET_HELLO_Message 210struct 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 */
239int 235int
240GNUNET_HELLO_is_friend_only (const struct GNUNET_HELLO_Message *h); 236GNUNET_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 */
254size_t 250size_t
255GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address, 251GNUNET_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 */
291struct GNUNET_HELLO_Message * 287struct GNUNET_HELLO_Message *
292GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, 288GNUNET_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 */
304uint16_t 300uint16_t
305GNUNET_HELLO_size (const struct GNUNET_HELLO_Message *hello); 301GNUNET_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 */
317struct GNUNET_HELLO_Message * 313struct GNUNET_HELLO_Message *
318GNUNET_HELLO_merge (const struct GNUNET_HELLO_Message *h1, 314GNUNET_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 */
338struct GNUNET_TIME_Absolute 334struct GNUNET_TIME_Absolute
339GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1, 335GNUNET_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 */
366struct GNUNET_TIME_Absolute 362struct GNUNET_TIME_Absolute
367GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg); 363GNUNET_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 */
382struct GNUNET_HELLO_Message * 378struct GNUNET_HELLO_Message *
383GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, 379GNUNET_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 */
402void 398void
403GNUNET_HELLO_iterate_new_addresses ( 399GNUNET_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 */
418int 414int
419GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello, 415GNUNET_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 */
431struct GNUNET_MessageHeader * 427struct GNUNET_MessageHeader *
432GNUNET_HELLO_get_header (struct GNUNET_HELLO_Message *hello); 428GNUNET_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 */
442typedef struct GNUNET_TRANSPORT_PluginFunctions *( 438typedef 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 */
453char * 449char *
454GNUNET_HELLO_compose_uri (const struct GNUNET_HELLO_Message *hello, 450GNUNET_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 */
467int 463int
468GNUNET_HELLO_parse_uri (const char *uri, 464GNUNET_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 */
488void 484void
489GNUNET_HELLO_sign_address ( 485GNUNET_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 */
508char * 504char *
509GNUNET_HELLO_extract_address (const void *raw, 505GNUNET_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 */
523char * 519char *
524GNUNET_HELLO_address_to_prefix (const char *address); 520GNUNET_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 */