38 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
237 printf (
_ (
"%sPeer `%s'\n"),
240 for (i = 0; i <
pc->num_addresses; i++)
242 if (NULL !=
pc->address_list[i].result)
244 printf (
_ (
"\tExpires: %s \t %s\n"),
246 pc->address_list[i].expiration),
247 pc->address_list[i].result);
292 _ (
"Failure: Cannot convert address to string for peer `%s'\n"),
295 if (
pc->num_addresses ==
pc->address_list_size)
337 ar = &
pc->address_list[--
pc->off];
343 (
unsigned long)
address->address_length,
379 _ (
"Error in communication with PEERINFO service: %s\n"),
406 pc->address_list_size =
pc->off;
451 fprintf (stderr,
_ (
"Failure: Received invalid %s\n"),
"HELLO");
464 _ (
"Failed to write HELLO with %u bytes to file `%s'\n"),
480 _ (
"Wrote %s HELLO containing %u addresses with %u bytes to file `%s'\n"),
516 _ (
"Error in communication with PEERINFO service: %s\n"),
527 printf (
"%s\n", (
const char *)
uri);
620 for (i = 0; i <
pc->address_list_size; i++)
622 ar = &
pc->address_list[i];
624 if (NULL != ar->
atsc)
659 fprintf (stderr,
"Failed to get my own HELLO from this peer!\n");
690 (
args[0] == strcasestr (
args[0],
"gnunet://hello/")))
697 fprintf (stderr,
_ (
"Invalid command line argument `%s'\n"),
args[0]);
702 fprintf (stderr,
"%s",
"Could not access PEERINFO service. Exiting.\n");
737 fprintf (stderr,
_ (
"Invalid URI `%s'\n"),
put_uri);
795 main (
int argc,
char *
const *argv)
806 "output only the identity strings"),
811 "include friend-only information"),
839 "add given HELLO uri to the database"),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
#define gettext_noop(String)
static char * expiration
Credential TTL.
static int ret
Return value of the commandline.
static char * address
GNS address for this phone.
static int be_quiet
Option '-q'.
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.
static struct PrintContext * pc_head
Head of list of print contexts.
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.
static struct GNUNET_TRANSPORT_HelloGetHandle * gh
Pending GNUNET_TRANSPORT_hello_get() operation.
static void dump_my_hello()
Write HELLO of my peer to a file.
static char * put_uri
Option.
static int no_resolve
Option '-n'.
#define TIMEOUT
How long until we time out during address lookup?
static struct GNUNET_PEERINFO_IteratorContext * pic
Current iterator context (if active, otherwise NULL).
static int default_operation
Option.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle.
static int get_uri
Option.
static int get_info
Option '-i'.
static void process_resolved_address(void *cls, const char *address, int res)
Function to call with a human-readable format of an address.
static int get_self
Option '-s'.
static struct GNUNET_PEERINFO_Handle * peerinfo
Handle to peerinfo service.
static void shutdown_task(void *cls)
Main state machine that goes over all options and runs the next requested function.
static char * dump_hello
Option -d.
static struct GNUNET_SCHEDULER_Task * tt
Main state machine task (if active).
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.
static struct PrintContext * pc_tail
Tail of list of print contexts.
static int include_friend_only
Option '-f'.
static void state_machine(void *cls)
Main state machine that goes over all options and runs the next requested function.
static void add_continuation(void *cls)
Continuation called from GNUNET_PEERINFO_add_peer()
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.
static struct GNUNET_HELLO_Message * my_hello
Hello of this peer (if initialized).
int main(int argc, char *const *argv)
The main function to obtain peer information.
static struct GNUNET_PeerIdentity my_peer_identity
My peer identity.
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.
static void dump_pc(struct PrintContext *pc)
Print the collected address information to the console and free pc.
static int print_address(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Iterator callback to go over all addresses.
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.
static void hello_callback(void *cls, const struct GNUNET_MessageHeader *hello)
Function called with our peer's HELLO message.
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
struct GNUNET_TRANSPORT_PluginFunctions * GPI_plugins_find(const char *name)
Obtain the plugin API based on a plugin name.
void GPI_plugins_load(const struct GNUNET_CONFIGURATION_Handle *cfg)
Load and initialize all plugins.
void GPI_plugins_unload()
Unload all plugins.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
Helper library for handling HELLOs.
Maintain the list of currently known hosts.
obtain information about our current address
enum GNUNET_GenericReturnValue GNUNET_DISK_fn_write(const char *fn, const void *buf, size_t buf_size, enum GNUNET_DISK_AccessPermissions mode)
Write a buffer to a file atomically.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_GROUP_READ
Group can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
@ GNUNET_DISK_PERM_OTHER_READ
Everybody can read.
#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_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.
int GNUNET_HELLO_get_id(const struct GNUNET_HELLO_Message *hello, struct GNUNET_PeerIdentity *peer)
Get the peer identity from a HELLO message.
uint16_t GNUNET_HELLO_size(const struct GNUNET_HELLO_Message *hello)
Return the size of the given HELLO message.
int GNUNET_HELLO_parse_uri(const char *uri, struct GNUNET_CRYPTO_EddsaPublicKey *pubkey, struct GNUNET_HELLO_Message **hello, GNUNET_HELLO_TransportPluginsFind plugins_find)
Parse a hello URI string to a hello message.
int GNUNET_HELLO_is_friend_only(const struct GNUNET_HELLO_Message *h)
Return HELLO type.
char * GNUNET_HELLO_compose_uri(const struct GNUNET_HELLO_Message *hello, GNUNET_HELLO_TransportPluginsFind plugins_find)
Compose a hello URI string from a hello message.
struct GNUNET_HELLO_Message * GNUNET_HELLO_iterate_addresses(const struct GNUNET_HELLO_Message *msg, int return_modified, GNUNET_HELLO_AddressIterator it, void *it_cls)
Iterate over all of the addresses in the HELLO.
#define GNUNET_log(kind,...)
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.
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_free_nz(ptr)
Wrapper around free.
void GNUNET_MQ_send_cancel(struct GNUNET_MQ_Envelope *ev)
Cancel sending the message.
struct GNUNET_MQ_Envelope * GNUNET_PEERINFO_add_peer(struct GNUNET_PEERINFO_Handle *h, const struct GNUNET_HELLO_Message *hello, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Add a host to the persistent list.
struct GNUNET_PEERINFO_Handle * GNUNET_PEERINFO_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the peerinfo service.
struct GNUNET_PEERINFO_IteratorContext * GNUNET_PEERINFO_iterate(struct GNUNET_PEERINFO_Handle *h, int include_friend_only, const struct GNUNET_PeerIdentity *peer, GNUNET_PEERINFO_Processor callback, void *callback_cls)
Call a method for each known matching host.
void GNUNET_PEERINFO_iterate_cancel(struct GNUNET_PEERINFO_IteratorContext *ic)
Cancel an iteration over peer information.
void GNUNET_PEERINFO_disconnect(struct GNUNET_PEERINFO_Handle *h)
Disconnect from the peerinfo service.
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.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
struct GNUNET_TRANSPORT_HelloGetHandle * GNUNET_TRANSPORT_hello_get(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_TRANSPORT_AddressClass ac, GNUNET_TRANSPORT_HelloUpdateCallback rec, void *rec_cls)
Obtain updates on changes to the HELLO message for this peer.
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_hello_get_cancel(struct GNUNET_TRANSPORT_HelloGetHandle *ghh)
Stop receiving updates about changes to our HELLO message.
void GNUNET_TRANSPORT_address_to_string_cancel(struct GNUNET_TRANSPORT_AddressToStringContext *alc)
Cancel request for address conversion.
@ GNUNET_TRANSPORT_AC_ANY
Bitmask for "any" address.
static unsigned int size
Size of the "table".
Record we keep for each printable address.
struct GNUNET_TIME_Absolute expiration
Address expiration time.
struct PrintContext * pc
Print context this address record belongs to.
struct GNUNET_TRANSPORT_AddressToStringContext * atsc
Current address-to-string context (if active, otherwise NULL).
char * result
Printable address.
Definition of a command line option.
An address for communicating with a peer.
A HELLO message is used to exchange information about transports with other peers.
Handle to the peerinfo service.
Context for an iteration request.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Entry in list of pending tasks.
Time for absolute times used by GNUnet, in microseconds.
Context for the address lookup.
Functions to call with this peer's HELLO.
Structure we use to collect printable address information.
struct AddressRecord * address_list
List of printable addresses.
unsigned int off
Current offset in address_list (counted down).
unsigned int num_addresses
Number of completed addresses in address_list.
unsigned int address_list_size
Number of addresses allocated in address_list.
struct GNUNET_PeerIdentity peer
Identity of the peer.
int friend_only
Hello was friend only, GNUNET_YES or GNUNET_NO.
struct PrintContext * next
Kept in DLL.
struct PrintContext * prev
Kept in DLL.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.