GNUnet  0.10.x
plugin_rest_peerinfo.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2012-2015 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  */
27 #include "platform.h"
28 #include "gnunet_rest_plugin.h"
31 #include "gnunet_rest_lib.h"
32 #include "gnunet_json_lib.h"
33 #include "microhttpd.h"
34 #include <jansson.h>
35 
39 #define GNUNET_REST_API_NS_PEERINFO "/peerinfo"
40 
44 #define GNUNET_REST_PEERINFO_PEER "peer"
45 
49 #define GNUNET_REST_PEERINFO_FRIEND "friend"
50 
54 #define GNUNET_REST_PEERINFO_ARRAY "array"
55 
59 #define GNUNET_REST_PEERINFO_ERROR_UNKNOWN "Unknown Error"
60 
64 #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
65 
69 
73 static char* allow_methods;
74 
78 struct Plugin {
79  const struct GNUNET_CONFIGURATION_Handle *cfg;
80 };
81 
82 
86 struct AddressRecord {
91 
95  struct GNUNET_TIME_Absolute expiration;
96 
100  char *result;
101 
105  struct PrintContext *pc;
106 };
107 
108 
112 struct PrintContext {
116  struct PrintContext *next;
117 
121  struct PrintContext *prev;
122 
126  struct GNUNET_PeerIdentity peer;
127 
131  struct AddressRecord *address_list;
132 
136  unsigned int num_addresses;
137 
141  unsigned int address_list_size;
142 
146  unsigned int off;
147 
151  int friend_only;
152 
157 };
158 
162 static struct PrintContext *pc_head;
163 
167 static struct PrintContext *pc_tail;
168 
172 struct RequestHandle {
176  json_t *temp_array;
177 
182 
186  const char *address;
187 
191  char *pubkey;
192 
196  json_t *response;
197 
202 
207 
211  struct GNUNET_REST_RequestHandle *rest_handle;
212 
217 
222 
227 
231  void *proc_cls;
232 
236  char *url;
237 
241  char *emsg;
242 
246  int response_code;
247 };
248 
249 
254 static void
255 cleanup_handle(void *cls)
256 {
257  struct RequestHandle *handle = cls;
258 
260  "Cleaning up\n");
261  if (NULL != handle->timeout_task)
262  {
264  handle->timeout_task = NULL;
265  }
266  if (NULL != handle->url)
267  GNUNET_free(handle->url);
268  if (NULL != handle->emsg)
269  GNUNET_free(handle->emsg);
270  if (NULL != handle->address)
271  GNUNET_free((char*)handle->address);
272  if (NULL != handle->expiration_str)
273  GNUNET_free(handle->expiration_str);
274  if (NULL != handle->pubkey)
275  GNUNET_free(handle->pubkey);
276 
277  if (NULL != handle->temp_array)
278  {
279  json_decref(handle->temp_array);
280  handle->temp_array = NULL;
281  }
282  if (NULL != handle->response)
283  {
284  json_decref(handle->response);
285  handle->response = NULL;
286  }
287 
288  if (NULL != handle->list_it)
289  {
291  handle->list_it = NULL;
292  }
293  if (NULL != handle->peerinfo_handle)
294  {
296  handle->peerinfo_handle = NULL;
297  }
298 
299  GNUNET_free(handle);
300 }
301 
302 
308 static void
309 do_error(void *cls)
310 {
311  struct RequestHandle *handle = cls;
312  struct MHD_Response *resp;
313  json_t *json_error = json_object();
314  char *response;
315 
316  if (NULL == handle->emsg)
318 
319  json_object_set_new(json_error, "error", json_string(handle->emsg));
320 
321  if (0 == handle->response_code)
322  handle->response_code = MHD_HTTP_OK;
323  response = json_dumps(json_error, 0);
324  resp = GNUNET_REST_create_response(response);
325  handle->proc(handle->proc_cls, resp, handle->response_code);
326  json_decref(json_error);
327  GNUNET_free(response);
329 }
330 
331 
337 static void
339 {
340  struct RequestHandle *handle = cls;
341  char *result_str;
342  struct MHD_Response *resp;
343 
344  if (NULL == handle->response)
345  {
346  handle->response_code = MHD_HTTP_NOT_FOUND;
347  handle->emsg = GNUNET_strdup("No peers found");
349  return;
350  }
351 
352  result_str = json_dumps(handle->response, 0);
353  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
354  resp = GNUNET_REST_create_response(result_str);
355  handle->proc(handle->proc_cls, resp, MHD_HTTP_OK);
356  GNUNET_free_non_null(result_str);
358 }
359 
360 
369 static int
370 count_address(void *cls,
371  const struct GNUNET_HELLO_Address *address,
373 {
374  struct PrintContext *pc = cls;
375 
376  if (0 == GNUNET_TIME_absolute_get_remaining(expiration).rel_value_us)
377  {
378  return GNUNET_OK; /* ignore expired address */
379  }
380 
381  pc->off++;
382  return GNUNET_OK;
383 }
384 
385 
391 static void
393 {
394  struct RequestHandle *handle;
395  unsigned int i;
396  json_t *response_entry;
397  json_t *temp_array;
398  json_t *object;
399  json_t *address;
400  json_t *expires;
401  json_t *friend_and_peer_json;
402  char *friend_and_peer;
403 
404  temp_array = json_array();
405  response_entry = json_object();
406 
407  for (i = 0; i < pc->num_addresses; i++)
408  {
409  if (NULL != pc->address_list[i].result)
410  {
411  object = json_object();
412  address = json_string(pc->address_list[i].result);
413  expires = json_string(
415  json_object_set(object, "address", address);
416  json_object_set(object, "expires", expires);
417 
418  json_decref(address);
419  json_decref(expires);
420 
421  json_array_append(temp_array, object);
422  json_decref(object);
424  }
425  }
426 
427  if (0 < json_array_size(temp_array))
428  {
429  GNUNET_asprintf(&friend_and_peer,
430  "%s%s",
431  (GNUNET_YES == pc->friend_only) ? "F2F:" : "",
432  GNUNET_i2s_full(&pc->peer));
433  friend_and_peer_json = json_string(friend_and_peer);
434  json_object_set(response_entry,
436  friend_and_peer_json);
437  json_object_set(response_entry,
439  temp_array);
440  json_array_append(pc->handle->response, response_entry);
441  json_decref(friend_and_peer_json);
442  GNUNET_free(friend_and_peer);
443  }
444 
445  json_decref(temp_array);
446  json_decref(response_entry);
447 
450  pc_tail,
451  pc);
452  handle = pc->handle;
453  GNUNET_free(pc);
454 
455  if ((NULL == pc_head) &&
456  (NULL == handle->list_it))
457  {
459  }
460 }
461 
462 
473 static void
475  const char *address,
476  int res)
477 {
478  struct AddressRecord *ar = cls;
479  struct PrintContext *pc = ar->pc;
480 
481  if (NULL != address)
482  {
483  if (0 != strlen(address))
484  {
485  if (NULL != ar->result)
486  GNUNET_free(ar->result);
487  ar->result = GNUNET_strdup(address);
488  }
489  return;
490  }
491  ar->atsc = NULL;
492  if (GNUNET_SYSERR == res)
494  _("Failure: Cannot convert address to string for peer `%s'\n"),
495  GNUNET_i2s(&ar->pc->peer));
496  pc->num_addresses++;
497  if (pc->num_addresses == pc->address_list_size)
498  dump_pc(ar->pc);
499 }
500 
501 
510 static int
511 print_address(void *cls,
512  const struct GNUNET_HELLO_Address *address,
514 {
515  struct PrintContext *pc = cls;
516  struct AddressRecord *ar;
517 
518  if (0 == GNUNET_TIME_absolute_get_remaining(expiration).rel_value_us)
519  {
520  return GNUNET_OK; /* ignore expired address */
521  }
522 
523  GNUNET_assert(0 < pc->off);
524  ar = &pc->address_list[--pc->off];
525  ar->pc = pc;
526  ar->expiration = expiration;
527  GNUNET_asprintf(&ar->result,
528  "%s:%u:%u",
529  address->transport_name,
530  address->address_length,
531  address->local_info);
533  address,
534  GNUNET_NO,
535  TIMEOUT,
537  ar);
538  return GNUNET_OK;
539 }
540 
541 
551 void
553  const struct GNUNET_PeerIdentity *peer,
554  const struct GNUNET_HELLO_Message *hello,
555  const char *err_msg)
556 {
557  struct RequestHandle *handle = cls;
558  struct PrintContext *pc;
559  int friend_only;
560 
561  if (NULL == handle->response)
562  {
563  handle->response = json_array();
564  }
565 
566  if (NULL == peer)
567  {
568  handle->list_it = NULL;
569  handle->emsg = GNUNET_strdup("Error in communication with peerinfo");
570  if (NULL != err_msg)
571  {
572  GNUNET_free(handle->emsg);
573  handle->emsg = GNUNET_strdup(err_msg);
574  handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
575  }
576  if (NULL == pc_head)
578  return;
579  }
580  if (NULL == hello)
581  return;
582 
583  friend_only = GNUNET_NO;
584  if (NULL != hello)
585  friend_only = GNUNET_HELLO_is_friend_only(hello);
586 
587  pc = GNUNET_new(struct PrintContext);
589  pc_tail,
590  pc);
591  pc->peer = *peer;
592  pc->friend_only = friend_only;
593  pc->handle = handle;
595  GNUNET_NO,
596  &count_address,
597  pc);
598  if (0 == pc->off)
599  {
600  dump_pc(pc);
601  return;
602  }
603  pc->address_list_size = pc->off;
605  sizeof(struct AddressRecord) * pc->off);
607  GNUNET_NO,
608  &print_address,
609  pc);
610 }
611 
619 void
621  const char* url,
622  void *cls)
623 {
624  struct RequestHandle *handle = cls;
625  struct GNUNET_HashCode key;
626  const struct GNUNET_PeerIdentity *specific_peer;
627  //GNUNET_PEER_Id peer_id;
629  char* include_friend_only_str;
630 
631  include_friend_only = GNUNET_NO;
634  &key);
635  if (GNUNET_YES
637  &key))
638  {
639  include_friend_only_str = GNUNET_CONTAINER_multihashmap_get(
640  con_handle->url_param_map, &key);
641  if (0 == strcmp(include_friend_only_str, "yes"))
642  {
643  include_friend_only = GNUNET_YES;
644  }
645  }
646 
647  specific_peer = NULL;
650  &key);
651  if (GNUNET_YES
653  &key))
654  {
655  //peer_id = *(unsigned int*)GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map, &key);
656  //specific_peer = GNUNET_PEER_resolve2(peer_id);
657  }
658 
660  include_friend_only,
661  specific_peer,
663  handle);
664 }
665 
666 
667 
675 static void
677  const char* url,
678  void *cls)
679 {
680  struct MHD_Response *resp;
681  struct RequestHandle *handle = cls;
682 
683  //independent of path return all options
684  resp = GNUNET_REST_create_response(NULL);
685  MHD_add_response_header(resp,
686  "Access-Control-Allow-Methods",
687  allow_methods);
688  handle->proc(handle->proc_cls, resp, MHD_HTTP_OK);
690  return;
691 }
692 
693 
699 static void
701 {
703  static const struct GNUNET_REST_RequestHandler handlers[] = {
704  { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_PEERINFO, &peerinfo_get },
705  { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_PEERINFO, &options_cont },
707  };
708 
710  handlers,
711  &err,
712  handle))
713  {
714  handle->response_code = err.error_code;
716  }
717 }
718 
719 
731 static void
734  void *proc_cls)
735 {
736  struct RequestHandle *handle = GNUNET_new(struct RequestHandle);
737 
738  handle->response_code = 0;
740  handle->proc_cls = proc_cls;
741  handle->proc = proc;
742  handle->rest_handle = rest_handle;
743 
744  handle->url = GNUNET_strdup(rest_handle->url);
745  if (handle->url[strlen(handle->url) - 1] == '/')
746  handle->url[strlen(handle->url) - 1] = '\0';
747  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n");
749  init_cont(handle);
750  handle->timeout_task =
752  &do_error,
753  handle);
754 
755  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected\n");
756 }
757 
758 
765 void *
767 {
768  static struct Plugin plugin;
769  struct GNUNET_REST_Plugin *api;
770 
771  cfg = cls;
772  if (NULL != plugin.cfg)
773  return NULL; /* can only initialize once! */
774  memset(&plugin, 0, sizeof(struct Plugin));
775  plugin.cfg = cfg;
776  api = GNUNET_new(struct GNUNET_REST_Plugin);
777  api->cls = &plugin;
781  "%s, %s, %s, %s, %s",
782  MHD_HTTP_METHOD_GET,
783  MHD_HTTP_METHOD_POST,
784  MHD_HTTP_METHOD_PUT,
785  MHD_HTTP_METHOD_DELETE,
786  MHD_HTTP_METHOD_OPTIONS);
787 
789  _("Peerinfo REST API initialized\n"));
790  return api;
791 }
792 
793 
800 void *
802 {
803  struct GNUNET_REST_Plugin *api = cls;
804  struct Plugin *plugin = api->cls;
805 
806  plugin->cfg = NULL;
807 
809  GNUNET_free(api);
811  "Peerinfo REST plugin is finished\n");
812  return NULL;
813 }
814 
815 /* end of plugin_rest_peerinfo.c */
816 
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
size_t address_length
Number of bytes in address.
enum GNUNET_HELLO_AddressInfo local_info
Extended information about address.
void(* GNUNET_REST_ResultProcessor)(void *cls, struct MHD_Response *resp, int status)
Iterator called on obtained result for a REST result.
void peerinfo_list_iteration(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg)
Callback that processes each of the known HELLOs for the iteration response construction.
struct GNUNET_PeerIdentity peer
Identity of the peer.
Handle to the peerinfo service.
Definition: peerinfo_api.c:83
A HELLO message is used to exchange information about transports with other peers.
static char * expiration
Credential TTL.
struct GNUNET_PEERINFO_IteratorContext * list_it
Handle to PEERINFO it.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_PEERINFO_Handle * peerinfo_handle
Handle to PEERINFO.
static char * allow_methods
HTTP methods allows for this plugin.
functions to parse JSON objects into GNUnet objects
struct GNUNET_PEERINFO_Handle * GNUNET_PEERINFO_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the peerinfo service.
Definition: peerinfo_api.c:128
void * cls
The closure of the plugin.
struct PrintContext * pc
Print context this address record belongs to.
GNUNET_REST_ResultProcessor proc
The plugin result processor.
Structure we use to collect printable address information.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_TIME_UNIT_SECONDS
One second.
void peerinfo_get(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Handle peerinfo GET request.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
struct returned by the initialization function of the plugin
static int include_friend_only
Option &#39;-f&#39;.
#define GNUNET_NO
Definition: gnunet_common.h:78
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void * libgnunet_plugin_rest_peerinfo_init(void *cls)
Entry point for the plugin.
#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.
void(* proc)(struct GNUNET_REST_RequestHandle *handle, const char *url, void *cls)
Namespace to handle.
int GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL)...
void(* process_request)(struct GNUNET_REST_RequestHandle *handle, GNUNET_REST_ResultProcessor proc, void *proc_cls)
Function to process a REST call.
struct PrintContext * next
Kept in DLL.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
void * proc_cls
The closure of the result processor.
Context for an iteration request.
Definition: peerinfo_api.c:37
#define GNUNET_REST_HANDLER_END
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:46
The request handle.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_PEERINFO_IteratorContext * GNUNET_PEERINFO_iterate(struct GNUNET_PEERINFO_Handle *h, int include_friend_only, const struct GNUNET_PeerIdentity *peer, GNUNET_PEERINFO_Processor callback, void *callback_cls)
Call a method for each known matching host.
Definition: peerinfo_api.c:486
#define GNUNET_REST_API_NS_PEERINFO
Peerinfo Namespace.
unsigned int num_addresses
Number of completed addresses in address_list.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
struct GNUNET_NAMESTORE_ZoneIterator * list_it
Handle to NAMESTORE it.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1237
void GNUNET_PEERINFO_iterate_cancel(struct GNUNET_PEERINFO_IteratorContext *ic)
Cancel an iteration over peer information.
Definition: peerinfo_api.c:519
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:114
Record we keep for each printable address.
static int print_address(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Iterator callback to go over all addresses.
char * emsg
Error response message.
#define GNUNET_REST_PEERINFO_ERROR_UNKNOWN
Error message Unknown Error.
struct GNUNET_CONTAINER_MultiHashMap * url_param_map
Map of url parameters.
static void peerinfo_list_finished(void *cls)
Function that assembles the response.
struct GNUNET_HELLO_Message * GNUNET_HELLO_iterate_addresses(const struct GNUNET_HELLO_Message *msg, int return_modified, GNUNET_HELLO_AddressIterator it, void *it_cls)
Iterate over all of the addresses in the HELLO.
Definition: hello.c:252
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
const char * url
The url as string.
static void init_cont(struct RequestHandle *handle)
Handle rest request.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
char * name
Plugin name.
struct GNUNET_TIME_Relative timeout
Timeout.
const char * transport_name
Name of the transport plugin enabling the communication using this address.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static int result
Global testing status.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:440
int GNUNET_REST_handle_request(struct GNUNET_REST_RequestHandle *conn, const struct GNUNET_REST_RequestHandler *handlers, struct GNUNET_REST_RequestHandlerError *err, void *cls)
Definition: rest.c:75
struct GNUNET_REST_RequestHandle * rest_handle
Handle to rest request.
A 512-bit hashcode.
int response_code
HTTP response code.
struct PrintContext * prev
Kept in DLL.
static int res
struct GNUNET_TIME_Absolute expiration
Address expiration time.
#define GNUNET_REST_PEERINFO_ARRAY
Peerinfo parameter array.
static void process_resolved_address(void *cls, const char *address, int res)
Function to call with a human-readable format of an address.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
json_t * response
JSON response.
struct GNUNET_TRANSPORT_AddressToStringContext * GNUNET_TRANSPORT_address_to_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_HELLO_Address *address, int numeric, struct GNUNET_TIME_Relative timeout, GNUNET_TRANSPORT_AddressToStringCallback aluc, void *aluc_cls)
Convert a binary address into a human readable address.
int GNUNET_HELLO_is_friend_only(const struct GNUNET_HELLO_Message *h)
Return HELLO type.
Definition: hello.c:87
static struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run on timeout.
Definition: gnunet-arm.c:119
struct GNUNET_TRANSPORT_AddressToStringContext * atsc
Current address-to-string context (if active, otherwise NULL).
static void cleanup_handle(void *cls)
Cleanup lookup handle.
#define GNUNET_REST_PEERINFO_PEER
Peerinfo parameter peer.
char * result
Printable address.
The identity of the host (wraps the signing key of the peer).
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
static struct PrintContext * pc_head
Head of list of print contexts.
void * libgnunet_plugin_rest_peerinfo_done(void *cls)
Exit point from the plugin.
unsigned int off
Current offset in address_list (counted down).
configuration data
Definition: configuration.c:83
Handle for a plugin.
Definition: block.c:37
struct GNUNET_SCHEDULER_Task * timeout_task
ID of a task associated with the resolution process.
struct MHD_Response * GNUNET_REST_create_response(const char *data)
Create REST MHD response.
Definition: rest.c:56
char * expiration_str
Expiration time string.
An address for communicating with a peer.
json_t * temp_array
JSON temporary array.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:131
#define TIMEOUT
How long until we time out during address lookup?
void GNUNET_PEERINFO_disconnect(struct GNUNET_PEERINFO_Handle *h)
Disconnect from the peerinfo service.
Definition: peerinfo_api.c:154
static struct MHD_Response * response
Our canonical response.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:331
static void rest_process_request(struct GNUNET_REST_RequestHandle *rest_handle, GNUNET_REST_ResultProcessor proc, void *proc_cls)
Function processing the REST call.
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:77
static void options_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Respond to OPTIONS request.
int friend_only
Hello was friend only, GNUNET_YES or GNUNET_NO.
struct AddressRecord * address_list
List of printable addresses.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:741
static int count_address(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Iterator callback to go over all addresses and count them.
static void dump_pc(struct PrintContext *pc)
Print the collected address information to the console and free pc.
unsigned int address_list_size
Number of addresses allocated in address_list.
const char * address
Address string.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
static char * address
GNS address for this phone.
struct RequestHandle * handle
RequestHandle.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_REST_PEERINFO_FRIEND
Peerinfo parameter friend.
char * pubkey
Iteration peer public key.
static struct PrintContext * pc_tail
Tail of list of print contexts.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
static void do_error(void *cls)
Task run on errors.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
char * url
The url.