35 #define LOG(kind, ...) GNUNET_log_from (kind, "transport-api-core", __VA_ARGS__)
41 #define UNREADY_WARN_TIME GNUNET_TIME_UNIT_MINUTES
46 #define STARTING_NEIGHBOURS_SIZE 16
236 "Notifying CORE that more bandwidth is available for %s\n",
239 if (NULL !=
h->neb_cb)
261 "Dropping entry for neighbour `%s'.\n",
264 if (NULL !=
handle->nd_cb)
301 "Error receiving from transport service (%d), disconnecting temporarily.\n",
444 "Queued message of type %u for neighbour `%s'.\n",
540 "Receiving CONNECT message for `%s' with quota %u\n",
577 if (NULL !=
h->nc_cb)
599 "Receiving DISCONNECT message for `%s'.\n",
624 uint32_t bytes_physical;
625 uint16_t success = ntohs (okm->
success);
630 "Receiving SEND_OK message, transmission to %s %s.\n",
632 success ==
GNUNET_OK ?
"succeeded" :
"failed");
642 if (bytes_physical > bytes_msg)
645 "Overhead for %u byte message was %u\n",
647 bytes_physical - bytes_msg);
696 "Received message of type %u with %u bytes from `%s'.\n",
697 (
unsigned int) ntohs (imm->
type),
698 (
unsigned int) ntohs (imm->
size),
725 "Receiving SET_QUOTA message for `%s' with quota %u\n",
790 if (NULL !=
h->handlers)
816 "Scheduling task to reconnect to transport service in %s.\n",
884 for (i = 0; NULL !=
handlers[i].cb; i++)
925 handle->neighbours = NULL;
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MQ_Handle * mq
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static struct GNUNET_CADET_Channel * ch
Channel handle.
static GNUNET_NETWORK_STRUCT_END struct GNUNET_PeerIdentity me
Our own peer identity.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static char * value
Value of the record to add/remove.
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
#define MAX_BANDWIDTH_CARRY_S
Number of seconds that available bandwidth carries over (can accumulate).
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
Helper library for handling HELLOs.
Constants for network protocols.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
void *(* GNUNET_TRANSPORT_NotifyConnect)(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Function called to notify transport users that another peer connected to us.
void(* GNUNET_TRANSPORT_NotifyDisconnect)(void *cls, const struct GNUNET_PeerIdentity *peer, void *handler_cls)
Function called to notify transport users that another peer disconnected from us.
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
void GNUNET_BANDWIDTH_tracker_notification_stop(struct GNUNET_BANDWIDTH_Tracker *av)
Stop notifying about tracker updates and excess notifications.
int GNUNET_BANDWIDTH_tracker_consume(struct GNUNET_BANDWIDTH_Tracker *av, ssize_t size)
Notify the tracker that a certain number of bytes of bandwidth have been consumed.
void GNUNET_BANDWIDTH_tracker_update_quota(struct GNUNET_BANDWIDTH_Tracker *av, struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit)
Update quota of bandwidth tracker.
void GNUNET_BANDWIDTH_tracker_init2(struct GNUNET_BANDWIDTH_Tracker *av, GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb, void *update_cb_cls, struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit, uint32_t max_carry_s, GNUNET_BANDWIDTH_ExcessNotificationCallback excess_cb, void *excess_cb_cls)
Initialize bandwidth tracker.
struct GNUNET_TIME_Relative GNUNET_BANDWIDTH_tracker_get_delay(struct GNUNET_BANDWIDTH_Tracker *av, size_t size)
Compute how long we should wait until consuming size bytes of bandwidth in order to stay within the g...
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_DEFAULT_BW_IN_OUT
Bandwidth (in/out) to assume initially (before either peer has communicated any particular preference...
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from 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...
int GNUNET_HELLO_get_id(const struct GNUNET_HELLO_Message *hello, struct GNUNET_PeerIdentity *peer)
Get the peer identity from a HELLO message.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#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.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_send_cancel(struct GNUNET_MQ_Envelope *ev)
Cancel sending the message.
GNUNET_MQ_Error
Error codes for the queue.
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.
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.
#define GNUNET_MQ_msg_nested_mh(mvar, type, mh)
Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct.
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...
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
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_impl_send_in_flight(struct GNUNET_MQ_Handle *mq)
Call the send notification for the current message, but do not try to send the next message until #gn...
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.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT
Message from TRANSPORT notifying about a client that connected to us.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_START
Message from the core saying that the transport server should start giving it messages.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_RECV_OK
Message telling transport to limit its receive rate.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_RECV
Message from TRANSPORT notifying about a message that was received.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT
Message from TRANSPORT notifying about a client that disconnected from us.
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND
Request to TRANSPORT to transmit a message.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK
Confirmation from TRANSPORT that message for transmission has been queued (and that the next message ...
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA
Message telling transport to limit its receive rate.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
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.
#define GNUNET_TIME_UNIT_MINUTES
One minute.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
struct GNUNET_MQ_Handle * GNUNET_TRANSPORT_core_get_mq(struct GNUNET_TRANSPORT_CoreHandle *handle, const struct GNUNET_PeerIdentity *peer)
Checks if a given peer is connected to us and get the message queue.
void(* GNUNET_TRANSPORT_NotifyExcessBandwidth)(void *cls, const struct GNUNET_PeerIdentity *neighbour, void *handlers_cls)
Function called if we have "excess" bandwidth to a peer.
struct GNUNET_TRANSPORT_CoreHandle * GNUNET_TRANSPORT_core_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *self, const struct GNUNET_MQ_MessageHandler *handlers, void *cls, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd, GNUNET_TRANSPORT_NotifyExcessBandwidth neb)
Connect to the transport service.
static unsigned int size
Size of the "table".
static void disconnect(struct GNUNET_PEERSTORE_Handle *h)
Disconnect from the peerstore service.
Message from the transport service to the library informing about neighbors.
struct GNUNET_PeerIdentity id
Identity of the new neighbour.
struct GNUNET_BANDWIDTH_Value32NBO quota_out
Current outbound quota for this peer.
Message from the transport service to the library informing about disconnects.
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).
Struct to track available bandwidth.
uint32_t value__
The actual value (bytes per second).
struct GNUNET_MQ_Handle * mq
Message Queue for the channel (which we are implementing).
Internal representation of the hash map.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task to reconnect to the service.
A HELLO message is used to exchange information about transports with other peers.
Handle to a message queue.
Message handler for a specific message type.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Handle for the transport service (includes all of the state for the transport service).
int check_self
Should we check that self matches what the service thinks? (if GNUNET_NO, then self is all zeros!...
struct GNUNET_PeerIdentity self
Peer identity as assumed by this process, or all zeros.
const struct GNUNET_CONFIGURATION_Handle * cfg
My configuration.
struct GNUNET_CONTAINER_MultiPeerMap * neighbours
Hash map of the current connected neighbours of this peer.
void * cls
Closure for the callbacks.
GNUNET_TRANSPORT_NotifyDisconnect nd_cb
function to call on disconnect events
unsigned int rom_pending
Internal counter to check how many more receive OK messages this CORE service is allowed to send in t...
struct GNUNET_MQ_Handle * mq
My client connection to the transport service.
GNUNET_TRANSPORT_NotifyConnect nc_cb
function to call on connect events
struct GNUNET_TIME_Relative reconnect_delay
Delay until we try to reconnect.
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the task trying to reconnect to the service.
GNUNET_TRANSPORT_NotifyExcessBandwidth neb_cb
function to call on excess bandwidth events
struct GNUNET_MQ_MessageHandler * handlers
Functions to call for received data (template for new message queues).
Message used to notify the transport API about a message received from the network.
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV.
struct GNUNET_PeerIdentity peer
Which peer sent the message?
A connected controller which is not our child.
void * handlers_cls
Closure for mq handlers.
uint16_t env_size
Size of the message in env.
struct GNUNET_TRANSPORT_CoreHandle * h
Overall transport handle.
struct GNUNET_MQ_Envelope * env
Envelope with the message we are currently transmitting (or NULL).
struct GNUNET_MQ_Handle * mq
Active message queue for the peer.
struct GNUNET_CONTAINER_HeapNode * hn
Entry in our readiness heap (which is sorted by next_ready value).
struct GNUNET_BANDWIDTH_Tracker out_tracker
Outbound bandwidh tracker.
struct GNUNET_PeerIdentity id
Identity of this neighbour.
int is_ready
Is this peer currently ready to receive a message?
struct GNUNET_SCHEDULER_Task * timeout_task
Task to trigger MQ when we have enough bandwidth for the next transmission.
unsigned long long traffic_overhead
Sending consumed more bytes on wire than payload was announced This overhead is added to the delay of...
Message used to notify the transport service about a message to be transmitted to another peer.
uint32_t priority
An enum GNUNET_MQ_PriorityPreferences in NBO.
struct GNUNET_PeerIdentity peer
Which peer should receive the message?
struct GNUNET_TIME_RelativeNBO timeout
Allowed delay.
Message used to set a particular bandwidth quota.
struct GNUNET_BANDWIDTH_Value32NBO quota
Quota.
struct GNUNET_PeerIdentity peer
About which peer are we talking here?
Message used to notify the transport API that it can send another message to the transport service.
struct GNUNET_PeerIdentity peer
Which peer can CORE handle more from now?
uint32_t increase_window_delta
Number of messages by which to increase the window, greater or equal to one.
Message used to notify the transport API that it can send another message to the transport service.
uint16_t success
GNUNET_OK if the transmission succeeded, GNUNET_SYSERR if it failed (i.e.
uint16_t bytes_msg
Size of message sent.
uint32_t bytes_physical
Size of message sent over wire.
struct GNUNET_PeerIdentity peer
Which peer can send more now?
Message from the transport service to the library asking to check if both processes agree about this ...
uint32_t options
0: no options 1: The self field should be checked 2: this client is interested in payload traffic
struct GNUNET_PeerIdentity self
Identity we think we have.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
common internal definitions for transport service
static void handle_hello(void *cls, const struct GNUNET_MessageHeader *msg)
Function we use for handling incoming HELLO messages.
static int check_hello(void *cls, const struct GNUNET_MessageHeader *msg)
Function we use for checking incoming HELLO messages.
static int neighbour_delete(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries, for deleting state of a neighbour.
static void handle_connect(void *cls, const struct ConnectInfoMessage *cim)
Function we use for handling incoming connect messages.
static void peer_mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
We had an error processing a message we forwarded from a peer to the CORE service.
static void outbound_bw_tracker_update(void *cls)
The outbound quota has changed in a way that may require us to reset the timeout.
static void notify_send_done_fin(void *cls)
A message from the handler's message queue to a neighbour was transmitted.
static void handle_disconnect(void *cls, const struct DisconnectInfoMessage *dim)
Function we use for handling incoming disconnect messages.
static struct Neighbour * neighbour_find(struct GNUNET_TRANSPORT_CoreHandle *h, const struct GNUNET_PeerIdentity *peer)
Get the neighbour list entry for the given peer.
static void handle_send_ok(void *cls, const struct SendOkMessage *okm)
Function we use for handling incoming send-ok messages.
static int check_recv(void *cls, const struct InboundMessage *im)
Function we use for checking incoming "inbound" messages.
static void disconnect_and_schedule_reconnect(struct GNUNET_TRANSPORT_CoreHandle *h)
Function that will schedule the job that will try to connect us again to the client.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
static void reconnect(void *cls)
Try again to connect to transport service.
static void notify_send_done(void *cls)
A message from the handler's message queue to a neighbour was transmitted.
static void mq_destroy_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
Handle destruction of a message queue.
static void handle_set_quota(void *cls, const struct QuotaSetMessage *qm)
Function we use for handling incoming set quota messages.
#define STARTING_NEIGHBOURS_SIZE
How large to start with for the hashmap of neighbours.
static void mq_cancel_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
Implementation function that cancels the currently sent message.
static void notify_excess_cb(void *cls)
Function called by the bandwidth tracker if we have excess bandwidth.
static void handle_recv(void *cls, const struct InboundMessage *im)
Function we use for handling incoming messages.
static void mq_send_impl(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *msg, void *impl_state)
Implement sending functionality of a message queue.