38 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) 237 printf (
_ (
"%sPeer `%s'\n"),
244 printf (
_ (
"\tExpires: %s \t %s\n"),
255 if ((NULL == pc_head) && (NULL == pic))
281 if (0 != strlen (address))
292 _ (
"Failure: Cannot convert address to string for peer `%s'\n"),
379 _ (
"Error in communication with PEERINFO service: %s\n"),
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);
617 while (NULL != (pc = pc_head))
624 if (NULL != ar->
atsc)
634 if (NULL != peerinfo)
639 if (NULL != my_hello)
659 fprintf (stderr,
"Failed to get my own HELLO from this peer!\n");
689 if ((NULL != args[0]) && (NULL ==
put_uri) &&
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"),
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
size_t address_length
Number of bytes in address.
int GNUNET_HELLO_get_id(const struct GNUNET_HELLO_Message *hello, struct GNUNET_PeerIdentity *peer)
Get the peer identity from a HELLO message.
static int default_operation
Option.
enum GNUNET_HELLO_AddressInfo local_info
Extended information about address.
static void add_continuation(void *cls)
Continuation called from GNUNET_PEERINFO_add_peer()
static int be_quiet
Option '-q'.
struct GNUNET_PeerIdentity peer
Identity of the peer.
static int print_address(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Iterator callback to go over all addresses.
Handle to the peerinfo service.
A HELLO message is used to exchange information about transports with other peers.
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, parse options).
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static void shutdown_task(void *cls)
Main state machine that goes over all options and runs the next requested function.
struct GNUNET_PEERINFO_Handle * GNUNET_PEERINFO_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the peerinfo service.
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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
struct PrintContext * pc
Print context this address record belongs to.
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.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Structure we use to collect printable address information.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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 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 int ret
Return value of the commandline.
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 const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle.
static struct GNUNET_SCHEDULER_Task * tt
Main state machine task (if active).
static int include_friend_only
Option '-f'.
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Definition of a command line option.
Context for the address lookup.
#define TIMEOUT
How long until we time out during address lookup?
struct PrintContext * next
Kept in DLL.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static char * put_uri
Option.
Context for an iteration request.
static char * dump_hello
Option -d.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
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.
static int get_uri
Option.
int main(int argc, char *const *argv)
The main function to obtain peer information.
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.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
unsigned int num_addresses
Number of completed addresses in address_list.
static struct GNUNET_PEERINFO_Handle * peerinfo
Handle to peerinfo service.
static struct GNUNET_PEERINFO_IteratorContext * pic
Current iterator context (if active, otherwise NULL).
void GNUNET_PEERINFO_iterate_cancel(struct GNUNET_PEERINFO_IteratorContext *ic)
Cancel an iteration over peer information.
Record we keep for each printable address.
static void state_machine(void *cls)
Main state machine that goes over all options and runs the next requested function.
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_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
void GNUNET_TRANSPORT_address_to_string_cancel(struct GNUNET_TRANSPORT_AddressToStringContext *alc)
Cancel request for address conversion.
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.
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.
const char * transport_name
Name of the transport plugin enabling the communication using this address.
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.
Bitmask for "any" address.
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.
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.
static void hello_callback(void *cls, const struct GNUNET_MessageHeader *hello)
Function called with our peer's HELLO message.
struct PrintContext * prev
Kept in DLL.
static struct PrintContext * pc_head
Head of list of print contexts.
void GPI_plugins_unload()
Unload all plugins.
static struct GNUNET_HELLO_Message * my_hello
Hello of this peer (if initialized).
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
struct GNUNET_TIME_Absolute expiration
Address expiration time.
#define GNUNET_free_nz(ptr)
Wrapper around free.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
static unsigned int size
Size of the "table".
static int no_resolve
Option '-n'.
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.
int GNUNET_HELLO_is_friend_only(const struct GNUNET_HELLO_Message *h)
Return HELLO type.
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
static struct GNUNET_PeerIdentity my_peer_identity
My peer identity.
struct GNUNET_TRANSPORT_AddressToStringContext * atsc
Current address-to-string context (if active, otherwise NULL).
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.
char * result
Printable address.
static void dump_pc(struct PrintContext *pc)
Print the collected address information to the console and free pc.
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.
The identity of the host (wraps the signing key of the peer).
unsigned int off
Current offset in address_list (counted down).
static struct PrintContext * pc_tail
Tail of list of print contexts.
void GPI_plugins_load(const struct GNUNET_CONFIGURATION_Handle *cfg)
Load and initialize all plugins.
An address for communicating with a peer.
static int get_self
Option '-s'.
struct GNUNET_TRANSPORT_PluginFunctions * GPI_plugins_find(const char *name)
Obtain the plugin API based on a plugin name.
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_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.
static struct GNUNET_TRANSPORT_HelloGetHandle * gh
Pending GNUNET_TRANSPORT_hello_get() operation.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
uint16_t GNUNET_HELLO_size(const struct GNUNET_HELLO_Message *hello)
Return the size of the given HELLO message.
void GNUNET_PEERINFO_disconnect(struct GNUNET_PEERINFO_Handle *h)
Disconnect from the peerinfo service.
Functions to call with this peer's HELLO.
Time for absolute times used by GNUnet, in microseconds.
int friend_only
Hello was friend only, GNUNET_YES or GNUNET_NO.
static void process_resolved_address(void *cls, const char *address, int res)
Function to call with a human-readable format of an address.
struct AddressRecord * address_list
List of printable addresses.
static void dump_my_hello()
Write HELLO of my peer to a file.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
unsigned int address_list_size
Number of addresses allocated in address_list.
static char * address
GNS address for this phone.
void GNUNET_MQ_send_cancel(struct GNUNET_MQ_Envelope *ev)
Cancel sending the message.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_TRANSPORT_hello_get_cancel(struct GNUNET_TRANSPORT_HelloGetHandle *ghh)
Stop receiving updates about changes to our HELLO message.
#define GNUNET_malloc(size)
Wrapper around malloc.
static int get_info
Option '-i'.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_CRYPTO_EddsaPublicKey public_key
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
#define gettext_noop(String)
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.