35 #define UNLIMITED_STRING "unlimited"
285 while (NULL != (pr =
next))
299 fprintf (stdout,
_ (
"%u address resolutions had a timeout\n"),
pending);
302 _ (
"ATS returned stat_results for %u addresses\n"),
362 "Failed to convert address for peer `%s' plugin `%s' length %u to string (communication error)\n",
371 "Failed to convert address for peer `%s' plugin `%s' length %u to string (address invalid or not supported)\n",
389 "Peer `%s' plugin `%s', address `%s', `%s' bw out: %u Bytes/s, bw in %u Bytes/s, %s\n"),
396 pr->
active ?
_ (
"active ") :
_ (
"inactive "));
469 for (cur =
next; NULL != cur; cur =
next)
491 if (NULL == actx.
res)
501 _ (
"Removed address of peer `%s' with plugin `%s'\n"),
519 if ((NULL != actx.
res))
633 char *entry_in = NULL;
634 char *entry_out = NULL;
637 unsigned long long int quota_out;
638 unsigned long long int quota_in;
655 quota_out = UINT32_MAX;
663 "Outbound quota for network `%11s' not configured!\n",
678 quota_in = UINT32_MAX;
685 "Inbound quota for network `%11s' not configured!\n",
692 _ (
"Quota for network `%11s' (in/out): %10s / %10s\n"),
734 fprintf (stderr,
_ (
"Failed to parse peer identity `%s'\n"),
opt_pid_str);
745 fprintf (stderr,
_ (
"Failed to parse peer identity `%s'\n"),
cpid_str);
756 _ (
"Please select one operation: %s or %s or %s or %s or %s\n"),
776 fprintf (stderr,
"%s",
_ (
"Cannot connect to ATS service, exiting...\n"));
789 _ (
"Cannot issue request to ATS service, exiting...\n"));
800 fprintf (stderr,
"%s",
_ (
"Cannot connect to ATS service, exiting...\n"));
812 _ (
"Cannot issue request to ATS service, exiting...\n"));
825 fprintf (stderr,
"%s",
_ (
"Cannot connect to ATS service, exiting...\n"));
834 fprintf (stderr,
"%s",
_ (
"No preference type given!\n"));
839 fprintf (stderr,
"%s",
_ (
"No peer given!\n"));
855 fprintf (stderr,
"%s",
_ (
"Valid type required\n"));
862 fprintf (stderr,
"%s",
_ (
"Cannot connect to ATS service, exiting...\n"));
894 main (
int argc,
char *
const *argv)
911 "get list of active addresses currently used"),
916 "get list of all active addresses"),
927 "do not resolve IP addresses to hostnames"),
938 "set preference for the given peer"),
955 "preference type to set: latency | bandwidth"),
967 gettext_noop (
"verbose output (include ATS address properties)"),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
#define gettext_noop(String)
static struct PendingResolutions * tail
Tail of list of pending resolution requests.
static char * opt_pid_str
CLI Option: use specific peer.
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.
static unsigned int opt_pref_value
CLI Option: preference value to set.
static char * opt_type_str
CLI Option: preference type to set.
static struct GNUNET_ATS_ConnectivityHandle * ats_ch
Our connectivity handle.
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
static int stat_receive_done
State: all pending receive operations done?
static int opt_set_pref
CLI Option: set preference.
static char * cpid_str
Which peer should we connect to?
static int opt_verbose
CLI Opt: Print verbose ATS information.
static int stat_pending
State: number of pending operations.
static int ret
Final status code.
static int stat_results
Number of results returned from service.
static struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle.
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.
static struct PendingResolutions * head
Head of list of pending resolution requests.
static void end(void *cls)
Task run on shutdown.
static unsigned int print_quotas(const struct GNUNET_CONFIGURATION_Handle *cfg)
Print information about the quotas configured for the various network scopes.
static int opt_list_all
CLI Option: List all addresses.
static struct GNUNET_ATS_AddressListHandle * alh
ATS address list handle used.
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.
static int opt_monitor
CLI Option: Monitor addresses used.
static int opt_resolve_addresses_numeric
CLI Opt:
static void transport_addr_to_str_cb(void *cls, const char *address, int res)
Function to call with a textual representation of an address.
static struct GNUNET_SCHEDULER_Task * shutdown_task
Shutdown task.
static int opt_print_quotas
CLI Option: print quotas configured.
static int opt_list_used
CLI Option: List only addresses currently used (active)
#define UNLIMITED_STRING
String to respresent unlimited.
int main(int argc, char *const *argv)
The main function.
static struct GNUNET_ATS_ConnectivitySuggestHandle * ats_sh
Handle for address suggestion request.
static int free_addr_it(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Free address corresponding to a given peer.
static struct GNUNET_CONTAINER_MultiPeerMap * addresses
Hashmap to store addresses.
static int find_address_it(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Find address corresponding to a given peer.
static const struct GNUNET_CONFIGURATION_Handle * my_cfg
Our configuration.
static char * address
GNS address for this phone.
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static char * cpid
Which peer should we connect to?
static unsigned int pending
The number of queries that are outstanding.
Automatic transport selection and outbound bandwidth determination.
struct GNUNET_ATS_PerformanceHandle * GNUNET_ATS_performance_init(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ATS_AddressInformationCallback addr_info_cb, void *addr_info_cb_cls)
Get handle to access performance API of the ATS subsystem.
struct GNUNET_ATS_ConnectivityHandle * GNUNET_ATS_connectivity_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the ATS connectivity suggestion client handle.
void GNUNET_ATS_performance_list_addresses_cancel(struct GNUNET_ATS_AddressListHandle *alh)
Cancel a pending address listing operation.
void GNUNET_ATS_performance_done(struct GNUNET_ATS_PerformanceHandle *ph)
Client is done using the ATS performance subsystem, release resources.
struct GNUNET_ATS_ConnectivitySuggestHandle * GNUNET_ATS_connectivity_suggest(struct GNUNET_ATS_ConnectivityHandle *ch, const struct GNUNET_PeerIdentity *peer, uint32_t strength)
We would like to receive address suggestions for a peer.
void GNUNET_ATS_connectivity_done(struct GNUNET_ATS_ConnectivityHandle *ch)
Client is done with ATS connectivity management, release resources.
void GNUNET_ATS_performance_change_preference(struct GNUNET_ATS_PerformanceHandle *ph, const struct GNUNET_PeerIdentity *peer,...)
Change preferences for the given peer.
struct GNUNET_ATS_AddressListHandle * GNUNET_ATS_performance_list_addresses(struct GNUNET_ATS_PerformanceHandle *ph, const struct GNUNET_PeerIdentity *peer, int all, GNUNET_ATS_AddressInformationCallback infocb, void *infocb_cls)
Get information about addresses known to the ATS subsystem.
void GNUNET_ATS_connectivity_suggest_cancel(struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
We no longer care about being connected to a peer.
@ GNUNET_ATS_PREFERENCE_BANDWIDTH
Change the peer's bandwidth value (value per byte of bandwidth in the goal function) to the given amo...
@ GNUNET_ATS_PREFERENCE_LATENCY
Change the peer's latency value to the given amount.
@ GNUNET_ATS_PREFERENCE_END
End of preference list.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
int GNUNET_CONTAINER_multipeermap_get_multiple(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
#define GNUNET_HELLO_address_free(addr)
Free an address.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a string representing a public key to a public key.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_free_nz(ptr)
Wrapper around free.
const char * GNUNET_NT_to_string(enum GNUNET_NetworkType net)
Convert a enum GNUNET_NetworkType to a string.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_size_to_bytes(const char *fancy_size, unsigned long long *size)
Convert a given fancy human-readable size to bytes.
#define GNUNET_TIME_UNIT_SECONDS
One second.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
struct GNUNET_TRANSPORT_AddressToStringContext * GNUNET_TRANSPORT_address_to_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_HELLO_Address *address, int numeric, struct GNUNET_TIME_Relative timeout, GNUNET_TRANSPORT_AddressToStringCallback aluc, void *aluc_cls)
Convert a binary address into a human readable address.
void GNUNET_TRANSPORT_address_to_string_cancel(struct GNUNET_TRANSPORT_AddressToStringContext *alc)
Cancel request for address conversion.
Information we keep for an address.
int active
Is this an active address?
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out
Current outbound bandwidth.
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in
Current inbound bandwidth.
struct GNUNET_HELLO_Address * address
Address information.
Closure for find_address_it().
struct ATSAddress * res
Where to write the struct ATSAddress if we found one that matches.
const struct GNUNET_HELLO_Address * src
Address we are looking for.
Linked list of pending reservations.
Handle to the ATS subsystem for connectivity management.
Handle for ATS address suggestion requests.
ATS performance characteristics for an address.
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change.
32-bit bandwidth used for network exchange by GNUnet, in bytes per second.
uint32_t value__
The actual value (bytes per second).
Internal representation of the hash map.
Definition of a command line option.
An address for communicating with a peer.
const char * transport_name
Name of the transport plugin enabling the communication using this address.
size_t address_length
Number of bytes in address.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Entry in list of pending tasks.
Context for the address lookup.
Structure used to remember all pending address resolutions.
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in
Amount of inbound bandwidth assigned by ATS.
struct PendingResolutions * prev
Kept in a DLL.
struct GNUNET_TRANSPORT_AddressToStringContext * tats_ctx
Handle to the transport request to convert the address to a string.
struct GNUNET_HELLO_Address * address
Copy of the address we are resolving.
struct GNUNET_ATS_Properties properties
Performance data.
struct PendingResolutions * next
Kept in a DLL.
int active
Is this an active address?
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out
Amount of outbound bandwidth assigned by ATS.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model