GNUnet  0.10.x
Data Structures | Macros | Functions | Variables
gnunet-daemon-hostlist_server.c File Reference

application to provide an integrated hostlist HTTP server More...

#include "platform.h"
#include <microhttpd.h>
#include "gnunet-daemon-hostlist_server.h"
#include "gnunet_hello_lib.h"
#include "gnunet_peerinfo_service.h"
#include "gnunet-daemon-hostlist.h"
#include "gnunet_resolver_service.h"
Include dependency graph for gnunet-daemon-hostlist_server.c:

Go to the source code of this file.

Data Structures

struct  HostSet
 Context for host_processor(). More...
 

Macros

#define GNUNET_ADV_TIMEOUT   GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5)
 How long until our hostlist advertisment transmission via CORE should time out? More...
 

Functions

static void add_cors_headers (struct MHD_Response *response)
 Add headers to a request indicating that we allow Cross-Origin Resource Sharing. More...
 
static void finish_response ()
 Function that assembles our response. More...
 
static int check_has_addr (void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
 Set cls to GNUNET_YES (we have an address!). More...
 
static void host_processor (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg)
 Callback that processes each of the known HELLOs for the hostlist response construction. More...
 
static int accept_policy_callback (void *cls, const struct sockaddr *addr, socklen_t addrlen)
 Hostlist access policy (very permissive, allows everything). More...
 
static int access_handler_callback (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **con_cls)
 Main request handler. More...
 
static void adv_transmit (struct GNUNET_MQ_Handle *mq)
 Handler called by CORE when CORE is ready to transmit message. More...
 
static void * connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
 Method called whenever a given peer connects. More...
 
static void process_notify (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg)
 PEERINFO calls this function to let us know about a possible peer that we might want to connect to. More...
 
static struct GNUNET_SCHEDULER_Taskprepare_daemon (struct MHD_Daemon *daemon_handle)
 Function that queries MHD's select sets and starts the task waiting for them. More...
 
static void run_daemon (void *cls)
 Call MHD to process pending requests and then go back and schedule the next run. More...
 
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. More...
 
void GNUNET_HOSTLIST_server_stop ()
 Stop server offering our hostlist. More...
 

Variables

static struct MHD_Daemon * daemon_handle_v6
 Handle to the HTTP server as provided by libmicrohttpd for IPv6. More...
 
static struct MHD_Daemon * daemon_handle_v4
 Handle to the HTTP server as provided by libmicrohttpd for IPv4. More...
 
static const struct GNUNET_CONFIGURATION_Handlecfg
 Our configuration. More...
 
static struct GNUNET_STATISTICS_Handlestats
 For keeping statistics. More...
 
static struct GNUNET_CORE_Handlecore
 Handle to the core service (NULL until we've connected to it). More...
 
static struct GNUNET_PEERINFO_NotifyContextnotify
 Handle to the peerinfo notify service (NULL until we've connected to it). More...
 
static struct GNUNET_SCHEDULER_Taskhostlist_task_v4
 Our primary task for IPv4. More...
 
static struct GNUNET_SCHEDULER_Taskhostlist_task_v6
 Our primary task for IPv6. More...
 
static struct MHD_Response * response
 Our canonical response. More...
 
static struct GNUNET_PEERINFO_Handlepeerinfo
 Handle for accessing peerinfo service. More...
 
static int advertising
 Set if we are allowed to advertise our hostlist to others. More...
 
static char * hostlist_uri
 Buffer for the hostlist address. More...
 
static struct HostSetbuilder
 NULL if we are not currenlty iterating over peer information. More...
 

Detailed Description

application to provide an integrated hostlist HTTP server

Author
Christian Grothoff
Matthias Wachs
David Barksdale

Definition in file gnunet-daemon-hostlist_server.c.

Macro Definition Documentation

◆ GNUNET_ADV_TIMEOUT

#define GNUNET_ADV_TIMEOUT   GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5)

How long until our hostlist advertisment transmission via CORE should time out?

Definition at line 41 of file gnunet-daemon-hostlist_server.c.

Function Documentation

◆ add_cors_headers()

static void add_cors_headers ( struct MHD_Response *  response)
static

Add headers to a request indicating that we allow Cross-Origin Resource Sharing.

Parameters
responseresponse to add headers to

Definition at line 140 of file gnunet-daemon-hostlist_server.c.

Referenced by access_handler_callback(), and finish_response().

141 {
142  MHD_add_response_header(response, "Access-Control-Allow-Origin", "*");
143  MHD_add_response_header(response,
144  "Access-Control-Allow-Methods",
145  "GET, OPTIONS");
146  MHD_add_response_header(response, "Access-Control-Max-Age", "86400");
147 }
static struct MHD_Response * response
Our canonical response.
Here is the caller graph for this function:

◆ finish_response()

static void finish_response ( )
static

Function that assembles our response.

Definition at line 154 of file gnunet-daemon-hostlist_server.c.

References add_cors_headers(), daemon_handle_v4, daemon_handle_v6, HostSet::data, gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_STATISTICS_set(), GNUNET_YES, response, and HostSet::size.

Referenced by host_processor().

155 {
156  if (NULL != response)
157  MHD_destroy_response(response);
159  "Creating hostlist response with %u bytes\n",
160  (unsigned int)builder->size);
161  response = MHD_create_response_from_buffer(builder->size,
162  builder->data,
163  MHD_RESPMEM_MUST_FREE);
165  if ((NULL == daemon_handle_v4) && (NULL == daemon_handle_v6))
166  {
167  MHD_destroy_response(response);
168  response = NULL;
169  }
171  gettext_noop("bytes in hostlist"),
172  builder->size,
173  GNUNET_YES);
175  builder = NULL;
176 }
static struct GNUNET_STATISTICS_Handle * stats
For keeping statistics.
unsigned int size
Number of bytes in data.
static void add_cors_headers(struct MHD_Response *response)
Add headers to a request indicating that we allow Cross-Origin Resource Sharing.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
static struct MHD_Daemon * daemon_handle_v6
Handle to the HTTP server as provided by libmicrohttpd for IPv6.
#define GNUNET_log(kind,...)
static struct MHD_Response * response
Our canonical response.
#define GNUNET_YES
Definition: gnunet_common.h:77
char * data
Place where we accumulate all of the HELLO messages.
static struct MHD_Daemon * daemon_handle_v4
Handle to the HTTP server as provided by libmicrohttpd for IPv4.
static struct HostSet * builder
NULL if we are not currenlty iterating over peer information.
#define GNUNET_free(ptr)
Wrapper around free.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_has_addr()

static int check_has_addr ( void *  cls,
const struct GNUNET_HELLO_Address address,
struct GNUNET_TIME_Absolute  expiration 
)
static

Set cls to GNUNET_YES (we have an address!).

Parameters
clsclosure, an int *
addressthe address (ignored)
expirationexpiration time (call is ignored if this is in the past)
Returns
GNUNET_SYSERR to stop iterating (unless expiration has occured)

Definition at line 188 of file gnunet-daemon-hostlist_server.c.

References find_typedefs::arg, gettext_noop, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_remaining(), and GNUNET_YES.

Referenced by host_processor().

191 {
192  int *arg = cls;
193 
194  if (0 == GNUNET_TIME_absolute_get_remaining(expiration).rel_value_us)
195  {
197  gettext_noop("expired addresses encountered"),
198  1,
199  GNUNET_YES);
200  return GNUNET_YES; /* ignore this address */
201  }
202  *arg = GNUNET_YES;
203  return GNUNET_SYSERR;
204 }
static struct GNUNET_STATISTICS_Handle * stats
For keeping statistics.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:331
#define GNUNET_YES
Definition: gnunet_common.h:77
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ host_processor()

static void host_processor ( void *  cls,
const struct GNUNET_PeerIdentity peer,
const struct GNUNET_HELLO_Message hello,
const char *  err_msg 
)
static

Callback that processes each of the known HELLOs for the hostlist response construction.

Parameters
clsclosure, NULL
peerid of the peer, NULL for last call
hellohello message for the peer (can be NULL)
err_msgmessage

Definition at line 217 of file gnunet-daemon-hostlist_server.c.

References _, check_has_addr(), HostSet::data, finish_response(), gettext_noop, GNUNET_array_grow, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_free_non_null, GNUNET_HELLO_iterate_addresses(), GNUNET_HELLO_size(), GNUNET_i2s(), GNUNET_log, GNUNET_MAX_MALLOC_CHECKED, GNUNET_memcpy, GNUNET_NO, GNUNET_STATISTICS_update(), MAX_BYTES_PER_HOSTLISTS, HostSet::pitr, and HostSet::size.

Referenced by process_notify().

221 {
222  size_t old;
223  size_t s;
224  int has_addr;
225 
226  if (NULL != err_msg)
227  {
228  GNUNET_assert(NULL == peer);
229  builder->pitr = NULL;
232  builder = NULL;
234  _("Error in communication with PEERINFO service: %s\n"),
235  err_msg);
236  return;
237  }
238  if (NULL == peer)
239  {
240  builder->pitr = NULL;
241  finish_response();
242  return;
243  }
244  if (NULL == hello)
245  return;
246  has_addr = GNUNET_NO;
248  if (GNUNET_NO == has_addr)
249  {
251  "HELLO for peer `%4s' has no address, not suitable for hostlist!\n",
252  GNUNET_i2s(peer));
254  gettext_noop(
255  "HELLOs without addresses encountered (ignored)"),
256  1,
257  GNUNET_NO);
258  return;
259  }
260  old = builder->size;
261  s = GNUNET_HELLO_size(hello);
263  "Received %u bytes of `%s' from peer `%s' for hostlist.\n",
264  (unsigned int)s,
265  "HELLO",
266  GNUNET_i2s(peer));
267  if ((old + s >= GNUNET_MAX_MALLOC_CHECKED) ||
268  (old + s >= MAX_BYTES_PER_HOSTLISTS))
269  {
270  /* too large, skip! */
272  gettext_noop(
273  "bytes not included in hostlist (size limit)"),
274  s,
275  GNUNET_NO);
276  return;
277  }
279  "Adding peer `%s' to hostlist (%u bytes)\n",
280  GNUNET_i2s(peer),
281  (unsigned int)s);
283  GNUNET_memcpy(&builder->data[old], hello, s);
284 }
static int check_has_addr(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Set cls to GNUNET_YES (we have an address!).
#define MAX_BYTES_PER_HOSTLISTS
How many bytes do we download at most from a hostlist server?
static struct GNUNET_STATISTICS_Handle * stats
For keeping statistics.
struct GNUNET_PEERINFO_IteratorContext * pitr
Iterator used to build data (NULL when done).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
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.
Definition: hello.c:252
static void finish_response()
Function that assembles our response.
unsigned int size
Number of bytes in data.
#define GNUNET_MAX_MALLOC_CHECKED
Maximum allocation with GNUNET_malloc macro.
#define GNUNET_log(kind,...)
uint16_t GNUNET_HELLO_size(const struct GNUNET_HELLO_Message *hello)
Return the size of the given HELLO message.
Definition: hello.c:643
char * data
Place where we accumulate all of the HELLO messages.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static struct HostSet * builder
NULL if we are not currenlty iterating over peer information.
#define GNUNET_free(ptr)
Wrapper around free.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ accept_policy_callback()

static int accept_policy_callback ( void *  cls,
const struct sockaddr *  addr,
socklen_t  addrlen 
)
static

Hostlist access policy (very permissive, allows everything).

Returns #MHD_NO only if we are not yet ready to serve.

Parameters
clsclosure
addraddress information from the client
addrlenlength of addr
Returns
#MHD_YES if connection is allowed, #MHD_NO if not (we are not ready)

Definition at line 297 of file gnunet-daemon-hostlist_server.c.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and response.

Referenced by GNUNET_HOSTLIST_server_start().

300 {
301  if (NULL == response)
302  {
303  GNUNET_log(
305  "Received request for hostlist, but I am not yet ready; rejecting!\n");
306  return MHD_NO;
307  }
308  return MHD_YES; /* accept all */
309 }
#define GNUNET_log(kind,...)
static struct MHD_Response * response
Our canonical response.
Here is the caller graph for this function:

◆ access_handler_callback()

static int access_handler_callback ( void *  cls,
struct MHD_Connection *  connection,
const char *  url,
const char *  method,
const char *  version,
const char *  upload_data,
size_t *  upload_data_size,
void **  con_cls 
)
static

Main request handler.

Parameters
clsargument given together with the function pointer when the handler was registered with MHD
connection
urlthe requested url
methodthe HTTP method used (#MHD_HTTP_METHOD_GET, #MHD_HTTP_METHOD_PUT, etc.)
versionthe HTTP version string (i.e. #MHD_HTTP_VERSION_1_1)
upload_datathe data being uploaded (excluding HEADERS, for a POST that fits into memory and that is encoded with a supported encoding, the POST data will NOT be given in upload_data and is instead available as part of #MHD_get_connection_values; very large POST data will be made available incrementally in upload_data)
upload_data_sizeset initially to the size of the upload_data provided; the method must update this value to the number of bytes NOT processed;
con_clspointer that the callback can set to some address and that will be preserved by MHD for future calls for this request; since the access handler may be called many times (i.e., for a PUT/POST operation with plenty of upload data) this allows the application to easily associate some request-specific state. If necessary, this state can be cleaned up in the global #MHD_RequestCompletedCallback (which can be set with the #MHD_OPTION_NOTIFY_COMPLETED). Initially, *con_cls will be NULL.
Returns
#MHD_YES if the connection was handled successfully, #MHD_NO if the socket must be closed due to a serios error while handling the request

Definition at line 348 of file gnunet-daemon-hostlist_server.c.

References _, add_cors_headers(), dummy, gettext_noop, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_STATISTICS_update(), GNUNET_YES, and response.

Referenced by GNUNET_HOSTLIST_server_start().

356 {
357  static int dummy;
358 
359  /* CORS pre-flight request */
360  if (0 == strcmp(MHD_HTTP_METHOD_OPTIONS, method))
361  {
362  struct MHD_Response *options_response;
363  int rc;
364 
365  options_response =
366  MHD_create_response_from_buffer(0, NULL, MHD_RESPMEM_PERSISTENT);
367  add_cors_headers(options_response);
368  rc = MHD_queue_response(connection, MHD_HTTP_OK, options_response);
369  MHD_destroy_response(options_response);
370  return rc;
371  }
372  if (0 != strcmp(method, MHD_HTTP_METHOD_GET))
373  {
375  _("Refusing `%s' request to hostlist server\n"),
376  method);
378  gettext_noop(
379  "hostlist requests refused (not HTTP GET)"),
380  1,
381  GNUNET_YES);
382  return MHD_NO;
383  }
384  if (NULL == *con_cls)
385  {
386  (*con_cls) = &dummy;
387  return MHD_YES;
388  }
389  if (0 != *upload_data_size)
390  {
392  _("Refusing `%s' request with %llu bytes of upload data\n"),
393  method,
394  (unsigned long long)*upload_data_size);
396  gettext_noop(
397  "hostlist requests refused (upload data)"),
398  1,
399  GNUNET_YES);
400  return MHD_NO; /* do not support upload data */
401  }
402  if (NULL == response)
403  {
404  GNUNET_log(
406  _(
407  "Could not handle hostlist request since I do not have a response yet\n"));
409  gettext_noop(
410  "hostlist requests refused (not ready)"),
411  1,
412  GNUNET_YES);
413  return MHD_NO; /* internal error, no response yet */
414  }
416  _("Received request for our hostlist\n"));
418  gettext_noop("hostlist requests processed"),
419  1,
420  GNUNET_YES);
421  return MHD_queue_response(connection, MHD_HTTP_OK, response);
422 }
static struct GNUNET_STATISTICS_Handle * stats
For keeping statistics.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static void add_cors_headers(struct MHD_Response *response)
Add headers to a request indicating that we allow Cross-Origin Resource Sharing.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
#define GNUNET_log(kind,...)
static struct MHD_Response * response
Our canonical response.
#define GNUNET_YES
Definition: gnunet_common.h:77
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ adv_transmit()

static void adv_transmit ( struct GNUNET_MQ_Handle mq)
static

Handler called by CORE when CORE is ready to transmit message.

Parameters
clsclosure with the const struct GNUNET_PeerIdentity * of the peer we are sending to
sizesize of buffer to copy message to
bufbuffer to copy message to
Returns
number of bytes copied to buf

Definition at line 435 of file gnunet-daemon-hostlist_server.c.

References env, gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT, GNUNET_MQ_env_set_options(), GNUNET_MQ_msg_extra, GNUNET_MQ_PREF_CORK_ALLOWED, GNUNET_MQ_PREF_UNRELIABLE, GNUNET_MQ_send(), GNUNET_NO, GNUNET_STATISTICS_update(), and hostlist_uri.

Referenced by connect_handler().

436 {
437  static uint64_t hostlist_adv_count;
438  size_t uri_size; /* Including \0 termination! */
439  struct GNUNET_MessageHeader *header;
440  struct GNUNET_MQ_Envelope *env;
441 
442  uri_size = strlen(hostlist_uri) + 1;
443  env = GNUNET_MQ_msg_extra(header,
444  uri_size,
446  GNUNET_memcpy(&header[1], hostlist_uri, uri_size);
450  GNUNET_MQ_send(mq, env);
452  "Sent advertisement message: Copied %u bytes into buffer!\n",
453  (unsigned int)uri_size);
454  hostlist_adv_count++;
456  " # Sent advertisement message: %llu\n",
457  (unsigned long long)hostlist_adv_count);
459  gettext_noop("# hostlist advertisements send"),
460  1,
461  GNUNET_NO);
462 }
static struct GNUNET_STATISTICS_Handle * stats
For keeping statistics.
void GNUNET_MQ_env_set_options(struct GNUNET_MQ_Envelope *env, enum GNUNET_MQ_PriorityPreferences pp)
Set application-specific options for this envelope.
Definition: mq.c:1002
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_NO
Definition: gnunet_common.h:78
static char * hostlist_uri
Buffer for the hostlist address.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_log(kind,...)
#define GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT
Further X-VINE DHT messages continued from 880.
Flag to indicate that CORKing is acceptable.
Header for all communications.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:351
Flag to indicate that unreliable delivery is acceptable.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ connect_handler()

static void* connect_handler ( void *  cls,
const struct GNUNET_PeerIdentity peer,
struct GNUNET_MQ_Handle mq 
)
static

Method called whenever a given peer connects.

Parameters
clsclosure
peerpeer identity this notification is about
mqqueue for transmission to peer
Returns
NULL (must!)

Definition at line 474 of file gnunet-daemon-hostlist_server.c.

References adv_transmit(), advertising, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, hostlist_uri, and HostSet::size.

Referenced by GNUNET_HOSTLIST_server_start().

477 {
478  size_t size;
479 
480  if (!advertising)
481  return NULL;
482  if (NULL == hostlist_uri)
483  return NULL;
484  size = strlen(hostlist_uri) + 1;
485  if (size + sizeof(struct GNUNET_MessageHeader) >= GNUNET_MAX_MESSAGE_SIZE)
486  {
487  GNUNET_break(0);
488  return NULL;
489  }
490  size += sizeof(struct GNUNET_MessageHeader);
491  if (NULL == core)
492  {
493  GNUNET_break(0);
494  return NULL;
495  }
496  GNUNET_log(
498  "Asked CORE to transmit advertisement message with a size of %u bytes to peer `%s'\n",
499  (unsigned int)size,
500  GNUNET_i2s(peer));
501  adv_transmit(mq);
502  return NULL;
503 }
static void adv_transmit(struct GNUNET_MQ_Handle *mq)
Handler called by CORE when CORE is ready to transmit message.
static char * hostlist_uri
Buffer for the hostlist address.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static int advertising
Set if we are allowed to advertise our hostlist to others.
static unsigned int size
Size of the "table".
Definition: peer.c:66
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
#define GNUNET_log(kind,...)
Header for all communications.
static struct GNUNET_CORE_Handle * core
Handle to the core service (NULL until we&#39;ve connected to it).
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_notify()

static void process_notify ( void *  cls,
const struct GNUNET_PeerIdentity peer,
const struct GNUNET_HELLO_Message hello,
const char *  err_msg 
)
static

PEERINFO calls this function to let us know about a possible peer that we might want to connect to.

Parameters
clsclosure (not used)
peerpotential peer to connect to
helloHELLO for this peer (or NULL)
err_msgNULL if successful, otherwise contains error message

Definition at line 516 of file gnunet-daemon-hostlist_server.c.

References _, daemon_handle, HostSet::data, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_free_non_null, GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_PEERINFO_iterate(), GNUNET_PEERINFO_iterate_cancel(), host_processor(), HostSet::pitr, prepare_daemon(), and HostSet::size.

Referenced by GNUNET_HOSTLIST_server_start().

520 {
522  "Peerinfo is notifying us to rebuild our hostlist\n");
523  if (NULL != err_msg)
525  _("Error in communication with PEERINFO service: %s\n"),
526  err_msg);
527  if (NULL != builder)
528  {
529  /* restart re-build already in progress ... */
530  if (NULL != builder->pitr)
531  {
533  builder->pitr = NULL;
534  }
536  builder->size = 0;
537  builder->data = NULL;
538  }
539  else
540  {
541  builder = GNUNET_new(struct HostSet);
542  }
543  GNUNET_assert(NULL != peerinfo);
544  builder->pitr =
546 }
struct GNUNET_PEERINFO_IteratorContext * pitr
Iterator used to build data (NULL when done).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
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.
Definition: peerinfo_api.c:486
Context for host_processor().
void GNUNET_PEERINFO_iterate_cancel(struct GNUNET_PEERINFO_IteratorContext *ic)
Cancel an iteration over peer information.
Definition: peerinfo_api.c:519
unsigned int size
Number of bytes in data.
static struct GNUNET_PEERINFO_Handle * peerinfo
Handle for accessing peerinfo service.
static void host_processor(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg)
Callback that processes each of the known HELLOs for the hostlist response construction.
#define GNUNET_log(kind,...)
char * data
Place where we accumulate all of the HELLO messages.
static struct HostSet * builder
NULL if we are not currenlty iterating over peer information.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepare_daemon()

static struct GNUNET_SCHEDULER_Task * prepare_daemon ( struct MHD_Daemon *  daemon_handle)
static

Function that queries MHD's select sets and starts the task waiting for them.

Parameters
daemon_handleHTTP server to prepare to run

Definition at line 587 of file gnunet-daemon-hostlist_server.c.

References GNUNET_assert, GNUNET_NETWORK_fdset_copy_native(), GNUNET_NETWORK_fdset_create(), GNUNET_NETWORK_fdset_destroy(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_PRIORITY_HIGH, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_Relative::rel_value_us, ret, run_daemon(), and timeout.

Referenced by GNUNET_HOSTLIST_server_start(), process_notify(), and run_daemon().

588 {
589  struct GNUNET_SCHEDULER_Task *ret;
590  fd_set rs;
591  fd_set ws;
592  fd_set es;
593  struct GNUNET_NETWORK_FDSet *wrs;
594  struct GNUNET_NETWORK_FDSet *wws;
595  int max;
596  MHD_UNSIGNED_LONG_LONG timeout;
597  int haveto;
598  struct GNUNET_TIME_Relative tv;
599 
600  FD_ZERO(&rs);
601  FD_ZERO(&ws);
602  FD_ZERO(&es);
605  max = -1;
606  GNUNET_assert(MHD_YES == MHD_get_fdset(daemon_handle, &rs, &ws, &es, &max));
607  haveto = MHD_get_timeout(daemon_handle, &timeout);
608  if (haveto == MHD_YES)
609  tv.rel_value_us = (uint64_t)timeout * 1000LL;
610  else
612  GNUNET_NETWORK_fdset_copy_native(wrs, &rs, max + 1);
613  GNUNET_NETWORK_fdset_copy_native(wws, &ws, max + 1);
615  tv,
616  wrs,
617  wws,
618  &run_daemon,
619  daemon_handle);
622  return ret;
623 }
static struct MHD_Daemon * daemon_handle
Handle to the HTTP server as provided by libmicrohttpd.
Definition: gnunet-bcd.c:46
Run with high priority (important requests).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static int ret
Final status code.
Definition: gnunet-arm.c:89
void GNUNET_NETWORK_fdset_copy_native(struct GNUNET_NETWORK_FDSet *to, const fd_set *from, int nfds)
Copy a native fd set into the GNUnet representation.
Definition: network.c:1108
void GNUNET_NETWORK_fdset_destroy(struct GNUNET_NETWORK_FDSet *fds)
Releases the associated memory of an fd set.
Definition: network.c:1254
struct GNUNET_NETWORK_FDSet * GNUNET_NETWORK_fdset_create(void)
Creates an fd set.
Definition: network.c:1238
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:114
collection of IO descriptors
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_select(enum GNUNET_SCHEDULER_Priority prio, struct GNUNET_TIME_Relative delay, const struct GNUNET_NETWORK_FDSet *rs, const struct GNUNET_NETWORK_FDSet *ws, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when any of the specified file descriptor set...
Definition: scheduler.c:1784
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
Entry in list of pending tasks.
Definition: scheduler.c:131
static void run_daemon(void *cls)
Call MHD to process pending requests and then go back and schedule the next run.
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_daemon()

static void run_daemon ( void *  cls)
static

Call MHD to process pending requests and then go back and schedule the next run.

Parameters
clsthe struct MHD_Daemon of the HTTP server to run

Definition at line 564 of file gnunet-daemon-hostlist_server.c.

References daemon_handle, daemon_handle_v4, GNUNET_assert, and prepare_daemon().

Referenced by prepare_daemon().

565 {
566  struct MHD_Daemon *daemon_handle = cls;
567 
568  if (daemon_handle == daemon_handle_v4)
569  hostlist_task_v4 = NULL;
570  else
571  hostlist_task_v6 = NULL;
572  GNUNET_assert(MHD_YES == MHD_run(daemon_handle));
573  if (daemon_handle == daemon_handle_v4)
574  hostlist_task_v4 = prepare_daemon(daemon_handle);
575  else
576  hostlist_task_v6 = prepare_daemon(daemon_handle);
577 }
static struct MHD_Daemon * daemon_handle
Handle to the HTTP server as provided by libmicrohttpd.
Definition: gnunet-bcd.c:46
static struct GNUNET_SCHEDULER_Task * prepare_daemon(struct MHD_Daemon *daemon_handle)
Function that queries MHD&#39;s select sets and starts the task waiting for them.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_SCHEDULER_Task * hostlist_task_v6
Our primary task for IPv6.
static struct GNUNET_SCHEDULER_Task * hostlist_task_v4
Our primary task for IPv4.
static struct MHD_Daemon * daemon_handle_v4
Handle to the HTTP server as provided by libmicrohttpd for IPv4.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HOSTLIST_server_start()

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.

Parameters
cconfiguration to use
ststatistics handle to use
cocore handle to use
[out]server_chset to handler for CORE connect events
advertiseGNUNET_YES if we should advertise our hostlist
Returns
GNUNET_OK on success

Definition at line 637 of file gnunet-daemon-hostlist_server.c.

References _, accept_policy_callback(), access_handler_callback(), advertising, connect_handler(), daemon_handle_v4, daemon_handle_v6, GNUNET_asprintf(), GNUNET_break, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_have_value(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_PEERINFO_connect(), GNUNET_PEERINFO_notify(), GNUNET_RESOLVER_local_fqdn_get(), GNUNET_SYSERR, hostlist_uri, hostname, ipv4, ipv6, MAX_URL_LEN, port, prepare_daemon(), process_notify(), HostSet::size, and st.

Referenced by run().

642 {
643  unsigned long long port;
644  char *hostname;
645  char *ipv4;
646  char *ipv6;
647  size_t size;
648  struct in_addr i4;
649  struct in6_addr i6;
650  struct sockaddr_in v4;
651  struct sockaddr_in6 v6;
652  const struct sockaddr *sa4;
653  const struct sockaddr *sa6;
654 
655  advertising = advertise;
656  if (!advertising)
657  {
659  "Advertising not enabled on this hostlist server\n");
660  }
661  else
662  {
664  "Advertising enabled on this hostlist server\n");
665  }
666  cfg = c;
667  stats = st;
669  if (NULL == peerinfo)
670  {
672  _("Could not access PEERINFO service. Exiting.\n"));
673  return GNUNET_SYSERR;
674  }
676  "HOSTLIST",
677  "HTTPPORT",
678  &port))
679  return GNUNET_SYSERR;
680  if ((0 == port) || (port > UINT16_MAX))
681  {
683  _("Invalid port number %llu. Exiting.\n"),
684  port);
685  return GNUNET_SYSERR;
686  }
687 
688  if (GNUNET_SYSERR ==
690  "HOSTLIST",
691  "EXTERNAL_DNS_NAME",
692  &hostname))
693  hostname = GNUNET_RESOLVER_local_fqdn_get();
695  _("Hostlist service starts on %s:%llu\n"),
696  hostname,
697  port);
698  if (NULL != hostname)
699  {
700  size = strlen(hostname);
701  if (size + 15 > MAX_URL_LEN)
702  {
703  GNUNET_break(0);
704  }
705  else
706  {
708  "http://%s:%u/",
709  hostname,
710  (unsigned int)port);
712  _("Address to obtain hostlist: `%s'\n"),
713  hostlist_uri);
714  }
715  GNUNET_free(hostname);
716  }
717 
718  if (GNUNET_CONFIGURATION_have_value(cfg, "HOSTLIST", "BINDTOIPV4"))
719  {
721  "HOSTLIST",
722  "BINDTOIP",
723  &ipv4))
724  {
725  GNUNET_log(
727  _("BINDTOIP does not a valid IPv4 address! Ignoring BINDTOIPV4.\n"));
728  }
729  }
730  else
731  ipv4 = NULL;
732  if (GNUNET_CONFIGURATION_have_value(cfg, "HOSTLIST", "BINDTOIPV6"))
733  {
735  "HOSTLIST",
736  "BINDTOIP",
737  &ipv6))
738  {
739  GNUNET_log(
741  _("BINDTOIP does not a valid IPv4 address! Ignoring BINDTOIPV6.\n"));
742  }
743  }
744  else
745  ipv6 = NULL;
746  sa4 = NULL;
747  if (NULL != ipv4)
748  {
749  if (1 == inet_pton(AF_INET, ipv4, &i4))
750  {
751  memset(&v4, 0, sizeof(v4));
752  v4.sin_family = AF_INET;
753  v4.sin_addr = i4;
754  v4.sin_port = htons(port);
755 #if HAVE_SOCKADDR_IN_SIN_LEN
756  v4.sin_len = sizeof(v4);
757 #endif
758  sa4 = (const struct sockaddr *)&v4;
759  }
760  else
762  _(
763  "`%s' is not a valid IPv4 address! Ignoring BINDTOIPV4.\n"),
764  ipv4);
765  GNUNET_free(ipv4);
766  }
767  sa6 = NULL;
768  if (NULL != ipv6)
769  {
770  if (1 == inet_pton(AF_INET6, ipv6, &i6))
771  {
772  memset(&v6, 0, sizeof(v6));
773  v6.sin6_family = AF_INET6;
774  v6.sin6_addr = i6;
775  v6.sin6_port = htons(port);
776 #if HAVE_SOCKADDR_IN_SIN_LEN
777  v6.sin6_len = sizeof(v6);
778 #endif
779  sa6 = (const struct sockaddr *)&v6;
780  }
781  else
783  _(
784  "`%s' is not a valid IPv6 address! Ignoring BINDTOIPV6.\n"),
785  ipv6);
786  GNUNET_free(ipv6);
787  }
788 
789  daemon_handle_v6 = MHD_start_daemon(MHD_USE_IPv6 | MHD_USE_DEBUG,
790  (uint16_t)port,
792  NULL,
794  NULL,
795  MHD_OPTION_CONNECTION_LIMIT,
796  (unsigned int)128,
797  MHD_OPTION_PER_IP_CONNECTION_LIMIT,
798  (unsigned int)32,
799  MHD_OPTION_CONNECTION_TIMEOUT,
800  (unsigned int)16,
801  MHD_OPTION_CONNECTION_MEMORY_LIMIT,
802  (size_t)(16 * 1024),
803  MHD_OPTION_SOCK_ADDR,
804  sa6,
805  MHD_OPTION_END);
806  daemon_handle_v4 = MHD_start_daemon(MHD_NO_FLAG | MHD_USE_DEBUG,
807  (uint16_t)port,
809  NULL,
811  NULL,
812  MHD_OPTION_CONNECTION_LIMIT,
813  (unsigned int)128,
814  MHD_OPTION_PER_IP_CONNECTION_LIMIT,
815  (unsigned int)32,
816  MHD_OPTION_CONNECTION_TIMEOUT,
817  (unsigned int)16,
818  MHD_OPTION_CONNECTION_MEMORY_LIMIT,
819  (size_t)(16 * 1024),
820  MHD_OPTION_SOCK_ADDR,
821  sa4,
822  MHD_OPTION_END);
823 
824  if ((NULL == daemon_handle_v6) && (NULL == daemon_handle_v4))
825  {
827  _("Could not start hostlist HTTP server on port %u\n"),
828  (unsigned short)port);
829  return GNUNET_SYSERR;
830  }
831 
832  core = co;
833  *server_ch = &connect_handler;
834  if (NULL != daemon_handle_v4)
836  if (NULL != daemon_handle_v6)
839  return GNUNET_OK;
840 }
static struct GNUNET_SCHEDULER_Task * prepare_daemon(struct MHD_Daemon *daemon_handle)
Function that queries MHD&#39;s select sets and starts the task waiting for them.
#define MAX_URL_LEN
How long can hostlist URLs be?
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
struct GNUNET_PEERINFO_Handle * GNUNET_PEERINFO_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the peerinfo service.
Definition: peerinfo_api.c:128
static struct GNUNET_STATISTICS_Handle * stats
For keeping statistics.
static int ipv4
Option -4: IPv4 requested.
Definition: gnunet-vpn.c:61
static void * connect_handler(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a given peer connects.
#define GNUNET_NO
Definition: gnunet_common.h:78
static char * hostlist_uri
Buffer for the hostlist address.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static void process_notify(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg)
PEERINFO calls this function to let us know about a possible peer that we might want to connect to...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_PEERINFO_NotifyContext * GNUNET_PEERINFO_notify(const struct GNUNET_CONFIGURATION_Handle *cfg, int include_friend_only, GNUNET_PEERINFO_Processor callback, void *callback_cls)
Call a method whenever our known information about peers changes.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static struct GNUNET_SCHEDULER_Task * hostlist_task_v6
Our primary task for IPv6.
static int advertising
Set if we are allowed to advertise our hostlist to others.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
static struct GNUNET_SCHEDULER_Task * hostlist_task_v4
Our primary task for IPv4.
int GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
static struct GNUNET_PEERINFO_NotifyContext * notify
Handle to the peerinfo notify service (NULL until we&#39;ve connected to it).
char * GNUNET_RESOLVER_local_fqdn_get(void)
Get local fully qualified domain name.
static struct GNUNET_PEERINFO_Handle * peerinfo
Handle for accessing peerinfo service.
static int access_handler_callback(void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **con_cls)
Main request handler.
static int accept_policy_callback(void *cls, const struct sockaddr *addr, socklen_t addrlen)
Hostlist access policy (very permissive, allows everything).
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:66
static struct MHD_Daemon * daemon_handle_v6
Handle to the HTTP server as provided by libmicrohttpd for IPv6.
static char * hostname
Our hostname; we give this to all the peers we start.
static uint16_t port
Port number.
Definition: gnunet-bcd.c:81
#define GNUNET_log(kind,...)
static struct GNUNET_CORE_Handle * core
Handle to the core service (NULL until we&#39;ve connected to it).
static struct GNUNET_SCHEDULER_Task * st
The shutdown task.
static struct MHD_Daemon * daemon_handle_v4
Handle to the HTTP server as provided by libmicrohttpd for IPv4.
#define GNUNET_free(ptr)
Wrapper around free.
static int ipv6
Option -6: IPv6 requested.
Definition: gnunet-vpn.c:66
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_HOSTLIST_server_stop()

void GNUNET_HOSTLIST_server_stop ( void  )

Stop server offering our hostlist.

Definition at line 847 of file gnunet-daemon-hostlist_server.c.

References daemon_handle_v4, daemon_handle_v6, HostSet::data, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_free_non_null, GNUNET_log, GNUNET_PEERINFO_disconnect(), GNUNET_PEERINFO_iterate_cancel(), GNUNET_PEERINFO_notify_cancel(), GNUNET_SCHEDULER_cancel(), HostSet::pitr, and response.

Referenced by cleaning_task().

848 {
849  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Hostlist server shutdown\n");
850  if (NULL != hostlist_task_v6)
851  {
853  hostlist_task_v6 = NULL;
854  }
855  if (NULL != hostlist_task_v4)
856  {
858  hostlist_task_v4 = NULL;
859  }
860  if (NULL != daemon_handle_v4)
861  {
862  MHD_stop_daemon(daemon_handle_v4);
863  daemon_handle_v4 = NULL;
864  }
865  if (NULL != daemon_handle_v6)
866  {
867  MHD_stop_daemon(daemon_handle_v6);
868  daemon_handle_v6 = NULL;
869  }
870  if (NULL != response)
871  {
872  MHD_destroy_response(response);
873  response = NULL;
874  }
875  if (NULL != notify)
876  {
878  notify = NULL;
879  }
880  if (NULL != builder)
881  {
882  if (NULL != builder->pitr)
883  {
885  builder->pitr = NULL;
886  }
889  builder = NULL;
890  }
891  if (NULL != peerinfo)
892  {
894  peerinfo = NULL;
895  }
896  cfg = NULL;
897  stats = NULL;
898  core = NULL;
899 }
static struct GNUNET_STATISTICS_Handle * stats
For keeping statistics.
struct GNUNET_PEERINFO_IteratorContext * pitr
Iterator used to build data (NULL when done).
void GNUNET_PEERINFO_notify_cancel(struct GNUNET_PEERINFO_NotifyContext *nc)
Stop notifying about changes.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static struct GNUNET_SCHEDULER_Task * hostlist_task_v6
Our primary task for IPv6.
void GNUNET_PEERINFO_iterate_cancel(struct GNUNET_PEERINFO_IteratorContext *ic)
Cancel an iteration over peer information.
Definition: peerinfo_api.c:519
static struct GNUNET_SCHEDULER_Task * hostlist_task_v4
Our primary task for IPv4.
static struct GNUNET_PEERINFO_NotifyContext * notify
Handle to the peerinfo notify service (NULL until we&#39;ve connected to it).
static struct GNUNET_PEERINFO_Handle * peerinfo
Handle for accessing peerinfo service.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct MHD_Daemon * daemon_handle_v6
Handle to the HTTP server as provided by libmicrohttpd for IPv6.
#define GNUNET_log(kind,...)
void GNUNET_PEERINFO_disconnect(struct GNUNET_PEERINFO_Handle *h)
Disconnect from the peerinfo service.
Definition: peerinfo_api.c:154
static struct MHD_Response * response
Our canonical response.
char * data
Place where we accumulate all of the HELLO messages.
static struct GNUNET_CORE_Handle * core
Handle to the core service (NULL until we&#39;ve connected to it).
static struct MHD_Daemon * daemon_handle_v4
Handle to the HTTP server as provided by libmicrohttpd for IPv4.
static struct HostSet * builder
NULL if we are not currenlty iterating over peer information.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ daemon_handle_v6

struct MHD_Daemon* daemon_handle_v6
static

Handle to the HTTP server as provided by libmicrohttpd for IPv6.

Definition at line 48 of file gnunet-daemon-hostlist_server.c.

Referenced by finish_response(), GNUNET_HOSTLIST_server_start(), and GNUNET_HOSTLIST_server_stop().

◆ daemon_handle_v4

struct MHD_Daemon* daemon_handle_v4
static

Handle to the HTTP server as provided by libmicrohttpd for IPv4.

Definition at line 53 of file gnunet-daemon-hostlist_server.c.

Referenced by finish_response(), GNUNET_HOSTLIST_server_start(), GNUNET_HOSTLIST_server_stop(), and run_daemon().

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Our configuration.

Definition at line 58 of file gnunet-daemon-hostlist_server.c.

◆ stats

struct GNUNET_STATISTICS_Handle* stats
static

For keeping statistics.

Definition at line 63 of file gnunet-daemon-hostlist_server.c.

◆ core

struct GNUNET_CORE_Handle* core
static

Handle to the core service (NULL until we've connected to it).

Definition at line 68 of file gnunet-daemon-hostlist_server.c.

◆ notify

struct GNUNET_PEERINFO_NotifyContext* notify
static

Handle to the peerinfo notify service (NULL until we've connected to it).

Definition at line 73 of file gnunet-daemon-hostlist_server.c.

Referenced by connect_error(), envi_set_active_suggestion(), GNUNET_CONNECTION_notify_transmit_ready(), process_notify(), run(), signal_transmit_error(), transmit_ready(), and transmit_timeout().

◆ hostlist_task_v4

struct GNUNET_SCHEDULER_Task* hostlist_task_v4
static

Our primary task for IPv4.

Definition at line 78 of file gnunet-daemon-hostlist_server.c.

◆ hostlist_task_v6

struct GNUNET_SCHEDULER_Task* hostlist_task_v6
static

Our primary task for IPv6.

Definition at line 83 of file gnunet-daemon-hostlist_server.c.

◆ response

struct MHD_Response* response
static

◆ peerinfo

struct GNUNET_PEERINFO_Handle* peerinfo
static

Handle for accessing peerinfo service.

Definition at line 93 of file gnunet-daemon-hostlist_server.c.

◆ advertising

int advertising
static

Set if we are allowed to advertise our hostlist to others.

Definition at line 98 of file gnunet-daemon-hostlist_server.c.

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

◆ hostlist_uri

char* hostlist_uri
static

Buffer for the hostlist address.

Definition at line 103 of file gnunet-daemon-hostlist_server.c.

Referenced by adv_transmit(), connect_handler(), and GNUNET_HOSTLIST_server_start().

◆ builder

struct HostSet* builder
static

NULL if we are not currenlty iterating over peer information.

Definition at line 130 of file gnunet-daemon-hostlist_server.c.