GNUnet 0.22.2
Hello_Uri library

Helper library for handling HELLO URIs. More...

Collaboration diagram for Hello_Uri library:

Macros

#define GNUNET_HELLO_ADDRESS_EXPIRATION
 For how long are HELLO signatures valid? More...
 

Typedefs

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

Functions

struct GNUNET_HELLO_BuilderGNUNET_HELLO_builder_new (const struct GNUNET_PeerIdentity *pid)
 Allocate builder. More...
 
struct GNUNET_HELLO_BuilderGNUNET_HELLO_builder_from_parser (const struct GNUNET_HELLO_Parser *parser)
 Allocate builder from parser. More...
 
const struct GNUNET_PeerIdentityGNUNET_HELLO_parser_get_id (const struct GNUNET_HELLO_Parser *parser)
 Get the PeerIdentity for this builder. More...
 
void GNUNET_HELLO_builder_free (struct GNUNET_HELLO_Builder *builder)
 Release resources of a builder. More...
 
void GNUNET_HELLO_parser_free (struct GNUNET_HELLO_Parser *parser)
 Release resources of a builder. More...
 
struct GNUNET_HELLO_ParserGNUNET_HELLO_parser_from_msg (const struct GNUNET_MessageHeader *msg)
 Parse msg. More...
 
struct GNUNET_HELLO_ParserGNUNET_HELLO_parser_from_block (const void *block, size_t block_size)
 Parse block. More...
 
struct GNUNET_HELLO_ParserGNUNET_HELLO_parser_from_url (const char *url)
 Parse GNUnet HELLO url. More...
 
struct GNUNET_TIME_Absolute GNUNET_HELLO_get_expiration_time_from_msg (const struct GNUNET_MessageHeader *msg)
 Get the expiration time for this HELLO. More...
 
struct GNUNET_MQ_EnvelopeGNUNET_HELLO_builder_to_env (const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_TIME_Relative expiration_time)
 Generate envelope with GNUnet HELLO message (including peer ID) from a builder. More...
 
struct GNUNET_MQ_EnvelopeGNUNET_HELLO_parser_to_env (const struct GNUNET_HELLO_Parser *parser)
 Generate envelope with GNUnet HELLO message (including peer ID) from a parser. More...
 
struct GNUNET_MessageHeaderGNUNET_HELLO_builder_to_dht_hello_msg (const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_TIME_Relative expiration_time)
 Generate DHT HELLO message (without peer ID) from a builder. More...
 
char * GNUNET_HELLO_parser_to_url (const struct GNUNET_HELLO_Parser *parser)
 Generate GNUnet HELLO URI from a parser. More...
 
char * GNUNET_HELLO_builder_to_url (const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
 Generate GNUnet HELLO URI from a builder. More...
 
char * GNUNET_HELLO_builder_to_url2 (const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_TIME_Relative expiration_time)
 Generate GNUnet HELLO URI from a builder. More...
 
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_to_block (const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, void *block, size_t *block_size, struct GNUNET_TIME_Relative expiration_time)
 Generate DHT block from a builder. More...
 
enum GNUNET_GenericReturnValue GNUNET_HELLO_parser_to_block (const struct GNUNET_HELLO_Parser *parser, void *block, size_t *block_size)
 Generate DHT block from a parser. More...
 
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_add_address (struct GNUNET_HELLO_Builder *builder, const char *address)
 Add individual address to the builder. More...
 
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_del_address (struct GNUNET_HELLO_Builder *builder, const char *address)
 Remove individual address from the builder. More...
 
const struct GNUNET_PeerIdentityGNUNET_HELLO_parser_iterate (const struct GNUNET_HELLO_Parser *parser, GNUNET_HELLO_UriCallback uc, void *uc_cls)
 Iterate over URIs in a parser. More...
 
enum GNUNET_GenericReturnValue GNUNET_HELLO_dht_msg_to_block (const struct GNUNET_MessageHeader *hello, const struct GNUNET_PeerIdentity *pid, void **block, size_t *block_size, struct GNUNET_TIME_Absolute *block_expiration)
 Convert a DHT hello message to a HELLO block. More...
 
char * GNUNET_HELLO_address_to_prefix (const char *address)
 Given an address as a string, extract the prefix that identifies the communicator offering transmissions to that address. More...
 
void GNUNET_HELLO_sign_address (const char *address, enum GNUNET_NetworkType nt, struct GNUNET_TIME_Absolute mono_time, const struct GNUNET_CRYPTO_EddsaPrivateKey *private_key, void **result, size_t *result_size)
 Build address record by signing raw information with private key. More...
 

Detailed Description

Helper library for handling HELLO URIs.

Macro Definition Documentation

◆ GNUNET_HELLO_ADDRESS_EXPIRATION

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

For how long are HELLO signatures valid?

Definition at line 63 of file gnunet_hello_uri_lib.h.

Typedef Documentation

◆ GNUNET_HELLO_UriCallback

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

Callback function used to extract URIs from a builder.

Parameters
clsclosure
urione of the URIs

Definition at line 288 of file gnunet_hello_uri_lib.h.

Function Documentation

◆ GNUNET_HELLO_builder_new()

struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_new ( const struct GNUNET_PeerIdentity pid)

Allocate builder.

Parameters
pidpeer the builder is for
Returns
new builder

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

402{
404
406 builder->pid = *pid;
407 return builder;
408}
static struct HostSet * builder
NULL if we are not currently iterating over peer information.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Context for building (or parsing) HELLO URIs.
Definition: hello-uri.c:205

References builder, GNUNET_new, and pid.

Referenced by GCH_get_mine(), GNUNET_HELLO_builder_from_parser(), 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)

Allocate builder from parser.

Parameters
parserthe parser
Returns
new builder

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

420{
422 struct Address *a;
423
425 /* check for duplicates */
426 for (a = p->a_head;
427 NULL != a;
428 a = a->next)
430 return builder;
431}
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_new(const struct GNUNET_PeerIdentity *pid)
Allocate builder.
Definition: hello-uri.c:401
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:646
Address of a peer.
Definition: hello-uri.c:178
struct Address * next
Kept in a DLL.
Definition: hello-uri.c:182
const char * uri
Actual URI, allocated at the end of this struct.
Definition: hello-uri.c:192
pid_t pid
PID of the process.
Definition: os_priority.c:49

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

Referenced by got_hello(), and hello_iter().

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

413{
414 return &parser->pid;
415}

References consensus-simulation::parser.

Referenced by check_hello(), GNUNET_PEERSTORE_hello_add(), hello_iter(), and hosts_directory_scan_callback().

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

454{
455 struct Address *a;
456
457 while (NULL != (a = builder->a_head))
458 {
460 builder->a_tail,
461 a);
462 builder->a_length--;
463 GNUNET_free (a);
464 }
465 GNUNET_assert (0 == builder->a_length);
467}
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_free(ptr)
Wrapper around free.

References builder, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, and GNUNET_free.

Referenced by do_shutdown(), GCH_get_mine(), got_hello(), hello_iter(), and shutdown_task().

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

436{
437 struct Address *a;
438
439 while (NULL != (a = parser->a_head))
440 {
442 parser->a_tail,
443 a);
444 parser->a_length--;
445 GNUNET_free (a);
446 }
447 GNUNET_assert (0 == parser->a_length);
449}

References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, and consensus-simulation::parser.

Referenced by block_plugin_dht_check_block(), block_plugin_dht_check_reply(), block_plugin_dht_get_key(), build_json_response(), check_for_burst_address(), check_for_global_natted(), consider_for_advertising(), GNUNET_HELLO_dht_msg_to_block(), GNUNET_HELLO_parser_from_block(), GNUNET_HELLO_parser_from_url(), GNUNET_PEERSTORE_hello_add(), got_hello(), handle_dht_local_hello_offer(), handle_hello(), handle_hello_for_client(), handle_hello_for_incoming(), hello_check(), hello_iter(), hosts_directory_scan_callback(), peerinfo_cb(), and run().

Here is the caller graph for this function:

◆ GNUNET_HELLO_parser_from_msg()

struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_msg ( const struct GNUNET_MessageHeader msg)

Parse msg.

Parameters
msgmessage to parse
Returns
builder, NULL on failure

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

472{
473 const struct HelloUriMessage *h;
474 uint16_t size = ntohs (msg->size);
475
476 if (GNUNET_MESSAGE_TYPE_HELLO_URI != ntohs (msg->type))
477 {
478 GNUNET_break (0);
479 return NULL;
480 }
481 if (sizeof (struct HelloUriMessage) > size)
482 {
483 GNUNET_break_op (0);
484 return NULL;
485 }
486 h = (const struct HelloUriMessage *) msg;
487 size -= sizeof (*h);
489 size);
490}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:98
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_block(const void *block, size_t block_size)
Parse block.
Definition: hello-uri.c:559
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_MESSAGE_TYPE_HELLO_URI
Latest HELLO messages used for communicating peer addresses.
static unsigned int size
Size of the "table".
Definition: peer.c:68
Message used when gossiping HELLOs between peers.
Definition: hello-uri.c:93

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

Referenced by build_json_response(), check_for_burst_address(), check_for_global_natted(), check_hello(), consider_for_advertising(), GNUNET_PEERSTORE_hello_add(), got_hello(), handle_hello(), handle_hello_for_client(), handle_hello_for_incoming(), hello_iter(), hosts_directory_scan_callback(), and peerinfo_cb().

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

◆ GNUNET_HELLO_parser_from_block()

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

Parse block.

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

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

561{
562 const struct BlockHeader *bh = block;
563 struct GNUNET_HELLO_Parser *p;
564
565 if (block_size < sizeof (*bh))
566 {
567 GNUNET_break_op (0);
568 return NULL;
569 }
570 p = parser_new (&bh->pid);
571 block += sizeof (*bh);
572 block_size -= sizeof (*bh);
573 while (block_size > 0)
574 {
575 const void *end = memchr (block,
576 '\0',
577 block_size);
578
579 if (NULL == end)
580 {
581 GNUNET_break_op (0);
583 return NULL;
584 }
585 if (GNUNET_OK !=
587 block))
588 {
589 GNUNET_break_op (0);
591 return NULL;
592 }
593 end++;
594 block_size -= (end - block);
595 block = end;
596 }
597 {
599 struct GNUNET_TIME_Absolute et;
600
602 ret = verify_hello (p,
603 et,
604 &bh->sig);
606 if (GNUNET_OK != ret)
607 {
609 return NULL;
610 }
612 p->sig = bh->sig;
613 }
614 return p;
615}
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:435
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_OK
@ GNUNET_SYSERR
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:741
static enum GNUNET_GenericReturnValue verify_hello(const struct GNUNET_HELLO_Parser *parser, struct GNUNET_TIME_Absolute et, const struct GNUNET_CRYPTO_EddsaSignature *sig)
Verify HELLO signature.
Definition: hello-uri.c:362
static struct GNUNET_HELLO_Parser * parser_new(const struct GNUNET_PeerIdentity *pid)
Definition: hello-uri.c:390
static enum GNUNET_GenericReturnValue parser_add_address(struct GNUNET_HELLO_Parser *parser, const char *address)
Definition: hello-uri.c:523
Start of a 'block'.
Definition: hello-uri.c:117
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the HELLO expire?
Definition: hello-uri.c:131
struct GNUNET_CRYPTO_EddsaSignature sig
Signature over the block, of purpose GNUNET_SIGNATURE_PURPOSE_HELLO.
Definition: hello-uri.c:126
struct GNUNET_PeerIdentity pid
Public key of the peer.
Definition: hello-uri.c:121
Context for parsing HELLOs.
Definition: hello-uri.c:258
Time for absolute times used by GNUnet, in microseconds.

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

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(), and hello_check().

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

683{
684 const char *q;
685 const char *s1;
686 const char *s2;
688 struct GNUNET_TIME_Absolute et;
689 size_t len;
690 struct GNUNET_HELLO_Parser *p;
692
693 if (0 != strncasecmp (url,
694 "gnunet://hello/",
695 strlen ("gnunet://hello/")))
696 return NULL;
697 url += strlen ("gnunet://hello/");
698 s1 = strchr (url, '/');
699 if (NULL == s1)
700 {
701 GNUNET_break_op (0);
702 return NULL;
703 }
704 s2 = strchr (s1 + 1, '/');
705 if (NULL == s1)
706 {
707 GNUNET_break_op (0);
708 return NULL;
709 }
710 q = strchr (url, '?');
711 if (NULL == q)
712 q = url + strlen (url);
713 if (GNUNET_OK !=
715 s1 - url,
716 &pid,
717 sizeof(pid)))
718 {
719 GNUNET_break_op (0);
720 return NULL;
721 }
722 if (GNUNET_OK !=
724 s2 - (s1 + 1),
725 &sig,
726 sizeof(sig)))
727 {
728 GNUNET_break_op (0);
729 return NULL;
730 }
731 {
732 uint64_t sec;
733 char dummy = '?';
734
735 if ( (0 == sscanf (s2 + 1,
736 "%" PRIu64 "%c",
737 &sec,
738 &dummy)) ||
739 ('?' != dummy) )
740 {
741 GNUNET_break_op (0);
742 return NULL;
743 }
744 et.abs_value_us = sec;
745 }
746
747 p = parser_new (&pid);
748 p->et = et;
749 p->sig = sig;
750 len = strlen (q);
751 while (len > 0)
752 {
753 const char *eq;
754 const char *amp;
755 char *addr = NULL;
756 char *uri;
757
758 /* skip ?/& separator */
759 len--;
760 q++;
761 eq = strchr (q, '=');
762 if ( (eq == q) ||
763 (NULL == eq) )
764 {
765 GNUNET_break_op (0);
767 return NULL;
768 }
769 amp = strchr (eq, '&');
770 if (NULL == amp)
771 amp = &q[len];
773 amp - (eq + 1),
774 &addr);
775 if ( (NULL == addr) ||
776 (0 == strlen (addr)) )
777 {
778 GNUNET_free (addr);
779 GNUNET_break_op (0);
781 return NULL;
782 }
784 "%.*s://%s",
785 (int) (eq - q),
786 q,
787 addr);
788 GNUNET_free (addr);
789 if (GNUNET_OK !=
791 uri))
792 {
793 GNUNET_break_op (0);
796 return NULL;
797 }
799 /* move to next URL */
800 len -= (amp - q);
801 q = amp;
802 }
803
804 {
806
807 ret = verify_hello (p,
808 et,
809 &p->sig);
811 if (GNUNET_OK != ret)
812 {
814 return NULL;
815 }
816 }
817 return p;
818}
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:1808
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:812
an ECC signature using EdDSA.
The identity of the host (wraps the signing key of the peer).

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

Referenced by handle_dht_local_hello_offer(), and run().

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

◆ GNUNET_HELLO_get_expiration_time_from_msg()

struct GNUNET_TIME_Absolute GNUNET_HELLO_get_expiration_time_from_msg ( const struct GNUNET_MessageHeader msg)

Get the expiration time for this HELLO.

Parameters
msgThe hello msg.
Returns
The expiration time.

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

621{
622 struct GNUNET_TIME_Absolute et;
623 if (GNUNET_MESSAGE_TYPE_HELLO_URI == ntohs (msg->type))
624 {
625 const struct HelloUriMessage *h = (const struct HelloUriMessage *) msg;
626 const struct BlockHeader *bh = (const struct BlockHeader *) &h[1];
627
629 return et;
630 }
631 else if (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO == ntohs (msg->type))
632 {
633 const struct DhtHelloMessage *dht_hello
634 = (const struct DhtHelloMessage *) msg;
635
637 return et;
638 }
639 else
640 GNUNET_break (0);
642}
#define GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO
HELLO advertising a neighbours addresses.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
Message used when a DHT provides its HELLO to direct neighbours.
Definition: hello-uri.c:141
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the HELLO expire?
Definition: hello-uri.c:165

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

struct GNUNET_MQ_Envelope * GNUNET_HELLO_builder_to_env ( const struct GNUNET_HELLO_Builder builder,
const struct GNUNET_CRYPTO_EddsaPrivateKey priv,
struct GNUNET_TIME_Relative  expiration_time 
)

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

Parameters
builderbuilder to serialize
privprivate key to use to sign the result
Returns
HELLO message matching builder

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

1171{
1172 return GNUNET_HELLO_builder_to_env_ (builder, priv, expiration_time, NULL);
1173}
static struct GNUNET_MQ_Envelope * GNUNET_HELLO_builder_to_env_(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_TIME_Relative expiration_time, const struct GNUNET_CRYPTO_EddsaSignature *sig)
Definition: hello-uri.c:1132

References builder, and GNUNET_HELLO_builder_to_env_().

Referenced by hello_iter(), and store_pi().

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

1104{
1105 struct GNUNET_MQ_Envelope *env;
1106 struct HelloUriMessage *msg;
1107 size_t blen;
1108
1109 if (parser->a_length > UINT16_MAX)
1110 {
1111 GNUNET_break (0);
1112 return NULL;
1113 }
1114 blen = 0;
1117 NULL,
1118 &blen));
1120 blen,
1122 msg->url_counter = htons ((uint16_t) parser->a_length);
1125 &msg[1],
1126 &blen));
1127 return env;
1128}
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:1060
@ GNUNET_NO
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:61

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

Referenced by run().

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_CRYPTO_EddsaPrivateKey priv,
struct GNUNET_TIME_Relative  expiration_time 
)

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

Parameters
builderbuilder to serialize
privprivate key to use to sign the result
Returns
HELLO message matching builder

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

826{
827 struct DhtHelloMessage *msg;
828 size_t blen;
829
830 if (builder->a_length > UINT16_MAX)
831 {
832 GNUNET_break (0);
833 return NULL;
834 }
835 blen = 0;
838 priv,
839 NULL,
840 &blen,
842 GNUNET_assert (blen < UINT16_MAX);
843 GNUNET_assert (blen >= sizeof (struct BlockHeader));
844 {
845 char buf[blen] GNUNET_ALIGN;
846 const struct BlockHeader *block = (const struct BlockHeader *) buf;
847
850 priv,
851 buf,
852 &blen,
854 msg = GNUNET_malloc (sizeof (*msg)
855 + blen
856 - sizeof (*block));
858 msg->header.size = htons (sizeof (*msg)
859 + blen
860 - sizeof (*block));
861 memcpy (&msg[1],
862 &block[1],
863 blen - sizeof (*block));
864 msg->sig = block->sig;
865 msg->expiration_time = block->expiration_time;
866 }
867 msg->url_counter = htons ((uint16_t) builder->a_length);
868 return &msg->header;
869}
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_to_block(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, void *block, size_t *block_size, struct GNUNET_TIME_Relative expiration_time)
Generate DHT block from a builder.
Definition: hello-uri.c:1006
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's.
#define GNUNET_malloc(size)
Wrapper around malloc.

References builder, BlockHeader::expiration_time, DhtHelloMessage::expiration_time, GNUNET_ALIGN, GNUNET_assert, GNUNET_break, GNUNET_HELLO_builder_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 broadcast_hello(), GCH_get_mine(), and got_hello().

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

941{
942 char *result;
943 char *pids;
944 char *sigs;
945 const char *sep = "?";
946
948 sizeof (parser->pid));
950 sizeof (parser->sig));
952 "gnunet://hello/%s/%s/%" PRIu64,
953 pids,
954 sigs,
955 parser->et.abs_value_us);
956 GNUNET_free (sigs);
957 GNUNET_free (pids);
958 for (struct Address *a = parser->a_head;
959 NULL != a;
960 a = a->next)
961 {
962 char *ue;
963 char *tmp;
964 int pfx_len;
965 const char *eou;
966
967 eou = strstr (a->uri,
968 "://");
969 if (NULL == eou)
970 {
971 GNUNET_break (0);
973 return NULL;
974 }
975 pfx_len = eou - a->uri;
976 eou += 3;
977 GNUNET_STRINGS_urlencode (a->uri_len - 4 - pfx_len,
978 eou,
979 &ue);
980 GNUNET_asprintf (&tmp,
981 "%s%s%.*s=%s",
982 result,
983 sep,
984 pfx_len,
985 a->uri,
986 ue);
987 GNUNET_free (ue);
989 result = tmp;
990 sep = "&";
991 }
992 return result;
993}
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:1863
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:787

References GNUNET_asprintf(), GNUNET_break, GNUNET_free, GNUNET_STRINGS_data_to_string_alloc(), GNUNET_STRINGS_urlencode(), consensus-simulation::parser, and result.

Referenced by build_json_response().

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

◆ GNUNET_HELLO_builder_to_url()

char * GNUNET_HELLO_builder_to_url ( const struct GNUNET_HELLO_Builder builder,
const struct GNUNET_CRYPTO_EddsaPrivateKey priv 
)

Generate GNUnet HELLO URI from a builder.

Parameters
builderbuilder to serialize
privprivate key to use to sign the result
Returns
hello URI

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

999{
1002}
#define GNUNET_HELLO_ADDRESS_EXPIRATION
For how long are HELLO signatures valid?
char * GNUNET_HELLO_builder_to_url2(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_TIME_Relative validity)
Generate GNUnet HELLO URI from a builder.
Definition: hello-uri.c:873

References builder, GNUNET_HELLO_ADDRESS_EXPIRATION, and GNUNET_HELLO_builder_to_url2().

Referenced by handle_dht_local_hello_get(), and hello_iter().

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

◆ GNUNET_HELLO_builder_to_url2()

char * GNUNET_HELLO_builder_to_url2 ( const struct GNUNET_HELLO_Builder builder,
const struct GNUNET_CRYPTO_EddsaPrivateKey priv,
struct GNUNET_TIME_Relative  expiration_time 
)

Generate GNUnet HELLO URI from a builder.

Parameters
builderbuilder to serialize
privprivate key to use to sign the result
expiration_timethe expiration time to use.
Returns
hello URI

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

876{
878 struct GNUNET_TIME_Absolute et;
879 char *result;
880 char *pids;
881 char *sigs;
882 const char *sep = "?";
883
884 et = GNUNET_TIME_relative_to_absolute (validity);
885 GNUNET_assert (NULL != priv);
887 et,
888 priv,
889 &sig);
891 sizeof (builder->pid));
893 sizeof (sig));
895 "gnunet://hello/%s/%s/%" PRIu64,
896 pids,
897 sigs,
898 et.abs_value_us);
899 GNUNET_free (sigs);
900 GNUNET_free (pids);
901 for (struct Address *a = builder->a_head;
902 NULL != a;
903 a = a->next)
904 {
905 char *ue;
906 char *tmp;
907 int pfx_len;
908 const char *eou;
909
910 eou = strstr (a->uri,
911 "://");
912 if (NULL == eou)
913 {
914 GNUNET_break (0);
916 return NULL;
917 }
918 pfx_len = eou - a->uri;
919 eou += 3;
920 GNUNET_STRINGS_urlencode (a->uri_len - 4 - pfx_len,
921 eou,
922 &ue);
923 GNUNET_asprintf (&tmp,
924 "%s%s%.*s=%s",
925 result,
926 sep,
927 pfx_len,
928 a->uri,
929 ue);
930 GNUNET_free (ue);
932 result = tmp;
933 sep = "&";
934 }
935 return result;
936}
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
static void sign_hello(const struct GNUNET_HELLO_Builder *builder, struct GNUNET_TIME_Absolute et, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaSignature *sig)
Create HELLO signature.
Definition: hello-uri.c:330

References GNUNET_TIME_Absolute::abs_value_us, builder, GNUNET_asprintf(), GNUNET_assert, GNUNET_break, GNUNET_free, GNUNET_STRINGS_data_to_string_alloc(), GNUNET_STRINGS_urlencode(), GNUNET_TIME_relative_to_absolute(), result, and sign_hello().

Referenced by GNUNET_HELLO_builder_to_url(), and hello_iter().

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

◆ GNUNET_HELLO_builder_to_block()

enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_to_block ( const struct GNUNET_HELLO_Builder builder,
const struct GNUNET_CRYPTO_EddsaPrivateKey priv,
void *  block,
size_t *  block_size,
struct GNUNET_TIME_Relative  expiration_time 
)

Generate DHT block from a builder.

Parameters
builderthe builder to serialize
privprivate key to use to sign the result
[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 1006 of file hello-uri.c.

1011{
1012 struct BlockHeader bh;
1013 size_t needed = sizeof (bh);
1014 char *pos;
1015 struct GNUNET_TIME_Absolute et;
1016
1017 GNUNET_assert (NULL != priv);
1018 for (struct Address *a = builder->a_head;
1019 NULL != a;
1020 a = a->next)
1021 {
1022 GNUNET_assert (needed + a->uri_len > needed);
1023 needed += a->uri_len;
1024 }
1025 if ( (NULL == block) ||
1026 (needed < *block_size) )
1027 {
1028 *block_size = needed;
1029 return GNUNET_NO;
1030 }
1031 bh.pid = builder->pid;
1032 if (GNUNET_TIME_UNIT_ZERO.rel_value_us == expiration_time.rel_value_us)
1034 else
1035 et = GNUNET_TIME_relative_to_absolute (expiration_time);
1036 bh.expiration_time = GNUNET_TIME_absolute_hton (et);
1038 et,
1039 priv,
1040 &bh.sig);
1041 memcpy (block,
1042 &bh,
1043 sizeof (bh));
1044 pos = block + sizeof (bh);
1045 for (struct Address *a = builder->a_head;
1046 NULL != a;
1047 a = a->next)
1048 {
1049 memcpy (pos,
1050 a->uri,
1051 a->uri_len);
1052 pos += a->uri_len;
1053 }
1054 *block_size = needed;
1055 return GNUNET_OK;
1056}
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:640
uint64_t rel_value_us
The actual value.

References builder, BlockHeader::expiration_time, GNUNET_assert, GNUNET_HELLO_ADDRESS_EXPIRATION, GNUNET_NO, GNUNET_OK, GNUNET_TIME_absolute_hton(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_ZERO, BlockHeader::pid, GNUNET_TIME_Relative::rel_value_us, BlockHeader::sig, and sign_hello().

Referenced by GNUNET_HELLO_builder_to_dht_hello_msg(), GNUNET_HELLO_builder_to_env_(), and handle_find_my_hello().

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

1063{
1064 struct BlockHeader bh;
1065 size_t needed = sizeof (bh);
1066 char *pos;
1067
1068 for (struct Address *a = parser->a_head;
1069 NULL != a;
1070 a = a->next)
1071 {
1072 GNUNET_assert (needed + a->uri_len > needed);
1073 needed += a->uri_len;
1074 }
1075 if ( (NULL == block) ||
1076 (needed < *block_size) )
1077 {
1078 *block_size = needed;
1079 return GNUNET_NO;
1080 }
1081 bh.pid = parser->pid;
1082 bh.sig = parser->sig;
1083 bh.expiration_time = GNUNET_TIME_absolute_hton (parser->et);
1084 memcpy (block,
1085 &bh,
1086 sizeof (bh));
1087 pos = block + sizeof (bh);
1088 for (struct Address *a = parser->a_head;
1089 NULL != a;
1090 a = a->next)
1091 {
1092 memcpy (pos,
1093 a->uri,
1094 a->uri_len);
1095 pos += a->uri_len;
1096 }
1097 *block_size = needed;
1098 return GNUNET_OK;
1099}

References BlockHeader::expiration_time, GNUNET_assert, GNUNET_NO, GNUNET_OK, GNUNET_TIME_absolute_hton(), consensus-simulation::parser, BlockHeader::pid, and BlockHeader::sig.

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

648{
649 struct Address *a;
651 size_t alen = strlen (address) + 1;
652
654 if (GNUNET_OK != ret)
655 {
657 "Failed to add address to builder\n");
658 return ret;
659 }
660 /* check for duplicates */
661 for (a = builder->a_head;
662 NULL != a;
663 a = a->next)
664 if (0 == strcmp (address,
665 a->uri))
666 return GNUNET_NO;
667 a = GNUNET_malloc (sizeof (struct Address) + alen);
668 a->uri_len = alen;
669 memcpy (&a[1],
670 address,
671 alen);
672 a->uri = (const char *) &a[1];
674 builder->a_tail,
675 a);
676 builder->a_length++;
677 return GNUNET_OK;
678}
static char * address
GNS address for this phone.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG
static enum GNUNET_GenericReturnValue check_address(const char *address)
Definition: hello-uri.c:494
size_t uri_len
Length of uri including 0-terminator.
Definition: hello-uri.c:197

References address, builder, check_address(), GNUNET_CONTAINER_DLL_insert_tail, 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(), store_pi(), and u_address_add().

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

1179{
1180 struct Address *a;
1181
1182 /* check for duplicates */
1183 for (a = builder->a_head;
1184 NULL != a;
1185 a = a->next)
1186 if (0 == strcmp (address,
1187 a->uri))
1188 break;
1189 if (NULL == a)
1190 return GNUNET_NO;
1192 builder->a_tail,
1193 a);
1194 builder->a_length--;
1195 GNUNET_free (a);
1196 return GNUNET_OK;
1197}

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

Referenced by u_address_del().

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

1204{
1205 struct Address *nxt;
1206
1207 if (NULL == uc)
1208 return &parser->pid;
1209 for (struct Address *a = parser->a_head;
1210 NULL != a;
1211 a = nxt)
1212 {
1213 nxt = a->next;
1214 uc (uc_cls,
1215 &parser->pid,
1216 a->uri);
1217 }
1218 return &parser->pid;
1219}
static struct GNUNET_FS_UnindexContext * uc

References Address::next, consensus-simulation::parser, and uc.

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

Here is the caller graph for this function:

◆ GNUNET_HELLO_dht_msg_to_block()

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

Convert a DHT hello message to a HELLO block.

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

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

1228{
1229 const struct DhtHelloMessage *msg
1230 = (const struct DhtHelloMessage *) hello;
1231 uint16_t len = ntohs (hello->size);
1232 struct BlockHeader *bh;
1233 struct GNUNET_HELLO_Parser *b;
1235
1236 if (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO != ntohs (hello->type))
1237 {
1238 GNUNET_break (0);
1239 return GNUNET_SYSERR;
1240 }
1241 if (len < sizeof (*msg))
1242 {
1243 GNUNET_break_op (0);
1244 return GNUNET_SYSERR;
1245 }
1246 len -= sizeof (*msg);
1247 *block_size = len + sizeof (*bh);
1248 *block = GNUNET_malloc (*block_size);
1249 bh = *block;
1250 bh->pid = *pid;
1251 bh->sig = msg->sig;
1252 bh->expiration_time = msg->expiration_time;
1253 *block_expiration = GNUNET_TIME_absolute_ntoh (msg->expiration_time);
1254 memcpy (&bh[1],
1255 &msg[1],
1256 len);
1258 *block_size);
1259 if (NULL == b)
1260 {
1261 GNUNET_break_op (0);
1262 GNUNET_free (*block);
1263 *block_size = 0;
1264 return GNUNET_SYSERR;
1265 }
1266 ret = verify_hello (b,
1267 *block_expiration,
1268 &msg->sig);
1270 if (GNUNET_SYSERR == ret)
1271 {
1272 GNUNET_free (*block);
1273 *block_size = 0;
1274 return GNUNET_SYSERR;
1275 }
1276 return ret;
1277}

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

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

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

◆ GNUNET_HELLO_address_to_prefix()

char * GNUNET_HELLO_address_to_prefix ( const char *  address)

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

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

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

1289{
1290 const char *dash;
1291
1292 dash = strchr (address, '-');
1293 if (NULL == dash)
1294 return NULL;
1295 return GNUNET_strndup (address, dash - address);
1296}
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.

References address, and GNUNET_strndup.

Referenced by GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue(), store_pi(), and suggest_to_connect().

Here is the caller graph for this function:

◆ GNUNET_HELLO_sign_address()

void GNUNET_HELLO_sign_address ( const char *  address,
enum GNUNET_NetworkType  nt,
struct GNUNET_TIME_Absolute  mono_time,
const struct GNUNET_CRYPTO_EddsaPrivateKey private_key,
void **  result,
size_t *  result_size 
)

Build address record by signing raw information with private key.

Parameters
addresstext address to sign
ntnetwork type of address
mono_timewhen was address valid
private_keysigning key to use
[out]resultwhere to write address record (allocated)
[out]result_sizeset to size of result
addresstext address at communicator to sign
ntnetwork type of address
mono_timemonotonic time at which address was valid
private_keysigning key to use
[out]resultwhere to write address record (allocated)
[out]result_sizeset to size of result

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

1317{
1318 struct SignedAddress sa;
1320 char *sig_str;
1321
1322 sa.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS);
1323 sa.purpose.size = htonl (sizeof(sa));
1324 sa.mono_time = GNUNET_TIME_absolute_hton (mono_time);
1325 GNUNET_CRYPTO_hash (address, strlen (address), &sa.addr_hash);
1326 GNUNET_CRYPTO_eddsa_sign (private_key, &sa, &sig);
1327 sig_str = NULL;
1328 (void) GNUNET_STRINGS_base64_encode (&sig, sizeof(sig), &sig_str);
1329 *result_size =
1330 1 + GNUNET_asprintf ((char **) result,
1331 "%s;%llu;%u;%s",
1332 sig_str,
1333 (unsigned long long) mono_time.abs_value_us,
1334 (unsigned int) nt,
1335 address);
1336 GNUNET_free (sig_str);
1337}
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
#define GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS
Signature by a peer affirming that this is one of its addresses for the given time period.
#define GNUNET_CRYPTO_eddsa_sign(priv, ps, sig)
EdDSA sign a given block.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
size_t GNUNET_STRINGS_base64_encode(const void *in, size_t len, char **output)
Encode into Base64.
Definition: strings.c:1599
uint64_t abs_value_us
The actual value.
Binary block we sign when we sign an address.
Definition: hello-uri.c:50

References GNUNET_TIME_Absolute::abs_value_us, SignedAddress::addr_hash, address, GNUNET_asprintf(), GNUNET_CRYPTO_eddsa_sign, GNUNET_CRYPTO_hash(), GNUNET_free, GNUNET_SIGNATURE_PURPOSE_TRANSPORT_ADDRESS, GNUNET_STRINGS_base64_encode(), GNUNET_TIME_absolute_hton(), SignedAddress::mono_time, nt, GNUNET_CRYPTO_EccSignaturePurpose::purpose, SignedAddress::purpose, result, and GNUNET_CRYPTO_EccSignaturePurpose::size.

Referenced by store_pi().

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