33#define LOG(kind, ...) GNUNET_log_from (kind, "cadet-api", __VA_ARGS__)
173 h->next_ccn.channel_of_client =
175 | (1 + ntohl (
h->next_ccn.channel_of_client)));
208 "Destroying channel %X of %p\n",
326 "Sending message on channel %s to CADET, new window size is %u\n",
380 cadet_msg->
pp = htonl ((uint32_t)
pp);
427 "MQ error in communication with CADET: %d\n",
478 port_number = &
msg->port;
494 "No handler for incoming channel %X (on port %s, recently closed?)\n",
508 "Creating incoming channel %X [%s] %p\n",
546 "Received channel destroy for unknown channel %X from CADET service (recently close?)\n",
547 ntohl (
msg->ccn.channel_of_client));
551 "Received channel destroy for channel %X from CADET service\n",
552 ntohl (
msg->ccn.channel_of_client));
600 "Unknown channel %X for incoming data (recently closed?)\n",
609 "Got a %s data on channel %s [%X] of type %u\n",
635 "ACK on unknown channel %X\n",
641 "Got an ACK on mq channel %X (peer %s); new window size is %u!\n",
648 "Got an ACK on mq channel %X, allow send now %u!\n",
678 "Destroying channel due to GNUNET_CADET_disconnect()\n");
791 if (NULL !=
handle->reconnect_task)
794 handle->reconnect_task = NULL;
806 if (NULL !=
p->cadet->mq)
843 "Destroying channel due to GNUNET_CADET_channel_destroy()\n");
879 "Sending ACK on channel %X\n",
968 "Listening to CADET port %s\n",
984 p->cls = connects_cls;
985 p->window_changes = window_changes;
1029 "Creating channel to peer %s at port %s\n",
1033 ch->
ctx = channel_cls;
1052 msg->peer = *destination;
struct GNUNET_MQ_MessageHandlers handlers[]
struct GNUNET_MQ_Handle * mq
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
void * connects(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
void disconnects(void *cls, const struct GNUNET_PeerIdentity *peer)
#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI
Minimum value for channel IDs of local clients.
static void notify_window_size(struct GNUNET_CADET_Channel *ch)
Notify the application about a change in the window size (if needed).
static void reconnect_cbk(void *cls)
Reconnect callback: tries to reconnect again after a failed previous connection.
static void cadet_mq_send_impl(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *msg, void *impl_state)
Implement sending functionality of a message queue for us sending messages to a peer.
static void handle_channel_destroy(void *cls, const struct GNUNET_CADET_LocalChannelDestroyMessage *msg)
Process the channel destroy notification and free associated resources.
static void return_agpl(void *cls, const struct GNUNET_MessageHeader *msg)
Function to return link to AGPL source upon request.
static void cadet_mq_send_now(void *cls)
Transmit the next message from our queue.
static void cadet_mq_destroy_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
Handle destruction of a message queue.
static void destroy_channel(struct GNUNET_CADET_Channel *ch)
Destroy the specified channel.
static void cadet_mq_cancel_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
Implementation function that cancels the currently sent message.
static void handle_local_data(void *cls, const struct GNUNET_CADET_LocalData *message)
Process the incoming data packets, call appropriate handlers.
static void cadet_mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
We had an error processing a message we forwarded from a peer to the CADET service.
static int destroy_channel_cb(void *cls, uint32_t cid, void *value)
Function called during GNUNET_CADET_disconnect() to destroy all channels that are still open.
static void handle_local_ack(void *cls, const struct GNUNET_CADET_LocalAck *message)
Process a local ACK message, enabling the client to send more data to the service.
static struct GNUNET_CADET_Channel * create_channel(struct GNUNET_CADET_Handle *h, const struct GNUNET_CADET_ClientChannelNumber *ccnp)
Create a new channel and insert it in the channel list of the cadet handle.
static struct GNUNET_CADET_Port * find_port(const struct GNUNET_CADET_Handle *h, const struct GNUNET_HashCode *hash)
Find the Port struct for a hash.
static void reconnect(struct GNUNET_CADET_Handle *h)
Reconnect to the service, retransmit all information to try to restore the original state.
static int check_local_data(void *cls, const struct GNUNET_CADET_LocalData *message)
Check that message received from CADET service is well-formed.
static int open_port_cb(void *cls, const struct GNUNET_HashCode *id, void *value)
Function called during reconnect_cbk() to (re)open all ports that are still open.
static void handle_channel_created(void *cls, const struct GNUNET_CADET_LocalChannelCreateMessage *msg)
Process the new channel notification and add it to the channels in the handle.
static struct GNUNET_CADET_Channel * find_channel(struct GNUNET_CADET_Handle *h, struct GNUNET_CADET_ClientChannelNumber ccn)
Get the channel handler for the channel specified by id from the given handle.
static int destroy_port_cb(void *cls, const struct GNUNET_HashCode *id, void *value)
Function called during GNUNET_CADET_disconnect() to destroy all ports that are still open.
static void handle_mq_error(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
P2P messages used by CADET.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static uint16_t port
Port number.
static struct GNUNET_CADET_Channel * ch
Channel handle.
static char * res
Currently read line or NULL on EOF.
static char * value
Value of the record to add/remove.
static uint32_t type
Type string converted to DNS type value.
static void channel_destroy(struct CadetChannel *ch)
Destroy the given channel.
static unsigned long long payload
How much data are we currently storing in the database?
static struct GNUNET_OS_Process * p
Helper process we started.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
CADET service; establish channels to distant peers.
#define GNUNET_AGPL_URL
NOTE: You MUST adjust this URL to point to the location of a publicly accessible repository (or TGZ) ...
struct GNUNET_CADET_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Send an ack on the channel to confirm the processing of a message.
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
struct GNUNET_MQ_Handle * GNUNET_CADET_get_mq(const struct GNUNET_CADET_Channel *channel)
Obtain the message queue for a connected peer.
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...
GNUNET_CADET_ChannelInfoOption
struct GNUNET_CADET_Port * GNUNET_CADET_open_port(struct GNUNET_CADET_Handle *h, const struct GNUNET_HashCode *port, GNUNET_CADET_ConnectEventHandler connects, void *connects_cls, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Open a port to receive incoming MQ-based channels.
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port.
struct GNUNET_CADET_Channel * GNUNET_CADET_channel_create(struct GNUNET_CADET_Handle *h, void *channel_cls, const struct GNUNET_PeerIdentity *destination, const struct GNUNET_HashCode *port, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Create a new channel towards a remote peer.
const union GNUNET_CADET_ChannelInfo * GNUNET_CADET_channel_get_info(struct GNUNET_CADET_Channel *channel, enum GNUNET_CADET_ChannelInfoOption option,...)
Get information about a channel.
void *(* GNUNET_CADET_ConnectEventHandler)(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *source)
Method called whenever a peer connects to a port in MQ-based CADET.
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.
@ GNUNET_CADET_OPTION_PEER
Who is the peer at the other end of the channel.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
#define GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE
Maximum message size that can be sent on CADET.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_put(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
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.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_remove(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value)
Remove the given key-value pair from the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
void * GNUNET_CONTAINER_multihashmap32_get(const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t 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.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MultiHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
#define GNUNET_log(kind,...)
void * cls
Closure for mv and cb.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#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_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MQ_Error
Error codes for the queue.
struct GNUNET_MQ_Handle * GNUNET_MQ_queue_for_callbacks(GNUNET_MQ_SendImpl send, GNUNET_MQ_DestroyImpl destroy, GNUNET_MQ_CancelImpl cancel, void *impl_state, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *cls)
Create a message queue for the specified handlers.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
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.
struct GNUNET_MQ_MessageHandler * GNUNET_MQ_copy_handlers2(const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_MessageCallback agpl_handler, void *agpl_cls)
Copy an array of handlers, appending AGPL handler.
#define GNUNET_MQ_msg_nested_mh(mvar, type, mh)
Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct.
struct GNUNET_MQ_MessageHandler * GNUNET_MQ_copy_handlers(const struct GNUNET_MQ_MessageHandler *handlers)
Copy an array of handlers.
void GNUNET_MQ_impl_send_continue(struct GNUNET_MQ_Handle *mq)
Call the send implementation for the next queued message, if any.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
void GNUNET_MQ_inject_message(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *mh)
Call the message message handler that was registered for the type of the given message in the given m...
GNUNET_MQ_PriorityPreferences
Per envelope preferences and priorities.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
enum GNUNET_MQ_PriorityPreferences GNUNET_MQ_env_get_options(struct GNUNET_MQ_Envelope *env)
Get performance preferences set for this envelope.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_set_handlers_closure(struct GNUNET_MQ_Handle *mq, void *handlers_cls)
Change the closure argument in all of the handlers of the mq.
struct GNUNET_MQ_Envelope * GNUNET_MQ_get_current_envelope(struct GNUNET_MQ_Handle *mq)
Function to obtain the current envelope from within GNUNET_MQ_SendImpl implementations.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
@ GNUNET_MQ_ERROR_NO_MATCH
We received a message for which we have no matching handler.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_get(void)
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE
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_LOCAL_PORT_CLOSE
Stop listening on a port.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN
Start listening on a port.
#define GNUNET_MESSAGE_TYPE_RESPONSE_AGPL
Source code link.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA
Payload client <-> service.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY
Tell client that a channel was destroyed.
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.
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static unsigned int size
Size of the "table".
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
Opaque handle to a channel.
void * ctx
Any data the caller wants to put in here, used for the various callbacks (disconnects,...
struct GNUNET_CADET_Handle * cadet
Handle to the cadet this channel belongs to.
unsigned int allow_send
How many messages are we allowed to send to the service right now?
struct GNUNET_SCHEDULER_Task * mq_cont
Task to allow mq to send more traffic.
struct GNUNET_PeerIdentity peer
Other end of the channel.
GNUNET_CADET_WindowSizeEventHandler window_changes
Window change handler.
struct GNUNET_CADET_ClientChannelNumber ccn
Local ID of the channel, GNUNET_CADET_LOCAL_CHANNEL_ID_CLI bit is set if outbound.
GNUNET_CADET_DisconnectEventHandler disconnects
Disconnect handler.
struct GNUNET_MQ_Handle * mq
Message Queue for the channel (which we are implementing).
struct GNUNET_MQ_Envelope * pending_env
Pending envelope with a message to be transmitted to the service as soon as we are allowed to.
struct GNUNET_CADET_Port * incoming_port
Channel's port, if incoming.
Number uniquely identifying a channel of a client.
uint32_t channel_of_client
Values for channel numbering.
Opaque handle to the service.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for trying to reconnect.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration given by the client, in case of reconnection.
struct GNUNET_CADET_ClientChannelNumber next_ccn
child of the next channel to create (to avoid reusing IDs often)
struct GNUNET_CONTAINER_MultiHashMap * ports
Ports open.
struct GNUNET_TIME_Relative reconnect_time
Time to the next reconnect in case one reconnect fails.
struct GNUNET_MQ_Handle * mq
Message queue.
struct GNUNET_CONTAINER_MultiHashMap32 * channels
Channels open.
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 a client to create channels.
Message for or to a client to destroy tunnel.
struct GNUNET_CADET_ClientChannelNumber ccn
ID of a channel controlled by this client.
Message for cadet data traffic.
struct GNUNET_CADET_ClientChannelNumber ccn
ID of the channel.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA.
uint32_t pp
Priority and preferences (an enum GNUNET_MQ_PriorityPreferences) of the message in NBO.
Message for a client to create and destroy channels.
GNUNET_CADET_DisconnectEventHandler disconnects
Handler called when an incoming channel is destroyed.
void * cls
Closure for handler.
struct GNUNET_MQ_MessageHandler * handlers
Payload handlers for incoming channels.
struct GNUNET_HashCode id
Port "number".
GNUNET_CADET_WindowSizeEventHandler window_changes
Window size change handler.
void * connects_cls
Closure for connects.
struct GNUNET_CADET_Handle * cadet
Handle to the CADET session this port belongs to.
GNUNET_CADET_ConnectEventHandler connects
Handler for incoming channels on this port.
Internal representation of the hash map.
Internal representation of the hash map.
Handle to a message queue.
Message handler for a specific message type.
Project-specific data used to help the OS subsystem find installation paths.
const char * agpl_url
URL pointing to the source code of the application.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Handle to a client that is connected to a service.
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Union to retrieve info about a channel.