GNUnet 0.26.2-113-ged4734898
 
Loading...
Searching...
No Matches
gnunet-dht-hello.c File Reference

Obtain HELLO from DHT for bootstrapping. More...

#include "platform.h"
#include "gnunet_dht_service.h"
Include dependency graph for gnunet-dht-hello.c:

Go to the source code of this file.

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "dht-clients", __VA_ARGS__)
 

Functions

static void cleanup_task (void *cls)
 Task run to clean up on shutdown.
 
static void hello_done_cb (void *cls)
 Task run when we are finished.
 
static void hello_result_cb (void *cls, const char *url)
 Function called on our HELLO.
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Main function that will be run by the scheduler.
 
int main (int argc, char *const *argv)
 Entry point for gnunet-dht-hello.
 

Variables

static struct GNUNET_DHT_Handledht_handle
 Handle to the DHT.
 
static struct GNUNET_DHT_HelloGetHandleget_hello_handle
 Handle to the DHT hello get operation.
 
static int global_ret
 Global status value.
 

Detailed Description

Obtain HELLO from DHT for bootstrapping.

Author
Christian Grothoff

Definition in file gnunet-dht-hello.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "dht-clients", __VA_ARGS__)

Definition at line 28 of file gnunet-dht-hello.c.

Function Documentation

◆ cleanup_task()

static void cleanup_task ( void *  cls)
static

Task run to clean up on shutdown.

Parameters
clsunused

Definition at line 52 of file gnunet-dht-hello.c.

53{
54 if (NULL != get_hello_handle)
55 {
57 get_hello_handle = NULL;
58 }
59 if (NULL != dht_handle)
60 {
62 dht_handle = NULL;
63 }
64}
static struct GNUNET_DHT_Handle * dht_handle
Handle to the DHT.
static struct GNUNET_DHT_HelloGetHandle * get_hello_handle
Handle to the DHT hello get operation.
void GNUNET_DHT_hello_get_cancel(struct GNUNET_DHT_HelloGetHandle *hgh)
Cancel hello get operation.
Definition dht_api.c:1470
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition dht_api.c:1059

References dht_handle, get_hello_handle, GNUNET_DHT_disconnect(), and GNUNET_DHT_hello_get_cancel().

Here is the call graph for this function:

◆ hello_done_cb()

static void hello_done_cb ( void *  cls)
static

Task run when we are finished.

Triggers shutdown.

Parameters
clsunused

Definition at line 73 of file gnunet-dht-hello.c.

74{
76}
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition scheduler.c:572

References GNUNET_SCHEDULER_shutdown().

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hello_result_cb()

static void hello_result_cb ( void *  cls,
const char *  url 
)
static

Function called on our HELLO.

Parameters
clsclosure
urlthe HELLO URL

Definition at line 86 of file gnunet-dht-hello.c.

88{
89 get_hello_handle = NULL;
90 if (NULL != url)
91 fprintf (stdout,
92 "%s\n",
93 url);
95}

References get_hello_handle, and GNUNET_SCHEDULER_shutdown().

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Main function that will be run by the scheduler.

Parameters
clsclosure, NULL
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cfgconfiguration

Definition at line 107 of file gnunet-dht-hello.c.

111{
112 (void) cls;
113 (void) cfgfile;
115 NULL);
116 if (NULL == (dht_handle = GNUNET_DHT_connect (cfg,
117 1)))
118 {
119 fprintf (stderr,
120 _ ("Failed to connect to DHT service!\n"));
123 return;
124 }
125 if (NULL == args[0])
126 {
129 NULL);
131 }
132 else
133 {
135 args[0],
137 NULL);
138 }
139}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
static int global_ret
Global status value.
static void hello_done_cb(void *cls)
Task run when we are finished.
static void hello_result_cb(void *cls, const char *url)
Function called on our HELLO.
static struct GNUNET_SCHEDULER_Task * cleanup_task
Cleanup task.
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
Definition dht_api.c:1036
struct GNUNET_DHT_HelloGetHandle * GNUNET_DHT_hello_get(struct GNUNET_DHT_Handle *dht_handle, GNUNET_DHT_HelloGetCallback cb, void *cb_cls)
Obtain HELLO URL of the DHT identified by dht_handle.
Definition dht_api.c:1446
void GNUNET_DHT_hello_offer(struct GNUNET_DHT_Handle *dht_handle, const char *url, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Offer HELLO URL of the DHT identified by dht_handle.
Definition dht_api.c:1482
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
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,...
Definition scheduler.c:1345
#define _(String)
GNU gettext support macro.
Definition platform.h:179
#define EXIT_NOTCONFIGURED
Definition platform.h:270

References _, cfg, cleanup_task, dht_handle, EXIT_NOTCONFIGURED, get_hello_handle, global_ret, GNUNET_break, GNUNET_DHT_connect(), GNUNET_DHT_hello_get(), GNUNET_DHT_hello_offer(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), hello_done_cb(), and hello_result_cb().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

Entry point for gnunet-dht-hello.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 150 of file gnunet-dht-hello.c.

152{
155 };
157
158 iret = GNUNET_PROGRAM_run (
160 argc,
161 argv,
162 "gnunet-dht-hello [URL]",
164 "Obtain HELLO from DHT or provide HELLO to DHT for bootstrapping"),
165 options,
166 &run,
167 NULL);
168 if (GNUNET_SYSERR == iret)
169 return EXIT_FAILURE;
170 if (GNUNET_NO == iret)
171 return EXIT_SUCCESS;
172 return global_ret;
173}
struct GNUNET_GETOPT_CommandLineOption options[]
Definition 002.c:5
#define gettext_noop(String)
Definition gettext.h:74
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run by the scheduler.
#define GNUNET_GETOPT_OPTION_END
Marker for the end of the list of options.
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_NO
@ GNUNET_SYSERR
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, 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,...
Definition program.c:407
Definition of a command line option.

References gettext_noop, global_ret, GNUNET_GETOPT_OPTION_END, GNUNET_NO, GNUNET_OS_project_data_gnunet(), GNUNET_PROGRAM_run(), GNUNET_SYSERR, options, and run().

Here is the call graph for this function:

Variable Documentation

◆ dht_handle

struct GNUNET_DHT_Handle* dht_handle
static

Handle to the DHT.

Definition at line 33 of file gnunet-dht-hello.c.

Referenced by cleanup_task(), and run().

◆ get_hello_handle

struct GNUNET_DHT_HelloGetHandle* get_hello_handle
static

Handle to the DHT hello get operation.

Definition at line 38 of file gnunet-dht-hello.c.

Referenced by cleanup_task(), hello_result_cb(), and run().

◆ global_ret

int global_ret
static

Global status value.

Definition at line 43 of file gnunet-dht-hello.c.

Referenced by main(), main(), and run().