GNUnet 0.28.1-dev.4-47-g3e168ca2d
 
Loading...
Searching...
No Matches
Hello_Uri library

Helper library for handling HELLO URIs. More...

Collaboration diagram for Hello_Uri library:

Macros

#define GNUNET_HELLO_ADDRESS_EXPIRATION
 For how long are HELLO signatures valid?
 

Typedefs

typedef void(* GNUNET_HELLO_UriCallback) (void *cls, const struct GNUNET_PeerIdentity *pid, const char *uri)
 Callback function used to extract URIs from a builder.
 

Functions

struct GNUNET_HELLO_BuilderGNUNET_HELLO_builder_new ()
 Allocate builder.
 
struct GNUNET_HELLO_BuilderGNUNET_HELLO_builder_from_parser (const struct GNUNET_HELLO_Parser *parser, struct GNUNET_PeerIdentity *pid)
 Allocate builder from parser.
 
const struct GNUNET_PeerIdentityGNUNET_HELLO_parser_get_id (const struct GNUNET_HELLO_Parser *parser)
 Get the PeerIdentity for this builder.
 
void GNUNET_HELLO_builder_free (struct GNUNET_HELLO_Builder *builder)
 Release resources of a builder.
 
void GNUNET_HELLO_parser_free (struct GNUNET_HELLO_Parser *parser)
 Release resources of a builder.
 
struct GNUNET_HELLO_ParserGNUNET_HELLO_parser_from_msg (const struct GNUNET_MessageHeader *msg, const struct GNUNET_PeerIdentity *pid)
 Parse msg.
 
struct GNUNET_HELLO_ParserGNUNET_HELLO_parser_from_msg_ (const struct GNUNET_MessageHeader *msg, const struct GNUNET_PeerIdentity *pid, int noverify)
 Parse msg.
 
struct GNUNET_HELLO_ParserGNUNET_HELLO_parser_from_block (const void *block, size_t block_size)
 Parse block.
 
struct GNUNET_HELLO_ParserGNUNET_HELLO_parser_from_block_ (const void *block, size_t block_size, int noverify)
 Parse block.
 
struct GNUNET_HELLO_ParserGNUNET_HELLO_parser_from_url (const char *url)
 Parse GNUnet HELLO url.
 
struct GNUNET_TIME_Absolute GNUNET_HELLO_get_expiration_time_from_msg (const struct GNUNET_MessageHeader *msg)
 Get the expiration time for this HELLO.
 
struct GNUNET_MQ_EnvelopeGNUNET_HELLO_parser_to_env (const struct GNUNET_HELLO_Parser *parser)
 Generate envelope with GNUnet HELLO message (including peer ID) from a parser.
 
char * GNUNET_HELLO_parser_to_url (const struct GNUNET_HELLO_Parser *parser)
 Generate GNUnet HELLO URI from a parser.
 
enum GNUNET_GenericReturnValue GNUNET_HELLO_parser_to_block (const struct GNUNET_HELLO_Parser *parser, void *block, size_t *block_size)
 Generate DHT block from a parser.
 
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_add_address (struct GNUNET_HELLO_Builder *builder, const char *address)
 Add individual address to the builder.
 
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_del_address (struct GNUNET_HELLO_Builder *builder, const char *address)
 Remove individual address from the builder.
 
void GNUNET_HELLO_builder_iterate (const struct GNUNET_HELLO_Builder *builder, GNUNET_HELLO_UriCallback uc, void *uc_cls)
 Iterate over URIs in a builder.
 
const struct GNUNET_PeerIdentityGNUNET_HELLO_parser_iterate (const struct GNUNET_HELLO_Parser *parser, GNUNET_HELLO_UriCallback uc, void *uc_cls)
 Iterate over URIs in a parser.
 
enum GNUNET_GenericReturnValue GNUNET_HELLO_dht_msg_to_block (const struct GNUNET_MessageHeader *hello, const struct GNUNET_PeerIdentity *pid, void **block, size_t *block_size, struct GNUNET_TIME_Absolute *block_expiration)
 Convert a DHT hello message to a HELLO block.
 
char * GNUNET_HELLO_address_to_prefix (const char *address)
 Given an address as a string, extract the prefix that identifies the communicator offering transmissions to that address.
 
enum GNUNET_GenericReturnValue GNUNET_HELLO_build_url (const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig, struct GNUNET_TIME_Absolute expiration, char **result)
 
struct GNUNET_MessageHeaderGNUNET_HELLO_builder_to_dht_hello_msg (const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig, struct GNUNET_TIME_Absolute expiration_time)
 Generate DHT HELLO message (without peer ID) from a builder.
 
struct GNUNET_MessageHeaderGNUNET_HELLO_parser_to_dht_hello_msg (const struct GNUNET_HELLO_Parser *parser)
 Generate DHT HELLO message from a parser.
 
void GNUNET_HELLO_builder_to_block (const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig, struct GNUNET_TIME_Absolute expiration_time, char *outbuf)
 Generate DHT block from a builder.
 
void GNUNET_HELLO_builder_hash_addresses (const struct GNUNET_HELLO_Builder *builder, struct GNUNET_HashCode *hash)
 Compute hash over addresses in builder.
 
struct GNUNET_MQ_EnvelopeGNUNET_HELLO_builder_to_env (const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig, struct GNUNET_TIME_Absolute expiration_time)
 Generate envelope with GNUnet HELLO message (including peer ID) from a builder.
 
size_t GNUNET_HELLO_get_builder_to_block_size (const struct GNUNET_HELLO_Builder *builder)
 Get projected block size for builder.
 
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_to_url (const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig, char **result)
 Generate GNUnet HELLO URI from a builder.
 
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_to_url2 (const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig, struct GNUNET_TIME_Absolute validity, char **result)
 Generate GNUnet HELLO URI from a builder.
 
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_address_list_cmp (const struct GNUNET_HELLO_Builder *abuilder, const struct GNUNET_HELLO_Builder *bbuilder)
 Compare address lists of two builders.
 

Detailed Description

Helper library for handling HELLO URIs.

Macro Definition Documentation

◆ GNUNET_HELLO_ADDRESS_EXPIRATION

#define GNUNET_HELLO_ADDRESS_EXPIRATION
Value:
#define GNUNET_TIME_UNIT_DAYS
One day.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition time.c:486

For how long are HELLO signatures valid?

Definition at line 63 of file gnunet_hello_uri_lib.h.

459{
460#endif
461#ifdef __cplusplus
462}
463#endif
464
465/* ifndef GNUNET_HELLO_URI_LIB_H */
466#endif
467
/* end of group */
469
/* end of group addition */
471
472/* end of gnunet_hello_uri_lib.h */

Typedef Documentation

◆ GNUNET_HELLO_UriCallback

typedef void(* GNUNET_HELLO_UriCallback) (void *cls, const struct GNUNET_PeerIdentity *pid, const char *uri)

Callback function used to extract URIs from a builder.

Parameters
clsclosure
urione of the URIs

Definition at line 252 of file gnunet_hello_uri_lib.h.

Function Documentation

◆ GNUNET_HELLO_builder_new()

struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_new ( )

Allocate builder.

Returns
new builder

Definition at line 344 of file hello-uri.c.

345{
347
349 return builder;
350}
static struct HostSet * builder
NULL if we are not currently iterating over peer information.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Context for building (or parsing) HELLO URIs.
Definition hello-uri.c:185

References builder, and GNUNET_new.

Referenced by do_generate_pid(), GNUNET_HELLO_builder_from_parser(), pils_pid_change_cb(), run(), and run().

Here is the caller graph for this function:

◆ GNUNET_HELLO_builder_from_parser()

struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_from_parser ( const struct GNUNET_HELLO_Parser parser,
struct GNUNET_PeerIdentity pid 
)

Allocate builder from parser.

Parameters
parserthe parser
pidthe peer identity from the parsed hello
Returns
new builder

Definition at line 361 of file hello-uri.c.

363{
365 struct Address *a;
366
368 if (NULL != pid)
369 *pid = p->pid;
370 /* check for duplicates */
371 for (a = p->a_head;
372 NULL != a;
373 a = a->next)
375 return builder;
376}
static struct GNUNET_Process * p
Helper process we started.
Definition gnunet-uri.c:38
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_new()
Allocate builder.
Definition hello-uri.c:344
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_add_address(struct GNUNET_HELLO_Builder *builder, const char *address)
Add individual address to the builder.
Definition hello-uri.c:701
Address of a peer.
Definition hello-uri.c:158
struct Address * next
Kept in a DLL.
Definition hello-uri.c:162
const char * uri
Actual URI, allocated at the end of this struct.
Definition hello-uri.c:172
pid_t pid
PID of the process.
Definition os_process.c:94

References builder, GNUNET_HELLO_builder_add_address(), GNUNET_HELLO_builder_new(), Address::next, p, GNUNET_Process::pid, and Address::uri.

Referenced by do_generate_pid(), pid_changed_cb(), and pils_pid_change_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_parser_get_id()

const struct GNUNET_PeerIdentity * GNUNET_HELLO_parser_get_id ( const struct GNUNET_HELLO_Parser parser)

Get the PeerIdentity for this builder.

Definition at line 354 of file hello-uri.c.

355{
356 return &parser->pid;
357}

Referenced by callback_peer_id_changed(), check_hello(), GNUNET_PEERSTORE_hello_add(), handle_hello_for_client(), handle_peer_id(), hello_iter(), hosts_directory_scan_callback(), pid_change_cb(), pid_change_cb(), pid_change_cb(), and process_notify().

Here is the caller graph for this function:

◆ GNUNET_HELLO_builder_free()

void GNUNET_HELLO_builder_free ( struct GNUNET_HELLO_Builder builder)

Release resources of a builder.

Parameters
[in]builderto free

Definition at line 398 of file hello-uri.c.

399{
400 struct Address *a;
401
402 while (NULL != (a = builder->a_head))
403 {
405 builder->a_tail,
406 a);
407 builder->a_length--;
408 GNUNET_free (a);
409 }
410 GNUNET_assert (0 == builder->a_length);
412}
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_free(ptr)
Wrapper around free.

References builder, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, and GNUNET_free.

Referenced by do_generate_pid(), do_shutdown(), env_resign_cb(), GCH_shutdown(), pils_pid_change_cb(), and url_resign_cb().

Here is the caller graph for this function:

◆ GNUNET_HELLO_parser_free()

void GNUNET_HELLO_parser_free ( struct GNUNET_HELLO_Parser parser)

Release resources of a builder.

Parameters
[in]builderto free

Definition at line 380 of file hello-uri.c.

381{
382 struct Address *a;
383
384 while (NULL != (a = parser->a_head))
385 {
387 parser->a_tail,
388 a);
389 parser->a_length--;
390 GNUNET_free (a);
391 }
392 GNUNET_assert (0 == parser->a_length);
393 GNUNET_free (parser);
394}

References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, and GNUNET_free.

Referenced by block_plugin_dht_check_block(), block_plugin_dht_check_reply(), block_plugin_dht_get_key(), build_json_response(), check_for_burst_address(), check_for_global_natted(), consider_for_advertising(), GNUNET_HELLO_dht_msg_to_block(), GNUNET_HELLO_parser_from_block_(), GNUNET_HELLO_parser_from_url(), GNUNET_PEERSTORE_hello_add(), handle_dht_local_hello_get(), handle_dht_local_hello_offer(), handle_feed_addresses(), handle_hello(), handle_hello_for_client(), handle_hello_for_incoming(), handle_peer_id(), hello_check(), hello_iter(), hosts_directory_scan_callback(), peerinfo_cb(), process_notify(), and run().

Here is the caller graph for this function:

◆ GNUNET_HELLO_parser_from_msg()

struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_msg ( const struct GNUNET_MessageHeader msg,
const struct GNUNET_PeerIdentity pid 
)

Parse msg.

Parameters
msgmessage to parse
pidpeer identity
Returns
builder, NULL on failure

Definition at line 416 of file hello-uri.c.

418{
420 pid,
421 GNUNET_NO);
422}
struct GNUNET_MessageHeader * msg
Definition 005.c:2
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_msg_(const struct GNUNET_MessageHeader *msg, const struct GNUNET_PeerIdentity *pid, int noverify)
Parse msg.
Definition hello-uri.c:426
@ GNUNET_NO

References GNUNET_HELLO_parser_from_msg_(), GNUNET_NO, msg, and GNUNET_HELLO_Parser::pid.

Referenced by check_for_burst_address(), check_for_global_natted(), check_hello(), consider_for_advertising(), GNUNET_PEERSTORE_hello_add(), handle_dht_local_hello_get(), handle_hello(), handle_hello_for_client(), handle_hello_for_incoming(), hello_iter(), peerinfo_cb(), and process_notify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_parser_from_msg_()

struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_msg_ ( const struct GNUNET_MessageHeader msg,
const struct GNUNET_PeerIdentity pid,
int  noverify 
)

Parse msg.

Optionally do not verify the signature.

Only pass GNUNET_YES for noverify if the signature over this very HELLO was already checked, and the bytes have not left our hands since.

Parameters
msgmessage to parse
pidpeer identity
noverifynot verifying signature if GNUNET_YES
Returns
parser, NULL on failure

Definition at line 426 of file hello-uri.c.

429{
430 uint16_t size;
431
432 /* Callers routinely pass the value of a PEERSTORE record straight in,
433 and a zero-length record has a NULL value. Failing that the same way
434 as any other unusable input beats dereferencing it. */
435 if (NULL == msg)
436 {
437 GNUNET_break (0);
438 return NULL;
439 }
440 size = ntohs (msg->size);
441 switch (ntohs (msg->type))
442 {
444 {
445 const struct HelloUriMessage *h;
446
447 if (sizeof (struct HelloUriMessage) > size)
448 {
449 GNUNET_break_op (0);
450 return NULL;
451 }
452
453 h = (const struct HelloUriMessage *) msg;
454 size -= sizeof (*h);
456 size,
457 noverify);
458 }
460 {
461 struct GNUNET_TIME_Absolute block_expiration;
462 struct GNUNET_HELLO_Parser *p;
463 size_t block_size;
464 void *block;
465
466 if (sizeof (struct DhtHelloMessage) > size)
467 {
468 GNUNET_break_op (0);
469 return NULL;
470 }
471
473 msg,
474 pid,
475 &block,
476 &block_size,
477 &block_expiration))
478 {
479 GNUNET_break_op (0);
480 return NULL;
481 }
482
484 block_size,
485 noverify);
486 GNUNET_free (block);
487 return p;
488 }
489 default:
490 GNUNET_break_op (0);
491 return NULL;
492 }
493}
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition gnunet-arm.c:98
enum GNUNET_GenericReturnValue GNUNET_HELLO_dht_msg_to_block(const struct GNUNET_MessageHeader *hello, const struct GNUNET_PeerIdentity *pid, void **block, size_t *block_size, struct GNUNET_TIME_Absolute *block_expiration)
Convert a DHT hello message to a HELLO block.
Definition hello-uri.c:1074
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_block_(const void *block, size_t block_size, int noverify)
Parse block.
Definition hello-uri.c:592
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_SYSERR
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO
HELLO advertising a neighbours addresses.
#define GNUNET_MESSAGE_TYPE_HELLO_URI
Latest HELLO messages used for communicating peer addresses.
static unsigned int size
Size of the "table".
Definition peer.c:68
Message used when a DHT provides its HELLO to direct neighbours.
Definition hello-uri.c:121
Context for parsing HELLOs.
Definition hello-uri.c:233
struct GNUNET_PeerIdentity pid
Public key of the peer.
Definition hello-uri.c:237
Time for absolute times used by GNUnet, in microseconds.
Message used when gossiping HELLOs between peers.
Definition hello-uri.c:73

References GNUNET_break, GNUNET_break_op, GNUNET_free, GNUNET_HELLO_dht_msg_to_block(), GNUNET_HELLO_parser_from_block_(), GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO, GNUNET_MESSAGE_TYPE_HELLO_URI, GNUNET_SYSERR, h, msg, p, GNUNET_HELLO_Parser::pid, GNUNET_MessageHeader::size, size, and GNUNET_MessageHeader::type.

Referenced by build_json_response(), and GNUNET_HELLO_parser_from_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_parser_from_block()

struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_block ( const void *  block,
size_t  block_size 
)

Parse block.

Parameters
blockDHT block to parse
block_sizenumber of bytes in block
Returns
parser, NULL on failure

Definition at line 582 of file hello-uri.c.

584{
586 block_size,
587 GNUNET_NO);
588}

References GNUNET_HELLO_parser_from_block_(), and GNUNET_NO.

Referenced by block_plugin_dht_check_block(), block_plugin_dht_check_reply(), block_plugin_dht_get_key(), GNUNET_HELLO_dht_msg_to_block(), handle_peer_id(), and hello_check().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_parser_from_block_()

struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_block_ ( const void *  block,
size_t  block_size,
int  noverify 
)

Parse block.

Optionally Do not verify signature.

Parameters
blockDHT block to parse
block_sizenumber of bytes in block
noverifynot verifying signature if GNUNET_YES
Returns
parser, NULL on failure

Definition at line 592 of file hello-uri.c.

595{
596 const struct BlockHeader *bh = block;
597 struct GNUNET_HELLO_Parser *p;
598
599 if (block_size < sizeof (*bh))
600 {
601 GNUNET_break_op (0);
602 return NULL;
603 }
604 p = parser_new (&bh->pid);
605 block += sizeof (*bh);
606 block_size -= sizeof (*bh);
607 while (block_size > 0)
608 {
609 const void *end = memchr (block,
610 '\0',
611 block_size);
612
613 if (NULL == end)
614 {
615 GNUNET_break_op (0);
617 return NULL;
618 }
619 if (GNUNET_OK !=
621 block))
622 {
623 GNUNET_break_op (0);
625 return NULL;
626 }
627 end++;
628 block_size -= (end - block);
629 block = end;
630 }
631 {
632 struct GNUNET_TIME_Absolute et;
634 if (GNUNET_YES != noverify)
635 {
637 ret = verify_hello (p,
638 et,
639 &bh->sig);
641 if (GNUNET_OK != ret)
642 {
644 return NULL;
645 }
646 }
647 p->et = et;
648 p->sig = bh->sig;
649 }
650 return p;
651}
static int ret
Final status code.
Definition gnunet-arm.c:93
static int end
Set if we are to shutdown all services (including ARM).
Definition gnunet-arm.c:33
void GNUNET_HELLO_parser_free(struct GNUNET_HELLO_Parser *parser)
Release resources of a builder.
Definition hello-uri.c:380
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_OK
@ GNUNET_YES
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition time.c:737
static enum GNUNET_GenericReturnValue verify_hello(const struct GNUNET_HELLO_Parser *parser, struct GNUNET_TIME_Absolute et, const struct GNUNET_CRYPTO_EddsaSignature *sig)
Verify HELLO signature.
Definition hello-uri.c:304
static struct GNUNET_HELLO_Parser * parser_new(const struct GNUNET_PeerIdentity *pid)
Definition hello-uri.c:333
static enum GNUNET_GenericReturnValue parser_add_address(struct GNUNET_HELLO_Parser *parser, const char *address)
Definition hello-uri.c:543
Start of a 'block'.
Definition hello-uri.c:97
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the HELLO expire?
Definition hello-uri.c:111
struct GNUNET_CRYPTO_EddsaSignature sig
Signature over the block, of purpose GNUNET_SIGNATURE_PURPOSE_HELLO.
Definition hello-uri.c:106
struct GNUNET_PeerIdentity pid
Public key of the peer.
Definition hello-uri.c:101

References end, BlockHeader::expiration_time, GNUNET_break_op, GNUNET_HELLO_parser_free(), GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_absolute_ntoh(), GNUNET_YES, p, parser_add_address(), parser_new(), BlockHeader::pid, ret, BlockHeader::sig, and verify_hello().

Referenced by GNUNET_HELLO_parser_from_block(), GNUNET_HELLO_parser_from_msg_(), and handle_feed_addresses().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_parser_from_url()

struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_url ( const char *  url)

Parse GNUnet HELLO url.

Parameters
urlURL to parse
Returns
builder, NULL on failure

Definition at line 740 of file hello-uri.c.

741{
742 const char *q;
743 const char *s1;
744 const char *s2;
745 struct GNUNET_PeerIdentity pid;
746 struct GNUNET_TIME_Absolute et;
747 size_t len;
748 struct GNUNET_HELLO_Parser *p;
750
751 if (0 != strncasecmp (url,
752 "gnunet://hello/",
753 strlen ("gnunet://hello/")))
754 return NULL;
755 url += strlen ("gnunet://hello/");
756 s1 = strchr (url, '/');
757 if (NULL == s1)
758 {
759 GNUNET_break_op (0);
760 return NULL;
761 }
762 s2 = strchr (s1 + 1, '/');
763 if (NULL == s2)
764 {
765 GNUNET_break_op (0);
766 return NULL;
767 }
768 q = strchr (url, '?');
769 if (NULL == q)
770 q = url + strlen (url);
771 if (GNUNET_OK !=
773 s1 - url,
774 &pid,
775 sizeof(pid)))
776 {
777 GNUNET_break_op (0);
778 return NULL;
779 }
780 if (GNUNET_OK !=
782 s2 - (s1 + 1),
783 &sig,
784 sizeof(sig)))
785 {
786 GNUNET_break_op (0);
787 return NULL;
788 }
789 {
790 uint64_t sec;
791 char dummy = '?';
792
793 if ( (0 == sscanf (s2 + 1,
794 "%" PRIu64 "%c",
795 &sec,
796 &dummy)) ||
797 ('?' != dummy) )
798 {
799 GNUNET_break_op (0);
800 return NULL;
801 }
802 et.abs_value_us = sec;
803 }
804
805 p = parser_new (&pid);
806 p->et = et;
807 p->sig = sig;
808 len = strlen (q);
809 while (len > 0)
810 {
811 const char *eq;
812 const char *amp;
813 char *addr = NULL;
814 char *uri;
815
816 /* skip ?/& separator */
817 len--;
818 q++;
819 eq = strchr (q, '=');
820 if ( (eq == q) ||
821 (NULL == eq) )
822 {
823 GNUNET_break_op (0);
825 return NULL;
826 }
827 amp = strchr (eq, '&');
828 if (NULL == amp)
829 amp = &q[len];
831 amp - (eq + 1),
832 &addr);
833 if ( (NULL == addr) ||
834 (0 == strlen (addr)) )
835 {
836 GNUNET_free (addr);
837 GNUNET_break_op (0);
839 return NULL;
840 }
842 "%.*s://%s",
843 (int) (eq - q),
844 q,
845 addr);
846 GNUNET_free (addr);
847 if (GNUNET_OK !=
849 uri))
850 {
851 GNUNET_break_op (0);
854 return NULL;
855 }
857 /* move to next URL */
858 len -= (amp - q);
859 q = amp;
860 }
861
862 {
864
865 ret = verify_hello (p,
866 et,
867 &p->sig);
869 if (GNUNET_OK != ret)
870 {
872 return NULL;
873 }
874 }
875 return p;
876}
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
size_t GNUNET_STRINGS_urldecode(const char *data, size_t len, char **out)
url/percent encode (RFC3986).
Definition strings.c:1838
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition strings.c:843
an ECC signature using EdDSA.
The identity of the host (wraps the signing key of the peer).

References GNUNET_TIME_Absolute::abs_value_us, dummy, GNUNET_asprintf(), GNUNET_break_op, GNUNET_free, GNUNET_HELLO_parser_free(), GNUNET_OK, GNUNET_STRINGS_string_to_data(), GNUNET_STRINGS_urldecode(), GNUNET_SYSERR, p, parser_add_address(), parser_new(), q, ret, uri, and verify_hello().

Referenced by handle_dht_local_hello_offer(), hosts_directory_scan_callback(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_get_expiration_time_from_msg()

struct GNUNET_TIME_Absolute GNUNET_HELLO_get_expiration_time_from_msg ( const struct GNUNET_MessageHeader msg)

Get the expiration time for this HELLO.

Parameters
msgThe hello msg.
Returns
The expiration time.

Definition at line 655 of file hello-uri.c.

657{
658 struct GNUNET_TIME_Absolute et;
659 if (GNUNET_MESSAGE_TYPE_HELLO_URI == ntohs (msg->type))
660 {
661 const struct HelloUriMessage *h = (const struct HelloUriMessage *) msg;
662 const struct BlockHeader *bh = (const struct BlockHeader *) &h[1];
663 if (ntohs (msg->size) <
664 sizeof (struct HelloUriMessage) + sizeof (struct BlockHeader))
665 {
666 GNUNET_break_op (0);
668 }
669 if (ntohs (msg->size) ==
670 sizeof (struct HelloUriMessage) + sizeof (struct BlockHeader))
671 {
672 /* Well-formed, but carries no address: nothing worth keeping. This is
673 what our own HELLO looks like before a communicator has reported an
674 address, so it is not a protocol violation. */
676 }
677
679 return et;
680 }
681 else if (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO == ntohs (msg->type))
682 {
683 const struct DhtHelloMessage *dht_hello
684 = (const struct DhtHelloMessage *) msg;
685 if (ntohs (msg->size) < sizeof (struct DhtHelloMessage))
686 {
687 GNUNET_break_op (0);
689 }
690
692 return et;
693 }
694 else
695 GNUNET_break_op (0);
697}
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the HELLO expire?
Definition hello-uri.c:145

References BlockHeader::expiration_time, DhtHelloMessage::expiration_time, GNUNET_break_op, GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO, GNUNET_MESSAGE_TYPE_HELLO_URI, GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_UNIT_ZERO_ABS, h, msg, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by announce_id(), consider_for_advertising(), consider_peer_destroy(), GCP_set_hello(), GNUNET_PEERSTORE_hello_add(), got_hello(), hello_add_iter(), hello_iter(), and hosts_directory_scan_callback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_parser_to_env()

struct GNUNET_MQ_Envelope * GNUNET_HELLO_parser_to_env ( const struct GNUNET_HELLO_Parser parser)

Generate envelope with GNUnet HELLO message (including peer ID) from a parser.

Parameters
builderbuilder to serialize
Returns
HELLO message matching parser

Definition at line 980 of file hello-uri.c.

981{
982 struct GNUNET_MQ_Envelope *env;
983 struct HelloUriMessage *msg;
984 size_t blen;
985
986 if (parser->a_length > UINT16_MAX)
987 {
988 GNUNET_break_op (0);
989 return NULL;
990 }
991 blen = 0;
994 NULL,
995 &blen));
997 blen,
999 msg->url_counter = htons ((uint16_t) parser->a_length);
1002 &msg[1],
1003 &blen));
1004 return env;
1005}
struct GNUNET_MQ_Envelope * env
Definition 005.c:1
enum GNUNET_GenericReturnValue GNUNET_HELLO_parser_to_block(const struct GNUNET_HELLO_Parser *parser, void *block, size_t *block_size)
Generate DHT block from a parser.
Definition hello-uri.c:937
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.

References env, GNUNET_assert, GNUNET_break_op, GNUNET_HELLO_parser_to_block(), GNUNET_MESSAGE_TYPE_HELLO_URI, GNUNET_MQ_msg_extra, GNUNET_NO, GNUNET_OK, and msg.

Referenced by hosts_directory_scan_callback(), output_parser(), pils_pid_change_cb(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_parser_to_url()

char * GNUNET_HELLO_parser_to_url ( const struct GNUNET_HELLO_Parser parser)

Generate GNUnet HELLO URI from a parser.

Parameters
parserHELLO parser to serialize
Returns
hello URI

Definition at line 880 of file hello-uri.c.

881{
882 char *result;
883 char *pids;
884 char *sigs;
885 const char *sep = "?";
886
888 sizeof (parser->pid));
890 sizeof (parser->sig));
892 "gnunet://hello/%s/%s/%" PRIu64,
893 pids,
894 sigs,
895 parser->et.abs_value_us);
896 GNUNET_free (sigs);
897 GNUNET_free (pids);
898 for (struct Address *a = parser->a_head;
899 NULL != a;
900 a = a->next)
901 {
902 char *eou_url_encoded;
903 char *tmp;
904 int pfx_len;
905 const char *eou;
906
907 eou = strstr (a->uri,
908 "://");
909 if (NULL == eou)
910 {
911 GNUNET_break_op (0);
913 return NULL;
914 }
915 pfx_len = eou - a->uri;
916 eou += 3;
917 GNUNET_STRINGS_urlencode (a->uri_len - 4 - pfx_len,
918 eou,
919 &eou_url_encoded);
920 GNUNET_asprintf (&tmp,
921 "%s%s%.*s=%s",
922 result,
923 sep,
924 pfx_len,
925 a->uri,
926 eou_url_encoded);
927 GNUNET_free (eou_url_encoded);
929 result = tmp;
930 sep = "&";
931 }
932 return result;
933}
static int result
Global testing status.
size_t GNUNET_STRINGS_urlencode(size_t len, const char data[static len], char **out)
url/percent encode (RFC3986).
Definition strings.c:1893
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition strings.c:818

References GNUNET_asprintf(), GNUNET_break_op, GNUNET_free, GNUNET_STRINGS_data_to_string_alloc(), GNUNET_STRINGS_urlencode(), and result.

Referenced by build_json_response(), handle_dht_local_hello_get(), and output_parser().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_parser_to_block()

enum GNUNET_GenericReturnValue GNUNET_HELLO_parser_to_block ( const struct GNUNET_HELLO_Parser parser,
void *  block,
size_t *  block_size 
)

Generate DHT block from a parser.

Parameters
builderthe builder to serialize
[out]blockwhere to write the block, NULL to only calculate block_size
[in,out]block_sizeinput is number of bytes available in block, output is number of bytes needed in block
Returns
GNUNET_OK on success, GNUNET_NO if block_size was too small or if block was NULL

Definition at line 937 of file hello-uri.c.

940{
941 struct BlockHeader bh;
942 size_t needed = sizeof (bh);
943 char *pos;
944
945 for (struct Address *a = parser->a_head;
946 NULL != a;
947 a = a->next)
948 {
949 GNUNET_assert (needed + a->uri_len > needed);
950 needed += a->uri_len;
951 }
952 if ( (NULL == block) ||
953 (needed > *block_size) )
954 {
955 *block_size = needed;
956 return GNUNET_NO;
957 }
958 bh.pid = parser->pid;
959 bh.sig = parser->sig;
960 bh.expiration_time = GNUNET_TIME_absolute_hton (parser->et);
961 memcpy (block,
962 &bh,
963 sizeof (bh));
964 pos = block + sizeof (bh);
965 for (struct Address *a = parser->a_head;
966 NULL != a;
967 a = a->next)
968 {
969 memcpy (pos,
970 a->uri,
971 a->uri_len);
972 pos += a->uri_len;
973 }
974 *block_size = needed;
975 return GNUNET_OK;
976}
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition time.c:636

References BlockHeader::expiration_time, GNUNET_assert, GNUNET_NO, GNUNET_OK, GNUNET_TIME_absolute_hton(), BlockHeader::pid, and BlockHeader::sig.

Referenced by GNUNET_HELLO_parser_to_dht_hello_msg(), and GNUNET_HELLO_parser_to_env().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_builder_add_address()

enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_add_address ( struct GNUNET_HELLO_Builder builder,
const char *  address 
)

Add individual address to the builder.

Parameters
[in,out]builderto update
addressaddress URI to add
Returns
GNUNET_OK on success, GNUNET_NO if address was already in builder

Definition at line 701 of file hello-uri.c.

703{
704 struct Address *a;
706 size_t alen = strlen (address) + 1;
707
709 if (GNUNET_OK != ret)
710 {
712 "Failed to add address to builder\n");
713 return ret;
714 }
715 /* check for duplicates */
716 for (a = builder->a_head;
717 NULL != a;
718 a = a->next)
719 if (0 == strcmp (address,
720 a->uri))
721 return GNUNET_NO;
722 a = GNUNET_malloc (sizeof (struct Address) + alen);
723 a->uri_len = alen;
724 memcpy (&a[1],
725 address,
726 alen);
727 a->uri = (const char *) &a[1];
730 NULL,
731 builder->a_head,
732 builder->a_tail,
733 a);
734 builder->a_length++;
735 return GNUNET_OK;
736}
static char * address
GNS address for this phone.
#define GNUNET_log(kind,...)
#define GNUNET_CONTAINER_DLL_insert_sorted(TYPE, comparator, comparator_cls, head, tail, element)
Insertion sort of element into DLL from head to tail sorted by comparator.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_malloc(size)
Wrapper around malloc.
static int cmp_address(void *cls, struct Address *a, struct Address *b)
Alphanumeric sorting for addresses.
Definition hello-uri.c:536
static enum GNUNET_GenericReturnValue check_address(const char *address)
Definition hello-uri.c:497
size_t uri_len
Length of uri including 0-terminator.
Definition hello-uri.c:177

References address, builder, check_address(), cmp_address(), GNUNET_CONTAINER_DLL_insert_sorted, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_malloc, GNUNET_NO, GNUNET_OK, Address::next, ret, Address::uri, and Address::uri_len.

Referenced by GNUNET_HELLO_builder_from_parser(), handle_add_address(), run(), and store_pi().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_builder_del_address()

enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_del_address ( struct GNUNET_HELLO_Builder builder,
const char *  address 
)

Remove individual address from the builder.

Parameters
[in,out]builderto update
addressaddress URI to remove
Returns
GNUNET_OK on success, GNUNET_NO if address was not in builder

Definition at line 1009 of file hello-uri.c.

1011{
1012 struct Address *a;
1013
1014 /* check for duplicates */
1015 for (a = builder->a_head;
1016 NULL != a;
1017 a = a->next)
1018 if (0 == strcmp (address,
1019 a->uri))
1020 break;
1021 if (NULL == a)
1022 return GNUNET_NO;
1024 builder->a_tail,
1025 a);
1026 builder->a_length--;
1027 GNUNET_free (a);
1028 return GNUNET_OK;
1029}

References address, builder, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NO, GNUNET_OK, Address::next, and Address::uri.

Referenced by handle_del_address().

Here is the caller graph for this function:

◆ GNUNET_HELLO_builder_iterate()

void GNUNET_HELLO_builder_iterate ( const struct GNUNET_HELLO_Builder builder,
GNUNET_HELLO_UriCallback  uc,
void *  uc_cls 
)

Iterate over URIs in a builder.

Parameters
builderbuilder to iterate over
uccallback invoked for each URI, can be NULL
uc_clsclosure for addrgen
Returns
pid of the peer the builder is for, can be NULL

Definition at line 1033 of file hello-uri.c.

1036{
1037 struct Address *nxt;
1038
1039 for (struct Address *a = builder->a_head;
1040 NULL != a;
1041 a = nxt)
1042 {
1043 nxt = a->next;
1044 uc (uc_cls,
1045 NULL,
1046 a->uri);
1047 }
1048}
static struct GNUNET_FS_UnindexContext * uc

References builder, Address::next, and uc.

Referenced by do_generate_pid(), pils_pid_change_cb(), and run().

Here is the caller graph for this function:

◆ GNUNET_HELLO_parser_iterate()

const struct GNUNET_PeerIdentity * GNUNET_HELLO_parser_iterate ( const struct GNUNET_HELLO_Parser parser,
GNUNET_HELLO_UriCallback  uc,
void *  uc_cls 
)

Iterate over URIs in a parser.

Parameters
builderbuilder to iterate over
uccallback invoked for each URI, can be NULL
uc_clsclosure for addrgen
Returns
pid of the peer the builder is for, can be NULL

Definition at line 1052 of file hello-uri.c.

1055{
1056 struct Address *nxt;
1057
1058 if (NULL == uc)
1059 return &parser->pid;
1060 for (struct Address *a = parser->a_head;
1061 NULL != a;
1062 a = nxt)
1063 {
1064 nxt = a->next;
1065 uc (uc_cls,
1066 &parser->pid,
1067 a->uri);
1068 }
1069 return &parser->pid;
1070}

References Address::next, and uc.

Referenced by block_plugin_dht_check_block(), block_plugin_dht_check_reply(), block_plugin_dht_get_key(), check_for_burst_address(), check_for_global_natted(), consider_for_advertising(), handle_dht_local_hello_offer(), handle_hello_for_client(), handle_hello_for_incoming(), hello_check(), hello_iter(), and peerinfo_cb().

Here is the caller graph for this function:

◆ GNUNET_HELLO_dht_msg_to_block()

enum GNUNET_GenericReturnValue GNUNET_HELLO_dht_msg_to_block ( const struct GNUNET_MessageHeader hello,
const struct GNUNET_PeerIdentity pid,
void **  block,
size_t *  block_size,
struct GNUNET_TIME_Absolute block_expiration 
)

Convert a DHT hello message to a HELLO block.

Parameters
hellothe HELLO message
pidpeer that created the hello
[out]blockset to the HELLO block
[out]block_sizeset to number of bytes in block
[out]block_expirationset to expiration time of block
Returns
GNUNET_OK on success, GNUNET_NO if the hello is expired (block is set!) GNUNET_SYSERR if hello is invalid (block will be set to NULL)

Definition at line 1074 of file hello-uri.c.

1079{
1080 const struct DhtHelloMessage *msg
1081 = (const struct DhtHelloMessage *) hello;
1082 uint16_t len = ntohs (hello->size);
1083 struct BlockHeader *bh;
1084 struct GNUNET_HELLO_Parser *b;
1086
1087 if (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO != ntohs (hello->type))
1088 {
1089 GNUNET_break_op (0);
1090 return GNUNET_SYSERR;
1091 }
1092 if (len < sizeof (*msg))
1093 {
1094 GNUNET_break_op (0);
1095 return GNUNET_SYSERR;
1096 }
1097 len -= sizeof (*msg);
1098 *block_size = len + sizeof (*bh);
1099 *block = GNUNET_malloc (*block_size);
1100 bh = *block;
1101 bh->pid = *pid;
1102 bh->sig = msg->sig;
1103 bh->expiration_time = msg->expiration_time;
1104 *block_expiration = GNUNET_TIME_absolute_ntoh (msg->expiration_time);
1105 memcpy (&bh[1],
1106 &msg[1],
1107 len);
1109 *block_size);
1110 if (NULL == b)
1111 {
1112 GNUNET_break_op (0);
1113 GNUNET_free (*block);
1114 *block_size = 0;
1115 return GNUNET_SYSERR;
1116 }
1117 ret = verify_hello (b,
1118 *block_expiration,
1119 &msg->sig);
1121 if (GNUNET_SYSERR == ret)
1122 {
1123 GNUNET_free (*block);
1124 *block_size = 0;
1125 return GNUNET_SYSERR;
1126 }
1127 return ret;
1128}
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_block(const void *block, size_t block_size)
Parse block.
Definition hello-uri.c:582

References BlockHeader::expiration_time, GNUNET_break_op, GNUNET_free, GNUNET_HELLO_parser_free(), GNUNET_HELLO_parser_from_block(), GNUNET_malloc, GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO, GNUNET_SYSERR, GNUNET_TIME_absolute_ntoh(), msg, BlockHeader::pid, GNUNET_HELLO_Parser::pid, ret, BlockHeader::sig, GNUNET_MessageHeader::size, GNUNET_MessageHeader::type, and verify_hello().

Referenced by announce_id(), check_dht_p2p_hello(), GNUNET_HELLO_parser_from_msg_(), handle_dht_p2p_hello(), and handle_find_my_hello().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_address_to_prefix()

char * GNUNET_HELLO_address_to_prefix ( const char *  address)

Given an address as a string, extract the prefix that identifies the communicator offering transmissions to that address.

Parameters
addressa peer's address
Returns
NULL if the address is mal-formed, otherwise the prefix

Definition at line 1139 of file hello-uri.c.

1140{
1141 const char *dash;
1142
1143 dash = strchr (address, '-');
1144 if (NULL == dash)
1145 return NULL;
1146 return GNUNET_strndup (address, dash - address);
1147}
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.

References address, and GNUNET_strndup.

Referenced by check_validation_request_pending(), find_queue_by_ip(), GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue(), handle_add_address(), store_pi(), and suggest_to_connect().

Here is the caller graph for this function:

◆ GNUNET_HELLO_build_url()

enum GNUNET_GenericReturnValue GNUNET_HELLO_build_url ( const struct GNUNET_HELLO_Builder builder,
const struct GNUNET_PeerIdentity pid,
const struct GNUNET_CRYPTO_EddsaSignature sig,
struct GNUNET_TIME_Absolute  expiration,
char **  result 
)
Parameters
builderbuilder to serialize
pidpeer identity
sigsignature of the hello
expiration_timeexpiration time

Definition at line 1151 of file hello-uri.c.

1156{
1157 char *pids;
1158 char *sigs;
1159 const char *sep = "?";
1160
1162 sizeof (*pid));
1164 sizeof (*sig));
1166 "gnunet://hello/%s/%s/%" PRIu64,
1167 pids,
1168 sigs,
1169 expiration.abs_value_us);
1170 GNUNET_free (sigs);
1171 GNUNET_free (pids);
1172 for (struct Address *a = builder->a_head;
1173 NULL != a;
1174 a = a->next)
1175 {
1176 char *eou_url_encoded;
1177 char *tmp;
1178 int pfx_len;
1179 const char *eou;
1180
1181 eou = strstr (a->uri,
1182 "://");
1183 if (NULL == eou)
1184 {
1185 GNUNET_break_op (0);
1187 return GNUNET_SYSERR;
1188 }
1189 pfx_len = eou - a->uri;
1190 eou += 3;
1191 GNUNET_STRINGS_urlencode (a->uri_len - 4 - pfx_len,
1192 eou,
1193 &eou_url_encoded);
1194 GNUNET_asprintf (&tmp,
1195 "%s%s%.*s=%s",
1196 *result,
1197 sep,
1198 pfx_len,
1199 a->uri,
1200 eou_url_encoded);
1201 GNUNET_free (eou_url_encoded);
1203 *result = tmp;
1204 sep = "&";
1205 }
1206 return GNUNET_OK;
1207}
static struct GNUNET_TIME_Relative expiration
User supplied expiration value.

References builder, expiration, GNUNET_asprintf(), GNUNET_break_op, GNUNET_free, GNUNET_OK, GNUNET_STRINGS_data_to_string_alloc(), GNUNET_STRINGS_urlencode(), GNUNET_SYSERR, GNUNET_HELLO_Parser::pid, result, and GNUNET_HELLO_Parser::sig.

Referenced by GNUNET_HELLO_builder_to_url2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_builder_to_dht_hello_msg()

struct GNUNET_MessageHeader * GNUNET_HELLO_builder_to_dht_hello_msg ( const struct GNUNET_HELLO_Builder builder,
const struct GNUNET_PeerIdentity pid,
const struct GNUNET_CRYPTO_EddsaSignature sig,
struct GNUNET_TIME_Absolute  expiration_time 
)

Generate DHT HELLO message (without peer ID) from a builder.

Parameters
builderbuilder to serialize
pidpeer identity
sigsignature of the hello
expiration_timeexpiration time
Returns
handle to the message

Definition at line 1287 of file hello-uri.c.

1292{
1293 struct BlockHeader *block;
1294 struct DhtHelloMessage *msg;
1295 size_t block_size;
1296
1297
1299 msg = GNUNET_malloc (sizeof (*msg)
1300 + block_size);
1301 block = (struct BlockHeader*) &msg[1];
1303 pid,
1304 hello_sig,
1306 (char*) &msg[1]);
1307 msg->sig = block->sig;
1308 msg->expiration_time = block->expiration_time;
1309 memmove (&msg[1],
1310 (char*) block + sizeof (*block),
1311 block_size - sizeof (*block));
1312 msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO);
1313 msg->header.size = htons (sizeof (*msg)
1314 + block_size
1315 - sizeof (*block));
1316 msg->url_counter = htons ((uint16_t) builder->a_length);
1317 return &msg->header;
1318}
void GNUNET_HELLO_builder_to_block(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig, struct GNUNET_TIME_Absolute expiration_time, char *block)
Generate DHT block from a builder.
Definition hello-uri.c:1322
size_t GNUNET_HELLO_get_builder_to_block_size(const struct GNUNET_HELLO_Builder *builder)
Get projected block size for builder.
Definition hello-uri.c:1390

References builder, BlockHeader::expiration_time, GNUNET_HELLO_builder_to_block(), GNUNET_HELLO_get_builder_to_block_size(), GNUNET_malloc, GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO, msg, BlockHeader::pid, BlockHeader::sig, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Here is the call graph for this function:

◆ GNUNET_HELLO_parser_to_dht_hello_msg()

struct GNUNET_MessageHeader * GNUNET_HELLO_parser_to_dht_hello_msg ( const struct GNUNET_HELLO_Parser parser)

Generate DHT HELLO message from a parser.

Parameters
parserbuilder to serialize
Returns
handle to the message

Definition at line 1249 of file hello-uri.c.

1250{
1251 struct BlockHeader *block;
1252 struct DhtHelloMessage *msg;
1253 size_t block_size;
1254
1255
1256 block_size = 0;
1259 NULL,
1260 &block_size));
1261 msg = GNUNET_malloc (sizeof (*msg)
1262 + block_size);
1263 if (GNUNET_OK !=
1265 &msg[1],
1266 &block_size))
1267 {
1268 GNUNET_free (msg);
1269 return NULL;
1270 }
1271 block = (struct BlockHeader*) &msg[1];
1272 msg->sig = block->sig;
1273 msg->expiration_time = block->expiration_time;
1274 memmove (&msg[1],
1275 (char*) block + sizeof (*block),
1276 block_size - sizeof (*block));
1277 msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO);
1278 msg->header.size = htons (sizeof (*msg)
1279 + block_size
1280 - sizeof (*block));
1281 msg->url_counter = htons ((uint16_t) parser->a_length);
1282 return &msg->header;
1283}

References BlockHeader::expiration_time, GNUNET_assert, GNUNET_free, GNUNET_HELLO_parser_to_block(), GNUNET_malloc, GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO, GNUNET_NO, GNUNET_OK, msg, BlockHeader::sig, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by pid_change_cb(), and sign_hello_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_builder_to_block()

void GNUNET_HELLO_builder_to_block ( const struct GNUNET_HELLO_Builder builder,
const struct GNUNET_PeerIdentity pid,
const struct GNUNET_CRYPTO_EddsaSignature sig,
struct GNUNET_TIME_Absolute  expiration_time,
char *  outbuf 
)

Generate DHT block from a builder.

Parameters
builderbuilder to serialize
pidpeer identity
sigsignature of the hello
expiration_timeexpiration time
outbufthe buffer to the block

Definition at line 1322 of file hello-uri.c.

1328{
1329 struct BlockHeader bh = { 0 };
1330 char *pos;
1331 struct GNUNET_TIME_Absolute et;
1332
1333 if (NULL != pid)
1334 bh.pid = *pid;
1335 if (NULL != sig)
1336 bh.sig = *sig;
1337 if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == expiration_time.abs_value_us)
1339 else
1340 et = expiration_time;
1342 memcpy (block,
1343 &bh,
1344 sizeof (bh));
1345 pos = block + sizeof (bh);
1346 for (struct Address *a = builder->a_head; NULL != a; a = a->next)
1347 {
1348 memcpy (pos,
1349 a->uri,
1350 a->uri_len);
1351 pos += a->uri_len;
1352 }
1353}
#define GNUNET_HELLO_ADDRESS_EXPIRATION
For how long are HELLO signatures valid?
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition time.c:316
uint64_t abs_value_us
The actual value.

References GNUNET_TIME_Absolute::abs_value_us, builder, BlockHeader::expiration_time, GNUNET_HELLO_ADDRESS_EXPIRATION, GNUNET_TIME_absolute_hton(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_ZERO_ABS, BlockHeader::pid, and BlockHeader::sig.

Referenced by do_generate_pid(), GNUNET_HELLO_builder_to_dht_hello_msg(), GNUNET_HELLO_builder_to_env(), and GNUNET_PILS_feed_addresses().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_builder_hash_addresses()

void GNUNET_HELLO_builder_hash_addresses ( const struct GNUNET_HELLO_Builder builder,
struct GNUNET_HashCode hash 
)

Compute hash over addresses in builder.

Note: Duplicate of hash_addresses in src/lib/hello/hello-uri.c

Parameters
builderthe builder to hash addresses of
[out]hashwhere to write the hash

Definition at line 1211 of file hello-uri.c.

1213{
1214 hash_addresses (builder->a_head, hash);
1215}
static void hash_addresses(const struct Address *addr_start, struct GNUNET_HashCode *hash)
Definition hello-uri.c:267

References builder, and hash_addresses().

Referenced by do_generate_pid(), GNUNET_PILS_sign_hello(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_builder_to_env()

struct GNUNET_MQ_Envelope * GNUNET_HELLO_builder_to_env ( const struct GNUNET_HELLO_Builder builder,
const struct GNUNET_PeerIdentity pid,
const struct GNUNET_CRYPTO_EddsaSignature sig,
struct GNUNET_TIME_Absolute  expiration_time 
)

Generate envelope with GNUnet HELLO message (including peer ID) from a builder.

Parameters
builderbuilder to serialize
pidpeer identity
sigsignature of the hello
expiration_timeexpiration time
Returns
HELLO message matching builder

Definition at line 1219 of file hello-uri.c.

1224{
1225 struct GNUNET_MQ_Envelope *env;
1226 struct HelloUriMessage *msg;
1227 size_t blen;
1228
1229 if (builder->a_length > UINT16_MAX)
1230 {
1231 GNUNET_break_op (0);
1232 return NULL;
1233 }
1236 blen,
1238 msg->url_counter = htons ((uint16_t) builder->a_length);
1240 pid,
1241 hello_sig,
1242 expiration_time,
1243 (char*) &msg[1]);
1244 return env;
1245}

References builder, env, GNUNET_break_op, GNUNET_HELLO_builder_to_block(), GNUNET_HELLO_get_builder_to_block_size(), GNUNET_MESSAGE_TYPE_HELLO_URI, GNUNET_MQ_msg_extra, and msg.

Referenced by env_resign_cb(), and pils_sign_hello_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_get_builder_to_block_size()

size_t GNUNET_HELLO_get_builder_to_block_size ( const struct GNUNET_HELLO_Builder builder)

Get projected block size for builder.

Parameters
builderbuilder to serialize
Returns
block size

Definition at line 1390 of file hello-uri.c.

1392{
1393 struct BlockHeader bh;
1394 size_t needed = sizeof (bh);
1395
1396 for (struct Address *a = builder->a_head;
1397 NULL != a;
1398 a = a->next)
1399 {
1400 GNUNET_assert (needed + a->uri_len > needed);
1401 needed += a->uri_len;
1402 }
1403 return needed;
1404}

References builder, and GNUNET_assert.

Referenced by do_generate_pid(), GNUNET_HELLO_builder_to_dht_hello_msg(), GNUNET_HELLO_builder_to_env(), and GNUNET_PILS_feed_addresses().

Here is the caller graph for this function:

◆ GNUNET_HELLO_builder_to_url()

enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_to_url ( const struct GNUNET_HELLO_Builder builder,
const struct GNUNET_PeerIdentity pid,
const struct GNUNET_CRYPTO_EddsaSignature sig,
char **  result 
)

Generate GNUnet HELLO URI from a builder.

Parameters
builderbuilder to serialize
pidpeer identity
sigsignature of the hello
Returns
GNUNET_SYSERR on error

Definition at line 1372 of file hello-uri.c.

1376{
1377 struct GNUNET_TIME_Absolute et;
1378
1380
1382 pid,
1383 sig,
1384 et,
1385 result);
1386}
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_to_url2(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig, struct GNUNET_TIME_Absolute validity, char **result)
Generate GNUnet HELLO URI from a builder.
Definition hello-uri.c:1357

References builder, GNUNET_HELLO_ADDRESS_EXPIRATION, GNUNET_HELLO_builder_to_url2(), GNUNET_TIME_relative_to_absolute(), and result.

Here is the call graph for this function:

◆ GNUNET_HELLO_builder_to_url2()

enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_to_url2 ( const struct GNUNET_HELLO_Builder builder,
const struct GNUNET_PeerIdentity pid,
const struct GNUNET_CRYPTO_EddsaSignature sig,
struct GNUNET_TIME_Absolute  validity,
char **  result 
)

Generate GNUnet HELLO URI from a builder.

Parameters
builderbuilder to serialize
pidpeer identity
sigsignature of the hello
validityrelative validity target of hello
Returns
GNUNET_SYSERR on error

Definition at line 1357 of file hello-uri.c.

1362{
1364 pid,
1365 sig,
1366 validity,
1367 result);
1368}
enum GNUNET_GenericReturnValue GNUNET_HELLO_build_url(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_PeerIdentity *pid, const struct GNUNET_CRYPTO_EddsaSignature *sig, struct GNUNET_TIME_Absolute expiration, char **result)
Definition hello-uri.c:1151

References builder, GNUNET_HELLO_build_url(), and result.

Referenced by GNUNET_HELLO_builder_to_url(), and url_resign_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HELLO_builder_address_list_cmp()

enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_address_list_cmp ( const struct GNUNET_HELLO_Builder abuilder,
const struct GNUNET_HELLO_Builder bbuilder 
)

Compare address lists of two builders.

Assumes that address lists are already sorted. Will also return GNUNET_YES if address lists are usorted, but values match!

Parameters
abuilderthe first builder
bbuilderthe second builder
Returns
GNUNET_YES if address lists are the same

Definition at line 1408 of file hello-uri.c.

1412{
1413 bool found = false;
1414 for (struct Address *a = abuilder->a_head; NULL != a; a = a->next)
1415 {
1416 for (struct Address *b = bbuilder->a_head; NULL != b; b = b->next)
1417 {
1418 if (0 != strcmp (b->uri, a->uri))
1419 continue;
1420 found = true;
1421 break;
1422 }
1423 if (! found)
1424 return GNUNET_NO;
1425 found = false;
1426 }
1427 return GNUNET_YES;
1428}
struct Address * a_head
Head of the addresses DLL.
Definition hello-uri.c:189

References GNUNET_HELLO_Builder::a_head, GNUNET_NO, and GNUNET_YES.

Referenced by pils_pid_change_cb().

Here is the caller graph for this function: