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 
56  protocol_start = src;
57 
58  sp = GNUNET_new(struct SplittedHTTPAddress);
59  /* Address string consists of protocol://host[:port]path*/
60 
61  host_start = strstr(src, "://");
62  if (NULL == host_start)
63  {
64  GNUNET_free(src);
65  GNUNET_free(sp);
66  return NULL;
67  }
68  host_start[0] = '\0';
69  sp->protocol = GNUNET_strdup(protocol_start);
70 
71  host_start += strlen("://");
72  if (strlen(host_start) == 0)
73  {
74  GNUNET_free(src);
75  GNUNET_free(sp->protocol);
76  GNUNET_free(sp);
77  return NULL;
78  }
79 
80  /* Find path start */
81  path_start = strchr(host_start, '/');
82  if (NULL != path_start)
83  {
84  sp->path = GNUNET_strdup(path_start);
85  path_start[0] = '\0';
86  }
87  else
88  sp->path = GNUNET_strdup("");
89 
90  if (strlen(host_start) < 1)
91  {
92  GNUNET_free(src);
93  GNUNET_free(sp->protocol);
94  GNUNET_free(sp->path);
95  GNUNET_free(sp);
96  return NULL;
97  }
98 
99  if (NULL != (port_start = strrchr(host_start, ':')))
100  {
101  /* *We COULD have a port, but also an IPv6 address! */
102  if (NULL != (v6_end = strchr(host_start, ']')))
103  {
104  if (v6_end < port_start)
105  {
106  /* IPv6 address + port */
107  port_start[0] = '\0';
108  port_start++;
109  sp->port = atoi(port_start);
110  if ((0 == sp->port) || (65535 < sp->port))
111  {
112  GNUNET_free(src);
113  GNUNET_free(sp->protocol);
114  GNUNET_free(sp->path);
115  GNUNET_free(sp);
116  return NULL;
117  }
118  }
119  else
120  {
121  /* IPv6 address + no port */
122  if (0 == strcmp(sp->protocol, "https"))
123  sp->port = HTTPS_DEFAULT_PORT;
124  else if (0 == strcmp(sp->protocol, "http"))
125  sp->port = HTTP_DEFAULT_PORT;
126  }
127  }
128  else
129  {
130  /* No IPv6 address */
131  port_start[0] = '\0';
132  port_start++;
133  sp->port = atoi(port_start);
134  if ((0 == sp->port) || (65535 < sp->port))
135  {
136  GNUNET_free(src);
137  GNUNET_free(sp->protocol);
138  GNUNET_free(sp->path);
139  GNUNET_free(sp);
140  return NULL;
141  }
142  }
143  }
144  else
145  {
146  /* No ':' as port separator, default port for protocol */
147  if (0 == strcmp(sp->protocol, "https"))
148  sp->port = HTTPS_DEFAULT_PORT;
149  else if (0 == strcmp(sp->protocol, "http"))
150  sp->port = HTTP_DEFAULT_PORT;
151  else
152  {
153  GNUNET_break(0);
154  GNUNET_free(src);
155  GNUNET_free(sp->protocol);
156  GNUNET_free(sp->path);
157  GNUNET_free(sp);
158  return NULL;
159  }
160  }
161  if (strlen(host_start) > 0)
162  sp->host = GNUNET_strdup(host_start);
163  else
164  {
165  GNUNET_break(0);
166  GNUNET_free(src);
167  GNUNET_free(sp->protocol);
168  GNUNET_free(sp->path);
169  GNUNET_free(sp);
170  return NULL;
171  }
172  GNUNET_free(src);
173  return sp;
174 }
175 
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  else
289  {
290  ppc->asc(ppc->asc_cls, NULL,
291  (GNUNET_NO == ppc->sucess) ? GNUNET_SYSERR : GNUNET_OK);
292 
293  GNUNET_CONTAINER_DLL_remove(dll_ppc_head, dll_ppc_tail, ppc);
295  GNUNET_free(ppc->plugin);
296  GNUNET_free(ppc);
297  }
298 }
299 
300 
301 static int
302 http_common_dns_reverse_lookup(const struct sockaddr *sockaddr,
303  socklen_t sockaddr_len,
304  const char *type,
305  struct SplittedHTTPAddress *saddr,
306  uint32_t options,
309  void *asc_cls)
310 {
311  struct PrettyPrinterContext *ppc;
312 
313  ppc = GNUNET_new(struct PrettyPrinterContext);
314  ppc->saddr = saddr;
315  ppc->asc = asc;
316  ppc->asc_cls = asc_cls;
317  ppc->plugin = GNUNET_strdup(type);
318  ppc->options = options;
320  sockaddr_len,
321  GNUNET_YES,
322  timeout,
324  ppc);
325  if (NULL == ppc->resolver_handle)
326  {
327  GNUNET_free(ppc->plugin);
328  GNUNET_free(ppc);
329  return GNUNET_SYSERR;
330  }
331  GNUNET_CONTAINER_DLL_insert(dll_ppc_head,
332  dll_ppc_tail,
333  ppc);
334  return GNUNET_OK;
335 }
336 
337 
338 static void
340  const struct sockaddr *addr,
341  socklen_t addrlen)
342 {
343  struct PrettyPrinterContext *ppc = cls;
344 
345  if (NULL != addr)
346  {
347  ppc->asc(ppc->asc_cls,
349  GNUNET_a2s(addr, addrlen)), GNUNET_OK);
350  ppc->sucess = GNUNET_YES;
351  ppc->asc(ppc->asc_cls, GNUNET_a2s(addr, addrlen), GNUNET_OK);
352  }
353  else
354  {
355  ppc->asc(ppc->asc_cls, NULL,
356  (GNUNET_NO == ppc->sucess) ? GNUNET_SYSERR : GNUNET_OK);
357 
358  GNUNET_CONTAINER_DLL_remove(dll_ppc_head, dll_ppc_tail, ppc);
359  GNUNET_free(ppc->plugin);
361  GNUNET_free(ppc);
362  }
363 }
364 
365 
366 static int
368  const char *type,
369  struct SplittedHTTPAddress *saddr,
370  uint32_t options,
373 {
374  struct PrettyPrinterContext *ppc;
375 
376  ppc = GNUNET_new(struct PrettyPrinterContext);
377  ppc->sucess = GNUNET_NO;
378  ppc->saddr = saddr;
379  ppc->asc = asc;
380  ppc->asc_cls = asc_cls;
381  ppc->plugin = GNUNET_strdup(type);
382  ppc->options = options;
384  AF_UNSPEC,
385  timeout,
387  ppc);
388  if (NULL == ppc->resolver_handle)
389  {
390  GNUNET_free(ppc->plugin);
391  GNUNET_free(ppc);
392  return GNUNET_SYSERR;
393  }
394  GNUNET_CONTAINER_DLL_insert(dll_ppc_head,
395  dll_ppc_tail,
396  ppc);
397  return GNUNET_OK;
398 }
399 
400 
415 void
417  const void *addr,
418  size_t addrlen,
419  int numeric,
422  void *asc_cls)
423 {
424  const struct HttpAddress *address = addr;
425  struct SplittedHTTPAddress *saddr;
426  struct sockaddr *sock_addr;
427  const char *ret;
428  char *addr_str;
429  int res;
430  int have_ip;
431 
432  saddr = NULL;
433  sock_addr = NULL;
434  if ((addrlen < sizeof(struct HttpAddress)) ||
435  (addrlen != http_common_address_get_size(address)))
436  {
437  GNUNET_break(0);
438  goto handle_error;
439  }
440 
441  addr_str = (char *)&address[1];
442  if (addr_str[ntohl(address->urlen) - 1] != '\0')
443  {
444  GNUNET_break(0);
445  goto handle_error;
446  }
447 
448  saddr = http_split_address(addr_str);
449  if (NULL == saddr)
450  {
451  GNUNET_break(0);
452  goto handle_error;
453  }
454 
455  sock_addr = http_common_socket_from_address(addr, addrlen, &res);
456  if (GNUNET_SYSERR == res)
457  {
458  /* Malformed address */
459  GNUNET_break(0);
460  goto handle_error;
461  }
462  else if (GNUNET_NO == res)
463  {
464  /* Could not convert to IP */
465  have_ip = GNUNET_NO;
466  }
467  else if (GNUNET_YES == res)
468  {
469  /* Converted to IP */
470  have_ip = GNUNET_YES;
471  }
472  else
473  {
474  /* Must not happen */
475  GNUNET_break(0);
476  goto handle_error;
477  }
478 
479  if ((GNUNET_YES == numeric) &&
480  (GNUNET_YES == have_ip))
481  {
482  /* No lookup required */
483  ret = http_common_plugin_address_to_string(type, address, addrlen);
484  asc(asc_cls, ret, (NULL == ret) ? GNUNET_SYSERR : GNUNET_OK);
485  asc(asc_cls, NULL, GNUNET_OK);
486  http_clean_splitted(saddr);
487  GNUNET_free_non_null(sock_addr);
488  return;
489  }
490  if ((GNUNET_YES == numeric) &&
491  (GNUNET_NO == have_ip))
492  {
493  /* Forward lookup */
494  if (GNUNET_SYSERR ==
495  http_common_dns_ip_lookup(saddr->host, type, saddr,
496  address->options, timeout,
497  asc, asc_cls))
498  {
499  GNUNET_break(0);
500  goto handle_error;
501  }
502  /* Wait for resolver callback */
503  GNUNET_free_non_null(sock_addr);
504  return;
505  }
506  if ((GNUNET_NO == numeric) &&
507  (GNUNET_YES == have_ip))
508  {
509  /* Reverse lookup */
510  if (GNUNET_SYSERR ==
512  (AF_INET == sock_addr->sa_family)
513  ? sizeof(struct sockaddr_in)
514  : sizeof(struct sockaddr_in6),
515  type,
516  saddr,
517  address->options, timeout,
518  asc, asc_cls))
519  {
520  GNUNET_break(0);
521  goto handle_error;
522  }
523  /* Wait for resolver callback */
524  GNUNET_free_non_null(sock_addr);
525  return;
526  }
527  if ((GNUNET_NO == numeric) &&
528  (GNUNET_NO == have_ip))
529  {
530  /* No lookup required */
531  ret = http_common_plugin_address_to_string(type, address, addrlen);
532  asc(asc_cls, ret, (NULL == ret) ? GNUNET_SYSERR : GNUNET_OK);
533  asc(asc_cls, NULL, GNUNET_OK);
534  GNUNET_free_non_null(sock_addr);
535  http_clean_splitted(saddr);
536  return;
537  }
538  /* Error (argument supplied not GNUNET_YES or GNUNET_NO) */
539  GNUNET_break(0);
540  goto handle_error;
541 
542 handle_error:
543  /* Report error */
544  asc(asc_cls, NULL, GNUNET_SYSERR);
545  asc(asc_cls, NULL, GNUNET_OK);
546  GNUNET_free_non_null(sock_addr);
547  if (NULL != saddr)
548  http_clean_splitted(saddr);
549 }
550 
551 
555 const char *
557  const void *addr,
558  size_t addrlen)
559 {
560  static char rbuf[1024];
561  const struct HttpAddress *address = addr;
562  const char * addr_str;
563 
564  if (NULL == addr)
565  {
566  GNUNET_break(0);
567  return NULL;
568  }
569  if (0 == addrlen)
570  {
571  GNUNET_break(0);
572  return NULL;
573  }
574  if (addrlen != http_common_address_get_size(address))
575  {
576  GNUNET_break(0);
577  return NULL;
578  }
579  addr_str = (char *)&address[1];
580  if (addr_str[ntohl(address->urlen) - 1] != '\0')
581  return NULL;
582 
583  GNUNET_memcpy(rbuf,
584  &address[1],
585  ntohl(address->urlen));
586  return rbuf;
587 }
588 
589 
601 const char *
603  const void *addr,
604  size_t addrlen)
605 {
606  static char rbuf[1024];
607  const struct HttpAddress *address = addr;
608  const char * addr_str;
609  char *res;
610 
611  GNUNET_assert(NULL != plugin);
612  if (NULL == addr)
613  return NULL;
614  if (0 == addrlen)
615  return NULL;
616  if (addrlen != http_common_address_get_size(address))
617  return NULL;
618  addr_str = (char *)&address[1];
619  if (addr_str[ntohl(address->urlen) - 1] != '\0')
620  return NULL;
621  GNUNET_asprintf(&res, "%s.%u.%s", plugin, ntohl(address->options),
622  &address[1]);
623  if (strlen(res) + 1 < 500)
624  {
625  GNUNET_memcpy(rbuf, res, strlen(res) + 1);
626  GNUNET_free(res);
627  return rbuf;
628  }
629  GNUNET_break(0);
630  GNUNET_free(res);
631  return NULL;
632 }
633 
646 int
648  const char *addr,
649  uint16_t addrlen,
650  void **buf,
651  size_t *added)
652 {
653  struct HttpAddress *a;
654  char *address;
655  char *plugin;
656  char *optionstr;
657  size_t urlen;
658  uint32_t options;
659 
660  /* Format protocol.options.address:port */
661  address = NULL;
662  plugin = NULL;
663  optionstr = NULL;
664  if ((NULL == addr) || (addrlen == 0))
665  {
666  GNUNET_break(0);
667  return GNUNET_SYSERR;
668  }
669  if ('\0' != addr[addrlen - 1])
670  {
671  GNUNET_break(0);
672  return GNUNET_SYSERR;
673  }
674  if (strlen(addr) != addrlen - 1)
675  {
676  GNUNET_break(0);
677  return GNUNET_SYSERR;
678  }
679  plugin = GNUNET_strdup(addr);
680  optionstr = strchr(plugin, '.');
681  if (NULL == optionstr)
682  {
683  GNUNET_break(0);
684  GNUNET_free(plugin);
685  return GNUNET_SYSERR;
686  }
687  optionstr[0] = '\0';
688  optionstr++;
689  options = atol(optionstr); /* 0 on conversion error, that's ok */
690  address = strchr(optionstr, '.');
691  if (NULL == address)
692  {
693  GNUNET_break(0);
694  GNUNET_free(plugin);
695  return GNUNET_SYSERR;
696  }
697  address[0] = '\0';
698  address++;
699  urlen = strlen(address) + 1;
700 
701  a = GNUNET_malloc(sizeof(struct HttpAddress) + urlen);
702  a->options = htonl(options);
703  a->urlen = htonl(urlen);
704  GNUNET_memcpy(&a[1], address, urlen);
705 
706  (*buf) = a;
707  (*added) = sizeof(struct HttpAddress) + urlen;
708  GNUNET_free(plugin);
709  return GNUNET_OK;
710 }
711 
712 
721 struct HttpAddress *
722 http_common_address_from_socket(const char *protocol,
723  const struct sockaddr *addr,
724  socklen_t addrlen)
725 {
726  struct HttpAddress *address = NULL;
727  char *res;
728  size_t len;
729 
730  GNUNET_asprintf(&res,
731  "%s://%s",
732  protocol,
733  GNUNET_a2s(addr,
734  addrlen));
735  len = strlen(res) + 1;
736  address = GNUNET_malloc(sizeof(struct HttpAddress) + len);
737  address->options = htonl(HTTP_OPTIONS_NONE);
738  address->urlen = htonl(len);
739  GNUNET_memcpy(&address[1], res, len);
740  GNUNET_free(res);
741  return address;
742 }
743 
744 
756 struct sockaddr *
758  size_t addrlen,
759  int *res)
760 {
761  const struct HttpAddress *ha;
762  struct SplittedHTTPAddress * spa;
763  struct sockaddr_storage *s;
764  char * to_conv;
765  size_t urlen;
766 
767  (*res) = GNUNET_SYSERR;
768  ha = (const struct HttpAddress *)addr;
769  if (NULL == addr)
770  {
771  GNUNET_break(0);
772  return NULL;
773  }
774  if (0 == addrlen)
775  {
776  GNUNET_break(0);
777  return NULL;
778  }
779  if (addrlen < sizeof(struct HttpAddress))
780  {
781  GNUNET_break(0);
782  return NULL;
783  }
784  urlen = ntohl(ha->urlen);
785  if (sizeof(struct HttpAddress) + urlen != addrlen)
786  {
787  /* This is a legacy addresses */
788  return NULL;
789  }
790  if (addrlen < sizeof(struct HttpAddress) + urlen)
791  {
792  /* This is a legacy addresses */
793  return NULL;
794  }
795  if (((char *)addr)[addrlen - 1] != '\0')
796  {
797  GNUNET_break(0);
798  return NULL;
799  }
800  spa = http_split_address((const char *)&ha[1]);
801  if (NULL == spa)
802  {
803  (*res) = GNUNET_SYSERR;
804  return NULL;
805  }
806 
807  s = GNUNET_new(struct sockaddr_storage);
808  GNUNET_asprintf(&to_conv, "%s:%u", spa->host, spa->port);
809  if (GNUNET_SYSERR
810  == GNUNET_STRINGS_to_address_ip(to_conv, strlen(to_conv), s))
811  {
812  /* could be a hostname */
813  GNUNET_free(s);
814  (*res) = GNUNET_NO;
815  s = NULL;
816  }
817  else if ((AF_INET != s->ss_family) && (AF_INET6 != s->ss_family))
818  {
819  GNUNET_free(s);
820  (*res) = GNUNET_SYSERR;
821  s = NULL;
822  }
823  else
824  {
825  (*res) = GNUNET_YES;
826  }
827  http_clean_splitted(spa);
828  GNUNET_free(to_conv);
829  return (struct sockaddr *)s;
830 }
831 
832 
839 size_t
841 {
842  return sizeof(struct HttpAddress) + ntohl(addr->urlen);
843 }
844 
845 
855 size_t
856 http_common_cmp_addresses(const void *addr1,
857  size_t addrlen1,
858  const void *addr2,
859  size_t addrlen2)
860 {
861  const char *a1 = addr1;
862  const char *a2 = addr2;
863  const struct HttpAddress *ha1;
864  const struct HttpAddress *ha2;
865 
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  struct sockaddr *sa;
906  enum GNUNET_NetworkType net_type;
907  size_t salen = 0;
908  int res;
909 
910  net_type = GNUNET_NT_UNSPECIFIED;
912  address->address_length,
913  &res);
914  if (GNUNET_SYSERR == res)
915  return net_type;
916  if (GNUNET_YES == res)
917  {
918  GNUNET_assert(NULL != sa);
919  if (AF_INET == sa->sa_family)
920  {
921  salen = sizeof(struct sockaddr_in);
922  }
923  else if (AF_INET6 == sa->sa_family)
924  {
925  salen = sizeof(struct sockaddr_in6);
926  }
927  net_type = env->get_address_type(env->cls,
928  sa,
929  salen);
930  GNUNET_free(sa);
931  }
932  return net_type;
933 }
934 
935 
936 
937 /* 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_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_NO
Definition: gnunet_common.h:78
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:933
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#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
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:76
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:131
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:77
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:1327
#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:39