functionality shared between http(s)client plugins More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_transport_plugin.h"
#include "plugin_transport_http_common.h"
#include "gnunet_resolver_service.h"
Go to the source code of this file.
Data Structures | |
struct | PrettyPrinterContext |
Closure for append_port(). More... | |
Functions | |
static void | http_clean_splitted (struct SplittedHTTPAddress *spa) |
struct SplittedHTTPAddress * | http_split_address (const char *addr) |
Split an HTTP address into protocol, hostname, port and path components. More... | |
static const char * | http_common_plugin_dnsresult_to_address (const char *plugin, const struct SplittedHTTPAddress *saddr, uint32_t options, const char *dnsresult) |
Function called for a quick conversion of the binary address to a numeric address. More... | |
static void | http_common_dns_reverse_lookup_cb (void *cls, const char *hostname) |
static int | http_common_dns_reverse_lookup (const struct sockaddr *sockaddr, socklen_t sockaddr_len, const char *type, struct SplittedHTTPAddress *saddr, uint32_t options, struct GNUNET_TIME_Relative timeout, GNUNET_TRANSPORT_AddressStringCallback asc, void *asc_cls) |
static void | http_common_dns_ip_lookup_cb (void *cls, const struct sockaddr *addr, socklen_t addrlen) |
static int | http_common_dns_ip_lookup (const char *name, const char *type, struct SplittedHTTPAddress *saddr, uint32_t options, struct GNUNET_TIME_Relative timeout, GNUNET_TRANSPORT_AddressStringCallback asc, void *asc_cls) |
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. More... | |
const char * | http_common_plugin_address_to_url (void *cls, const void *addr, size_t addrlen) |
FIXME. More... | |
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. More... | |
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. More... | |
struct HttpAddress * | http_common_address_from_socket (const char *protocol, const struct sockaddr *addr, socklen_t addrlen) |
Create a HTTP address from a socketaddr. More... | |
struct sockaddr * | http_common_socket_from_address (const void *addr, size_t addrlen, int *res) |
Create a socketaddr from a HTTP address. More... | |
size_t | http_common_address_get_size (const struct HttpAddress *addr) |
Get the length of an address. More... | |
size_t | http_common_cmp_addresses (const void *addr1, size_t addrlen1, const void *addr2, size_t addrlen2) |
Compare addr1 to addr2. More... | |
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. More... | |
Variables | |
static struct PrettyPrinterContext * | dll_ppc_head |
Head of PPC list. More... | |
static struct PrettyPrinterContext * | dll_ppc_tail |
Tail of PPC list. More... | |
functionality shared between http(s)client plugins
functionality shared by http client and server transport service plugin
Definition in file plugin_transport_http_common.c.
|
static |
Definition at line 33 of file plugin_transport_http_common.c.
References GNUNET_free, SplittedHTTPAddress::host, SplittedHTTPAddress::path, and SplittedHTTPAddress::protocol.
Referenced by http_common_dns_ip_lookup_cb(), http_common_dns_reverse_lookup_cb(), http_common_plugin_address_pretty_printer(), and http_common_socket_from_address().
struct SplittedHTTPAddress* http_split_address | ( | const char * | addr | ) |
Split an HTTP address into protocol, hostname, port and path components.
Definition at line 46 of file plugin_transport_http_common.c.
References GNUNET_break, GNUNET_free, GNUNET_new, GNUNET_strdup, SplittedHTTPAddress::host, HTTP_DEFAULT_PORT, HTTPS_DEFAULT_PORT, SplittedHTTPAddress::path, SplittedHTTPAddress::port, and SplittedHTTPAddress::protocol.
Referenced by http_common_plugin_address_pretty_printer(), and http_common_socket_from_address().
|
static |
Function called for a quick conversion of the binary address to a numeric address.
Note that the caller must not free the address and that the next call to this function is allowed to override the address again.
plugin | the name of the plugin |
saddr | the split http address |
options | address options |
dnsresult | dns name to include in address |
Definition at line 256 of file plugin_transport_http_common.c.
References GNUNET_asprintf(), GNUNET_break, GNUNET_free, GNUNET_memcpy, options, SplittedHTTPAddress::path, plugin, SplittedHTTPAddress::port, SplittedHTTPAddress::protocol, res, and PrettyPrinterContext::saddr.
Referenced by http_common_dns_ip_lookup_cb(), and http_common_dns_reverse_lookup_cb().
|
static |
Definition at line 280 of file plugin_transport_http_common.c.
References PrettyPrinterContext::asc, PrettyPrinterContext::asc_cls, dll_ppc_head, dll_ppc_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, hostname, http_clean_splitted(), http_common_plugin_dnsresult_to_address(), PrettyPrinterContext::options, PrettyPrinterContext::plugin, PrettyPrinterContext::saddr, and PrettyPrinterContext::success.
Referenced by http_common_dns_reverse_lookup().
|
static |
Definition at line 306 of file plugin_transport_http_common.c.
References PrettyPrinterContext::asc, PrettyPrinterContext::asc_cls, dll_ppc_head, dll_ppc_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_free, GNUNET_new, GNUNET_OK, GNUNET_RESOLVER_hostname_get(), GNUNET_strdup, GNUNET_SYSERR, GNUNET_YES, http_common_dns_reverse_lookup_cb(), options, PrettyPrinterContext::options, PrettyPrinterContext::plugin, PrettyPrinterContext::resolver_handle, PrettyPrinterContext::saddr, timeout, and type.
Referenced by http_common_plugin_address_pretty_printer().
|
static |
Definition at line 344 of file plugin_transport_http_common.c.
References PrettyPrinterContext::asc, PrettyPrinterContext::asc_cls, dll_ppc_head, dll_ppc_tail, GNUNET_a2s(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, http_clean_splitted(), http_common_plugin_dnsresult_to_address(), PrettyPrinterContext::options, PrettyPrinterContext::plugin, PrettyPrinterContext::saddr, and PrettyPrinterContext::success.
Referenced by http_common_dns_ip_lookup().
|
static |
Definition at line 375 of file plugin_transport_http_common.c.
References PrettyPrinterContext::asc, PrettyPrinterContext::asc_cls, dll_ppc_head, dll_ppc_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_free, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_RESOLVER_ip_get(), GNUNET_strdup, GNUNET_SYSERR, http_common_dns_ip_lookup_cb(), name, options, PrettyPrinterContext::options, PrettyPrinterContext::plugin, PrettyPrinterContext::resolver_handle, PrettyPrinterContext::saddr, PrettyPrinterContext::success, timeout, and type.
Referenced by http_common_plugin_address_pretty_printer().
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.
cls | closure |
type | name of the transport that generated the address |
addr | one of the addresses of the host, NULL for the last address the specific address format depends on the transport |
addrlen | length of addr |
numeric | should (IP) addresses be displayed in numeric form? |
timeout | after how long should we give up? |
asc | function to call on each string |
asc_cls | closure for asc |
Definition at line 411 of file plugin_transport_http_common.c.
References HttpAddress::addr, address, GNUNET_break, GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, SplittedHTTPAddress::host, http_clean_splitted(), http_common_address_get_size(), http_common_dns_ip_lookup(), http_common_dns_reverse_lookup(), http_common_plugin_address_to_string(), http_common_socket_from_address(), http_split_address(), numeric, res, ret, timeout, and type.
Referenced by libgnunet_plugin_transport_http_client_init().
const char* http_common_plugin_address_to_url | ( | void * | cls, |
const void * | addr, | ||
size_t | addrlen | ||
) |
FIXME.
Definition at line 552 of file plugin_transport_http_common.c.
References HttpAddress::addr, address, GNUNET_break, GNUNET_memcpy, and http_common_address_get_size().
Referenced by client_connect().
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.
Note that the caller must not free the address and that the next call to this function is allowed to override the address again.
plugin | name of the plugin |
addr | binary address |
addrlen | length of addr |
Definition at line 587 of file plugin_transport_http_common.c.
References HttpAddress::addr, address, GNUNET_asprintf(), GNUNET_assert, GNUNET_break, GNUNET_free, GNUNET_memcpy, http_common_address_get_size(), plugin, and res.
Referenced by client_connect(), client_receive_mst_cb(), http_client_plugin_address_to_string(), http_client_plugin_get_session(), http_common_plugin_address_pretty_printer(), http_server_plugin_address_to_string(), libgnunet_plugin_transport_http_client_done(), server_access_cb(), server_add_address(), server_disconnect_cb(), server_lookup_connection(), server_receive_mst_cb(), and server_remove_address().
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.
cls | closure (struct Plugin* ) |
addr | string address |
addrlen | length of addr |
buf | location to store the buffer If the function returns GNUNET_SYSERR, its contents are undefined. |
added | length of created address |
Definition at line 621 of file plugin_transport_http_common.c.
References HttpAddress::addr, address, GNUNET_break, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, options, HttpAddress::options, plugin, and HttpAddress::urlen.
Referenced by libgnunet_plugin_transport_http_client_init().
struct HttpAddress* http_common_address_from_socket | ( | const char * | protocol, |
const struct sockaddr * | addr, | ||
socklen_t | addrlen | ||
) |
Create a HTTP address from a socketaddr.
protocol | protocol |
addr | sockaddr * address |
addrlen | length of the addr |
struct HttpAddress
derived from addr Definition at line 688 of file plugin_transport_http_common.c.
References HttpAddress::addr, address, GNUNET_a2s(), GNUNET_asprintf(), GNUNET_free, GNUNET_malloc, GNUNET_memcpy, HTTP_OPTIONS_NONE, len, and res.
Referenced by server_add_address(), server_lookup_connection(), and server_remove_address().
struct sockaddr* http_common_socket_from_address | ( | const void * | addr, |
size_t | addrlen, | ||
int * | res | ||
) |
Create a socketaddr from a HTTP address.
addr | a sockaddr * address |
addrlen | length of the addr |
res | the result: GNUNET_SYSERR, invalid input, GNUNET_YES: could convert to ip, GNUNET_NO: valid input but could not convert to ip (hostname?) |
Definition at line 723 of file plugin_transport_http_common.c.
References HttpAddress::addr, GNUNET_asprintf(), GNUNET_break, GNUNET_free, GNUNET_new, GNUNET_NO, GNUNET_STRINGS_to_address_ip(), GNUNET_SYSERR, GNUNET_YES, SplittedHTTPAddress::host, http_clean_splitted(), http_split_address(), SplittedHTTPAddress::port, and HttpAddress::urlen.
Referenced by http_client_plugin_get_session(), and http_common_plugin_address_pretty_printer().
size_t http_common_address_get_size | ( | const struct HttpAddress * | addr | ) |
Get the length of an address.
addr | address |
Definition at line 806 of file plugin_transport_http_common.c.
References HttpAddress::addr, and HttpAddress::urlen.
Referenced by http_common_plugin_address_pretty_printer(), http_common_plugin_address_to_string(), http_common_plugin_address_to_url(), server_add_address(), server_lookup_connection(), and server_remove_address().
size_t http_common_cmp_addresses | ( | const void * | addr1, |
size_t | addrlen1, | ||
const void * | addr2, | ||
size_t | addrlen2 | ||
) |
Compare addr1 to addr2.
addr1 | address1 |
addrlen1 | address 1 length |
addr2 | address2 |
addrlen2 | address 2 length |
Definition at line 822 of file plugin_transport_http_common.c.
References GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, and HttpAddress::urlen.
Referenced by http_server_plugin_address_suggested(), and server_remove_address().
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.
env | the environment |
address | the address |
Definition at line 822 of file plugin_transport_http_common.c.
|
static |
Head of PPC list.
Definition at line 236 of file plugin_transport_http_common.c.
Referenced by http_common_dns_ip_lookup(), http_common_dns_ip_lookup_cb(), http_common_dns_reverse_lookup(), and http_common_dns_reverse_lookup_cb().
|
static |
Tail of PPC list.
Definition at line 241 of file plugin_transport_http_common.c.
Referenced by http_common_dns_ip_lookup(), http_common_dns_ip_lookup_cb(), http_common_dns_reverse_lookup(), and http_common_dns_reverse_lookup_cb().