34 #include <microhttpd.h>
39 #define PLUGIN_NAME "https_server"
40 #define LIBGNUNET_PLUGIN_TRANSPORT_INIT \
41 libgnunet_plugin_transport_https_server_init
42 #define LIBGNUNET_PLUGIN_TRANSPORT_DONE \
43 libgnunet_plugin_transport_https_server_done
45 #define PLUGIN_NAME "http_server"
46 #define LIBGNUNET_PLUGIN_TRANSPORT_INIT \
47 libgnunet_plugin_transport_http_server_init
48 #define LIBGNUNET_PLUGIN_TRANSPORT_DONE \
49 libgnunet_plugin_transport_http_server_done
52 #define HTTP_ERROR_RESPONSE \
53 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"><HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD><BODY><H1>Not Found</H1>The requested URL was not found on this server.<P><HR><ADDRESS></ADDRESS></BODY></HTML>"
58 #define LOG(kind, ...) GNUNET_log_from (kind, "transport-" PLUGIN_NAME, \
87 #define OPTION_LONG_POLL 1
508 "Session %p: Waking up PUT handle\n",
526 struct MHD_Daemon *server,
567 if (NULL !=
msg->transmit_cont)
568 msg->transmit_cont (
msg->transmit_cont_cls,
572 msg->pos +
msg->overhead);
586 "Server: %p / %p Terminating inbound PUT session to peer `%s'\n",
591 MHD_CONNECTION_OPTION_TIMEOUT,
606 "Server: %p / %p Terminating inbound GET session to peer `%s'\n",
610 MHD_CONNECTION_OPTION_TIMEOUT,
633 "Session %p destroyed\n",
682 "Session %p was idle for %s, disconnecting\n",
737 unsigned int priority,
744 ssize_t bytes_sent = 0;
748 "Session %p/request %p: Sending message with %lu to peer `%s'\n",
751 (
unsigned long) msgbuf_size,
760 msg->buf = (
char *) &
msg[1];
761 msg->transmit_cont = cont;
762 msg->transmit_cont_cls = cont_cls;
775 "# bytes currently in %s_server buffers",
860 "Transport tells me to disconnect `%s'\n",
891 if ((NULL !=
plugin->ext_addr) &&
893 plugin->ext_addr->address,
904 while (NULL != (pos = next))
946 plugin->server_v4_task = NULL;
964 plugin->server_v6_task = NULL;
982 struct MHD_Daemon *daemon_handle,
992 MHD_UNSIGNED_LONG_LONG
timeout;
993 static unsigned long long last_timeout = 0;
1008 MHD_get_fdset (daemon_handle,
1013 haveto = MHD_get_timeout (daemon_handle, &
timeout);
1014 if (haveto == MHD_YES)
1019 "SELECT Timeout changed from %llu to %llu (ms)\n",
1036 if (daemon_handle ==
plugin->server_v4)
1038 if (
plugin->server_v4_task != NULL)
1041 plugin->server_v4_task = NULL;
1045 "Scheduling IPv4 server task in %llu ms\n",
1053 if (daemon_handle ==
plugin->server_v6)
1055 if (
plugin->server_v6_task != NULL)
1058 plugin->server_v6_task = NULL;
1062 "Scheduling IPv6 server task in %llu ms\n", tv);
1085 struct MHD_Daemon *server,
1088 if ((server ==
plugin->server_v4) && (
plugin->server_v4 != NULL))
1096 if (
plugin->server_v4_task != NULL)
1099 plugin->server_v4_task = NULL;
1104 if ((server ==
plugin->server_v6) && (
plugin->server_v6 != NULL))
1112 if (
plugin->server_v6_task != NULL)
1115 plugin->server_v6_task = NULL;
1172 "Setting timeout for %p to %u sec.\n",
1175 MHD_CONNECTION_OPTION_TIMEOUT,
1182 "Setting timeout for %p to %u sec.\n",
1185 MHD_CONNECTION_OPTION_TIMEOUT,
1210 const char *tag_start;
1211 const char *target_start;
1215 unsigned long int rc;
1219 ("^.*/([0-9A-Z]+);([0-9]+)(,[0-9]+)?$")
1230 "URL `%s' did not match regex\n", url);
1234 target_start = &url[
matches[1].rm_so];
1235 tag_start = &url[
matches[2].rm_so];
1238 rc = strtoul (tag_start, &tag_end, 10);
1239 if (&url[
matches[2].rm_eo] != tag_end)
1242 "URL tag did not line up with submatch\n");
1248 "URL tag is zero\n");
1251 if ((rc == ULONG_MAX) && (ERANGE == errno))
1254 "URL tag > ULONG_MAX\n");
1257 if (rc > UINT32_MAX)
1260 "URL tag > UINT32_MAX\n");
1263 (*tag) = (uint32_t) rc;
1265 "Found tag `%u' in url\n",
1270 if (hash_length !=
plugin->peer_id_length)
1273 "URL target is %lu bytes, expecting %u\n",
1274 (
unsigned long) hash_length,
plugin->peer_id_length);
1283 "URL target conversion failed\n");
1287 "Found target `%s' in URL\n",
1297 rc = strtoul (&url[
matches[3].rm_so + 1], &options_end, 10);
1298 if (&url[
matches[3].rm_eo] != options_end)
1301 "URL options did not line up with submatch\n");
1304 if ((rc == ULONG_MAX) && (ERANGE == errno))
1307 "URL options > ULONG_MAX\n");
1310 if (rc > UINT32_MAX)
1313 "URL options > UINT32_MAX\n");
1316 (*options) = (uint32_t) rc;
1318 "Found options `%u' in url\n",
1378 struct MHD_Connection *mhd_connection,
1384 const union MHD_ConnectionInfo *conn_info;
1394 conn_info = MHD_get_connection_info (mhd_connection,
1395 MHD_CONNECTION_INFO_CLIENT_ADDRESS);
1396 if ((conn_info->client_addr->sa_family != AF_INET) &&
1397 (conn_info->client_addr->sa_family != AF_INET6))
1400 "New %s request from %s\n",
1409 "Invalid url %s\n", url);
1412 if (0 == strcmp (MHD_HTTP_METHOD_PUT, method))
1414 else if (0 == strcmp (MHD_HTTP_METHOD_GET, method))
1419 "Invalid method %s for request from %s\n",
1426 "New %s request from %s with tag %u (%u of %u)\n",
1437 if (NULL == (s = stc.
res))
1441 switch (conn_info->client_addr->sa_family)
1445 conn_info->client_addr,
1446 sizeof(
struct sockaddr_in));
1449 conn_info->client_addr,
1450 sizeof(
struct sockaddr_in));
1455 conn_info->client_addr,
1456 sizeof(
struct sockaddr_in6));
1459 conn_info->client_addr,
1460 sizeof(
struct sockaddr_in6));
1493 "Creating new session %p for peer `%s' connecting from `%s'\n",
1505 "Duplicate PUT request from `%s' tag %u, dismissing new request\n",
1513 "Duplicate GET request from `%s' tag %u, dismissing new request\n",
1519 if (conn_info->client_addr->sa_family == AF_INET)
1520 sc->mhd_daemon =
plugin->server_v4;
1521 if (conn_info->client_addr->sa_family == AF_INET6)
1522 sc->mhd_daemon =
plugin->server_v6;
1523 sc->mhd_conn = mhd_connection;
1574 ssize_t bytes_read = 0;
1594 msg->pos += bytes_read;
1602 if (NULL !=
msg->transmit_cont)
1619 "Sent %lu bytes to peer `%s' with session %p \n",
1620 (
unsigned long) bytes_read,
1624 "# bytes currently in %s_server buffers",
1632 "# bytes transmitted via %s_server",
1641 "Completing GET response to peer `%s' with session %p\n",
1644 return MHD_CONTENT_READER_END_OF_STREAM;
1688 "# bytes received via %s_server",
1692 ntohs (message->
size),
1699 "Peer `%s' address `%s' next read delayed for %s\n",
1722 "Access-Control-Allow-Origin",
1725 "Access-Control-Allow-Methods",
1726 "GET, PUT, OPTIONS");
1728 "Access-Control-Max-Age",
1748 struct MHD_Connection *mhd_connection,
1751 const char *version,
1752 const char *upload_data,
1753 size_t *upload_data_size,
1754 void **httpSessionCache)
1764 "Access from connection %p (%u of %u) for `%s' `%s' url `%s' with upload data size %lu\n"),
1771 (
unsigned long) (*upload_data_size));
1775 if (0 == strcmp (MHD_HTTP_METHOD_OPTIONS, method))
1777 response = MHD_create_response_from_buffer (0, NULL,
1778 MHD_RESPMEM_PERSISTENT);
1789 (*httpSessionCache) =
sc;
1796 MHD_RESPMEM_PERSISTENT);
1798 MHD_HTTP_HEADER_CONTENT_TYPE,
1807 if (NULL == (s =
sc->session))
1811 response = MHD_create_response_from_buffer (strlen (
"Thank you!"),
1813 MHD_RESPMEM_PERSISTENT);
1822 response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 32 * 1024,
1832 if ((*upload_data_size == 0) && (
sc->connected ==
GNUNET_NO))
1836 "Session %p / Connection %p: Peer `%s' PUT on address `%s' connected\n",
1845 else if ((*upload_data_size == 0) && (
sc->connected ==
GNUNET_YES))
1849 "Session %p / Connection %p: Peer `%s' PUT on address `%s' finished upload\n",
1857 response = MHD_create_response_from_buffer (strlen (
"Thank you!"),
1859 MHD_RESPMEM_PERSISTENT);
1865 else if ((*upload_data_size > 0) && (
sc->connected ==
GNUNET_YES))
1871 "Session %p / Connection %p: Peer `%s' PUT on address `%s' received %lu bytes\n",
1877 (
unsigned long) *upload_data_size);
1882 "PUT with %lu bytes forwarded to MST\n",
1883 (
unsigned long) *upload_data_size);
1897 (*upload_data_size) = 0;
1903 "Session %p / Connection %p: no inbound bandwidth available! Next read was delayed by %s\n",
1938 struct MHD_Connection *connection,
1939 void **httpSessionCache)
1945 "Disconnect for connection %p\n",
1953 if (NULL !=
sc->session)
1958 "Peer `%s' connection %p, GET on address `%s' disconnected\n",
1960 sc->session->server_send,
1962 sc->session->address->address,
1963 sc->session->address->
1966 sc->session->server_send = NULL;
1971 "Peer `%s' connection %p PUT on address `%s' disconnected\n",
1973 sc->session->server_recv,
1975 sc->session->address->address,
1976 sc->session->address->
1978 sc->session->server_recv = NULL;
1979 if (NULL !=
sc->session->msg_tk)
1982 sc->session->msg_tk = NULL;
2002 struct MHD_Connection *connection,
2003 void **socket_context,
2004 enum MHD_ConnectionNotificationCode toe)
2007 const union MHD_ConnectionInfo *
info;
2009 if (MHD_CONNECTION_NOTIFY_STARTED == toe)
2013 info = MHD_get_connection_info (connection,
2014 MHD_CONNECTION_INFO_DAEMON);
2032 const struct sockaddr *addr,
2040 _ (
"Accepting connection (%u of %u) from `%s'\n"),
2049 "Server reached maximum number connections (%u), rejecting new connection\n"),
2089 server_load_file (
const char *file)
2102 if (NULL == gn_file)
2140 "KEY_FILE", &key_file))
2143 plugin->name,
"CERT_FILE");
2149 "CERT_FILE", &cert_file))
2152 plugin->name,
"CERT_FILE");
2164 "Using crypto init string `%s'\n",
2168 "Using default crypto init string \n");
2172 "Trying to loading TLS certificate from key-file `%s' cert-file`%s'\n",
2173 key_file, cert_file);
2175 plugin->key = server_load_file (key_file);
2176 plugin->cert = server_load_file (cert_file);
2188 "No usable TLS certificate found, creating certificate\n");
2193 "gnunet-transport-certificate-creation",
2194 "gnunet-transport-certificate-creation",
2198 if (NULL == cert_creation)
2202 "Could not create a new TLS certificate, program `gnunet-transport-certificate-creation' could not be started!\n"));
2211 plugin->crypto_init = NULL;
2218 plugin->key = server_load_file (key_file);
2219 plugin->cert = server_load_file (cert_file);
2226 "No usable TLS certificate found and creating one at `%s/%s' failed!\n"),
2227 key_file, cert_file);
2236 plugin->crypto_init = NULL;
2243 "TLS certificate loaded\n");
2260 static struct MHD_Daemon *
2262 const struct sockaddr_in *addr,
2265 struct MHD_Daemon *server;
2268 #if MHD_VERSION >= 0x00090E00
2271 "MHD can set timeout per connection! Default time out %u sec.\n",
2276 "MHD cannot set timeout per connection! Default time out %u sec.\n",
2279 server = MHD_start_daemon (
2286 MHD_USE_SUSPEND_RESUME
2291 MHD_OPTION_SOCK_ADDR,
2293 MHD_OPTION_CONNECTION_LIMIT,
2294 (
unsigned int)
plugin->max_request,
2296 MHD_OPTION_HTTPS_PRIORITIES,
2298 MHD_OPTION_HTTPS_MEM_KEY,
2300 MHD_OPTION_HTTPS_MEM_CERT,
2303 MHD_OPTION_CONNECTION_TIMEOUT,
2305 MHD_OPTION_CONNECTION_MEMORY_LIMIT,
2308 MHD_OPTION_NOTIFY_COMPLETED,
2310 MHD_OPTION_NOTIFY_CONNECTION,
2312 MHD_OPTION_EXTERNAL_LOGGER,
2316 if ((NULL != server) &&
2319 const union MHD_DaemonInfo *di;
2321 di = MHD_get_daemon_info (server,
2322 MHD_DAEMON_INFO_LISTEN_FD,
2324 if ((0 != setsockopt ((
int) di->listen_fd,
2327 plugin->env->my_identity,
2331 _ (
"TCP_STEALTH not supported on this platform.\n"));
2332 MHD_stop_daemon (server);
2358 "Could not load or create server certificate! Loading plugin failed!\n"));
2364 plugin->server_v4 = NULL;
2370 sockaddr_in *)
plugin->server_addr_v4,
2373 if (NULL ==
plugin->server_v4)
2376 "Failed to start %s IPv4 server component on port %u\n",
2387 plugin->server_v6 = NULL;
2393 sockaddr_in *)
plugin->server_addr_v6,
2395 if (NULL ==
plugin->server_v6)
2398 "Failed to start %s IPv6 server component on port %u\n",
2410 if ((NULL ==
plugin->server_v6) &&
2411 (NULL ==
plugin->server_v4))
2414 "%s %s server component started on port %u\n",
2420 if ((NULL !=
plugin->server_v6) &&
2421 (NULL !=
plugin->server_v4))
2422 msg =
"IPv4 and IPv6";
2423 else if (NULL !=
plugin->server_v6)
2425 else if (NULL !=
plugin->server_v4)
2428 "%s %s server component started on port %u\n",
2447 const struct sockaddr *addr,
2469 "Notifying transport to add address `%s'\n",
2504 const struct sockaddr *addr,
2536 "Notifying transport to remove address `%s'\n",
2579 const struct sockaddr *addr,
2586 "NAT called to %s address `%s'\n",
2587 (add_remove ==
GNUNET_NO) ?
"remove" :
"add",
2590 if (AF_INET == addr->sa_family)
2592 struct sockaddr_in *s4 = (
struct sockaddr_in *) addr;
2597 if ((NULL !=
plugin->server_addr_v4) &&
2598 (0 != memcmp (&
plugin->server_addr_v4->sin_addr,
2600 sizeof(
struct in_addr))))
2603 "Skipping address `%s' (not bindto address)\n",
2609 if (AF_INET6 == addr->sa_family)
2611 struct sockaddr_in6 *s6 = (
struct sockaddr_in6 *) addr;
2615 if ((NULL !=
plugin->server_addr_v6) &&
2616 (0 != memcmp (&
plugin->server_addr_v6->sin6_addr,
2617 &s6->sin6_addr,
sizeof(
struct in6_addr))))
2620 "Skipping address `%s' (not bindto address)\n",
2653 struct sockaddr ***addrs,
2654 socklen_t **addr_lens)
2657 unsigned long long port;
2658 struct addrinfo hints;
2659 struct addrinfo *
res;
2660 struct addrinfo *pos;
2661 struct addrinfo *next;
2665 struct sockaddr **saddrs;
2666 socklen_t *saddrlens;
2672 disablev6 = !
plugin->use_ipv6;
2684 "Require valid port number for service in configuration!\n"));
2691 "Starting in listen only mode\n");
2709 "Resolving `%s' since that is where `%s' will bind to.\n",
2711 memset (&hints, 0,
sizeof(
struct addrinfo));
2713 hints.ai_family = AF_INET;
2718 _ (
"Failed to resolve `%s': %s\n"),
2720 gai_strerror (
ret));
2726 while (NULL != (pos = next))
2728 next = pos->ai_next;
2729 if ((disablev6) && (pos->ai_family == AF_INET6))
2736 _ (
"Failed to find %saddress for `%s'.\n"),
2737 disablev6 ?
"IPv4 " :
"",
hostname);
2743 saddrs =
GNUNET_malloc ((resi + 1) *
sizeof(
struct sockaddr *));
2747 while (NULL != (pos = next))
2749 next = pos->ai_next;
2750 if ((disablev6) && (pos->ai_family == AF_INET6))
2752 if ((pos->ai_protocol != IPPROTO_TCP) && (0 != pos->ai_protocol))
2754 if ((pos->ai_socktype != SOCK_STREAM) && (0 != pos->ai_socktype))
2757 "Service will bind to `%s'\n",
2760 if (pos->ai_family == AF_INET)
2762 GNUNET_assert (pos->ai_addrlen ==
sizeof(
struct sockaddr_in));
2763 saddrlens[i] = pos->ai_addrlen;
2766 ((
struct sockaddr_in *) saddrs[i])->sin_port = htons (
port);
2771 GNUNET_assert (pos->ai_addrlen ==
sizeof(
struct sockaddr_in6));
2772 saddrlens[i] = pos->ai_addrlen;
2775 ((
struct sockaddr_in6 *) saddrs[i])->sin6_port = htons (
port);
2791 saddrs =
GNUNET_malloc ((resi + 1) *
sizeof(
struct sockaddr *));
2794 saddrlens[i] =
sizeof(
struct sockaddr_in);
2796 #if HAVE_SOCKADDR_IN_SIN_LEN
2797 ((
struct sockaddr_in *) saddrs[i])->sin_len = saddrlens[i];
2799 ((
struct sockaddr_in *) saddrs[i])->sin_family = AF_INET;
2800 ((
struct sockaddr_in *) saddrs[i])->sin_port = htons (
port);
2806 saddrs =
GNUNET_malloc ((resi + 1) *
sizeof(
struct sockaddr *));
2809 saddrlens[i] =
sizeof(
struct sockaddr_in6);
2811 #if HAVE_SOCKADDR_IN_SIN_LEN
2812 ((
struct sockaddr_in6 *) saddrs[i])->sin6_len = saddrlens[0];
2814 ((
struct sockaddr_in6 *) saddrs[i])->sin6_family = AF_INET6;
2815 ((
struct sockaddr_in6 *) saddrs[i])->sin6_port = htons (
port);
2817 saddrlens[i] =
sizeof(
struct sockaddr_in);
2819 #if HAVE_SOCKADDR_IN_SIN_LEN
2820 ((
struct sockaddr_in *) saddrs[i])->sin_len = saddrlens[1];
2822 ((
struct sockaddr_in *) saddrs[i])->sin_family = AF_INET;
2823 ((
struct sockaddr_in *) saddrs[i])->sin_port = htons (
port);
2827 *addr_lens = saddrlens;
2841 struct sockaddr **addrs;
2842 socklen_t *addrlens;
2849 _ (
"Found %u addresses to report to NAT service\n"),
2863 (
const struct sockaddr **) addrs,
2896 while (NULL !=
plugin->addr_head)
2926 if ((errno == ENOBUFS) ||
2927 (errno == ENOMEM) ||
2928 (errno == ENFILE) ||
2935 _ (
"Disabling IPv6 since it is not supported on this system!\n"));
2946 "Testing IPv6 on this system: %s\n",
2962 size_t ext_addr_len;
2966 plugin->notify_ext_task = NULL;
2970 plugin->external_hostname);
2971 urlen = strlen (url) + 1;
2980 "Notifying transport about external hostname address `%s'\n",
2981 plugin->external_hostname);
2986 "Enabling SSL verification for external hostname address `%s'\n",
2987 plugin->external_hostname);
3022 unsigned long long port;
3024 char *bind4_address = NULL;
3025 char *bind6_address = NULL;
3026 char *eh_tmp = NULL;
3027 int external_hostname_use_port;
3041 _ (
"IPv4 support is %s\n"),
3056 _ (
"IPv6 support is %s\n"),
3062 _ (
"Neither IPv4 nor IPv6 are enabled! Fix in configuration\n"));
3073 _ (
"Port is required! Fix in configuration\n"));
3079 _ (
"Using port %u\n"),
plugin->port);
3089 "Binding %s plugin to specific IPv4 address: `%s'\n",
3093 if (1 != inet_pton (AF_INET,
3095 &
plugin->server_addr_v4->sin_addr))
3098 _ (
"Specific IPv4 address `%s' in configuration file is invalid!\n"),
3102 plugin->server_addr_v4 = NULL;
3108 "Binding to IPv4 address %s\n",
3110 plugin->server_addr_v4->sin_family = AF_INET;
3111 plugin->server_addr_v4->sin_port = htons (
plugin->port);
3124 "Binding %s plugin to specific IPv6 address: `%s'\n",
3125 plugin->protocol, bind6_address);
3128 inet_pton (AF_INET6,
3130 &
plugin->server_addr_v6->sin6_addr))
3133 _ (
"Specific IPv6 address `%s' in configuration file is invalid!\n"),
3137 plugin->server_addr_v6 = NULL;
3143 "Binding to IPv6 address %s\n",
3145 plugin->server_addr_v6->sin6_family = AF_INET6;
3146 plugin->server_addr_v6->sin6_port = htons (
plugin->port);
3153 plugin->verify_external_hostname
3156 "VERIFY_EXTERNAL_HOSTNAME");
3162 external_hostname_use_port
3165 "EXTERNAL_HOSTNAME_USE_PORT");
3173 "EXTERNAL_HOSTNAME",
3178 char *pos_url = NULL;
3180 if (NULL != strstr (eh_tmp,
"://"))
3181 tmp = &strstr (eh_tmp,
"://")[3];
3185 if (
GNUNET_YES == external_hostname_use_port)
3187 if ((strlen (tmp) > 1) && (NULL != (pos = strchr (tmp,
'/'))))
3208 _ (
"Using external hostname `%s'\n"),
3209 plugin->external_hostname);
3218 "EXTERNAL_HOSTNAME_ONLY"))
3223 "EXTERNAL_HOSTNAME_ONLY");
3230 _ (
"Notifying transport only about hostname `%s'\n"),
3231 plugin->external_hostname);
3235 "No external hostname configured\n");
3247 _ (
"Maximum number of connections is %u\n"),
3268 if (NULL == api->
cls)
3276 _ (
"Shutting down plugin `%s'\n"),
3279 if (NULL !=
plugin->notify_ext_task)
3282 plugin->notify_ext_task = NULL;
3285 if (NULL !=
plugin->ext_addr)
3288 "Notifying transport to remove address `%s'\n",
3290 plugin->ext_addr->address,
3291 plugin->ext_addr->address_length));
3307 if (NULL !=
plugin->server_v4_task)
3310 plugin->server_v4_task = NULL;
3313 if (NULL !=
plugin->server_v6_task)
3316 plugin->server_v6_task = NULL;
3328 if (NULL !=
plugin->server_v4)
3330 MHD_stop_daemon (
plugin->server_v4);
3331 plugin->server_v4 = NULL;
3333 if (NULL !=
plugin->server_v6)
3335 MHD_stop_daemon (
plugin->server_v6);
3336 plugin->server_v6 = NULL;
3343 regfree (&
plugin->url_regex);
3346 _ (
"Shutdown for plugin `%s' complete\n"),
3388 return session->
scope;
3429 "New inbound delay %s\n",
3512 if (NULL ==
env->receive)
3546 plugin->name =
"transport-https_server";
3547 plugin->protocol =
"https";
3549 plugin->name =
"transport-http_server";
3550 plugin->protocol =
"http";
3562 _ (
"TCP_STEALTH not supported on this platform.\n"));
3569 if (regcomp (&
plugin->url_regex,
3574 _ (
"Unable to compile URL regex\n"));
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
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).
enum GNUNET_ABD_AlgoDirectionFlags direction
API enum, filled and passed for collect/verify.
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.
static struct MHD_Response * response
Our canonical response.
struct GNUNET_HashCode key
The key used in the DHT.
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_FS_SearchContext * sc
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
static char * hostname
Our hostname; we give this to all the peers we start.
static char * service_name
Option -s: service name (hash to get service descriptor)
API to create, modify and access statistics.
Transport service plugin API.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
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_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?
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
@ GNUNET_DISK_OPEN_READ
Open the file for reading.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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).
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.
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.
@ 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_log(kind,...)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a string representing a public key to a public key.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_SCHEDULER_PRIORITY_DEFAULT
Run with the default priority (normal P2P operations).
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.
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#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).
@ 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_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_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...
struct GNUNET_NETWORK_FDSet * GNUNET_NETWORK_fdset_create(void)
Creates an fd set.
enum GNUNET_GenericReturnValue GNUNET_NETWORK_socket_close(struct GNUNET_NETWORK_Handle *desc)
Close a socket.
void GNUNET_NETWORK_fdset_destroy(struct GNUNET_NETWORK_FDSet *fds)
Releases the associated memory of an fd set.
void GNUNET_NETWORK_fdset_copy_native(struct GNUNET_NETWORK_FDSet *to, const fd_set *from, int nfds)
Copy a native fd set into the GNUnet representation.
struct GNUNET_NETWORK_Handle * GNUNET_NETWORK_socket_create(int domain, int type, int protocol)
Create a new socket.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
struct GNUNET_OS_Process * GNUNET_OS_start_process(enum GNUNET_OS_InheritStdioFlags std_inheritance, struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNET_DISK_PipeHandle *pipe_stdout, struct GNUNET_DISK_PipeHandle *pipe_stderr, const char *filename,...)
Start a process.
void GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc)
Cleans up process structure contents (OS-dependent) and deallocates it.
enum GNUNET_GenericReturnValue GNUNET_OS_process_wait(struct GNUNET_OS_Process *proc)
Wait for a process to terminate.
@ GNUNET_OS_INHERIT_STD_OUT_AND_ERR
When these flags are set, the child process will inherit stdout and stderr of the parent.
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_select(enum GNUNET_SCHEDULER_Priority prio, struct GNUNET_TIME_Relative delay, const struct GNUNET_NETWORK_FDSet *rs, const struct GNUNET_NETWORK_FDSet *ws, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when any of the specified file descriptor set...
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.
enum GNUNET_GenericReturnValue GNUNET_MST_from_buffer(struct GNUNET_MessageStreamTokenizer *mst, 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 GNUNET_MST_destroy(struct GNUNET_MessageStreamTokenizer *mst)
Destroys a tokenizer.
struct GNUNET_MessageStreamTokenizer * GNUNET_MST_create(GNUNET_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define GNUNET_TIME_UNIT_SECONDS
One second.
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?
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
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.
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".
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.
@ MHD_HTTP_OK
OK [RFC7231, Section 6.3.1].
@ MHD_HTTP_NOT_FOUND
Not Found [RFC7231, Section 6.5.4].
const char * http_common_plugin_address_to_string(const char *plugin, const void *addr, size_t addrlen)
Function called for a quick conversion of the binary address to a numeric address.
size_t http_common_address_get_size(const struct HttpAddress *addr)
Get the length of an address.
size_t http_common_cmp_addresses(const void *addr1, size_t addrlen1, const void *addr2, size_t addrlen2)
Compare addr1 to addr2.
int http_common_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.
void http_common_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.
struct HttpAddress * http_common_address_from_socket(const char *protocol, const struct sockaddr *addr, socklen_t addrlen)
Create a HTTP address from a socketaddr.
enum GNUNET_NetworkType http_common_get_network_for_address(struct GNUNET_TRANSPORT_PluginEnvironment *env, const struct GNUNET_HELLO_Address *address)
Function obtain the network type for an address.
#define HTTP_SERVER_SESSION_TIMEOUT
@ HTTP_OPTIONS_VERIFY_CERTIFICATE
Verify X509 server certificate, it should be valid.
@ HTTP_OPTIONS_TCP_STEALTH
Enable TCP Stealth-style port knocking.
#define HTTP_SERVER_NOT_VALIDATED_TIMEOUT
static void http_server_plugin_setup_monitor(void *cls, GNUNET_TRANSPORT_SessionInfoCallback sic, void *sic_cls)
Begin monitoring sessions of a plugin.
static void server_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.
static void server_mhd_connection_timeout(struct HTTP_Server_Plugin *plugin, struct GNUNET_ATS_Session *s, unsigned int to)
Tell MHD that the connection should timeout after to seconds.
#define LIBGNUNET_PLUGIN_TRANSPORT_DONE
static void server_connection_cb(void *cls, struct MHD_Connection *connection, void **socket_context, enum MHD_ConnectionNotificationCode toe)
Callback from MHD when a connection starts/stops.
static void server_start_report_addresses(struct HTTP_Server_Plugin *plugin)
Ask NAT for addresses.
static MHD_RESULT server_accept_cb(void *cls, const struct sockaddr *addr, socklen_t addr_len)
Check if incoming connection is accepted.
static void server_add_address(void *cls, int add_remove, const struct sockaddr *addr, socklen_t addrlen)
Add an address to the server's set of addresses and notify transport.
static void server_session_timeout(void *cls)
Session was idle, so disconnect it.
static struct GNUNET_ATS_Session * http_server_plugin_get_session(void *cls, const struct GNUNET_HELLO_Address *address)
Creates a new outbound session the transport service will use to send data to the peer.
static void add_cors_headers(struct MHD_Response *response)
Add headers to a request indicating that we allow Cross-Origin Resource Sharing.
static unsigned int http_server_query_keepalive_factor(void *cls)
Function that is called to get the keepalive factor.
static void server_remove_address(void *cls, int add_remove, const struct sockaddr *addr, socklen_t addrlen)
Remove an address from the server's set of addresses and notify transport.
static void server_disconnect_cb(void *cls, struct MHD_Connection *connection, void **httpSessionCache)
Callback from MHD when a connection disconnects.
static int http_server_plugin_address_suggested(void *cls, const void *addr, size_t addrlen)
Another peer has suggested an address for this peer and transport plugin.
static void server_v4_run(void *cls)
Call MHD IPv4 to process pending requests and then go back and schedule the next run.
static int server_parse_url(struct HTTP_Server_Plugin *plugin, const char *url, struct GNUNET_PeerIdentity *target, uint32_t *tag, uint32_t *options)
Parse incoming URL for tag and target.
static void http_server_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 struct ServerRequest * server_lookup_connection(struct HTTP_Server_Plugin *plugin, struct MHD_Connection *mhd_connection, const char *url, const char *method)
Lookup a mhd connection and create one if none is found.
static void server_v6_run(void *cls)
Call MHD IPv6 to process pending requests and then go back and schedule the next run.
static int destroy_session_cb(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Terminate session.
static int server_start(struct HTTP_Server_Plugin *plugin)
Start the HTTP server.
static int session_tag_it(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Find a session with a matching tag.
static void server_log(void *arg, const char *fmt, va_list ap)
Log function called by MHD.
static void http_server_plugin_disconnect_peer(void *cls, const struct GNUNET_PeerIdentity *target)
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
static void server_delete_session(struct GNUNET_ATS_Session *s)
Deletes the session.
static void server_stop_report_addresses(struct HTTP_Server_Plugin *plugin)
Stop NAT for addresses.
static int server_receive_mst_cb(void *cls, const struct GNUNET_MessageHeader *message)
Callback called by MessageStreamTokenizer when a message has arrived.
static ssize_t http_server_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.
#define LIBGNUNET_PLUGIN_TRANSPORT_INIT
static int server_check_ipv6_support(struct HTTP_Server_Plugin *plugin)
Check if IPv6 supported on this system.
static struct GNUNET_SCHEDULER_Task * server_schedule(struct HTTP_Server_Plugin *plugin, struct MHD_Daemon *daemon_handle, int now)
Function that queries MHD's select sets and starts the task waiting for them.
static struct MHD_Daemon * run_mhd_start_daemon(struct HTTP_Server_Plugin *plugin, const struct sockaddr_in *addr, int v6)
Invoke MHD_start_daemon with the various options we need to setup the HTTP server with the given list...
static ssize_t server_send_callback(void *cls, uint64_t pos, char *buf, size_t max)
Callback called by MHD when it needs data to send.
static void notify_session_monitor(struct HTTP_Server_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.
static void server_wake_up(void *cls)
Wake up an MHD connection which was suspended.
static void server_notify_external_hostname(void *cls)
Notify server about our external hostname.
static enum GNUNET_NetworkType http_server_plugin_get_network(void *cls, struct GNUNET_ATS_Session *session)
Function obtain the network type for a session.
static int destroy_session_shutdown_cb(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Terminate session during shutdown.
static int http_server_plugin_disconnect_session(void *cls, struct GNUNET_ATS_Session *s)
Disconnect session s by telling MHD to close the connections (reducing timeout, etc....
static void http_server_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...
static void server_reschedule(struct HTTP_Server_Plugin *plugin, struct MHD_Daemon *server, int now)
Reschedule the execution of both IPv4 and IPv6 server.
static int server_configure_plugin(struct HTTP_Server_Plugin *plugin)
Configure the plugin.
static int server_get_addresses(struct HTTP_Server_Plugin *plugin, const char *service_name, const struct GNUNET_CONFIGURATION_Handle *cfg, struct sockaddr ***addrs, socklen_t **addr_lens)
Get valid server addresses.
static const char * http_server_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.
static enum GNUNET_NetworkType http_server_plugin_get_network_for_address(void *cls, const struct GNUNET_HELLO_Address *address)
Function obtain the network type for an address.
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 server_reschedule_session_timeout(struct GNUNET_ATS_Session *s)
Increment session timeout due to activity session s.
#define HTTP_ERROR_RESPONSE
static MHD_RESULT server_access_cb(void *cls, struct MHD_Connection *mhd_connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **httpSessionCache)
MHD callback for a new incoming connection.
static enum GNUNET_NetworkType scope
Which network scope do we belong to?
Closure for session_tag_it().
struct GNUNET_ATS_Session * res
Set to session matching the tag.
uint32_t tag
Tag 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.
struct ServerRequest * server_recv
Client send handle.
unsigned int msgs_in_queue
Number of messages waiting for transmission to this peer.
int known_to_service
GNUNET_YES if this session is known to the service.
struct GNUNET_TIME_Absolute timeout
When does this session time out.
struct ServerRequest * server_send
Client send handle.
struct HTTP_Message * msg_tail
previous pointer for double linked list
struct HTTP_Server_Plugin * plugin
Pointer to the global plugin struct.
uint32_t tag
Unique HTTP/S connection tag for this connection.
struct GNUNET_HELLO_Address * address
Address.
struct HTTP_Message * msg_head
next pointer for double linked list
enum GNUNET_NetworkType scope
ATS network type.
unsigned long long bytes_in_queue
Number of bytes waiting for transmission to this peer.
struct GNUNET_SCHEDULER_Task * recv_wakeup_task
Task to wake up client receive handle when receiving is allowed again.
struct GNUNET_TIME_Absolute next_receive
Absolute time when to receive data again Used for receive throttling.
struct GNUNET_SCHEDULER_Task * timeout_task
Session timeout task.
struct GNUNET_SERVER_MessageStreamTokenizer * msg_tk
Message stream tokenizer for incoming data.
Internal representation of the hash map.
Handle used to access files (and pipes).
enum GNUNET_FS_SearchOptions options
Options for the search.
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 to a message stream tokenizer.
Handle for active NAT registrations.
collection of IO descriptors
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Entry in list of pending tasks.
Time for absolute times used by GNUnet, in microseconds.
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.
Message to send using http.
struct HTTP_Message * next
next pointer for double linked list
size_t pos
amount of data already sent
GNUNET_TRANSPORT_TransmitContinuation transmit_cont
Continuation function to call once the transmission buffer has again space available.
void * transmit_cont_cls
Closure for transmit_cont.
char * buf
buffer containing data to send
struct HTTP_Message * prev
previous pointer for double linked list
size_t overhead
HTTP/S specific overhead.
Encapsulation of all of the state of the plugin.
uint16_t use_ipv6
use IPv6
struct MHD_Daemon * server_v4
MHD IPv4 daemon.
void * sic_cls
Closure for sic.
struct sockaddr_in * server_addr_v4
IPv4 server socket to bind to.
int server_v6_immediately
The IPv6 server is scheduled to run asap.
struct GNUNET_TRANSPORT_PluginEnvironment * env
Our environment.
struct sockaddr_in6 * server_addr_v6
IPv6 server socket to bind to.
GNUNET_TRANSPORT_SessionInfoCallback sic
Function to call about session status changes.
struct MHD_Daemon * server_v6
MHD IPv4 daemon.
struct HttpAddressWrapper * addr_tail
IPv4 addresses DLL tail.
char * external_hostname
External address.
struct GNUNET_SCHEDULER_Task * server_v4_task
MHD IPv4 task.
int server_v4_immediately
The IPv4 server is scheduled to run asap.
struct GNUNET_CONTAINER_MultiPeerMap * sessions
Hash map of open sessions.
struct GNUNET_SCHEDULER_Task * notify_ext_task
Task calling transport service about external address.
uint32_t options
My options to be included in the address.
struct GNUNET_HELLO_Address * ext_addr
External hostname the plugin can be connected to, can be different to the host's FQDN,...
unsigned int cur_request
Current number of sockets the plugin can use Each http connection are two requests.
int peer_id_length
Length of peer id.
struct GNUNET_SCHEDULER_Task * server_v6_task
MHD IPv6 task.
struct HttpAddressWrapper * addr_head
IPv4 addresses DLL head.
uint16_t use_ipv4
use IPv4
int verify_external_hostname
Verify external address.
unsigned int max_request
Maximum number of sockets the plugin can use Each http request /request connections are two connectio...
regex_t url_regex
Regex for parsing URLs.
int in_shutdown
Did we immediately end the session in disconnect_cb.
struct GNUNET_NAT_Handle * nat
NAT handle & address management.
unsigned int external_only
Notify transport only about external address.
Wrapper to manage addresses.
size_t addrlen
Length of the address.
struct HttpAddressWrapper * prev
Linked list previous.
struct HttpAddress * address
An address we are using.
struct HttpAddressWrapper * next
Linked list next.
HTTP addresses including a full URI.
void * addr
Address following.
uint32_t urlen
Length of URL located after struct.
uint32_t options
Address options see enum HttpAddressOptions
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
char * protocol
Plugin protocol http, https.
Information we keep with MHD for an HTTP request.
int connected
For PUT requests: Is this the first or last callback with size 0 For GET requests: Have we sent a mes...
struct GNUNET_ATS_Session * session
The session this server connection belongs to.
int direction
_RECV or _SEND
bool suspended
Currently suspended.
struct MHD_Daemon * mhd_daemon
The MHD daemon.
uint32_t options
Options requested by peer.
struct MHD_Connection * mhd_conn
The MHD connection.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.