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 141 of file gnunet-daemon-hostlist_server.c.

Referenced by access_handler_callback(), and finish_response().

142 {
143  MHD_add_response_header (response, "Access-Control-Allow-Origin", "*");
144  MHD_add_response_header (response,
145  "Access-Control-Allow-Methods",
146  "GET, OPTIONS");
147  MHD_add_response_header (response, "Access-Control-Max-Age", "86400");
148 }
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 155 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().

156 {
157  if (NULL != response)
158  MHD_destroy_response (response);
160  "Creating hostlist response with %u bytes\n",
161  (unsigned int) builder->size);
162  response = MHD_create_response_from_buffer (builder->size,
163  builder->data,
164  MHD_RESPMEM_MUST_FREE);
166  if ((NULL == daemon_handle_v4) && (NULL == daemon_handle_v6))
167  {
168  MHD_destroy_response (response);
169  response = NULL;
170  }
172  gettext_noop ("bytes in hostlist"),
173  builder->size,
174  GNUNET_YES);
176  builder = NULL;
177 }
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:80
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 189 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().

192 {
193  int *arg = cls;
194 
195  if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us)
196  {
198  gettext_noop ("expired addresses encountered"),
199  1,
200  GNUNET_YES);
201  return GNUNET_YES; /* ignore this address */
202  }
203  *arg = GNUNET_YES;
204  return GNUNET_SYSERR;
205 }
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:79
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:80
#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 218 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().

222 {
223  size_t old;
224  size_t s;
225  int has_addr;
226 
227  if (NULL != err_msg)
228  {
229  GNUNET_assert (NULL == peer);
230  builder->pitr = NULL;
233  builder = NULL;
235  _ ("Error in communication with PEERINFO service: %s\n"),
236  err_msg);
237  return;
238  }
239  if (NULL == peer)
240  {
241  builder->pitr = NULL;
242  finish_response ();
243  return;
244  }
245  if (NULL == hello)
246  return;
247  has_addr = GNUNET_NO;
249  if (GNUNET_NO == has_addr)
250  {
252  "HELLO for peer `%4s' has no address, not suitable for hostlist!\n",
253  GNUNET_i2s (peer));
255  gettext_noop (
256  "HELLOs without addresses encountered (ignored)"),
257  1,
258  GNUNET_NO);
259  return;
260  }
261  old = builder->size;
262  s = GNUNET_HELLO_size (hello);
264  "Received %u bytes of `%s' from peer `%s' for hostlist.\n",
265  (unsigned int) s,
266  "HELLO",
267  GNUNET_i2s (peer));
268  if ((old + s >= GNUNET_MAX_MALLOC_CHECKED) ||
269  (old + s >= MAX_BYTES_PER_HOSTLISTS))
270  {
271  /* too large, skip! */
273  gettext_noop (
274  "bytes not included in hostlist (size limit)"),
275  s,
276  GNUNET_NO);
277  return;
278  }
280  "Adding peer `%s' to hostlist (%u bytes)\n",
281  GNUNET_i2s (peer),
282  (unsigned int) s);
283  GNUNET_array_grow (builder->data, builder->size, old + s);
284  GNUNET_memcpy (&builder->data[old], hello, s);
285 }
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_NO
Definition: gnunet_common.h:81
#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:208
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
#define GNUNET_memcpy(dst, src, n)
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:254
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:649
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 298 of file gnunet-daemon-hostlist_server.c.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and response.

Referenced by GNUNET_HOSTLIST_server_start().

301 {
302  if (NULL == response)
303  {
304  GNUNET_log (
306  "Received request for hostlist, but I am not yet ready; rejecting!\n");
307  return MHD_NO;
308  }
309  return MHD_YES; /* accept all */
310 }
#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 349 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().

357 {
358  static int dummy;
359 
360  /* CORS pre-flight request */
361  if (0 == strcmp (MHD_HTTP_METHOD_OPTIONS, method))
362  {
363  struct MHD_Response *options_response;
364  int rc;
365 
366  options_response =
367  MHD_create_response_from_buffer (0, NULL, MHD_RESPMEM_PERSISTENT);
368  add_cors_headers (options_response);
369  rc = MHD_queue_response (connection, MHD_HTTP_OK, options_response);
370  MHD_destroy_response (options_response);
371  return rc;
372  }
373  if (0 != strcmp (method, MHD_HTTP_METHOD_GET))
374  {
376  _ ("Refusing `%s' request to hostlist server\n"),
377  method);
379  gettext_noop (
380  "hostlist requests refused (not HTTP GET)"),
381  1,
382  GNUNET_YES);
383  return MHD_NO;
384  }
385  if (NULL == *con_cls)
386  {
387  (*con_cls) = &dummy;
388  return MHD_YES;
389  }
390  if (0 != *upload_data_size)
391  {
393  _ ("Refusing `%s' request with %llu bytes of upload data\n"),
394  method,
395  (unsigned long long) *upload_data_size);
397  gettext_noop (
398  "hostlist requests refused (upload data)"),
399  1,
400  GNUNET_YES);
401  return MHD_NO; /* do not support upload data */
402  }
403  if (NULL == response)
404  {
405  GNUNET_log (
407  _ (
408  "Could not handle hostlist request since I do not have a response yet\n"));
410  gettext_noop (
411  "hostlist requests refused (not ready)"),
412  1,
413  GNUNET_YES);
414  return MHD_NO; /* internal error, no response yet */
415  }
417  _ ("Received request for our hostlist\n"));
419  gettext_noop ("hostlist requests processed"),
420  1,
421  GNUNET_YES);
422  return MHD_queue_response (connection, MHD_HTTP_OK, response);
423 }
static struct in_addr dummy
Target "dummy" address.
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:208
static void add_cors_headers(struct MHD_Response *response)
Add headers to a request indicating that we allow Cross-Origin Resource Sharing.
#define GNUNET_log(kind,...)
static struct MHD_Response * response
Our canonical response.
#define GNUNET_YES
Definition: gnunet_common.h:80
#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 436 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().

437 {
438  static uint64_t hostlist_adv_count;
439  size_t uri_size; /* Including \0 termination! */
440  struct GNUNET_MessageHeader *header;
441  struct GNUNET_MQ_Envelope *env;
442 
443  uri_size = strlen (hostlist_uri) + 1;
444  env = GNUNET_MQ_msg_extra (header,
445  uri_size,
447  GNUNET_memcpy (&header[1], hostlist_uri, uri_size);
451  GNUNET_MQ_send (mq, env);
453  "Sent advertisement message: Copied %u bytes into buffer!\n",
454  (unsigned int) uri_size);
455  hostlist_adv_count++;
457  " # Sent advertisement message: %llu\n",
458  (unsigned long long) hostlist_adv_count);
460  gettext_noop ("# hostlist advertisements send"),
461  1,
462  GNUNET_NO);
463 }
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:1005
#define GNUNET_NO
Definition: gnunet_common.h:81
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
#define GNUNET_memcpy(dst, src, n)
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:353
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 475 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().

478 {
479  size_t size;
480 
481  if (! advertising)
482  return NULL;
483  if (NULL == hostlist_uri)
484  return NULL;
485  size = strlen (hostlist_uri) + 1;
486  if (size + sizeof (struct GNUNET_MessageHeader) >= GNUNET_MAX_MESSAGE_SIZE)
487  {
488  GNUNET_break (0);
489  return NULL;
490  }
491  size += sizeof (struct GNUNET_MessageHeader);
492  if (NULL == core)
493  {
494  GNUNET_break (0);
495  return NULL;
496  }
497  GNUNET_log (
499  "Asked CORE to transmit advertisement message with a size of %u bytes to peer `%s'\n",
500  (unsigned int) size,
501  GNUNET_i2s (peer));
502  adv_transmit (mq);
503  return NULL;
504 }
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:67
#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 517 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().

521 {
523  "Peerinfo is notifying us to rebuild our hostlist\n");
524  if (NULL != err_msg)
526  _ ("Error in communication with PEERINFO service: %s\n"),
527  err_msg);
528  if (NULL != builder)
529  {
530  /* restart re-build already in progress ... */
531  if (NULL != builder->pitr)
532  {
534  builder->pitr = NULL;
535  }
537  builder->size = 0;
538  builder->data = NULL;
539  }
540  else
541  {
542  builder = GNUNET_new (struct HostSet);
543  }
544  GNUNET_assert (NULL != peerinfo);
545  builder->pitr =
547 }
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:81
#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:208
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:491
Context for host_processor().
void GNUNET_PEERINFO_iterate_cancel(struct GNUNET_PEERINFO_IteratorContext *ic)
Cancel an iteration over peer information.
Definition: peerinfo_api.c:524
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 588 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().

589 {
590  struct GNUNET_SCHEDULER_Task *ret;
591  fd_set rs;
592  fd_set ws;
593  fd_set es;
594  struct GNUNET_NETWORK_FDSet *wrs;
595  struct GNUNET_NETWORK_FDSet *wws;
596  int max;
597  MHD_UNSIGNED_LONG_LONG timeout;
598  int haveto;
599  struct GNUNET_TIME_Relative tv;
600 
601  FD_ZERO (&rs);
602  FD_ZERO (&ws);
603  FD_ZERO (&es);
606  max = -1;
607  GNUNET_assert (MHD_YES == MHD_get_fdset (daemon_handle, &rs, &ws, &es, &max));
608  haveto = MHD_get_timeout (daemon_handle, &timeout);
609  if (haveto == MHD_YES)
610  tv.rel_value_us = (uint64_t) timeout * 1000LL;
611  else
613  GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1);
614  GNUNET_NETWORK_fdset_copy_native (wws, &ws, max + 1);
616  tv,
617  wrs,
618  wws,
619  &run_daemon,
620  daemon_handle);
623  return ret;
624 }
static struct MHD_Daemon * daemon_handle
Handle to the HTTP server as provided by libmicrohttpd.
Definition: gnunet-bcd.c:44
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:1308
void GNUNET_NETWORK_fdset_destroy(struct GNUNET_NETWORK_FDSet *fds)
Releases the associated memory of an fd set.
Definition: network.c:1554
struct GNUNET_NETWORK_FDSet * GNUNET_NETWORK_fdset_create(void)
Creates an fd set.
Definition: network.c:1538
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:1829
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
Entry in list of pending tasks.
Definition: scheduler.c:134
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 565 of file gnunet-daemon-hostlist_server.c.

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

Referenced by prepare_daemon().

566 {
567  struct MHD_Daemon *daemon_handle = cls;
568 
569  if (daemon_handle == daemon_handle_v4)
570  hostlist_task_v4 = NULL;
571  else
572  hostlist_task_v6 = NULL;
573  GNUNET_assert (MHD_YES == MHD_run (daemon_handle));
574  if (daemon_handle == daemon_handle_v4)
575  hostlist_task_v4 = prepare_daemon (daemon_handle);
576  else
577  hostlist_task_v6 = prepare_daemon (daemon_handle);
578 }
static struct MHD_Daemon * daemon_handle
Handle to the HTTP server as provided by libmicrohttpd.
Definition: gnunet-bcd.c:44
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 638 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, inet_pton(), ipv4, ipv6, MAX_URL_LEN, port, prepare_daemon(), process_notify(), HostSet::size, and st.

Referenced by run().

643 {
644  unsigned long long port;
645  char *hostname;
646  char *ipv4;
647  char *ipv6;
648  size_t size;
649  struct in_addr i4;
650  struct in6_addr i6;
651  struct sockaddr_in v4;
652  struct sockaddr_in6 v6;
653  const struct sockaddr *sa4;
654  const struct sockaddr *sa6;
655 
656  advertising = advertise;
657  if (! advertising)
658  {
660  "Advertising not enabled on this hostlist server\n");
661  }
662  else
663  {
665  "Advertising enabled on this hostlist server\n");
666  }
667  cfg = c;
668  stats = st;
670  if (NULL == peerinfo)
671  {
673  _ ("Could not access PEERINFO service. Exiting.\n"));
674  return GNUNET_SYSERR;
675  }
677  "HOSTLIST",
678  "HTTPPORT",
679  &port))
680  return GNUNET_SYSERR;
681  if ((0 == port) || (port > UINT16_MAX))
682  {
684  _ ("Invalid port number %llu. Exiting.\n"),
685  port);
686  return GNUNET_SYSERR;
687  }
688 
689  if (GNUNET_SYSERR ==
691  "HOSTLIST",
692  "EXTERNAL_DNS_NAME",
693  &hostname))
694  hostname = GNUNET_RESOLVER_local_fqdn_get ();
696  _ ("Hostlist service starts on %s:%llu\n"),
697  hostname,
698  port);
699  if (NULL != hostname)
700  {
701  size = strlen (hostname);
702  if (size + 15 > MAX_URL_LEN)
703  {
704  GNUNET_break (0);
705  }
706  else
707  {
709  "http://%s:%u/",
710  hostname,
711  (unsigned int) port);
713  _ ("Address to obtain hostlist: `%s'\n"),
714  hostlist_uri);
715  }
716  GNUNET_free (hostname);
717  }
718 
719  if (GNUNET_CONFIGURATION_have_value (cfg, "HOSTLIST", "BINDTOIPV4"))
720  {
722  "HOSTLIST",
723  "BINDTOIP",
724  &ipv4))
725  {
726  GNUNET_log (
728  _ ("BINDTOIP does not a valid IPv4 address! Ignoring BINDTOIPV4.\n"));
729  }
730  }
731  else
732  ipv4 = NULL;
733  if (GNUNET_CONFIGURATION_have_value (cfg, "HOSTLIST", "BINDTOIPV6"))
734  {
736  "HOSTLIST",
737  "BINDTOIP",
738  &ipv6))
739  {
740  GNUNET_log (
742  _ ("BINDTOIP does not a valid IPv4 address! Ignoring BINDTOIPV6.\n"));
743  }
744  }
745  else
746  ipv6 = NULL;
747  sa4 = NULL;
748  if (NULL != ipv4)
749  {
750  if (1 == inet_pton (AF_INET, ipv4, &i4))
751  {
752  memset (&v4, 0, sizeof (v4));
753  v4.sin_family = AF_INET;
754  v4.sin_addr = i4;
755  v4.sin_port = htons (port);
756 #if HAVE_SOCKADDR_IN_SIN_LEN
757  v4.sin_len = sizeof (v4);
758 #endif
759  sa4 = (const struct sockaddr *) &v4;
760  }
761  else
763  _ (
764  "`%s' is not a valid IPv4 address! Ignoring BINDTOIPV4.\n"),
765  ipv4);
766  GNUNET_free (ipv4);
767  }
768  sa6 = NULL;
769  if (NULL != ipv6)
770  {
771  if (1 == inet_pton (AF_INET6, ipv6, &i6))
772  {
773  memset (&v6, 0, sizeof (v6));
774  v6.sin6_family = AF_INET6;
775  v6.sin6_addr = i6;
776  v6.sin6_port = htons (port);
777 #if HAVE_SOCKADDR_IN_SIN_LEN
778  v6.sin6_len = sizeof (v6);
779 #endif
780  sa6 = (const struct sockaddr *) &v6;
781  }
782  else
784  _ (
785  "`%s' is not a valid IPv6 address! Ignoring BINDTOIPV6.\n"),
786  ipv6);
787  GNUNET_free (ipv6);
788  }
789 
790  daemon_handle_v6 = MHD_start_daemon (MHD_USE_IPv6 | MHD_USE_DEBUG,
791  (uint16_t) port,
793  NULL,
795  NULL,
796  MHD_OPTION_CONNECTION_LIMIT,
797  (unsigned int) 128,
798  MHD_OPTION_PER_IP_CONNECTION_LIMIT,
799  (unsigned int) 32,
800  MHD_OPTION_CONNECTION_TIMEOUT,
801  (unsigned int) 16,
802  MHD_OPTION_CONNECTION_MEMORY_LIMIT,
803  (size_t) (16 * 1024),
804  MHD_OPTION_SOCK_ADDR,
805  sa6,
806  MHD_OPTION_END);
807  daemon_handle_v4 = MHD_start_daemon (MHD_NO_FLAG | MHD_USE_DEBUG,
808  (uint16_t) port,
810  NULL,
812  NULL,
813  MHD_OPTION_CONNECTION_LIMIT,
814  (unsigned int) 128,
815  MHD_OPTION_PER_IP_CONNECTION_LIMIT,
816  (unsigned int) 32,
817  MHD_OPTION_CONNECTION_TIMEOUT,
818  (unsigned int) 16,
819  MHD_OPTION_CONNECTION_MEMORY_LIMIT,
820  (size_t) (16 * 1024),
821  MHD_OPTION_SOCK_ADDR,
822  sa4,
823  MHD_OPTION_END);
824 
825  if ((NULL == daemon_handle_v6) && (NULL == daemon_handle_v4))
826  {
828  _ ("Could not start hostlist HTTP server on port %u\n"),
829  (unsigned short) port);
830  return GNUNET_SYSERR;
831  }
832 
833  core = co;
834  *server_ch = &connect_handler;
835  if (NULL != daemon_handle_v4)
837  if (NULL != daemon_handle_v6)
840  return GNUNET_OK;
841 }
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:133
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:81
static char * hostlist_uri
Buffer for the hostlist address.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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:208
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:79
static unsigned int size
Size of the "table".
Definition: peer.c:67
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:79
static int inet_pton(int af, const char *cp, struct in_addr *buf)
Convert IPv4 address from text to binary form.
#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 848 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().

849 {
850  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hostlist server shutdown\n");
851  if (NULL != hostlist_task_v6)
852  {
854  hostlist_task_v6 = NULL;
855  }
856  if (NULL != hostlist_task_v4)
857  {
859  hostlist_task_v4 = NULL;
860  }
861  if (NULL != daemon_handle_v4)
862  {
863  MHD_stop_daemon (daemon_handle_v4);
864  daemon_handle_v4 = NULL;
865  }
866  if (NULL != daemon_handle_v6)
867  {
868  MHD_stop_daemon (daemon_handle_v6);
869  daemon_handle_v6 = NULL;
870  }
871  if (NULL != response)
872  {
873  MHD_destroy_response (response);
874  response = NULL;
875  }
876  if (NULL != notify)
877  {
879  notify = NULL;
880  }
881  if (NULL != builder)
882  {
883  if (NULL != builder->pitr)
884  {
886  builder->pitr = NULL;
887  }
890  builder = NULL;
891  }
892  if (NULL != peerinfo)
893  {
895  peerinfo = NULL;
896  }
897  cfg = NULL;
898  stats = NULL;
899  core = NULL;
900 }
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:524
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:159
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:965
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 131 of file gnunet-daemon-hostlist_server.c.