GNUnet  0.10.x
Typedefs | Functions
gnunet-service-transport_hello.h File Reference

hello API More...

#include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_lib.h"
Include dependency graph for gnunet-service-transport_hello.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* GST_HelloCallback) (void *cls, const struct GNUNET_MessageHeader *hello)
 Signature of a function to call whenever our hello changes. More...
 

Functions

void GST_hello_start (int friend_only, GST_HelloCallback cb, void *cb_cls)
 Initialize the HELLO module. More...
 
void GST_hello_stop (void)
 Shutdown the HELLO module. More...
 
const struct GNUNET_MessageHeaderGST_hello_get (void)
 Obtain this peers HELLO message. More...
 
void GST_hello_modify_addresses (int addremove, const struct GNUNET_HELLO_Address *address)
 Add or remove an address from this peer's HELLO message. More...
 
int GST_hello_test_address (const struct GNUNET_HELLO_Address *address, struct GNUNET_CRYPTO_EddsaSignature **sig, struct GNUNET_TIME_Absolute **sig_expiration)
 Test if a particular address is one of ours. More...
 

Detailed Description

hello API

Author
Christian Grothoff

Definition in file gnunet-service-transport_hello.h.

Typedef Documentation

◆ GST_HelloCallback

typedef void(* GST_HelloCallback) (void *cls, const struct GNUNET_MessageHeader *hello)

Signature of a function to call whenever our hello changes.

Parameters
clsclosure
helloupdated HELLO

Definition at line 41 of file gnunet-service-transport_hello.h.

Function Documentation

◆ GST_hello_start()

void GST_hello_start ( int  friend_only,
GST_HelloCallback  cb,
void *  cb_cls 
)

Initialize the HELLO module.

Parameters
friend_onlyuse a friend only hello
cbfunction to call whenever our HELLO changes
cb_clsclosure for cb

Definition at line 234 of file gnunet-service-transport_hello.c.

References friend_option, hello_cb, hello_cb_cls, and refresh_hello_task().

Referenced by run().

237 {
238  hello_cb = cb;
239  hello_cb_cls = cb_cls;
240  friend_option = friend_only;
241  refresh_hello_task(NULL);
242 }
static int friend_option
Should we use a friend-only HELLO?
static void refresh_hello_task(void *cls)
Construct our HELLO message from all of the addresses of all of the transports.
static GST_HelloCallback hello_cb
Function to call on HELLO changes.
static void * hello_cb_cls
Closure for hello_cb.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_hello_stop()

void GST_hello_stop ( void  )

Shutdown the HELLO module.

Definition at line 249 of file gnunet-service-transport_hello.c.

References GNUNET_free, GNUNET_SCHEDULER_cancel(), hello_cb, and hello_cb_cls.

Referenced by shutdown_task().

250 {
251  hello_cb = NULL;
252  hello_cb_cls = NULL;
253  if (NULL != hello_task)
254  {
256  hello_task = NULL;
257  }
258  if (NULL != our_hello)
259  {
261  our_hello = NULL;
262  }
263 }
static struct GNUNET_HELLO_Message * our_hello
Our HELLO message.
static GST_HelloCallback hello_cb
Function to call on HELLO changes.
static void * hello_cb_cls
Closure for hello_cb.
static struct GNUNET_SCHEDULER_Task * hello_task
Identifier of refresh_hello_task().
#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:

◆ GST_hello_get()

const struct GNUNET_MessageHeader* GST_hello_get ( void  )

Obtain this peers HELLO message.

Returns
our HELLO message

Definition at line 272 of file gnunet-service-transport_hello.c.

References our_hello.

Referenced by GST_plugins_load(), handle_client_start(), refresh_hello_task(), and transmit_ping_if_allowed().

273 {
274  return (const struct GNUNET_MessageHeader *)our_hello;
275 }
static struct GNUNET_HELLO_Message * our_hello
Our HELLO message.
Header for all communications.
Here is the caller graph for this function:

◆ GST_hello_modify_addresses()

void GST_hello_modify_addresses ( int  addremove,
const struct GNUNET_HELLO_Address address 
)

Add or remove an address from this peer's HELLO message.

Parameters
addremoveGNUNET_YES to add, GNUNET_NO to remove
addressaddress to add or remove

Definition at line 285 of file gnunet-service-transport_hello.c.

References OwnAddressList::address, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_HELLO_address_cmp(), GNUNET_HELLO_address_copy(), GNUNET_HELLO_address_free, GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_YES, GST_plugins_a2s(), OwnAddressList::next, OwnAddressList::rc, and refresh_hello().

Referenced by plugin_env_address_change_notification().

287 {
288  struct OwnAddressList *al;
289 
291  (GNUNET_YES == addremove)
292  ? "Adding `%s' to the set of our addresses\n"
293  : "Removing `%s' from the set of our addresses\n",
294  GST_plugins_a2s(address));
295  GNUNET_assert(NULL != address);
296  for (al = oal_head; al != NULL; al = al->next)
297  if (0 == GNUNET_HELLO_address_cmp(address, al->address))
298  break;
299  if (GNUNET_NO == addremove)
300  {
301  if (NULL == al)
302  {
303  /* address to be removed not found!? */
304  GNUNET_break(0);
305  return;
306  }
307  al->rc--;
308  if (0 != al->rc)
309  return; /* RC not yet zero */
311  oal_tail,
312  al);
314  GNUNET_free(al);
315  refresh_hello();
316  return;
317  }
318  if (NULL != al)
319  {
320  /* address added twice or more */
321  al->rc++;
322  return;
323  }
324  al = GNUNET_new(struct OwnAddressList);
325  al->rc = 1;
327  oal_tail,
328  al);
329  al->address = GNUNET_HELLO_address_copy(address);
330  refresh_hello();
331 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct OwnAddressList * next
This is a doubly-linked list.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void refresh_hello()
Schedule task to refresh hello (but only if such a task exists already, as otherwise the module might...
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
Definition: address.c:130
static struct OwnAddressList * oal_tail
Tail of my addresses.
const char * GST_plugins_a2s(const struct GNUNET_HELLO_Address *address)
Convert a given address to a human-readable format.
static struct OwnAddressList * oal_head
Head of my addresses.
struct GNUNET_HELLO_Address * address
The address.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:109
#define GNUNET_log(kind,...)
Entry in linked list of network addresses for ourselves.
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_HELLO_address_free(addr)
Free an address.
unsigned int rc
How often has this address been added/removed? Used as some plugins may learn the same external addre...
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_hello_test_address()

int GST_hello_test_address ( const struct GNUNET_HELLO_Address address,
struct GNUNET_CRYPTO_EddsaSignature **  sig,
struct GNUNET_TIME_Absolute **  sig_expiration 
)

Test if a particular address is one of ours.

Parameters
addressthe address to test
siglocation where to cache PONG signatures for this address [set]
sig_expirationhow long until the current 'sig' expires? (ZERO if sig was never created) [set]
Returns
GNUNET_YES if this is one of our addresses, GNUNET_NO if not
Parameters
addressaddress to test
siglocation where to cache PONG signatures for this address [set]
sig_expirationhow long until the current 'sig' expires? (ZERO if sig was never created) [set]
Returns
GNUNET_YES if this is one of our addresses, GNUNET_NO if not

Definition at line 345 of file gnunet-service-transport_hello.c.

References OwnAddressList::address, GNUNET_HELLO_address_cmp(), GNUNET_NO, GNUNET_YES, OwnAddressList::next, OwnAddressList::pong_sig_expires, and OwnAddressList::pong_signature.

Referenced by GST_validation_handle_ping().

348 {
349  struct OwnAddressList *al;
350 
351  for (al = oal_head; al != NULL; al = al->next)
352  if (0 == GNUNET_HELLO_address_cmp(address,
353  al->address))
354  {
355  *sig = &al->pong_signature;
356  *sig_expiration = &al->pong_sig_expires;
357  return GNUNET_YES;
358  }
359  *sig = NULL;
360  *sig_expiration = NULL;
361  return GNUNET_NO;
362 }
struct OwnAddressList * next
This is a doubly-linked list.
#define GNUNET_NO
Definition: gnunet_common.h:78
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
Definition: address.c:130
struct GNUNET_TIME_Absolute pong_sig_expires
How long until the current signature expires? (ZERO if the signature was never created).
static struct OwnAddressList * oal_head
Head of my addresses.
struct GNUNET_CRYPTO_EddsaSignature pong_signature
Signature for a 'struct TransportPongMessage' for this address.
struct GNUNET_HELLO_Address * address
The address.
Entry in linked list of network addresses for ourselves.
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller graph for this function: