GNUnet 0.28.1-dev.4-47-g3e168ca2d
 
Loading...
Searching...
No Matches
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.

Data Structures

struct  PilsRequest
 DLL. More...
 

Macros

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

Functions

static void sign_hello_cb (void *cls, const struct GNUNET_HELLO_Parser *parser, const struct GNUNET_HashCode *hash)
 
static void got_hello (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *err_msg)
 Process each hello message received from peerinfo.
 
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.
 
void GCH_shutdown ()
 Shut down the hello subsystem.
 
struct GNUNET_MessageHeaderGCH_get_mine ()
 Get own hello message.
 

Variables

static struct PilsRequestpils_requests_head
 PILS Operation DLL.
 
static struct PilsRequestpils_requests_tail
 PILS Operation DLL.
 
static struct GNUNET_MessageHeadermine
 Hello message of local peer.
 
static struct GNUNET_PEERSTORE_Handlepeerstore
 Handle to the PEERSTORE service.
 
static struct GNUNET_PEERSTORE_Monitorpeerstore_notify
 Our peerstore notification context.
 

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

◆ sign_hello_cb()

static void sign_hello_cb ( void *  cls,
const struct GNUNET_HELLO_Parser parser,
const struct GNUNET_HashCode hash 
)
static

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

98{
99
103 "Received new PID information with address hash `%s'\n",
104 GNUNET_h2s (hash));
106}
void GCD_hello_update()
Function called by the HELLO subsystem whenever OUR hello changes.
static struct GNUNET_MessageHeader * mine
Hello message of local peer.
#define LOG(level,...)
struct GNUNET_MessageHeader * GNUNET_HELLO_parser_to_dht_hello_msg(const struct GNUNET_HELLO_Parser *parser)
Generate DHT HELLO message from a parser.
Definition hello-uri.c:1249
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_free(ptr)
Wrapper around free.

References GCD_hello_update(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_h2s(), GNUNET_HELLO_parser_to_dht_hello_msg(), LOG, and mine.

Referenced by GCH_init().

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

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

121{
122 const struct GNUNET_PeerIdentity *my_identity;
123 struct CadetPeer *peer;
124 struct GNUNET_MessageHeader *hello;
125
127 if (! my_identity)
128 {
129 /* MUST still ask for the next record. Returning without doing so stops
130 this monitor permanently -- the PEERSTORE service waits for a
131 MONITOR_NEXT that never comes -- so CADET would never learn another
132 peer's HELLO for the rest of the process's life. We only need our own
133 identity to skip our own HELLO below, so skipping this one record
134 while PILS is still answering costs nothing. */
136 return;
137 }
138
139 if (NULL == record->value)
140 {
142 return;
143 }
144 hello = record->value;
145 if (0 == GNUNET_memcmp (&record->peer, my_identity))
146 {
148 "Ignoring own HELLOs\n");
150 return;
151 }
152
154 "Hello for %s (%d bytes), expires on %s\n",
155 GNUNET_i2s (&record->peer),
156 ntohs (hello->size),
159 peer = GCP_get (&record->peer,
160 GNUNET_YES);
161 GCP_set_hello (peer,
162 hello);
164}
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
static struct GNUNET_PILS_Handle * pils
Handle to PILS.
Definition gnunet-pils.c:44
static struct GNUNET_PEERSTORE_Monitor * peerstore_notify
Our peerstore notification context.
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).
static struct GNUNET_PeerIdentity my_identity
Identity of this peer.
const struct GNUNET_PeerIdentity * GNUNET_PILS_get_identity(const struct GNUNET_PILS_Handle *handle)
Return the current peer identity of a given handle.
Definition pils_api.c:875
struct GNUNET_TIME_Absolute GNUNET_HELLO_get_expiration_time_from_msg(const struct GNUNET_MessageHeader *msg)
Get the expiration time for this HELLO.
Definition hello-uri.c:655
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ 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
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).
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition strings.c:671
Struct containing all information regarding a given peer.
Header for all communications.
The identity of the host (wraps the signing key of the peer).

References GCP_get(), GCP_set_hello(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELLO_get_expiration_time_from_msg(), GNUNET_i2s(), GNUNET_memcmp, GNUNET_PEERSTORE_monitor_next(), GNUNET_PILS_get_identity(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_YES, LOG, my_identity, peerstore_notify, pils, 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 168 of file gnunet-service-cadet_hello.c.

169{
171 "Error in PEERSTORE monitoring\n");
172}
#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 176 of file gnunet-service-cadet_hello.c.

177{
179 "Done with initial PEERSTORE iteration during monitoring\n");
180}

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

190{
196 "peerstore",
197 NULL,
199 &error_cb,
200 NULL,
201 &sync_cb,
202 NULL,
203 &got_hello,
204 NULL);
207 NULL);
208}
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 sign_hello_cb(void *cls, const struct GNUNET_HELLO_Parser *parser, const struct GNUNET_HashCode *hash)
static void error_cb(void *cls)
struct GNUNET_PILS_Handle * GNUNET_PILS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PILS_PidChangeCallback pid_change_cb, void *cls)
Connect to the PILS service.
Definition pils_api.c:624
#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_PILS_connect(), GNUNET_YES, got_hello(), peerstore, peerstore_notify, pils, sign_hello_cb(), 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 215 of file gnunet-service-cadet_hello.c.

216{
217 struct PilsRequest *pr;
218
219 if (NULL != peerstore_notify)
220 {
222 peerstore_notify = NULL;
223 }
224 if (NULL != peerstore)
225 {
227 peerstore = NULL;
228 }
229 while (NULL != (pr = pils_requests_head))
230 {
233 pr);
234 if (NULL != pr->op)
236 if (NULL != pr->builder)
238 GNUNET_free (pr);
239 }
240 if (NULL != pils)
241 {
243 pils = NULL;
244 }
245 if (NULL != mine)
246 {
248 mine = NULL;
249 }
250}
static struct PilsRequest * pils_requests_head
PILS Operation DLL.
static struct PilsRequest * pils_requests_tail
PILS Operation DLL.
void GNUNET_PILS_disconnect(struct GNUNET_PILS_Handle *handle)
Disconnect from the PILS service.
Definition pils_api.c:647
void GNUNET_PILS_cancel(struct GNUNET_PILS_Operation *op)
Cancel request.
Definition pils_api.c:776
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void GNUNET_HELLO_builder_free(struct GNUNET_HELLO_Builder *builder)
Release resources of a builder.
Definition hello-uri.c:398
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.
struct GNUNET_PILS_Operation * op
The pils operation.
struct GNUNET_HELLO_Builder * builder
Address builder.

References PilsRequest::builder, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_HELLO_builder_free(), GNUNET_PEERSTORE_disconnect(), GNUNET_PEERSTORE_monitor_stop(), GNUNET_PILS_cancel(), GNUNET_PILS_disconnect(), mine, PilsRequest::op, peerstore, peerstore_notify, pils, pils_requests_head, and pils_requests_tail.

Referenced by shutdown_rest().

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

◆ GCH_get_mine()

struct GNUNET_MessageHeader * GCH_get_mine ( )

Get own hello message.

Returns
Own hello message.

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

260{
261 return mine;
262}

References mine.

Referenced by announce_id().

Here is the caller graph for this function:

Variable Documentation

◆ pils_requests_head

struct PilsRequest* pils_requests_head
static

PILS Operation DLL.

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

Referenced by GCH_shutdown().

◆ pils_requests_tail

struct PilsRequest* pils_requests_tail
static

PILS Operation DLL.

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

Referenced by GCH_shutdown().

◆ mine

struct GNUNET_MessageHeader* mine
static

Hello message of local peer.

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

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

◆ peerstore

struct GNUNET_PEERSTORE_Handle* peerstore
static

Handle to the PEERSTORE service.

Definition at line 85 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 91 of file gnunet-service-cadet_hello.c.

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