GNUnet  0.11.x
Data Structures | Macros | Functions
core_api.c File Reference

core service; this is the main API for encrypted P2P communications More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_core_service.h"
#include "core.h"
Include dependency graph for core_api.c:

Go to the source code of this file.

Data Structures

struct  PeerRecord
 Information we track for each peer. More...
 
struct  GNUNET_CORE_Handle
 Context for the core service connection. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "core-api", __VA_ARGS__)
 

Functions

static void reconnect (struct GNUNET_CORE_Handle *h)
 Our current client connection went down. More...
 
static void reconnect_task (void *cls)
 Task schedule to try to re-connect to core. More...
 
static int disconnect_and_free_peer_entry (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 Notify clients about disconnect and free the entry for connected peer. More...
 
static void reconnect_later (struct GNUNET_CORE_Handle *h)
 Close down any existing connection to the CORE service and try re-establishing it later. More...
 
static void handle_mq_error (void *cls, enum GNUNET_MQ_Error error)
 Error handler for the message queue to the CORE service. More...
 
static void core_mq_send_impl (struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *msg, void *impl_state)
 Implement sending functionality of a message queue for us sending messages to a peer. More...
 
static void core_mq_destroy_impl (struct GNUNET_MQ_Handle *mq, void *impl_state)
 Handle destruction of a message queue. More...
 
static void core_mq_cancel_impl (struct GNUNET_MQ_Handle *mq, void *impl_state)
 Implementation function that cancels the currently sent message. More...
 
static void core_mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 We had an error processing a message we forwarded from a peer to the CORE service. More...
 
static void connect_peer (struct GNUNET_CORE_Handle *h, const struct GNUNET_PeerIdentity *peer)
 Add the given peer to the list of our connected peers and create the respective data structures and notify the application. More...
 
static void handle_init_reply (void *cls, const struct InitReplyMessage *m)
 Handle init reply message received from CORE service. More...
 
static void handle_connect_notify (void *cls, const struct ConnectNotifyMessage *cnm)
 Handle connect message received from CORE service. More...
 
static void handle_disconnect_notify (void *cls, const struct DisconnectNotifyMessage *dnm)
 Handle disconnect message received from CORE service. More...
 
static int check_notify_inbound (void *cls, const struct NotifyTrafficMessage *ntm)
 Check that message received from CORE service is well-formed. More...
 
static void handle_notify_inbound (void *cls, const struct NotifyTrafficMessage *ntm)
 Handle inbound message received from CORE service. More...
 
static void handle_send_ready (void *cls, const struct SendMessageReady *smr)
 Handle message received from CORE service notifying us that we are now allowed to send a message to a peer. More...
 
struct GNUNET_CORE_HandleGNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
 Connect to the core service. More...
 
void GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle)
 Disconnect from the core service. More...
 
struct GNUNET_MQ_HandleGNUNET_CORE_get_mq (const struct GNUNET_CORE_Handle *h, const struct GNUNET_PeerIdentity *pid)
 Obtain the message queue for a connected peer. More...
 

Detailed Description

core service; this is the main API for encrypted P2P communications

Author
Christian Grothoff

Definition in file core_api.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "core-api", __VA_ARGS__)

Function Documentation

◆ reconnect()

static void reconnect ( struct GNUNET_CORE_Handle h)
static

Our current client connection went down.

Clean it up and try to reconnect!

Parameters
hour handle to the core service

Definition at line 630 of file core_api.c.

References GNUNET_CORE_Handle::cfg, connect_notify(), disconnect_notify(), PeerRecord::env, GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_INFO, GNUNET_MESSAGE_TYPE_CORE_INIT, GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY, GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT, GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT, GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND, GNUNET_MESSAGE_TYPE_CORE_SEND_READY, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), handle_mq_error(), GNUNET_CORE_Handle::handlers, GNUNET_CORE_Handle::hcnt, init, LOG, GNUNET_CORE_Handle::mq, InitMessage::options, reconnect_later(), and GNUNET_MQ_MessageHandler::type.

Referenced by GNUNET_CORE_connect(), and reconnect_task().

631 {
633  { GNUNET_MQ_hd_fixed_size (init_reply,
635  struct InitReplyMessage,
636  h),
639  struct ConnectNotifyMessage,
640  h),
644  h),
645  GNUNET_MQ_hd_var_size (notify_inbound,
647  struct NotifyTrafficMessage,
648  h),
649  GNUNET_MQ_hd_fixed_size (send_ready,
651  struct SendMessageReady,
652  h),
654  struct InitMessage *init;
655  struct GNUNET_MQ_Envelope *env;
656  uint16_t *ts;
657 
658  GNUNET_assert (NULL == h->mq);
659  h->mq = GNUNET_CLIENT_connect (h->cfg, "core", handlers, &handle_mq_error, h);
660  if (NULL == h->mq)
661  {
662  reconnect_later (h);
663  return;
664  }
665  env = GNUNET_MQ_msg_extra (init,
666  sizeof(uint16_t) * h->hcnt,
668  LOG (GNUNET_ERROR_TYPE_INFO, "(Re)connecting to CORE service\n");
669  init->options = htonl (0);
670  ts = (uint16_t *) &init[1];
671  for (unsigned int hpos = 0; hpos < h->hcnt; hpos++)
672  ts[hpos] = htons (h->handlers[hpos].type);
673  GNUNET_MQ_send (h->mq, env);
674 }
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
#define LOG(kind,...)
Definition: core_api.c:32
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Message sent by the service to clients to notify them about a peer connecting.
Definition: core.h:124
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we&#39;re using.
Definition: core_api.c:82
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND
Notify clients about incoming P2P messages.
#define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT
Notify clients about peer disconnecting.
uint32_t options
Options, see GNUNET_CORE_OPTION_ values.
Definition: core.h:93
Message transmitted core clients to gnunet-service-core to start the interaction. ...
Definition: core.h:83
Message transmitted by the gnunet-service-core process to its clients in response to an INIT message...
Definition: core.h:101
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
#define GNUNET_MESSAGE_TYPE_CORE_INIT
Initial setup message from core client to core.
uint16_t type
Type of the message this handler covers, in host byte order.
Core notifying client that it is allowed to now transmit a message to the given target (response to G...
Definition: core.h:241
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
static void reconnect_later(struct GNUNET_CORE_Handle *h)
Close down any existing connection to the CORE service and try re-establishing it later...
Definition: core_api.c:215
struct GNUNET_MQ_Handle * mq
Our message queue for transmissions to the service.
Definition: core_api.c:112
Message handler for a specific message type.
#define GNUNET_MESSAGE_TYPE_CORE_SEND_READY
Confirmation from core that message can now be sent.
struct GNUNET_MQ_MessageHandler * handlers
Function handlers for messages of particular type.
Definition: core_api.c:107
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT
Notify clients about new peer-to-peer connections (triggered after key exchange). ...
static char * init
Set to the name of a service to start.
Definition: gnunet-arm.c:74
static void handle_mq_error(void *cls, enum GNUNET_MQ_Error error)
Error handler for the message queue to the CORE service.
Definition: core_api.c:241
static void * connect_notify(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a peer connects.
Message sent by the service to clients to notify them about a peer disconnecting. ...
Definition: core.h:147
Message sent by the service to clients to notify them about messages being received or transmitted...
Definition: core.h:175
unsigned int hcnt
Number of entries in the handlers array.
Definition: core_api.c:138
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
#define GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY
Response from core to core client to INIT message.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
static void disconnect_notify(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Method called whenever a peer disconnects.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reconnect_task()

static void reconnect_task ( void *  cls)
static

Task schedule to try to re-connect to core.

Parameters
clsthe struct GNUNET_CORE_Handle
tctask context

Definition at line 164 of file core_api.c.

References GNUNET_CORE_Handle::cls, GNUNET_ERROR_TYPE_DEBUG, PeerRecord::h, LOG, reconnect(), and GNUNET_CORE_Handle::reconnect_task.

Referenced by reconnect_later().

165 {
166  struct GNUNET_CORE_Handle *h = cls;
167 
168  h->reconnect_task = NULL;
169  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to CORE service after delay\n");
170  reconnect (h);
171 }
Context for the core service connection.
Definition: core_api.c:77
#define LOG(kind,...)
Definition: core_api.c:32
void * cls
Closure for the various callbacks.
Definition: core_api.c:87
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of reconnect task (if any).
Definition: core_api.c:128
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static void reconnect(struct GNUNET_CORE_Handle *h)
Our current client connection went down.
Definition: core_api.c:630
Here is the call graph for this function:
Here is the caller graph for this function:

◆ disconnect_and_free_peer_entry()

static int disconnect_and_free_peer_entry ( void *  cls,
const struct GNUNET_PeerIdentity key,
void *  value 
)
static

Notify clients about disconnect and free the entry for connected peer.

Parameters
clsthe struct GNUNET_CORE_Handle *
keythe peer identity (not used)
valuethe struct PeerRecord to free.
Returns
GNUNET_YES (continue)

Definition at line 184 of file core_api.c.

References PeerRecord::client_cls, GNUNET_CORE_Handle::cls, GNUNET_CORE_Handle::disconnects, PeerRecord::env, GNUNET_assert, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_free, GNUNET_MQ_destroy(), GNUNET_MQ_discard(), GNUNET_YES, PeerRecord::h, PeerRecord::mq, PeerRecord::peer, GNUNET_CORE_Handle::peers, and value.

Referenced by GNUNET_CORE_disconnect(), handle_disconnect_notify(), and reconnect_later().

187 {
188  struct GNUNET_CORE_Handle *h = cls;
189  struct PeerRecord *pr = value;
190 
191  GNUNET_assert (pr->h == h);
192  if (NULL != h->disconnects)
193  h->disconnects (h->cls, &pr->peer, pr->client_cls);
196  GNUNET_MQ_destroy (pr->mq);
197  GNUNET_assert (NULL == pr->mq);
198  if (NULL != pr->env)
199  {
200  GNUNET_MQ_discard (pr->env);
201  pr->env = NULL;
202  }
203  GNUNET_free (pr);
204  return GNUNET_YES;
205 }
struct GNUNET_MQ_Envelope * env
Message we are currently trying to pass to the CORE service for this peer (from mq).
Definition: core_api.c:54
Context for the core service connection.
Definition: core_api.c:77
Information we track for each peer.
Definition: core_api.c:38
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_Handle * mq
Message queue for the peer.
Definition: core_api.c:48
void * cls
Closure for the various callbacks.
Definition: core_api.c:87
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
struct GNUNET_PeerIdentity peer
Peer the record is about.
Definition: core_api.c:65
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_CORE_Handle * h
Corresponding CORE handle.
Definition: core_api.c:43
void * client_cls
Value the client returned when we connected, used as the closure in various places.
Definition: core_api.c:60
static char * value
Value of the record to add/remove.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:321
struct GNUNET_CONTAINER_MultiPeerMap * peers
Hash map listing all of the peers that we are currently connected to.
Definition: core_api.c:118
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_CORE_DisconnectEventHandler disconnects
Function to call whenever we&#39;re notified about a peer disconnecting.
Definition: core_api.c:102
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reconnect_later()

static void reconnect_later ( struct GNUNET_CORE_Handle h)
static

Close down any existing connection to the CORE service and try re-establishing it later.

Parameters
hour handle

Definition at line 215 of file core_api.c.

References disconnect_and_free_peer_entry(), GNUNET_assert, GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, GNUNET_CORE_Handle::mq, GNUNET_CORE_Handle::peers, GNUNET_CORE_Handle::reconnect_task, reconnect_task(), and GNUNET_CORE_Handle::retry_backoff.

Referenced by handle_connect_notify(), handle_disconnect_notify(), handle_mq_error(), handle_notify_inbound(), handle_send_ready(), and reconnect().

216 {
217  GNUNET_assert (NULL == h->reconnect_task);
218  if (NULL != h->mq)
219  {
220  GNUNET_MQ_destroy (h->mq);
221  h->mq = NULL;
222  }
223  GNUNET_assert (NULL == h->reconnect_task);
224  h->reconnect_task =
228  h);
230 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of reconnect task (if any).
Definition: core_api.c:128
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1253
static int disconnect_and_free_peer_entry(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Notify clients about disconnect and free the entry for connected peer.
Definition: core_api.c:184
struct GNUNET_TIME_Relative retry_backoff
Current delay we use for re-trying to connect to core.
Definition: core_api.c:133
static void reconnect_task(void *cls)
Task schedule to try to re-connect to core.
Definition: core_api.c:164
struct GNUNET_MQ_Handle * mq
Our message queue for transmissions to the service.
Definition: core_api.c:112
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
struct GNUNET_CONTAINER_MultiPeerMap * peers
Hash map listing all of the peers that we are currently connected to.
Definition: core_api.c:118
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_mq_error()

static void handle_mq_error ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Error handler for the message queue to the CORE service.

On errors, we reconnect.

Parameters
clsclosure, a struct GNUNET_CORE_Handle *
errorerror code

Definition at line 241 of file core_api.c.

References GNUNET_CORE_Handle::cls, GNUNET_ERROR_TYPE_DEBUG, PeerRecord::h, LOG, and reconnect_later().

Referenced by reconnect().

242 {
243  struct GNUNET_CORE_Handle *h = cls;
244 
245  LOG (GNUNET_ERROR_TYPE_DEBUG, "MQ ERROR: %d\n", error);
246  reconnect_later (h);
247 }
Context for the core service connection.
Definition: core_api.c:77
#define LOG(kind,...)
Definition: core_api.c:32
void * cls
Closure for the various callbacks.
Definition: core_api.c:87
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static void reconnect_later(struct GNUNET_CORE_Handle *h)
Close down any existing connection to the CORE service and try re-establishing it later...
Definition: core_api.c:215
Here is the call graph for this function:
Here is the caller graph for this function:

◆ core_mq_send_impl()

static void core_mq_send_impl ( struct GNUNET_MQ_Handle mq,
const struct GNUNET_MessageHeader msg,
void *  impl_state 
)
static

Implement sending functionality of a message queue for us sending messages to a peer.

Parameters
mqthe message queue
msgthe message to send
impl_statestate of the implementation

Definition at line 259 of file core_api.c.

References PeerRecord::env, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_MESSAGE_TYPE_CORE_SEND, GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST, GNUNET_MQ_env_get_options(), GNUNET_MQ_get_current_envelope(), GNUNET_MQ_impl_send_continue(), GNUNET_MQ_msg, GNUNET_MQ_msg_nested_mh, GNUNET_MQ_send(), PeerRecord::h, LOG, GNUNET_CORE_Handle::mq, PeerRecord::peer, SendMessageRequest::peer, SendMessage::peer, SendMessageRequest::priority, SendMessage::priority, SendMessageRequest::size, GNUNET_MessageHeader::size, SendMessageRequest::smr_id, and PeerRecord::smr_id_gen.

Referenced by connect_peer().

262 {
263  struct PeerRecord *pr = impl_state;
264  struct GNUNET_CORE_Handle *h = pr->h;
265  struct SendMessageRequest *smr;
266  struct SendMessage *sm;
267  struct GNUNET_MQ_Envelope *env;
268  uint16_t msize;
270 
271  if (NULL == h->mq)
272  {
273  /* We're currently reconnecting, pretend this worked */
275  return;
276  }
277  GNUNET_assert (NULL == pr->env);
278  /* extract options from envelope */
280  flags = GNUNET_MQ_env_get_options (env);
281 
282  /* check message size for sanity */
283  msize = ntohs (msg->size);
284  if (msize >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct SendMessage))
285  {
286  GNUNET_break (0);
288  return;
289  }
290 
291  /* ask core for transmission */
293  "Asking core for transmission of %u bytes to `%s'\n",
294  (unsigned int) msize,
295  GNUNET_i2s (&pr->peer));
297  smr->priority = htonl ((uint32_t) flags);
298  smr->peer = pr->peer;
299  smr->size = htons (msize);
300  smr->smr_id = htons (++pr->smr_id_gen);
301  GNUNET_MQ_send (h->mq, env);
302 
303  /* prepare message with actual transmission data */
305  sm->priority = htonl ((uint32_t) flags);
306  sm->peer = pr->peer;
308  "Calling get_message with buffer of %u bytes\n",
309  (unsigned int) msize);
310 }
struct GNUNET_MQ_Envelope * env
Message we are currently trying to pass to the CORE service for this peer (from mq).
Definition: core_api.c:54
#define GNUNET_MESSAGE_TYPE_CORE_SEND
Client with message to transmit (after SEND_READY confirmation was received).
Context for the core service connection.
Definition: core_api.c:77
Information we track for each peer.
Definition: core_api.c:38
#define GNUNET_MQ_msg_nested_mh(mvar, type, mh)
Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct...
uint32_t priority
How important is this message?
Definition: core.h:206
#define LOG(kind,...)
Definition: core_api.c:32
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_PeerIdentity peer
Peer the record is about.
Definition: core_api.c:65
GNUNET_MQ_PriorityPreferences
Per envelope preferences and priorities.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
struct GNUNET_PeerIdentity peer
Identity of the intended target.
Definition: core.h:217
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_CORE_Handle * h
Corresponding CORE handle.
Definition: core_api.c:43
enum GNUNET_MQ_PriorityPreferences GNUNET_MQ_env_get_options(struct GNUNET_MQ_Envelope *env)
Get performance preferences set for this envelope.
Definition: mq.c:1020
#define GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST
Request from client to transmit message.
uint16_t size
How large is the message?
Definition: core.h:227
uint16_t smr_id
Counter for this peer to match SMRs to replies.
Definition: core.h:232
Client asking core to transmit a particular message to a particular target (response to GNUNET_MESSAG...
Definition: core.h:272
struct GNUNET_PeerIdentity peer
Identity of the intended receiver.
Definition: core.h:294
Client notifying core about the maximum-priority message it has in the queue for a particular target...
Definition: core.h:196
struct GNUNET_MQ_Handle * mq
Our message queue for transmissions to the service.
Definition: core_api.c:112
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
uint32_t priority
How important is this message? Contains a enum GNUNET_MQ_PriorityPreferences in NBO.
Definition: core.h:283
struct GNUNET_MQ_Envelope * GNUNET_MQ_get_current_envelope(struct GNUNET_MQ_Handle *mq)
Function to obtain the current envelope from within GNUNET_MQ_SendImpl implementations.
Definition: mq.c:974
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
uint16_t smr_id_gen
SendMessageRequest ID generator for this peer.
Definition: core_api.c:70
void GNUNET_MQ_impl_send_continue(struct GNUNET_MQ_Handle *mq)
Call the send implementation for the next queued message, if any.
Definition: mq.c:486
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ core_mq_destroy_impl()

static void core_mq_destroy_impl ( struct GNUNET_MQ_Handle mq,
void *  impl_state 
)
static

Handle destruction of a message queue.

Implementations must not free mq, but should take care of impl_state.

Parameters
mqthe message queue to destroy
impl_statestate of the implementation

Definition at line 321 of file core_api.c.

References GNUNET_assert, and PeerRecord::mq.

Referenced by connect_peer().

322 {
323  struct PeerRecord *pr = impl_state;
324 
325  GNUNET_assert (mq == pr->mq);
326  pr->mq = NULL;
327 }
Information we track for each peer.
Definition: core_api.c:38
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_Handle * mq
Message queue for the peer.
Definition: core_api.c:48
Here is the caller graph for this function:

◆ core_mq_cancel_impl()

static void core_mq_cancel_impl ( struct GNUNET_MQ_Handle mq,
void *  impl_state 
)
static

Implementation function that cancels the currently sent message.

Should basically undo whatever mq_send_impl() did.

Parameters
mqmessage queue
impl_statestate specific to the implementation

Definition at line 338 of file core_api.c.

References PeerRecord::env, GNUNET_assert, and GNUNET_MQ_discard().

Referenced by connect_peer().

339 {
340  struct PeerRecord *pr = impl_state;
341 
342  (void) mq;
343  GNUNET_assert (NULL != pr->env);
344  GNUNET_MQ_discard (pr->env);
345  pr->env = NULL;
346 }
struct GNUNET_MQ_Envelope * env
Message we are currently trying to pass to the CORE service for this peer (from mq).
Definition: core_api.c:54
Information we track for each peer.
Definition: core_api.c:38
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:321
Here is the call graph for this function:
Here is the caller graph for this function:

◆ core_mq_error_handler()

static void core_mq_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

We had an error processing a message we forwarded from a peer to the CORE service.

We should just complain about it but otherwise continue processing.

Parameters
clsclosure
errorerror code

Definition at line 358 of file core_api.c.

References GNUNET_break_op.

Referenced by connect_peer().

359 {
360  /* struct PeerRecord *pr = cls; */
361  (void) cls;
362  (void) error;
363  GNUNET_break_op (0);
364 }
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
Here is the caller graph for this function:

◆ connect_peer()

static void connect_peer ( struct GNUNET_CORE_Handle h,
const struct GNUNET_PeerIdentity peer 
)
static

Add the given peer to the list of our connected peers and create the respective data structures and notify the application.

Parameters
hthe core handle
peerthe peer that is connecting to us

Definition at line 376 of file core_api.c.

References PeerRecord::client_cls, GNUNET_CORE_Handle::cls, GNUNET_CORE_Handle::connects, core_mq_cancel_impl(), core_mq_destroy_impl(), core_mq_error_handler(), core_mq_send_impl(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_put(), GNUNET_MQ_queue_for_callbacks(), GNUNET_MQ_set_handlers_closure(), GNUNET_new, GNUNET_YES, PeerRecord::h, GNUNET_CORE_Handle::handlers, PeerRecord::mq, PeerRecord::peer, and GNUNET_CORE_Handle::peers.

Referenced by handle_connect_notify(), and handle_init_reply().

378 {
379  struct PeerRecord *pr;
380 
381  pr = GNUNET_new (struct PeerRecord);
382  pr->peer = *peer;
383  pr->h = h;
386  h->peers,
387  &pr->peer,
388  pr,
393  pr,
394  h->handlers,
396  pr);
397  if (NULL != h->connects)
398  {
399  pr->client_cls = h->connects (h->cls, &pr->peer, pr->mq);
401  }
402 }
Information we track for each peer.
Definition: core_api.c:38
GNUNET_CORE_ConnectEventHandler connects
Function to call whenever we&#39;re notified about a peer connecting.
Definition: core_api.c:97
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_Handle * mq
Message queue for the peer.
Definition: core_api.c:48
void * cls
Closure for the various callbacks.
Definition: core_api.c:87
struct GNUNET_PeerIdentity peer
Peer the record is about.
Definition: core_api.c:65
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void core_mq_cancel_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
Implementation function that cancels the currently sent message.
Definition: core_api.c:338
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_CORE_Handle * h
Corresponding CORE handle.
Definition: core_api.c:43
void GNUNET_MQ_set_handlers_closure(struct GNUNET_MQ_Handle *mq, void *handlers_cls)
Change the closure argument in all of the handlers of the mq.
Definition: mq.c:583
struct GNUNET_MQ_Handle * GNUNET_MQ_queue_for_callbacks(GNUNET_MQ_SendImpl send, GNUNET_MQ_DestroyImpl destroy, GNUNET_MQ_CancelImpl cancel, void *impl_state, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *cls)
Create a message queue for the specified handlers.
Definition: mq.c:552
void * client_cls
Value the client returned when we connected, used as the closure in various places.
Definition: core_api.c:60
static void core_mq_destroy_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
Handle destruction of a message queue.
Definition: core_api.c:321
There must only be one value per key; storing a value should fail if a value under the same key alrea...
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_MessageHandler * handlers
Function handlers for messages of particular type.
Definition: core_api.c:107
static void core_mq_send_impl(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *msg, void *impl_state)
Implement sending functionality of a message queue for us sending messages to a peer.
Definition: core_api.c:259
struct GNUNET_CONTAINER_MultiPeerMap * peers
Hash map listing all of the peers that we are currently connected to.
Definition: core_api.c:118
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
#define GNUNET_YES
Definition: gnunet_common.h:77
static void core_mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
We had an error processing a message we forwarded from a peer to the CORE service.
Definition: core_api.c:358
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_init_reply()

static void handle_init_reply ( void *  cls,
const struct InitReplyMessage m 
)
static

Handle init reply message received from CORE service.

Notify application that we are now connected to the CORE. Also fake loopback connection.

Parameters
clsthe struct GNUNET_CORE_Handle
mthe init reply

Definition at line 414 of file core_api.c.

References GNUNET_CORE_Handle::cls, connect_peer(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_NO, GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_YES, PeerRecord::h, GNUNET_CORE_Handle::have_init, init, GNUNET_CORE_Handle::init, LOG, GNUNET_CORE_Handle::me, InitReplyMessage::my_identity, InitReplyMessage::reserved, and GNUNET_CORE_Handle::retry_backoff.

415 {
416  struct GNUNET_CORE_Handle *h = cls;
418 
419  GNUNET_break (0 == ntohl (m->reserved));
421  if (NULL != (init = h->init))
422  {
423  /* mark so we don't call init on reconnect */
424  h->init = NULL;
425  h->me = m->my_identity;
427  "Connected to core service of peer `%s'.\n",
428  GNUNET_i2s (&h->me));
429  h->have_init = GNUNET_YES;
430  init (h->cls, &h->me);
431  }
432  else
433  {
435  "Successfully reconnected to core service.\n");
436  if (GNUNET_NO == h->have_init)
437  {
438  h->me = m->my_identity;
439  h->have_init = GNUNET_YES;
440  }
441  else
442  {
443  GNUNET_break (0 == memcmp (&h->me,
444  &m->my_identity,
445  sizeof(struct GNUNET_PeerIdentity)));
446  }
447  }
448  /* fake 'connect to self' */
449  connect_peer (h, &h->me);
450 }
Context for the core service connection.
Definition: core_api.c:77
struct GNUNET_PeerIdentity me
Identity of this peer.
Definition: core_api.c:123
static void connect_peer(struct GNUNET_CORE_Handle *h, const struct GNUNET_PeerIdentity *peer)
Add the given peer to the list of our connected peers and create the respective data structures and n...
Definition: core_api.c:376
GNUNET_CORE_StartupCallback init
Function to call once we&#39;ve handshaked with the core service.
Definition: core_api.c:92
#define LOG(kind,...)
Definition: core_api.c:32
void * cls
Closure for the various callbacks.
Definition: core_api.c:87
void(* GNUNET_CORE_StartupCallback)(void *cls, const struct GNUNET_PeerIdentity *my_identity)
Function called after GNUNET_CORE_connect has succeeded (or failed for good).
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_PeerIdentity my_identity
Public key of the local peer.
Definition: core.h:116
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
int have_init
Did we ever get INIT?
Definition: core_api.c:143
struct GNUNET_TIME_Relative retry_backoff
Current delay we use for re-trying to connect to core.
Definition: core_api.c:133
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
static char * init
Set to the name of a service to start.
Definition: gnunet-arm.c:74
The identity of the host (wraps the signing key of the peer).
#define GNUNET_YES
Definition: gnunet_common.h:77
uint32_t reserved
Always zero.
Definition: core.h:111
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:

◆ handle_connect_notify()

static void handle_connect_notify ( void *  cls,
const struct ConnectNotifyMessage cnm 
)
static

Handle connect message received from CORE service.

Notify the application about the new connection.

Parameters
clsthe struct GNUNET_CORE_Handle
cnmthe connect message

Definition at line 461 of file core_api.c.

References GNUNET_CORE_Handle::cls, connect_peer(), GNUNET_break, GNUNET_CONTAINER_multipeermap_get(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), PeerRecord::h, LOG, GNUNET_CORE_Handle::me, ConnectNotifyMessage::peer, GNUNET_CORE_Handle::peers, and reconnect_later().

462 {
463  struct GNUNET_CORE_Handle *h = cls;
464  struct PeerRecord *pr;
465 
467  "Received notification about connection from `%s'.\n",
468  GNUNET_i2s (&cnm->peer));
469  if (0 == memcmp (&h->me, &cnm->peer, sizeof(struct GNUNET_PeerIdentity)))
470  {
471  /* connect to self!? */
472  GNUNET_break (0);
473  return;
474  }
476  if (NULL != pr)
477  {
478  GNUNET_break (0);
479  reconnect_later (h);
480  return;
481  }
482  connect_peer (h, &cnm->peer);
483 }
Context for the core service connection.
Definition: core_api.c:77
Information we track for each peer.
Definition: core_api.c:38
struct GNUNET_PeerIdentity me
Identity of this peer.
Definition: core_api.c:123
static void connect_peer(struct GNUNET_CORE_Handle *h, const struct GNUNET_PeerIdentity *peer)
Add the given peer to the list of our connected peers and create the respective data structures and n...
Definition: core_api.c:376
#define LOG(kind,...)
Definition: core_api.c:32
void * cls
Closure for the various callbacks.
Definition: core_api.c:87
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static void reconnect_later(struct GNUNET_CORE_Handle *h)
Close down any existing connection to the CORE service and try re-establishing it later...
Definition: core_api.c:215
struct GNUNET_PeerIdentity peer
Identity of the connecting peer.
Definition: core.h:139
struct GNUNET_CONTAINER_MultiPeerMap * peers
Hash map listing all of the peers that we are currently connected to.
Definition: core_api.c:118
The identity of the host (wraps the signing key of the peer).
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:

◆ handle_disconnect_notify()

static void handle_disconnect_notify ( void *  cls,
const struct DisconnectNotifyMessage dnm 
)
static

Handle disconnect message received from CORE service.

Notify the application about the lost connection.

Parameters
clsthe struct GNUNET_CORE_Handle
dnmmessage about the disconnect event

Definition at line 494 of file core_api.c.

References GNUNET_CORE_Handle::cls, disconnect_and_free_peer_entry(), GNUNET_break, GNUNET_CONTAINER_multipeermap_get(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), PeerRecord::h, LOG, GNUNET_CORE_Handle::me, PeerRecord::peer, DisconnectNotifyMessage::peer, GNUNET_CORE_Handle::peers, reconnect_later(), and DisconnectNotifyMessage::reserved.

495 {
496  struct GNUNET_CORE_Handle *h = cls;
497  struct PeerRecord *pr;
498 
499  if (0 == memcmp (&h->me, &dnm->peer, sizeof(struct GNUNET_PeerIdentity)))
500  {
501  /* disconnect from self!? */
502  GNUNET_break (0);
503  return;
504  }
505  GNUNET_break (0 == ntohl (dnm->reserved));
507  "Received notification about disconnect from `%s'.\n",
508  GNUNET_i2s (&dnm->peer));
510  if (NULL == pr)
511  {
512  GNUNET_break (0);
513  reconnect_later (h);
514  return;
515  }
516  disconnect_and_free_peer_entry (h, &pr->peer, pr);
517 }
Context for the core service connection.
Definition: core_api.c:77
Information we track for each peer.
Definition: core_api.c:38
struct GNUNET_PeerIdentity me
Identity of this peer.
Definition: core_api.c:123
#define LOG(kind,...)
Definition: core_api.c:32
void * cls
Closure for the various callbacks.
Definition: core_api.c:87
struct GNUNET_PeerIdentity peer
Peer the record is about.
Definition: core_api.c:65
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static int disconnect_and_free_peer_entry(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Notify clients about disconnect and free the entry for connected peer.
Definition: core_api.c:184
static void reconnect_later(struct GNUNET_CORE_Handle *h)
Close down any existing connection to the CORE service and try re-establishing it later...
Definition: core_api.c:215
struct GNUNET_CONTAINER_MultiPeerMap * peers
Hash map listing all of the peers that we are currently connected to.
Definition: core_api.c:118
The identity of the host (wraps the signing key of the peer).
uint32_t reserved
Always zero.
Definition: core.h:157
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
struct GNUNET_PeerIdentity peer
Identity of the connecting peer.
Definition: core.h:162
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:

◆ check_notify_inbound()

static int check_notify_inbound ( void *  cls,
const struct NotifyTrafficMessage ntm 
)
static

Check that message received from CORE service is well-formed.

Parameters
clsthe struct GNUNET_CORE_Handle
ntmthe message we got
Returns
GNUNET_OK if the message is well-formed

Definition at line 528 of file core_api.c.

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, NotifyTrafficMessage::header, and GNUNET_MessageHeader::size.

529 {
530  uint16_t msize;
531  const struct GNUNET_MessageHeader *em;
532 
533  (void) cls;
534  msize = ntohs (ntm->header.size) - sizeof(struct NotifyTrafficMessage);
535  if (msize < sizeof(struct GNUNET_MessageHeader))
536  {
537  GNUNET_break (0);
538  return GNUNET_SYSERR;
539  }
540  em = (const struct GNUNET_MessageHeader *) &ntm[1];
541  if (msize != ntohs (em->size))
542  {
543  GNUNET_break (0);
544  return GNUNET_SYSERR;
545  }
546  return GNUNET_OK;
547 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_MessageHeader header
Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND or GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND...
Definition: core.h:181
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Message sent by the service to clients to notify them about messages being received or transmitted...
Definition: core.h:175
Header for all communications.

◆ handle_notify_inbound()

static void handle_notify_inbound ( void *  cls,
const struct NotifyTrafficMessage ntm 
)
static

Handle inbound message received from CORE service.

If applicable, notify the application.

Parameters
clsthe struct GNUNET_CORE_Handle
ntmthe message we got from CORE.

Definition at line 558 of file core_api.c.

References GNUNET_CORE_Handle::cls, GNUNET_break, GNUNET_CONTAINER_multipeermap_get(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_MQ_inject_message(), PeerRecord::h, LOG, PeerRecord::mq, NotifyTrafficMessage::peer, GNUNET_CORE_Handle::peers, and reconnect_later().

559 {
560  struct GNUNET_CORE_Handle *h = cls;
561  const struct GNUNET_MessageHeader *em;
562  struct PeerRecord *pr;
563 
565  "Received inbound message from `%s'.\n",
566  GNUNET_i2s (&ntm->peer));
567  em = (const struct GNUNET_MessageHeader *) &ntm[1];
569  if (NULL == pr)
570  {
571  GNUNET_break (0);
572  reconnect_later (h);
573  return;
574  }
575  GNUNET_MQ_inject_message (pr->mq, em);
576 }
Context for the core service connection.
Definition: core_api.c:77
Information we track for each peer.
Definition: core_api.c:38
#define LOG(kind,...)
Definition: core_api.c:32
struct GNUNET_MQ_Handle * mq
Message queue for the peer.
Definition: core_api.c:48
void * cls
Closure for the various callbacks.
Definition: core_api.c:87
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static void reconnect_later(struct GNUNET_CORE_Handle *h)
Close down any existing connection to the CORE service and try re-establishing it later...
Definition: core_api.c:215
void GNUNET_MQ_inject_message(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *mh)
Call the message message handler that was registered for the type of the given message in the given m...
Definition: mq.c:202
struct GNUNET_CONTAINER_MultiPeerMap * peers
Hash map listing all of the peers that we are currently connected to.
Definition: core_api.c:118
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
Header for all communications.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_PeerIdentity peer
Identity of the receiver or sender.
Definition: core.h:186
Here is the call graph for this function:

◆ handle_send_ready()

static void handle_send_ready ( void *  cls,
const struct SendMessageReady smr 
)
static

Handle message received from CORE service notifying us that we are now allowed to send a message to a peer.

If that message is still pending, put it into the queue to be transmitted.

Parameters
clsthe struct GNUNET_CORE_Handle
smrthe message we got

Definition at line 588 of file core_api.c.

References GNUNET_CORE_Handle::cls, PeerRecord::env, GNUNET_break, GNUNET_CONTAINER_multipeermap_get(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_MQ_impl_send_continue(), GNUNET_MQ_send(), PeerRecord::h, LOG, PeerRecord::mq, GNUNET_CORE_Handle::mq, SendMessageReady::peer, GNUNET_CORE_Handle::peers, reconnect_later(), SendMessageReady::smr_id, and PeerRecord::smr_id_gen.

589 {
590  struct GNUNET_CORE_Handle *h = cls;
591  struct PeerRecord *pr;
592 
594  if (NULL == pr)
595  {
596  GNUNET_break (0);
597  reconnect_later (h);
598  return;
599  }
601  "Received notification about transmission readiness to `%s'.\n",
602  GNUNET_i2s (&smr->peer));
603  if (NULL == pr->env)
604  {
605  /* request must have been cancelled between the original request
606  * and the response from CORE, ignore CORE's readiness */
607  return;
608  }
609  if (ntohs (smr->smr_id) != pr->smr_id_gen)
610  {
611  /* READY message is for expired or cancelled message,
612  * ignore! (we should have already sent another request) */
613  return;
614  }
615 
616  /* ok, all good, send message out! */
617  GNUNET_MQ_send (h->mq, pr->env);
618  pr->env = NULL;
620 }
struct GNUNET_MQ_Envelope * env
Message we are currently trying to pass to the CORE service for this peer (from mq).
Definition: core_api.c:54
Context for the core service connection.
Definition: core_api.c:77
Information we track for each peer.
Definition: core_api.c:38
#define LOG(kind,...)
Definition: core_api.c:32
struct GNUNET_MQ_Handle * mq
Message queue for the peer.
Definition: core_api.c:48
void * cls
Closure for the various callbacks.
Definition: core_api.c:87
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static void reconnect_later(struct GNUNET_CORE_Handle *h)
Close down any existing connection to the CORE service and try re-establishing it later...
Definition: core_api.c:215
struct GNUNET_MQ_Handle * mq
Our message queue for transmissions to the service.
Definition: core_api.c:112
struct GNUNET_CONTAINER_MultiPeerMap * peers
Hash map listing all of the peers that we are currently connected to.
Definition: core_api.c:118
uint16_t smr_id
smr_id from the request.
Definition: core.h:259
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
uint16_t smr_id_gen
SendMessageRequest ID generator for this peer.
Definition: core_api.c:70
void GNUNET_MQ_impl_send_continue(struct GNUNET_MQ_Handle *mq)
Call the send implementation for the next queued message, if any.
Definition: mq.c:486
struct GNUNET_PeerIdentity peer
Identity of the intended target.
Definition: core.h:264
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function: