GNUnet  0.20.0
plugin_transport_http_common.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2002-2014 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
26 #include "platform.h"
27 #include "gnunet_common.h"
29 
33 #define TESTING GNUNET_NO
34 
35 #if TESTING
36 #define HTTP_SERVER_NOT_VALIDATED_TIMEOUT GNUNET_TIME_relative_multiply ( \
37  GNUNET_TIME_UNIT_SECONDS, 3)
38 #define HTTP_CLIENT_NOT_VALIDATED_TIMEOUT GNUNET_TIME_relative_multiply ( \
39  GNUNET_TIME_UNIT_SECONDS, 3)
40 #define HTTP_CLIENT_SESSION_TIMEOUT GNUNET_TIME_relative_multiply ( \
41  GNUNET_TIME_UNIT_SECONDS, 7)
42 #define SERVER_SESSION_TIMEOUT GNUNET_TIME_relative_multiply ( \
43  GNUNET_TIME_UNIT_SECONDS, 7)
44 #define TIMEOUT_LOG GNUNET_ERROR_TYPE_DEBUG
45 
46 #else
47 
48 #if BUILD_HTTPS
49 #define PROTOCOL "https"
50 #else
51 #define PROTOCOL "http"
52 #endif
53 
54 #define HTTP_SERVER_NOT_VALIDATED_TIMEOUT GNUNET_TIME_relative_multiply ( \
55  GNUNET_TIME_UNIT_SECONDS, 15)
56 #define HTTP_CLIENT_NOT_VALIDATED_TIMEOUT GNUNET_TIME_relative_multiply ( \
57  GNUNET_TIME_UNIT_SECONDS, 15)
58 #define HTTP_CLIENT_SESSION_TIMEOUT GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
59 #define HTTP_SERVER_SESSION_TIMEOUT GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT
60 #define TIMEOUT_LOG GNUNET_ERROR_TYPE_DEBUG
61 
62 #endif
63 
64 #define HTTP_DEFAULT_PORT 80
65 #define HTTPS_DEFAULT_PORT 443
66 
71 {
76 
83 
88 };
89 
90 
92 
96 struct HttpAddress
97 {
103 
108 };
109 
111 
116 {
117  char *protocol;
118  char *host;
119  char *path;
120  int port;
121 };
122 
123 
128 struct SplittedHTTPAddress *
129 http_split_address (const char *addr);
130 
131 
146 void
148  const char *type,
149  const void *addr,
150  size_t addrlen,
151  int numeric,
154  asc,
155  void *asc_cls);
156 
157 
169 const char *
171  const void *addr,
172  size_t addrlen);
173 
174 
187 int
189  const char *addr,
190  uint16_t addrlen,
191  void **buf,
192  size_t *added);
193 
194 
203 struct HttpAddress *
204 http_common_address_from_socket (const char *protocol,
205  const struct sockaddr *addr,
206  socklen_t addrlen);
207 
208 
220 struct sockaddr *
221 http_common_socket_from_address (const void *addr,
222  size_t addrlen,
223  int *res);
224 
225 
226 const char *
228  const void *addr,
229  size_t addrlen);
230 
231 
238 size_t
239 http_common_address_get_size (const struct HttpAddress *addr);
240 
241 
251 size_t
252 http_common_cmp_addresses (const void *addr1,
253  size_t addrlen1,
254  const void *addr2,
255  size_t addrlen2);
256 
257 
268  const struct
270 
271 
272 /* end of plugin_transport_http_common.h */
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
Definition: gnunet-abd.c:61
static int res
struct TestcasePlugin * plugin
The process handle to the testbed service.
static char * address
GNS address for this phone.
static char buf[2048]
static int numeric
Option -n.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
Transport service plugin API.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
#define GNUNET_PACKED
gcc-ism to get packed structs.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Definition: gnunet_nt_lib.h:39
void(* GNUNET_TRANSPORT_AddressStringCallback)(void *cls, const char *address, int res)
Function called by the pretty printer for the resolved address for each human-readable address obtain...
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.
HttpAddressOptions
Bits in the options field of HTTP addresses.
@ HTTP_OPTIONS_NONE
No bits set.
@ HTTP_OPTIONS_VERIFY_CERTIFICATE
Verify X509 server certificate, it should be valid.
@ HTTP_OPTIONS_TCP_STEALTH
Enable TCP Stealth-style port knocking.
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.
struct SplittedHTTPAddress * http_split_address(const char *addr)
Split an HTTP address into protocol, hostname, port and path components.
const char * http_common_plugin_address_to_url(void *cls, const void *addr, size_t addrlen)
FIXME.
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.
struct sockaddr * http_common_socket_from_address(const void *addr, size_t addrlen, int *res)
Create a socketaddr from a HTTP address.
An address for communicating with a peer.
Time for relative time used by GNUnet, in microseconds.
The transport service will pass a pointer to a struct of this type as the first and only argument to ...
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
Representation of HTTP URL split into its components.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model