GNUnet 0.28.0-dev.3-20-gf1136b0b8
 
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:671
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:1044
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 710 of file hello-uri.c.

711{
712 const char *q;
713 const char *s1;
714 const char *s2;
716 struct GNUNET_TIME_Absolute et;
717 size_t len;
718 struct GNUNET_HELLO_Parser *p;
720
721 if (0 != strncasecmp (url,
722 "gnunet://hello/",
723 strlen ("gnunet://hello/")))
724 return NULL;
725 url += strlen ("gnunet://hello/");
726 s1 = strchr (url, '/');
727 if (NULL == s1)
728 {
729 GNUNET_break_op (0);
730 return NULL;
731 }
732 s2 = strchr (s1 + 1, '/');
733 if (NULL == s2)
734 {
735 GNUNET_break_op (0);
736 return NULL;
737 }
738 q = strchr (url, '?');
739 if (NULL == q)
740 q = url + strlen (url);
741 if (GNUNET_OK !=
743 s1 - url,
744 &pid,
745 sizeof(pid)))
746 {
747 GNUNET_break_op (0);
748 return NULL;
749 }
750 if (GNUNET_OK !=
752 s2 - (s1 + 1),
753 &sig,
754 sizeof(sig)))
755 {
756 GNUNET_break_op (0);
757 return NULL;
758 }
759 {
760 uint64_t sec;
761 char dummy = '?';
762
763 if ( (0 == sscanf (s2 + 1,
764 "%" PRIu64 "%c",
765 &sec,
766 &dummy)) ||
767 ('?' != dummy) )
768 {
769 GNUNET_break_op (0);
770 return NULL;
771 }
772 et.abs_value_us = sec;
773 }
774
775 p = parser_new (&pid);
776 p->et = et;
777 p->sig = sig;
778 len = strlen (q);
779 while (len > 0)
780 {
781 const char *eq;
782 const char *amp;
783 char *addr = NULL;
784 char *uri;
785
786 /* skip ?/& separator */
787 len--;
788 q++;
789 eq = strchr (q, '=');
790 if ( (eq == q) ||
791 (NULL == eq) )
792 {
793 GNUNET_break_op (0);
795 return NULL;
796 }
797 amp = strchr (eq, '&');
798 if (NULL == amp)
799 amp = &q[len];
801 amp - (eq + 1),
802 &addr);
803 if ( (NULL == addr) ||
804 (0 == strlen (addr)) )
805 {
806 GNUNET_free (addr);
807 GNUNET_break_op (0);
809 return NULL;
810 }
812 "%.*s://%s",
813 (int) (eq - q),
814 q,
815 addr);
816 GNUNET_free (addr);
817 if (GNUNET_OK !=
819 uri))
820 {
821 GNUNET_break_op (0);
824 return NULL;
825 }
827 /* move to next URL */
828 len -= (amp - q);
829 q = amp;
830 }
831
832 {
834
835 ret = verify_hello (p,
836 et,
837 &p->sig);
839 if (GNUNET_OK != ret)
840 {
842 return NULL;
843 }
844 }
845 return p;
846}
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
size_t GNUNET_STRINGS_urldecode(const char *data, size_t len, char **out)
url/percent encode (RFC3986).
Definition strings.c:1838
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition strings.c:843
an ECC signature using EdDSA.
The identity of the host (wraps the signing key of the peer).

References GNUNET_TIME_Absolute::abs_value_us, dummy, GNUNET_asprintf(), GNUNET_break, 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 if (ntohs (msg->size) <=
642 sizeof (struct HelloUriMessage) + sizeof (struct BlockHeader))
643 {
644 GNUNET_break (0);
646 }
647
649 return et;
650 }
651 else if (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO == ntohs (msg->type))
652 {
653 const struct DhtHelloMessage *dht_hello
654 = (const struct DhtHelloMessage *) msg;
655 if (ntohs (msg->size) < sizeof (struct DhtHelloMessage))
656 {
657 GNUNET_break (0);
659 }
660
662 return et;
663 }
664 else
665 GNUNET_break (0);
667}
#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, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

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

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

◆ GNUNET_HELLO_parser_to_env()

struct GNUNET_MQ_Envelope * GNUNET_HELLO_parser_to_env ( const struct GNUNET_HELLO_Parser parser)

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

Parameters
builderbuilder to serialize
Returns
HELLO message matching parser

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

951{
952 struct GNUNET_MQ_Envelope *env;
953 struct HelloUriMessage *msg;
954 size_t blen;
955
956 if (parser->a_length > UINT16_MAX)
957 {
958 GNUNET_break (0);
959 return NULL;
960 }
961 blen = 0;
964 NULL,
965 &blen));
967 blen,
969 msg->url_counter = htons ((uint16_t) parser->a_length);
972 &msg[1],
973 &blen));
974 return env;
975}
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:907
#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 850 of file hello-uri.c.

851{
852 char *result;
853 char *pids;
854 char *sigs;
855 const char *sep = "?";
856
858 sizeof (parser->pid));
860 sizeof (parser->sig));
862 "gnunet://hello/%s/%s/%" PRIu64,
863 pids,
864 sigs,
865 parser->et.abs_value_us);
866 GNUNET_free (sigs);
867 GNUNET_free (pids);
868 for (struct Address *a = parser->a_head;
869 NULL != a;
870 a = a->next)
871 {
872 char *eou_url_encoded;
873 char *tmp;
874 int pfx_len;
875 const char *eou;
876
877 eou = strstr (a->uri,
878 "://");
879 if (NULL == eou)
880 {
881 GNUNET_break (0);
883 return NULL;
884 }
885 pfx_len = eou - a->uri;
886 eou += 3;
887 GNUNET_STRINGS_urlencode (a->uri_len - 4 - pfx_len,
888 eou,
889 &eou_url_encoded);
890 GNUNET_asprintf (&tmp,
891 "%s%s%.*s=%s",
892 result,
893 sep,
894 pfx_len,
895 a->uri,
896 eou_url_encoded);
897 GNUNET_free (eou_url_encoded);
899 result = tmp;
900 sep = "&";
901 }
902 return result;
903}
static int result
Global testing status.
size_t GNUNET_STRINGS_urlencode(size_t len, const char data[static len], char **out)
url/percent encode (RFC3986).
Definition strings.c:1893
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition strings.c:818

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

910{
911 struct BlockHeader bh;
912 size_t needed = sizeof (bh);
913 char *pos;
914
915 for (struct Address *a = parser->a_head;
916 NULL != a;
917 a = a->next)
918 {
919 GNUNET_assert (needed + a->uri_len > needed);
920 needed += a->uri_len;
921 }
922 if ( (NULL == block) ||
923 (needed > *block_size) )
924 {
925 *block_size = needed;
926 return GNUNET_NO;
927 }
928 bh.pid = parser->pid;
929 bh.sig = parser->sig;
930 bh.expiration_time = GNUNET_TIME_absolute_hton (parser->et);
931 memcpy (block,
932 &bh,
933 sizeof (bh));
934 pos = block + sizeof (bh);
935 for (struct Address *a = parser->a_head;
936 NULL != a;
937 a = a->next)
938 {
939 memcpy (pos,
940 a->uri,
941 a->uri_len);
942 pos += a->uri_len;
943 }
944 *block_size = needed;
945 return GNUNET_OK;
946}
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 671 of file hello-uri.c.

673{
674 struct Address *a;
676 size_t alen = strlen (address) + 1;
677
679 if (GNUNET_OK != ret)
680 {
682 "Failed to add address to builder\n");
683 return ret;
684 }
685 /* check for duplicates */
686 for (a = builder->a_head;
687 NULL != a;
688 a = a->next)
689 if (0 == strcmp (address,
690 a->uri))
691 return GNUNET_NO;
692 a = GNUNET_malloc (sizeof (struct Address) + alen);
693 a->uri_len = alen;
694 memcpy (&a[1],
695 address,
696 alen);
697 a->uri = (const char *) &a[1];
700 NULL,
701 builder->a_head,
702 builder->a_tail,
703 a);
704 builder->a_length++;
705 return GNUNET_OK;
706}
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 979 of file hello-uri.c.

981{
982 struct Address *a;
983
984 /* check for duplicates */
985 for (a = builder->a_head;
986 NULL != a;
987 a = a->next)
988 if (0 == strcmp (address,
989 a->uri))
990 break;
991 if (NULL == a)
992 return GNUNET_NO;
994 builder->a_tail,
995 a);
996 builder->a_length--;
997 GNUNET_free (a);
998 return GNUNET_OK;
999}

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

1006{
1007 struct Address *nxt;
1008
1009 for (struct Address *a = builder->a_head;
1010 NULL != a;
1011 a = nxt)
1012 {
1013 nxt = a->next;
1014 uc (uc_cls,
1015 NULL,
1016 a->uri);
1017 }
1018}
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 1022 of file hello-uri.c.

1025{
1026 struct Address *nxt;
1027
1028 if (NULL == uc)
1029 return &parser->pid;
1030 for (struct Address *a = parser->a_head;
1031 NULL != a;
1032 a = nxt)
1033 {
1034 nxt = a->next;
1035 uc (uc_cls,
1036 &parser->pid,
1037 a->uri);
1038 }
1039 return &parser->pid;
1040}

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

1049{
1050 const struct DhtHelloMessage *msg
1051 = (const struct DhtHelloMessage *) hello;
1052 uint16_t len = ntohs (hello->size);
1053 struct BlockHeader *bh;
1054 struct GNUNET_HELLO_Parser *b;
1056
1057 if (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO != ntohs (hello->type))
1058 {
1059 GNUNET_break (0);
1060 return GNUNET_SYSERR;
1061 }
1062 if (len < sizeof (*msg))
1063 {
1064 GNUNET_break_op (0);
1065 return GNUNET_SYSERR;
1066 }
1067 len -= sizeof (*msg);
1068 *block_size = len + sizeof (*bh);
1069 *block = GNUNET_malloc (*block_size);
1070 bh = *block;
1071 bh->pid = *pid;
1072 bh->sig = msg->sig;
1073 bh->expiration_time = msg->expiration_time;
1074 *block_expiration = GNUNET_TIME_absolute_ntoh (msg->expiration_time);
1075 memcpy (&bh[1],
1076 &msg[1],
1077 len);
1079 *block_size);
1080 if (NULL == b)
1081 {
1082 GNUNET_break_op (0);
1083 GNUNET_free (*block);
1084 *block_size = 0;
1085 return GNUNET_SYSERR;
1086 }
1087 ret = verify_hello (b,
1088 *block_expiration,
1089 &msg->sig);
1091 if (GNUNET_SYSERR == ret)
1092 {
1093 GNUNET_free (*block);
1094 *block_size = 0;
1095 return GNUNET_SYSERR;
1096 }
1097 return ret;
1098}

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

1110{
1111 const char *dash;
1112
1113 dash = strchr (address, '-');
1114 if (NULL == dash)
1115 return NULL;
1116 return GNUNET_strndup (address, dash - address);
1117}
#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 1121 of file hello-uri.c.

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

1262{
1263 struct BlockHeader *block;
1264 struct DhtHelloMessage *msg;
1265 size_t block_size;
1266
1267
1269 msg = GNUNET_malloc (sizeof (*msg)
1270 + block_size);
1271 block = (struct BlockHeader*) &msg[1];
1273 pid,
1274 hello_sig,
1276 (char*) &msg[1]);
1277 msg->sig = block->sig;
1278 msg->expiration_time = block->expiration_time;
1279 memmove (&msg[1],
1280 (char*) block + sizeof (*block),
1281 block_size - sizeof (*block));
1282 msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO);
1283 msg->header.size = htons (sizeof (*msg)
1284 + block_size
1285 - sizeof (*block));
1286 msg->url_counter = htons ((uint16_t) builder->a_length);
1287 return &msg->header;
1288}
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:1292
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:1360

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

1220{
1221 struct BlockHeader *block;
1222 struct DhtHelloMessage *msg;
1223 size_t block_size;
1224
1225
1226 block_size = 0;
1229 NULL,
1230 &block_size));
1231 msg = GNUNET_malloc (sizeof (*msg)
1232 + block_size);
1233 if (GNUNET_OK !=
1235 &msg[1],
1236 &block_size))
1237 {
1238 GNUNET_free (msg);
1239 return NULL;
1240 }
1241 block = (struct BlockHeader*) &msg[1];
1242 msg->sig = block->sig;
1243 msg->expiration_time = block->expiration_time;
1244 memmove (&msg[1],
1245 (char*) block + sizeof (*block),
1246 block_size - sizeof (*block));
1247 msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO);
1248 msg->header.size = htons (sizeof (*msg)
1249 + block_size
1250 - sizeof (*block));
1251 msg->url_counter = htons ((uint16_t) parser->a_length);
1252 return &msg->header;
1253}

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

Referenced by pid_change_cb(), and sign_hello_cb().

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

◆ GNUNET_HELLO_builder_to_block()

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

Generate DHT block from a builder.

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

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

1298{
1299 struct BlockHeader bh = { 0 };
1300 char *pos;
1301 struct GNUNET_TIME_Absolute et;
1302
1303 if (NULL != pid)
1304 bh.pid = *pid;
1305 if (NULL != sig)
1306 bh.sig = *sig;
1307 if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == expiration_time.abs_value_us)
1309 else
1310 et = expiration_time;
1312 memcpy (block,
1313 &bh,
1314 sizeof (bh));
1315 pos = block + sizeof (bh);
1316 for (struct Address *a = builder->a_head; NULL != a; a = a->next)
1317 {
1318 memcpy (pos,
1319 a->uri,
1320 a->uri_len);
1321 pos += a->uri_len;
1322 }
1323}
#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 1181 of file hello-uri.c.

1183{
1184 hash_addresses (builder->a_head, hash);
1185}
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 1189 of file hello-uri.c.

1194{
1195 struct GNUNET_MQ_Envelope *env;
1196 struct HelloUriMessage *msg;
1197 size_t blen;
1198
1199 if (builder->a_length > UINT16_MAX)
1200 {
1201 GNUNET_break (0);
1202 return NULL;
1203 }
1206 blen,
1208 msg->url_counter = htons ((uint16_t) builder->a_length);
1210 pid,
1211 hello_sig,
1212 expiration_time,
1213 (char*) &msg[1]);
1214 return env;
1215}

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

1362{
1363 struct BlockHeader bh;
1364 size_t needed = sizeof (bh);
1365
1366 for (struct Address *a = builder->a_head;
1367 NULL != a;
1368 a = a->next)
1369 {
1370 GNUNET_assert (needed + a->uri_len > needed);
1371 needed += a->uri_len;
1372 }
1373 return needed;
1374}

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

1346{
1347 struct GNUNET_TIME_Absolute et;
1348
1350
1352 pid,
1353 sig,
1354 et,
1355 result);
1356}
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:1327

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

1332{
1334 pid,
1335 sig,
1336 validity,
1337 result);
1338}
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:1121

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

1382{
1383 bool found = false;
1384 for (struct Address *a = abuilder->a_head; NULL != a; a = a->next)
1385 {
1386 for (struct Address *b = bbuilder->a_head; NULL != b; b = b->next)
1387 {
1388 if (0 != strcmp (b->uri, a->uri))
1389 continue;
1390 found = true;
1391 break;
1392 }
1393 if (! found)
1394 return GNUNET_NO;
1395 found = false;
1396 }
1397 return GNUNET_YES;
1398}
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: