32 #include "gnunet_signatures.h"
38 #define LOG(kind, ...) GNUNET_log_from (kind, "transport-tcp", __VA_ARGS__)
40 #define PLUGIN_NAME "tcp"
46 #define NAT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
158 const struct sockaddr *addr,
176 const struct sockaddr *addr,
199 typedef void *(*GNUNET_SERVER_MstCreateCallback) (
377 void *client_identity,
413 #define GNUNET_SERVER_client_get_user_context(client, type) \
414 (type *) GNUNET_SERVER_client_get_user_context_ (client, sizeof(type))
422 #define GNUNET_SERVER_client_set_user_context(client, value) \
423 GNUNET_SERVER_client_set_user_context_ (client, value, sizeof(*value))
1055 struct sockaddr ***addrs,
1056 socklen_t **addr_lens)
1060 unsigned long long port;
1062 struct addrinfo hints;
1063 struct addrinfo *
res;
1064 struct addrinfo *pos;
1065 struct addrinfo *next;
1070 struct sockaddr **saddrs;
1071 socklen_t *saddrlens;
1094 if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) ||
1102 "Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
1123 _ (
"Require valid port number for service `%s' in configuration!\n"),
1129 _ (
"Require valid port number for service `%s' in configuration!\n"),
1155 (0 < strlen (unixpath)))
1158 struct sockaddr_un s_un;
1160 if (strlen (unixpath) >=
sizeof(s_un.sun_path))
1163 _ (
"UNIXPATH `%s' too long, maximum length is %llu\n"),
1165 (
unsigned long long)
sizeof(s_un.sun_path));
1172 "USE_ABSTRACT_SOCKETS");
1180 if (NULL != unixpath)
1185 if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) ||
1195 "Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"),
1209 if ((0 ==
port) && (NULL == unixpath))
1213 "Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
1226 *addr_lens = saddrlens;
1233 "Resolving `%s' since that is where `%s' will bind to.\n",
1236 memset (&hints, 0,
sizeof(
struct addrinfo));
1238 hints.ai_family = AF_INET;
1239 hints.ai_protocol = IPPROTO_TCP;
1244 _ (
"Failed to resolve `%s': %s\n"),
1246 gai_strerror (
ret));
1253 while (NULL != (pos = next))
1255 next = pos->ai_next;
1256 if ((disablev6) && (pos->ai_family == AF_INET6))
1263 _ (
"Failed to find %saddress for `%s'.\n"),
1264 disablev6 ?
"IPv4 " :
"",
1272 if (NULL != unixpath)
1274 saddrs =
GNUNET_malloc ((resi + 1) *
sizeof(
struct sockaddr *));
1277 if (NULL != unixpath)
1283 while (NULL != (pos = next))
1285 next = pos->ai_next;
1286 if ((disablev6) && (AF_INET6 == pos->ai_family))
1288 if ((IPPROTO_TCP != pos->ai_protocol) && (0 != pos->ai_protocol))
1290 if ((SOCK_STREAM != pos->ai_socktype) && (0 != pos->ai_socktype))
1293 "Service `%s' will bind to `%s'\n",
1296 if (AF_INET == pos->ai_family)
1298 GNUNET_assert (
sizeof(
struct sockaddr_in) == pos->ai_addrlen);
1299 saddrlens[i] = pos->ai_addrlen;
1302 ((
struct sockaddr_in *) saddrs[i])->sin_port = htons (
port);
1307 GNUNET_assert (
sizeof(
struct sockaddr_in6) == pos->ai_addrlen);
1308 saddrlens[i] = pos->ai_addrlen;
1311 ((
struct sockaddr_in6 *) saddrs[i])->sin6_port = htons (
port);
1326 if (NULL != unixpath)
1329 saddrs =
GNUNET_malloc ((resi + 1) *
sizeof(
struct sockaddr *));
1331 if (NULL != unixpath)
1336 saddrlens[i] =
sizeof(
struct sockaddr_in);
1338 #if HAVE_SOCKADDR_IN_SIN_LEN
1339 ((
struct sockaddr_in *) saddrs[i])->sin_len = saddrlens[i];
1341 ((
struct sockaddr_in *) saddrs[i])->sin_family = AF_INET;
1342 ((
struct sockaddr_in *) saddrs[i])->sin_port = htons (
port);
1348 if (NULL != unixpath)
1350 saddrs =
GNUNET_malloc ((resi + 1) *
sizeof(
struct sockaddr *));
1353 if (NULL != unixpath)
1358 saddrlens[i] =
sizeof(
struct sockaddr_in6);
1360 #if HAVE_SOCKADDR_IN_SIN_LEN
1361 ((
struct sockaddr_in6 *) saddrs[i])->sin6_len = saddrlens[0];
1363 ((
struct sockaddr_in6 *) saddrs[i])->sin6_family = AF_INET6;
1364 ((
struct sockaddr_in6 *) saddrs[i])->sin6_port = htons (
port);
1366 saddrlens[i] =
sizeof(
struct sockaddr_in);
1368 #if HAVE_SOCKADDR_IN_SIN_LEN
1369 ((
struct sockaddr_in *) saddrs[i])->sin_len = saddrlens[1];
1371 ((
struct sockaddr_in *) saddrs[i])->sin_family = AF_INET;
1372 ((
struct sockaddr_in *) saddrs[i])->sin_port = htons (
port);
1377 *addr_lens = saddrlens;
1434 const struct sockaddr *addr,
1446 "NAT notification to %s address `%s'\n",
1447 (
GNUNET_YES == add_remove) ?
"add" :
"remove",
1450 switch (addr->sa_family)
1454 memset (&
t4, 0,
sizeof(
t4));
1455 t4.options = htonl (
plugin->myoptions);
1456 t4.ipv4_addr = ((
struct sockaddr_in *) addr)->sin_addr.s_addr;
1457 t4.t4_port = ((
struct sockaddr_in *) addr)->sin_port;
1463 if (IN6_IS_ADDR_LINKLOCAL (&((
struct sockaddr_in6 *) addr)->sin6_addr))
1470 memset (&
t6, 0,
sizeof(
t6));
1472 &((
struct sockaddr_in6 *) addr)->sin6_addr,
1473 sizeof(
struct in6_addr));
1474 t6.options = htonl (
plugin->myoptions);
1475 t6.t6_port = ((
struct sockaddr_in6 *) addr)->sin6_port;
1512 static char rbuf[INET6_ADDRSTRLEN + 12];
1513 char buf[INET6_ADDRSTRLEN];
1534 case sizeof(struct IPv4TcpAddress):
1537 port = ntohs (t4->t4_port);
1544 LOG (GNUNET_ERROR_TYPE_WARNING,
1545 _ ("Unexpected address length: %u bytes\n"),
1546 (unsigned int) addrlen);
1549 if (NULL == inet_ntop (af, sb, buf, INET6_ADDRSTRLEN))
1556 (af == AF_INET6) ?
"%s.%u.[%s]:%u" :
"%s.%u.%s:%u",
1584 struct sockaddr_storage socket_address;
1594 if ((NULL == addr) || (0 == addrlen))
1599 if (
'\0' != addr[addrlen - 1])
1604 if (strlen (addr) != addrlen - 1)
1610 optionstr = strchr (
plugin,
'.');
1611 if (NULL == optionstr)
1617 optionstr[0] =
'\0';
1620 address = strchr (optionstr,
'.');
1639 switch (socket_address.ss_family)
1643 struct sockaddr_in *in4 = (
struct sockaddr_in *) &socket_address;
1646 t4->ipv4_addr = in4->sin_addr.s_addr;
1647 t4->t4_port = in4->sin_port;
1655 struct sockaddr_in6 *in6 = (
struct sockaddr_in6 *) &socket_address;
1658 t6->ipv6_addr = in6->sin6_addr;
1659 t6->t6_port = in6->sin6_port;
1706 "Disconnecting session of peer `%s' address `%s'\n",
1735 if (NULL != session->
client)
1757 (NULL !=
pm->transmit_cont)
1758 ?
"Could not deliver message to `%s' at %s.\n"
1759 :
"Could not deliver message to `%s' at %s, notifying.\n",
1766 -(int64_t)
pm->message_size,
1770 "# bytes discarded by TCP (disconnect)"),
1780 if (NULL !=
pm->transmit_cont)
1781 pm->transmit_cont (
pm->transmit_cont_cls,
1797 if (NULL != session->
client)
1846 "Session %p was idle for %s, disconnecting\n",
1898 "Creating new session for peer `%s' at address %s\n",
1906 session->
is_nat = is_nat;
1918 pm->msg = (
const char *) &
pm[1];
1995 "Timeout trying to transmit to peer `%s', discarding message queue.\n",
2013 "Failed to transmit %lu byte message to `%s'.\n",
2026 while (NULL != (pos = hd))
2043 "# bytes discarded by TCP (timeout)"),
2070 "Transmitting message of type %u size %lu to peer %s at %s\n",
2093 while (NULL != (pos = hd))
2177 unsigned int priority,
2187 pm->msg = (
const char *) &
pm[1];
2189 pm->message_size = msgbuf_size;
2191 pm->transmit_cont = cont;
2192 pm->transmit_cont_cls = cont_cls;
2195 "Asked to transmit %lu bytes to `%s', added message to list.\n",
2196 (
unsigned long) msgbuf_size,
2230 "This NAT WAIT session for peer `%s' is not yet ready!\n",
2291 si_ctx->
result = session;
2308 "NAT WAIT connection to `%4s' at `%s' could not be established, removing session\n",
2371 "New inbound delay %s\n",
2398 struct sockaddr_in a4;
2399 struct sockaddr_in6 a6;
2413 "Trying to get session for `%s' address of peer `%s'\n",
2438 if (NULL != si_ctx.
result)
2442 "Found existing session for `%s' address `%s'\n",
2463 memset (&a6, 0,
sizeof(a6));
2464 #if HAVE_SOCKADDR_IN_SIN_LEN
2465 a6.sin6_len =
sizeof(a6);
2467 a6.sin6_family = AF_INET6;
2468 a6.sin6_port =
t6->t6_port;
2469 if (
t6->t6_port == 0)
2471 GNUNET_memcpy (&a6.sin6_addr, &
t6->ipv6_addr,
sizeof(
struct in6_addr));
2481 memset (&a4, 0,
sizeof(a4));
2482 #if HAVE_SOCKADDR_IN_SIN_LEN
2483 a4.sin_len =
sizeof(a4);
2485 a4.sin_family = AF_INET;
2486 a4.sin_port =
t4->t4_port;
2487 if (
t4->t4_port == 0)
2489 a4.sin_addr.s_addr =
t4->ipv4_addr;
2497 gettext_noop (
"# requests to create session with invalid address"),
2503 net_type =
plugin->env->get_address_type (
plugin->env->cls, sb, sbs);
2512 if (
plugin->cur_connections >=
plugin->max_connections)
2532 struct sockaddr_in local_sa;
2535 "Found valid IPv4 NAT address (creating session)!\n");
2547 "Created NAT WAIT connection to `%s' at `%s'\n",
2550 memset (&local_sa, 0,
sizeof(local_sa));
2551 local_sa.sin_family = AF_INET;
2552 local_sa.sin_port = htons (
plugin->open_port);
2559 "Running NAT client for `%s' at `%s' failed\n",
2589 TCP_STEALTH_INTEGRITY,
2613 "Failed to create connection to `%s' at `%s'\n",
2619 "Asked to transmit to `%s', creating fresh session using address `%s'.\n",
2660 "# transport-service disconnect requests for TCP"),
2690 "Disconnecting peer `%s'\n",
2721 "append_port called with hostname `%s'\n",
2780 struct sockaddr_in a4;
2781 struct sockaddr_in6 a6;
2790 memset (&a6, 0,
sizeof(a6));
2791 a6.sin6_family = AF_INET6;
2792 a6.sin6_port =
t6->t6_port;
2793 GNUNET_memcpy (&a6.sin6_addr, &
t6->ipv6_addr,
sizeof(
struct in6_addr));
2794 port = ntohs (
t6->t6_port);
2802 memset (&a4, 0,
sizeof(a4));
2803 a4.sin_family = AF_INET;
2804 a4.sin_port =
t4->t4_port;
2805 a4.sin_addr.s_addr =
t4->ipv4_addr;
2806 port = ntohs (
t4->t4_port);
2815 _ (
"Unexpected address length: %u bytes\n"),
2816 (
unsigned int) addrlen);
2879 struct sockaddr_in s4;
2882 if (0 != memcmp (&v4->options, &
plugin->myoptions,
sizeof(uint32_t)))
2887 memset (&s4, 0,
sizeof(s4));
2888 s4.sin_family = AF_INET;
2889 #if HAVE_SOCKADDR_IN_SIN_LEN
2890 s4.sin_len =
sizeof(s4);
2892 s4.sin_port = v4->t4_port;
2893 s4.sin_addr.s_addr = v4->ipv4_addr;
2901 struct sockaddr_in6 s6;
2904 if (IN6_IS_ADDR_LINKLOCAL (&v6->ipv6_addr))
2909 if (0 != memcmp (&v6->options, &
plugin->myoptions,
sizeof(uint32_t)))
2914 memset (&s6, 0,
sizeof(s6));
2915 s6.sin6_family = AF_INET6;
2916 #if HAVE_SOCKADDR_IN_SIN_LEN
2917 s6.sin6_len =
sizeof(s6);
2919 s6.sin6_port = v6->t6_port;
2920 s6.sin6_addr = v6->ipv6_addr;
2924 sizeof(
struct sockaddr_in6)))
2952 const struct sockaddr_in *s4;
2953 const struct sockaddr_in6 *s6;
2970 plugin->env->my_identity,
2980 if (NULL == session)
3014 "Found address `%s' for incoming connection\n",
3016 switch (((
const struct sockaddr *) vaddr)->sa_family)
3022 t4->t4_port = s4->sin_port;
3023 t4->ipv4_addr = s4->sin_addr.s_addr;
3036 t6->t6_port = s6->sin6_port;
3037 GNUNET_memcpy (&
t6->ipv6_addr, &s6->sin6_addr,
sizeof(
struct in6_addr));
3056 session->
client = client;
3087 const struct sockaddr_in *s4;
3088 const struct sockaddr_in6 *s6;
3091 plugin->env->my_identity,
3098 "Received WELCOME message from my own identity `%s' on address `%s'\n",
3110 "Received WELCOME message from `%s' on address `%s'\n",
3120 if (NULL != session)
3125 "Found existing session %p for peer `%s'\n",
3135 if (alen ==
sizeof(
struct sockaddr_in))
3138 memset (&
t4,
'\0',
sizeof(
t4));
3140 t4.t4_port = s4->sin_port;
3141 t4.ipv4_addr = s4->sin_addr.s_addr;
3149 else if (alen ==
sizeof(
struct sockaddr_in6))
3152 memset (&
t6,
'\0',
sizeof(
t6));
3154 t6.t6_port = s6->sin6_port;
3155 GNUNET_memcpy (&
t6.ipv6_addr, &s6->sin6_addr,
sizeof(
struct in6_addr));
3180 "Creating new%s session %p for peer `%s' client %p\n",
3205 "Did not obtain TCP socket address for incoming connection\n");
3255 if (NULL == session)
3264 "Received unexpected %u bytes of type %u from `%s'\n",
3265 (
unsigned int) ntohs (message->
size),
3266 (
unsigned int) ntohs (message->
type),
3281 "Received unexpected %u bytes of type %u from `%s'\n",
3282 (
unsigned int) ntohs (message->
size),
3283 (
unsigned int) ntohs (message->
type),
3298 "Passing %u bytes of type %u from `%s' at %s to transport service.\n",
3299 (
unsigned int) ntohs (message->
size),
3300 (
unsigned int) ntohs (message->
type),
3308 ntohs (message->
size),
3325 "Throttling receiving from `%s' for %s\n",
3351 plugin->cur_connections++;
3360 if (
plugin->cur_connections !=
plugin->max_connections)
3363 _ (
"TCP connection limit reached, suspending server\n"));
3390 plugin->cur_connections--;
3392 if (NULL == session)
3395 "Destroying session of `%s' with %s due to network-level disconnect.\n",
3401 if (
plugin->cur_connections ==
plugin->max_connections)
3415 "# network-level TCP disconnect events"),
3450 tcp_probe_ctx->
sock);
3468 const struct sockaddr *addr,
3517 return session->
scope;
3534 struct sockaddr_in a4;
3535 struct sockaddr_in6 a6;
3541 addrlen =
address->address_length;
3546 memset (&a6, 0,
sizeof(a6));
3547 #if HAVE_SOCKADDR_IN_SIN_LEN
3548 a6.sin6_len =
sizeof(a6);
3550 a6.sin6_family = AF_INET6;
3551 a6.sin6_port =
t6->t6_port;
3552 GNUNET_memcpy (&a6.sin6_addr, &
t6->ipv6_addr,
sizeof(
struct in6_addr));
3560 memset (&a4, 0,
sizeof(a4));
3561 #if HAVE_SOCKADDR_IN_SIN_LEN
3562 a4.sin_len =
sizeof(a4);
3564 a4.sin_family = AF_INET;
3565 a4.sin_port =
t4->t4_port;
3566 a4.sin_addr.s_addr =
t4->ipv4_addr;
3575 return plugin->env->get_address_type (
plugin->env->cls, sb, sbs);
3655 { NULL, NULL, 0, 0 } };
3660 unsigned long long aport;
3661 unsigned long long bport;
3671 struct sockaddr **addrs;
3672 socklen_t *addrlens;
3674 if (NULL ==
env->receive)
3706 _ (
"Require valid port number for service `%s' in configuration!\n"),
3733 plugin->open_port = bport;
3734 plugin->adv_port = aport;
3737 plugin->my_welcome.header.type =
3739 plugin->my_welcome.clientIdentity = *
plugin->env->my_identity;
3753 for (i = 0; NULL != lsocks[i]; i++)
3766 TCP_STEALTH_INTEGRITY_LEN,
3773 _ (
"TCP_STEALTH not supported on this platform.\n"));
3780 _ (
"TCP_STEALTH not supported on this platform.\n"));
3792 "Binding to address `%s'\n",
3797 (
unsigned int) ret_s,
3798 (
const struct sockaddr **) addrs,
3873 _ (
"TCP transport listening on port %llu\n"),
3877 _ (
"TCP transport not listening on any port (client only)\n"));
3878 if ((aport != bport) && (0 != bport))
3880 _ (
"TCP transport advertises itself as being on port %llu\n"),
3932 for (cur =
plugin->ppc_dll_head; NULL != cur; cur =
next)
3943 if (NULL !=
plugin->service)
3950 while (NULL != (tcp_probe =
plugin->probe_head))
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MQ_Envelope * env
#define gettext_noop(String)
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static int ret
Return value of the commandline.
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
static uint16_t port
Port number.
struct TestcasePlugin * plugin
The process handle to the testbed service.
static char * address
GNS address for this phone.
static unsigned long long max_connections
If there are at least this many connections, old ones will be removed.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_SCHEDULER_Task * t4
Task for IPv4 socket.
static struct GNUNET_SCHEDULER_Task * t6
Task for IPv6 socket.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static char * value
Value of the record to add/remove.
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
enum State state
current state of profiling
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
static void add_unixpath(struct sockaddr **saddrs, socklen_t *saddrlens, const char *unixpath, int abstract)
Add the given UNIX domain path as an address to the list (as the first entry).
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static char * hostname
Our hostname; we give this to all the peers we start.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static int numeric
Option -n.
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
static char * service_name
Option -s: service name (hash to get service descriptor)
Helper library for handling HELLOs.
Constants for network protocols.
Functions related to doing DNS lookups.
API to create, modify and access statistics.
Transport service plugin API.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
#define GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
After how long do we consider a connection to a peer dead if we don't receive messages from the peer?
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element)
Insert an element into a DLL after the given other element.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_contains(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Check if the map contains any value under the given key (including values that are NULL).
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_contains_value(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Check if the map contains the given value under the given key.
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_get_multiple(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular 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_MULTIPLE
Allow multiple values with the same key.
@ 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...
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_allocate(const struct GNUNET_PeerIdentity *peer, const char *transport_name, const void *address, size_t address_length, enum GNUNET_HELLO_AddressInfo local_info)
Allocate an address struct.
#define GNUNET_HELLO_address_free(addr)
Free an address.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
int GNUNET_HELLO_address_check_option(const struct GNUNET_HELLO_Address *address, enum GNUNET_HELLO_AddressInfo option)
Check if an address has a local option set.
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
@ GNUNET_HELLO_ADDRESS_INFO_INBOUND
This is an inbound address and cannot be used to initiate an outbound connection to another peer.
@ GNUNET_HELLO_ADDRESS_INFO_NONE
No additional information.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define GNUNET_log(kind,...)
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_PACKED
gcc-ism to get packed structs.
#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.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
const char * GNUNET_a2s(const struct sockaddr *addr, socklen_t addrlen)
Convert a "struct sockaddr*" (IPv4 or IPv6 address) to a string (for printing debug messages).
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
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.
int GNUNET_NAT_request_reversal(struct GNUNET_NAT_Handle *nh, const struct sockaddr_in *local_sa, const struct sockaddr_in *remote_sa)
We learned about a peer (possibly behind NAT) so run the gnunet-nat-client to send dummy ICMP respons...
void GNUNET_NAT_unregister(struct GNUNET_NAT_Handle *nh)
Stop port redirection and public IP address detection for the given handle.
GNUNET_NAT_AddressClass
Some addresses contain sensitive information or are not suitable for global distribution.
struct GNUNET_NAT_Handle * GNUNET_NAT_register(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *config_section, uint8_t proto, unsigned int num_addrs, const struct sockaddr **addrs, const socklen_t *addrlens, GNUNET_NAT_AddressCallback address_callback, GNUNET_NAT_ReversalCallback reversal_callback, void *callback_cls)
Attempt to enable port redirection and detect public IP address contacting UPnP or NAT-PMP routers on...
int GNUNET_NAT_test_address(struct GNUNET_NAT_Handle *nh, const void *addr, socklen_t addrlen)
Test if the given address is (currently) a plausible IP address for this peer.
enum GNUNET_GenericReturnValue GNUNET_NETWORK_socket_close(struct GNUNET_NETWORK_Handle *desc)
Close a socket.
struct GNUNET_NETWORK_Handle * GNUNET_NETWORK_socket_create(int domain, int type, int protocol)
Create a new socket.
char * GNUNET_NETWORK_shorten_unixpath(char *unixpath)
Given a unixpath that is too long (larger than UNIX_PATH_MAX), shorten it to an acceptable length whi...
int GNUNET_NETWORK_socket_setsockopt(struct GNUNET_NETWORK_Handle *fd, int level, int option_name, const void *option_value, socklen_t option_len)
Set socket option.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
@ GNUNET_NT_UNSPECIFIED
Category of last resort.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE
TCP NAT probe message, send from NAT'd peer to other peer to establish bi-directional communication.
#define GNUNET_MESSAGE_TYPE_ALL
Type used to match 'all' message types.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME
Welcome message between TCP transports.
void GNUNET_RESOLVER_request_cancel(struct GNUNET_RESOLVER_RequestHandle *rh)
Cancel a request that is still pending with the resolver.
struct GNUNET_RESOLVER_RequestHandle * GNUNET_RESOLVER_hostname_get(const struct sockaddr *sa, socklen_t salen, int do_resolve, struct GNUNET_TIME_Relative timeout, GNUNET_RESOLVER_HostnameCallback callback, void *cls)
Perform a reverse DNS lookup.
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.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_to_address_ip(const char *addr, uint16_t addrlen, struct sockaddr_storage *r_buf)
Tries to convert addr string to an IP (v4 or v6) address.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
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?
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_UNIT_ZERO_ABS
Absolute time zero.
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_UNIT_FOREVER_ABS
Constant used to specify "forever".
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 ...
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".
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_SessionState
Possible states of a session in a plugin.
@ GNUNET_TRANSPORT_SS_INIT
The session was created (first call for each session object).
@ GNUNET_TRANSPORT_SS_HANDSHAKE
Initial session handshake is in progress.
@ GNUNET_TRANSPORT_SS_DONE
Session is being torn down and about to disappear.
@ GNUNET_TRANSPORT_SS_UP
Session is fully UP.
@ GNUNET_TRANSPORT_SS_UPDATE
This is just an update about the session, the state did not change.
static unsigned int size
Size of the "table".
int(* GNUNET_SERVER_MessageTokenizerCallback)(void *cls, void *client, const struct GNUNET_MessageHeader *message)
Functions with this signature are called whenever a complete message is received by the tokenizer.
void GNUNET_SERVER_client_set_user_context_(struct GNUNET_SERVER_Client *client, void *ptr, size_t size)
Set user context to be associated with the given client.
static void handle_tcp_data(void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message)
We've received data for this peer via TCP.
static const char * tcp_plugin_address_to_string(void *cls, const void *addr, size_t addrlen)
Function called for a quick conversion of the binary address to a numeric address.
int GNUNET_SERVER_mst_receive(struct GNUNET_SERVER_MessageStreamTokenizer *mst, void *client_identity, const char *buf, size_t size, int purge, int one_shot)
Add incoming data to the receive buffer and call the callback for all complete messages.
void * libgnunet_plugin_transport_tcp_init(void *cls)
Entry point for the plugin.
TcpAddressOptions
Bits in the options field of TCP addresses.
@ TCP_OPTIONS_NONE
No bits set.
@ TCP_OPTIONS_TCP_STEALTH
Enable TCP Stealth-style port knocking.
@ TCP_OPTIONS_RESERVED
See HTTP_OPTIONS_VERIFY_CERTIFICATE.
static struct GNUNET_ATS_Session * lookup_session_by_client(struct Plugin *plugin, struct GNUNET_SERVER_Client *client)
Find the session handle for the given client.
static int tcp_plugin_disconnect_session(void *cls, struct GNUNET_ATS_Session *session)
Functions with this signature are called whenever we need to close a session due to a disconnect or f...
static void handle_tcp_nat_probe(void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message)
We've received a nat probe from this peer via TCP.
static void tcp_nat_port_map_callback(void *cls, void **app_ctx, int add_remove, enum GNUNET_NAT_AddressClass ac, const struct sockaddr *addr, socklen_t addrlen)
Our external IP address/port mapping has changed.
void GNUNET_SERVER_client_keep(struct GNUNET_SERVER_Client *client)
Notify the server that the given client handle should be kept (keeps the connection up if possible,...
struct GNUNET_SERVER_MessageStreamTokenizer * GNUNET_SERVER_mst_create(GNUNET_SERVER_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
void GNUNET_SERVER_client_drop(struct GNUNET_SERVER_Client *client)
Notify the server that the given client handle is no longer required.
#define GNUNET_SERVER_client_get_user_context(client, type)
Return user context associated with the given client.
static void session_timeout(void *cls)
Session was idle for too long, so disconnect it.
void(* LEGACY_SERVICE_Main)(void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg)
Function called by the service's run method to run service-specific setup code.
static void handle_tcp_welcome(void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message)
We've received a welcome from this peer via TCP.
void(* GNUNET_SERVER_MstDestroyCallback)(void *cls, void *mst)
Signature of a function to destroy a custom tokenizer.
static int tcp_plugin_check_address(void *cls, const void *addr, size_t addrlen)
Function that will be called to check if a binary address for this plugin is well-formed and correspo...
static void tcp_plugin_update_session_timeout(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...
static void try_connection_reversal(void *cls, const struct sockaddr *addr, socklen_t addrlen)
Function called by the NAT subsystem suggesting another peer wants to connect to us via connection re...
static struct GNUNET_ATS_Session * tcp_plugin_get_session(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 ...
static void tcp_plugin_setup_monitor(void *cls, GNUNET_TRANSPORT_SessionInfoCallback sic, void *sic_cls)
Begin monitoring sessions of a plugin.
static ssize_t tcp_plugin_send(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)
Function that can be used by the transport service to transmit a message using the plugin.
static void delayed_done(void *cls)
Task to signal the server that we can continue receiving from the TCP client now.
#define NAT_TIMEOUT
How long until we give up on establishing an NAT connection? Must be > 4 RTT.
void GNUNET_SERVER_destroy(struct GNUNET_SERVER_Handle *server)
Free resources held by this server.
static unsigned int tcp_plugin_query_keepalive_factor(void *cls)
Function that is called to get the keepalive factor.
void * GNUNET_SERVER_client_get_user_context_(struct GNUNET_SERVER_Client *client, size_t size)
Return user context associated with the given client.
static void tcp_plugin_disconnect(void *cls, const struct GNUNET_PeerIdentity *target)
Function that can be called to force a disconnect from the specified neighbour.
void(* GNUNET_SERVER_DisconnectCallback)(void *cls, struct GNUNET_SERVER_Client *client)
Functions with this signature are called whenever a client is disconnected on the network level.
struct GNUNET_SERVER_Client * GNUNET_SERVER_connect_socket(struct GNUNET_SERVER_Handle *server, struct GNUNET_CONNECTION_Handle *connection)
Add a TCP socket-based connection to the set of handles managed by this server.
static enum GNUNET_NetworkType tcp_plugin_get_network_for_address(void *cls, const struct GNUNET_HELLO_Address *address)
Function obtain the network type for an address.
void GNUNET_SERVER_mst_destroy(struct GNUNET_SERVER_MessageStreamTokenizer *mst)
Destroys a tokenizer.
static size_t notify_send_probe(void *cls, size_t size, void *buf)
We can now send a probe message, copy into buffer to really send.
size_t(* GNUNET_CONNECTION_TransmitReadyNotify)(void *cls, size_t size, void *buf)
Function called to notify a client about the connection begin ready to queue more data.
static int session_disconnect_it(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
We have been asked to destroy all connections to a particular peer.
static void nat_connect_timeout(void *cls)
Task cleaning up a NAT connection attempt after timeout.
void(* GNUNET_SERVER_ConnectCallback)(void *cls, struct GNUNET_SERVER_Client *client)
Functions with this signature are called whenever a client is connected on the network level.
static int get_server_addresses(const char *service_name, const struct GNUNET_CONFIGURATION_Handle *cfg, struct sockaddr ***addrs, socklen_t **addr_lens)
Get the list of addresses that a server for the given service should bind to.
static int tcp_plugin_string_to_address(void *cls, const char *addr, uint16_t addrlen, void **buf, size_t *added)
Function called to convert a string address to a binary address.
static struct GNUNET_ATS_Session * create_session(struct Plugin *plugin, const struct GNUNET_HELLO_Address *address, enum GNUNET_NetworkType scope, struct GNUNET_SERVER_Client *client, int is_nat)
Create a new session.
static void reschedule_session_timeout(struct GNUNET_ATS_Session *s)
Increment session timeout due to activity.
LEGACY_SERVICE_Options
Options for the service (bitmask).
@ LEGACY_SERVICE_OPTION_NONE
Use defaults.
@ LEGACY_SERVICE_OPTION_SOFT_SHUTDOWN
Trigger a SOFT server shutdown on signals, allowing active non-monitor clients to complete their tran...
@ LEGACY_SERVICE_OPTION_MANUAL_SHUTDOWN
Do not trigger server shutdown on signal at all; instead, allow for the user to terminate the server ...
void(* GNUNET_CONNECTION_Receiver)(void *cls, const void *buf, size_t available, const struct sockaddr *addr, socklen_t addrlen, int errCode)
Callback function for data received from the network.
static int session_lookup_it(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Look for a session by address.
static void append_port(void *cls, const char *hostname)
We are processing an address pretty printing request and finished the IP resolution (if applicable).
static void tcp_plugin_update_inbound_delay(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...
int(* GNUNET_SERVER_MstReceiveCallback)(void *cls, void *mst, struct GNUNET_SERVER_Client *client, const char *buf, size_t size, int purge, int one_shot)
Signature of a function to receive data for a custom tokenizer.
int(* GNUNET_CONNECTION_AccessCheck)(void *cls, const struct GNUNET_CONNECTION_Credentials *ucred, const struct sockaddr *addr, socklen_t addrlen)
Function to call for access control checks.
void GNUNET_CONNECTION_destroy(struct GNUNET_CONNECTION_Handle *connection)
Close the connection and free associated resources.
#define GNUNET_SERVER_client_set_user_context(client, value)
Set user context to be associated with the given client.
void GNUNET_SERVER_suspend(struct GNUNET_SERVER_Handle *server)
Suspend accepting connections from the listen socket temporarily.
void LEGACY_SERVICE_stop(struct LEGACY_SERVICE_Context *srv)
Stops a service that was started with GNUNET_SERVICE_start().
static size_t do_transmit(void *cls, size_t size, void *buf)
Function called to notify a client about the socket being ready to queue more data.
void(* GNUNET_SERVER_MessageCallback)(void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message)
Functions with this signature are called whenever a message is received.
static void process_pending_messages(struct GNUNET_ATS_Session *session)
If we have pending messages, ask the server to transmit them (schedule the respective tasks,...
static void tcp_plugin_address_pretty_printer(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.
void GNUNET_SERVER_client_disconnect(struct GNUNET_SERVER_Client *client)
Ask the server to disconnect from the given client.
static enum GNUNET_NetworkType tcp_plugin_get_network(void *cls, struct GNUNET_ATS_Session *session)
Function obtain the network type for a session.
static void disconnect_notify(void *cls, struct GNUNET_SERVER_Client *client)
Function called whenever a peer is disconnected on the "SERVER" level.
struct GNUNET_SERVER_TransmitHandle * GNUNET_SERVER_notify_transmit_ready(struct GNUNET_SERVER_Client *client, size_t size, struct GNUNET_TIME_Relative timeout, GNUNET_CONNECTION_TransmitReadyNotify callback, void *callback_cls)
Notify us when the server has enough space to transmit a message of the given size to the given clien...
static void connect_notify(void *cls, struct GNUNET_SERVER_Client *client)
Function called whenever a peer is connected on the "SERVER" level.
static int send_session_info_iter(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Return information about the given session to the monitor callback.
static void notify_session_monitor(struct Plugin *plugin, struct GNUNET_ATS_Session *session, enum GNUNET_TRANSPORT_SessionState state)
If a session monitor is attached, notify it about the new session state.
void * libgnunet_plugin_transport_tcp_done(void *cls)
Exit point from the plugin.
void GNUNET_SERVER_resume(struct GNUNET_SERVER_Handle *server)
Resume accepting connections from the listen socket.
void GNUNET_SERVER_notify_transmit_ready_cancel(struct GNUNET_SERVER_TransmitHandle *th)
Abort transmission request.
static enum GNUNET_NetworkType scope
Which network scope do we belong to?
Closure for session_lookup_it().
struct GNUNET_ATS_Session * result
Where to store the session (if we found it).
const struct GNUNET_HELLO_Address * address
Address we are looking for.
Session handle for connections.
struct GNUNET_PeerIdentity target
To whom are we talking to.
struct Plugin * plugin
Pointer to the global plugin struct.
unsigned int msgs_in_queue
Number of messages waiting for transmission to this peer.
int is_nat
Was this session created using NAT traversal?
struct GNUNET_SERVER_Client * client
The client (used to identify this connection)
struct PendingMessage * pending_messages_tail
Messages currently pending for transmission to this peer, if any.
struct GNUNET_SCHEDULER_Task * nat_connection_timeout
Task cleaning up a NAT client connection establishment attempt;.
struct GNUNET_TIME_Absolute timeout
When does this session time out.
struct GNUNET_SERVER_TransmitHandle * transmit_handle
Handle for pending transmission request.
struct PendingMessage * pending_messages_head
Messages currently pending for transmission to this peer, if any.
struct GNUNET_TIME_Absolute receive_delay
When will we continue to read from the socket? (used to enforce inbound quota).
struct GNUNET_HELLO_Address * address
Address.
enum GNUNET_NetworkType scope
ATS network type.
unsigned long long bytes_in_queue
Number of bytes waiting for transmission to this peer.
int expecting_welcome
Are we still expecting the welcome message? (GNUNET_YES/GNUNET_NO)
struct GNUNET_TIME_Absolute last_activity
Last activity on this connection.
struct GNUNET_SCHEDULER_Task * receive_delay_task
ID of task used to delay receiving more to throttle sender.
struct GNUNET_SCHEDULER_Task * timeout_task
Session timeout task.
void * cls
Closure for all of the callbacks.
Credentials for UNIX domain sockets.
uid_t uid
UID of the other end of the connection.
gid_t gid
GID of the other end of the connection.
handle for a network connection
struct GNUNET_NETWORK_Handle * sock
Underlying OS's socket, set to NULL after fatal errors.
Internal representation of the hash map.
void * cls
Closure to use for callbacks.
An address for communicating with a peer.
size_t address_length
Number of bytes in address.
const void * address
Binary representation of the address (plugin-specific).
Handle for active NAT registrations.
socklen_t addrlen
Number of bytes in addr.
The identity of the host (wraps the signing key of the peer).
Handle to a request given to the resolver.
Entry in list of pending tasks.
handle for a client of the server
struct GNUNET_CONNECTION_Handle * connection
Client closure for callbacks.
void * mst
Processing of incoming data.
struct GNUNET_SERVER_Handle * server
Server that this client belongs to.
uint16_t type
Type of the message this handler covers.
GNUNET_SERVER_MessageCallback callback
Function to call for messages of "type".
void * callback_cls
Closure argument for callback.
uint16_t expected_size
Expected size of messages of this type.
Handle to a message stream tokenizer.
GNUNET_SERVER_MessageTokenizerCallback cb
Function to call on completed messages.
void * cb_cls
Closure for cb.
Handle server returns for aborting transmission to a client.
void * callback_cls
Closure for callback.
GNUNET_CONNECTION_TransmitReadyNotify callback
Function to call to get the message.
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.
The transport service will pass a pointer to a struct of this type as the first and only argument to ...
void * cls
Closure for the various callbacks.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
void * cls
Closure for all of the callbacks.
GNUNET_TRANSPORT_TransmitFunction send
Function that the transport service will use to transmit data to another peer.
GNUNET_TRANSPORT_UpdateInboundDelay update_inbound_delay
Function that will be called whenever the transport service wants to notify the plugin that the inbou...
GNUNET_TRANSPORT_SessionMonitorSetup setup_monitor
Function to monitor the sessions managed by the plugin.
GNUNET_TRANSPORT_DisconnectPeerFunction disconnect_peer
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
GNUNET_TRANSPORT_GetNetworkTypeForAddress get_network_for_address
Function to obtain the network type for an address.
GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
GNUNET_TRANSPORT_QueryKeepaliveFactorFunction query_keepalive_factor
Function that is used to query keepalive factor.
GNUNET_TRANSPORT_AddressPrettyPrinter address_pretty_printer
Function to pretty-print addresses.
GNUNET_TRANSPORT_AddressToString address_to_string
Function that will be called to convert a binary address to a string (numeric conversion only).
GNUNET_TRANSPORT_GetNetworkType get_network
Function to obtain the network type for a session.
GNUNET_TRANSPORT_CreateSession get_session
Function that will be called tell the plugin to create a session object.
GNUNET_TRANSPORT_CheckAddress check_address
Function that will be called to check if a binary address for this plugin is well-formed and correspo...
GNUNET_TRANSPORT_StringToAddress string_to_address
Function that will be called to convert a string address to binary (numeric conversion only).
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's session.
Network format for IPv4 addresses.
uint16_t t4_port
Port number, in network byte order.
uint32_t ipv4_addr
IPv4 address, in network byte order.
uint32_t options
Optional options and flags for this address, see enum TcpAddressOptions
Network format for IPv6 addresses.
uint32_t options
Optional flags for this address see enum TcpAddressOptions
struct in6_addr ipv6_addr
IPv6 address.
uint16_t t6_port
Port number, in network byte order.
Context for "service_task".
List containing all messages that are yet to be send.
struct TransportClient * client
Client that issued the transmission request, if pmt is PMT_CORE.
size_t message_size
So that the gnunet-service-transport can group messages together, these pending messages need to acce...
struct PendingMessage * prev
This is a doubly-linked list.
struct PendingMessage * next
DLL next, prev.
const char * msg
The pending message.
GNUNET_TRANSPORT_TransmitContinuation transmit_cont
Continuation function to call once the message has been sent.
struct GNUNET_TIME_Absolute timeout
At what time should we give up on the transmission (and no longer retry)?
void * transmit_cont_cls
Closure for transmit_cont.
struct GNUNET_CONTAINER_MultiPeerMap * sessionmap
Map from peer identities to sessions for the given peer.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
unsigned long long cur_connections
How many more TCP sessions do we have right now?
void * sic_cls
Closure for sic.
struct GNUNET_CONNECTION_Handle * lsock
The listen socket.
struct GNUNET_SERVER_MessageHandler * handlers
Copy of the handler array where the closures are set to this struct's instance.
uint16_t adv_port
Port that the user said we would have visible to the rest of the world.
struct GNUNET_SCHEDULER_Task * address_update_task
ID of task used to update our addresses when one expires.
struct TCPProbeContext * probe_head
List of active TCP probes.
struct PrettyPrinterContext * ppc_dll_head
Running pretty printers: head.
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
unsigned long long max_connections
How many more TCP sessions are we allowed to open right now?
struct LEGACY_SERVICE_Context * service
Handle to the network service.
struct GNUNET_NAT_Handle * nat
NAT handle & address management.
uint32_t myoptions
Address options.
GNUNET_TRANSPORT_SessionInfoCallback sic
Function to call about session status changes.
struct GNUNET_SERVER_Handle * server
Handle to the server for this service.
struct TCPProbeContext * probe_tail
List of active TCP probes.
struct WelcomeMessage my_welcome
Welcome message used by this peer.
uint16_t open_port
Port that we are actually listening on.
struct PrettyPrinterContext * ppc_dll_tail
Running pretty printers: tail.
struct GNUNET_CONTAINER_MultiPeerMap * nat_wait_conns
Map of peers we have tried to contact behind a NAT.
Closure for append_port().
struct GNUNET_RESOLVER_RequestHandle * resolver_handle
Resolver handle.
struct Plugin * plugin
Our plugin.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
uint16_t port
Port to add after the IP address.
char * plugin
Plugin String.
void * asc_cls
Clsoure for asc.
GNUNET_TRANSPORT_AddressStringCallback asc
Function to call with the result.
uint32_t options
Address options.
struct PrettyPrinterContext * prev
DLL.
struct PrettyPrinterContext * next
DLL.
Context for sending a NAT probe via TCP.
struct TCPProbeContext * prev
Active probes are kept in a DLL.
struct TCPProbeContext * next
Active probes are kept in a DLL.
struct GNUNET_CONNECTION_Handle * sock
Probe connection.
struct TCP_NAT_ProbeMessage message
Message to be sent.
struct GNUNET_CONNECTION_TransmitHandle * transmit_handle
Handle to the transmission.
struct Plugin * plugin
Transport plugin handle.
Basically a WELCOME message, but with the purpose of giving the waiting peer a client handle to use.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE.
struct GNUNET_PeerIdentity clientIdentity
Identity of the sender of the message.
Initial handshake message for a session.
struct GNUNET_PeerIdentity clientIdentity
Identity of the node connecting (TCP client)
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME.
struct GNUNET_CONNECTION_TransmitHandle * GNUNET_CONNECTION_notify_transmit_ready(struct GNUNET_CONNECTION_Handle *connection, size_t size, struct GNUNET_TIME_Relative timeout, GNUNET_CONNECTION_TransmitReadyNotify notify, void *notify_cls)
Ask the connection to call us once the specified number of bytes are free in the transmission buffer.
struct GNUNET_CONNECTION_Handle * GNUNET_CONNECTION_connect_socket(struct GNUNET_NETWORK_Handle *s, const struct sockaddr *serv_addr, socklen_t addrlen)
Create a connection handle by (asynchronously) connecting to a host.
struct GNUNET_CONNECTION_Handle * GNUNET_CONNECTION_create_from_sockaddr(int af_family, const struct sockaddr *serv_addr, socklen_t addrlen)
Create a connection handle by creating a socket and (asynchronously) connecting to a host.
void GNUNET_SERVER_add_handlers(struct GNUNET_SERVER_Handle *server, const struct GNUNET_SERVER_MessageHandler *handlers)
Add additional handlers to an existing server.
void GNUNET_SERVER_disable_receive_done_warning(struct GNUNET_SERVER_Client *client)
Disable the warning the server issues if a message is not acknowledged in a timely fashion.
void GNUNET_SERVER_connect_notify(struct GNUNET_SERVER_Handle *server, GNUNET_SERVER_ConnectCallback callback, void *callback_cls)
Ask the server to notify us whenever a client connects.
void GNUNET_SERVER_client_set_timeout(struct GNUNET_SERVER_Client *client, struct GNUNET_TIME_Relative timeout)
Change the timeout for a particular client.
struct GNUNET_SERVER_Handle * GNUNET_SERVER_create_with_sockets(GNUNET_CONNECTION_AccessCheck access_cb, void *access_cb_cls, struct GNUNET_NETWORK_Handle **lsocks, struct GNUNET_TIME_Relative idle_timeout, int require_found)
Create a new server.
void GNUNET_SERVER_receive_done(struct GNUNET_SERVER_Client *client, int success)
Resume receiving from this client, we are done processing the current request.
int GNUNET_SERVER_client_get_address(struct GNUNET_SERVER_Client *client, void **addr, size_t *addrlen)
Obtain the network address of the other party.
void GNUNET_SERVER_disconnect_notify(struct GNUNET_SERVER_Handle *server, GNUNET_SERVER_DisconnectCallback callback, void *callback_cls)
Ask the server to notify us whenever a client disconnects.
struct GNUNET_SERVER_Handle * LEGACY_SERVICE_get_server(struct LEGACY_SERVICE_Context *ctx)
Obtain the server used by a service.
struct GNUNET_NETWORK_Handle *const * LEGACY_SERVICE_get_listen_sockets(struct LEGACY_SERVICE_Context *ctx)
Get the NULL-terminated array of listen sockets for this service.
struct LEGACY_SERVICE_Context * LEGACY_SERVICE_start(const char *service_name, const struct GNUNET_CONFIGURATION_Handle *cfg, enum LEGACY_SERVICE_Options options)
Run a service startup sequence within an existing initialized system.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
common internal definitions for transport service