GNUnet  0.10.x
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 */
35 #ifndef GNUNET_CADET_SERVICE_H
36 #define GNUNET_CADET_SERVICE_H
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #if 0 /* keep Emacsens' auto-indent happy */
41 }
42 #endif
43 #endif
44 
45 #include "gnunet_util_lib.h"
47 
51 #define GNUNET_CADET_VERSION 0x00000005
52 
53 
57 struct GNUNET_CADET_Handle;
58 
63 
67 struct GNUNET_CADET_Port;
68 
69 
74 {
76 };
77 
78 
83 {
93  uint32_t cn GNUNET_PACKED;
94 };
95 
96 
105 {
110 
116 
122 
128 
135 
136 };
137 
138 
151 typedef void *(*GNUNET_CADET_ConnectEventHandler) (
152  void *cls,
153  struct GNUNET_CADET_Channel *channel,
154  const struct GNUNET_PeerIdentity *source);
155 
156 
169  void *cls,
170  const struct GNUNET_CADET_Channel *channel);
171 
172 
188  void *cls,
189  const struct GNUNET_CADET_Channel *channel,
190  int window_size);
191 
192 
199 struct GNUNET_CADET_Handle *
201 
202 
211 void
213 
214 
228 struct GNUNET_CADET_Port *
230  const struct GNUNET_HashCode *port,
232  void *connects_cls,
235  const struct GNUNET_MQ_MessageHandler *handlers);
236 
237 
244 void
246 
247 
270 struct GNUNET_CADET_Channel *
272  void *channel_cls,
273  const struct GNUNET_PeerIdentity *destination,
274  const struct GNUNET_HashCode *port,
278  const struct GNUNET_MQ_MessageHandler *handlers);
279 
280 
290 void
292 
293 
300 struct GNUNET_MQ_Handle *
301 GNUNET_CADET_get_mq (const struct GNUNET_CADET_Channel *channel);
302 
303 
311 void
313 
314 
324 const struct GNUNET_HashCode *
325 GC_u2h (uint32_t port);
326 
327 
332 {
333 
337  int yes_no;
338 
342  const struct GNUNET_PeerIdentity peer;
343 };
344 
345 
354 const union GNUNET_CADET_ChannelInfo *
357  ...);
358 
359 
360 /******************************************************************************/
361 /******************** MONITORING /DEBUG API *************************/
362 /******************************************************************************/
363 /* The following calls are not useful for normal CADET operation, but for */
364 /* debug and monitoring of the cadet state. They can be safely ignored. */
365 /* The API can change at any point without notice. */
366 /* Please contact the developer if you consider any of this calls useful for */
367 /* normal cadet applications. */
368 /******************************************************************************/
369 
370 
375 {
379  struct GNUNET_PeerIdentity root;
380 
384  struct GNUNET_PeerIdentity dest;
385 
386  // to be expanded!
387 };
388 
389 
397 typedef void (*GNUNET_CADET_ChannelCB) (
398  void *cls,
399  const struct GNUNET_CADET_ChannelInternals *info);
400 
401 
406 
407 
418  struct GNUNET_PeerIdentity *peer,
419  GNUNET_CADET_ChannelCB callback,
420  void *callback_cls);
421 
422 
429 void *
431 
432 
437 {
441  struct GNUNET_PeerIdentity peer;
442 
447 
451  unsigned int n_paths;
452 
456  unsigned int best_path_length;
457 };
458 
459 
469 typedef void (*GNUNET_CADET_PeersCB) (
470  void *cls,
471  const struct GNUNET_CADET_PeerListEntry *ple);
472 
473 
478 
479 
492  GNUNET_CADET_PeersCB callback,
493  void *callback_cls);
494 
495 
502 void *
504 
505 
510 {
514  struct GNUNET_PeerIdentity peer;
515 
519  unsigned int target_offset;
520 
524  unsigned int path_length;
525 
531  const struct GNUNET_PeerIdentity *path;
532 };
533 
534 
542 typedef void (*GNUNET_CADET_PathCB) (
543  void *cls,
544  const struct GNUNET_CADET_PeerPathDetail *ppd);
545 
546 
550 struct GNUNET_CADET_GetPath;
551 
552 
562 struct GNUNET_CADET_GetPath *
564  const struct GNUNET_PeerIdentity *id,
565  GNUNET_CADET_PathCB callback,
566  void *callback_cls);
567 
568 
575 void *
577 
578 
583 {
587  struct GNUNET_PeerIdentity peer;
588 
592  uint32_t channels;
593 
597  uint32_t connections;
598 
602  uint16_t estate;
603 
607  uint16_t cstate;
608 };
609 
610 
620 typedef void (*GNUNET_CADET_TunnelsCB) (
621  void *cls,
622  const struct GNUNET_CADET_TunnelDetails *td);
623 
624 
629 
630 
643  GNUNET_CADET_TunnelsCB callback,
644  void *callback_cls);
645 
646 
653 void *
655 
656 
657 #if 0 /* keep Emacsens' auto-indent happy */
658 {
659 #endif
660 #ifdef __cplusplus
661 }
662 #endif
663 
664 /* ifndef GNUNET_CADET_SERVICE_H */
665 #endif
666  /* end of group */
668 
669 /* end of gnunet_cadet_service.h */
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_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
Definition: cadet_api.c:849
void * GNUNET_CADET_list_tunnels_cancel(struct GNUNET_CADET_ListTunnels *lt)
Cancel a monitor request.
Who is the peer at the other end of the channel.
GNUNET_CADET_WindowSizeEventHandler window_changes
Window size change handler.
Definition: cadet_api.c:182
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
Opaque handle to the service.
Definition: cadet_api.c:38
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.
void(* GNUNET_CADET_WindowSizeEventHandler)(void *cls, const struct GNUNET_CADET_Channel *channel, int window_size)
Function called whenever an MQ-channel&#39;s transmission window size changes.
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...
Internal details about a channel.
uint16_t cstate
What is our connectivity state?
Enable channel reliability, lost messages will be retransmitted.
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.
Opaque handle to a channel.
Definition: cadet_api.c:80
unsigned int path_length
Number of entries on the path.
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_ChannelCB)(void *cls, const struct GNUNET_CADET_ChannelInternals *info)
Method called to retrieve information about a specific channel the cadet peer is aware of...
void * GNUNET_CADET_list_peers_cancel(struct GNUNET_CADET_PeersLister *pl)
Cancel a peer info request.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
unsigned int best_path_length
Length of the shortest path (0 = unknown, 1 = ourselves, 2 = direct neighbour).
struct GNUNET_CADET_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
Definition: cadet_api.c:995
const struct GNUNET_HashCode * GC_u2h(uint32_t port)
Transitional function to convert an unsigned int port to a hash value.
A 256-bit hashcode.
Details about a tunnel managed by CADET.
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.
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 incomming MQ-based channels.
Definition: cadet_api.c:1029
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static char * option
Name of the option.
Definition: gnunet-config.c:38
uint32_t channels
How many channels use the tunnel.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
Default options: unreliable, default buffering, not out of order.
void * GNUNET_CADET_get_path_cancel(struct GNUNET_CADET_GetPath *gp)
Cancel gp operation.
Enable out of order delivery of messages.
A 512-bit hashcode.
Union to retrieve info about a channel.
unsigned int target_offset
Offset of the target peer on the path.
Message handler for a specific message type.
void * connects(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Definition: 010.c:2
int yes_no
GNUNET_YES / GNUNET_NO, for binary flags.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
Operation handle.
static GstElement * source
Appsrc instance into which we write data for the pipeline.
void disconnects(void *cls, const struct GNUNET_PeerIdentity *peer)
Definition: 011.c:2
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
int have_tunnel
Do we have a tunnel to this peer?
void * connects_cls
Closure for connects.
Definition: cadet_api.c:177
const struct GNUNET_PeerIdentity * path
Array of PEER_IDs representing all paths to reach the peer.
void * GNUNET_CADET_get_channel_cancel(struct GNUNET_CADET_ChannelMonitor *cm)
Cancel a channel monitor request.
const union GNUNET_CADET_ChannelInfo * GNUNET_CADET_channel_get_info(struct GNUNET_CADET_Channel *channel, enum GNUNET_CADET_ChannelOption option,...)
Get information about a channel.
Definition: cadet_api.c:940
Handle to a message queue.
Definition: mq.c:85
uint16_t estate
What is our encryption state?
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.
The identity of the host (wraps the signing key of the peer).
Detailed information we return per peer.
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Indicate readiness to receive the next message on a channel.
Definition: cadet_api.c:973
#define GNUNET_PACKED
gcc-ism to get packed structs.
static uint16_t port
Port number.
Definition: gnunet-bcd.c:79
Hash uniquely identifying a connection below a tunnel.
configuration data
Definition: configuration.c:85
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.
Information we return per peer.
GNUNET_CADET_WindowSizeEventHandler window_changes
Window change handler.
Definition: cadet_api.c:124
Number identifying a CADET channel within a tunnel.
Opaque handle to a port.
Definition: cadet_api.c:151
unsigned int n_paths
Number of disjoint known paths to peer.
uint32_t connections
How many connections support the tunnel.
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port.
Definition: cadet_api.c:882
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...
struct GNUNET_ShortHashCode connection_of_tunnel
GNUNET_CADET_ChannelOption
Channel options.
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
Definition: cadet_api.c:911
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, enum GNUNET_CADET_ChannelOption options, 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:1088
Disable buffering on intermediate nodes (for minimum latency).
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:1142