GNUnet debian-0.24.3-24-gfea921bd2
core_api.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009-2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_constants.h"
29#include "gnunet_core_service.h"
30#include "core.h"
31
32#define LOG(kind, ...) GNUNET_log_from (kind, "core-api", __VA_ARGS__)
33
34
39{
44
49
55
61
66
70 uint16_t smr_id_gen;
71};
72
73
78{
83
87 void *cls;
88
93
98
103
108
113
119
124
129
134
138 unsigned int hcnt;
139
144
149};
150
151
158static void
160
161
167static void
168reconnect_task (void *cls)
169{
170 struct GNUNET_CORE_Handle *h = cls;
171
172 h->reconnect_task = NULL;
173 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to CORE service after delay\n");
174 reconnect (h);
175}
176
177
187static int
189 const struct GNUNET_PeerIdentity *key,
190 void *value)
191{
192 struct GNUNET_CORE_Handle *h = cls;
193 struct PeerRecord *pr = value;
194
195 GNUNET_assert (pr->h == h);
196 if (NULL != h->disconnects)
197 h->disconnects (h->cls, &pr->peer, pr->client_cls);
200 GNUNET_MQ_destroy (pr->mq);
201 GNUNET_assert (NULL == pr->mq);
202 if (NULL != pr->env)
203 {
205 pr->env = NULL;
206 }
207 GNUNET_free (pr);
208 return GNUNET_YES;
209}
210
211
218static void
220{
221 GNUNET_assert (NULL == h->reconnect_task);
222 if (NULL != h->mq)
223 {
225 h->mq = NULL;
226 }
227 GNUNET_assert (NULL == h->reconnect_task);
232 h);
234}
235
236
244static void
245handle_mq_error (void *cls, enum GNUNET_MQ_Error error)
246{
247 struct GNUNET_CORE_Handle *h = cls;
248
249 LOG (GNUNET_ERROR_TYPE_DEBUG, "MQ ERROR: %d\n", error);
251}
252
253
262static void
264 const struct GNUNET_MessageHeader *msg,
265 void *impl_state)
266{
267 struct PeerRecord *pr = impl_state;
268 struct GNUNET_CORE_Handle *h = pr->h;
269 struct SendMessageRequest *smr;
270 struct SendMessage *sm;
271 struct GNUNET_MQ_Envelope *env;
272 uint16_t msize;
274
275 if (NULL == h->mq)
276 {
277 /* We're currently reconnecting, pretend this worked */
279 return;
280 }
281 GNUNET_assert (NULL == pr->env);
282 /* extract options from envelope */
285
286 /* check message size for sanity */
287 msize = ntohs (msg->size);
288 if (msize >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct SendMessage))
289 {
290 GNUNET_break (0);
292 return;
293 }
294
295 /* ask core for transmission */
297 "Asking core for transmission of %u bytes to `%s'\n",
298 (unsigned int) msize,
299 GNUNET_i2s (&pr->peer));
301 smr->priority = htonl ((uint32_t) flags);
302 smr->peer = pr->peer;
303 smr->size = htons (msize);
304 smr->smr_id = htons (++pr->smr_id_gen);
306
307 /* prepare message with actual transmission data */
309 sm->priority = htonl ((uint32_t) flags);
310 sm->peer = pr->peer;
312 "Calling get_message with buffer of %u bytes\n",
313 (unsigned int) msize);
314}
315
316
324static void
325core_mq_destroy_impl (struct GNUNET_MQ_Handle *mq, void *impl_state)
326{
327 struct PeerRecord *pr = impl_state;
328
329 GNUNET_assert (mq == pr->mq);
330 pr->mq = NULL;
331}
332
333
341static void
342core_mq_cancel_impl (struct GNUNET_MQ_Handle *mq, void *impl_state)
343{
344 struct PeerRecord *pr = impl_state;
345
346 (void) mq;
347 GNUNET_assert (NULL != pr->env);
349 pr->env = NULL;
350}
351
352
361static void
363{
364 /* struct PeerRecord *pr = cls; */
365 (void) cls;
366 (void) error;
367 GNUNET_break_op (0);
368}
369
370
380static void
382 const struct GNUNET_PeerIdentity *peer,
383 enum GNUNET_CORE_PeerClass class)
384{
385 struct PeerRecord *pr;
386
387 pr = GNUNET_new (struct PeerRecord);
388 pr->peer = *peer;
389 pr->h = h;
392 h->peers,
393 &pr->peer,
394 pr,
399 pr,
400 h->handlers,
402 pr);
403 if (NULL != h->connects)
404 {
405 pr->client_cls = h->connects (h->cls, &pr->peer, pr->mq, class);
407 }
408}
409
410
419static void
420handle_init_reply (void *cls, const struct InitReplyMessage *m)
421{
422 struct GNUNET_CORE_Handle *h = cls;
424
425 GNUNET_break (0 == ntohl (m->reserved));
427 if (NULL != (init = h->init))
428 {
429 /* mark so we don't call init on reconnect */
430 h->init = NULL;
431 h->me = m->my_identity;
433 "Connected to core service of peer `%s'.\n",
434 GNUNET_i2s (&h->me));
435 h->have_init = GNUNET_YES;
436 init (h->cls, &h->me);
437 }
438 else
439 {
441 "Successfully reconnected to core service.\n");
442 if (GNUNET_NO == h->have_init)
443 {
444 h->me = m->my_identity;
445 h->have_init = GNUNET_YES;
446 }
447 else
448 {
449 GNUNET_break (0 == memcmp (&h->me,
450 &m->my_identity,
451 sizeof(struct GNUNET_PeerIdentity)));
452 }
453 }
454 /* fake 'connect to self' */
455 connect_peer (h, &h->me, m->class);
456}
457
458
466static void
468{
469 struct GNUNET_CORE_Handle *h = cls;
470 struct PeerRecord *pr;
471
473 "Received notification about connection from `%s'.\n",
474 GNUNET_i2s (&cnm->peer));
475 if (0 == memcmp (&h->me, &cnm->peer, sizeof(struct GNUNET_PeerIdentity)))
476 {
477 /* connect to self!? */
478 GNUNET_break (0);
479 return;
480 }
481 pr = GNUNET_CONTAINER_multipeermap_get (h->peers, &cnm->peer);
482 if (NULL != pr)
483 {
484 GNUNET_break (0);
486 return;
487 }
488 connect_peer (h, &cnm->peer, cnm->peer_class);
489}
490
491
499static void
501{
502 struct GNUNET_CORE_Handle *h = cls;
503 struct PeerRecord *pr;
504
505 if (0 == memcmp (&h->me, &dnm->peer, sizeof(struct GNUNET_PeerIdentity)))
506 {
507 /* disconnect from self!? */
508 GNUNET_break (0);
509 return;
510 }
511 GNUNET_break (0 == ntohl (dnm->reserved));
513 "Received notification about disconnect from `%s'.\n",
514 GNUNET_i2s (&dnm->peer));
515 pr = GNUNET_CONTAINER_multipeermap_get (h->peers, &dnm->peer);
516 if (NULL == pr)
517 {
518 GNUNET_break (0);
520 return;
521 }
523}
524
525
533static int
534check_notify_inbound (void *cls, const struct NotifyTrafficMessage *ntm)
535{
536 uint16_t msize;
537 const struct GNUNET_MessageHeader *em;
538
539 (void) cls;
540 msize = ntohs (ntm->header.size) - sizeof(struct NotifyTrafficMessage);
541 if (msize < sizeof(struct GNUNET_MessageHeader))
542 {
543 GNUNET_break (0);
544 return GNUNET_SYSERR;
545 }
546 em = (const struct GNUNET_MessageHeader *) &ntm[1];
547 if (msize != ntohs (em->size))
548 {
549 GNUNET_break (0);
550 return GNUNET_SYSERR;
551 }
552 return GNUNET_OK;
553}
554
555
563static void
564handle_notify_inbound (void *cls, const struct NotifyTrafficMessage *ntm)
565{
566 struct GNUNET_CORE_Handle *h = cls;
567 const struct GNUNET_MessageHeader *em;
568 struct PeerRecord *pr;
569
571 "Received inbound message from `%s'.\n",
572 GNUNET_i2s (&ntm->peer));
573 em = (const struct GNUNET_MessageHeader *) &ntm[1];
574 pr = GNUNET_CONTAINER_multipeermap_get (h->peers, &ntm->peer);
575 if (NULL == pr)
576 {
577 GNUNET_break (0);
579 return;
580 }
582}
583
584
593static void
594handle_send_ready (void *cls, const struct SendMessageReady *smr)
595{
596 struct GNUNET_CORE_Handle *h = cls;
597 struct PeerRecord *pr;
598
599 pr = GNUNET_CONTAINER_multipeermap_get (h->peers, &smr->peer);
600 if (NULL == pr)
601 {
602 GNUNET_break (0);
604 return;
605 }
607 "Received notification about transmission readiness to `%s'.\n",
608 GNUNET_i2s (&smr->peer));
609 if (NULL == pr->env)
610 {
611 /* request must have been cancelled between the original request
612 * and the response from CORE, ignore CORE's readiness */
613 return;
614 }
615 if (ntohs (smr->smr_id) != pr->smr_id_gen)
616 {
617 /* READY message is for expired or cancelled message,
618 * ignore! (we should have already sent another request) */
619 return;
620 }
621
622 /* ok, all good, send message out! */
623 GNUNET_MQ_send (h->mq, pr->env);
624 pr->env = NULL;
626}
627
628
635static void
637{
639 { GNUNET_MQ_hd_fixed_size (init_reply,
641 struct InitReplyMessage,
642 h),
646 h),
650 h),
651 GNUNET_MQ_hd_var_size (notify_inbound,
654 h),
655 GNUNET_MQ_hd_fixed_size (send_ready,
657 struct SendMessageReady,
658 h),
660 struct InitMessage *init;
661 struct GNUNET_MQ_Envelope *env;
662 uint16_t *ts;
663
664 GNUNET_assert (NULL == h->mq);
666 if (NULL == h->mq)
667 {
669 return;
670 }
672 sizeof(uint16_t) * h->hcnt,
674 LOG (GNUNET_ERROR_TYPE_INFO, "(Re)connecting to CORE service\n");
675 init->options = htonl (0);
676 ts = (uint16_t *) &init[1];
677 for (unsigned int hpos = 0; hpos < h->hcnt; hpos++)
678 ts[hpos] = htons (h->handlers[hpos].type);
680}
681
682
697struct GNUNET_CORE_Handle *
699 void *cls,
703 /* TODO handler for peerID change */
704 /* TODO do we need a handler for address change? -
705 * currently don't think so. I guess pils might be the
706 * responsible service? */
709{
710 struct GNUNET_CORE_Handle *h;
711
713 h->cfg = cfg;
714 h->cls = cls;
715 h->init = init;
716 h->connects = connects;
717 h->disconnects = disconnects;
719 h->handlers = GNUNET_MQ_copy_handlers (handlers);
721 // TODO this needs an assertion in the future:
722 // GNUNET_assert (NULL != service_info);
723 h->service_info = *service_info;
724 GNUNET_assert (h->hcnt <
725 (GNUNET_MAX_MESSAGE_SIZE - sizeof(struct InitMessage))
726 / sizeof(uint16_t));
727 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to CORE service\n");
728 reconnect (h);
729 if (NULL == h->mq)
730 {
732 return NULL;
733 }
734 return h;
735}
736
737
743void
745{
746 LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from CORE service\n");
749 handle);
751 handle->peers = NULL;
752 if (NULL != handle->reconnect_task)
753 {
754 GNUNET_SCHEDULER_cancel (handle->reconnect_task);
755 handle->reconnect_task = NULL;
756 }
757 if (NULL != handle->mq)
758 {
760 handle->mq = NULL;
761 }
762 GNUNET_free (handle->handlers);
764}
765
766
774struct GNUNET_MQ_Handle *
776 const struct GNUNET_PeerIdentity *pid)
777{
778 struct PeerRecord *pr;
779
781 if (NULL == pr)
782 return NULL;
783 return pr->mq;
784}
785
786
787/* end of core_api.c */
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
void * connects(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Definition: 010.c:2
void disconnects(void *cls, const struct GNUNET_PeerIdentity *peer)
Definition: 011.c:2
common internal definitions for core service
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:188
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...
Definition: core_api.c:594
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:219
static void connect_peer(struct GNUNET_CORE_Handle *h, const struct GNUNET_PeerIdentity *peer, enum GNUNET_CORE_PeerClass class)
Add the given peer to the list of our connected peers and create the respective data structures and n...
Definition: core_api.c:381
static int check_notify_inbound(void *cls, const struct NotifyTrafficMessage *ntm)
Check that message received from CORE service is well-formed.
Definition: core_api.c:534
static void handle_connect_notify(void *cls, const struct ConnectNotifyMessage *cnm)
Handle connect message received from CORE service.
Definition: core_api.c:467
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:263
static void handle_disconnect_notify(void *cls, const struct DisconnectNotifyMessage *dnm)
Handle disconnect message received from CORE service.
Definition: core_api.c:500
static void reconnect(struct GNUNET_CORE_Handle *h)
Our current client connection went down.
Definition: core_api.c:636
static void handle_notify_inbound(void *cls, const struct NotifyTrafficMessage *ntm)
Handle inbound message received from CORE service.
Definition: core_api.c:564
static void handle_init_reply(void *cls, const struct InitReplyMessage *m)
Handle init reply message received from CORE service.
Definition: core_api.c:420
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:342
#define LOG(kind,...)
Definition: core_api.c:32
static void core_mq_destroy_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
Handle destruction of a message queue.
Definition: core_api.c:325
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:245
static void reconnect_task(void *cls)
Task schedule to try to re-connect to core.
Definition: core_api.c:168
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:362
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:103
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:98
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
static char * init
Set to the name of a service to start.
Definition: gnunet-arm.c:73
static void disconnect_notify(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Method called whenever a peer disconnects.
static void * connect_notify(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq, enum GNUNET_CORE_PeerClass class)
Method called whenever a peer connects.
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
Core service; the main API for encrypted P2P communications.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
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:1060
void(* GNUNET_CORE_DisconnectEventHandler)(void *cls, const struct GNUNET_PeerIdentity *peer, void *peer_cls)
Method called whenever a peer disconnects.
GNUNET_CORE_PeerClass
The peer class gives a hint about the capabilities of a peer.
struct GNUNET_CORE_Handle * GNUNET_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, struct GNUNET_CORE_ServiceInfo *service_info)
Connect to the core service.
Definition: core_api.c:698
struct GNUNET_MQ_Handle * GNUNET_CORE_get_mq(const struct GNUNET_CORE_Handle *h, const struct GNUNET_PeerIdentity *pid)
Obtain the message queue for a connected peer.
Definition: core_api.c:775
void(* GNUNET_CORE_StartupCallback)(void *cls, const struct GNUNET_PeerIdentity *my_identity)
Function called after GNUNET_CORE_connect has succeeded (or failed for good).
void *(* GNUNET_CORE_ConnectEventHandler)(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq, enum GNUNET_CORE_PeerClass class)
Method called whenever a given peer connects.
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition: core_api.c:744
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_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
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.
enum GNUNET_GenericReturnValue 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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MQ_Error
Error codes for the queue.
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:482
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:305
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:285
#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:61
#define GNUNET_MQ_msg_nested_mh(mvar, type, mh)
Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct.
struct GNUNET_MQ_MessageHandler * GNUNET_MQ_copy_handlers(const struct GNUNET_MQ_MessageHandler *handlers)
Copy an array of handlers.
Definition: mq.c:974
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:437
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:76
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:187
GNUNET_MQ_PriorityPreferences
Per envelope preferences and priorities.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
enum GNUNET_MQ_PriorityPreferences GNUNET_MQ_env_get_options(struct GNUNET_MQ_Envelope *env)
Get performance preferences set for this envelope.
Definition: mq.c:856
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
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:506
unsigned int GNUNET_MQ_count_handlers(const struct GNUNET_MQ_MessageHandler *handlers)
Count the handlers in a handler array.
Definition: mq.c:1017
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:830
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:700
#define GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST
Request from client to transmit message.
#define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT
Notify clients about new peer-to-peer connections (triggered after key exchange).
#define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT
Notify clients about peer disconnecting.
#define GNUNET_MESSAGE_TYPE_CORE_INIT
Initial setup message from core client to core.
#define GNUNET_MESSAGE_TYPE_CORE_SEND
Client with message to transmit (after SEND_READY confirmation was received).
#define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND
Notify clients about incoming P2P messages.
#define GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY
Response from core to core client to INIT message.
#define GNUNET_MESSAGE_TYPE_CORE_SEND_READY
Confirmation from core that message can now be sent.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:980
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:1277
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
Message sent by the service to clients to notify them about a peer connecting.
Definition: core.h:129
struct GNUNET_PeerIdentity peer
Identity of the connecting peer.
Definition: core.h:143
enum GNUNET_CORE_PeerClass peer_class
Class of the connecting peer TODO is it correct to send an enum like this?
Definition: core.h:149
Message sent by the service to clients to notify them about a peer disconnecting.
Definition: core.h:158
uint32_t reserved
Always zero.
Definition: core.h:167
struct GNUNET_PeerIdentity peer
Identity of the connecting peer.
Definition: core.h:172
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
struct GNUNET_TIME_Relative retry_backoff
Current delay we use for re-trying to connect to core.
Definition: arm_api.c:152
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
Definition: arm_api.c:147
Internal representation of the hash map.
Context for the core service connection.
Definition: core_api.c:78
void * cls
Closure for the various callbacks.
Definition: core_api.c:87
struct GNUNET_CONTAINER_MultiPeerMap * peers
Hash map listing all of the peers that we are currently connected to.
Definition: core_api.c:118
GNUNET_CORE_DisconnectEventHandler disconnects
Function to call whenever we're notified about a peer disconnecting.
Definition: core_api.c:102
GNUNET_CORE_ConnectEventHandler connects
Function to call whenever we're notified about a peer connecting.
Definition: core_api.c:97
struct GNUNET_MQ_Handle * mq
Our message queue for transmissions to the service.
Definition: core_api.c:112
struct GNUNET_MQ_MessageHandler * handlers
Function handlers for messages of particular type.
Definition: core_api.c:107
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
GNUNET_CORE_StartupCallback init
Function to call once we've handshaked with the core service.
Definition: core_api.c:92
struct GNUNET_CORE_ServiceInfo service_info
Services info field for the connected service.
Definition: core_api.c:148
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we're using.
Definition: core_api.c:82
unsigned int hcnt
Number of entries in the handlers array.
Definition: core_api.c:138
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of reconnect task (if any).
Definition: core_api.c:128
struct GNUNET_PeerIdentity me
Identity of this peer.
Definition: core_api.c:123
Gnunet service info - identifying compatibility with a range of version of a service communicating ov...
Handle to a message queue.
Definition: mq.c:87
Message handler for a specific message type.
Header for all communications.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Definition: scheduler.c:136
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Definition: vpn_api.c:44
Message transmitted core clients to gnunet-service-core to start the interaction.
Definition: core.h:82
Message transmitted by the gnunet-service-core process to its clients in response to an INIT message.
Definition: core.h:100
Message sent by the service to clients to notify them about messages being received or transmitted.
Definition: core.h:186
struct GNUNET_MessageHeader header
Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND or GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND.
Definition: core.h:191
struct GNUNET_PeerIdentity peer
Identity of the receiver or sender.
Definition: core.h:196
Information we track for each peer.
Definition: core_api.c:39
uint16_t smr_id_gen
SendMessageRequest ID generator for this peer.
Definition: core_api.c:70
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
struct GNUNET_PeerIdentity peer
Peer the record is about.
Definition: core_api.c:65
struct GNUNET_MQ_Handle * mq
Message queue for the peer.
Definition: core_api.c:48
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
Core notifying client that it is allowed to now transmit a message to the given target (response to G...
Definition: core.h:252
uint16_t smr_id
smr_id from the request.
Definition: core.h:269
struct GNUNET_PeerIdentity peer
Identity of the intended target.
Definition: core.h:274
Client notifying core about the maximum-priority message it has in the queue for a particular target.
Definition: core.h:207
uint32_t priority
How important is this message?
Definition: core.h:216
struct GNUNET_PeerIdentity peer
Identity of the intended target.
Definition: core.h:227
uint16_t size
How large is the message?
Definition: core.h:237
uint16_t smr_id
Counter for this peer to match SMRs to replies.
Definition: core.h:242
Client asking core to transmit a particular message to a particular target (response to GNUNET_MESSAG...
Definition: core.h:283
uint32_t priority
How important is this message? Contains a enum GNUNET_MQ_PriorityPreferences in NBO.
Definition: core.h:293
struct GNUNET_PeerIdentity peer
Identity of the intended receiver.
Definition: core.h:304