GNUnet 0.27.0
 
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_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.

442{
443#endif
444#ifdef __cplusplus
445}
446#endif
447
448/* ifndef GNUNET_HELLO_URI_LIB_H */
449#endif
450
/* end of group */
452
/* end of group addition */
454
455/* 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 235 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_PeerIdentity pid
Identity of the peer we transmit to / connect to.
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:660
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, 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(), and pid_change_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 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(), 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{
419 uint16_t size = ntohs (msg->size);
420
421 switch (ntohs (msg->type))
422 {
424 {
425 const struct HelloUriMessage *h;
426
427 if (sizeof (struct HelloUriMessage) > size)
428 {
429 GNUNET_break_op (0);
430 return NULL;
431 }
432
433 h = (const struct HelloUriMessage *) msg;
434 size -= sizeof (*h);
436 size);
437 }
439 {
440 struct GNUNET_TIME_Absolute block_expiration;
441 struct GNUNET_HELLO_Parser *p;
442 size_t block_size;
443 void *block;
444
445 if (sizeof (struct DhtHelloMessage) > size)
446 {
447 GNUNET_break_op (0);
448 return NULL;
449 }
450
452 msg,
453 pid,
454 &block,
455 &block_size,
456 &block_expiration))
457 {
458 GNUNET_break_op (0);
459 return NULL;
460 }
461
463 block_size);
464 GNUNET_free (block);
465 return p;
466 }
467 default:
468 GNUNET_break (0);
469 return NULL;
470 }
471}
struct GNUNET_MessageHeader * msg
Definition 005.c:2
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:1033
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_block(const void *block, size_t block_size)
Parse block.
Definition hello-uri.c:560
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
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, pid, 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(), 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 560 of file hello-uri.c.

562{
564 block_size,
565 GNUNET_NO);
566}
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_block_(const void *block, size_t block_size, int noverify)
Parse block.
Definition hello-uri.c:570
@ 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 570 of file hello-uri.c.

573{
574 const struct BlockHeader *bh = block;
575 struct GNUNET_HELLO_Parser *p;
576
577 if (block_size < sizeof (*bh))
578 {
579 GNUNET_break_op (0);
580 return NULL;
581 }
582 p = parser_new (&bh->pid);
583 block += sizeof (*bh);
584 block_size -= sizeof (*bh);
585 while (block_size > 0)
586 {
587 const void *end = memchr (block,
588 '\0',
589 block_size);
590
591 if (NULL == end)
592 {
593 GNUNET_break_op (0);
595 return NULL;
596 }
597 if (GNUNET_OK !=
599 block))
600 {
601 GNUNET_break_op (0);
603 return NULL;
604 }
605 end++;
606 block_size -= (end - block);
607 block = end;
608 }
609 {
610 struct GNUNET_TIME_Absolute et;
612 if (GNUNET_YES != noverify)
613 {
615 ret = verify_hello (p,
616 et,
617 &bh->sig);
619 if (GNUNET_OK != ret)
620 {
622 return NULL;
623 }
624 }
625 p->et = et;
626 p->sig = bh->sig;
627 }
628 return p;
629}
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:521
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(), 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 699 of file hello-uri.c.

700{
701 const char *q;
702 const char *s1;
703 const char *s2;
705 struct GNUNET_TIME_Absolute et;
706 size_t len;
707 struct GNUNET_HELLO_Parser *p;
709
710 if (0 != strncasecmp (url,
711 "gnunet://hello/",
712 strlen ("gnunet://hello/")))
713 return NULL;
714 url += strlen ("gnunet://hello/");
715 s1 = strchr (url, '/');
716 if (NULL == s1)
717 {
718 GNUNET_break_op (0);
719 return NULL;
720 }
721 s2 = strchr (s1 + 1, '/');
722 if (NULL == s1)
723 {
724 GNUNET_break_op (0);
725 return NULL;
726 }
727 q = strchr (url, '?');
728 if (NULL == q)
729 q = url + strlen (url);
730 if (GNUNET_OK !=
732 s1 - url,
733 &pid,
734 sizeof(pid)))
735 {
736 GNUNET_break_op (0);
737 return NULL;
738 }
739 if (GNUNET_OK !=
741 s2 - (s1 + 1),
742 &sig,
743 sizeof(sig)))
744 {
745 GNUNET_break_op (0);
746 return NULL;
747 }
748 {
749 uint64_t sec;
750 char dummy = '?';
751
752 if ( (0 == sscanf (s2 + 1,
753 "%" PRIu64 "%c",
754 &sec,
755 &dummy)) ||
756 ('?' != dummy) )
757 {
758 GNUNET_break_op (0);
759 return NULL;
760 }
761 et.abs_value_us = sec;
762 }
763
764 p = parser_new (&pid);
765 p->et = et;
766 p->sig = sig;
767 len = strlen (q);
768 while (len > 0)
769 {
770 const char *eq;
771 const char *amp;
772 char *addr = NULL;
773 char *uri;
774
775 /* skip ?/& separator */
776 len--;
777 q++;
778 eq = strchr (q, '=');
779 if ( (eq == q) ||
780 (NULL == eq) )
781 {
782 GNUNET_break_op (0);
784 return NULL;
785 }
786 amp = strchr (eq, '&');
787 if (NULL == amp)
788 amp = &q[len];
790 amp - (eq + 1),
791 &addr);
792 if ( (NULL == addr) ||
793 (0 == strlen (addr)) )
794 {
795 GNUNET_free (addr);
796 GNUNET_break_op (0);
798 return NULL;
799 }
801 "%.*s://%s",
802 (int) (eq - q),
803 q,
804 addr);
805 GNUNET_free (addr);
806 if (GNUNET_OK !=
808 uri))
809 {
810 GNUNET_break_op (0);
813 return NULL;
814 }
816 /* move to next URL */
817 len -= (amp - q);
818 q = amp;
819 }
820
821 {
823
824 ret = verify_hello (p,
825 et,
826 &p->sig);
828 if (GNUNET_OK != ret)
829 {
831 return NULL;
832 }
833 }
834 return p;
835}
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:1832
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:837
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(), 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 633 of file hello-uri.c.

635{
636 struct GNUNET_TIME_Absolute et;
637 if (GNUNET_MESSAGE_TYPE_HELLO_URI == ntohs (msg->type))
638 {
639 const struct HelloUriMessage *h = (const struct HelloUriMessage *) msg;
640 const struct BlockHeader *bh = (const struct BlockHeader *) &h[1];
641
643 return et;
644 }
645 else if (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO == ntohs (msg->type))
646 {
647 const struct DhtHelloMessage *dht_hello
648 = (const struct DhtHelloMessage *) msg;
649
651 return et;
652 }
653 else
654 GNUNET_break (0);
656}
#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, 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 939 of file hello-uri.c.

940{
941 struct GNUNET_MQ_Envelope *env;
942 struct HelloUriMessage *msg;
943 size_t blen;
944
945 if (parser->a_length > UINT16_MAX)
946 {
947 GNUNET_break (0);
948 return NULL;
949 }
950 blen = 0;
953 NULL,
954 &blen));
956 blen,
958 msg->url_counter = htons ((uint16_t) parser->a_length);
961 &msg[1],
962 &blen));
963 return env;
964}
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:896
#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, 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 839 of file hello-uri.c.

840{
841 char *result;
842 char *pids;
843 char *sigs;
844 const char *sep = "?";
845
847 sizeof (parser->pid));
849 sizeof (parser->sig));
851 "gnunet://hello/%s/%s/%" PRIu64,
852 pids,
853 sigs,
854 parser->et.abs_value_us);
855 GNUNET_free (sigs);
856 GNUNET_free (pids);
857 for (struct Address *a = parser->a_head;
858 NULL != a;
859 a = a->next)
860 {
861 char *eou_url_encoded;
862 char *tmp;
863 int pfx_len;
864 const char *eou;
865
866 eou = strstr (a->uri,
867 "://");
868 if (NULL == eou)
869 {
870 GNUNET_break (0);
872 return NULL;
873 }
874 pfx_len = eou - a->uri;
875 eou += 3;
876 GNUNET_STRINGS_urlencode (a->uri_len - 4 - pfx_len,
877 eou,
878 &eou_url_encoded);
879 GNUNET_asprintf (&tmp,
880 "%s%s%.*s=%s",
881 result,
882 sep,
883 pfx_len,
884 a->uri,
885 eou_url_encoded);
886 GNUNET_free (eou_url_encoded);
888 result = tmp;
889 sep = "&";
890 }
891 return result;
892}
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:1887
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition strings.c:812

References GNUNET_asprintf(), GNUNET_break, 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 896 of file hello-uri.c.

899{
900 struct BlockHeader bh;
901 size_t needed = sizeof (bh);
902 char *pos;
903
904 for (struct Address *a = parser->a_head;
905 NULL != a;
906 a = a->next)
907 {
908 GNUNET_assert (needed + a->uri_len > needed);
909 needed += a->uri_len;
910 }
911 if ( (NULL == block) ||
912 (needed < *block_size) )
913 {
914 *block_size = needed;
915 return GNUNET_NO;
916 }
917 bh.pid = parser->pid;
918 bh.sig = parser->sig;
919 bh.expiration_time = GNUNET_TIME_absolute_hton (parser->et);
920 memcpy (block,
921 &bh,
922 sizeof (bh));
923 pos = block + sizeof (bh);
924 for (struct Address *a = parser->a_head;
925 NULL != a;
926 a = a->next)
927 {
928 memcpy (pos,
929 a->uri,
930 a->uri_len);
931 pos += a->uri_len;
932 }
933 *block_size = needed;
934 return GNUNET_OK;
935}
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 660 of file hello-uri.c.

662{
663 struct Address *a;
665 size_t alen = strlen (address) + 1;
666
668 if (GNUNET_OK != ret)
669 {
671 "Failed to add address to builder\n");
672 return ret;
673 }
674 /* check for duplicates */
675 for (a = builder->a_head;
676 NULL != a;
677 a = a->next)
678 if (0 == strcmp (address,
679 a->uri))
680 return GNUNET_NO;
681 a = GNUNET_malloc (sizeof (struct Address) + alen);
682 a->uri_len = alen;
683 memcpy (&a[1],
684 address,
685 alen);
686 a->uri = (const char *) &a[1];
689 NULL,
690 builder->a_head,
691 builder->a_tail,
692 a);
693 builder->a_length++;
694 return GNUNET_OK;
695}
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:514
static enum GNUNET_GenericReturnValue check_address(const char *address)
Definition hello-uri.c:475
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 968 of file hello-uri.c.

970{
971 struct Address *a;
972
973 /* check for duplicates */
974 for (a = builder->a_head;
975 NULL != a;
976 a = a->next)
977 if (0 == strcmp (address,
978 a->uri))
979 break;
980 if (NULL == a)
981 return GNUNET_NO;
983 builder->a_tail,
984 a);
985 builder->a_length--;
986 GNUNET_free (a);
987 return GNUNET_OK;
988}

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

995{
996 struct Address *nxt;
997
998 for (struct Address *a = builder->a_head;
999 NULL != a;
1000 a = nxt)
1001 {
1002 nxt = a->next;
1003 uc (uc_cls,
1004 NULL,
1005 a->uri);
1006 }
1007}
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 1011 of file hello-uri.c.

1014{
1015 struct Address *nxt;
1016
1017 if (NULL == uc)
1018 return &parser->pid;
1019 for (struct Address *a = parser->a_head;
1020 NULL != a;
1021 a = nxt)
1022 {
1023 nxt = a->next;
1024 uc (uc_cls,
1025 &parser->pid,
1026 a->uri);
1027 }
1028 return &parser->pid;
1029}

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

1038{
1039 const struct DhtHelloMessage *msg
1040 = (const struct DhtHelloMessage *) hello;
1041 uint16_t len = ntohs (hello->size);
1042 struct BlockHeader *bh;
1043 struct GNUNET_HELLO_Parser *b;
1045
1046 if (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO != ntohs (hello->type))
1047 {
1048 GNUNET_break (0);
1049 return GNUNET_SYSERR;
1050 }
1051 if (len < sizeof (*msg))
1052 {
1053 GNUNET_break_op (0);
1054 return GNUNET_SYSERR;
1055 }
1056 len -= sizeof (*msg);
1057 *block_size = len + sizeof (*bh);
1058 *block = GNUNET_malloc (*block_size);
1059 bh = *block;
1060 bh->pid = *pid;
1061 bh->sig = msg->sig;
1062 bh->expiration_time = msg->expiration_time;
1063 *block_expiration = GNUNET_TIME_absolute_ntoh (msg->expiration_time);
1064 memcpy (&bh[1],
1065 &msg[1],
1066 len);
1068 *block_size);
1069 if (NULL == b)
1070 {
1071 GNUNET_break_op (0);
1072 GNUNET_free (*block);
1073 *block_size = 0;
1074 return GNUNET_SYSERR;
1075 }
1076 ret = verify_hello (b,
1077 *block_expiration,
1078 &msg->sig);
1080 if (GNUNET_SYSERR == ret)
1081 {
1082 GNUNET_free (*block);
1083 *block_size = 0;
1084 return GNUNET_SYSERR;
1085 }
1086 return ret;
1087}

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

1099{
1100 const char *dash;
1101
1102 dash = strchr (address, '-');
1103 if (NULL == dash)
1104 return NULL;
1105 return GNUNET_strndup (address, dash - address);
1106}
#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 1110 of file hello-uri.c.

1115{
1116 char *pids;
1117 char *sigs;
1118 const char *sep = "?";
1119
1121 sizeof (*pid));
1123 sizeof (*sig));
1125 "gnunet://hello/%s/%s/%" PRIu64,
1126 pids,
1127 sigs,
1128 expiration.abs_value_us);
1129 GNUNET_free (sigs);
1130 GNUNET_free (pids);
1131 for (struct Address *a = builder->a_head;
1132 NULL != a;
1133 a = a->next)
1134 {
1135 char *eou_url_encoded;
1136 char *tmp;
1137 int pfx_len;
1138 const char *eou;
1139
1140 eou = strstr (a->uri,
1141 "://");
1142 if (NULL == eou)
1143 {
1144 GNUNET_break (0);
1146 return GNUNET_SYSERR;
1147 }
1148 pfx_len = eou - a->uri;
1149 eou += 3;
1150 GNUNET_STRINGS_urlencode (a->uri_len - 4 - pfx_len,
1151 eou,
1152 &eou_url_encoded);
1153 GNUNET_asprintf (&tmp,
1154 "%s%s%.*s=%s",
1155 *result,
1156 sep,
1157 pfx_len,
1158 a->uri,
1159 eou_url_encoded);
1160 GNUNET_free (eou_url_encoded);
1162 *result = tmp;
1163 sep = "&";
1164 }
1165 return GNUNET_OK;
1166}
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 1245 of file hello-uri.c.

1250{
1251 struct BlockHeader *block;
1252 struct DhtHelloMessage *msg;
1253 size_t block_size;
1254
1255
1257 msg = GNUNET_malloc (sizeof (*msg)
1258 + block_size);
1259 block = (struct BlockHeader*) &msg[1];
1261 pid,
1262 hello_sig,
1264 (char*) &msg[1]);
1265 msg->sig = block->sig;
1266 msg->expiration_time = block->expiration_time;
1267 memmove (&msg[1],
1268 (char*) block + sizeof (*block),
1269 block_size - sizeof (*block));
1270 msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO);
1271 msg->header.size = htons (sizeof (*msg)
1272 + block_size
1273 - sizeof (*block));
1274 msg->url_counter = htons ((uint16_t) builder->a_length);
1275 return &msg->header;
1276}
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:1280
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:1348

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

1209{
1210 struct BlockHeader *block;
1211 struct DhtHelloMessage *msg;
1212 size_t block_size;
1213
1214
1215 block_size = 0;
1218 NULL,
1219 &block_size));
1220 msg = GNUNET_malloc (sizeof (*msg)
1221 + block_size);
1222 if (GNUNET_OK !=
1224 &msg[1],
1225 &block_size))
1226 {
1227 return NULL;
1228 }
1229 block = (struct BlockHeader*) &msg[1];
1230 msg->sig = block->sig;
1231 msg->expiration_time = block->expiration_time;
1232 memmove (&msg[1],
1233 (char*) block + sizeof (*block),
1234 block_size - sizeof (*block));
1235 msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO);
1236 msg->header.size = htons (sizeof (*msg)
1237 + block_size
1238 - sizeof (*block));
1239 msg->url_counter = htons ((uint16_t) parser->a_length);
1240 return &msg->header;
1241}

References BlockHeader::expiration_time, GNUNET_assert, 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 1280 of file hello-uri.c.

1286{
1287 struct BlockHeader bh = { 0 };
1288 char *pos;
1289 struct GNUNET_TIME_Absolute et;
1290
1291 if (NULL != pid)
1292 bh.pid = *pid;
1293 if (NULL != sig)
1294 bh.sig = *sig;
1295 if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == expiration_time.abs_value_us)
1297 else
1298 et = expiration_time;
1300 memcpy (block,
1301 &bh,
1302 sizeof (bh));
1303 pos = block + sizeof (bh);
1304 for (struct Address *a = builder->a_head; NULL != a; a = a->next)
1305 {
1306 memcpy (pos,
1307 a->uri,
1308 a->uri_len);
1309 pos += a->uri_len;
1310 }
1311}
#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 1170 of file hello-uri.c.

1172{
1173 hash_addresses (builder->a_head, hash);
1174}
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 1178 of file hello-uri.c.

1183{
1184 struct GNUNET_MQ_Envelope *env;
1185 struct HelloUriMessage *msg;
1186 size_t blen;
1187
1188 if (builder->a_length > UINT16_MAX)
1189 {
1190 GNUNET_break (0);
1191 return NULL;
1192 }
1195 blen,
1197 msg->url_counter = htons ((uint16_t) builder->a_length);
1199 pid,
1200 hello_sig,
1201 expiration_time,
1202 (char*) &msg[1]);
1203 return env;
1204}

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

1350{
1351 struct BlockHeader bh;
1352 size_t needed = sizeof (bh);
1353
1354 for (struct Address *a = builder->a_head;
1355 NULL != a;
1356 a = a->next)
1357 {
1358 GNUNET_assert (needed + a->uri_len > needed);
1359 needed += a->uri_len;
1360 }
1361 return needed;
1362}

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

1334{
1335 struct GNUNET_TIME_Absolute et;
1336
1338
1340 pid,
1341 sig,
1342 et,
1343 result);
1344}
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:1315

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

1320{
1322 pid,
1323 sig,
1324 validity,
1325 result);
1326}
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:1110

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

1370{
1371 bool found = false;
1372 for (struct Address *a = abuilder->a_head; NULL != a; a = a->next)
1373 {
1374 for (struct Address *b = bbuilder->a_head; NULL != b; b = b->next)
1375 {
1376 if (0 != strcmp (b->uri, a->uri))
1377 continue;
1378 found = true;
1379 break;
1380 }
1381 if (! found)
1382 return GNUNET_NO;
1383 found = false;
1384 }
1385 return GNUNET_YES;
1386}
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: