GNUnet  0.19.2
gnunet_cadet_service.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2009-2017 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  */
38 #ifndef GNUNET_CADET_SERVICE_H
39 #define GNUNET_CADET_SERVICE_H
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #if 0 /* keep Emacsens' auto-indent happy */
44 }
45 #endif
46 #endif
47 
48 
49 #include "gnunet_util_lib.h"
51 
55 #define GNUNET_CADET_VERSION 0x00000005
56 
57 
61 struct GNUNET_CADET_Handle;
62 
67 
71 struct GNUNET_CADET_Port;
72 
73 
78 {
80 };
81 
82 
87 {
97  uint32_t cn GNUNET_PACKED;
98 };
99 
112 typedef void *(*GNUNET_CADET_ConnectEventHandler) (
113  void *cls,
114  struct GNUNET_CADET_Channel *channel,
115  const struct GNUNET_PeerIdentity *source);
116 
117 
130  void *cls,
131  const struct GNUNET_CADET_Channel *channel);
132 
133 
149  void *cls,
150  const struct GNUNET_CADET_Channel *channel,
151  int window_size);
152 
153 
160 struct GNUNET_CADET_Handle *
162 
163 
172 void
174 
175 
189 struct GNUNET_CADET_Port *
191  const struct GNUNET_HashCode *port,
193  void *connects_cls,
196  const struct GNUNET_MQ_MessageHandler *handlers);
197 
198 
205 void
207 
208 
229 struct GNUNET_CADET_Channel *
231  void *channel_cls,
232  const struct GNUNET_PeerIdentity *destination,
233  const struct GNUNET_HashCode *port,
236  const struct GNUNET_MQ_MessageHandler *handlers);
237 
238 
248 void
250 
251 
258 struct GNUNET_MQ_Handle *
259 GNUNET_CADET_get_mq (const struct GNUNET_CADET_Channel *channel);
260 
261 
269 void
271 
272 
282 const struct GNUNET_HashCode *
283 GC_u2h (uint32_t port);
284 
286 {
293 };
294 
299 {
303  int yes_no;
304 
308  const struct GNUNET_PeerIdentity peer;
309 };
310 
311 
321 const union GNUNET_CADET_ChannelInfo *
323  enum GNUNET_CADET_ChannelInfoOption option,
324  ...);
325 
326 
327 /******************************************************************************/
328 /******************** MONITORING /DEBUG API *************************/
329 /******************************************************************************/
330 /* The following calls are not useful for normal CADET operation, but for */
331 /* debug and monitoring of the cadet state. They can be safely ignored. */
332 /* The API can change at any point without notice. */
333 /* Please contact the developer if you consider any of this calls useful for */
334 /* normal cadet applications. */
335 /******************************************************************************/
336 
337 
342 {
346  struct GNUNET_PeerIdentity root;
347 
351  struct GNUNET_PeerIdentity dest;
352 
353  // to be expanded!
354 };
355 
356 
364 typedef void (*GNUNET_CADET_ChannelCB) (
365  void *cls,
366  const struct GNUNET_CADET_ChannelInternals *info);
367 
368 
373 
374 
385  struct GNUNET_PeerIdentity *peer,
386  GNUNET_CADET_ChannelCB callback,
387  void *callback_cls);
388 
389 
396 void *
398 
399 
404 {
408  struct GNUNET_PeerIdentity peer;
409 
414 
418  unsigned int n_paths;
419 
423  unsigned int best_path_length;
424 };
425 
426 
436 typedef void (*GNUNET_CADET_PeersCB) (
437  void *cls,
438  const struct GNUNET_CADET_PeerListEntry *ple);
439 
440 
445 
446 
459  GNUNET_CADET_PeersCB callback,
460  void *callback_cls);
461 
462 
469 void *
471 
472 
477 {
481  struct GNUNET_PeerIdentity peer;
482 
486  unsigned int target_offset;
487 
491  unsigned int path_length;
492 
498  const struct GNUNET_PeerIdentity *path;
499 };
500 
501 
509 typedef void (*GNUNET_CADET_PathCB) (
510  void *cls,
511  const struct GNUNET_CADET_PeerPathDetail *ppd);
512 
513 
517 struct GNUNET_CADET_GetPath;
518 
519 
529 struct GNUNET_CADET_GetPath *
531  const struct GNUNET_PeerIdentity *id,
532  GNUNET_CADET_PathCB callback,
533  void *callback_cls);
534 
535 
542 void *
544 
545 
550 {
554  struct GNUNET_PeerIdentity peer;
555 
559  uint32_t channels;
560 
564  uint32_t connections;
565 
569  uint16_t estate;
570 
574  uint16_t cstate;
575 };
576 
577 
587 typedef void (*GNUNET_CADET_TunnelsCB) (
588  void *cls,
589  const struct GNUNET_CADET_TunnelDetails *td);
590 
591 
596 
597 
610  GNUNET_CADET_TunnelsCB callback,
611  void *callback_cls);
612 
613 
620 void *
622 
623 
624 #if 0 /* keep Emacsens' auto-indent happy */
625 {
626 #endif
627 #ifdef __cplusplus
628 }
629 #endif
630 
631 /* ifndef GNUNET_CADET_SERVICE_H */
632 #endif
633  /* end of group */
635  /* end of group addition */
637 
638 /* end of gnunet_cadet_service.h */
639 
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
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static uint16_t port
Port number.
Definition: gnunet-bcd.c:147
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static GstElement * source
Appsrc instance into which we write data for the pipeline.
#define info
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
struct GNUNET_CADET_Channel * GNUNET_CADET_channel_create(struct GNUNET_CADET_Handle *h, void *channel_cls, const struct GNUNET_PeerIdentity *destination, const struct GNUNET_HashCode *port, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Create a new channel towards a remote peer.
Definition: cadet_api.c:1015
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Indicate readiness to receive the next message on a channel.
Definition: cadet_api.c:872
void(* GNUNET_CADET_PeersCB)(void *cls, const struct GNUNET_CADET_PeerListEntry *ple)
Method called to retrieve information about all peers in CADET, called once per peer.
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
Definition: cadet_api.c:830
void(* GNUNET_CADET_DisconnectEventHandler)(void *cls, const struct GNUNET_CADET_Channel *channel)
Function called whenever an MQ-channel is destroyed, unless the destruction was requested by GNUNET_C...
GNUNET_CADET_ChannelInfoOption
void * GNUNET_CADET_get_channel_cancel(struct GNUNET_CADET_ChannelMonitor *cm)
Cancel a channel monitor request.
void * GNUNET_CADET_list_tunnels_cancel(struct GNUNET_CADET_ListTunnels *lt)
Cancel a monitor request.
struct GNUNET_CADET_GetPath * GNUNET_CADET_get_path(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *id, GNUNET_CADET_PathCB callback, void *callback_cls)
Request information about a peer known to the running cadet peer.
const union GNUNET_CADET_ChannelInfo * GNUNET_CADET_channel_get_info(struct GNUNET_CADET_Channel *channel, enum GNUNET_CADET_ChannelInfoOption option,...)
Get information about a channel.
Definition: cadet_api.c:850
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
Definition: cadet_api.c:774
struct GNUNET_CADET_PeersLister * GNUNET_CADET_list_peers(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CADET_PeersCB callback, void *callback_cls)
Request information about peers known to the running cadet service.
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port.
Definition: cadet_api.c:801
void(* GNUNET_CADET_PathCB)(void *cls, const struct GNUNET_CADET_PeerPathDetail *ppd)
Method called to retrieve information about a specific path known to the service.
void(* GNUNET_CADET_ChannelCB)(void *cls, const struct GNUNET_CADET_ChannelInternals *info)
Method called to retrieve information about a specific channel the cadet peer is aware of,...
struct GNUNET_CADET_ChannelMonitor * GNUNET_CADET_get_channel(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *peer, GNUNET_CADET_ChannelCB callback, void *callback_cls)
Request information about channels to peer from the local peer.
void(* GNUNET_CADET_TunnelsCB)(void *cls, const struct GNUNET_CADET_TunnelDetails *td)
Method called to retrieve information about all tunnels in CADET, called once per tunnel.
void(* GNUNET_CADET_WindowSizeEventHandler)(void *cls, const struct GNUNET_CADET_Channel *channel, int window_size)
Function called whenever an MQ-channel's transmission window size changes.
void *(* GNUNET_CADET_ConnectEventHandler)(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *source)
Method called whenever a peer connects to a port in MQ-based CADET.
struct GNUNET_MQ_Handle * GNUNET_CADET_get_mq(const struct GNUNET_CADET_Channel *channel)
Obtain the message queue for a connected channel.
Definition: cadet_api.c:1066
struct GNUNET_CADET_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
Definition: cadet_api.c:894
void * GNUNET_CADET_get_path_cancel(struct GNUNET_CADET_GetPath *gp)
Cancel gp operation.
void * GNUNET_CADET_list_peers_cancel(struct GNUNET_CADET_PeersLister *pl)
Cancel a peer info request.
struct GNUNET_CADET_Port * GNUNET_CADET_open_port(struct GNUNET_CADET_Handle *h, const struct GNUNET_HashCode *port, GNUNET_CADET_ConnectEventHandler connects, void *connects_cls, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Open a port to receive incoming MQ-based channels.
Definition: cadet_api.c:954
const struct GNUNET_HashCode * GC_u2h(uint32_t port)
Transitional function to convert an unsigned int port to a hash value.
struct GNUNET_CADET_ListTunnels * GNUNET_CADET_list_tunnels(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CADET_TunnelsCB callback, void *callback_cls)
Request information about tunnels of the running cadet peer.
@ GNUNET_CADET_OPTION_PEER
Who is the peer at the other end of the channel.
#define GNUNET_PACKED
gcc-ism to get packed structs.
Internal details about a channel.
struct GNUNET_PeerIdentity dest
Destination of the channel.
struct GNUNET_PeerIdentity root
Root of the channel.
Number identifying a CADET channel within a tunnel.
uint32_t cn
Which number does this channel have that uniquely identfies it within its tunnel, in network byte ord...
Opaque handle to a channel.
Definition: cadet.h:116
GNUNET_CADET_WindowSizeEventHandler window_changes
Window change handler.
Definition: cadet.h:159
Hash uniquely identifying a connection below a tunnel.
struct GNUNET_ShortHashCode connection_of_tunnel
Operation handle.
Opaque handle to the service.
Definition: cadet_api.c:39
Information we return per peer.
unsigned int best_path_length
Length of the shortest path (0 = unknown, 1 = ourselves, 2 = direct neighbour).
unsigned int n_paths
Number of disjoint known paths to peer.
struct GNUNET_PeerIdentity peer
Which peer is the information about?
int have_tunnel
Do we have a tunnel to this peer?
Detailed information we return per peer.
unsigned int path_length
Number of entries on the path.
const struct GNUNET_PeerIdentity * path
Array of PEER_IDs representing all paths to reach the peer.
unsigned int target_offset
Offset of the target peer on the path.
struct GNUNET_PeerIdentity peer
Peer this is about.
Opaque handle to a port.
Definition: cadet_api.c:80
GNUNET_CADET_WindowSizeEventHandler window_changes
Window size change handler.
Definition: cadet_api.c:109
void * connects_cls
Closure for connects.
Definition: cadet_api.c:104
Details about a tunnel managed by CADET.
uint16_t cstate
What is our connectivity state?
uint32_t channels
How many channels use the tunnel.
uint16_t estate
What is our encryption state?
struct GNUNET_PeerIdentity peer
Target of the tunnel.
uint32_t connections
How many connections support the tunnel.
A 512-bit hashcode.
Handle to a message queue.
Definition: mq.c:87
Message handler for a specific message type.
The identity of the host (wraps the signing key of the peer).
A 256-bit hashcode.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Union to retrieve info about a channel.
const struct GNUNET_PeerIdentity peer
Peer on the other side of the channel.
int yes_no
GNUNET_YES / GNUNET_NO, for binary flags.