GNUnet  0.10.x
Macros | Functions | Variables
gnunet-service-cadet_hello.c File Reference

spread knowledge about how to contact us (get HELLO from peerinfo), and remember HELLOs of other peers we have an interest in More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_statistics_service.h"
#include "gnunet_peerinfo_service.h"
#include "cadet_protocol.h"
#include "gnunet-service-cadet.h"
#include "gnunet-service-cadet_dht.h"
#include "gnunet-service-cadet_hello.h"
#include "gnunet-service-cadet_peer.h"
Include dependency graph for gnunet-service-cadet_hello.c:

Go to the source code of this file.

Macros

#define LOG(level, ...)   GNUNET_log_from(level,"cadet-hll",__VA_ARGS__)
 

Functions

static void got_hello (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_HELLO_Message *hello, const char *err_msg)
 Process each hello message received from peerinfo. More...
 
void GCH_init (const struct GNUNET_CONFIGURATION_Handle *c)
 Initialize the hello subsystem. More...
 
void GCH_shutdown ()
 Shut down the hello subsystem. More...
 
const struct GNUNET_HELLO_MessageGCH_get_mine (void)
 Get own hello message. More...
 

Variables

static struct GNUNET_HELLO_Messagemine
 Hello message of local peer. More...
 
static struct GNUNET_PEERINFO_Handlepeerinfo
 Handle to peerinfo service. More...
 
static struct GNUNET_PEERINFO_NotifyContextnc
 Iterator context. More...
 

Detailed Description

spread knowledge about how to contact us (get HELLO from peerinfo), and remember HELLOs of other peers we have an interest in

Author
Bartlomiej Polot
Christian Grothoff

Definition in file gnunet-service-cadet_hello.c.

Macro Definition Documentation

◆ LOG

#define LOG (   level,
  ... 
)    GNUNET_log_from(level,"cadet-hll",__VA_ARGS__)

Definition at line 38 of file gnunet-service-cadet_hello.c.

Referenced by got_hello().

Function Documentation

◆ got_hello()

static void got_hello ( void *  cls,
const struct GNUNET_PeerIdentity id,
const struct GNUNET_HELLO_Message hello,
const char *  err_msg 
)
static

Process each hello message received from peerinfo.

Parameters
clsClosure (unused).
peerIdentity of the peer.
helloHello of the peer.
err_msgError message.

Definition at line 65 of file gnunet-service-cadet_hello.c.

References GCD_hello_update(), GCP_get(), GCP_set_hello(), GNUNET_copy_message(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free_non_null, GNUNET_HELLO_get_last_expiration(), GNUNET_HELLO_size(), GNUNET_i2s(), GNUNET_memcmp, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_YES, GNUNET_HELLO_Message::header, LOG, my_full_id, and peer.

Referenced by GCH_init().

69 {
70  struct CadetPeer *peer;
71 
72  if ( (NULL == id) ||
73  (NULL == hello) )
74  return;
75  if (0 == GNUNET_memcmp (id,
76  &my_full_id))
77  {
79  mine = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (&hello->header);
81  return;
82  }
83 
85  "Hello for %s (%d bytes), expires on %s\n",
86  GNUNET_i2s (id),
87  GNUNET_HELLO_size (hello),
89  peer = GCP_get (id,
90  GNUNET_YES);
91  GCP_set_hello (peer,
92  hello);
93 }
Peer description.
A HELLO message is used to exchange information about transports with other peers.
static struct GNUNET_HELLO_Message * mine
Hello message of local peer.
void GCP_set_hello(struct CadetPeer *cp, const struct GNUNET_HELLO_Message *hello)
We got a HELLO for a peer, remember it, and possibly trigger adequate actions (like trying to connect...
struct GNUNET_PeerIdentity my_full_id
Local peer own ID.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
void GCD_hello_update()
Function called by the HELLO subsystem whenever OUR hello changes.
#define LOG(level,...)
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_HELLO.
struct CadetPeer * GCP_get(const struct GNUNET_PeerIdentity *peer_id, int create)
Retrieve the CadetPeer stucture associated with the peer.
uint16_t GNUNET_HELLO_size(const struct GNUNET_HELLO_Message *hello)
Return the size of the given HELLO message.
Definition: hello.c:649
#define GNUNET_YES
Definition: gnunet_common.h:80
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:792
struct GNUNET_TIME_Absolute GNUNET_HELLO_get_last_expiration(const struct GNUNET_HELLO_Message *msg)
When does the last address in the given HELLO expire?
Definition: hello.c:890
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCH_init()

void GCH_init ( const struct GNUNET_CONFIGURATION_Handle c)

Initialize the hello subsystem.

Parameters
cConfiguration.

Definition at line 102 of file gnunet-service-cadet_hello.c.

References GNUNET_assert, GNUNET_NO, GNUNET_PEERINFO_connect(), GNUNET_PEERINFO_notify(), and got_hello().

Referenced by run().

103 {
104  GNUNET_assert (NULL == nc);
107  GNUNET_NO,
108  &got_hello,
109  NULL);
110 }
struct GNUNET_PEERINFO_Handle * GNUNET_PEERINFO_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the peerinfo service.
Definition: peerinfo_api.c:133
static void got_hello(void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_HELLO_Message *hello, const char *err_msg)
Process each hello message received from peerinfo.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:81
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.
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
static struct GNUNET_PEERINFO_Handle * peerinfo
Handle to peerinfo service.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCH_shutdown()

void GCH_shutdown ( void  )

Shut down the hello subsystem.

Definition at line 117 of file gnunet-service-cadet_hello.c.

References GNUNET_free, GNUNET_PEERINFO_disconnect(), and GNUNET_PEERINFO_notify_cancel().

Referenced by shutdown_rest().

118 {
119  if (NULL != nc)
120  {
122  nc = NULL;
123  }
124  if (NULL != peerinfo)
125  {
127  peerinfo = NULL;
128  }
129  if (NULL != mine)
130  {
131  GNUNET_free (mine);
132  mine = NULL;
133  }
134 }
static struct GNUNET_HELLO_Message * mine
Hello message of local peer.
void GNUNET_PEERINFO_notify_cancel(struct GNUNET_PEERINFO_NotifyContext *nc)
Stop notifying about changes.
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
void GNUNET_PEERINFO_disconnect(struct GNUNET_PEERINFO_Handle *h)
Disconnect from the peerinfo service.
Definition: peerinfo_api.c:159
static struct GNUNET_PEERINFO_Handle * peerinfo
Handle to peerinfo service.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GCH_get_mine()

const struct GNUNET_HELLO_Message* GCH_get_mine ( void  )

Get own hello message.

Returns
Own hello message.

Definition at line 143 of file gnunet-service-cadet_hello.c.

References mine.

Referenced by announce_id().

144 {
145  return mine;
146 }
static struct GNUNET_HELLO_Message * mine
Hello message of local peer.
Here is the caller graph for this function:

Variable Documentation

◆ mine

struct GNUNET_HELLO_Message* mine
static

Hello message of local peer.

Definition at line 43 of file gnunet-service-cadet_hello.c.

Referenced by GCH_get_mine().

◆ peerinfo

struct GNUNET_PEERINFO_Handle* peerinfo
static

Handle to peerinfo service.

Definition at line 48 of file gnunet-service-cadet_hello.c.

◆ nc

struct GNUNET_PEERINFO_NotifyContext* nc
static