GNUnet 0.21.1
cadet.h
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2001 - 2011 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 */
20
26#ifndef CADET_H_
27#define CADET_H_
28
29#ifdef __cplusplus
30extern "C" {
31#if 0 /* keep Emacsens' auto-indent happy */
32}
33#endif
34#endif
35
36#include <stdint.h>
37
38#if ! defined(GNUNET_CULL_LOGGING)
39#define CADET_TIMING_START \
40 struct GNUNET_TIME_Absolute __timestamp; \
41 __timestamp = GNUNET_TIME_absolute_get ()
42
43#define CADET_TIMING_END \
44 struct GNUNET_TIME_Relative __duration; \
45 __duration = GNUNET_TIME_absolute_get_duration (__timestamp); \
46 LOG (GNUNET_ERROR_TYPE_INFO, \
47 " %s duration %s\n", \
48 __FUNCTION__, \
49 GNUNET_STRINGS_relative_time_to_string (__duration, GNUNET_YES));
50#else
51#define CADET_TIMING_START
52#define CADET_TIMING_END
53#endif
54
55
56#include "platform.h"
57#include "gnunet_util_lib.h"
58#include "gnunet_core_service.h"
60#include "gnunet_protocols.h"
62
63/******************************************************************************/
64/************************** CONSTANTS ******************************/
65/******************************************************************************/
66
70#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI 0x80000000U
71
75#define HIGH_PID 0xFF000000
76
80#define LOW_PID 0x00FFFFFF
81
82
89#define PID_OVERFLOW(pid, max) (((pid) > HIGH_PID) && ((max) < LOW_PID))
90
91/******************************************************************************/
92/************************** MESSAGES ******************************/
93/******************************************************************************/
94
96
101{
110};
111
116{
117
122
127
132
137 void *ctx;
138
143
148
155
160
165
170
174 unsigned int allow_send;
175};
176
181{
189
194};
195
196
201{
208
213
218
223
228};
229
230
235{
240
245};
246
247
252{
257
262
268
272};
273
274
280{
285
290};
291
292
299{
305
310
315};
316
321{
322
327
331 uint16_t type;
332
337
338};
339
344{
349
354
359};
360
361
366{
371
376
381
382 /* FIXME: expand! */
383};
384
385
390{
395
400};
401
402
407{
412
417};
418
419
424{
429
434
439
444
449};
450
451
458{
464
469
474
479
484
489
490 /* If TUNNEL (no 'S'): struct GNUNET_CADET_ConnectionTunnelIdentifier connection_ids[connections] */
491 /* If TUNNEL (no 'S'): uint32_t channel_ids[channels] */
492};
493
494
496
497
505char *
506GC_f2s (int fwd);
507
508
517int
518GC_is_pid_bigger (uint32_t bigger, uint32_t smaller);
519
520
529uint32_t
530GC_max_pid (uint32_t a, uint32_t b);
531
532
541uint32_t
542GC_min_pid (uint32_t a, uint32_t b);
543
544
554size_t
555GC_bin2s (void *bin, unsigned int len, char **output);
556
557
568const char *
569GC_m2s (uint16_t m);
570
571#if 0 /* keep Emacsens' auto-indent happy */
572{
573#endif
574#ifdef __cplusplus
575}
576#endif
577
578#endif
size_t GC_bin2s(void *bin, unsigned int len, char **output)
Allocate a string with a hexdump of any binary data.
uint32_t GC_min_pid(uint32_t a, uint32_t b)
Get the lower ACK value out of two values, taking in account overflow.
uint32_t GC_max_pid(uint32_t a, uint32_t b)
Get the higher ACK value out of two values, taking in account overflow.
GNUNET_NETWORK_STRUCT_END char * GC_f2s(int fwd)
Translate a fwd variable into a string representation, for logging.
const char * GC_m2s(uint16_t m)
Convert a message type into a string to help debug Generated with: FIND: "#define ([^ ]+)[ ]*([0-9]+)...
int GC_is_pid_bigger(uint32_t bigger, uint32_t smaller)
Check if one pid is bigger than other, accounting for overflow.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
CADET service; establish channels to distant peers.
Core service; the main API for encrypted P2P communications.
Constants for network protocols.
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...
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.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
#define GNUNET_PACKED
gcc-ism to get packed structs.
Message to inform the client about channels in the service.
Definition: cadet.h:366
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_CHANNEL.
Definition: cadet.h:370
struct GNUNET_PeerIdentity dest
Destination of the channel.
Definition: cadet.h:380
struct GNUNET_PeerIdentity root
Root of the channel.
Definition: cadet.h:375
Opaque handle to a channel.
Definition: cadet.h:116
void * ctx
Any data the caller wants to put in here, used for the various callbacks (disconnects,...
Definition: cadet.h:137
struct GNUNET_CADET_Handle * cadet
Handle to the cadet this channel belongs to.
Definition: cadet.h:126
unsigned int allow_send
How many messages are we allowed to send to the service right now?
Definition: cadet.h:174
struct GNUNET_SCHEDULER_Task * mq_cont
Task to allow mq to send more traffic.
Definition: cadet.h:147
struct GNUNET_PeerIdentity peer
Other end of the channel.
Definition: cadet.h:121
GNUNET_CADET_WindowSizeEventHandler window_changes
Window change handler.
Definition: cadet.h:159
struct GNUNET_CADET_ClientChannelNumber ccn
Local ID of the channel, GNUNET_CADET_LOCAL_CHANNEL_ID_CLI bit is set if outbound.
Definition: cadet.h:169
GNUNET_CADET_DisconnectEventHandler disconnects
Disconnect handler.
Definition: cadet.h:164
struct GNUNET_MQ_Handle * mq
Message Queue for the channel (which we are implementing).
Definition: cadet.h:142
struct GNUNET_MQ_Envelope * pending_env
Pending envelope with a message to be transmitted to the service as soon as we are allowed to.
Definition: cadet.h:154
struct GNUNET_CADET_Port * incoming_port
Channel's port, if incoming.
Definition: cadet.h:131
Number uniquely identifying a channel of a client.
Definition: cadet.h:101
uint32_t channel_of_client
Values for channel numbering.
Definition: cadet.h:109
Opaque handle to the service.
Definition: cadet_api.c:39
Message to allow the client send more data to the service (always service -> client).
Definition: cadet.h:280
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK.
Definition: cadet.h:284
struct GNUNET_CADET_ClientChannelNumber ccn
ID of the channel allowed to send more data.
Definition: cadet.h:289
Message for a client to create channels.
Definition: cadet.h:201
struct GNUNET_PeerIdentity peer
Channel's peer.
Definition: cadet.h:217
struct GNUNET_CADET_ClientChannelNumber ccn
ID of a channel controlled by this client.
Definition: cadet.h:212
struct GNUNET_HashCode port
Port of the channel.
Definition: cadet.h:222
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE.
Definition: cadet.h:207
Message for or to a client to destroy tunnel.
Definition: cadet.h:235
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY.
Definition: cadet.h:239
struct GNUNET_CADET_ClientChannelNumber ccn
ID of a channel controlled by this client.
Definition: cadet.h:244
Message for cadet data traffic.
Definition: cadet.h:252
struct GNUNET_CADET_ClientChannelNumber ccn
ID of the channel.
Definition: cadet.h:261
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA.
Definition: cadet.h:256
uint32_t pp
Priority and preferences (an enum GNUNET_MQ_PriorityPreferences) of the message in NBO.
Definition: cadet.h:267
Message to inform the client about one of the paths known to the service.
Definition: cadet.h:407
uint32_t off
Offset of the peer that was requested.
Definition: cadet.h:416
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PATH.
Definition: cadet.h:411
Message to inform the client about one of the peers in the service.
Definition: cadet.h:424
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS.
Definition: cadet.h:428
struct GNUNET_PeerIdentity destination
ID of the peer (can be local peer).
Definition: cadet.h:448
uint32_t best_path_length
Shortest known path.
Definition: cadet.h:443
int16_t tunnel
Do we have a tunnel toward this peer?
Definition: cadet.h:438
uint16_t paths
Number of paths.
Definition: cadet.h:433
Message to inform the client about one of the tunnels in the service.
Definition: cadet.h:458
struct GNUNET_MessageHeader header
Type: #GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL or GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS.
Definition: cadet.h:463
uint16_t cstate
Connection state.
Definition: cadet.h:488
uint16_t estate
Encryption state.
Definition: cadet.h:483
struct GNUNET_PeerIdentity destination
ID of the destination of the tunnel (can be local peer).
Definition: cadet.h:473
uint32_t connections
Number of connections.
Definition: cadet.h:478
uint32_t channels
Number of channels.
Definition: cadet.h:468
Message to inform the client about channels in the service.
Definition: cadet.h:299
struct GNUNET_PeerIdentity peer
ID of the destination of the channel (can be local peer).
Definition: cadet.h:314
struct GNUNET_CADET_ClientChannelNumber ccn
ID of the channel allowed to send more data.
Definition: cadet.h:309
struct GNUNET_MessageHeader header
Type: #GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL or #GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER.
Definition: cadet.h:304
Message for a client to create and destroy channels.
Definition: cadet.h:181
struct GNUNET_HashCode port
Port to open/close.
Definition: cadet.h:193
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN or GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE.
Definition: cadet.h:188
Opaque handle to a port.
Definition: cadet_api.c:80
Message to as the service about information on a channel.
Definition: cadet.h:390
struct GNUNET_PeerIdentity target
Target of the channel.
Definition: cadet.h:399
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_CHANNEL.
Definition: cadet.h:394
Message to drop another message of specific type.
Definition: cadet.h:321
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_DROP_CADET_MESSAGE.
Definition: cadet.h:326
struct GNUNET_CADET_ClientChannelNumber ccn
ID of the channel we want to drop a message for.
Definition: cadet.h:336
uint16_t type
Type of the message this handler covers, in host byte order.
Definition: cadet.h:331
Message to inform the client about channels in the service.
Definition: cadet.h:344
uint32_t resered
Always zero.
Definition: cadet.h:353
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PATH.
Definition: cadet.h:348
struct GNUNET_PeerIdentity peer
ID of the destination of the channel (can be local peer).
Definition: cadet.h:358
A 512-bit hashcode.
Handle to a message queue.
Definition: mq.c:87
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