GNUnet  0.10.x
plugin_transport_http_common.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2002-2013 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  */
20 
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
31 
32 static void
34 {
35  if (NULL != spa)
36  {
41  }
42 }
43 
44 
45 struct SplittedHTTPAddress *
46 http_split_address (const char * addr)
47 {
48  struct SplittedHTTPAddress *sp;
49  char *src = GNUNET_strdup (addr);
50  char *protocol_start = NULL;
51  char *host_start = NULL;
52  char *v6_end = NULL;
53  char *port_start = NULL;
54  char *path_start = NULL;
55  protocol_start = src;
56 
57  sp = GNUNET_new (struct SplittedHTTPAddress);
58  /* Address string consists of protocol://host[:port]path*/
59 
60  host_start = strstr (src, "://");
61  if (NULL == host_start)
62  {
63  GNUNET_free(src);
64  GNUNET_free(sp);
65  return NULL ;
66  }
67  host_start[0] = '\0';
68  sp->protocol = GNUNET_strdup (protocol_start);
69 
70  host_start += strlen ("://");
71  if (strlen (host_start) == 0)
72  {
73  GNUNET_free(src);
74  GNUNET_free(sp->protocol);
75  GNUNET_free(sp);
76  return NULL ;
77  }
78 
79  /* Find path start */
80  path_start = strchr (host_start, '/');
81  if (NULL != path_start)
82  {
83  sp->path = GNUNET_strdup (path_start);
84  path_start[0] = '\0';
85  }
86  else
87  sp->path = GNUNET_strdup ("");
88 
89  if (strlen (host_start) < 1)
90  {
91  GNUNET_free(src);
92  GNUNET_free(sp->protocol);
93  GNUNET_free(sp->path);
94  GNUNET_free(sp);
95  return NULL ;
96  }
97 
98  if (NULL != (port_start = strrchr (host_start, ':')))
99  {
100  /* *We COULD have a port, but also an IPv6 address! */
101  if (NULL != (v6_end = strchr (host_start, ']')))
102  {
103  if (v6_end < port_start)
104  {
105  /* IPv6 address + port */
106  port_start[0] = '\0';
107  port_start++;
108  sp->port = atoi (port_start);
109  if ((0 == sp->port) || (65535 < sp->port))
110  {
111  GNUNET_free(src);
112  GNUNET_free(sp->protocol);
113  GNUNET_free(sp->path);
114  GNUNET_free(sp);
115  return NULL ;
116  }
117  }
118  else
119  {
120  /* IPv6 address + no port */
121  if (0 == strcmp (sp->protocol, "https"))
122  sp->port = HTTPS_DEFAULT_PORT;
123  else if (0 == strcmp (sp->protocol, "http"))
124  sp->port = HTTP_DEFAULT_PORT;
125  }
126  }
127  else
128  {
129  /* No IPv6 address */
130  port_start[0] = '\0';
131  port_start++;
132  sp->port = atoi (port_start);
133  if ((0 == sp->port) || (65535 < sp->port))
134  {
135  GNUNET_free(src);
136  GNUNET_free(sp->protocol);
137  GNUNET_free(sp->path);
138  GNUNET_free(sp);
139  return NULL ;
140  }
141  }
142  }
143  else
144  {
145  /* No ':' as port separator, default port for protocol */
146  if (0 == strcmp (sp->protocol, "https"))
147  sp->port = HTTPS_DEFAULT_PORT;
148  else if (0 == strcmp (sp->protocol, "http"))
149  sp->port = HTTP_DEFAULT_PORT;
150  else
151  {
152  GNUNET_break(0);
153  GNUNET_free(src);
154  GNUNET_free(sp->protocol);
155  GNUNET_free(sp->path);
156  GNUNET_free(sp);
157  return NULL ;
158  }
159  }
160  if (strlen (host_start) > 0)
161  sp->host = GNUNET_strdup (host_start);
162  else
163  {
164  GNUNET_break(0);
165  GNUNET_free(src);
166  GNUNET_free(sp->protocol);
167  GNUNET_free(sp->path);
168  GNUNET_free(sp);
169  return NULL ;
170  }
171  GNUNET_free(src);
172  return sp;
173 }
174 
179 {
184 
189 
194 
199 
203  void *asc_cls;
204 
209 
214 
218  char *plugin;
219 
223  int sucess;
224 
228  uint32_t options;
229 };
230 
235 
240 
253 static const char *
255  const struct SplittedHTTPAddress *saddr,
256  uint32_t options,
257  const char *dnsresult)
258 {
259  static char rbuf[1024];
260  char *res;
261 
262  GNUNET_asprintf (&res, "%s.%u.%s://%s:%u%s", plugin, options, saddr->protocol,
263  dnsresult, saddr->port, saddr->path);
264  if (strlen (res) + 1 < 500)
265  {
266  GNUNET_memcpy (rbuf, res, strlen (res) + 1);
267  GNUNET_free(res);
268  return rbuf;
269  }
270  GNUNET_break(0);
271  GNUNET_free(res);
272  return NULL ;
273 }
274 
275 
276 static void
278 {
279  struct PrettyPrinterContext *ppc = cls;
280 
281  if (NULL != hostname)
282  {
283  ppc->asc (ppc->asc_cls,
285  hostname), GNUNET_OK);
286  ppc->sucess = GNUNET_YES;
287 
288  }
289  else
290  {
291  ppc->asc (ppc->asc_cls, NULL,
292  (GNUNET_NO == ppc->sucess) ? GNUNET_SYSERR : GNUNET_OK);
293 
294  GNUNET_CONTAINER_DLL_remove(dll_ppc_head, dll_ppc_tail, ppc);
295  http_clean_splitted (ppc->saddr);
296  GNUNET_free(ppc->plugin);
297  GNUNET_free(ppc);
298  }
299 }
300 
301 
302 static int
303 http_common_dns_reverse_lookup (const struct sockaddr *sockaddr,
304  socklen_t sockaddr_len,
305  const char *type,
306  struct SplittedHTTPAddress *saddr,
307  uint32_t options,
310  void *asc_cls)
311 {
312  struct PrettyPrinterContext *ppc;
313 
314  ppc = GNUNET_new (struct PrettyPrinterContext);
315  ppc->saddr = saddr;
316  ppc->asc = asc;
317  ppc->asc_cls = asc_cls;
318  ppc->plugin = GNUNET_strdup (type);
319  ppc->options = options;
321  sockaddr_len,
322  GNUNET_YES,
323  timeout,
325  ppc);
326  if (NULL == ppc->resolver_handle)
327  {
328  GNUNET_free(ppc->plugin);
329  GNUNET_free(ppc);
330  return GNUNET_SYSERR;
331  }
332  GNUNET_CONTAINER_DLL_insert (dll_ppc_head,
333  dll_ppc_tail,
334  ppc);
335  return GNUNET_OK;
336 }
337 
338 
339 static void
341  const struct sockaddr *addr,
342  socklen_t addrlen)
343 {
344  struct PrettyPrinterContext *ppc = cls;
345 
346  if (NULL != addr)
347  {
348  ppc->asc (ppc->asc_cls,
350  GNUNET_a2s (addr, addrlen)), GNUNET_OK);
351  ppc->sucess = GNUNET_YES;
352  ppc->asc (ppc->asc_cls, GNUNET_a2s (addr, addrlen), GNUNET_OK);
353  }
354  else
355  {
356  ppc->asc (ppc->asc_cls, NULL,
357  (GNUNET_NO == ppc->sucess) ? GNUNET_SYSERR : GNUNET_OK);
358 
359  GNUNET_CONTAINER_DLL_remove(dll_ppc_head, dll_ppc_tail, ppc);
360  GNUNET_free(ppc->plugin);
361  http_clean_splitted (ppc->saddr);
362  GNUNET_free(ppc);
363  }
364 }
365 
366 
367 static int
369  const char *type,
370  struct SplittedHTTPAddress *saddr,
371  uint32_t options,
374 {
375  struct PrettyPrinterContext *ppc;
376 
377  ppc = GNUNET_new (struct PrettyPrinterContext);
378  ppc->sucess = GNUNET_NO;
379  ppc->saddr = saddr;
380  ppc->asc = asc;
381  ppc->asc_cls = asc_cls;
382  ppc->plugin = GNUNET_strdup (type);
383  ppc->options = options;
385  AF_UNSPEC,
386  timeout,
388  ppc);
389  if (NULL == ppc->resolver_handle)
390  {
391  GNUNET_free(ppc->plugin);
392  GNUNET_free(ppc);
393  return GNUNET_SYSERR;
394  }
395  GNUNET_CONTAINER_DLL_insert (dll_ppc_head,
396  dll_ppc_tail,
397  ppc);
398  return GNUNET_OK;
399 }
400 
401 
416 void
418  const void *addr,
419  size_t addrlen,
420  int numeric,
423  void *asc_cls)
424 {
425  const struct HttpAddress *address = addr;
426  struct SplittedHTTPAddress *saddr;
427  struct sockaddr *sock_addr;
428  const char *ret;
429  char *addr_str;
430  int res;
431  int have_ip;
432 
433  saddr = NULL;
434  sock_addr = NULL;
435  if ( (addrlen < sizeof(struct HttpAddress)) ||
436  (addrlen != http_common_address_get_size (address)) )
437  {
438  GNUNET_break(0);
439  goto handle_error;
440  }
441 
442  addr_str = (char *) &address[1];
443  if (addr_str[ntohl (address->urlen) - 1] != '\0')
444  {
445  GNUNET_break(0);
446  goto handle_error;
447  }
448 
449  saddr = http_split_address (addr_str);
450  if (NULL == saddr)
451  {
452  GNUNET_break(0);
453  goto handle_error;
454  }
455 
456  sock_addr = http_common_socket_from_address (addr, addrlen, &res);
457  if (GNUNET_SYSERR == res)
458  {
459  /* Malformed address */
460  GNUNET_break (0);
461  goto handle_error;
462  }
463  else if (GNUNET_NO == res)
464  {
465  /* Could not convert to IP */
466  have_ip = GNUNET_NO;
467  }
468  else if (GNUNET_YES == res)
469  {
470  /* Converted to IP */
471  have_ip = GNUNET_YES;
472  }
473  else
474  {
475  /* Must not happen */
476  GNUNET_break (0);
477  goto handle_error;
478  }
479 
480  if ( (GNUNET_YES == numeric) &&
481  (GNUNET_YES == have_ip) )
482  {
483  /* No lookup required */
484  ret = http_common_plugin_address_to_string (type, address, addrlen);
485  asc (asc_cls, ret, (NULL == ret) ? GNUNET_SYSERR : GNUNET_OK);
486  asc (asc_cls, NULL, GNUNET_OK);
487  http_clean_splitted (saddr);
488  GNUNET_free_non_null (sock_addr);
489  return;
490  }
491  if ( (GNUNET_YES == numeric) &&
492  (GNUNET_NO == have_ip) )
493  {
494  /* Forward lookup */
495  if (GNUNET_SYSERR ==
496  http_common_dns_ip_lookup (saddr->host, type, saddr,
497  address->options, timeout,
498  asc, asc_cls))
499  {
500  GNUNET_break(0);
501  goto handle_error;
502  }
503  /* Wait for resolver callback */
504  GNUNET_free_non_null (sock_addr);
505  return;
506  }
507  if ( (GNUNET_NO == numeric) &&
508  (GNUNET_YES == have_ip) )
509  {
510  /* Reverse lookup */
511  if (GNUNET_SYSERR ==
513  (AF_INET == sock_addr->sa_family)
514  ? sizeof(struct sockaddr_in)
515  : sizeof(struct sockaddr_in6),
516  type,
517  saddr,
518  address->options, timeout,
519  asc, asc_cls))
520  {
521  GNUNET_break(0);
522  goto handle_error;
523  }
524  /* Wait for resolver callback */
525  GNUNET_free_non_null (sock_addr);
526  return;
527  }
528  if ( (GNUNET_NO == numeric) &&
529  (GNUNET_NO == have_ip) )
530  {
531  /* No lookup required */
532  ret = http_common_plugin_address_to_string (type, address, addrlen);
533  asc (asc_cls, ret, (NULL == ret) ? GNUNET_SYSERR : GNUNET_OK);
534  asc (asc_cls, NULL, GNUNET_OK);
535  GNUNET_free_non_null (sock_addr);
536  http_clean_splitted (saddr);
537  return;
538  }
539  /* Error (argument supplied not GNUNET_YES or GNUNET_NO) */
540  GNUNET_break (0);
541  goto handle_error;
542 
543  handle_error:
544  /* Report error */
545  asc (asc_cls, NULL, GNUNET_SYSERR);
546  asc (asc_cls, NULL, GNUNET_OK);
547  GNUNET_free_non_null (sock_addr);
548  if (NULL != saddr)
549  http_clean_splitted (saddr);
550 }
551 
552 
556 const char *
558  const void *addr,
559  size_t addrlen)
560 {
561  static char rbuf[1024];
562  const struct HttpAddress *address = addr;
563  const char * addr_str;
564 
565  if (NULL == addr)
566  {
567  GNUNET_break(0);
568  return NULL;
569  }
570  if (0 == addrlen)
571  {
572  GNUNET_break(0);
573  return NULL;
574  }
575  if (addrlen != http_common_address_get_size (address))
576  {
577  GNUNET_break(0);
578  return NULL;
579  }
580  addr_str = (char *) &address[1];
581  if (addr_str[ntohl (address->urlen) - 1] != '\0')
582  return NULL;
583 
584  GNUNET_memcpy (rbuf,
585  &address[1],
586  ntohl (address->urlen));
587  return rbuf;
588 }
589 
590 
602 const char *
604  const void *addr,
605  size_t addrlen)
606 {
607  static char rbuf[1024];
608  const struct HttpAddress *address = addr;
609  const char * addr_str;
610  char *res;
611 
612  GNUNET_assert(NULL != plugin);
613  if (NULL == addr)
614  return NULL;
615  if (0 == addrlen)
616  return NULL;
617  if (addrlen != http_common_address_get_size (address))
618  return NULL;
619  addr_str = (char *) &address[1];
620  if (addr_str[ntohl (address->urlen) - 1] != '\0')
621  return NULL;
622  GNUNET_asprintf (&res, "%s.%u.%s", plugin, ntohl (address->options),
623  &address[1]);
624  if (strlen (res) + 1 < 500)
625  {
626  GNUNET_memcpy (rbuf, res, strlen (res) + 1);
627  GNUNET_free(res);
628  return rbuf;
629  }
630  GNUNET_break(0);
631  GNUNET_free(res);
632  return NULL;
633 }
634 
647 int
649  const char *addr,
650  uint16_t addrlen,
651  void **buf,
652  size_t *added)
653 {
654  struct HttpAddress *a;
655  char *address;
656  char *plugin;
657  char *optionstr;
658  size_t urlen;
659  uint32_t options;
660 
661  /* Format protocol.options.address:port */
662  address = NULL;
663  plugin = NULL;
664  optionstr = NULL;
665  if ((NULL == addr) || (addrlen == 0))
666  {
667  GNUNET_break(0);
668  return GNUNET_SYSERR;
669  }
670  if ('\0' != addr[addrlen - 1])
671  {
672  GNUNET_break(0);
673  return GNUNET_SYSERR;
674  }
675  if (strlen (addr) != addrlen - 1)
676  {
677  GNUNET_break(0);
678  return GNUNET_SYSERR;
679  }
680  plugin = GNUNET_strdup (addr);
681  optionstr = strchr (plugin, '.');
682  if (NULL == optionstr)
683  {
684  GNUNET_break(0);
685  GNUNET_free(plugin);
686  return GNUNET_SYSERR;
687  }
688  optionstr[0] = '\0';
689  optionstr++;
690  options = atol (optionstr); /* 0 on conversion error, that's ok */
691  address = strchr (optionstr, '.');
692  if (NULL == address)
693  {
694  GNUNET_break(0);
695  GNUNET_free(plugin);
696  return GNUNET_SYSERR;
697  }
698  address[0] = '\0';
699  address++;
700  urlen = strlen (address) + 1;
701 
702  a = GNUNET_malloc (sizeof (struct HttpAddress) + urlen);
703  a->options = htonl (options);
704  a->urlen = htonl (urlen);
705  GNUNET_memcpy (&a[1], address, urlen);
706 
707  (*buf) = a;
708  (*added) = sizeof(struct HttpAddress) + urlen;
709  GNUNET_free(plugin);
710  return GNUNET_OK;
711 }
712 
713 
722 struct HttpAddress *
723 http_common_address_from_socket (const char *protocol,
724  const struct sockaddr *addr,
725  socklen_t addrlen)
726 {
727  struct HttpAddress *address = NULL;
728  char *res;
729  size_t len;
730 
731  GNUNET_asprintf (&res,
732  "%s://%s",
733  protocol,
734  GNUNET_a2s (addr,
735  addrlen));
736  len = strlen (res) + 1;
737  address = GNUNET_malloc (sizeof (struct HttpAddress) + len);
738  address->options = htonl (HTTP_OPTIONS_NONE);
739  address->urlen = htonl (len);
740  GNUNET_memcpy (&address[1], res, len);
741  GNUNET_free(res);
742  return address;
743 }
744 
745 
757 struct sockaddr *
759  size_t addrlen,
760  int *res)
761 {
762  const struct HttpAddress *ha;
763  struct SplittedHTTPAddress * spa;
764  struct sockaddr_storage *s;
765  char * to_conv;
766  size_t urlen;
767 
768  (*res) = GNUNET_SYSERR;
769  ha = (const struct HttpAddress *) addr;
770  if (NULL == addr)
771  {
772  GNUNET_break (0);
773  return NULL;
774  }
775  if (0 == addrlen)
776  {
777  GNUNET_break (0);
778  return NULL;
779  }
780  if (addrlen < sizeof(struct HttpAddress))
781  {
782  GNUNET_break (0);
783  return NULL;
784  }
785  urlen = ntohl (ha->urlen);
786  if (sizeof(struct HttpAddress) + urlen != addrlen)
787  {
788  /* This is a legacy addresses */
789  return NULL;
790  }
791  if (addrlen < sizeof(struct HttpAddress) + urlen)
792  {
793  /* This is a legacy addresses */
794  return NULL;
795  }
796  if (((char *) addr)[addrlen - 1] != '\0')
797  {
798  GNUNET_break (0);
799  return NULL;
800  }
801  spa = http_split_address ((const char *) &ha[1]);
802  if (NULL == spa)
803  {
804  (*res) = GNUNET_SYSERR;
805  return NULL;
806  }
807 
808  s = GNUNET_new (struct sockaddr_storage);
809  GNUNET_asprintf (&to_conv, "%s:%u", spa->host, spa->port);
810  if (GNUNET_SYSERR
811  == GNUNET_STRINGS_to_address_ip (to_conv, strlen (to_conv), s))
812  {
813  /* could be a hostname */
814  GNUNET_free(s);
815  (*res) = GNUNET_NO;
816  s = NULL;
817  }
818  else if ((AF_INET != s->ss_family) && (AF_INET6 != s->ss_family))
819  {
820  GNUNET_free (s);
821  (*res) = GNUNET_SYSERR;
822  s = NULL;
823  }
824  else
825  {
826  (*res) = GNUNET_YES;
827  }
828  http_clean_splitted (spa);
829  GNUNET_free (to_conv);
830  return (struct sockaddr *) s;
831 }
832 
833 
840 size_t
842 {
843  return sizeof(struct HttpAddress) + ntohl (addr->urlen);
844 }
845 
846 
856 size_t
857 http_common_cmp_addresses (const void *addr1,
858  size_t addrlen1,
859  const void *addr2,
860  size_t addrlen2)
861 {
862  const char *a1 = addr1;
863  const char *a2 = addr2;
864  const struct HttpAddress *ha1;
865  const struct HttpAddress *ha2;
866  ha1 = (const struct HttpAddress *) a1;
867  ha2 = (const struct HttpAddress *) a2;
868 
869  if (NULL == a1)
870  return GNUNET_SYSERR;
871  if (0 == addrlen1)
872  return GNUNET_SYSERR;
873  if (a1[addrlen1 - 1] != '\0')
874  return GNUNET_SYSERR;
875 
876  if (NULL == a2)
877  return GNUNET_SYSERR;
878  if (0 == addrlen2)
879  return GNUNET_SYSERR;
880  if (a2[addrlen2 - 1] != '\0')
881  return GNUNET_SYSERR;
882 
883  if (addrlen1 != addrlen2)
884  return GNUNET_NO;
885  if (ha1->urlen != ha2->urlen)
886  return GNUNET_NO;
887 
888  if (0 == strcmp ((const char *) &ha1[1], (const char *) &ha2[1]))
889  return GNUNET_YES;
890  return GNUNET_NO;
891 }
892 
893 
903  const struct GNUNET_HELLO_Address *address)
904 {
905 
906  struct sockaddr *sa;
907  enum GNUNET_NetworkType net_type;
908  size_t salen = 0;
909  int res;
910 
911  net_type = GNUNET_NT_UNSPECIFIED;
913  address->address_length,
914  &res);
915  if (GNUNET_SYSERR == res)
916  return net_type;
917  if (GNUNET_YES == res)
918  {
919  GNUNET_assert (NULL != sa);
920  if (AF_INET == sa->sa_family)
921  {
922  salen = sizeof (struct sockaddr_in);
923  }
924  else if (AF_INET6 == sa->sa_family)
925  {
926  salen = sizeof (struct sockaddr_in6);
927  }
928  net_type = env->get_address_type (env->cls,
929  sa,
930  salen);
931  GNUNET_free (sa);
932  }
933  return net_type;
934 }
935 
936 
937 
938 /* end of plugin_transport_http_common.c */
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
size_t address_length
Number of bytes in address.
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, WAN 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_NO
Definition: gnunet_common.h:81
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.
Definition: resolver_api.c:927
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#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.
static int ret
Final status code.
Definition: gnunet-arm.c:89
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Definition: gnunet_nt_lib.h:35
#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.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
void * cls
Closure for the various callbacks.
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:114
#define GNUNET_memcpy(dst, src, n)
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.
static char buf[2048]
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.
static int res
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
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.
Definition: resolver_api.c:100
const char * name
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
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.
Definition: scheduler.c:134
static struct PrettyPrinterContext * dll_ppc_head
Head of PPC list.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_YES
Definition: gnunet_common.h:80
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.
Definition: strings.c:1409
#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...
Category of last resort.
Definition: gnunet_nt_lib.h:40