GNUnet 0.21.1
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 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_PEERSTORE_Record *record, const char *err_msg)
 Process each hello message received from peerinfo. More...
 
static void error_cb (void *cls)
 
static void sync_cb (void *cls)
 
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_MessageHeaderGCH_get_mine (void)
 Get own hello message. More...
 

Variables

static struct GNUNET_MessageHeadermine
 Hello message of local peer. More...
 
static struct GNUNET_PEERSTORE_Handlepeerstore
 Handle to the PEERSTORE service. More...
 
static struct GNUNET_PEERSTORE_Monitorpeerstore_notify
 Our peerstore notification 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.

Function Documentation

◆ got_hello()

static void got_hello ( void *  cls,
const struct GNUNET_PEERSTORE_Record record,
const char *  err_msg 
)
static

Process each hello message received from peerinfo.

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

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

69{
70 struct CadetPeer *peer;
72 struct GNUNET_MessageHeader *hello;
73
74 if (NULL == record->value)
75 {
77 return;
78 }
79 hello = record->value;
80 if (0 == GNUNET_memcmp (&record->peer,
81 &my_full_id))
82 {
91 return;
92 }
93
95 "Hello for %s (%d bytes), expires on %s\n",
96 GNUNET_i2s (&record->peer),
97 ntohs (hello->size),
100 peer = GCP_get (&record->peer,
101 GNUNET_YES);
102 GCP_set_hello (peer,
103 hello);
105}
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
static struct HostSet * builder
NULL if we are not currently iterating over peer information.
struct GNUNET_PeerIdentity my_full_id
Local peer own ID.
Definition: gnunet-hello.c:101
static struct GNUNET_CRYPTO_EddsaPrivateKey * my_private_key
Our private key.
Definition: gnunet-hello.c:96
void GCD_hello_update()
Function called by the HELLO subsystem whenever OUR hello changes.
static struct GNUNET_PEERSTORE_Monitor * peerstore_notify
Our peerstore notification context.
static struct GNUNET_MessageHeader * mine
Hello message of local peer.
#define LOG(level,...)
struct CadetPeer * GCP_get(const struct GNUNET_PeerIdentity *peer_id, int create)
Retrieve the CadetPeer structure associated with the peer.
void GCP_set_hello(struct CadetPeer *cp, const struct GNUNET_MessageHeader *hello)
We got a HELLO for a cp, remember it, and possibly trigger adequate actions (like trying to connect).
void GNUNET_HELLO_builder_free(struct GNUNET_HELLO_Builder *builder)
Release resources of a builder.
Definition: hello-uri.c:373
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_from_msg(const struct GNUNET_MessageHeader *msg)
Parse msg into builder.
Definition: hello-uri.c:391
struct GNUNET_TIME_Absolute GNUNET_HELLO_builder_get_expiration_time(const struct GNUNET_MessageHeader *msg)
Get the expiration time for this HELLO.
Definition: hello-uri.c:470
struct GNUNET_MessageHeader * GNUNET_HELLO_builder_to_dht_hello_msg(const struct GNUNET_HELLO_Builder *builder, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_TIME_Relative expiration_time)
Generate DHT HELLO message (without peer ID) from a builder.
Definition: hello-uri.c:666
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
@ GNUNET_YES
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_PEERSTORE_monitor_next(struct GNUNET_PEERSTORE_Monitor *zm, uint64_t limit)
Calls the monitor processor specified in GNUNET_PEERSTORE_monitor_start for the next record(s).
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:617
Struct containing all information regarding a given peer.
Context for building (or parsing) HELLO URIs.
Definition: hello-uri.c:205
Header for all communications.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.

References builder, GCD_hello_update(), GCP_get(), GCP_set_hello(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_HELLO_builder_free(), GNUNET_HELLO_builder_from_msg(), GNUNET_HELLO_builder_get_expiration_time(), GNUNET_HELLO_builder_to_dht_hello_msg(), GNUNET_i2s(), GNUNET_memcmp, GNUNET_PEERSTORE_monitor_next(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_UNIT_ZERO, GNUNET_YES, LOG, mine, my_full_id, my_private_key, peerstore_notify, record(), and GNUNET_MessageHeader::size.

Referenced by GCH_init().

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

◆ error_cb()

static void error_cb ( void *  cls)
static

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

110{
112 "Error in PEERSTORE monitoring\n");
113}
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_WARNING

References GNUNET_ERROR_TYPE_WARNING, and GNUNET_log.

Referenced by GCH_init().

Here is the caller graph for this function:

◆ sync_cb()

static void sync_cb ( void *  cls)
static

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

118{
120 "Done with initial PEERSTORE iteration during monitoring\n");
121}

References GNUNET_ERROR_TYPE_WARNING, and GNUNET_log.

Referenced by GCH_init().

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 130 of file gnunet-service-cadet_hello.c.

131{
137 "peerstore",
138 NULL,
140 &error_cb,
141 NULL,
142 &sync_cb,
143 NULL,
144 &got_hello,
145 NULL);
146}
static void sync_cb(void *cls)
static void got_hello(void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *err_msg)
Process each hello message received from peerinfo.
static struct GNUNET_PEERSTORE_Handle * peerstore
Handle to the PEERSTORE service.
static void error_cb(void *cls)
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_PEERSTORE_Monitor * GNUNET_PEERSTORE_monitor_start(const struct GNUNET_CONFIGURATION_Handle *cfg, int iterate_first, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_SCHEDULER_TaskCallback sync_cb, void *sync_cb_cls, GNUNET_PEERSTORE_Processor callback, void *callback_cls)
Request watching a given key The monitoring can be filtered to contain only records matching peer and...
struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the PEERSTORE service.
#define GNUNET_PEERSTORE_HELLO_KEY
Key used for storing HELLO in the peerstore.

References error_cb(), GNUNET_assert, GNUNET_PEERSTORE_connect(), GNUNET_PEERSTORE_HELLO_KEY, GNUNET_PEERSTORE_monitor_start(), GNUNET_YES, got_hello(), peerstore, peerstore_notify, and sync_cb().

Referenced by run().

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 153 of file gnunet-service-cadet_hello.c.

154{
155 if (NULL != peerstore_notify)
156 {
158 peerstore_notify = NULL;
159 }
160 if (NULL != peerstore)
161 {
163 peerstore = NULL;
164 }
165 if (NULL != mine)
166 {
168 mine = NULL;
169 }
170}
void GNUNET_PEERSTORE_monitor_stop(struct GNUNET_PEERSTORE_Monitor *zm)
Stop monitoring.
void GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h)
Disconnect from the PEERSTORE service.

References GNUNET_free, GNUNET_PEERSTORE_disconnect(), GNUNET_PEERSTORE_monitor_stop(), mine, peerstore, and peerstore_notify.

Referenced by shutdown_rest().

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

◆ GCH_get_mine()

const struct GNUNET_MessageHeader * GCH_get_mine ( void  )

Get own hello message.

Returns
Own hello message.

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

180{
182
183 if (NULL == mine)
184 {
190 }
191 return mine;
192}
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_new(const struct GNUNET_PeerIdentity *pid)
Allocate builder.
Definition: hello-uri.c:355

References builder, GNUNET_HELLO_builder_free(), GNUNET_HELLO_builder_new(), GNUNET_HELLO_builder_to_dht_hello_msg(), GNUNET_TIME_UNIT_ZERO, mine, my_full_id, and my_private_key.

Referenced by announce_id().

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

Variable Documentation

◆ mine

struct GNUNET_MessageHeader* mine
static

Hello message of local peer.

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

Referenced by GCH_get_mine(), GCH_shutdown(), and got_hello().

◆ peerstore

struct GNUNET_PEERSTORE_Handle* peerstore
static

Handle to the PEERSTORE service.

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

Referenced by GCH_init(), and GCH_shutdown().

◆ peerstore_notify

struct GNUNET_PEERSTORE_Monitor* peerstore_notify
static

Our peerstore notification context.

We use notification to instantly learn about new peers as they are discovered.

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

Referenced by GCH_init(), GCH_shutdown(), and got_hello().