GNUnet  0.10.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 
98 
103 {
112 };
113 
114 
119 {
126  struct GNUNET_MessageHeader header;
127 
132 };
133 
134 
139 {
145  struct GNUNET_MessageHeader header;
146 
151 
156 
161 
165  uint32_t opt GNUNET_PACKED;
166 };
167 
168 
173 {
177  struct GNUNET_MessageHeader header;
178 
183 };
184 
185 
190 {
194  struct GNUNET_MessageHeader header;
195 
200 
205  uint32_t pp GNUNET_PACKED;
206 
210 };
211 
212 
218 {
222  struct GNUNET_MessageHeader header;
223 
228 };
229 
230 
237 {
242  struct GNUNET_MessageHeader header;
243 
248 
253 };
254 
255 
260 {
264  struct GNUNET_MessageHeader header;
265 
269  uint32_t resered GNUNET_PACKED;
270 
274  struct GNUNET_PeerIdentity peer;
275 };
276 
277 
282 {
286  struct GNUNET_MessageHeader header;
287 
291  struct GNUNET_PeerIdentity root;
292 
296  struct GNUNET_PeerIdentity dest;
297 
298  /* FIXME: expand! */
299 };
300 
301 
306 {
310  struct GNUNET_MessageHeader header;
311 
315  struct GNUNET_PeerIdentity target;
316 };
317 
318 
323 {
327  struct GNUNET_MessageHeader header;
328 
332  uint32_t off GNUNET_PACKED;
333 };
334 
335 
340 {
344  struct GNUNET_MessageHeader header;
345 
349  uint16_t paths GNUNET_PACKED;
350 
354  int16_t tunnel GNUNET_PACKED;
355 
359  uint32_t best_path_length GNUNET_PACKED;
360 
364  struct GNUNET_PeerIdentity destination;
365 };
366 
367 
374 {
379  struct GNUNET_MessageHeader header;
380 
385 
389  struct GNUNET_PeerIdentity destination;
390 
395 
399  uint16_t estate GNUNET_PACKED;
400 
404  uint16_t cstate GNUNET_PACKED;
405 
406  /* If TUNNEL (no 'S'): struct GNUNET_CADET_ConnectionTunnelIdentifier connection_ids[connections] */
407  /* If TUNNEL (no 'S'): uint32_t channel_ids[channels] */
408 };
409 
410 
412 
413 
421 char *
422 GC_f2s (int fwd);
423 
424 
433 int
434 GC_is_pid_bigger (uint32_t bigger, uint32_t smaller);
435 
436 
445 uint32_t
446 GC_max_pid (uint32_t a, uint32_t b);
447 
448 
457 uint32_t
458 GC_min_pid (uint32_t a, uint32_t b);
459 
460 
470 size_t
471 GC_bin2s (void *bin, unsigned int len, char **output);
472 
473 
484 const char *
485 GC_m2s (uint16_t m);
486 
487 #if 0 /* keep Emacsens' auto-indent happy */
488 {
489 #endif
490 #ifdef __cplusplus
491 }
492 #endif
493 
494 #endif
Message to allow the client send more data to the service (always service -> client).
Definition: cadet.h:217
uint32_t channel_of_client
Values for channel numbering.
Definition: cadet.h:111
Message for or to a client to destroy tunnel.
Definition: cadet.h:172
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:118
Message to inform the client about channels in the service.
Definition: cadet.h:259
static int channels
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...
#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:281
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
Message to inform the client about one of the paths known to the service.
Definition: cadet.h:322
Message to inform the client about one of the peers in the service.
Definition: cadet.h:339
Message to as the service about information on a channel.
Definition: cadet.h:305
Number uniquely identifying a channel of a client.
Definition: cadet.h:102
Message to inform the client about one of the tunnels in the service.
Definition: cadet.h:373
Message to inform the client about channels in the service.
Definition: cadet.h:236
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.
Message for a client to create channels.
Definition: cadet.h:138
GNUNET_NETWORK_STRUCT_END char * GC_f2s(int fwd)
Translate a fwd variable into a string representation, for logging.
#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:79
int GC_is_pid_bigger(uint32_t bigger, uint32_t smaller)
Check if one pid is bigger than other, accounting for overflow.
Header for all communications.
Message for cadet data traffic.
Definition: cadet.h:189
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...