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];
266 dnsresult, saddr->
port, saddr->
path);
267 if (strlen (res) + 1 < 500)
284 if (NULL != hostname)
307 socklen_t sockaddr_len,
345 const struct sockaddr *addr,
436 struct sockaddr *sock_addr;
451 addr_str = (
char *) &address[1];
452 if (addr_str[ntohl (address->
urlen) - 1] !=
'\0')
495 asc (asc_cls, NULL, GNUNET_OK);
522 (AF_INET == sock_addr->sa_family)
523 ?
sizeof(
struct sockaddr_in)
524 :
sizeof(
struct sockaddr_in6),
543 asc (asc_cls, NULL, GNUNET_OK);
570 static char rbuf[1024];
572 const char *addr_str;
589 addr_str = (
char *) &address[1];
590 if (addr_str[ntohl (address->
urlen) - 1] !=
'\0')
595 ntohl (address->
urlen));
616 static char rbuf[1024];
618 const char *addr_str;
628 addr_str = (
char *) &address[1];
629 if (addr_str[ntohl (address->
urlen) - 1] !=
'\0')
633 if (strlen (res) + 1 < 500)
675 if ((NULL == addr) || (addrlen == 0))
680 if (
'\0' != addr[addrlen - 1])
685 if (strlen (addr) != addrlen - 1)
691 optionstr = strchr (plugin,
'.');
692 if (NULL == optionstr)
700 options = atol (optionstr);
701 address = strchr (optionstr,
'.');
710 urlen = strlen (address) + 1;
714 a->
urlen = htonl (urlen);
734 const struct sockaddr *
addr,
746 len = strlen (res) + 1;
749 address->
urlen = htonl (len);
774 struct sockaddr_storage *s;
795 urlen = ntohl (ha->
urlen);
806 if (((
char *) addr)[addrlen - 1] !=
'\0')
828 else if ((AF_INET != s->ss_family) && (AF_INET6 != s->ss_family))
840 return (
struct sockaddr *) s;
853 return sizeof(
struct HttpAddress) + ntohl (addr->urlen);
872 const char *a1 = addr1;
873 const char *a2 = addr2;
884 if (a1[addrlen1 - 1] !=
'\0')
891 if (a2[addrlen2 - 1] !=
'\0')
894 if (addrlen1 != addrlen2)
899 if (0 == strcmp ((
const char *) &ha1[1], (
const char *) &ha2[1]))
931 if (AF_INET == sa->sa_family)
933 salen =
sizeof(
struct sockaddr_in);
935 else if (AF_INET6 == sa->sa_family)
937 salen =
sizeof(
struct sockaddr_in6);
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
size_t address_length
Number of bytes in address.
char * plugin
Plugin String.
GNUNET_TRANSPORT_AddressStringCallback asc
Function to call with the result.
static void http_common_dns_reverse_lookup_cb(void *cls, const char *hostname)
uint32_t options
Address options see enum HttpAddressOptions
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.
struct SplittedHTTPAddress * saddr
Splitted Address.
const char * http_common_plugin_address_to_url(void *cls, const void *addr, size_t addrlen)
FIXME.
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.
GNUNET_TRANSPORT_AddressToType get_address_type
Function that will be called to figure if an address is an loopback, LAN, WANT etc.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_RESOLVER_RequestHandle * resolver_handle
Resolver handle.
struct SplittedHTTPAddress * http_split_address(const char *addr)
Split an HTTP address into protocol, hostname, port and path components.
Closure for append_port().
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int ret
Return value of the commandline.
static int numeric
Option -n.
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.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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.
void * asc_cls
Clsoure for asc.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
int sucess
Was conversion successful.
#define HTTP_DEFAULT_PORT
size_t http_common_address_get_size(const struct HttpAddress *addr)
Get the length of an address.
void * cls
Closure for the various callbacks.
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
Representation of HTTP URL split into its components.
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...
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 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.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
The transport service will pass a pointer to a struct of this type as the first and only argument to ...
struct PrettyPrinterContext * prev
DLL.
void * addr
Address following.
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.
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 PrettyPrinterContext * dll_ppc_tail
Tail of PPC list.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
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)
uint32_t urlen
Length of URL located after struct.
static void http_common_dns_ip_lookup_cb(void *cls, const struct sockaddr *addr, socklen_t addrlen)
Handle to a request given to the resolver.
struct GNUNET_MQ_Envelope * env
struct PrettyPrinterContext * next
DLL.
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_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.
static char * hostname
Our hostname; we give this to all the peers we start.
size_t http_common_cmp_addresses(const void *addr1, size_t addrlen1, const void *addr2, size_t addrlen2)
Compare addr1 to addr2.
struct sockaddr * http_common_socket_from_address(const void *addr, size_t addrlen, int *res)
Create a socketaddr from a HTTP address.
uint32_t options
Address options.
An address for communicating with a peer.
struct HttpAddress * http_common_address_from_socket(const char *protocol, const struct sockaddr *addr, socklen_t addrlen)
Create a HTTP address from a socketaddr.
Entry in list of pending tasks.
static struct PrettyPrinterContext * dll_ppc_head
Head of PPC list.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
static char * address
GNS address for this phone.
HTTP addresses including a full URI.
int 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.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define HTTPS_DEFAULT_PORT
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
static void http_clean_splitted(struct SplittedHTTPAddress *spa)
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...