Print information about other known peers. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_lib.h"
#include "gnunet_transport_service.h"
#include "gnunet_transport_hello_service.h"
#include "gnunet_peerinfo_service.h"
#include "gnunet-peerinfo_plugins.h"
Go to the source code of this file.
Data Structures | |
struct | AddressRecord |
Record we keep for each printable address. More... | |
struct | PrintContext |
Structure we use to collect printable address information. More... | |
Macros | |
#define | TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) |
How long until we time out during address lookup? More... | |
Functions | |
static void | state_machine (void *cls) |
Main state machine that goes over all options and runs the next requested function. More... | |
static void | dump_pc (struct PrintContext *pc) |
Print the collected address information to the console and free pc. More... | |
static void | process_resolved_address (void *cls, const char *address, int res) |
Function to call with a human-readable format of an address. More... | |
static int | count_address (void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration) |
Iterator callback to go over all addresses and count them. More... | |
static int | print_address (void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration) |
Iterator callback to go over all addresses. More... | |
static void | print_peer_info (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg) |
Print information about the peer. More... | |
static int | count_addr (void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration) |
Count the number of addresses in the HELLO. More... | |
static void | dump_my_hello () |
Write HELLO of my peer to a file. More... | |
static void | print_my_uri (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg) |
Print URI of the peer. More... | |
static void | add_continuation (void *cls) |
Continuation called from GNUNET_PEERINFO_add_peer() More... | |
static int | parse_hello_uri (const char *put_uri) |
Parse the PUT URI given at the command line and add it to our peerinfo database. More... | |
static void | shutdown_task (void *cls) |
Main state machine that goes over all options and runs the next requested function. More... | |
static void | hello_callback (void *cls, const struct GNUNET_MessageHeader *hello) |
Function called with our peer's HELLO message. More... | |
static void | run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) |
Main function that will be run by the scheduler. More... | |
int | main (int argc, char *const *argv) |
The main function to obtain peer information. More... | |
Variables | |
static int | no_resolve |
Option '-n'. More... | |
static int | be_quiet |
Option '-q'. More... | |
static int | include_friend_only |
Option '-f'. More... | |
static int | get_self |
Option '-s'. More... | |
static int | get_uri |
Option. More... | |
static int | default_operation |
Option. More... | |
static int | get_info |
Option '-i'. More... | |
static char * | put_uri |
Option. More... | |
static char * | dump_hello |
Option -d. More... | |
static struct GNUNET_PEERINFO_Handle * | peerinfo |
Handle to peerinfo service. More... | |
static const struct GNUNET_CONFIGURATION_Handle * | cfg |
Configuration handle. More... | |
static struct GNUNET_SCHEDULER_Task * | tt |
Main state machine task (if active). More... | |
static struct GNUNET_TRANSPORT_HelloGetHandle * | gh |
Pending GNUNET_TRANSPORT_hello_get() operation. More... | |
static struct GNUNET_PEERINFO_IteratorContext * | pic |
Current iterator context (if active, otherwise NULL). More... | |
static struct GNUNET_PeerIdentity | my_peer_identity |
My peer identity. More... | |
static struct PrintContext * | pc_head |
Head of list of print contexts. More... | |
static struct PrintContext * | pc_tail |
Tail of list of print contexts. More... | |
static struct GNUNET_MQ_Envelope * | ac |
Handle to current GNUNET_PEERINFO_add_peer() operation. More... | |
static struct GNUNET_HELLO_Message * | my_hello |
Hello of this peer (if initialized). More... | |
Print information about other known peers.
Definition in file gnunet-peerinfo.c.
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) |
How long until we time out during address lookup?
Definition at line 38 of file gnunet-peerinfo.c.
|
static |
Main state machine that goes over all options and runs the next requested function.
cls | unused |
Definition at line 728 of file gnunet-peerinfo.c.
References _, be_quiet, cfg, default_operation, get_info, get_self, get_uri, GNUNET_free, GNUNET_i2s_full(), GNUNET_NO, GNUNET_PEERINFO_iterate(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_shutdown(), GNUNET_SYSERR, GNUNET_YES, GPI_plugins_load(), include_friend_only, my_peer_identity, parse_hello_uri(), peerinfo, pic, print_my_uri(), print_peer_info(), put_uri, and tt.
Referenced by add_continuation(), dump_pc(), hello_callback(), parse_hello_uri(), print_my_uri(), print_peer_info(), and run().
|
static |
Print the collected address information to the console and free pc.
pc | printing context |
Definition at line 233 of file gnunet-peerinfo.c.
References _, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_i2s_full(), GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_YES, pc, pc_head, pc_tail, pic, state_machine(), and tt.
Referenced by print_peer_info(), and process_resolved_address().
|
static |
Function to call with a human-readable format of an address.
cls | closure |
address | NULL on error, otherwise 0-terminated printable UTF-8 string |
res | result of the address to string conversion: if GNUNET_OK: address was valid (conversion to string might still have failed) if GNUNET_SYSERR: address is invalid |
Definition at line 274 of file gnunet-peerinfo.c.
References _, address, AddressRecord::atsc, dump_pc(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_strdup, GNUNET_SYSERR, pc, AddressRecord::pc, PrintContext::peer, res, and AddressRecord::result.
Referenced by print_address().
|
static |
Iterator callback to go over all addresses and count them.
cls | struct PrintContext * with off to increment |
address | the address |
expiration | expiration time |
Definition at line 309 of file gnunet-peerinfo.c.
Referenced by print_peer_info().
|
static |
Iterator callback to go over all addresses.
cls | closure |
address | the address |
expiration | expiration time |
Definition at line 329 of file gnunet-peerinfo.c.
References address, AddressRecord::atsc, cfg, expiration, AddressRecord::expiration, GNUNET_asprintf(), GNUNET_assert, GNUNET_OK, GNUNET_TRANSPORT_address_to_string(), no_resolve, pc, AddressRecord::pc, process_resolved_address(), AddressRecord::result, and TIMEOUT.
Referenced by print_peer_info().
|
static |
Print information about the peer.
Currently prints the struct GNUNET_PeerIdentity
and the transport address.
cls | the struct PrintContext * |
peer | identity of the peer |
hello | addresses of the peer |
err_msg | error message |
Definition at line 365 of file gnunet-peerinfo.c.
References _, be_quiet, count_address(), dump_pc(), PrintContext::friend_only, GNUNET_CONTAINER_DLL_insert, GNUNET_HELLO_is_friend_only(), GNUNET_HELLO_iterate_addresses(), GNUNET_i2s_full(), GNUNET_malloc, GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_YES, pc, pc_head, pc_tail, peer, pic, print_address(), state_machine(), and tt.
Referenced by state_machine().
|
static |
Count the number of addresses in the HELLO.
cls | pointer to an int * used for the counter |
address | an address to count |
expiration | (unused) |
Definition at line 423 of file gnunet-peerinfo.c.
References GNUNET_OK.
Referenced by dump_my_hello().
|
static |
Write HELLO of my peer to a file.
cls | the struct GetUriContext * |
peer | identity of the peer (unused) |
hello | addresses of the peer |
err_msg | error message |
Definition at line 443 of file gnunet-peerinfo.c.
References _, be_quiet, count_addr(), dump_hello, GNUNET_DISK_fn_write(), GNUNET_DISK_PERM_GROUP_READ, GNUNET_DISK_PERM_OTHER_READ, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_HELLO_is_friend_only(), GNUNET_HELLO_iterate_addresses(), GNUNET_HELLO_size(), GNUNET_log_strerror_file, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, my_hello, and size.
Referenced by hello_callback().
|
static |
Print URI of the peer.
cls | the struct GetUriContext * |
peer | identity of the peer (unused) |
hello | addresses of the peer |
err_msg | error message |
Definition at line 504 of file gnunet-peerinfo.c.
References _, GNUNET_free, GNUNET_HELLO_compose_uri(), GNUNET_SCHEDULER_add_now(), GPI_plugins_find(), peer, pic, state_machine(), tt, and uri.
Referenced by state_machine().
|
static |
Continuation called from GNUNET_PEERINFO_add_peer()
cls | closure, NULL |
Definition at line 542 of file gnunet-peerinfo.c.
References ac, GNUNET_SCHEDULER_add_now(), state_machine(), and tt.
Referenced by parse_hello_uri().
|
static |
Parse the PUT URI given at the command line and add it to our peerinfo database.
put_uri | URI string to parse |
Definition at line 559 of file gnunet-peerinfo.c.
References ac, add_continuation(), GNUNET_free, GNUNET_HELLO_parse_uri(), GNUNET_OK, GNUNET_PEERINFO_add_peer(), GNUNET_SCHEDULER_add_now(), GPI_plugins_find(), my_peer_identity, peerinfo, GNUNET_PeerIdentity::public_key, put_uri, ret, state_machine(), and tt.
Referenced by state_machine().
|
static |
Main state machine that goes over all options and runs the next requested function.
cls | unused |
Definition at line 591 of file gnunet-peerinfo.c.
References ac, AddressRecord::atsc, gh, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_send_cancel(), GNUNET_PEERINFO_disconnect(), GNUNET_PEERINFO_iterate_cancel(), GNUNET_SCHEDULER_cancel(), GNUNET_TRANSPORT_address_to_string_cancel(), GNUNET_TRANSPORT_hello_get_cancel(), GPI_plugins_unload(), my_hello, pc, pc_head, pc_tail, peerinfo, pic, AddressRecord::result, and tt.
Referenced by run().
|
static |
Function called with our peer's HELLO message.
Used to obtain our peer's public key.
cls | NULL |
hello | the HELLO message |
Definition at line 655 of file gnunet-peerinfo.c.
References dump_hello, dump_my_hello(), gh, GNUNET_assert, GNUNET_copy_message(), GNUNET_HELLO_get_id(), GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_shutdown(), GNUNET_TRANSPORT_hello_get_cancel(), my_hello, my_peer_identity, state_machine(), and tt.
Referenced by run().
|
static |
Main function that will be run by the scheduler.
cls | closure |
args | remaining command-line arguments |
cfgfile | name of the configuration file used (for saving, can be NULL!) |
c | configuration |
Definition at line 683 of file gnunet-peerinfo.c.
References _, consensus-simulation::args, cfg, dump_hello, get_self, get_uri, gh, GNUNET_PEERINFO_connect(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_strdup, GNUNET_TRANSPORT_AC_ANY, GNUNET_TRANSPORT_hello_get(), GNUNET_YES, hello_callback(), peerinfo, put_uri, shutdown_task(), state_machine(), and tt.
Referenced by main().
int main | ( | int | argc, |
char *const * | argv | ||
) |
The main function to obtain peer information.
argc | number of arguments from the command line |
argv | command line arguments |
Definition at line 795 of file gnunet-peerinfo.c.
References be_quiet, default_operation, dump_hello, get_info, get_self, get_uri, gettext_noop, GNUNET_free_nz, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_string(), GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), GNUNET_YES, include_friend_only, no_resolve, options, put_uri, ret, and run().
|
static |
Option '-n'.
Definition at line 122 of file gnunet-peerinfo.c.
Referenced by main(), and print_address().
|
static |
Option '-q'.
Definition at line 127 of file gnunet-peerinfo.c.
Referenced by dump_my_hello(), main(), print_peer_info(), and state_machine().
|
static |
Option '-f'.
Definition at line 132 of file gnunet-peerinfo.c.
Referenced by GNUNET_PEERINFO_iterate(), GNUNET_PEERINFO_notify(), main(), make_info_message(), peerinfo_get(), and state_machine().
|
static |
Option '-s'.
Definition at line 137 of file gnunet-peerinfo.c.
Referenced by main(), run(), and state_machine().
|
static |
Option.
Definition at line 142 of file gnunet-peerinfo.c.
Referenced by main(), run(), and state_machine().
|
static |
Option.
Definition at line 147 of file gnunet-peerinfo.c.
Referenced by main(), and state_machine().
|
static |
Option '-i'.
Definition at line 152 of file gnunet-peerinfo.c.
Referenced by main(), and state_machine().
|
static |
Option.
Definition at line 157 of file gnunet-peerinfo.c.
Referenced by main(), parse_hello_uri(), run(), and state_machine().
|
static |
Option -d.
Definition at line 162 of file gnunet-peerinfo.c.
Referenced by dump_my_hello(), hello_callback(), main(), and run().
|
static |
Handle to peerinfo service.
Definition at line 167 of file gnunet-peerinfo.c.
Referenced by parse_hello_uri(), run(), shutdown_task(), and state_machine().
|
static |
Configuration handle.
Definition at line 172 of file gnunet-peerinfo.c.
Referenced by print_address(), run(), and state_machine().
|
static |
Main state machine task (if active).
Definition at line 177 of file gnunet-peerinfo.c.
Referenced by add_continuation(), dump_pc(), hello_callback(), parse_hello_uri(), print_my_uri(), print_peer_info(), run(), shutdown_task(), and state_machine().
|
static |
Pending GNUNET_TRANSPORT_hello_get() operation.
Definition at line 182 of file gnunet-peerinfo.c.
Referenced by add_get_request_to_pending(), clean_node(), connection_ready(), free_action_item(), GNUNET_DHT_get_start(), GNUNET_STATISTICS_get_cancel(), GST_connection_pool_get_handle(), GST_connection_pool_get_handle_done(), hello_callback(), main_task(), peer_connect_notify_cb(), reconnect_later(), run(), search_waiting(), send_get(), shutdown_task(), and try_connect().
|
static |
Current iterator context (if active, otherwise NULL).
Definition at line 187 of file gnunet-peerinfo.c.
Referenced by dump_pc(), GNUNET_TRANSPORT_monitor_peers_cancel(), print_my_uri(), print_peer_info(), shutdown_task(), and state_machine().
|
static |
My peer identity.
Definition at line 187 of file gnunet-peerinfo.c.
Referenced by hello_callback(), parse_hello_uri(), and state_machine().
|
static |
Head of list of print contexts.
Definition at line 197 of file gnunet-peerinfo.c.
Referenced by dump_pc(), print_peer_info(), and shutdown_task().
|
static |
Tail of list of print contexts.
Definition at line 202 of file gnunet-peerinfo.c.
Referenced by dump_pc(), print_peer_info(), and shutdown_task().
|
static |
Handle to current GNUNET_PEERINFO_add_peer() operation.
Definition at line 207 of file gnunet-peerinfo.c.
Referenced by add_continuation(), add_from_hello(), add_to_buf(), address_cb(), age_values(), block_until_external_trigger_traits(), cancel_get(), check_autoconfig_finished(), conclude_autoconfig_request(), continue_with_gns2dns(), cummulative_ack(), delayed_get(), delayed_put(), destroy_ack_cummulator(), dht_connected(), dht_disconnect(), do_refresh(), do_shutdown(), free_ack_cummulator_cb(), get_iter(), GNS_resolver_lookup_cancel(), GNUNET_NAT_mini_map_start(), GNUNET_TESTING_async_fail(), GNUNET_TESTING_async_finish(), GNUNET_TRANSPORT_hello_get(), handle_address_change_notification(), handle_autoconfig_request(), handle_dht_response(), handle_gns2dns_ip(), handle_gns2dns_result(), handle_gns_redirect_result(), handle_gns_resolution_result(), handle_namecache_block_response(), handle_revocation_result(), ifc_proc(), notify_client(), occ_cache_get_handle_ats_occ_cb(), occ_cache_get_handle_ats_rocc_cb(), parse_hello_uri(), preference_aging(), put_cont(), recursive_dns_resolution(), recursive_gns2dns_resolution(), recursive_gns_resolution_namecache(), recursive_gns_resolution_revocation(), recursive_pkey_resolution(), shutdown_task(), start_profiling(), start_resolver_lookup(), terminate_ac_activities(), transmit_cummulative_ack_cb(), update_enable_upnpc_option(), and upnp_addr_change_cb().
|
static |
Hello of this peer (if initialized).
Definition at line 212 of file gnunet-peerinfo.c.
Referenced by dump_my_hello(), hello_callback(), and shutdown_task().