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... | |
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 233 of file gnunet_hello_uri_lib.h.
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_new | ( | ) |
Allocate builder.
Definition at line 343 of file hello-uri.c.
References builder, and GNUNET_new.
Referenced by do_generate_pid(), GNUNET_HELLO_builder_from_parser(), pils_pid_change_cb(), and run().
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_from_parser | ( | const struct GNUNET_HELLO_Parser * | parser, |
struct GNUNET_PeerIdentity * | pid | ||
) |
Allocate builder from parser.
parser | the parser |
pid | the peer identity from the parsed hello |
Definition at line 360 of file hello-uri.c.
References builder, GNUNET_HELLO_builder_add_address(), GNUNET_HELLO_builder_new(), Address::next, p, GNUNET_OS_Process::pid, pid, and Address::uri.
Referenced by do_generate_pid(), pid_changed_cb(), and pils_pid_change_cb().
const struct GNUNET_PeerIdentity * GNUNET_HELLO_parser_get_id | ( | const struct GNUNET_HELLO_Parser * | parser | ) |
Get the PeerIdentity for this builder.
Definition at line 353 of file hello-uri.c.
References warningfilter::parser.
Referenced by check_hello(), GNUNET_PEERSTORE_hello_add(), handle_hello_for_client(), hello_iter(), hosts_directory_scan_callback(), peer_id_change_cb(), pid_change_cb(), pils_id_change_cb(), and sign_hello_cb().
void GNUNET_HELLO_builder_free | ( | struct GNUNET_HELLO_Builder * | builder | ) |
Release resources of a builder.
[in] | builder | to free |
Definition at line 397 of file hello-uri.c.
References builder, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, and GNUNET_free.
Referenced by do_shutdown(), GCH_shutdown(), pid_changed_cb(), and pils_pid_change_cb().
void GNUNET_HELLO_parser_free | ( | struct GNUNET_HELLO_Parser * | parser | ) |
Release resources of a builder.
[in] | builder | to free |
Definition at line 379 of file hello-uri.c.
References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, and warningfilter::parser.
Referenced by block_plugin_dht_check_block(), block_plugin_dht_check_reply(), block_plugin_dht_get_key(), build_json_response(), check_for_burst_address(), check_for_global_natted(), consider_for_advertising(), GNUNET_HELLO_dht_msg_to_block(), GNUNET_HELLO_parser_from_block_(), GNUNET_HELLO_parser_from_url(), GNUNET_PEERSTORE_hello_add(), handle_dht_local_hello_get(), handle_dht_local_hello_offer(), handle_feed_addresses(), handle_hello(), handle_hello_for_client(), handle_hello_for_incoming(), handle_peer_id(), hello_check(), hello_iter(), hosts_directory_scan_callback(), peerinfo_cb(), and run().
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_msg | ( | const struct GNUNET_MessageHeader * | msg | ) |
Parse msg.
msg | message to parse |
Definition at line 415 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(), handle_dht_local_hello_get(), 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 523 of file hello-uri.c.
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().
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.
block | DHT block to parse |
block_size | number of bytes in block |
noverify | not verifying signature if GNUNET_YES |
Definition at line 533 of file hello-uri.c.
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().
struct GNUNET_HELLO_Parser * GNUNET_HELLO_parser_from_url | ( | const char * | url | ) |
Parse GNUnet HELLO url.
url | URL to parse |
Definition at line 663 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 597 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_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 903 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 warningfilter::parser.
Referenced by output_parser(), pils_pid_change_cb(), and run().
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 803 of file hello-uri.c.
References GNUNET_asprintf(), GNUNET_break, GNUNET_free, GNUNET_STRINGS_data_to_string_alloc(), GNUNET_STRINGS_urlencode(), warningfilter::parser, and result.
Referenced by build_json_response(), handle_dht_local_hello_get(), and output_parser().
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 860 of file hello-uri.c.
References BlockHeader::expiration_time, GNUNET_assert, GNUNET_NO, GNUNET_OK, GNUNET_TIME_absolute_hton(), warningfilter::parser, BlockHeader::pid, and BlockHeader::sig.
Referenced by GNUNET_HELLO_parser_to_dht_hello_msg(), and GNUNET_HELLO_parser_to_env().
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 624 of file hello-uri.c.
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().
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 932 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 handle_del_address().
void GNUNET_HELLO_builder_iterate | ( | const struct GNUNET_HELLO_Builder * | builder, |
GNUNET_HELLO_UriCallback | uc, | ||
void * | uc_cls | ||
) |
Iterate over URIs in a builder.
builder | builder to iterate over |
uc | callback invoked for each URI, can be NULL |
uc_cls | closure for addrgen |
Definition at line 956 of file hello-uri.c.
References builder, Address::next, and uc.
Referenced by do_generate_pid(), pils_pid_change_cb(), and run().
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 975 of file hello-uri.c.
References Address::next, warningfilter::parser, and uc.
Referenced by block_plugin_dht_check_block(), block_plugin_dht_check_reply(), block_plugin_dht_get_key(), check_for_burst_address(), check_for_global_natted(), consider_for_advertising(), handle_dht_local_hello_offer(), handle_hello_for_client(), handle_hello_for_incoming(), hello_check(), hello_iter(), and peerinfo_cb().
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 997 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 1062 of file hello-uri.c.
References address, and GNUNET_strndup.
Referenced by GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue(), handle_add_address(), store_pi(), and suggest_to_connect().
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 | ||
) |
builder | builder to serialize |
pid | peer identity |
sig | signature of the hello |
expiration_time | expiration time |
Definition at line 1074 of file hello-uri.c.
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().
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.
builder | builder to serialize |
pid | peer identity |
sig | signature of the hello |
expiration_time | expiration time |
Definition at line 1209 of file hello-uri.c.
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.
struct GNUNET_MessageHeader * GNUNET_HELLO_parser_to_dht_hello_msg | ( | const struct GNUNET_HELLO_Parser * | parser | ) |
Generate DHT HELLO message from a parser.
parser | builder to serialize |
Definition at line 1172 of file hello-uri.c.
References BlockHeader::expiration_time, GNUNET_assert, GNUNET_HELLO_parser_to_block(), GNUNET_malloc, GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO, GNUNET_NO, GNUNET_OK, msg, warningfilter::parser, BlockHeader::sig, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by pid_change_cb(), and sign_hello_cb().
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.
builder | builder to serialize |
pid | peer identity |
sig | signature of the hello |
expiration_time | expiration time |
outbuf | the buffer to the block |
Definition at line 1244 of file hello-uri.c.
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().
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
builder | the builder to hash addresses of | |
[out] | hash | where to write the hash |
Definition at line 1134 of file hello-uri.c.
References builder, and hash_addresses().
Referenced by do_generate_pid(), GNUNET_PILS_sign_hello(), and run().
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.
builder | builder to serialize |
pid | peer identity |
sig | signature of the hello |
expiration_time | expiration time |
Definition at line 1142 of file hello-uri.c.
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().
size_t GNUNET_HELLO_get_builder_to_block_size | ( | const struct GNUNET_HELLO_Builder * | builder | ) |
Get projected block size for builder.
builder | builder to serialize |
Definition at line 1312 of file hello-uri.c.
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().
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.
builder | builder to serialize |
pid | peer identity |
sig | signature of the hello |
Definition at line 1294 of file hello-uri.c.
References builder, GNUNET_HELLO_ADDRESS_EXPIRATION, GNUNET_HELLO_builder_to_url2(), GNUNET_TIME_relative_to_absolute(), pid, and result.
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.
builder | builder to serialize |
pid | peer identity |
sig | signature of the hello |
validity | relative validity target of hello |
Definition at line 1279 of file hello-uri.c.
References builder, GNUNET_HELLO_build_url(), pid, and result.
Referenced by GNUNET_HELLO_builder_to_url(), and url_resign_cb().
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!
abuilder | the first builder |
bbuilder | the second builder |
Definition at line 1330 of file hello-uri.c.
References GNUNET_HELLO_Builder::a_head, GNUNET_NO, GNUNET_YES, and Address::next.
Referenced by pils_pid_change_cb().