GNUnet debian-0.24.3-29-g453fda2cf
 
Loading...
Searching...
No Matches
cadet.h File Reference
#include <stdint.h>
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_core_service.h"
#include "gnunet_cadet_service.h"
#include "gnunet_protocols.h"
Include dependency graph for cadet.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GNUNET_CADET_ClientChannelNumber
 Number uniquely identifying a channel of a client. More...
 
struct  GNUNET_CADET_Channel
 Opaque handle to a channel. More...
 
struct  GNUNET_CADET_PortMessage
 Message for a client to create and destroy channels. More...
 
struct  GNUNET_CADET_LocalChannelCreateMessage
 Message for a client to create channels. More...
 
struct  GNUNET_CADET_LocalChannelDestroyMessage
 Message for or to a client to destroy tunnel. More...
 
struct  GNUNET_CADET_LocalData
 Message for cadet data traffic. More...
 
struct  GNUNET_CADET_LocalAck
 Message to allow the client send more data to the service (always service -> client). More...
 
struct  GNUNET_CADET_LocalInfo
 Message to inform the client about channels in the service. More...
 
struct  GNUNET_CADET_RequestDropCadetMessage
 Message to drop another message of specific type. More...
 
struct  GNUNET_CADET_RequestPathInfoMessage
 Message to inform the client about channels in the service. More...
 
struct  GNUNET_CADET_ChannelInfoMessage
 Message to inform the client about channels in the service. More...
 
struct  GNUNET_CADET_RequestChannelInfoMessage
 Message to as the service about information on a channel. More...
 
struct  GNUNET_CADET_LocalInfoPath
 Message to inform the client about one of the paths known to the service. More...
 
struct  GNUNET_CADET_LocalInfoPeers
 Message to inform the client about one of the peers in the service. More...
 
struct  GNUNET_CADET_LocalInfoTunnel
 Message to inform the client about one of the tunnels in the service. More...
 

Macros

#define CADET_TIMING_START
 
#define CADET_TIMING_END
 
#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI   0x80000000U
 Minimum value for channel IDs of local clients.
 
#define HIGH_PID   0xFF000000
 FIXME.
 
#define LOW_PID   0x00FFFFFF
 FIXME.
 
#define PID_OVERFLOW(pid, max)   (((pid) > HIGH_PID) && ((max) < LOW_PID))
 Test if the two PIDs (of type uint32_t) are in the range where we have to worry about overflows.
 

Functions

GNUNET_NETWORK_STRUCT_END char * GC_f2s (int fwd)
 Translate a fwd variable into a string representation, for logging.
 
int GC_is_pid_bigger (uint32_t bigger, uint32_t smaller)
 Check if one pid is bigger than other, accounting for 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.
 
uint32_t GC_min_pid (uint32_t a, uint32_t b)
 Get the lower ACK value out of two values, taking in account overflow.
 
size_t GC_bin2s (void *bin, unsigned int len, char **output)
 Allocate a string with a hexdump of any binary data.
 
const char * GC_m2s (uint16_t m)
 Convert a message type into a string to help debug Generated with: FIND: "#define ([^ ]+)[ ]*([0-9]+)" REPLACE: " case \2: return "\1"; break;".
 

Detailed Description

Author
Bartlomiej Polot

Definition in file cadet.h.

Macro Definition Documentation

◆ CADET_TIMING_START

#define CADET_TIMING_START
Value:
struct GNUNET_TIME_Absolute __timestamp; \
__timestamp = GNUNET_TIME_absolute_get ()
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition time.c:111
Time for absolute times used by GNUnet, in microseconds.

Definition at line 39 of file cadet.h.

100{
108 uint32_t channel_of_client GNUNET_PACKED;
109};
110
115{
116
121
126
131
136 void *ctx;
137
141 struct GNUNET_MQ_Handle *mq;
142
147
154
159
164
169
173 unsigned int allow_send;
174};
175
180{
188
193};
194
195
200{
207
212
217
221 struct GNUNET_HashCode port;
222
226 uint32_t opt GNUNET_PACKED;
227};
228
229
234{
239
244};
245
246
251{
256
261
266 uint32_t pp GNUNET_PACKED;
267
271};
272
273
279{
284
289};
290
291
298{
304
309
314};
315
320{
321
326
330 uint16_t type;
331
336
337};
338
343{
348
352 uint32_t resered GNUNET_PACKED;
353
358};
359
360
365{
370
375
380
381 /* FIXME: expand! */
382};
383
384
389{
394
399};
400
401
406{
411
416};
417
418
423{
428
432 uint16_t paths GNUNET_PACKED;
433
437 int16_t tunnel GNUNET_PACKED;
438
443
448};
449
450
457{
463
467 uint32_t channels GNUNET_PACKED;
468
473
477 uint32_t connections GNUNET_PACKED;
478
482 uint16_t estate GNUNET_PACKED;
483
487 uint16_t cstate GNUNET_PACKED;
488
489 /* If TUNNEL (no 'S'): struct GNUNET_CADET_ConnectionTunnelIdentifier connection_ids[connections] */
490 /* If TUNNEL (no 'S'): uint32_t channel_ids[channels] */
491};
492
493
495
496
504char *
505GC_f2s (int fwd);
506
507
516int
517GC_is_pid_bigger (uint32_t bigger, uint32_t smaller);
518
519
528uint32_t
529GC_max_pid (uint32_t a, uint32_t b);
530
531
540uint32_t
541GC_min_pid (uint32_t a, uint32_t b);
542
543
553size_t
554GC_bin2s (void *bin, unsigned int len, char **output);
555
556
567const char *
568GC_m2s (uint16_t m);
569
570#if 0 /* keep Emacsens' auto-indent happy */
571{
572#endif
573#ifdef __cplusplus
574}
575#endif
576
577#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:103
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_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
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

◆ CADET_TIMING_END

#define CADET_TIMING_END
Value:
struct GNUNET_TIME_Relative __duration; \
__duration = GNUNET_TIME_absolute_get_duration (__timestamp); \
" %s duration %s\n", \
__FUNCTION__, \
@ GNUNET_YES
@ GNUNET_ERROR_TYPE_INFO
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition time.c:438
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition strings.c:599
Time for relative time used by GNUnet, in microseconds.

Definition at line 43 of file cadet.h.

◆ GNUNET_CADET_LOCAL_CHANNEL_ID_CLI

#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI   0x80000000U

Minimum value for channel IDs of local clients.

Definition at line 70 of file cadet.h.

◆ HIGH_PID

#define HIGH_PID   0xFF000000

FIXME.

Definition at line 75 of file cadet.h.

◆ LOW_PID

#define LOW_PID   0x00FFFFFF

FIXME.

Definition at line 80 of file cadet.h.

◆ PID_OVERFLOW

#define PID_OVERFLOW (   pid,
  max 
)    (((pid) > HIGH_PID) && ((max) < LOW_PID))

Test if the two PIDs (of type uint32_t) are in the range where we have to worry about overflows.

This is the case when pid is large and max is small, useful when comparing pid smaller than max.

Definition at line 89 of file cadet.h.

Function Documentation

◆ GC_f2s()

GNUNET_NETWORK_STRUCT_END char * GC_f2s ( int  fwd)

Translate a fwd variable into a string representation, for logging.

Parameters
fwdIs FWD? (GNUNET_YES or GNUNET_NO)
Returns
String representing FWD or BCK.

◆ GC_is_pid_bigger()

int GC_is_pid_bigger ( uint32_t  bigger,
uint32_t  smaller 
)

Check if one pid is bigger than other, accounting for overflow.

Parameters
biggerArgument that should be bigger.
smallerArgument that should be smaller.
Returns
True if bigger (arg1) has a higher value than smaller (arg 2).

◆ GC_max_pid()

uint32_t GC_max_pid ( uint32_t  a,
uint32_t  b 
)

Get the higher ACK value out of two values, taking in account overflow.

Parameters
aFirst ACK value.
bSecond ACK value.
Returns
Highest ACK value from the two.

◆ GC_min_pid()

uint32_t GC_min_pid ( uint32_t  a,
uint32_t  b 
)

Get the lower ACK value out of two values, taking in account overflow.

Parameters
aFirst ACK value.
bSecond ACK value.
Returns
Lowest ACK value from the two.

◆ GC_bin2s()

size_t GC_bin2s ( void *  bin,
unsigned int  len,
char **  output 
)

Allocate a string with a hexdump of any binary data.

Parameters
binArbitrary binary data.
lenLength of bin in bytes.
outputWhere to write the output (if *output be NULL it's allocated).
Returns
The size of the output.

◆ GC_m2s()

const char * GC_m2s ( uint16_t  m)

Convert a message type into a string to help debug Generated with: FIND: "#define ([^ ]+)[ ]*([0-9]+)" REPLACE: " case \2: return "\1"; break;".

Parameters
mMessage type.
Returns
Human readable string description.