33 #define LOG(type, ...) \
34 GNUNET_log (type, __VA_ARGS__)
39 #define LOG_DEBUG(...) \
40 LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
88 "testbed-logger-handle-log-msg",
188 if (0 != gethostname (hname,
192 "Cannot get hostname. Exiting\n");
215 LOG_DEBUG (
"TESTBED-LOGGER startup complete\n");
struct GNUNET_MQ_Handle * mq
struct GNUNET_MessageHeader * msg
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static char * dir
Set to the directory where runtime files are stored.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static int check_log_msg(void *cls, const struct GNUNET_MessageHeader *msg)
Check GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_MSG messages.
struct GNUNET_BIO_WriteHandle * bio
Handle for buffered writing.
GNUNET_SERVICE_MAIN("testbed-logger", GNUNET_SERVICE_OPTION_NONE, &logger_run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(log_msg, GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_MSG, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
static unsigned int nconn
The number of connections we have.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *c, struct GNUNET_MQ_Handle *mq)
Callback called when a client connects to the service.
static void handle_log_msg(void *cls, const struct GNUNET_MessageHeader *msg)
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_MSG messages.
static int in_shutdown
Are we shutting down?
static void shutdown_task(void *cls)
Task to clean up and shutdown nicely.
#define LOG(type,...)
Generic logging shorthand.
#define LOG_DEBUG(...)
Debug logging shorthand.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *c, void *internal_cls)
Callback called when a client disconnected from the service.
static void logger_run(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
Testbed setup.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
enum GNUNET_GenericReturnValue GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h, char **emsg)
Close an IO handle.
enum GNUNET_GenericReturnValue GNUNET_BIO_write(struct GNUNET_BIO_WriteHandle *h, const char *what, const void *buffer, size_t n)
Write a buffer to a handle.
struct GNUNET_BIO_WriteHandle * GNUNET_BIO_write_open_file(const char *fn)
Open a file for writing.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
#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.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
@ GNUNET_ERROR_TYPE_ERROR
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_OS_get_hostname_max_length()
Get maximum string length returned by gethostname()
#define GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_MSG
Message for TESTBED LOGGER.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
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_SERVICE_client_persist(struct GNUNET_SERVICE_Client *c)
Set the persist option on this client.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
Handle for buffered writing.
Handle to a message queue.
Handle to a client that is connected to a service.