GNUnet debian-0.24.3-23-g589b01d60
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? More...
 

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. More...
 

Functions

struct GNUNET_HELLO_BuilderGNUNET_HELLO_builder_new ()
 Allocate builder. More...
 
struct GNUNET_HELLO_BuilderGNUNET_HELLO_builder_from_parser (const struct GNUNET_HELLO_Parser *parser, struct GNUNET_PeerIdentity *pid)
 Allocate builder from parser. More...
 
const struct GNUNET_PeerIdentityGNUNET_HELLO_parser_get_id (const struct GNUNET_HELLO_Parser *parser)
 Get the PeerIdentity for this builder. More...
 
void GNUNET_HELLO_builder_free (struct GNUNET_HELLO_Builder *builder)
 Release resources of a builder. More...
 
void GNUNET_HELLO_parser_free (struct GNUNET_HELLO_Parser *parser)
 Release resources of a builder. More...
 
struct GNUNET_HELLO_ParserGNUNET_HELLO_parser_from_msg (const struct GNUNET_MessageHeader *msg)
 Parse msg. More...
 
struct GNUNET_HELLO_ParserGNUNET_HELLO_parser_from_block (const void *block, size_t block_size)
 Parse block. More...
 
struct GNUNET_HELLO_ParserGNUNET_HELLO_parser_from_block_ (const void *block, size_t block_size, int noverify)
 Parse block. More...
 
struct GNUNET_HELLO_ParserGNUNET_HELLO_parser_from_url (const char *url)
 Parse GNUnet HELLO url. More...
 
struct GNUNET_TIME_Absolute GNUNET_HELLO_get_expiration_time_from_msg (const struct GNUNET_MessageHeader *msg)
 Get the expiration time for this HELLO. More...
 
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. More...
 
char * GNUNET_HELLO_parser_to_url (const struct GNUNET_HELLO_Parser *parser)
 Generate GNUnet HELLO URI from a parser. More...
 
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. More...
 
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_add_address (struct GNUNET_HELLO_Builder *builder, const char *address)
 Add individual address to the builder. More...
 
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_del_address (struct GNUNET_HELLO_Builder *builder, const char *address)
 Remove individual address from the builder. More...
 
void GNUNET_HELLO_builder_iterate (const struct GNUNET_HELLO_Builder *builder, GNUNET_HELLO_UriCallback uc, void *uc_cls)
 Iterate over URIs in a builder. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
struct GNUNET_MessageHeaderGNUNET_HELLO_parser_to_dht_hello_msg (const struct GNUNET_HELLO_Parser *parser)
 Generate DHT HELLO message from a parser. More...
 
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. More...
 
void GNUNET_HELLO_builder_hash_addresses (const struct GNUNET_HELLO_Builder *builder, struct GNUNET_HashCode *hash)
 Compute hash over addresses in builder. More...
 
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. More...
 
size_t GNUNET_HELLO_get_builder_to_block_size (const struct GNUNET_HELLO_Builder *builder)
 Get projected block size for builder. More...
 
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. More...
 
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. More...
 
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. More...
 

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.

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 233 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 343 of file hello-uri.c.

344{
346
348 return builder;
349}
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:184

References builder, and GNUNET_new.

Referenced by do_generate_pid(), GNUNET_HELLO_builder_from_parser(), pils_pid_change_cb(), 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 360 of file hello-uri.c.

362{
364 struct Address *a;
365
367 if (NULL != pid)
368 *pid = p->pid;
369 /* check for duplicates */
370 for (a = p->a_head;
371 NULL != a;
372 a = a->next)
374 return builder;
375}
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static struct GNUNET_OS_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:343
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:624
Address of a peer.
Definition: hello-uri.c:157
struct Address * next
Kept in a DLL.
Definition: hello-uri.c:161
const char * uri
Actual URI, allocated at the end of this struct.
Definition: hello-uri.c:171
pid_t pid
PID of the process.
Definition: os_priority.c:50

References builder, GNUNET_HELLO_builder_add_address(), GNUNET_HELLO_builder_new(), Address::next, p, GNUNET_OS_Process::pid, 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 353 of file hello-uri.c.

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

References warningfilter::parser.

Referenced by check_hello(), GNUNET_PEERSTORE_hello_add(), handle_hello_for_client(), hello_iter(), hosts_directory_scan_callback(), peer_id_change_cb(), pid_change_cb(), pils_id_change_cb(), and sign_hello_cb().

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 397 of file hello-uri.c.

398{
399 struct Address *a;
400
401 while (NULL != (a = builder->a_head))
402 {
404 builder->a_tail,
405 a);
406 builder->a_length--;
407 GNUNET_free (a);
408 }
409 GNUNET_assert (0 == builder->a_length);
411}
#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_shutdown(), GCH_shutdown(), pid_changed_cb(), and pils_pid_change_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 379 of file hello-uri.c.

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

References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, and warningfilter::parser.

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(), 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)

Parse msg.

Parameters
msgmessage to parse
Returns
builder, NULL on failure

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

416{
417 const struct HelloUriMessage *h;
418 uint16_t size = ntohs (msg->size);
419
420 if (GNUNET_MESSAGE_TYPE_HELLO_URI != ntohs (msg->type))
421 {
422 GNUNET_break (0);
423 return NULL;
424 }
425 if (sizeof (struct HelloUriMessage) > size)
426 {
427 GNUNET_break_op (0);
428 return NULL;
429 }
430 h = (const struct HelloUriMessage *) msg;
431 size -= sizeof (*h);
433 size);
434}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:98
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_block(const void *block, size_t block_size)
Parse block.
Definition: hello-uri.c:523
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.
#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_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 gossiping HELLOs between peers.
Definition: hello-uri.c:72

References GNUNET_break, GNUNET_break_op, GNUNET_HELLO_parser_from_block(), GNUNET_MESSAGE_TYPE_HELLO_URI, h, msg, GNUNET_MessageHeader::size, size, and GNUNET_MessageHeader::type.

Referenced by build_json_response(), 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(), hosts_directory_scan_callback(), and peerinfo_cb().

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 523 of file hello-uri.c.

525{
527 block_size,
528 GNUNET_NO);
529}
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_block_(const void *block, size_t block_size, int noverify)
Parse block.
Definition: hello-uri.c:533
@ GNUNET_NO

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(), GNUNET_HELLO_parser_from_msg(), 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 533 of file hello-uri.c.

536{
537 const struct BlockHeader *bh = block;
538 struct GNUNET_HELLO_Parser *p;
539
540 if (block_size < sizeof (*bh))
541 {
542 GNUNET_break_op (0);
543 return NULL;
544 }
545 p = parser_new (&bh->pid);
546 block += sizeof (*bh);
547 block_size -= sizeof (*bh);
548 while (block_size > 0)
549 {
550 const void *end = memchr (block,
551 '\0',
552 block_size);
553
554 if (NULL == end)
555 {
556 GNUNET_break_op (0);
558 return NULL;
559 }
560 if (GNUNET_OK !=
562 block))
563 {
564 GNUNET_break_op (0);
566 return NULL;
567 }
568 end++;
569 block_size -= (end - block);
570 block = end;
571 }
572 {
573 struct GNUNET_TIME_Absolute et;
574
576 if (GNUNET_YES != noverify)
577 {
579 ret = verify_hello (p,
580 et,
581 &bh->sig);
583 if (GNUNET_OK != ret)
584 {
586 return NULL;
587 }
588 }
590 p->sig = bh->sig;
591 }
592 return p;
593}
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:379
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_SYSERR
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:741
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:303
static struct GNUNET_HELLO_Parser * parser_new(const struct GNUNET_PeerIdentity *pid)
Definition: hello-uri.c:332
static enum GNUNET_GenericReturnValue parser_add_address(struct GNUNET_HELLO_Parser *parser, const char *address)
Definition: hello-uri.c:484
Start of a 'block'.
Definition: hello-uri.c:96
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the HELLO expire?
Definition: hello-uri.c:110
struct GNUNET_CRYPTO_EddsaSignature sig
Signature over the block, of purpose GNUNET_SIGNATURE_PURPOSE_HELLO.
Definition: hello-uri.c:105
struct GNUNET_PeerIdentity pid
Public key of the peer.
Definition: hello-uri.c:100
Context for parsing HELLOs.
Definition: hello-uri.c:232
Time for absolute times used by GNUnet, in microseconds.

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(), 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 663 of file hello-uri.c.

664{
665 const char *q;
666 const char *s1;
667 const char *s2;
669 struct GNUNET_TIME_Absolute et;
670 size_t len;
671 struct GNUNET_HELLO_Parser *p;
673
674 if (0 != strncasecmp (url,
675 "gnunet://hello/",
676 strlen ("gnunet://hello/")))
677 return NULL;
678 url += strlen ("gnunet://hello/");
679 s1 = strchr (url, '/');
680 if (NULL == s1)
681 {
682 GNUNET_break_op (0);
683 return NULL;
684 }
685 s2 = strchr (s1 + 1, '/');
686 if (NULL == s1)
687 {
688 GNUNET_break_op (0);
689 return NULL;
690 }
691 q = strchr (url, '?');
692 if (NULL == q)
693 q = url + strlen (url);
694 if (GNUNET_OK !=
696 s1 - url,
697 &pid,
698 sizeof(pid)))
699 {
700 GNUNET_break_op (0);
701 return NULL;
702 }
703 if (GNUNET_OK !=
705 s2 - (s1 + 1),
706 &sig,
707 sizeof(sig)))
708 {
709 GNUNET_break_op (0);
710 return NULL;
711 }
712 {
713 uint64_t sec;
714 char dummy = '?';
715
716 if ( (0 == sscanf (s2 + 1,
717 "%" PRIu64 "%c",
718 &sec,
719 &dummy)) ||
720 ('?' != dummy) )
721 {
722 GNUNET_break_op (0);
723 return NULL;
724 }
725 et.abs_value_us = sec;
726 }
727
728 p = parser_new (&pid);
729 p->et = et;
730 p->sig = sig;
731 len = strlen (q);
732 while (len > 0)
733 {
734 const char *eq;
735 const char *amp;
736 char *addr = NULL;
737 char *uri;
738
739 /* skip ?/& separator */
740 len--;
741 q++;
742 eq = strchr (q, '=');
743 if ( (eq == q) ||
744 (NULL == eq) )
745 {
746 GNUNET_break_op (0);
748 return NULL;
749 }
750 amp = strchr (eq, '&');
751 if (NULL == amp)
752 amp = &q[len];
754 amp - (eq + 1),
755 &addr);
756 if ( (NULL == addr) ||
757 (0 == strlen (addr)) )
758 {
759 GNUNET_free (addr);
760 GNUNET_break_op (0);
762 return NULL;
763 }
765 "%.*s://%s",
766 (int) (eq - q),
767 q,
768 addr);
769 GNUNET_free (addr);
770 if (GNUNET_OK !=
772 uri))
773 {
774 GNUNET_break_op (0);
777 return NULL;
778 }
780 /* move to next URL */
781 len -= (amp - q);
782 q = amp;
783 }
784
785 {
787
788 ret = verify_hello (p,
789 et,
790 &p->sig);
792 if (GNUNET_OK != ret)
793 {
795 return NULL;
796 }
797 }
798 return p;
799}
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:1827
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:832
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, 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(), pid, q, ret, uri, and verify_hello().

Referenced by handle_dht_local_hello_offer(), 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 597 of file hello-uri.c.

599{
600 struct GNUNET_TIME_Absolute et;
601 if (GNUNET_MESSAGE_TYPE_HELLO_URI == ntohs (msg->type))
602 {
603 const struct HelloUriMessage *h = (const struct HelloUriMessage *) msg;
604 const struct BlockHeader *bh = (const struct BlockHeader *) &h[1];
605
607 return et;
608 }
609 else if (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO == ntohs (msg->type))
610 {
611 const struct DhtHelloMessage *dht_hello
612 = (const struct DhtHelloMessage *) msg;
613
615 return et;
616 }
617 else
618 GNUNET_break (0);
620}
#define GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO
HELLO advertising a neighbours addresses.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
Message used when a DHT provides its HELLO to direct neighbours.
Definition: hello-uri.c:120
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the HELLO expire?
Definition: hello-uri.c:144

References BlockHeader::expiration_time, DhtHelloMessage::expiration_time, GNUNET_break, GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO, GNUNET_MESSAGE_TYPE_HELLO_URI, GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_UNIT_ZERO_ABS, h, msg, 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 903 of file hello-uri.c.

904{
905 struct GNUNET_MQ_Envelope *env;
906 struct HelloUriMessage *msg;
907 size_t blen;
908
909 if (parser->a_length > UINT16_MAX)
910 {
911 GNUNET_break (0);
912 return NULL;
913 }
914 blen = 0;
917 NULL,
918 &blen));
920 blen,
922 msg->url_counter = htons ((uint16_t) parser->a_length);
925 &msg[1],
926 &blen));
927 return env;
928}
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:860
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:61

References env, GNUNET_assert, GNUNET_break, GNUNET_HELLO_parser_to_block(), GNUNET_MESSAGE_TYPE_HELLO_URI, GNUNET_MQ_msg_extra, GNUNET_NO, GNUNET_OK, msg, and warningfilter::parser.

Referenced by 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 803 of file hello-uri.c.

804{
805 char *result;
806 char *pids;
807 char *sigs;
808 const char *sep = "?";
809
811 sizeof (parser->pid));
813 sizeof (parser->sig));
815 "gnunet://hello/%s/%s/%" PRIu64,
816 pids,
817 sigs,
818 parser->et.abs_value_us);
819 GNUNET_free (sigs);
820 GNUNET_free (pids);
821 for (struct Address *a = parser->a_head;
822 NULL != a;
823 a = a->next)
824 {
825 char *ue;
826 char *tmp;
827 int pfx_len;
828 const char *eou;
829
830 eou = strstr (a->uri,
831 "://");
832 if (NULL == eou)
833 {
834 GNUNET_break (0);
836 return NULL;
837 }
838 pfx_len = eou - a->uri;
839 eou += 3;
840 GNUNET_STRINGS_urlencode (a->uri_len - 4 - pfx_len,
841 eou,
842 &ue);
843 GNUNET_asprintf (&tmp,
844 "%s%s%.*s=%s",
845 result,
846 sep,
847 pfx_len,
848 a->uri,
849 ue);
850 GNUNET_free (ue);
852 result = tmp;
853 sep = "&";
854 }
855 return result;
856}
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:1882
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:807

References GNUNET_asprintf(), GNUNET_break, GNUNET_free, GNUNET_STRINGS_data_to_string_alloc(), GNUNET_STRINGS_urlencode(), warningfilter::parser, 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 860 of file hello-uri.c.

863{
864 struct BlockHeader bh;
865 size_t needed = sizeof (bh);
866 char *pos;
867
868 for (struct Address *a = parser->a_head;
869 NULL != a;
870 a = a->next)
871 {
872 GNUNET_assert (needed + a->uri_len > needed);
873 needed += a->uri_len;
874 }
875 if ( (NULL == block) ||
876 (needed < *block_size) )
877 {
878 *block_size = needed;
879 return GNUNET_NO;
880 }
881 bh.pid = parser->pid;
882 bh.sig = parser->sig;
883 bh.expiration_time = GNUNET_TIME_absolute_hton (parser->et);
884 memcpy (block,
885 &bh,
886 sizeof (bh));
887 pos = block + sizeof (bh);
888 for (struct Address *a = parser->a_head;
889 NULL != a;
890 a = a->next)
891 {
892 memcpy (pos,
893 a->uri,
894 a->uri_len);
895 pos += a->uri_len;
896 }
897 *block_size = needed;
898 return GNUNET_OK;
899}
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:640

References BlockHeader::expiration_time, GNUNET_assert, GNUNET_NO, GNUNET_OK, GNUNET_TIME_absolute_hton(), warningfilter::parser, 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 624 of file hello-uri.c.

626{
627 struct Address *a;
629 size_t alen = strlen (address) + 1;
630
632 if (GNUNET_OK != ret)
633 {
635 "Failed to add address to builder\n");
636 return ret;
637 }
638 /* check for duplicates */
639 for (a = builder->a_head;
640 NULL != a;
641 a = a->next)
642 if (0 == strcmp (address,
643 a->uri))
644 return GNUNET_NO;
645 a = GNUNET_malloc (sizeof (struct Address) + alen);
646 a->uri_len = alen;
647 memcpy (&a[1],
648 address,
649 alen);
650 a->uri = (const char *) &a[1];
653 NULL,
654 builder->a_head,
655 builder->a_tail,
656 a);
657 builder->a_length++;
658 return GNUNET_OK;
659}
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:477
static enum GNUNET_GenericReturnValue check_address(const char *address)
Definition: hello-uri.c:438
size_t uri_len
Length of uri including 0-terminator.
Definition: hello-uri.c:176

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 932 of file hello-uri.c.

934{
935 struct Address *a;
936
937 /* check for duplicates */
938 for (a = builder->a_head;
939 NULL != a;
940 a = a->next)
941 if (0 == strcmp (address,
942 a->uri))
943 break;
944 if (NULL == a)
945 return GNUNET_NO;
947 builder->a_tail,
948 a);
949 builder->a_length--;
950 GNUNET_free (a);
951 return GNUNET_OK;
952}

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 956 of file hello-uri.c.

959{
960 struct Address *nxt;
961
962 for (struct Address *a = builder->a_head;
963 NULL != a;
964 a = nxt)
965 {
966 nxt = a->next;
967 uc (uc_cls,
968 NULL,
969 a->uri);
970 }
971}
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 975 of file hello-uri.c.

978{
979 struct Address *nxt;
980
981 if (NULL == uc)
982 return &parser->pid;
983 for (struct Address *a = parser->a_head;
984 NULL != a;
985 a = nxt)
986 {
987 nxt = a->next;
988 uc (uc_cls,
989 &parser->pid,
990 a->uri);
991 }
992 return &parser->pid;
993}

References Address::next, warningfilter::parser, 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 997 of file hello-uri.c.

1002{
1003 const struct DhtHelloMessage *msg
1004 = (const struct DhtHelloMessage *) hello;
1005 uint16_t len = ntohs (hello->size);
1006 struct BlockHeader *bh;
1007 struct GNUNET_HELLO_Parser *b;
1009
1010 if (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO != ntohs (hello->type))
1011 {
1012 GNUNET_break (0);
1013 return GNUNET_SYSERR;
1014 }
1015 if (len < sizeof (*msg))
1016 {
1017 GNUNET_break_op (0);
1018 return GNUNET_SYSERR;
1019 }
1020 len -= sizeof (*msg);
1021 *block_size = len + sizeof (*bh);
1022 *block = GNUNET_malloc (*block_size);
1023 bh = *block;
1024 bh->pid = *pid;
1025 bh->sig = msg->sig;
1026 bh->expiration_time = msg->expiration_time;
1027 *block_expiration = GNUNET_TIME_absolute_ntoh (msg->expiration_time);
1028 memcpy (&bh[1],
1029 &msg[1],
1030 len);
1032 *block_size);
1033 if (NULL == b)
1034 {
1035 GNUNET_break_op (0);
1036 GNUNET_free (*block);
1037 *block_size = 0;
1038 return GNUNET_SYSERR;
1039 }
1040 ret = verify_hello (b,
1041 *block_expiration,
1042 &msg->sig);
1044 if (GNUNET_SYSERR == ret)
1045 {
1046 GNUNET_free (*block);
1047 *block_size = 0;
1048 return GNUNET_SYSERR;
1049 }
1050 return ret;
1051}

References BlockHeader::expiration_time, GNUNET_break, 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, pid, ret, BlockHeader::sig, GNUNET_MessageHeader::size, GNUNET_MessageHeader::type, and verify_hello().

Referenced by announce_id(), check_dht_p2p_hello(), and handle_dht_p2p_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 1062 of file hello-uri.c.

1063{
1064 const char *dash;
1065
1066 dash = strchr (address, '-');
1067 if (NULL == dash)
1068 return NULL;
1069 return GNUNET_strndup (address, dash - address);
1070}
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.

References address, and GNUNET_strndup.

Referenced by 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 1074 of file hello-uri.c.

1079{
1080 char *pids;
1081 char *sigs;
1082 const char *sep = "?";
1083
1085 sizeof (*pid));
1087 sizeof (*sig));
1089 "gnunet://hello/%s/%s/%" PRIu64,
1090 pids,
1091 sigs,
1092 expiration.abs_value_us);
1093 GNUNET_free (sigs);
1094 GNUNET_free (pids);
1095 for (struct Address *a = builder->a_head;
1096 NULL != a;
1097 a = a->next)
1098 {
1099 char *ue;
1100 char *tmp;
1101 int pfx_len;
1102 const char *eou;
1103
1104 eou = strstr (a->uri,
1105 "://");
1106 if (NULL == eou)
1107 {
1108 GNUNET_break (0);
1110 return GNUNET_SYSERR;
1111 }
1112 pfx_len = eou - a->uri;
1113 eou += 3;
1114 GNUNET_STRINGS_urlencode (a->uri_len - 4 - pfx_len,
1115 eou,
1116 &ue);
1117 GNUNET_asprintf (&tmp,
1118 "%s%s%.*s=%s",
1119 *result,
1120 sep,
1121 pfx_len,
1122 a->uri,
1123 ue);
1124 GNUNET_free (ue);
1126 *result = tmp;
1127 sep = "&";
1128 }
1129 return GNUNET_OK;
1130}
static struct GNUNET_TIME_Relative expiration
User supplied expiration value.

References builder, expiration, GNUNET_asprintf(), GNUNET_break, GNUNET_free, GNUNET_OK, GNUNET_STRINGS_data_to_string_alloc(), GNUNET_STRINGS_urlencode(), GNUNET_SYSERR, 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 1209 of file hello-uri.c.

1214{
1215 struct BlockHeader *block;
1216 struct DhtHelloMessage *msg;
1217 size_t block_size;
1218
1219
1221 msg = GNUNET_malloc (sizeof (*msg)
1222 + block_size);
1223 block = (struct BlockHeader*) &msg[1];
1225 pid,
1226 hello_sig,
1228 (char*) &msg[1]);
1229 msg->sig = block->sig;
1230 msg->expiration_time = block->expiration_time;
1231 memmove (&msg[1],
1232 (char*) block + sizeof (*block),
1233 block_size - sizeof (*block));
1234 msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO);
1235 msg->header.size = htons (sizeof (*msg)
1236 + block_size
1237 - sizeof (*block));
1238 msg->url_counter = htons ((uint16_t) builder->a_length);
1239 return &msg->header;
1240}
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:1244
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:1312

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, 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 1172 of file hello-uri.c.

1173{
1174 struct BlockHeader *block;
1175 struct DhtHelloMessage *msg;
1176 size_t block_size;
1177
1178
1179 block_size = 0;
1182 NULL,
1183 &block_size));
1184 msg = GNUNET_malloc (sizeof (*msg)
1185 + block_size);
1186 if (GNUNET_OK !=
1188 &msg[1],
1189 &block_size))
1190 {
1191 return NULL;
1192 }
1193 block = (struct BlockHeader*) &msg[1];
1194 msg->sig = block->sig;
1195 msg->expiration_time = block->expiration_time;
1196 memmove (&msg[1],
1197 (char*) block + sizeof (*block),
1198 block_size - sizeof (*block));
1199 msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO);
1200 msg->header.size = htons (sizeof (*msg)
1201 + block_size
1202 - sizeof (*block));
1203 msg->url_counter = htons ((uint16_t) parser->a_length);
1204 return &msg->header;
1205}

References BlockHeader::expiration_time, GNUNET_assert, GNUNET_HELLO_parser_to_block(), GNUNET_malloc, GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO, GNUNET_NO, GNUNET_OK, msg, warningfilter::parser, 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 1244 of file hello-uri.c.

1250{
1251 struct BlockHeader bh = { 0 };
1252 char *pos;
1253 struct GNUNET_TIME_Absolute et;
1254
1255 if (NULL != pid)
1256 bh.pid = *pid;
1257 if (NULL != sig)
1258 bh.sig = *sig;
1259 if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == expiration_time.abs_value_us)
1261 else
1262 et = expiration_time;
1264 memcpy (block,
1265 &bh,
1266 sizeof (bh));
1267 pos = block + sizeof (bh);
1268 for (struct Address *a = builder->a_head; NULL != a; a = a->next)
1269 {
1270 memcpy (pos,
1271 a->uri,
1272 a->uri_len);
1273 pos += a->uri_len;
1274 }
1275}
#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, 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 1134 of file hello-uri.c.

1136{
1137 hash_addresses (builder->a_head, hash);
1138}
static void hash_addresses(const struct Address *addr_start, struct GNUNET_HashCode *hash)
Definition: hello-uri.c:266

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 1142 of file hello-uri.c.

1147{
1148 struct GNUNET_MQ_Envelope *env;
1149 struct HelloUriMessage *msg;
1150 size_t blen;
1151
1152 if (builder->a_length > UINT16_MAX)
1153 {
1154 GNUNET_break (0);
1155 return NULL;
1156 }
1159 blen,
1161 msg->url_counter = htons ((uint16_t) builder->a_length);
1163 pid,
1164 hello_sig,
1165 expiration_time,
1166 (char*) &msg[1]);
1167 return env;
1168}

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

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 1312 of file hello-uri.c.

1314{
1315 struct BlockHeader bh;
1316 size_t needed = sizeof (bh);
1317
1318 for (struct Address *a = builder->a_head;
1319 NULL != a;
1320 a = a->next)
1321 {
1322 GNUNET_assert (needed + a->uri_len > needed);
1323 needed += a->uri_len;
1324 }
1325 return needed;
1326}

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 1294 of file hello-uri.c.

1298{
1299 struct GNUNET_TIME_Absolute et;
1300
1302
1304 pid,
1305 sig,
1306 et,
1307 result);
1308}
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:1279

References builder, GNUNET_HELLO_ADDRESS_EXPIRATION, GNUNET_HELLO_builder_to_url2(), GNUNET_TIME_relative_to_absolute(), pid, 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 1279 of file hello-uri.c.

1284{
1286 pid,
1287 sig,
1288 validity,
1289 result);
1290}
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:1074

References builder, GNUNET_HELLO_build_url(), pid, 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 1330 of file hello-uri.c.

1334{
1335 bool found = false;
1336 for (struct Address *a = abuilder->a_head; NULL != a; a = a->next)
1337 {
1338 for (struct Address *b = bbuilder->a_head; NULL != b; b = b->next)
1339 {
1340 if (0 != strcmp (b->uri, a->uri))
1341 continue;
1342 found = true;
1343 break;
1344 }
1345 if (!found)
1346 return GNUNET_NO;
1347 found = false;
1348 }
1349 return GNUNET_YES;
1350}
struct Address * a_head
Head of the addresses DLL.
Definition: hello-uri.c:188

References GNUNET_HELLO_Builder::a_head, GNUNET_NO, GNUNET_YES, and Address::next.

Referenced by pils_pid_change_cb().

Here is the caller graph for this function: