Helper library for handling HELLO URIs. More...
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_Builder * | GNUNET_HELLO_builder_new (const struct GNUNET_PeerIdentity *pid) |
Allocate builder. More... | |
struct GNUNET_HELLO_Builder * | GNUNET_HELLO_builder_from_parser (const struct GNUNET_HELLO_Parser *parser) |
Allocate builder from parser. More... | |
const struct GNUNET_PeerIdentity * | GNUNET_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_Parser * | GNUNET_HELLO_parser_from_msg (const struct GNUNET_MessageHeader *msg) |
Parse msg. More... | |
struct GNUNET_HELLO_Parser * | GNUNET_HELLO_parser_from_block (const void *block, size_t block_size) |
Parse block. More... | |
struct GNUNET_HELLO_Parser * | GNUNET_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_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. More... | |
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. More... | |
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. 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_PeerIdentity * | GNUNET_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... | |
Helper library for handling HELLO URIs.
#define GNUNET_HELLO_ADDRESS_EXPIRATION |
For how long are HELLO signatures valid?
Definition at line 63 of file gnunet_hello_uri_lib.h.
typedef void(* GNUNET_HELLO_UriCallback) (void *cls, const struct GNUNET_PeerIdentity *pid, const char *uri) |
Callback function used to extract URIs from a builder.
cls | closure |
uri | one of the URIs |
Definition at line 288 of file gnunet_hello_uri_lib.h.
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_new | ( | const struct GNUNET_PeerIdentity * | pid | ) |
Allocate builder.
pid | peer the builder is for |
Definition at line 401 of file hello-uri.c.
References builder, GNUNET_new, and pid.
Referenced by GCH_get_mine(), GNUNET_HELLO_builder_from_parser(), and run().
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_from_parser | ( | const struct GNUNET_HELLO_Parser * | parser | ) |
Allocate builder from parser.
parser | the parser |
Definition at line 419 of file hello-uri.c.
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().
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.
References consensus-simulation::parser.
Referenced by check_hello(), GNUNET_PEERSTORE_hello_add(), hello_iter(), and hosts_directory_scan_callback().
void GNUNET_HELLO_builder_free | ( | struct GNUNET_HELLO_Builder * | builder | ) |
Release resources of a builder.
[in] | builder | to free |
Definition at line 453 of file hello-uri.c.
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().
void GNUNET_HELLO_parser_free | ( | struct GNUNET_HELLO_Parser * | parser | ) |
Release resources of a builder.
[in] | builder | to free |
Definition at line 435 of file hello-uri.c.
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().
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_msg | ( | const struct GNUNET_MessageHeader * | msg | ) |
Parse msg.
msg | message to parse |
Definition at line 471 of file hello-uri.c.
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().
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_block | ( | const void * | block, |
size_t | block_size | ||
) |
Parse block.
block | DHT block to parse |
block_size | number of bytes in block |
Definition at line 559 of file hello-uri.c.
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().
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_url | ( | const char * | url | ) |
Parse GNUnet HELLO url.
url | URL to parse |
Definition at line 682 of file hello-uri.c.
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().
struct GNUNET_TIME_Absolute GNUNET_HELLO_get_expiration_time_from_msg | ( | const struct GNUNET_MessageHeader * | msg | ) |
Get the expiration time for this HELLO.
msg | The hello msg. |
Definition at line 619 of file hello-uri.c.
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().
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.
builder | builder to serialize |
priv | private key to use to sign the result |
Definition at line 1168 of file hello-uri.c.
References builder, and GNUNET_HELLO_builder_to_env_().
Referenced by hello_iter(), and store_pi().
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.
builder | builder to serialize |
Definition at line 1103 of file hello-uri.c.
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().
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.
builder | builder to serialize |
priv | private key to use to sign the result |
Definition at line 822 of file hello-uri.c.
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().
char * GNUNET_HELLO_parser_to_url | ( | const struct GNUNET_HELLO_Parser * | parser | ) |
Generate GNUnet HELLO URI from a parser.
parser | HELLO parser to serialize |
Definition at line 940 of file hello-uri.c.
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().
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.
builder | builder to serialize |
priv | private key to use to sign the result |
Definition at line 997 of file hello-uri.c.
References builder, GNUNET_HELLO_ADDRESS_EXPIRATION, and GNUNET_HELLO_builder_to_url2().
Referenced by handle_dht_local_hello_get(), and hello_iter().
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.
builder | builder to serialize |
priv | private key to use to sign the result |
expiration_time | the expiration time to use. |
Definition at line 873 of file hello-uri.c.
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().
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.
builder | the builder to serialize | |
priv | private key to use to sign the result | |
[out] | block | where to write the block, NULL to only calculate block_size |
[in,out] | block_size | input is number of bytes available in block, output is number of bytes needed in block |
Definition at line 1006 of file hello-uri.c.
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().
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.
builder | the builder to serialize | |
[out] | block | where to write the block, NULL to only calculate block_size |
[in,out] | block_size | input is number of bytes available in block, output is number of bytes needed in block |
Definition at line 1060 of file hello-uri.c.
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().
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_add_address | ( | struct GNUNET_HELLO_Builder * | builder, |
const char * | address | ||
) |
Add individual address to the builder.
[in,out] | builder | to update |
address | address URI to add |
Definition at line 646 of file hello-uri.c.
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().
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_del_address | ( | struct GNUNET_HELLO_Builder * | builder, |
const char * | address | ||
) |
Remove individual address from the builder.
[in,out] | builder | to update |
address | address URI to remove |
Definition at line 1177 of file hello-uri.c.
References address, builder, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NO, GNUNET_OK, Address::next, and Address::uri.
Referenced by u_address_del().
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.
builder | builder to iterate over |
uc | callback invoked for each URI, can be NULL |
uc_cls | closure for addrgen |
Definition at line 1201 of file hello-uri.c.
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().
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.
hello | the HELLO message | |
pid | peer that created the hello | |
[out] | block | set to the HELLO block |
[out] | block_size | set to number of bytes in block |
[out] | block_expiration | set to expiration time of block |
Definition at line 1223 of file hello-uri.c.
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().
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.
address | a peer's address |
Definition at line 1288 of file hello-uri.c.
References address, and GNUNET_strndup.
Referenced by GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue(), store_pi(), and suggest_to_connect().
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.
address | text address to sign | |
nt | network type of address | |
mono_time | when was address valid | |
private_key | signing key to use | |
[out] | result | where to write address record (allocated) |
[out] | result_size | set to size of result |
address | text address at communicator to sign | |
nt | network type of address | |
mono_time | monotonic time at which address was valid | |
private_key | signing key to use | |
[out] | result | where to write address record (allocated) |
[out] | result_size | set to size of result |
Definition at line 1310 of file hello-uri.c.
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().