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 
111 };
112 
113 
124  struct GNUNET_MessageHeader header;
125 
130 };
131 
132 
142  struct GNUNET_MessageHeader header;
143 
148 
153 
158 
162  uint32_t opt GNUNET_PACKED;
163 };
164 
165 
173  struct GNUNET_MessageHeader header;
174 
179 };
180 
181 
189  struct GNUNET_MessageHeader header;
190 
195 
200  uint32_t pp GNUNET_PACKED;
201 
205 };
206 
207 
216  struct GNUNET_MessageHeader header;
217 
222 };
223 
224 
235  struct GNUNET_MessageHeader header;
236 
241 
246 };
247 
248 
256  struct GNUNET_MessageHeader header;
257 
261  uint32_t resered GNUNET_PACKED;
262 
266  struct GNUNET_PeerIdentity peer;
267 };
268 
269 
277  struct GNUNET_MessageHeader header;
278 
282  struct GNUNET_PeerIdentity root;
283 
287  struct GNUNET_PeerIdentity dest;
288 
289  /* FIXME: expand! */
290 };
291 
292 
300  struct GNUNET_MessageHeader header;
301 
305  struct GNUNET_PeerIdentity target;
306 };
307 
308 
316  struct GNUNET_MessageHeader header;
317 
321  uint32_t off GNUNET_PACKED;
322 };
323 
324 
332  struct GNUNET_MessageHeader header;
333 
337  uint16_t paths GNUNET_PACKED;
338 
342  int16_t tunnel GNUNET_PACKED;
343 
347  uint32_t best_path_length GNUNET_PACKED;
348 
352  struct GNUNET_PeerIdentity destination;
353 };
354 
355 
366  struct GNUNET_MessageHeader header;
367 
372 
376  struct GNUNET_PeerIdentity destination;
377 
382 
386  uint16_t estate GNUNET_PACKED;
387 
391  uint16_t cstate GNUNET_PACKED;
392 
393  /* If TUNNEL (no 'S'): struct GNUNET_CADET_ConnectionTunnelIdentifier connection_ids[connections] */
394  /* If TUNNEL (no 'S'): uint32_t channel_ids[channels] */
395 };
396 
397 
399 
400 
408 char *
409 GC_f2s(int fwd);
410 
411 
420 int
421 GC_is_pid_bigger(uint32_t bigger, uint32_t smaller);
422 
423 
432 uint32_t
433 GC_max_pid(uint32_t a, uint32_t b);
434 
435 
444 uint32_t
445 GC_min_pid(uint32_t a, uint32_t b);
446 
447 
457 size_t
458 GC_bin2s(void *bin, unsigned int len, char **output);
459 
460 
471 const char *
472 GC_m2s(uint16_t m);
473 
474 #if 0 /* keep Emacsens' auto-indent happy */
475 {
476 #endif
477 #ifdef __cplusplus
478 }
479 #endif
480 
481 #endif
Message to allow the client send more data to the service (always service -> client).
Definition: cadet.h:212
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:169
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:117
Message to inform the client about channels in the service.
Definition: cadet.h:252
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:273
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:312
Message to inform the client about one of the peers in the service.
Definition: cadet.h:328
Message to as the service about information on a channel.
Definition: cadet.h:296
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:361
Message to inform the client about channels in the service.
Definition: cadet.h:230
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:136
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:81
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:185
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...