44#define LOG(level, ...) GNUNET_log_from (level, "cadet-chn", __VA_ARGS__)
49#define CADET_INITIAL_RETRANSMIT_TIME \
50 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250)
56#define TIMEOUT_CLOSED_PORT \
57 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
62#define MIN_RTT_DELAY \
63 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 75)
75#define MAX_OUT_OF_ORDER_DISTANCE 1024
411 if (
ch->type == message->
type)
431 static char buf[128];
435 "Channel %s:%s ctn:%X(%X/%X)",
472 "Calculated port hash %s\n",
522 while (NULL != (crm =
ch->head_sent))
538 if (NULL !=
ch->owner)
543 if (NULL !=
ch->dest)
548 if (NULL !=
ch->last_control_qe)
551 ch->last_control_qe = NULL;
553 if (NULL !=
ch->retry_data_task)
556 ch->retry_data_task = NULL;
558 if (NULL !=
ch->retry_control_task)
561 ch->retry_control_task = NULL;
596 ch->last_control_qe = NULL;
599 "Sent CADET_CHANNEL_OPEN on %s, retrying in %s\n",
602 ch->retry_control_task =
618 ch->retry_control_task = NULL;
620 "Sending CHANNEL_OPEN message for %s\n",
629 if (NULL !=
ch->last_control_qe)
631 ch->last_control_qe =
652 "Tunnel up, sending CHANNEL_OPEN on %s now\n",
674 ch->mid_recv.mid = htonl (1);
678 ch->max_pending_messages =
679 (
ch->nobuffer) ? 1 : 4;
699 "Created loose incoming loopback channel to port %s\n",
715 "Created channel to port %s at peer %s for %s using %s\n",
735 ch->retry_control_task = NULL;
737 "Closing incoming channel to port %s from peer %s due to timeout\n",
761 ch->max_pending_messages =
762 (
ch->nobuffer) ? 1 : 4;
780 "Created loose incoming channel to port %s from peer %s\n",
809 ch->last_control_qe = NULL;
828 msg.mid.mid = htonl (ntohl (
ch->mid_recv.mid));
831 "Sending DATA_ACK %u:%llX via %s\n",
832 (
unsigned int) ntohl (
msg.mid.mid),
833 (
unsigned long long)
ch->mid_futures,
835 if (NULL !=
ch->last_control_qe)
854 ch->retry_control_task = NULL;
856 "Sending CHANNEL_OPEN_ACK on %s\n",
860 msg.reserved = htonl (0);
863 if (NULL !=
ch->last_control_qe)
883 if (NULL ==
ch->dest)
886 "Ignoring duplicate CHANNEL_OPEN on %s: port is closed\n",
890 if (NULL !=
ch->retry_control_task)
893 "Ignoring duplicate CHANNEL_OPEN on %s: control message is pending\n",
898 "Retransmitting CHANNEL_OPEN_ACK on %s\n",
929 "Sending CADET_LOCAL_ACK to %s (%s) at ccn %X (%u/%u pending)\n",
933 ch->pending_messages,
934 ch->max_pending_messages);
948 "Binding %s from %s to port %s of %s\n",
953 if (NULL !=
ch->retry_control_task)
957 ch->retry_control_task = NULL;
975 ch->mid_recv.mid = htonl (1);
990 for (
unsigned int i = 0; i <
ch->max_pending_messages; i++)
1009 ch->retry_control_task = NULL;
1010 ccc = (NULL !=
ch->owner) ?
ch->owner :
ch->dest;
1030 "%s asks for destruction of %s\n",
1034 if ((NULL !=
ch->owner) && (
c ==
ch->owner->c) &&
1040 else if ((NULL !=
ch->dest) && (
c ==
ch->dest->c) &&
1058 if ((NULL !=
ch->head_sent) && ((NULL !=
ch->owner) || (NULL !=
ch->dest)))
1066 ((NULL !=
ch->owner) || (NULL !=
ch->dest)))
1068 if (NULL !=
ch->retry_control_task)
1070 ch->retry_control_task =
1115 if (NULL ==
ch->owner)
1129 "Received CHANNEL_OPEN_ACK for waiting %s, entering READY state\n",
1131 if (NULL !=
ch->retry_control_task)
1134 ch->retry_control_task = NULL;
1139 for (
unsigned int i = 0; i <
ch->max_pending_messages; i++)
1146 "Received duplicate channel OPEN_ACK for %s\n",
1167 int *duplicate = cls;
1168 uint32_t v1 = ntohl (m1->
mid.
mid);
1169 uint32_t v2 = ntohl (m2->
mid.
mid);
1197 size_t payload_size;
1206 if ((NULL ==
ch->owner) && (NULL ==
ch->dest))
1212 "Dropping incoming payload on %s as this end is already closed\n",
1219 payload_size = ntohs (
msg->header.
size) -
sizeof(*msg);
1225 ccc = (NULL !=
ch->owner) ?
ch->owner :
ch->dest;
1236 (ntohl (
msg->mid.mid) >= ntohl (
ch->mid_recv.mid)) &&
1241 "Giving %u bytes of payload with MID %u from %s to client %s\n",
1242 (
unsigned int) payload_size,
1243 ntohl (
msg->mid.mid),
1249 ch->mid_recv.mid = htonl (1 + ntohl (
msg->mid.mid));
1251 ch->mid_recv.mid = htonl (1 + ntohl (
ch->mid_recv.mid));
1252 ch->mid_futures >>= 1;
1256 uint64_t
d = htonl (
msg->mid.mid) - 1 - ntohl (
ch->mid_recv.mid);
1259 ch->mid_futures = 0;
1261 ch->mid_futures >>=
d;
1262 ch->mid_recv.mid = htonl (1 + ntohl (
msg->mid.mid));
1272 mid_min = ntohl (
ch->mid_recv.mid);
1273 mid_max = mid_min +
ch->max_pending_messages;
1274 mid_msg = ntohl (
msg->mid.mid);
1275 if (((uint32_t) (mid_msg - mid_min) >
ch->max_pending_messages) ||
1276 ((uint32_t) (mid_max - mid_msg) >
ch->max_pending_messages))
1279 "%s at %u drops ancient or far-future message %u\n",
1281 (
unsigned int) mid_min,
1282 ntohl (
msg->mid.mid));
1285 "# duplicate DATA (ancient or future)",
1293 delta = mid_msg - mid_min - 1;
1296 if (0 != (
ch->mid_futures & (1LLU <<
delta)))
1300 "Duplicate payload of %u bytes on %s (mid %u) dropped\n",
1301 (
unsigned int) payload_size,
1303 ntohl (
msg->mid.mid));
1309 ch->mid_futures |= (1LLU <<
delta);
1311 "Marked bit %llX for mid %u (base: %u); now: %llX\n",
1315 (
unsigned long long)
ch->mid_futures);
1330 "Giving queued MID %u from %s to client %s\n",
1331 ntohl (next_msg->
mid.
mid),
1336 ch->mid_recv.mid = htonl (1 + ntohl (next_msg->
mid.
mid));
1337 ch->mid_futures >>= 1;
1346 "Message on %s (mid %u) dropped, duplicate\n",
1348 ntohl (
msg->mid.mid));
1356 if (ntohl (
msg->mid.mid) < ntohl (
ch->mid_recv.mid))
1360 "Message on %s (mid %u) dropped, old.\n",
1362 ntohl (
msg->mid.mid));
1369 if (ccc->
num_recv >=
ch->max_pending_messages)
1376 "Queue full due slow client on %s, dropping oldest message\n",
1379 "# messages dropped due to slow client",
1410 "Duplicate payload of %u bytes on %s (mid %u) dropped\n",
1411 (
unsigned int) payload_size,
1413 ntohl (
msg->mid.mid));
1423 "Queued %s payload of %u bytes on %s-%X(%p) (mid %u, need %u first)\n",
1425 (
unsigned int) payload_size,
1429 ntohl (
msg->mid.mid),
1430 ntohl (
ch->mid_recv.mid));
1466 ch->retry_data_task = NULL;
1469 "Retrying transmission on %s of message %u\n",
1492 ch->pending_messages--;
1495 "Received DATA_ACK on %s for message %u (%u ACKs pending)\n",
1498 ch->pending_messages);
1499 if (NULL != crm->
qe)
1551 mid_base = ntohl (ack->
mid.
mid);
1554 for (crm =
ch->head_sent; NULL != crm; crm = crmn)
1558 if (
delta >= UINT_MAX -
ch->max_pending_messages)
1562 "Got DATA_ACK with base %u satisfying past message %u on %s\n",
1563 (
unsigned int) mid_base,
1574 "Testing bit %llX for mid %u (base: %u)\n",
1578 if (0 != (mid_mask & (1LLU <<
delta)))
1581 "Got DATA_ACK with mask for %u on %s\n",
1593 "Duplicate DATA_ACK on %s, ignoring\n",
1598 if (NULL !=
ch->retry_data_task)
1601 ch->retry_data_task = NULL;
1603 if ((NULL !=
ch->head_sent) && (NULL ==
ch->head_sent->qe))
1619 "Received remote channel DESTROY for %s\n",
1627 ccc = (NULL !=
ch->owner) ?
ch->owner :
ch->dest;
1628 if ((NULL != ccc) && (NULL != ccc->
head_recv))
1631 "Lost end of transmission due to remote shutdown on %s\n",
1686 ch->pending_messages--;
1727 "Message %u sent, next transmission on %s in %s\n",
1732 ch->head_sent->next_retry),
1734 if (NULL ==
ch->head_sent->qe)
1736 if (NULL !=
ch->retry_data_task)
1767 if (
ch->pending_messages >=
ch->max_pending_messages)
1777 ch->pending_messages++;
1788 if ((NULL !=
ch->owner) &&
1794 else if ((NULL !=
ch->dest) &&
1811 ch->pending_messages--;
1838 ch->mid_send.mid = htonl (ntohl (
ch->mid_send.mid) + 1);
1844 "Sending message %u from local client to %s with %lu bytes\n",
1847 (
unsigned long) buf_len);
1848 if (NULL !=
ch->retry_data_task)
1851 ch->retry_data_task = NULL;
1867 if ((NULL !=
ch->owner) &&
1870 else if ((NULL !=
ch->dest) &&
1880 "Got LOCAL_ACK, %s-%X ready to receive more data, but none pending on %s-%X(%p)!\n",
1897 if ((NULL !=
ch->owner) &&
1917 "Got LOCAL_ACK, %s-%X ready to receive more data (but next one is out-of-order %u vs. %u)!\n",
1921 ntohl (
ch->mid_recv.mid));
1926 "Got LOCAL_ACK, giving payload message %u to %s-%X on %s\n",
1938 ch->mid_recv.mid = htonl (1 + ntohl (com->
mid.
mid));
1939 ch->mid_futures >>= 1;
1953#define LOG2(level, ...) \
1954 GNUNET_log_from_nocheck (level, "cadet-chn", __VA_ARGS__)
1966#if ! defined(GNUNET_CULL_LOGGING)
1979 LOG2 (level,
"CHN *** DEBUG NULL CHANNEL ***\n");
1983 if (NULL !=
ch->owner)
1986 "CHN origin %s ready %s local-id: %u\n",
1988 ch->owner->client_ready ?
"YES" :
"NO",
1991 if (NULL !=
ch->dest)
1994 "CHN destination %s ready %s local-id: %u\n",
1996 ch->dest->client_ready ?
"YES" :
"NO",
2000 "CHN Message IDs recv: %d (%llX), send: %d\n",
2001 ntohl (
ch->mid_recv.mid),
2002 (
unsigned long long)
ch->mid_futures,
2003 ntohl (
ch->mid_send.mid));
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI
Minimum value for channel IDs of local clients.
static mp_limb_t d[(((256)+GMP_NUMB_BITS - 1)/GMP_NUMB_BITS)]
static struct GNUNET_ARM_Operation * op
Current operation.
static uint16_t port
Port number.
static struct GNUNET_CADET_Channel * ch
Channel handle.
static struct GNUNET_PeerIdentity my_full_id
Peer identity.
void GSC_handle_remote_channel_destroy(struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn, struct CadetChannel *ch)
A channel was destroyed by the other peer.
void GSC_send_to_client(struct CadetClient *c, struct GNUNET_MQ_Envelope *env)
Send a message to a client.
struct GNUNET_CONTAINER_MultiHashMap * open_ports
All ports clients of this peer have opened.
struct GNUNET_CADET_ClientChannelNumber GSC_bind(struct CadetClient *c, struct CadetChannel *ch, struct CadetPeer *dest, const struct GNUNET_HashCode *port, uint32_t options)
Bind incoming channel to this client, and notify client about incoming connection.
struct GNUNET_CONTAINER_MultiHashMap * loose_channels
Map from ports to channels where the ports were closed at the time we got the inbound connection.
void GSC_drop_loose_channel(const struct GNUNET_HashCode *h_port, struct CadetChannel *ch)
A client that created a loose channel that was not bound to a port disconnected, drop it from the loo...
const char * GSC_2s(struct CadetClient *c)
Return identifier for a client as a string.
void GCCH_handle_channel_plaintext_data_ack(struct CadetChannel *ch, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, const struct GNUNET_CADET_ChannelDataAckMessage *ack)
We got an acknowledgement for payload data for a channel.
static void send_channel_data_ack(struct CadetChannel *ch)
Compute and send the current GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK to the other peer.
static void handle_matching_ack(struct CadetChannel *ch, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, struct CadetReliableMessage *crm)
We got an PLAINTEXT_DATA_ACK for a message in our queue, remove it from the queue and tell our client...
static void free_channel_client(struct CadetChannelClient *ccc)
Release memory associated with ccc.
static void channel_destroy(struct CadetChannel *ch)
Destroy the given channel.
CadetChannelState
All the states a channel can be in.
@ CADET_CHANNEL_NEW
Uninitialized status, should never appear in operation.
@ CADET_CHANNEL_OPEN_SENT
CHANNEL_OPEN message sent, waiting for CHANNEL_OPEN_ACK.
@ CADET_CHANNEL_READY
Connection confirmed, ready to carry traffic.
@ CADET_CHANNEL_LOOSE
Channel is to a port that is not open, we're waiting for the port to be opened.
static void send_open_ack(void *cls)
Send our initial GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK to the client confirming that the connect...
int GCCH_handle_local_data(struct CadetChannel *ch, struct GNUNET_CADET_ClientChannelNumber sender_ccn, const char *buf, size_t buf_len)
Handle data given by a client.
static int cmp_crm_by_next_retry(void *cls, struct CadetReliableMessage *crm1, struct CadetReliableMessage *crm2)
Test if element e1 comes before element e2.
struct CadetChannel * GCCH_channel_incoming_new(struct CadetTunnel *t, struct GNUNET_CADET_ChannelTunnelNumber ctn, const struct GNUNET_HashCode *h_port, uint32_t options)
Create a new channel based on a request coming in over the network.
static void channel_open_sent_cb(void *cls, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Function called once the tunnel confirms that we sent the create message.
static void send_ack_to_client(struct CadetChannel *ch, int to_owner)
Send a GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK to the client to solicit more messages.
void GCCH_bind(struct CadetChannel *ch, struct CadetClient *c, const struct GNUNET_HashCode *port)
A client is bound to the port that we have a channel open to.
const char * GCCH_2s(const struct CadetChannel *ch)
Get the static string for identification of the channel.
void GCCH_handle_duplicate_open(struct CadetChannel *ch, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti)
We got a GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN message again for this channel.
static void send_ack_cb(void *cls, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Function called once the tunnel confirms that we sent the ACK message.
void GCCH_handle_local_ack(struct CadetChannel *ch, struct GNUNET_CADET_ClientChannelNumber client_ccn)
Handle ACK from client on local channel.
void GCCH_channel_local_destroy(struct CadetChannel *ch, struct CadetClient *c, struct GNUNET_CADET_ClientChannelNumber ccn)
Destroy locally created channel.
void GCCH_assign_type_to_drop(struct CadetChannel *ch, const struct GNUNET_CADET_RequestDropCadetMessage *message)
Assign type of message to drop.
static void timeout_closed_cb(void *cls)
We had an incoming channel to a port that is closed.
#define CADET_INITIAL_RETRANSMIT_TIME
How long do we initially wait before retransmitting?
struct CadetChannel * GCCH_channel_local_new(struct CadetClient *owner, struct GNUNET_CADET_ClientChannelNumber ccn, struct CadetPeer *destination, const struct GNUNET_HashCode *port, uint32_t options)
Create a new channel.
void GCCH_tunnel_up(struct CadetChannel *ch)
Function called once and only once after a channel was bound to its tunnel via GCT_add_channel() is r...
void GCCH_hash_port(struct GNUNET_HashCode *h_port, const struct GNUNET_HashCode *port, const struct GNUNET_PeerIdentity *listener)
Hash the port and initiator and listener to calculate the "challenge" h_port we send to the other pee...
void GCCH_debug(struct CadetChannel *ch, enum GNUNET_ErrorType level)
Log channel info.
static void send_channel_open(void *cls)
Send a channel create message.
static int is_before(void *cls, struct CadetOutOfOrderMessage *m1, struct CadetOutOfOrderMessage *m2)
Test if element e1 comes before element e2.
#define TIMEOUT_CLOSED_PORT
How long do we wait before dropping state about incoming connection to closed port?
#define MIN_RTT_DELAY
How long do we wait at least before retransmitting ever?
static void signal_remote_destroy_cb(void *cls)
One of our clients has disconnected, tell the other one that we are finished.
void GCCH_handle_channel_plaintext_data(struct CadetChannel *ch, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, const struct GNUNET_CADET_ChannelAppDataMessage *msg)
We got payload data for a channel.
static void data_sent_cb(void *cls, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Function called once the tunnel has sent one of our messages.
struct GNUNET_CADET_ChannelTunnelNumber GCCH_get_id(const struct CadetChannel *ch)
Get the channel's public ID.
static void retry_transmission(void *cls)
We need to retry a transmission, the last one took too long to be acknowledged.
void GCCH_handle_remote_destroy(struct CadetChannel *ch, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti)
Destroy channel, based on the other peer closing the connection.
void GCCH_handle_channel_open_ack(struct CadetChannel *ch, const struct GNUNET_CADET_ConnectionTunnelIdentifier *cti, const struct GNUNET_HashCode *port)
We got an acknowledgement for the creation of the channel (the port is open on the other side).
int GCCH_is_type_to_drop(struct CadetChannel *ch, const struct GNUNET_MessageHeader *message)
Check if type of message is the one to drop.
GNUnet CADET service with encryption.
void GCC_latency_observed(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, struct GNUNET_TIME_Relative latency)
We observed some the given latency on the connection identified by cti.
void GCC_ack_observed(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
We observed an ACK for a message that was originally sent via the connection identified by cid.
const struct CadetConnectionMetrics * GCC_get_metrics(struct CadetConnection *cc)
Obtain performance metrics from cc.
void GCC_ack_expected(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
We sent a message for which we expect to receive an ACK via the connection identified by cti.
struct CadetConnection * GCC_lookup(const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid)
Lookup a connection by its identifier.
A connection is a live end-to-end messaging mechanism where the peers are identified by a path and kn...
const struct GNUNET_PeerIdentity * GCP_get_id(struct CadetPeer *cp)
Obtain the peer identity for a struct CadetPeer.
struct CadetPeer * GCP_get(const struct GNUNET_PeerIdentity *peer_id, int create)
Retrieve the CadetPeer structure associated with the peer.
struct CadetTunnel * GCP_get_tunnel(struct CadetPeer *cp, int create)
Get the tunnel towards a peer.
const char * GCP_2s(const struct CadetPeer *cp)
Get the static string for a peer ID.
void GCT_remove_channel(struct CadetTunnel *t, struct CadetChannel *ch, struct GNUNET_CADET_ChannelTunnelNumber ctn)
Remove a channel from a tunnel.
struct CadetPeer * GCT_get_destination(struct CadetTunnel *t)
Return the peer to which this tunnel goes.
void GCT_send_channel_destroy(struct CadetTunnel *t, struct GNUNET_CADET_ChannelTunnelNumber ctn)
Send a DESTROY message via the tunnel.
void GCT_send_cancel(struct CadetTunnelQueueEntry *tq)
Cancel a previously sent message while it's in the queue.
struct CadetTunnelQueueEntry * GCT_send(struct CadetTunnel *t, const struct GNUNET_MessageHeader *message, GCT_SendContinuation cont, void *cont_cls, struct GNUNET_CADET_ChannelTunnelNumber *ctn)
Sends an already built message on a tunnel, encrypting it and choosing the best connection if not pro...
struct GNUNET_CADET_ChannelTunnelNumber GCT_add_channel(struct CadetTunnel *t, struct CadetChannel *ch)
Add a channel to a tunnel, and notify channel that we are ready for transmission if we are already up...
const char * GCT_2s(const struct CadetTunnel *t)
Get the static string for the peer this tunnel is directed.
Information we track per tunnel.
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
static struct GNUNET_SCHEDULER_Task * t
Main task.
API to create, modify and access statistics.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
int GNUNET_get_log_call_status(int caller_level, const char *comp, const char *file, const char *function, int line)
Decides whether a particular logging call should or should not be allowed to be made.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
#define GNUNET_CONTAINER_DLL_insert_sorted(TYPE, comparator, comparator_cls, head, tail, element)
Insertion sort of element into DLL from head to tail sorted by comparator.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
#define GNUNET_PACKED
gcc-ism to get packed structs.
GNUNET_ErrorType
Types of errors.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_DEBUG
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN
Ask the cadet service to create a new channel.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK
Local ACK for data.
#define GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK
Confirm payload data end-to-end.
#define GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA
Payload data (inside an encrypted tunnel).
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA
Payload client <-> service.
#define GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK
Confirm the creation of a channel.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_at(struct GNUNET_TIME_Absolute at, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run at the specified time.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
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...
struct GNUNET_TIME_Relative GNUNET_TIME_relative_max(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the maximum of two relative time values.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
void receiver(void *cls, const void *buf, size_t available, const struct sockaddr *addr, socklen_t addrlen, int errCode)
Callback to read from the SOCKS5 proxy.
static struct GNUNET_TIME_Relative delta
Client endpoint of a struct CadetChannel.
struct CadetOutOfOrderMessage * head_recv
Head of DLL of messages received out of order or while client was unready.
struct CadetClient * c
Client handle.
struct CadetOutOfOrderMessage * tail_recv
Tail DLL of messages received out of order or while client was unready.
struct GNUNET_CADET_ClientChannelNumber ccn
Local tunnel number for this client.
unsigned int num_recv
Number of entries currently in head_recv DLL.
int client_ready
Can we send data to the client?
Struct containing all information regarding a channel to a remote client.
struct CadetTunnel * t
Tunnel this channel is in.
unsigned int max_pending_messages
Maximum (reliable) messages pending ACK for this channel before we throttle the client.
unsigned int pending_messages
Total (reliable) messages pending ACK for this channel.
struct GNUNET_SCHEDULER_Task * retry_control_task
Task to resend/poll in case no ACK is received.
struct GNUNET_TIME_Absolute timestamp
Last time the channel was used.
struct ChannelMessageIdentifier mid_recv
Next MID expected for incoming traffic.
struct CadetReliableMessage * tail_sent
Tail of DLL of messages sent and not yet ACK'd.
struct GNUNET_TIME_Relative retry_time
Counter for exponential backoff.
int nobuffer
Is the tunnel bufferless (minimum latency)?
struct GNUNET_HashCode port
Destination port of the channel.
uint16_t type
Type of message to be dropped.
int destroy
Flag to signal the destruction of the channel.
enum CadetChannelState state
Channel state.
struct CadetChannelClient * owner
Client owner of the tunnel, if any.
int reliable
Is the tunnel reliable?
struct ChannelMessageIdentifier mid_send
Next MID to use for outgoing traffic.
uint64_t mid_futures
Bitfield of already-received messages past mid_recv.
int out_of_order
Is the tunnel out-of-order?
struct GNUNET_HashCode h_port
Hash'ed port of the channel with initiator and destination PID.
struct GNUNET_CADET_ChannelTunnelNumber ctn
Number identifying this channel in its tunnel.
struct GNUNET_SCHEDULER_Task * retry_data_task
Task to resend/poll in case no ACK is received.
struct CadetChannelClient * dest
Client destination of the tunnel, if any.
unsigned int skip_ack_series
Count how many ACKs we skipped, used to prevent long sequences of ACK skipping.
int is_loopback
Is this channel a loopback channel, where the destination is us again?
struct CadetReliableMessage * head_sent
Head of DLL of messages sent and not yet ACK'd.
struct CadetTunnelQueueEntry * last_control_qe
Last entry in the tunnel's queue relating to control messages (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN...
Struct containing information about a client of the service.
struct GNUNET_TIME_Relative aged_latency
Our current best estimate of the latency, based on a weighted average of at least latency_datapoints ...
Low-level connection to a destination.
struct GNUNET_CADET_ConnectionTunnelIdentifier cid
ID of the connection.
List of received out-of-order data messages.
struct ChannelMessageIdentifier mid
ID of the message (messages up to this point needed before we give this one to the client).
struct GNUNET_MQ_Envelope * env
The envelope with the payload of the out-of-order message.
struct CadetOutOfOrderMessage * next
Double linked list, FIFO style.
struct CadetOutOfOrderMessage * prev
Double linked list, FIFO style.
Struct containing all information regarding a given peer.
Info needed to retry a message in case it gets lost.
struct CadetTunnelQueueEntry * qe
Entry in the tunnels queue for this message, NULL if it has left the tunnel.
struct GNUNET_TIME_Absolute next_retry
How soon should we retry if we fail to get an ACK? Messages in the queue are sorted by this value.
struct CadetReliableMessage * next
Double linked list, FIFO style.
struct GNUNET_CADET_ChannelAppDataMessage * data_message
Data message we are trying to send.
struct GNUNET_CADET_ConnectionTunnelIdentifier connection_taken
Identifier of the connection that this message took when it was first transmitted.
struct CadetChannel * ch
Which channel is this message in?
struct GNUNET_TIME_Absolute first_transmission_time
Time when we first successfully transmitted the message (that is, set num_transmissions to 1).
struct CadetReliableMessage * prev
Double linked list, FIFO style.
int num_transmissions
How often was this message transmitted? GNUNET_SYSERR if there was an error transmitting the message,...
struct GNUNET_TIME_Relative retry_delay
How long do we wait for an ACK after transmission? Use for the back-off calculation.
Struct used to save messages in a non-ready tunnel to send once connected.
Struct containing all information regarding a tunnel to a peer.
Number used to uniquely identify messages in a CADET Channel.
uint32_t mid
Unique ID of the message, cycles around, in NBO.
Message for cadet data traffic.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA.
struct GNUNET_CADET_ChannelTunnelNumber ctn
ID of the channel.
struct ChannelMessageIdentifier mid
Unique ID of the payload message.
Message to acknowledge end-to-end data.
struct ChannelMessageIdentifier mid
Next message ID expected.
uint64_t futures
Bitfield of already-received newer messages.
Message to acknowledge opening a channel of type GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK.
Message to create a Channel.
struct GNUNET_HashCode h_port
Hash of destination port and listener.
struct GNUNET_CADET_ChannelTunnelNumber ctn
ID of the channel within the tunnel.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN.
uint32_t opt
Channel options.
Number identifying a CADET channel within a tunnel.
struct GNUNET_CADET_ClientChannelNumber ccn
Local ID of the channel, GNUNET_CADET_LOCAL_CHANNEL_ID_CLI bit is set if outbound.
Number uniquely identifying a channel of a client.
uint32_t channel_of_client
Values for channel numbering.
Hash uniquely identifying a connection below a tunnel.
Message to allow the client send more data to the service (always service -> client).
struct GNUNET_CADET_ClientChannelNumber ccn
ID of the channel allowed to send more data.
Message for cadet data traffic.
struct GNUNET_CADET_ClientChannelNumber ccn
ID of the channel.
Message to drop another message of specific type.
uint16_t type
Type of the message this handler covers, in host byte order.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
struct GNUNET_HashCode h_port
Port hashed with our PID (matches incoming OPEN messages).