151 size = ntohs (message->
size);
157 uri = (
const char *) &message[1];
159 if (uri[uri_size - 1] !=
'\0')
179 const char *
uri = (
const char *) &message[1];
204 "A new peer connected, notifying client and server\n");
215 return (
void *)
peer;
252 "Hostlist daemon is shutting down\n");
306 "None of the functions for the hostlist daemon were enabled. I have no reason to run!\n"));
328 learning ? learn_handlers : no_learn_handlers);
343 _ (
"Failed to connect to `%s' service.\n"),
"core");
358 main (
int argc,
char *
const *argv)
364 "advertise our hostlist to other peers"),
369 "bootstrap using hostlists (it is highly recommended that you always use this option)"),
374 "enable learning about hostlist servers from other peers"),
393 _ (
"GNUnet hostlist server and client"),
395 &
run, NULL)) ? 0 : 1;
static GNUNET_NETWORK_STRUCT_END struct GNUNET_PeerIdentity me
Our own peer identity.
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).
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
void GNUNET_HOSTLIST_client_stop()
Stop downloading hostlists from hostlist servers as necessary.
Context for the core service connection.
static void handle_advertisement(void *cls, const struct GNUNET_MessageHeader *message)
Core handler for p2p hostlist advertisements.
int GNUNET_HOSTLIST_server_start(const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_STATISTICS_Handle *st, struct GNUNET_CORE_Handle *co, GNUNET_CORE_ConnectEventHandler *server_ch, int advertise)
Start server offering our hostlist.
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 GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void(* GNUNET_CORE_DisconnectEventHandler)(void *cls, const struct GNUNET_PeerIdentity *peer, void *peer_cls)
Method called whenever a peer disconnects.
static void disconnect_handler(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Method called whenever a given peer disconnects.
static int ret
Return value of the commandline.
static void * connect_handler(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a given peer connects.
static void core_init(void *cls, const struct GNUNET_PeerIdentity *my_identity)
Callback invoked once our connection to CORE service is up.
Definition of a command line option.
static struct GNUNET_PeerIdentity my_identity
Identity of this peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
static void cleaning_task(void *cls)
Last task run during shutdown.
void *(* GNUNET_CORE_ConnectEventHandler)(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a given peer connects.
int main(int argc, char *const *argv)
The main function for the hostlist daemon.
A HOSTLIST_ADV message is used to exchange information about hostlist advertisements.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
void(* GNUNET_HOSTLIST_UriHandler)(const char *uri)
Function that handles an advertised URI.
static GNUNET_CORE_DisconnectEventHandler client_dh
Handle to hostlist client's disconnect handler.
static int check_advertisement(void *cls, const struct GNUNET_MessageHeader *message)
Core handler for p2p hostlist advertisements.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
static int learning
Set if the user allows us to learn about new hostlists from the network.
static GNUNET_CORE_ConnectEventHandler server_ch
Handle to hostlist server's connect handler.
Message handler for a specific message type.
static int provide_hostlist
Set if the user wants us to run a hostlist server.
#define GNUNET_free_nz(ptr)
Wrapper around free.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
uint32_t reserved
Always zero (for alignment).
static unsigned int size
Size of the "table".
struct GNUNET_CORE_Handle * GNUNET_CORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Connect to the core service.
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
int GNUNET_HOSTLIST_client_start(const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_STATISTICS_Handle *st, GNUNET_CORE_ConnectEventHandler *ch, GNUNET_CORE_DisconnectEventHandler *dh, GNUNET_HOSTLIST_UriHandler *msgh, int learn)
Start downloading hostlists from hostlist servers as necessary.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
Handle to a message queue.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
static struct GNUNET_CORE_Handle * core
Handle to the core service (NULL until we've connected to it).
The identity of the host (wraps the signing key of the peer).
static int bootstrapping
Set if we are allowed to learn about peers by accessing hostlist servers.
static GNUNET_HOSTLIST_UriHandler client_adv_handler
Handle to the hostlist client's advertisement handler.
#define GNUNET_PACKED
gcc-ism to get packed structs.
void GNUNET_HOSTLIST_server_stop()
Stop server offering our hostlist.
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.
static int advertising
Set if we are allowed to advertise our hostlist to others.
struct GNUNET_MQ_Handle * mq
#define GNUNET_log(kind,...)
#define GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT
Further X-VINE DHT messages continued from 880.
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT.
static struct GNUNET_STATISTICS_Handle * stats
Statistics handle.
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
static GNUNET_CORE_ConnectEventHandler client_ch
Handle to hostlist client's connect handler.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define gettext_noop(String)
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run.