GNUnet  0.19.4
gnunet-service-transport_hello.h File Reference

hello API More...

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.


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


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

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.

helloupdated HELLO

Definition at line 40 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.

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

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

240 {
241  hello_cb = cb;
242  hello_cb_cls = cb_cls;
243  friend_option = friend_only;
244  refresh_hello_task (NULL);
245 }
static int friend_option
Should we use a friend-only HELLO?
static GST_HelloCallback hello_cb
Function to call on HELLO changes.
static void refresh_hello_task(void *cls)
Construct our HELLO message from all of the addresses of all of the transports.
static void * hello_cb_cls
Closure for hello_cb.

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

Referenced by run().

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 252 of file gnunet-service-transport_hello.c.

253 {
254  hello_cb = NULL;
255  hello_cb_cls = NULL;
256  if (NULL != hello_task)
257  {
259  hello_task = NULL;
260  }
261  if (NULL != our_hello)
262  {
264  our_hello = NULL;
265  }
266 }
static struct GNUNET_SCHEDULER_Task * hello_task
Identifier of refresh_hello_task().
static struct GNUNET_HELLO_Message * our_hello
Our HELLO message.
#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:975

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

Referenced by shutdown_task().

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.

our HELLO message

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

276 {
277  return (const struct GNUNET_MessageHeader *) our_hello;
278 }
Header for all communications.

References our_hello.

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

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.

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

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

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

References address, 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, oal_head, oal_tail, OwnAddressList::rc, and refresh_hello().

Referenced by plugin_env_address_change_notification().

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.

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]
GNUNET_YES if this is one of our addresses, GNUNET_NO if not

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

341 {
342  struct OwnAddressList *al;
344  for (al = oal_head; al != NULL; al = al->next)
346  al->address))
347  {
348  *sig = &al->pong_signature;
349  *sig_expiration = &al->pong_sig_expires;
350  return GNUNET_YES;
351  }
352  *sig = NULL;
353  *sig_expiration = NULL;
354  return GNUNET_NO;
355 }
struct GNUNET_CRYPTO_EddsaSignature pong_signature
Signature for a 'struct TransportPongMessage' for this address.
struct GNUNET_TIME_Absolute pong_sig_expires
How long until the current signature expires? (ZERO if the signature was never created).

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

Referenced by GST_validation_handle_ping().

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