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 253 unsigned long long bytes_in_queue;
258 unsigned int msgs_in_queue;
480 if (NULL == plugin->
sic)
482 memset (&info, 0,
sizeof(info));
508 "Session %p: Waking up PUT handle\n",
526 struct MHD_Daemon *server,
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,
758 msg->size = 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",
904 while (NULL != (pos = next))
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)
1016 if (timeout != last_timeout)
1019 "SELECT Timeout changed from %llu to %llu (ms)\n",
1020 last_timeout, timeout);
1045 "Scheduling IPv4 server task in %llu ms\n",
1062 "Scheduling IPv6 server task in %llu ms\n", tv);
1085 struct MHD_Daemon *server,
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,
1209 regmatch_t matches[4];
1210 const char *tag_start;
1211 const char *target_start;
1215 unsigned long int rc;
1219 ("^.*/([0-9A-Z]+);([0-9]+)(,[0-9]+)?$") 1227 if (regexec (&plugin->
url_regex, url, 4, matches, 0))
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",
1269 hash_length = matches[1].rm_eo - matches[1].rm_so;
1273 "URL target is %lu bytes, expecting %u\n",
1283 "URL target conversion failed\n");
1287 "Found target `%s' in URL\n",
1291 if (-1 == matches[3].rm_so)
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)
1521 if (conn_info->client_addr->sa_family == AF_INET6)
1528 if (direction ==
_SEND)
1574 ssize_t bytes_read = 0;
1594 msg->
pos += bytes_read;
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",
1721 MHD_add_response_header (response,
1722 "Access-Control-Allow-Origin",
1724 MHD_add_response_header (response,
1725 "Access-Control-Allow-Methods",
1726 "GET, PUT, OPTIONS");
1727 MHD_add_response_header (response,
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);
1780 res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response);
1781 MHD_destroy_response (response);
1789 (*httpSessionCache) =
sc;
1796 MHD_RESPMEM_PERSISTENT);
1797 MHD_add_response_header (response,
1798 MHD_HTTP_HEADER_CONTENT_TYPE,
1801 res = MHD_queue_response (mhd_connection, MHD_HTTP_NOT_FOUND, response);
1802 MHD_destroy_response (response);
1807 if (NULL == (s = sc->
session))
1811 response = MHD_create_response_from_buffer (strlen (
"Thank you!"),
1813 MHD_RESPMEM_PERSISTENT);
1815 MHD_queue_response (mhd_connection, MHD_HTTP_OK, response);
1816 MHD_destroy_response (response);
1822 response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 32 * 1024,
1826 MHD_queue_response (mhd_connection, MHD_HTTP_OK, response);
1827 MHD_destroy_response (response);
1836 "Session %p / Connection %p: Peer `%s' PUT on address `%s' connected\n",
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);
1861 MHD_queue_response (mhd_connection, MHD_HTTP_OK, response);
1862 MHD_destroy_response (response);
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",
1958 "Peer `%s' connection %p, GET on address `%s' disconnected\n",
1971 "Peer `%s' connection %p PUT on address `%s' disconnected\n",
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");
2162 &plugin->crypto_init))
2164 "Using crypto init string `%s'\n",
2165 plugin->crypto_init);
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);
2178 if ((plugin->key == NULL) || (plugin->cert == NULL))
2185 plugin->cert = NULL;
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"));
2209 plugin->cert = NULL;
2211 plugin->crypto_init = NULL;
2218 plugin->key = server_load_file (key_file);
2219 plugin->cert = server_load_file (cert_file);
2222 if ((plugin->key == NULL) || (plugin->cert == NULL))
2226 "No usable TLS certificate found and creating one at `%s/%s' failed!\n"),
2227 key_file, cert_file);
2234 plugin->cert = NULL;
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,
2296 MHD_OPTION_HTTPS_PRIORITIES,
2297 plugin->crypto_init,
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,
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"));
2376 "Failed to start %s IPv4 server component on port %u\n",
2398 "Failed to start %s IPv6 server component on port %u\n",
2414 "%s %s server component started on port %u\n",
2422 msg =
"IPv4 and IPv6";
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;
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;
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;
2684 "Require valid port number for service in configuration!\n"));
2691 "Starting in listen only mode\n");
2701 "BINDTO", &hostname));
2706 if (NULL != hostname)
2709 "Resolving `%s' since that is where `%s' will bind to.\n",
2710 hostname, service_name);
2711 memset (&hints, 0,
sizeof(
struct addrinfo));
2713 hints.ai_family = AF_INET;
2714 if ((0 != (ret = getaddrinfo (hostname, NULL, &hints, &res))) ||
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,
2890 if (NULL != plugin->
nat)
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",
2947 (res ==
GNUNET_YES) ?
"successful" :
"failed");
2962 size_t ext_addr_len;
2971 urlen = strlen (url) + 1;
2974 ext_addr->
urlen = htonl (urlen);
2975 ext_addr_len =
sizeof(
struct HttpAddress) + urlen;
2980 "Notifying transport about external hostname address `%s'\n",
2986 "Enabling SSL verification for external hostname address `%s'\n",
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;
3031 (plugin->
env->
cfg, plugin->
name,
"USE_IPv4"))
3041 _ (
"IPv4 support is %s\n"),
3046 (plugin->
env->
cfg, plugin->
name,
"USE_IPv6"))
3056 _ (
"IPv6 support is %s\n"),
3062 _ (
"Neither IPv4 nor IPv6 are enabled! Fix in configuration\n"));
3070 "PORT", &port)) || (port > 65535))
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,
3098 _ (
"Specific IPv4 address `%s' in configuration file is invalid!\n"),
3108 "Binding to IPv4 address %s\n",
3124 "Binding %s plugin to specific IPv6 address: `%s'\n",
3128 inet_pton (AF_INET6,
3133 _ (
"Specific IPv6 address `%s' in configuration file is invalid!\n"),
3143 "Binding to IPv6 address %s\n",
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"),
3218 "EXTERNAL_HOSTNAME_ONLY"))
3223 "EXTERNAL_HOSTNAME_ONLY");
3230 _ (
"Notifying transport only about hostname `%s'\n"),
3235 "No external hostname configured\n");
3243 max_connections = 128;
3247 _ (
"Maximum number of connections is %u\n"),
3268 if (NULL == api->
cls)
3276 _ (
"Shutting down plugin `%s'\n"),
3288 "Notifying transport to remove address `%s'\n",
3346 _ (
"Shutdown for plugin `%s' complete\n"),
3388 return session->
scope;
3429 "New inbound delay %s\n",
3494 sic (sic_cls, NULL, NULL);
3546 plugin->
name =
"transport-https_server";
3549 plugin->
name =
"transport-http_server";
3562 _ (
"TCP_STEALTH not supported on this platform.\n"));
3574 _ (
"Unable to compile URL regex\n"));
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static int server_receive_mst_cb(void *cls, const struct GNUNET_MessageHeader *message)
Callback called by MessageStreamTokenizer when a message has arrived.
static struct MHD_Daemon * daemon_handle
Handle to the HTTP server as provided by libmicrohttpd.
struct GNUNET_SCHEDULER_Task * server_v6_task
MHD IPv6 task.
size_t address_length
Number of bytes in address.
void * sic_cls
Closure for sic.
Wrapper to manage addresses.
Session is being torn down and about to disappear.
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.
Open the file for reading.
struct GNUNET_TRANSPORT_PluginEnvironment * env
Our environment.
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.
struct ServerRequest * server_recv
Client send handle.
struct sockaddr_in6 * server_addr_v6
IPv6 server socket to bind to.
int verify_external_hostname
Verify external address.
Handle for active NAT registrations.
uint32_t num_bytes_pending
Number of bytes pending transmission for this session.
struct GNUNET_MessageHeader * msg
GNUNET_TRANSPORT_CreateSession get_session
Function that will be called tell the plugin to create a session object.
uint32_t options
Address options see enum HttpAddressOptions
GNUNET_TRANSPORT_AddressToString address_to_string
Function that will be called to convert a binary address to a string (numeric conversion only)...
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.
GNUNET_NAT_AddressClass
Some addresses contain sensitive information or are not suitable for global distribution.
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_TIME_UNIT_ZERO_ABS
Absolute time zero.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
struct GNUNET_SCHEDULER_Task * recv_wakeup_task
Task to wake up client receive handle when receiving is allowed again.
uint64_t rel_value_us
The actual value.
const void * address
Binary representation of the address (plugin-specific).
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
GNUNET_TRANSPORT_SessionStart session_start
Function called by the plugin when a new (incoming) session was created not explicitly created using ...
char * buf
buffer containing data to send
unsigned int msgs_in_queue
Number of messages waiting for transmission to this peer.
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...
void GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc)
Cleans up process structure contents (OS-dependent) and deallocates it.
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.
struct GNUNET_SCHEDULER_Task * timeout_task
Session timeout task.
struct HTTP_Message * msg_tail
previous pointer for double linked list
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.
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.
struct Plugin * plugin
Pointer to the global plugin struct.
static enum GNUNET_NetworkType http_server_plugin_get_network(void *cls, struct GNUNET_ATS_Session *session)
Function obtain the network type for a session.
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.
static void server_wake_up(void *cls)
Wake up an MHD connection which was suspended.
GNUNET_TRANSPORT_TransmitFunction send
Function that the transport service will use to transmit data to another peer.
GNUNET_TRANSPORT_DisconnectPeerFunction disconnect_peer
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
static unsigned long long max_connections
If there are at least this many connections, old ones will be removed.
GNUNET_TRANSPORT_AddressToType get_address_type
Function that will be called to figure if an address is an loopback, LAN, WANT etc.
int is_inbound
GNUNET_YES if this is an inbound connection, GNUNET_NO if this is an outbound connection, GNUNET_SYSERR if connections of this plugin are so fundamentally bidirectional that they have no 'initiator'
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
static void server_v6_run(void *cls)
Call MHD IPv6 to process pending requests and then go back and schedule the next run.
enum GNUNET_TRANSPORT_SessionState state
New state of the session.
unsigned int max_request
Maximum number of sockets the plugin can use Each http request /request connections are two connectio...
size_t pos
amount of data already sent
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
char * protocol
Plugin protocol http, https.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
#define GNUNET_TIME_UNIT_SECONDS
One second.
uint32_t options
My options to be included in the 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...
Message to send using http.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
struct GNUNET_SERVER_MessageStreamTokenizer * msg_tk
Message stream tokenizer for incoming data.
GNUNET_TRANSPORT_SessionMonitorSetup setup_monitor
Function to monitor the sessions managed by the plugin.
struct GNUNET_CONTAINER_MultiPeerMap * sessions
Hash map of open sessions.
Initial session handshake is in progress.
static void server_delete_session(struct GNUNET_ATS_Session *s)
Deletes the session.
struct HTTP_Message * next
next pointer for double linked list
bool suspended
Currently suspended.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_TRANSPORT_SessionInfoCallback sic
Function to call about session status changes.
static void server_session_timeout(void *cls)
Session was idle, so disconnect it.
const struct GNUNET_PeerIdentity * my_identity
Identity of this peer.
static int ret
Return value of the commandline.
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.
static void server_start_report_addresses(struct HTTP_Server_Plugin *plugin)
Ask NAT for addresses.
struct GNUNET_TIME_Absolute timeout
When does this session time out.
struct GNUNET_SCHEDULER_Task * server_v4_task
MHD IPv4 task.
int 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.
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
unsigned int cur_request
Current number of sockets the plugin can use Each http connection are two requests.
#define HTTP_SERVER_NOT_VALIDATED_TIMEOUT
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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.
struct HTTP_Server_Plugin * plugin
Pointer to the global plugin struct.
struct GNUNET_HELLO_Address * address
Address.
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.
struct GNUNET_HELLO_Address * ext_addr
External hostname the plugin can be connected to, can be different to the host's FQDN, used e.g.
struct HTTP_Message * msg_head
next pointer for double linked list
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
const struct GNUNET_HELLO_Address * address
Address used by the session.
unsigned long long bytes_in_queue
Number of bytes waiting for transmission to this peer.
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).
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.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
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...
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
uint32_t num_msg_pending
Number of messages pending transmission for this session.
int direction
_RECV or _SEND
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void * transmit_cont_cls
Closure for transmit_cont.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
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_TIME_Absolute receive_delay
Until when does this plugin refuse to receive to manage staying within the inbound quota...
int in_shutdown
Did we immediately end the session in disconnect_cb.
GNUNET_TRANSPORT_TransmitContinuation transmit_cont
Continuation function to call once the transmission buffer has again space available.
regex_t url_regex
Regex for parsing URLs.
struct MHD_Daemon * mhd_daemon
The MHD daemon.
struct HttpAddressWrapper * next
Linked list next.
GNUNET_TRANSPORT_SessionEnd session_end
Function that must be called by the plugin when a non-NULL session handle stops being valid (is destr...
GNUNET_TRANSPORT_PluginReceiveCallback receive
Function that should be called by the transport plugin whenever a message is received.
struct GNUNET_SCHEDULER_Task * notify_ext_task
Task calling transport service about external address.
struct GNUNET_TIME_Absolute next_receive
Absolute time when to receive data again Used for receive throttling.
static int server_check_ipv6_support(struct HTTP_Server_Plugin *plugin)
Check if IPv6 supported on this system.
GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout
Function that will be called whenever the transport service wants to notify the plugin that a session...
void GNUNET_NETWORK_fdset_destroy(struct GNUNET_NETWORK_FDSet *fds)
Releases the associated memory of an fd set.
static int session_tag_it(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Find a session with a matching tag.
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.
#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...
Information about a plugin's session.
size_t http_common_address_get_size(const struct HttpAddress *addr)
Get the length of an address.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
struct GNUNET_NETWORK_FDSet * GNUNET_NETWORK_fdset_create(void)
Creates an fd set.
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 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.
int server_v4_immediately
The IPv4 server is scheduled to run asap.
void * cls
Closure for the various callbacks.
enum State state
current state of profiling
void * cls
Closure for all of the callbacks.
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
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.).
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
static char * value
Value of the record to add/remove.
GNUNET_TRANSPORT_StringToAddress string_to_address
Function that will be called to convert a string address to binary (numeric conversion only)...
void GNUNET_MST_destroy(struct GNUNET_MessageStreamTokenizer *mst)
Destroys a tokenizer.
static int destroy_session_cb(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Terminate session.
Session handle for connections.
This is an inbound address and cannot be used to initiate an outbound connection to another peer...
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
struct MHD_Daemon * server_v4
MHD IPv4 daemon.
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.
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.
The transport service will pass a pointer to a struct of this type as the first and only argument to ...
static enum GNUNET_NetworkType scope
Which network scope do we belong to?
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.
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.
GNUNET_TRANSPORT_GetNetworkType get_network
Function to obtain the network type for a session.
Handle to a message stream tokenizer.
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 * addr
Address following.
static char * service_name
Option -s: service name (hash to get service descriptor)
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...
collection of IO descriptors
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 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 GNUNET_MessageStreamTokenizer * GNUNET_MST_create(GNUNET_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
void(* GNUNET_TRANSPORT_SessionInfoCallback)(void *cls, struct GNUNET_ATS_Session *session, const struct GNUNET_TRANSPORT_SessionInfo *info)
Function called by the plugin with information about the current sessions managed by the plugin (for ...
static unsigned int http_server_query_keepalive_factor(void *cls)
Function that is called to get the keepalive factor.
static int server_configure_plugin(struct HTTP_Server_Plugin *plugin)
Configure the plugin.
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)...
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.
int 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.
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.
struct GNUNET_TIME_Absolute session_timeout
At what time will this session timeout (unless activity happens)?
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.
int known_to_service
GNUNET_YES if this session is known to the service.
Internal representation of the hash map.
static void server_stop_report_addresses(struct HTTP_Server_Plugin *plugin)
Stop NAT for addresses.
GNUNET_TRANSPORT_UpdateInboundDelay update_inbound_delay
Function that will be called whenever the transport service wants to notify the plugin that the inbou...
struct GNUNET_NAT_Handle * nat
NAT handle & address management.
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
static char * plugin
Solver plugin name as string.
size_t overhead
HTTP/S specific overhead.
struct GNUNET_ATS_Session * res
Set to session matching the tag.
When these flags are set, the child process will inherit stdout and stderr of the parent...
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
Closure for session_tag_it().
void GNUNET_NAT_unregister(struct GNUNET_NAT_Handle *nh)
Stop port redirection and public IP address detection for the given handle.
static void server_log(void *arg, const char *fmt, va_list ap)
Log function called by MHD.
static int destroy_session_shutdown_cb(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Terminate session during shutdown.
struct MHD_Connection * mhd_conn
The MHD connection.
static void add_cors_headers(struct MHD_Response *response)
Add headers to a request indicating that we allow Cross-Origin Resource Sharing.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int size
Size of the "table".
#define LIBGNUNET_PLUGIN_TRANSPORT_INIT
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.
uint32_t urlen
Length of URL located after struct.
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.
enum GNUNET_NetworkType scope
ATS network type.
uint32_t tag
Unique HTTP/S connection tag for this connection.
#define HTTP_ERROR_RESPONSE
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...
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
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...
struct GNUNET_MQ_Envelope * env
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".
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
unsigned int external_only
Notify transport only about external address.
static struct GNUNET_FS_SearchContext * sc
static void server_notify_external_hostname(void *cls)
Notify server about our external hostname.
static struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run on timeout.
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
struct sockaddr_in * server_addr_v4
IPv4 server socket to bind to.
#define MHD_RESULT
Data type to use for functions return an "MHD result".
Enable TCP Stealth-style port knocking.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
static int server_start(struct HTTP_Server_Plugin *plugin)
Start the HTTP server.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
struct HttpAddress * address
An address we are using.
Allow multiple values with the same key.
#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...
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.
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).
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.
This is just an update about the session, the state did not change.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
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.
uint16_t use_ipv6
use IPv6
GNUNET_TRANSPORT_QueryKeepaliveFactorFunction query_keepalive_factor
Function that is used to query keepalive factor.
The identity of the host (wraps the signing key of the peer).
No additional information.
uint32_t tag
Tag we are looking for.
Information we keep with MHD for an HTTP request.
static char * hostname
Our hostname; we give this to all the peers we start.
#define HTTP_SERVER_SESSION_TIMEOUT
int GNUNET_OS_process_wait(struct GNUNET_OS_Process *proc)
Wait for a process to terminate.
static void http_server_plugin_setup_monitor(void *cls, GNUNET_TRANSPORT_SessionInfoCallback sic, void *sic_cls)
Begin monitoring sessions of a plugin.
size_t http_common_cmp_addresses(const void *addr1, size_t addrlen1, const void *addr2, size_t addrlen2)
Compare addr1 to addr2.
struct GNUNET_ATS_Session * session
The session this server connection belongs to.
static uint16_t port
Port number.
int connected
For PUT requests: Is this the first or last callback with size 0 For GET requests: Have we sent a mes...
Encapsulation of all of the state of the plugin.
struct GNUNET_PeerIdentity target
To whom are we talking to.
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.
An address for communicating with a peer.
static void server_disconnect_cb(void *cls, struct MHD_Connection *connection, void **httpSessionCache)
Callback from MHD when a connection disconnects.
struct HttpAddress * http_common_address_from_socket(const char *protocol, const struct sockaddr *addr, socklen_t addrlen)
Create a HTTP address from a socketaddr.
struct GNUNET_STATISTICS_Handle * stats
Handle for reporting statistics.
uint16_t use_ipv4
use IPv4
#define GNUNET_log(kind,...)
The session was created (first call for each session object).
Entry in list of pending tasks.
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...
struct HTTP_Message * prev
previous pointer for double linked list
uint32_t options
Options requested by peer.
int server_send(struct GNUNET_ATS_Session *s, struct HTTP_Message *msg)
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".
struct HttpAddressWrapper * addr_tail
IPv4 addresses DLL tail.
static struct MHD_Response * response
Our canonical response.
GNUNET_TRANSPORT_AddressNotification notify_address
Function that must be called by each plugin to notify the transport service about the addresses under...
Verify X509 server certificate, it should be valid.
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 ServerRequest * server_send
Client send handle.
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.
int server_v6_immediately
The IPv6 server is scheduled to run asap.
GNUNET_TRANSPORT_AddressPrettyPrinter address_pretty_printer
Function to pretty-print addresses.
Time for absolute times used by GNUnet, in microseconds.
static void server_reschedule_session_timeout(struct GNUNET_ATS_Session *s)
Increment session timeout due to activity session s.
struct HttpAddressWrapper * prev
Linked list previous.
static void server_v4_run(void *cls)
Call MHD IPv4 to process pending requests and then go back and schedule the next run.
Run with the default priority (normal P2P operations).
struct HttpAddressWrapper * addr_head
IPv4 addresses DLL head.
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_SessionState
Possible states of a session in a plugin.
#define LIBGNUNET_PLUGIN_TRANSPORT_DONE
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.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
static char * address
GNS address for this phone.
Handle used to access files (and pipes).
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
int GNUNET_NETWORK_socket_close(struct GNUNET_NETWORK_Handle *desc)
Close a socket.
#define GNUNET_HELLO_address_free(addr)
Free an address.
HTTP addresses including a full URI.
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.
static void server_reschedule(struct HTTP_Server_Plugin *plugin, struct MHD_Daemon *server, int now)
Reschedule the execution of both IPv4 and IPv6 server.
char * external_hostname
External address.
#define GNUNET_malloc(size)
Wrapper around malloc.
struct MHD_Daemon * server_v6
MHD IPv4 daemon.
size_t addrlen
Length of the address.
int peer_id_length
Length of peer id.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_CRYPTO_EddsaPublicKey public_key
GNUNET_TRANSPORT_GetNetworkTypeForAddress get_network_for_address
Function to obtain the network type for an address.
static MHD_RESULT server_accept_cb(void *cls, const struct sockaddr *addr, socklen_t addr_len)
Check if incoming connection is accepted.
struct GNUNET_NETWORK_Handle * GNUNET_NETWORK_socket_create(int domain, int type, int protocol)
Create a new socket.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.