GNUnet  0.11.x
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
30 extern "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_peer_lib.h"
59 #include "gnunet_core_service.h"
60 #include "gnunet_cadet_service.h"
61 #include "gnunet_protocols.h"
62 #include "gnunet_cadet_service.h"
63 
64 /******************************************************************************/
65 /************************** CONSTANTS ******************************/
66 /******************************************************************************/
67 
71 #define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI 0x80000000U
72 
76 #define HIGH_PID 0xFF000000
77 
81 #define LOW_PID 0x00FFFFFF
82 
83 
90 #define PID_OVERFLOW(pid, max) (((pid) > HIGH_PID) && ((max) < LOW_PID))
91 
92 /******************************************************************************/
93 /************************** MESSAGES ******************************/
94 /******************************************************************************/
95 
97 
102 {
111 };
112 
117 {
118 
123 
128 
133 
138  void *ctx;
139 
144 
149 
156 
161 
166 
171 
175  unsigned int allow_send;
176 };
177 
182 {
189  struct GNUNET_MessageHeader header;
190 
195 };
196 
197 
202 {
208  struct GNUNET_MessageHeader header;
209 
214 
219 
224 
228  uint32_t opt GNUNET_PACKED;
229 };
230 
231 
236 {
240  struct GNUNET_MessageHeader header;
241 
246 };
247 
248 
253 {
257  struct GNUNET_MessageHeader header;
258 
263 
268  uint32_t pp GNUNET_PACKED;
269 
273 };
274 
275 
281 {
285  struct GNUNET_MessageHeader header;
286 
291 };
292 
293 
300 {
305  struct GNUNET_MessageHeader header;
306 
311 
316 };
317 
322 {
323 
327  struct GNUNET_MessageHeader header;
328 
332  uint16_t type;
333 
338 
339 };
340 
345 {
349  struct GNUNET_MessageHeader header;
350 
354  uint32_t resered GNUNET_PACKED;
355 
359  struct GNUNET_PeerIdentity peer;
360 };
361 
362 
367 {
371  struct GNUNET_MessageHeader header;
372 
376  struct GNUNET_PeerIdentity root;
377 
381  struct GNUNET_PeerIdentity dest;
382 
383  /* FIXME: expand! */
384 };
385 
386 
391 {
395  struct GNUNET_MessageHeader header;
396 
400  struct GNUNET_PeerIdentity target;
401 };
402 
403 
408 {
412  struct GNUNET_MessageHeader header;
413 
417  uint32_t off GNUNET_PACKED;
418 };
419 
420 
425 {
429  struct GNUNET_MessageHeader header;
430 
434  uint16_t paths GNUNET_PACKED;
435 
439  int16_t tunnel GNUNET_PACKED;
440 
444  uint32_t best_path_length GNUNET_PACKED;
445 
449  struct GNUNET_PeerIdentity destination;
450 };
451 
452 
459 {
464  struct GNUNET_MessageHeader header;
465 
470 
474  struct GNUNET_PeerIdentity destination;
475 
480 
484  uint16_t estate GNUNET_PACKED;
485 
489  uint16_t cstate GNUNET_PACKED;
490 
491  /* If TUNNEL (no 'S'): struct GNUNET_CADET_ConnectionTunnelIdentifier connection_ids[connections] */
492  /* If TUNNEL (no 'S'): uint32_t channel_ids[channels] */
493 };
494 
495 
497 
498 
506 char *
507 GC_f2s (int fwd);
508 
509 
518 int
519 GC_is_pid_bigger (uint32_t bigger, uint32_t smaller);
520 
521 
530 uint32_t
531 GC_max_pid (uint32_t a, uint32_t b);
532 
533 
542 uint32_t
543 GC_min_pid (uint32_t a, uint32_t b);
544 
545 
555 size_t
556 GC_bin2s (void *bin, unsigned int len, char **output);
557 
558 
569 const char *
570 GC_m2s (uint16_t m);
571 
572 #if 0 /* keep Emacsens' auto-indent happy */
573 {
574 #endif
575 #ifdef __cplusplus
576 }
577 #endif
578 
579 #endif
Message to allow the client send more data to the service (always service -> client).
Definition: cadet.h:280
GNUNET_CADET_DisconnectEventHandler disconnects
Disconnect handler.
Definition: cadet.h:165
uint32_t channel_of_client
Values for channel numbering.
Definition: cadet.h:110
Message for or to a client to destroy tunnel.
Definition: cadet.h:235
Opaque handle to the service.
Definition: cadet_api.c:38
uint32_t GC_min_pid(uint32_t a, uint32_t b)
Get the lower ACK value out of two values, taking in account overflow.
const char * GC_m2s(uint16_t m)
Convert a message type into a string to help debug Generated with: FIND: "#define ([^ ]+)[ ]*([0-9]+)...
Message for a client to create and destroy channels.
Definition: cadet.h:181
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.
Opaque handle to a channel.
Definition: cadet.h:116
Message to inform the client about channels in the service.
Definition: cadet.h:344
static int channels
unsigned int allow_send
How many messages are we allowed to send to the service right now?
Definition: cadet.h:175
uint32_t GC_max_pid(uint32_t a, uint32_t b)
Get the higher ACK value out of two values, taking in account overflow.
struct GNUNET_CONTAINER_MultiShortmap * connections
Map from struct GNUNET_CADET_ConnectionTunnelIdentifier hash codes to struct CadetConnection objects...
uint16_t type
Type of the message this handler covers, in host byte order.
Definition: cadet.h:332
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won&#39;t work on W32.
Message to inform the client about channels in the service.
Definition: cadet.h:366
struct GNUNET_SCHEDULER_Task * mq_cont
Task to allow mq to send more traffic.
Definition: cadet.h:148
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
Message to inform the client about one of the paths known to the service.
Definition: cadet.h:407
void * ctx
Any data the caller wants to put in here, used for the various callbacks (disconnects, window_changes, handlers).
Definition: cadet.h:138
Message to inform the client about one of the peers in the service.
Definition: cadet.h:424
Message to as the service about information on a channel.
Definition: cadet.h:390
Number uniquely identifying a channel of a client.
Definition: cadet.h:101
Message to inform the client about one of the tunnels in the service.
Definition: cadet.h:458
Message to inform the client about channels in the service.
Definition: cadet.h:299
A 512-bit hashcode.
size_t GC_bin2s(void *bin, unsigned int len, char **output)
Allocate a string with a hexdump of any binary data.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_Handle * mq
Message Queue for the channel (which we are implementing).
Definition: cadet.h:143
Message for a client to create channels.
Definition: cadet.h:201
struct GNUNET_CADET_Handle * cadet
Handle to the cadet this channel belongs to.
Definition: cadet.h:127
GNUNET_NETWORK_STRUCT_END char * GC_f2s(int fwd)
Translate a fwd variable into a string representation, for logging.
Handle to a message queue.
Definition: mq.c:85
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won&#39;t work on W32;.
The identity of the host (wraps the signing key of the peer).
#define GNUNET_PACKED
gcc-ism to get packed structs.
static uint16_t port
Port number.
Definition: gnunet-bcd.c:82
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:155
int GC_is_pid_bigger(uint32_t bigger, uint32_t smaller)
Check if one pid is bigger than other, accounting for overflow.
GNUNET_CADET_WindowSizeEventHandler window_changes
Window change handler.
Definition: cadet.h:160
struct GNUNET_CADET_Port * incoming_port
Channel&#39;s port, if incoming.
Definition: cadet.h:132
Entry in list of pending tasks.
Definition: scheduler.c:134
Opaque handle to a port.
Definition: cadet_api.c:79
Header for all communications.
Message for cadet data traffic.
Definition: cadet.h:252
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...
Message to drop another message of specific type.
Definition: cadet.h:321
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...