50 char *protocol_start = NULL;
51 char *host_start = NULL;
53 char *port_start = NULL;
54 char *path_start = NULL;
61 host_start = strstr (src,
"://");
62 if (NULL == host_start)
71 host_start += strlen (
"://");
72 if (strlen (host_start) == 0)
81 path_start = strchr (host_start,
'/');
82 if (NULL != path_start)
90 if (strlen (host_start) < 1)
99 if (NULL != (port_start = strrchr (host_start,
':')))
102 if (NULL != (v6_end = strchr (host_start,
']')))
104 if (v6_end < port_start)
107 port_start[0] =
'\0';
109 sp->
port = atoi (port_start);
110 if ((0 == sp->
port) || (65535 < sp->
port))
122 if (0 == strcmp (sp->
protocol,
"https"))
124 else if (0 == strcmp (sp->
protocol,
"http"))
131 port_start[0] =
'\0';
133 sp->
port = atoi (port_start);
134 if ((0 == sp->
port) || (65535 < sp->
port))
147 if (0 == strcmp (sp->
protocol,
"https"))
149 else if (0 == strcmp (sp->
protocol,
"http"))
161 if (strlen (host_start) > 0)
260 const char *dnsresult)
262 static char rbuf[1024];
267 if (strlen (
res) + 1 < 500)
307 socklen_t sockaddr_len,
345 const struct sockaddr *addr,
422 struct sockaddr *sock_addr;
437 addr_str = (
char *) &
address[1];
438 if (addr_str[ntohl (
address->urlen) - 1] !=
'\0')
508 (AF_INET == sock_addr->sa_family)
509 ?
sizeof(
struct sockaddr_in)
510 :
sizeof(
struct sockaddr_in6),
556 static char rbuf[1024];
558 const char *addr_str;
575 addr_str = (
char *) &
address[1];
576 if (addr_str[ntohl (
address->urlen) - 1] !=
'\0')
591 static char rbuf[1024];
593 const char *addr_str;
603 addr_str = (
char *) &
address[1];
604 if (addr_str[ntohl (
address->urlen) - 1] !=
'\0')
608 if (strlen (
res) + 1 < 500)
638 if ((NULL ==
addr) || (addrlen == 0))
643 if (
'\0' !=
addr[addrlen - 1])
648 if (strlen (
addr) != addrlen - 1)
654 optionstr = strchr (
plugin,
'.');
655 if (NULL == optionstr)
664 address = strchr (optionstr,
'.');
689 const struct sockaddr *
addr,
729 struct sockaddr_storage *s;
761 if (((
char *)
addr)[addrlen - 1] !=
'\0')
783 else if ((AF_INET != s->ss_family) && (AF_INET6 != s->ss_family))
795 return (
struct sockaddr *) s;
827 const char *a1 = addr1;
828 const char *a2 = addr2;
839 if (a1[addrlen1 - 1] !=
'\0')
846 if (a2[addrlen2 - 1] !=
'\0')
849 if (addrlen1 != addrlen2)
854 if (0 == strcmp ((
const char *) &ha1[1], (
const char *) &ha2[1]))
886 if (AF_INET == sa->sa_family)
888 salen =
sizeof(
struct sockaddr_in);
890 else if (AF_INET6 == sa->sa_family)
892 salen =
sizeof(
struct sockaddr_in6);
894 net_type =
env->get_address_type (
env->cls,
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MQ_Envelope * env
static int ret
Return value of the commandline.
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
struct TestcasePlugin * plugin
The process handle to the testbed service.
static char * address
GNS address for this phone.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static char * hostname
Our hostname; we give this to all the peers we start.
static int numeric
Option -n.
Functions related to doing DNS lookups.
Transport service plugin API.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#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.
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).
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.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
@ GNUNET_NT_UNSPECIFIED
Category of last resort.
struct GNUNET_RESOLVER_RequestHandle * GNUNET_RESOLVER_ip_get(const char *hostname, int af, struct GNUNET_TIME_Relative timeout, GNUNET_RESOLVER_AddressCallback callback, void *callback_cls)
Convert a string to one or more IP addresses.
struct GNUNET_RESOLVER_RequestHandle * GNUNET_RESOLVER_hostname_get(const struct sockaddr *sa, socklen_t salen, int do_resolve, struct GNUNET_TIME_Relative timeout, GNUNET_RESOLVER_HostnameCallback callback, void *cls)
Perform a reverse DNS lookup.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_to_address_ip(const char *addr, uint16_t addrlen, struct sockaddr_storage *r_buf)
Tries to convert addr string to an IP (v4 or v6) address.
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.
static struct PrettyPrinterContext * dll_ppc_head
Head of PPC list.
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.
static void http_clean_splitted(struct SplittedHTTPAddress *spa)
static struct PrettyPrinterContext * dll_ppc_tail
Tail of PPC list.
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)
static void http_common_dns_ip_lookup_cb(void *cls, const struct sockaddr *addr, socklen_t addrlen)
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.
static void http_common_dns_reverse_lookup_cb(void *cls, const char *hostname)
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.
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)
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.
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.
#define HTTP_DEFAULT_PORT
#define HTTPS_DEFAULT_PORT
@ HTTP_OPTIONS_NONE
No bits set.
An address for communicating with a peer.
Handle to a request given to the resolver.
Entry in list of pending tasks.
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
Closure for append_port().
struct GNUNET_RESOLVER_RequestHandle * resolver_handle
Resolver handle.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
char * plugin
Plugin String.
struct SplittedHTTPAddress * saddr
Split Address.
void * asc_cls
Clsoure for asc.
GNUNET_TRANSPORT_AddressStringCallback asc
Function to call with the result.
int success
Was conversion successful.
uint32_t options
Address options.
struct PrettyPrinterContext * prev
DLL.
struct PrettyPrinterContext * next
DLL.
Representation of HTTP URL split into its components.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model