ATS command line tool. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_ats_service.h"
#include "gnunet_transport_service.h"
Go to the source code of this file.
Data Structures | |
struct | PendingResolutions |
Structure used to remember all pending address resolutions. More... | |
struct | ATSAddress |
Information we keep for an address. More... | |
struct | AddressFindCtx |
Closure for find_address_it(). More... | |
Macros | |
#define | UNLIMITED_STRING "unlimited" |
String to respresent unlimited. More... | |
Functions | |
static int | free_addr_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Free address corresponding to a given peer. More... | |
static void | end (void *cls) |
Task run on shutdown. More... | |
static void | transport_addr_to_str_cb (void *cls, const char *address, int res) |
Function to call with a textual representation of an address. More... | |
static int | find_address_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Find address corresponding to a given peer. More... | |
static void | ats_perf_mon_cb (void *cls, const struct GNUNET_HELLO_Address *address, int active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, const struct GNUNET_ATS_Properties *prop) |
Signature of a function that is called with QoS information about an address. More... | |
static void | ats_perf_cb (void *cls, const struct GNUNET_HELLO_Address *address, int active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, const struct GNUNET_ATS_Properties *prop) |
Signature of a function that is called with QoS information about an address. More... | |
static unsigned int | print_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg) |
Print information about the quotas configured for the various network scopes. More... | |
static void | run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *my_cfg) |
Main function that will be run by the scheduler. More... | |
int | main (int argc, char *const *argv) |
The main function. More... | |
Variables | |
static int | opt_resolve_addresses_numeric |
CLI Opt: More... | |
static int | opt_verbose |
CLI Opt: Print verbose ATS information. More... | |
static int | opt_list_used |
CLI Option: List only addresses currently used (active) More... | |
static int | opt_list_all |
CLI Option: List all addresses. More... | |
static int | opt_set_pref |
CLI Option: set preference. More... | |
static int | opt_print_quotas |
CLI Option: print quotas configured. More... | |
static int | opt_monitor |
CLI Option: Monitor addresses used. More... | |
static char * | opt_pid_str |
CLI Option: use specific peer. More... | |
static char * | opt_type_str |
CLI Option: preference type to set. More... | |
static unsigned int | opt_pref_value |
CLI Option: preference value to set. More... | |
static int | ret |
Final status code. More... | |
static int | stat_results |
Number of results returned from service. More... | |
static int | stat_receive_done |
State: all pending receive operations done? More... | |
static int | stat_pending |
State: number of pending operations. More... | |
static char * | cpid_str |
Which peer should we connect to? More... | |
static struct GNUNET_ATS_PerformanceHandle * | ph |
ATS performance handle used. More... | |
static struct GNUNET_ATS_ConnectivityHandle * | ats_ch |
Our connectivity handle. More... | |
static struct GNUNET_ATS_ConnectivitySuggestHandle * | ats_sh |
Handle for address suggestion request. More... | |
static struct GNUNET_ATS_AddressListHandle * | alh |
ATS address list handle used. More... | |
static struct GNUNET_CONFIGURATION_Handle * | cfg |
Configuration handle. More... | |
static struct GNUNET_SCHEDULER_Task * | shutdown_task |
Shutdown task. More... | |
static struct GNUNET_CONTAINER_MultiPeerMap * | addresses |
Hashmap to store addresses. More... | |
static struct PendingResolutions * | head |
Head of list of pending resolution requests. More... | |
static struct PendingResolutions * | tail |
Tail of list of pending resolution requests. More... | |
ATS command line tool.
Definition in file gnunet-ats.c.
#define UNLIMITED_STRING "unlimited" |
String to respresent unlimited.
Definition at line 35 of file gnunet-ats.c.
|
static |
Free address corresponding to a given peer.
cls | NULL |
key | peer identity |
value | the struct ATSAddress * to be freed |
Definition at line 247 of file gnunet-ats.c.
References ATSAddress::address, addresses, GNUNET_assert, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_free, GNUNET_HELLO_address_free, GNUNET_OK, key, and value.
Referenced by ats_perf_mon_cb(), and end().
|
static |
Task run on shutdown.
cls | NULL |
Definition at line 265 of file gnunet-ats.c.
References _, PendingResolutions::address, addresses, alh, ats_ch, ats_sh, free_addr_it(), GNUNET_ATS_connectivity_done(), GNUNET_ATS_connectivity_suggest_cancel(), GNUNET_ATS_performance_done(), GNUNET_ATS_performance_list_addresses_cancel(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_free, GNUNET_TRANSPORT_address_to_string_cancel(), head, PendingResolutions::next, opt_list_all, opt_list_used, pending, ph, ret, stat_results, tail, and PendingResolutions::tats_ctx.
Referenced by ats_perf_cb(), run(), and transport_addr_to_str_cb().
|
static |
Function to call with a textual representation of an address.
This function will be called several times with different possible textual representations, and a last time with address being NULL to signal the end of the iteration. Note that address NULL always is the last call, regardless of the value in res.
cls | closure, a struct PendingResolutions * |
address | NULL on end of iteration, otherwise 0-terminated printable UTF-8 string, in particular an empty string if res is GNUNET_NO |
res | result of the address to string conversion: if GNUNET_OK: conversion successful if GNUNET_NO: address was invalid (or not supported) if GNUNET_SYSERR: communication error (IPC error) |
Definition at line 336 of file gnunet-ats.c.
References _, PendingResolutions::active, PendingResolutions::address, address, GNUNET_HELLO_Address::address_length, PendingResolutions::bandwidth_in, PendingResolutions::bandwidth_out, end(), GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_i2s(), GNUNET_NO, GNUNET_NT_to_string(), GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, GNUNET_YES, head, GNUNET_HELLO_Address::peer, PendingResolutions::properties, res, GNUNET_ATS_Properties::scope, shutdown_task, stat_pending, stat_receive_done, tail, GNUNET_HELLO_Address::transport_name, and GNUNET_BANDWIDTH_Value32NBO::value__.
Referenced by ats_perf_cb(), and ats_perf_mon_cb().
|
static |
Find address corresponding to a given peer.
cls | the struct AddressFindCtx * |
key | peer identity |
value | the struct ATSAddress * for an existing address |
Definition at line 426 of file gnunet-ats.c.
References ATSAddress::address, GNUNET_HELLO_address_cmp(), GNUNET_NO, GNUNET_YES, AddressFindCtx::res, AddressFindCtx::src, and value.
Referenced by ats_perf_mon_cb().
|
static |
Signature of a function that is called with QoS information about an address.
cls | closure (NULL) |
address | the address, NULL if ATS service was disconnected |
active | GNUNET_YES if this address is actively used to maintain a connection to a peer; GNUNET_NO if the address is not actively used; GNUNET_SYSERR if this address is no longer available for ATS |
bandwidth_out | assigned outbound bandwidth for the connection |
bandwidth_in | assigned inbound bandwidth for the connection |
prop | performance data for the address (as far as known) |
Definition at line 454 of file gnunet-ats.c.
References _, PendingResolutions::active, ATSAddress::active, PendingResolutions::address, ATSAddress::address, address, addresses, PendingResolutions::bandwidth_in, ATSAddress::bandwidth_in, PendingResolutions::bandwidth_out, ATSAddress::bandwidth_out, cfg, find_address_it(), free_addr_it(), GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_get_multiple(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_free, GNUNET_HELLO_address_copy(), GNUNET_HELLO_address_free, GNUNET_i2s(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_SECONDS, GNUNET_TRANSPORT_address_to_string(), GNUNET_TRANSPORT_address_to_string_cancel(), head, PendingResolutions::next, opt_resolve_addresses_numeric, opt_verbose, PendingResolutions::properties, AddressFindCtx::res, AddressFindCtx::src, stat_pending, stat_results, tail, PendingResolutions::tats_ctx, transport_addr_to_str_cb(), GNUNET_HELLO_Address::transport_name, and GNUNET_BANDWIDTH_Value32NBO::value__.
Referenced by run().
|
static |
Signature of a function that is called with QoS information about an address.
cls | closure (NULL) |
address | the address, NULL if ATS service was disconnected |
active | is this address actively used to maintain a connection to a peer |
bandwidth_out | assigned outbound bandwidth for the connection |
bandwidth_in | assigned inbound bandwidth for the connection |
prop | performance data for the address (as far as known) |
Definition at line 580 of file gnunet-ats.c.
References PendingResolutions::active, PendingResolutions::address, address, alh, PendingResolutions::bandwidth_in, PendingResolutions::bandwidth_out, cfg, end(), GNUNET_CONTAINER_DLL_insert, GNUNET_HELLO_address_copy(), GNUNET_new, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_SECONDS, GNUNET_TRANSPORT_address_to_string(), GNUNET_YES, head, opt_resolve_addresses_numeric, PendingResolutions::properties, shutdown_task, stat_pending, stat_receive_done, stat_results, tail, PendingResolutions::tats_ctx, and transport_addr_to_str_cb().
Referenced by run().
|
static |
Print information about the quotas configured for the various network scopes.
cfg | configuration to obtain quota information from |
Definition at line 631 of file gnunet-ats.c.
References _, cfg, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_free, GNUNET_NT_COUNT, GNUNET_NT_to_string(), GNUNET_OK, GNUNET_STRINGS_fancy_size_to_bytes(), GNUNET_SYSERR, and UNLIMITED_STRING.
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!) |
my_cfg | configuration |
Definition at line 712 of file gnunet-ats.c.
References _, addresses, alh, ats_ch, ats_perf_cb(), ats_perf_mon_cb(), ats_sh, cfg, cpid, cpid_str, end(), GNUNET_ATS_connectivity_init(), GNUNET_ATS_connectivity_suggest(), GNUNET_ATS_performance_change_preference(), GNUNET_ATS_performance_init(), GNUNET_ATS_performance_list_addresses(), GNUNET_ATS_PREFERENCE_BANDWIDTH, GNUNET_ATS_PREFERENCE_END, GNUNET_ATS_PREFERENCE_LATENCY, GNUNET_CONTAINER_multipeermap_create(), GNUNET_CRYPTO_eddsa_public_key_from_string(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_TIME_UNIT_SECONDS, GNUNET_YES, my_cfg, opt_list_all, opt_list_used, opt_monitor, opt_pid_str, opt_pref_value, opt_print_quotas, opt_set_pref, opt_type_str, ph, pid, print_quotas(), GNUNET_PeerIdentity::public_key, ret, shutdown_task, stat_results, and type.
Referenced by main().
int main | ( | int | argc, |
char *const * | argv | ||
) |
The main function.
argc | number of arguments from the command line |
argv | command line arguments |
Definition at line 894 of file gnunet-ats.c.
References cpid_str, gettext_noop, GNUNET_free, GNUNET_free_nz, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_string(), GNUNET_GETOPT_option_uint(), GNUNET_NO, GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), opt_list_all, opt_list_used, opt_monitor, opt_pid_str, opt_pref_value, opt_print_quotas, opt_resolve_addresses_numeric, opt_set_pref, opt_type_str, opt_verbose, options, res, ret, run(), stat_pending, and stat_receive_done.
|
static |
CLI Opt:
Definition at line 41 of file gnunet-ats.c.
Referenced by ats_perf_cb(), ats_perf_mon_cb(), and main().
|
static |
CLI Opt: Print verbose ATS information.
Definition at line 46 of file gnunet-ats.c.
Referenced by ats_perf_mon_cb(), and main().
|
static |
CLI Option: List only addresses currently used (active)
Definition at line 51 of file gnunet-ats.c.
|
static |
CLI Option: List all addresses.
Definition at line 56 of file gnunet-ats.c.
|
static |
CLI Option: set preference.
Definition at line 61 of file gnunet-ats.c.
|
static |
CLI Option: print quotas configured.
Definition at line 66 of file gnunet-ats.c.
|
static |
CLI Option: Monitor addresses used.
Definition at line 71 of file gnunet-ats.c.
|
static |
CLI Option: use specific peer.
Definition at line 76 of file gnunet-ats.c.
|
static |
CLI Option: preference type to set.
Definition at line 81 of file gnunet-ats.c.
|
static |
CLI Option: preference value to set.
Definition at line 86 of file gnunet-ats.c.
|
static |
Final status code.
Definition at line 91 of file gnunet-ats.c.
|
static |
Number of results returned from service.
Definition at line 96 of file gnunet-ats.c.
Referenced by ats_perf_cb(), ats_perf_mon_cb(), end(), and run().
|
static |
State: all pending receive operations done?
Definition at line 101 of file gnunet-ats.c.
Referenced by ats_perf_cb(), main(), and transport_addr_to_str_cb().
|
static |
State: number of pending operations.
Definition at line 106 of file gnunet-ats.c.
Referenced by ats_perf_cb(), ats_perf_mon_cb(), main(), and transport_addr_to_str_cb().
|
static |
Which peer should we connect to?
Definition at line 111 of file gnunet-ats.c.
|
static |
ATS performance handle used.
Definition at line 116 of file gnunet-ats.c.
Referenced by calculate_pow(), calculate_pow_shutdown(), calculate_score(), do_disconnect(), do_reconnect(), ego_callback(), end(), GDS_u_drop(), GNUNET_ATS_performance_change_preference(), GNUNET_ATS_performance_done(), GNUNET_ATS_performance_give_feedback(), GNUNET_ATS_performance_init(), GNUNET_ATS_performance_list_addresses(), GNUNET_ATS_performance_list_addresses_cancel(), GNUNET_ATS_reserve_bandwidth(), GNUNET_DHT_disconnect(), GNUNET_DHT_put(), GNUNET_DHT_put_cancel(), gnunet_drop(), gnunet_hold(), GSC_KX_encrypt_and_transmit(), handle_address_list(), handle_encrypted(), handle_peer_information(), handle_put_cont(), handle_reservation_result(), ip_drop(), ip_hold(), linux_read(), mq_error_handler(), reconnect(), reconnect_task(), run(), and run_with_key().
|
static |
Our connectivity handle.
Definition at line 121 of file gnunet-ats.c.
Referenced by consider_peer_activate(), end(), and run().
|
static |
Handle for address suggestion request.
Definition at line 126 of file gnunet-ats.c.
|
static |
ATS address list handle used.
Definition at line 131 of file gnunet-ats.c.
Referenced by ats_perf_cb(), do_reconnect(), end(), GNUNET_ATS_performance_done(), GNUNET_ATS_performance_list_addresses(), GNUNET_ATS_performance_list_addresses_cancel(), handle_address_list(), and run().
|
static |
Configuration handle.
Definition at line 136 of file gnunet-ats.c.
Referenced by ats_perf_cb(), ats_perf_mon_cb(), print_quotas(), and run().
|
static |
Shutdown task.
Definition at line 141 of file gnunet-ats.c.
Referenced by ats_perf_cb(), run(), and transport_addr_to_str_cb().
|
static |
Hashmap to store addresses.
Definition at line 146 of file gnunet-ats.c.
Referenced by ats_perf_mon_cb(), end(), free_addr_it(), get_best_address(), plugin_env_address_change_notification(), and run().
|
static |
Head of list of pending resolution requests.
Definition at line 230 of file gnunet-ats.c.
Referenced by ats_perf_cb(), ats_perf_mon_cb(), end(), GPI_plugins_find(), meminfo(), parse_pattern(), parse_recordline(), search_waiting(), select_peer(), send_msg_from_cache(), and transport_addr_to_str_cb().
|
static |
Tail of list of pending resolution requests.
Definition at line 235 of file gnunet-ats.c.
Referenced by ats_perf_cb(), ats_perf_mon_cb(), discard_all_from_rung_tail(), end(), meminfo(), parse_pattern(), send_msg_from_cache(), sql_prepare(), and transport_addr_to_str_cb().