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

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

Referenced by run().

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

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

Referenced by shutdown_task().

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_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:965
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 275 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().

276 {
277  return (const struct GNUNET_MessageHeader *) our_hello;
278 }
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 288 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().

290 {
291  struct OwnAddressList *al;
292 
294  (GNUNET_YES == addremove)
295  ? "Adding `%s' to the set of our addresses\n"
296  : "Removing `%s' from the set of our addresses\n",
297  GST_plugins_a2s (address));
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);
332  al->address = GNUNET_HELLO_address_copy (address);
333  refresh_hello ();
334 }
#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:81
#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:80
#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 348 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().

351 {
352  struct OwnAddressList *al;
353 
354  for (al = oal_head; al != NULL; al = al->next)
355  if (0 == GNUNET_HELLO_address_cmp (address,
356  al->address))
357  {
358  *sig = &al->pong_signature;
359  *sig_expiration = &al->pong_sig_expires;
360  return GNUNET_YES;
361  }
362  *sig = NULL;
363  *sig_expiration = NULL;
364  return GNUNET_NO;
365 }
struct OwnAddressList * next
This is a doubly-linked list.
#define GNUNET_NO
Definition: gnunet_common.h:81
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:80
Here is the call graph for this function:
Here is the caller graph for this function: