GNUnet  0.10.x
gnunet_transport_plugin.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2009-2014 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 
36 #ifndef PLUGIN_TRANSPORT_H
37 #define PLUGIN_TRANSPORT_H
38 
40 #include "gnunet_scheduler_lib.h"
43 #include "gnunet_ats_service.h"
44 
45 #define TRANSPORT_SESSION_INBOUND_STRING "<inbound>"
46 
60 struct GNUNET_ATS_Session;
61 
62 
76 typedef void
78  const struct GNUNET_HELLO_Address *address,
79  struct GNUNET_ATS_Session *session);
80 
81 
90 typedef void
92  const struct GNUNET_HELLO_Address *address,
93  struct GNUNET_ATS_Session *session,
94  enum GNUNET_NetworkType net);
95 
96 
119 typedef struct GNUNET_TIME_Relative
121  const struct GNUNET_HELLO_Address *address,
122  struct GNUNET_ATS_Session *session,
123  const struct GNUNET_MessageHeader *message);
124 
125 
136 typedef enum GNUNET_NetworkType
138  const struct sockaddr *addr,
139  size_t addrlen);
140 
141 
149 typedef void
151  const struct GNUNET_HELLO_Address *address,
152  uint32_t distance);
153 
154 
164 typedef void
166  int add_remove,
167  const struct GNUNET_HELLO_Address *address);
168 
169 
186 typedef struct GNUNET_TIME_Relative
188  const struct GNUNET_PeerIdentity *peer,
189  size_t amount_recved);
190 
191 
197 typedef const struct GNUNET_MessageHeader *
198 (*GNUNET_TRANSPORT_GetHelloCallback) (void);
199 
200 
211 
216 
220  void *cls;
221 
226 
236 
241 
248 
254 
260 
266 
272 
278  uint32_t max_connections;
279 };
280 
281 
301 typedef void
303  const struct GNUNET_PeerIdentity *target,
304  int result,
305  size_t size_payload,
306  size_t size_on_wire);
307 
308 
338 typedef ssize_t
340  struct GNUNET_ATS_Session *session,
341  const char *msgbuf,
342  size_t msgbuf_size,
343  unsigned int priority,
344  struct GNUNET_TIME_Relative to,
346  void *cont_cls);
347 
348 
361 typedef int
363  struct GNUNET_ATS_Session *session);
364 
365 
374 typedef unsigned int
376 
377 
390 typedef void
392  const struct GNUNET_PeerIdentity *target);
393 
394 
409 typedef void
411  const char *address,
412  int res);
413 
414 
429 typedef void
431  const char *type,
432  const void *addr,
433  size_t addrlen,
434  int numeric,
437  void *asc_cls);
438 
439 
454 typedef int
456  const void *addr,
457  size_t addrlen);
458 
459 
469 typedef struct GNUNET_ATS_Session *
470 (*GNUNET_TRANSPORT_CreateSession) (void *cls,
471  const struct GNUNET_HELLO_Address *address);
472 
473 
483 typedef void
485  const struct GNUNET_PeerIdentity *peer,
486  struct GNUNET_ATS_Session *session);
487 
488 
499 typedef void
501  const struct GNUNET_PeerIdentity *peer,
502  struct GNUNET_ATS_Session *session,
503  struct GNUNET_TIME_Relative delay);
504 
505 
517 typedef const char *
518 (*GNUNET_TRANSPORT_AddressToString) (void *cls,
519  const void *addr,
520  size_t addrlen);
521 
522 
535 typedef int
537  const char *addr,
538  uint16_t addrlen,
539  void **buf,
540  size_t *added);
541 
542 
550 typedef enum GNUNET_NetworkType
552  struct GNUNET_ATS_Session *session);
553 
554 
562 typedef enum GNUNET_NetworkType
564  const struct GNUNET_HELLO_Address *address);
565 
566 
579 typedef void
581  struct GNUNET_ATS_Session *session,
582  const struct GNUNET_TRANSPORT_SessionInfo *info);
583 
584 
597 typedef void
600  void *sic_cls);
601 
602 
611  void *cls;
612 
621 
628 
635 
642 
649 
656 
661 
672 
678 
684 
690 
695 
700 
705 };
706 
707 
708 /*#ifndef PLUGIN_TRANSPORT_H*/
709 #endif
710  /* end of group */
712 
713 /* end of gnunet_transport_plugin.h */
void(* GNUNET_TRANSPORT_SessionEnd)(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session)
Function that will be called whenever the plugin internally cleans up a session pointer and hence the...
struct GNUNET_TIME_Relative(* GNUNET_TRANSPORT_TrafficReport)(void *cls, const struct GNUNET_PeerIdentity *peer, size_t amount_recved)
Function that will be called whenever the plugin receives data over the network and wants to determin...
GNUNET_TRANSPORT_CreateSession get_session
Function that will be called tell the plugin to create a session object.
GNUNET_TRANSPORT_AddressToString address_to_string
Function that will be called to convert a binary address to a string (numeric conversion only)...
void(* GNUNET_TRANSPORT_AddressNotification)(void *cls, int add_remove, const struct GNUNET_HELLO_Address *address)
Function that will be called for each address the transport is aware that it might be reachable under...
GNUNET_TRANSPORT_SessionStart session_start
Function called by the plugin when a new (incoming) session was created not explicitly created using ...
const struct GNUNET_MessageHeader *(* GNUNET_TRANSPORT_GetHelloCallback)(void)
Function that returns a HELLO message.
const char *(* GNUNET_TRANSPORT_AddressToString)(void *cls, const void *addr, size_t addrlen)
Function called for a quick conversion of the binary address to a numeric address.
void(* GNUNET_TRANSPORT_DisconnectPeerFunction)(void *cls, const struct GNUNET_PeerIdentity *target)
Function that can be called to force a disconnect from the specified neighbour.
GNUNET_TRANSPORT_TransmitFunction send
Function that the transport service will use to transmit data to another peer.
GNUNET_TRANSPORT_DisconnectPeerFunction disconnect_peer
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
enum GNUNET_NetworkType(* GNUNET_TRANSPORT_AddressToType)(void *cls, const struct sockaddr *addr, size_t addrlen)
Function that can be called by plugins to figure if an address is an loopback, LAN or WAN address...
GNUNET_TRANSPORT_AddressToType get_address_type
Function that will be called to figure if an address is an loopback, LAN, WAN etc.
unsigned int(* GNUNET_TRANSPORT_QueryKeepaliveFactorFunction)(void *cls)
Function that is called to get the keepalive factor.
GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
GNUNET_TRANSPORT_SessionMonitorSetup setup_monitor
Function to monitor the sessions managed by the plugin.
const struct GNUNET_PeerIdentity * my_identity
Identity of this peer.
static int numeric
Option -n.
struct GNUNET_ATS_Session *(* GNUNET_TRANSPORT_CreateSession)(void *cls, const struct GNUNET_HELLO_Address *address)
Create a new session to transmit data to the target This session will used to send data to this peer ...
uint32_t max_connections
What is the maximum number of connections that this transport should allow? Transports that do not ha...
Handle for the service.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Definition: gnunet_nt_lib.h:35
int(* GNUNET_TRANSPORT_StringToAddress)(void *cls, const char *addr, uint16_t addrlen, void **buf, size_t *added)
Function called to convert a string address to a binary address.
GNUNET_TRANSPORT_SessionEnd session_end
Function that must be called by the plugin when a non-NULL session handle stops being valid (is destr...
GNUNET_TRANSPORT_PluginReceiveCallback receive
Function that should be called by the transport plugin whenever a message is received.
GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout
Function that will be called whenever the transport service wants to notify the plugin that a session...
Information about a plugin&#39;s session.
void * cls
Closure for the various callbacks.
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:114
void * cls
Closure for all of the callbacks.
void(* GNUNET_TRANSPORT_AddressStringCallback)(void *cls, const char *address, int res)
Function called by the pretty printer for the resolved address for each human-readable address obtain...
GNUNET_TRANSPORT_GetHelloCallback get_our_hello
Function that returns our HELLO.
GNUNET_TRANSPORT_StringToAddress string_to_address
Function that will be called to convert a string address to binary (numeric conversion only)...
Information about ongoing sessions of the transport client.
int(* GNUNET_TRANSPORT_DisconnectSessionFunction)(void *cls, struct GNUNET_ATS_Session *session)
Function that can be called to force a disconnect from the specified neighbour for the given session ...
The transport service will pass a pointer to a struct of this type as the first and only argument to ...
void(* GNUNET_TRANSPORT_UpdateAddressDistance)(void *cls, const struct GNUNET_HELLO_Address *address, uint32_t distance)
Function called when distance of an address changes.
GNUNET_TRANSPORT_GetNetworkType get_network
Function to obtain the network type for a session.
static char buf[2048]
struct GNUNET_TIME_Relative(* GNUNET_TRANSPORT_PluginReceiveCallback)(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, const struct GNUNET_MessageHeader *message)
Function called by the transport for each received message.
void(* GNUNET_TRANSPORT_SessionInfoCallback)(void *cls, struct GNUNET_ATS_Session *session, const struct GNUNET_TRANSPORT_SessionInfo *info)
Function called by the plugin with information about the current sessions managed by the plugin (for ...
static int result
Global testing status.
GNUNET_TRANSPORT_UpdateInboundDelay update_inbound_delay
Function that will be called whenever the transport service wants to notify the plugin that the inbou...
void(* GNUNET_TRANSPORT_AddressPrettyPrinter)(void *cls, const char *type, const void *addr, size_t addrlen, int numeric, struct GNUNET_TIME_Relative timeout, GNUNET_TRANSPORT_AddressStringCallback asc, void *asc_cls)
Convert the transports address to a nice, human-readable format.
static int res
int(* GNUNET_TRANSPORT_CheckAddress)(void *cls, const void *addr, size_t addrlen)
Another peer has suggested an address for this peer and transport plugin.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
void(* GNUNET_TRANSPORT_TransmitContinuation)(void *cls, const struct GNUNET_PeerIdentity *target, int result, size_t size_payload, size_t size_on_wire)
Function called by the GNUNET_TRANSPORT_TransmitFunction upon "completion".
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
GNUNET_TRANSPORT_UpdateAddressDistance update_address_distance
Function that will be called by DV to update distance for an address.
enum GNUNET_NetworkType(* GNUNET_TRANSPORT_GetNetworkTypeForAddress)(void *cls, const struct GNUNET_HELLO_Address *address)
Function to obtain the network type for an address.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
ssize_t(* GNUNET_TRANSPORT_TransmitFunction)(void *cls, struct GNUNET_ATS_Session *session, const char *msgbuf, size_t msgbuf_size, unsigned int priority, struct GNUNET_TIME_Relative to, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
The new send function with just the session and no address.
void(* GNUNET_TRANSPORT_UpdateSessionTimeout)(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_ATS_Session *session)
Function that will be called whenever the transport service wants to notify the plugin that a session...
GNUNET_TRANSPORT_QueryKeepaliveFactorFunction query_keepalive_factor
Function that is used to query keepalive factor.
The identity of the host (wraps the signing key of the peer).
void(* GNUNET_TRANSPORT_SessionMonitorSetup)(void *cls, GNUNET_TRANSPORT_SessionInfoCallback sic, void *sic_cls)
Begin monitoring sessions of a plugin.
configuration data
Definition: configuration.c:83
An address for communicating with a peer.
struct GNUNET_STATISTICS_Handle * stats
Handle for reporting statistics.
Automatic transport selection and outbound bandwidth determination.
void(* GNUNET_TRANSPORT_UpdateInboundDelay)(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_ATS_Session *session, struct GNUNET_TIME_Relative delay)
Function that will be called whenever the transport service wants to notify the plugin that the inbou...
GNUNET_TRANSPORT_AddressNotification notify_address
Function that must be called by each plugin to notify the transport service about the addresses under...
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
GNUNET_TRANSPORT_AddressPrettyPrinter address_pretty_printer
Function to pretty-print addresses.
Header for all communications.
void(* GNUNET_TRANSPORT_SessionStart)(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, enum GNUNET_NetworkType net)
Plugin tells transport service about a new inbound session.
GNUNET_TRANSPORT_CheckAddress check_address
Function that will be called to check if a binary address for this plugin is well-formed and correspo...
static char * address
GNS address for this phone.
enum GNUNET_NetworkType(* GNUNET_TRANSPORT_GetNetworkType)(void *cls, struct GNUNET_ATS_Session *session)
Function to obtain the network type for a session.
Time for relative time used by GNUnet, in microseconds.
GNUNET_TRANSPORT_GetNetworkTypeForAddress get_network_for_address
Function to obtain the network type for an address.