GNUnet debian-0.24.3-28-g4f2a77692
 
Loading...
Searching...
No Matches
Core service

Encrypted direct communication between peers. More...

Collaboration diagram for Core service:

Data Structures

struct  GNUNET_CORE_ServiceVersion
 A gnunet service version for services above CORE TODO we might want to be compatible with https://semver.org. More...
 
struct  GNUNET_CORE_ServiceInfo
 Gnunet service info - identifying compatibility with a range of version of a service communicating over CORE. More...
 
struct  EphemeralKeyMessage
 Message transmitted with the signed ephemeral key of a peer. More...
 
struct  PingMessage
 We're sending an (encrypted) PING to the other peer to check if it can decrypt. More...
 
struct  PongMessage
 Response to a PING. More...
 

Macros

#define GNUNET_CORE_SVC_INFO_LEN   64
 Size of the services info field in the cake handshake TODO.
 
#define GNUNET_CORE_VERSION   0x00000001
 Version number of GNUnet-core API.
 
#define CONG_CRYPTO_ENABLED   0
 Enable XChaCha20-Poly1305 crypto https://bugs.gnunet.org/view.php?id=8630.
 

Typedefs

typedef 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.
 
typedef void(* GNUNET_CORE_DisconnectEventHandler) (void *cls, const struct GNUNET_PeerIdentity *peer, void *peer_cls)
 Method called whenever a peer disconnects.
 
typedef void(* GNUNET_CORE_StartupCallback) (void *cls, const struct GNUNET_PeerIdentity *my_identity)
 Function called after GNUNET_CORE_connect has succeeded (or failed for good).
 
typedef void(* GNUNET_CORE_MonitorCallback) (void *cls, const struct GNUNET_PeerIdentity *pid, enum GNUNET_CORE_KxState state, struct GNUNET_TIME_Absolute timeout)
 Function called by the monitor callback whenever a peer's connection status changes.
 

Enumerations

enum  GNUNET_CORE_PeerClass {
  GNUNET_CORE_CLASS_UNKNOWN , GNUNET_CORE_CLASS_UNWILLING , GNUNET_CORE_CLASS_MOBILE , GNUNET_CORE_CLASS_DESKTOP ,
  GNUNET_CORE_CLASS_ROUTER , GNUNET_CORE_CLASS_SERVER
}
 The peer class gives a hint about the capabilities of a peer. More...
 
enum  GNUNET_CORE_Service {
  GNUNET_CORE_SERVICE_CADET , GNUNET_CORE_SERVICE_FS , GNUNET_CORE_SERVICE_DHT , GNUNET_CORE_SERVICE_NSE ,
  GNUNET_CORE_SERVICE_REVOCATION , GNUNET_CORE_SERVICE_HOSTLIST , GNUNET_CORE_SERVICE_TOPOLOGY , GNUNET_CORE_SERVICE_RPS ,
  GNUNET_CORE_SERVICE_TEST
}
 Identifiers for services that communicate over CORE. More...
 
enum  GNUNET_CORE_KxState {
  GNUNET_CORE_KX_STATE_DOWN = 0 , GNUNET_CORE_KX_STATE_INITIATOR_HELLO_SENT , GNUNET_CORE_KX_STATE_AWAIT_INITIATION , GNUNET_CORE_KX_STATE_INITIATOR_HELLO_RECEIVED ,
  GNUNET_CORE_KX_STATE_RESPONDER_HELLO_SENT , GNUNET_CORE_KX_STATE_RESPONDER_HELLO_RECEIVED , GNUNET_CORE_KX_STATE_INITIATOR_DONE_SENT , GNUNET_CORE_KX_STATE_INITIATOR_CONNECTED ,
  GNUNET_CORE_KX_STATE_RESPONDER_CONNECTED , GNUNET_CORE_KX_STATE_REKEY_SENT , GNUNET_CORE_KX_PEER_DISCONNECT , GNUNET_CORE_KX_ITERATION_FINISHED ,
  GNUNET_CORE_KX_CORE_DISCONNECT
}
 TODO how does this harmonize with CAKE_CRYPTO_ENABLED? More...
 

Functions

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, struct GNUNET_CORE_ServiceInfo *service_info)
 Connect to the core service.
 
void GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle)
 Disconnect from the core service.
 
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.
 
struct GNUNET_CORE_MonitorHandleGNUNET_CORE_monitor_start (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CORE_MonitorCallback peer_cb, void *peer_cb_cls)
 Monitor connectivity and KX status of all peers known to CORE.
 
void GNUNET_CORE_monitor_stop (struct GNUNET_CORE_MonitorHandle *mh)
 Stop monitoring CORE activity.
 
int GNUNET_CORE_is_peer_connected_sync (const struct GNUNET_CORE_Handle *h, const struct GNUNET_PeerIdentity *pid)
 Check if the given peer is currently connected.
 

Detailed Description

Encrypted direct communication between peers.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_CORE_SVC_INFO_LEN

#define GNUNET_CORE_SVC_INFO_LEN   64

Size of the services info field in the cake handshake TODO.

Definition at line 53 of file gnunet_core_service.h.

◆ GNUNET_CORE_VERSION

#define GNUNET_CORE_VERSION   0x00000001

Version number of GNUnet-core API.

Definition at line 221 of file gnunet_core_service.h.

◆ CONG_CRYPTO_ENABLED

#define CONG_CRYPTO_ENABLED   0

Enable XChaCha20-Poly1305 crypto https://bugs.gnunet.org/view.php?id=8630.

Definition at line 225 of file gnunet_core_service.h.

Typedef Documentation

◆ GNUNET_CORE_ConnectEventHandler

typedef 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.

TODO provide with the service info about connecting peer/service

Parameters
clsclosure
peerpeer identity this notification is about
classthe class of the connecting peer
Returns
closure associated with peer. given to mq callbacks and GNUNET_CORE_DisconnectEventHandler

Definition at line 458 of file gnunet_core_service.h.

◆ GNUNET_CORE_DisconnectEventHandler

typedef void(* GNUNET_CORE_DisconnectEventHandler) (void *cls, const struct GNUNET_PeerIdentity *peer, void *peer_cls)

Method called whenever a peer disconnects.

Parameters
clsclosure
peerpeer identity this notification is about
peer_clsclosure associated with peer. given in GNUNET_CORE_ConnectEventHandler

Definition at line 473 of file gnunet_core_service.h.

◆ GNUNET_CORE_StartupCallback

typedef void(* GNUNET_CORE_StartupCallback) (void *cls, const struct GNUNET_PeerIdentity *my_identity)

Function called after GNUNET_CORE_connect has succeeded (or failed for good).

Note that the private key of the peer is intentionally not exposed here; if you need to sign something, do this via the pils service. Implementations of this function must not call GNUNET_CORE_disconnect (other than by scheduling a new task to do this later).

TODO we could potentially also remove the identity argument

Parameters
clsclosure
my_identityID of this peer, NULL if we failed

Definition at line 492 of file gnunet_core_service.h.

◆ GNUNET_CORE_MonitorCallback

typedef void(* GNUNET_CORE_MonitorCallback) (void *cls, const struct GNUNET_PeerIdentity *pid, enum GNUNET_CORE_KxState state, struct GNUNET_TIME_Absolute timeout)

Function called by the monitor callback whenever a peer's connection status changes.

Parameters
clsclosure
pididentity of the peer this update is about
statecurrent key exchange state of the peer
timeoutwhen does the current state expire

Definition at line 670 of file gnunet_core_service.h.

Enumeration Type Documentation

◆ GNUNET_CORE_PeerClass

The peer class gives a hint about the capabilities of a peer.

The general idea is to signal capabilities like connectivity/bandwidth, computational and storage capabilities and stability in the network.

TODO

  • this might move out of core to a more generic place
  • for now it is static, but it could in the future also include more detailed and dynamic attributes like 'battery-bound', 'behind more expensive mobile-bandwidth-connection', ...
  • it is only a general idea and it needs to be seen in the future how this will be used. With it's usage it will probably evolve into whatever seems to be useful
Enumerator
GNUNET_CORE_CLASS_UNKNOWN 

The device's capabilities are currently unknown.

GNUNET_CORE_CLASS_UNWILLING 

This device is currently unwilling to spend more then the absolutely necessary ressources.

GNUNET_CORE_CLASS_MOBILE 

This is a mobile device.

A smartphone or laptop. Could be battery bound, could be behind a costly mobile broadband connection.

GNUNET_CORE_CLASS_DESKTOP 

This is a desktop computer.

Probably on continuous power supply and a decent, rather stable internet connection. Probably not online 24/7. Probably behind NAT.

GNUNET_CORE_CLASS_ROUTER 

This is a piece of network infrastructure.

General computational and storage capabilities not overly high. Good placement in a network. Probably online 24/7

GNUNET_CORE_CLASS_SERVER 

This is something like a server.

Has good computational and storage capabilities. Has a stable connection with decent bandwidth. Is online 24/7. Might not be behind NAT.

Definition at line 69 of file gnunet_core_service.h.

70{
75
81
87
94
101
108};
@ GNUNET_CORE_CLASS_SERVER
This is something like a server.
@ GNUNET_CORE_CLASS_UNKNOWN
The device's capabilities are currently unknown.
@ GNUNET_CORE_CLASS_ROUTER
This is a piece of network infrastructure.
@ GNUNET_CORE_CLASS_MOBILE
This is a mobile device.
@ GNUNET_CORE_CLASS_DESKTOP
This is a desktop computer.
@ GNUNET_CORE_CLASS_UNWILLING
This device is currently unwilling to spend more then the absolutely necessary ressources.

◆ GNUNET_CORE_Service

Identifiers for services that communicate over CORE.

Enumerator
GNUNET_CORE_SERVICE_CADET 

Identifier for cadet service.

GNUNET_CORE_SERVICE_FS 

Identifier for fs (file sharing) service.

GNUNET_CORE_SERVICE_DHT 

Identifier for dht (distributed hash table) service.

GNUNET_CORE_SERVICE_NSE 

Identifier for nse (network size estimation) service.

GNUNET_CORE_SERVICE_REVOCATION 

Identifier for revocation service.

GNUNET_CORE_SERVICE_HOSTLIST 

Identifier for hostlist service.

GNUNET_CORE_SERVICE_TOPOLOGY 

Identifier for topology service.

GNUNET_CORE_SERVICE_RPS 

Identifier for rps (random peer sampling) service.

GNUNET_CORE_SERVICE_TEST 

Identifier for testing the api.

Definition at line 114 of file gnunet_core_service.h.

115{
120
125
130
135
140
145
150
155
156 // Note: Services using core need to define their own Identifier here
157
162};
@ GNUNET_CORE_SERVICE_TOPOLOGY
Identifier for topology service.
@ GNUNET_CORE_SERVICE_DHT
Identifier for dht (distributed hash table) service.
@ GNUNET_CORE_SERVICE_NSE
Identifier for nse (network size estimation) service.
@ GNUNET_CORE_SERVICE_CADET
Identifier for cadet service.
@ GNUNET_CORE_SERVICE_RPS
Identifier for rps (random peer sampling) service.
@ GNUNET_CORE_SERVICE_FS
Identifier for fs (file sharing) service.
@ GNUNET_CORE_SERVICE_REVOCATION
Identifier for revocation service.
@ GNUNET_CORE_SERVICE_TEST
Identifier for testing the api.
@ GNUNET_CORE_SERVICE_HOSTLIST
Identifier for hostlist service.

◆ GNUNET_CORE_KxState

TODO how does this harmonize with CAKE_CRYPTO_ENABLED?

State machine for our P2P encryption handshake. Everyone starts in GNUNET_CORE_KX_STATE_DOWN, if we receive the other peer's key (other peer initiated) we start in state #GNUNET_CORE_KX_STATE_KEY_RECEIVED (since we will immediately send our own); otherwise we start in #GNUNET_CORE_KX_STATE_KEY_SENT. If we get back a PONG from within either state, we move up to #GNUNET_CORE_KX_STATE_UP (the PONG will always be sent back encrypted with the key we sent to the other peer). Eventually, we will try to rekey, for this we will enter GNUNET_CORE_KX_STATE_REKEY_SENT until the rekey operation is confirmed by a PONG from the other peer.

Enumerator
GNUNET_CORE_KX_STATE_DOWN 

No handshake yet.

GNUNET_CORE_KX_STATE_INITIATOR_HELLO_SENT 

We sent the initiator hello.

GNUNET_CORE_KX_STATE_AWAIT_INITIATION 

We are awating the initiator hello.

GNUNET_CORE_KX_STATE_INITIATOR_HELLO_RECEIVED 

We've received the initiator hello.

GNUNET_CORE_KX_STATE_RESPONDER_HELLO_SENT 

We sent the responder hello.

GNUNET_CORE_KX_STATE_RESPONDER_HELLO_RECEIVED 

We've received the initiator hello.

GNUNET_CORE_KX_STATE_INITIATOR_DONE_SENT 

We sent initiator done.

GNUNET_CORE_KX_STATE_INITIATOR_CONNECTED 

Connected as initiator.

GNUNET_CORE_KX_STATE_RESPONDER_CONNECTED 

Connected as responder.

GNUNET_CORE_KX_STATE_REKEY_SENT 

We're rekeying (or had a timeout), so we have sent the other peer our new ephemeral key, but we did not get a matching PONG yet.

This is equivalent to being #GNUNET_CORE_KX_STATE_KEY_RECEIVED, except that the session is marked as 'up' with sessions (as we don't want to drop and re-establish P2P connections simply due to rekeying).

GNUNET_CORE_KX_PEER_DISCONNECT 

Last state of a KX (when it is being terminated).

Set just before CORE frees the internal state for this peer.

GNUNET_CORE_KX_ITERATION_FINISHED 

This is not a state in a peer's state machine, but a special value used with the GNUNET_CORE_MonitorCallback to indicate that we finished the initial iteration over the peers.

GNUNET_CORE_KX_CORE_DISCONNECT 

This is not a state in a peer's state machine, but a special value used with the GNUNET_CORE_MonitorCallback to indicate that we lost the connection to the CORE service (and will try to reconnect).

If this happens, most likely the CORE service crashed and thus all connection state should be assumed lost.

Definition at line 580 of file gnunet_core_service.h.

581{
586
591
596
601
606
611
616
621
626
636
642
649
658};
@ GNUNET_CORE_KX_PEER_DISCONNECT
Last state of a KX (when it is being terminated).
@ GNUNET_CORE_KX_STATE_RESPONDER_CONNECTED
Connected as responder.
@ GNUNET_CORE_KX_STATE_DOWN
No handshake yet.
@ GNUNET_CORE_KX_STATE_INITIATOR_DONE_SENT
We sent initiator done.
@ GNUNET_CORE_KX_CORE_DISCONNECT
This is not a state in a peer's state machine, but a special value used with the GNUNET_CORE_MonitorC...
@ GNUNET_CORE_KX_STATE_INITIATOR_HELLO_RECEIVED
We've received the initiator hello.
@ GNUNET_CORE_KX_STATE_AWAIT_INITIATION
We are awating the initiator hello.
@ GNUNET_CORE_KX_STATE_INITIATOR_CONNECTED
Connected as initiator.
@ GNUNET_CORE_KX_STATE_INITIATOR_HELLO_SENT
We sent the initiator hello.
@ GNUNET_CORE_KX_STATE_RESPONDER_HELLO_RECEIVED
We've received the initiator hello.
@ GNUNET_CORE_KX_STATE_RESPONDER_HELLO_SENT
We sent the responder hello.
@ GNUNET_CORE_KX_ITERATION_FINISHED
This is not a state in a peer's state machine, but a special value used with the GNUNET_CORE_MonitorC...
@ GNUNET_CORE_KX_STATE_REKEY_SENT
We're rekeying (or had a timeout), so we have sent the other peer our new ephemeral key,...

Function Documentation

◆ GNUNET_CORE_connect()

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.

Note that the connection may complete (or fail) asynchronously. This function primarily causes the given callback notification functions to be invoked whenever the specified event happens. The maximum number of queued notifications (queue length) is per client; the queue is shared across all types of notifications. So a slow client that registers for outbound_notify also risks missing inbound_notify messages. Certain events (such as connect/disconnect notifications) are not subject to queue size limitations.

Parameters
cfgconfiguration to use
clsclosure for the various callbacks that follow (including handlers in the handlers array)
initcallback to call once we have successfully connected to the core service
connectsfunction to call on peer connect, can be NULL
disconnectsfunction to call on peer disconnect / timeout, can be NULL
handlerscallbacks for messages we care about, NULL-terminated note that the core is allowed to drop notifications about inbound messages if the client does not process them fast enough (for this notification type, a bounded queue is used)
service_infoinformation about the connecting service and its compatibility with other service versions
Returns
handle to the core service (only useful for disconnect until init is called), NULL on error (in this case, init is never called)

Note that the connection may complete (or fail) asynchronously.

Parameters
cfgconfiguration to use
clsclosure for the various callbacks that follow (including handlers in the handlers array)
initcallback to call once we have successfully connected to the core service
connectsfunction to call on peer connect, can be NULL
disconnectsfunction to call on peer disconnect / timeout, can be NULL
handlerscallbacks for messages we care about, NULL-terminated
Returns
handle to the core service (only useful for disconnect until init is called); NULL on error (in this case, init is never called)

Definition at line 698 of file core_api.c.

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}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition 003.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
#define LOG(kind,...)
Definition core_api.c:32
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
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition core_api.c:744
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).
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_MQ_MessageHandler * GNUNET_MQ_copy_handlers(const struct GNUNET_MQ_MessageHandler *handlers)
Copy an array of handlers.
Definition mq.c:974
unsigned int GNUNET_MQ_count_handlers(const struct GNUNET_MQ_MessageHandler *handlers)
Count the handlers in a handler array.
Definition mq.c:1017
static void reconnect(void)
Adjust exponential back-off and reconnect to the service.
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
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_CORE_ServiceInfo service_info
Services info field for the connected service.
Definition core_api.c:148
Message transmitted core clients to gnunet-service-core to start the interaction.
Definition core.h:82

References cfg, GNUNET_ARM_Handle::cfg, GNUNET_CORE_Handle::cls, connects(), disconnects(), GNUNET_assert, GNUNET_CONTAINER_multipeermap_create(), GNUNET_CORE_disconnect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MAX_MESSAGE_SIZE, GNUNET_MQ_copy_handlers(), GNUNET_MQ_count_handlers(), GNUNET_new, GNUNET_NO, h, handlers, init, LOG, GNUNET_ARM_Handle::mq, reconnect(), and GNUNET_CORE_Handle::service_info.

Referenced by DHTU_gnunet_init(), exec_connect_run(), GCO_init(), main_init(), run(), run(), run(), run(), and run().

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

◆ GNUNET_CORE_disconnect()

void GNUNET_CORE_disconnect ( struct GNUNET_CORE_Handle handle)

Disconnect from the core service.

Parameters
handleconnection to core to disconnect

Definition at line 744 of file core_api.c.

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}
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 struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition gnunet-vpn.c:35
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.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition mq.c:700
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:980
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Definition vpn_api.c:44

References disconnect_and_free_peer_entry(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), handle, LOG, and GNUNET_VPN_Handle::mq.

Referenced by cleaning_task(), cleaning_task(), DHTU_gnunet_done(), exec_connect_cleanup(), GCO_shutdown(), GNUNET_CORE_connect(), shutdown_task(), shutdown_task(), shutdown_task(), and shutdown_task().

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

◆ GNUNET_CORE_get_mq()

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.

Messages may only be queued with GNUNET_MQ_send once the init callback has been called for the given handle.

TODO does this function in this form make sense? it's not used anywhere. Also it probably should take a hello as argument.

Parameters
hthe core handle
pidthe identity of the peer
Returns
NULL if pid is not connected
Parameters
hthe core handle
pidthe identity of the peer to check if it has been connected to us
Returns
NULL if peer is not connected

Definition at line 775 of file core_api.c.

777{
778 struct PeerRecord *pr;
779
781 if (NULL == pr)
782 return NULL;
783 return pr->mq;
784}
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
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.
Information we track for each peer.
Definition core_api.c:39
struct GNUNET_MQ_Handle * mq
Message queue for the peer.
Definition core_api.c:48

References GNUNET_CONTAINER_multipeermap_get(), h, PeerRecord::mq, and pid.

Here is the call graph for this function:

◆ GNUNET_CORE_monitor_start()

struct GNUNET_CORE_MonitorHandle * GNUNET_CORE_monitor_start ( const struct GNUNET_CONFIGURATION_Handle cfg,
GNUNET_CORE_MonitorCallback  peer_cb,
void *  peer_cb_cls 
)

Monitor connectivity and KX status of all peers known to CORE.

Calls peer_cb with the current status for each connected peer, and then once with NULL to indicate that all peers that are currently active have been handled. After that, the iteration continues until it is cancelled. Normal users of the CORE API are not expected to use this function. It is different in that it truly lists all connections (including those where the KX is in progress), not just those relevant to the application. This function is used by special applications for diagnostics.

Parameters
cfgconfiguration handle
peer_cbfunction to call with the peer information
peer_cb_clsclosure for peer_cb
Returns
NULL on error

Definition at line 158 of file core_api_monitor_peers.c.

161{
163
164 GNUNET_assert (NULL != peer_cb);
166 mh->cfg = cfg;
167 reconnect (mh);
168 mh->peer_cb = peer_cb;
169 mh->peer_cb_cls = peer_cb_cls;
170 if (NULL == mh->mq)
171 {
172 GNUNET_free (mh);
173 return NULL;
174 }
175 return mh;
176}
static struct GNUNET_CADET_Handle * mh
Cadet handle.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration given by the client, in case of reconnection.
Definition cadet_api.c:63
struct GNUNET_MQ_Handle * mq
Message queue.
Definition cadet_api.c:43
Handle to a CORE monitoring operation.
GNUNET_CORE_MonitorCallback peer_cb
Function called with the peer.
void * peer_cb_cls
Closure for peer_cb.

References cfg, GNUNET_CADET_Handle::cfg, GNUNET_assert, GNUNET_free, GNUNET_new, mh, GNUNET_CADET_Handle::mq, GNUNET_CORE_MonitorHandle::peer_cb, GNUNET_CORE_MonitorHandle::peer_cb_cls, and reconnect().

Referenced by run().

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

◆ GNUNET_CORE_monitor_stop()

void GNUNET_CORE_monitor_stop ( struct GNUNET_CORE_MonitorHandle mh)

Stop monitoring CORE activity.

Parameters
mhmonitor to stop

Definition at line 185 of file core_api_monitor_peers.c.

186{
187 if (NULL != mh->mq)
188 {
190 mh->mq = NULL;
191 }
192 GNUNET_free (mh);
193}

References GNUNET_free, GNUNET_MQ_destroy(), mh, and GNUNET_CADET_Handle::mq.

Referenced by shutdown_task().

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

◆ GNUNET_CORE_is_peer_connected_sync()

int GNUNET_CORE_is_peer_connected_sync ( const struct GNUNET_CORE_Handle h,
const struct GNUNET_PeerIdentity pid 
)

Check if the given peer is currently connected.

This function is for special circumstances (GNUNET_TESTBED uses it), normal users of the CORE API are expected to track which peers are connected based on the connect/disconnect callbacks from GNUNET_CORE_connect. This function is NOT part of the 'versioned', 'official' API. This function returns synchronously after looking in the CORE API cache.

FIXME not implemented

Parameters
hthe core handle
pidthe identity of the peer to check if it has been connected to us
Returns
GNUNET_YES if the peer is connected to us; GNUNET_NO if not