GNUnet  0.11.x
reclaim_api.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2016 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"
28 #include "gnunet_constants.h"
29 #include "gnunet_mq_lib.h"
30 #include "gnunet_protocols.h"
32 #include "gnunet_reclaim_service.h"
33 #include "reclaim.h"
34 
35 #define LOG(kind, ...) GNUNET_log_from (kind, "reclaim-api", __VA_ARGS__)
36 
37 
42 {
47 
52 
57 
62  const struct GNUNET_MessageHeader *msg;
63 
68 
73 
78 
83 
88 
92  uint32_t r_id;
93 
97  void *cls;
98 };
99 
100 
105 {
110 
115 
120 
125 
130 
135 
139  void *cls;
140 
145 
150 
156 
160  uint32_t r_id;
161 };
162 
163 
168 {
173 
178 
183 
188 
193 
198 
202  void *proc_cls;
203 
208 
213 
219 
224 
228  uint32_t r_id;
229 };
230 
231 
236 {
241 
245  struct GNUNET_CLIENT_Connection *client;
246 
250  void *cb_cls;
251 
256 
261 
266 
271 
276 
281 
285  struct GNUNET_CLIENT_TransmitHandle *th;
286 
291 
295  struct GNUNET_TIME_Relative reconnect_backoff;
296 
301 
305  uint32_t r_id_gen;
306 
311 };
312 
313 
319 static void
321 
322 
328 static void
330 {
331  struct GNUNET_RECLAIM_Handle *handle = cls;
332 
333  handle->reconnect_task = NULL;
334  reconnect (handle);
335 }
336 
337 
343 static void
345 {
346  GNUNET_MQ_destroy (handle->mq);
347  handle->mq = NULL;
348  handle->reconnect_backoff =
350  handle->reconnect_task =
353  handle);
354 }
355 
356 
362 static void
364 {
365  struct GNUNET_RECLAIM_Handle *h = it->h;
366 
368  if (NULL != it->env)
369  GNUNET_MQ_discard (it->env);
370  GNUNET_free (it);
371 }
372 
373 
379 static void
381 {
382  if (NULL == op)
383  return;
384  if (NULL != op->env)
385  GNUNET_MQ_discard (op->env);
386  GNUNET_free (op);
387 }
388 
389 
398 static void
400 {
401  struct GNUNET_RECLAIM_Handle *handle = cls;
402 
403  force_reconnect (handle);
404 }
405 
406 
414 static void
416 {
417  struct GNUNET_RECLAIM_Handle *h = cls;
419  uint32_t r_id = ntohl (msg->id);
420  int res;
421  const char *emsg;
422 
423  for (op = h->op_head; NULL != op; op = op->next)
424  if (op->r_id == r_id)
425  break;
426  if (NULL == op)
427  return;
428 
429  res = ntohl (msg->op_result);
431  "Received SUCCESS_RESPONSE with result %d\n",
432  res);
433 
434  /* TODO: add actual error message to response... */
435  if (GNUNET_SYSERR == res)
436  emsg = _ ("failed to store record\n");
437  else
438  emsg = NULL;
439  if (NULL != op->as_cb)
440  op->as_cb (op->cls, res, emsg);
442  free_op (op);
443 }
444 
445 
454 static int
456  const struct ConsumeTicketResultMessage *msg)
457 {
458  size_t msg_len;
459  size_t attrs_len;
460 
461  msg_len = ntohs (msg->header.size);
462  attrs_len = ntohs (msg->attrs_len);
463  if (msg_len != sizeof(struct ConsumeTicketResultMessage) + attrs_len)
464  {
465  GNUNET_break (0);
466  return GNUNET_SYSERR;
467  }
468  return GNUNET_OK;
469 }
470 
471 
479 static void
481  const struct ConsumeTicketResultMessage *msg)
482 {
483  struct GNUNET_RECLAIM_Handle *h = cls;
485  size_t attrs_len;
486  uint32_t r_id = ntohl (msg->id);
487 
488  attrs_len = ntohs (msg->attrs_len);
489  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
490 
491 
492  for (op = h->op_head; NULL != op; op = op->next)
493  if (op->r_id == r_id)
494  break;
495  if (NULL == op)
496  return;
497 
498  {
501  attrs =
502  GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *) &msg[1], attrs_len);
503  if (NULL != op->ar_cb)
504  {
505  if (NULL == attrs)
506  {
507  op->ar_cb (op->cls, &msg->identity, NULL);
508  }
509  else
510  {
511  for (le = attrs->list_head; NULL != le; le = le->next)
512  op->ar_cb (op->cls, &msg->identity, le->claim);
514  attrs = NULL;
515  }
516  op->ar_cb (op->cls, NULL, NULL);
517  }
519  free_op (op);
520  GNUNET_free_non_null (attrs);
521  return;
522  }
523  GNUNET_assert (0);
524 }
525 
526 
535 static int
537 {
538  size_t msg_len;
539  size_t attr_len;
540 
541  msg_len = ntohs (msg->header.size);
542  attr_len = ntohs (msg->attr_len);
543  if (msg_len != sizeof(struct AttributeResultMessage) + attr_len)
544  {
545  GNUNET_break (0);
546  return GNUNET_SYSERR;
547  }
548  return GNUNET_OK;
549 }
550 
551 
559 static void
561 {
562  static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
563  struct GNUNET_RECLAIM_Handle *h = cls;
566  size_t attr_len;
567  uint32_t r_id = ntohl (msg->id);
568 
569  attr_len = ntohs (msg->attr_len);
570  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
571 
572 
573  for (it = h->it_head; NULL != it; it = it->next)
574  if (it->r_id == r_id)
575  break;
576  for (op = h->op_head; NULL != op; op = op->next)
577  if (op->r_id == r_id)
578  break;
579  if ((NULL == it) && (NULL == op))
580  return;
581 
582  if ((0 ==
583  (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
584  {
585  if ((NULL == it) && (NULL == op))
586  {
587  GNUNET_break (0);
588  force_reconnect (h);
589  return;
590  }
591  if (NULL != it)
592  {
593  if (NULL != it->finish_cb)
594  it->finish_cb (it->finish_cb_cls);
595  free_it (it);
596  }
597  if (NULL != op)
598  {
599  if (NULL != op->ar_cb)
600  op->ar_cb (op->cls, NULL, NULL);
602  free_op (op);
603  }
604  return;
605  }
606 
607  {
608  struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
609  attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &msg[1], attr_len);
610  if (NULL != it)
611  {
612  if (NULL != it->proc)
613  it->proc (it->proc_cls, &msg->identity, attr);
614  }
615  else if (NULL != op)
616  {
617  if (NULL != op->ar_cb)
618  op->ar_cb (op->cls, &msg->identity, attr);
619  }
620  GNUNET_free (attr);
621  return;
622  }
623  GNUNET_assert (0);
624 }
625 
626 
634 static void
636 {
637  struct GNUNET_RECLAIM_Handle *handle = cls;
640  uint32_t r_id = ntohl (msg->id);
641  static const struct GNUNET_RECLAIM_Ticket ticket;
642 
643  for (op = handle->op_head; NULL != op; op = op->next)
644  if (op->r_id == r_id)
645  break;
646  for (it = handle->ticket_it_head; NULL != it; it = it->next)
647  if (it->r_id == r_id)
648  break;
649  if ((NULL == op) && (NULL == it))
650  return;
651  if (NULL != op)
652  {
653  GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
654  if (0 ==
655  memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
656  {
657  if (NULL != op->tr_cb)
658  op->tr_cb (op->cls, NULL);
659  }
660  else
661  {
662  if (NULL != op->tr_cb)
663  op->tr_cb (op->cls, &msg->ticket);
664  }
665  free_op (op);
666  return;
667  }
668  else if (NULL != it)
669  {
670  if (0 ==
671  memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
672  {
674  handle->ticket_it_tail,
675  it);
676  it->finish_cb (it->finish_cb_cls);
677  GNUNET_free (it);
678  }
679  else
680  {
681  if (NULL != it->tr_cb)
682  it->tr_cb (it->cls, &msg->ticket);
683  }
684  return;
685  }
686  GNUNET_break (0);
687 }
688 
689 
697 static void
699  const struct RevokeTicketResultMessage *msg)
700 {
701  struct GNUNET_RECLAIM_Handle *h = cls;
703  uint32_t r_id = ntohl (msg->id);
704  int32_t success;
705 
706  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n");
707 
708 
709  for (op = h->op_head; NULL != op; op = op->next)
710  if (op->r_id == r_id)
711  break;
712  if (NULL == op)
713  return;
714  success = ntohl (msg->success);
715  {
716  if (NULL != op->rvk_cb)
717  {
718  op->rvk_cb (op->cls, success, NULL);
719  }
721  free_op (op);
722  return;
723  }
724  GNUNET_assert (0);
725 }
726 
727 
733 static void
735 {
736  struct GNUNET_MQ_MessageHandler handlers[] =
737  { GNUNET_MQ_hd_fixed_size (success_response,
739  struct SuccessResultMessage,
740  h),
741  GNUNET_MQ_hd_var_size (attribute_result,
743  struct AttributeResultMessage,
744  h),
745  GNUNET_MQ_hd_fixed_size (ticket_result,
747  struct TicketResultMessage,
748  h),
749  GNUNET_MQ_hd_var_size (consume_ticket_result,
752  h),
753  GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
756  h),
759 
760  GNUNET_assert (NULL == h->mq);
761  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
762 
763  h->mq =
764  GNUNET_CLIENT_connect (h->cfg, "reclaim", handlers, &mq_error_handler, h);
765  if (NULL == h->mq)
766  return;
767  for (op = h->op_head; NULL != op; op = op->next)
768  GNUNET_MQ_send_copy (h->mq, op->env);
769 }
770 
771 
778 struct GNUNET_RECLAIM_Handle *
780 {
781  struct GNUNET_RECLAIM_Handle *h;
782 
783  h = GNUNET_new (struct GNUNET_RECLAIM_Handle);
784  h->cfg = cfg;
785  reconnect (h);
786  if (NULL == h->mq)
787  {
788  GNUNET_free (h);
789  return NULL;
790  }
791  return h;
792 }
793 
794 
803 void
805 {
806  struct GNUNET_RECLAIM_Handle *h = op->h;
807 
809  free_op (op);
810 }
811 
812 
818 void
820 {
821  GNUNET_assert (NULL != h);
822  if (NULL != h->mq)
823  {
824  GNUNET_MQ_destroy (h->mq);
825  h->mq = NULL;
826  }
827  if (NULL != h->reconnect_task)
828  {
830  h->reconnect_task = NULL;
831  }
832  GNUNET_assert (NULL == h->op_head);
833  GNUNET_free (h);
834 }
835 
836 
851  struct GNUNET_RECLAIM_Handle *h,
852  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
853  const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
854  const struct GNUNET_TIME_Relative *exp_interval,
856  void *cont_cls)
857 {
859  struct AttributeStoreMessage *sam;
860  size_t attr_len;
861 
862  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
863  op->h = h;
864  op->as_cb = cont;
865  op->cls = cont_cls;
866  op->r_id = h->r_id_gen++;
869  op->env = GNUNET_MQ_msg_extra (sam,
870  attr_len,
872  sam->identity = *pkey;
873  sam->id = htonl (op->r_id);
874  sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
875 
876  GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &sam[1]);
877 
878  sam->attr_len = htons (attr_len);
879  if (NULL != h->mq)
880  GNUNET_MQ_send_copy (h->mq, op->env);
881  return op;
882 }
883 
884 
898  struct GNUNET_RECLAIM_Handle *h,
899  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
900  const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
902  void *cont_cls)
903 {
905  struct AttributeDeleteMessage *dam;
906  size_t attr_len;
907 
908  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
909  op->h = h;
910  op->as_cb = cont;
911  op->cls = cont_cls;
912  op->r_id = h->r_id_gen++;
915  op->env = GNUNET_MQ_msg_extra (dam,
916  attr_len,
918  dam->identity = *pkey;
919  dam->id = htonl (op->r_id);
920  GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &dam[1]);
921 
922  dam->attr_len = htons (attr_len);
923  if (NULL != h->mq)
924  GNUNET_MQ_send_copy (h->mq, op->env);
925  return op;
926 }
927 
928 
955  struct GNUNET_RECLAIM_Handle *h,
958  void *error_cb_cls,
960  void *proc_cls,
962  void *finish_cb_cls)
963 {
965  struct GNUNET_MQ_Envelope *env;
967  uint32_t rid;
968 
969  rid = h->r_id_gen++;
971  it->h = h;
972  it->error_cb = error_cb;
973  it->error_cb_cls = error_cb_cls;
974  it->finish_cb = finish_cb;
975  it->finish_cb_cls = finish_cb_cls;
976  it->proc = proc;
977  it->proc_cls = proc_cls;
978  it->r_id = rid;
979  it->identity = *identity;
981  env =
983  msg->id = htonl (rid);
984  msg->identity = *identity;
985  if (NULL == h->mq)
986  it->env = env;
987  else
988  GNUNET_MQ_send (h->mq, env);
989  return it;
990 }
991 
992 
999 void
1001 {
1002  struct GNUNET_RECLAIM_Handle *h = it->h;
1004  struct GNUNET_MQ_Envelope *env;
1005 
1006  env =
1008  msg->id = htonl (it->r_id);
1009  GNUNET_MQ_send (h->mq, env);
1010 }
1011 
1012 
1020 void
1022 {
1023  struct GNUNET_RECLAIM_Handle *h = it->h;
1024  struct GNUNET_MQ_Envelope *env;
1026 
1027  if (NULL != h->mq)
1028  {
1029  env =
1031  msg->id = htonl (it->r_id);
1032  GNUNET_MQ_send (h->mq, env);
1033  }
1034  free_it (it);
1035 }
1036 
1037 
1051 struct GNUNET_RECLAIM_Operation *
1053  struct GNUNET_RECLAIM_Handle *h,
1054  const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
1055  const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
1056  const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
1058  void *cb_cls)
1059 {
1060  struct GNUNET_RECLAIM_Operation *op;
1061  struct IssueTicketMessage *tim;
1062  size_t attr_len;
1063 
1064  fprintf (stderr, "Issuing ticket\n");
1065  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1066  op->h = h;
1067  op->tr_cb = cb;
1068  op->cls = cb_cls;
1069  op->r_id = h->r_id_gen++;
1072  op->env = GNUNET_MQ_msg_extra (tim,
1073  attr_len,
1075  tim->identity = *iss;
1076  tim->rp = *rp;
1077  tim->id = htonl (op->r_id);
1078 
1079  GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, (char *) &tim[1]);
1080 
1081  tim->attr_len = htons (attr_len);
1082  if (NULL != h->mq)
1083  GNUNET_MQ_send_copy (h->mq, op->env);
1084  return op;
1085 }
1086 
1087 
1100 struct GNUNET_RECLAIM_Operation *
1102  struct GNUNET_RECLAIM_Handle *h,
1104  const struct GNUNET_RECLAIM_Ticket *ticket,
1106  void *cb_cls)
1107 {
1108  struct GNUNET_RECLAIM_Operation *op;
1109  struct ConsumeTicketMessage *ctm;
1110 
1111  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1112  op->h = h;
1113  op->ar_cb = cb;
1114  op->cls = cb_cls;
1115  op->r_id = h->r_id_gen++;
1118  ctm->identity = *identity;
1119  ctm->id = htonl (op->r_id);
1120  ctm->ticket = *ticket;
1121  if (NULL != h->mq)
1122  GNUNET_MQ_send_copy (h->mq, op->env);
1123  return op;
1124 }
1125 
1126 
1146  struct GNUNET_RECLAIM_Handle *h,
1149  void *error_cb_cls,
1151  void *proc_cls,
1153  void *finish_cb_cls)
1154 {
1155  struct GNUNET_RECLAIM_TicketIterator *it;
1156  struct GNUNET_MQ_Envelope *env;
1158  uint32_t rid;
1159 
1160  rid = h->r_id_gen++;
1162  it->h = h;
1163  it->error_cb = error_cb;
1164  it->error_cb_cls = error_cb_cls;
1165  it->finish_cb = finish_cb;
1166  it->finish_cb_cls = finish_cb_cls;
1167  it->tr_cb = proc;
1168  it->cls = proc_cls;
1169  it->r_id = rid;
1172  msg->id = htonl (rid);
1173  msg->identity = *identity;
1174  if (NULL == h->mq)
1175  it->env = env;
1176  else
1177  GNUNET_MQ_send (h->mq, env);
1178  return it;
1179 }
1180 
1181 
1188 void
1190 {
1191  struct GNUNET_RECLAIM_Handle *h = it->h;
1193  struct GNUNET_MQ_Envelope *env;
1194 
1196  msg->id = htonl (it->r_id);
1197  GNUNET_MQ_send (h->mq, env);
1198 }
1199 
1200 
1208 void
1210 {
1211  struct GNUNET_RECLAIM_Handle *h = it->h;
1212  struct GNUNET_MQ_Envelope *env;
1214 
1215  if (NULL != h->mq)
1216  {
1217  env =
1219  msg->id = htonl (it->r_id);
1220  GNUNET_MQ_send (h->mq, env);
1221  }
1222  GNUNET_free (it);
1223 }
1224 
1225 
1239 struct GNUNET_RECLAIM_Operation *
1241  struct GNUNET_RECLAIM_Handle *h,
1243  const struct GNUNET_RECLAIM_Ticket *ticket,
1245  void *cb_cls)
1246 {
1247  struct GNUNET_RECLAIM_Operation *op;
1248  struct RevokeTicketMessage *msg;
1249  uint32_t rid;
1250 
1251  rid = h->r_id_gen++;
1252  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1253  op->h = h;
1254  op->rvk_cb = cb;
1255  op->cls = cb_cls;
1256  op->r_id = rid;
1259  msg->id = htonl (rid);
1260  msg->identity = *identity;
1261  msg->ticket = *ticket;
1262  if (NULL != h->mq)
1263  {
1264  GNUNET_MQ_send (h->mq, op->env);
1265  op->env = NULL;
1266  }
1267  return op;
1268 }
1269 
1270 
1271 /* end of reclaim_api.c */
#define LOG(kind,...)
Definition: reclaim_api.c:35
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_RECLAIM_TicketIterator * ticket_it_tail
Tail of active iterations.
Definition: reclaim_api.c:280
#define GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
static int check_attribute_result(void *cls, const struct AttributeResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT.
Definition: reclaim_api.c:536
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:367
Ticket result message.
Definition: reclaim.h:357
Handle to the service.
Definition: reclaim_api.c:235
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:319
The authorization ticket.
struct GNUNET_CRYPTO_EcdsaPublicKey rp
Requesting party.
Definition: reclaim.h:291
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:65
struct GNUNET_RECLAIM_Handle * h
Main handle.
Definition: reclaim_api.c:46
struct GNUNET_RECLAIM_AttributeIterator * GNUNET_RECLAIM_get_attributes_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_AttributeResult proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
List all attributes for a local identity.
Definition: reclaim_api.c:954
struct GNUNET_RECLAIM_Ticket ticket
The new ticket.
Definition: reclaim.h:372
struct GNUNET_RECLAIM_Operation * prev
We keep operations in a DLL.
Definition: reclaim_api.c:56
Attribute list is returned from the idp.
Definition: reclaim.h:404
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
uint64_t rel_value_us
The actual value.
static char * pkey
Public key of the zone to look in, in ASCII.
void * cb_cls
Closure for &#39;cb&#39;.
Definition: reclaim_api.c:250
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:97
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT
GNUNET_RECLAIM_ContinuationWithStatus as_cb
Continuation to invoke after attribute store call.
Definition: reclaim_api.c:67
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:230
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store an attribute.
Definition: reclaim_api.c:850
Ticket consume message.
Definition: reclaim.h:378
struct GNUNET_RECLAIM_TicketIterator * GNUNET_RECLAIM_ticket_iteration_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_TicketCallback proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Lists all tickets that have been issued to remote identites (relying parties)
Definition: reclaim_api.c:1145
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:94
struct GNUNET_SCHEDULER_Task * reconnect_task
Task doing exponential back-off trying to reconnect.
Definition: reclaim_api.c:290
Start a attribute iteration for the given identity.
Definition: reclaim.h:160
GNUNET_MQ_Error
Error codes for the queue.
static void error_cb(void *cls)
Function called if lookup fails.
Definition: gnunet-abd.c:485
int in_receive
Are we polling for incoming messages right now?
Definition: reclaim_api.c:310
Stop attribute iteration for the given operation.
Definition: reclaim.h:199
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:118
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:314
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:134
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:414
struct GNUNET_CLIENT_TransmitHandle * th
Currently pending transmission request, or NULL for none.
Definition: reclaim_api.c:285
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT
Use to delete an identity attribute.
Definition: reclaim.h:74
void GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h)
Disconnect from service.
Definition: reclaim_api.c:819
struct GNUNET_RECLAIM_AttributeIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:177
void GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op)
Cancel an operation.
Definition: reclaim_api.c:804
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:129
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
void GNUNET_RECLAIM_ticket_iteration_next(struct GNUNET_RECLAIM_TicketIterator *it)
Calls the ticket processor specified in GNUNET_RECLAIM_ticket_iteration_start for the next record...
Definition: reclaim_api.c:1189
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT
void GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1209
#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 * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:192
Private ECC key encoded for transmission.
void GNUNET_RECLAIM_get_attributes_next(struct GNUNET_RECLAIM_AttributeIterator *it)
Calls the record processor specified in GNUNET_RECLAIM_get_attributes_start for the next record...
Definition: reclaim_api.c:1000
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:89
static struct GNUNET_TIME_Relative exp_interval
Attribute expiration interval.
Handle for an operation with the service.
Definition: reclaim_api.c:41
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: reclaim_api.c:207
Use to store an identity attribute.
Definition: reclaim.h:40
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:286
GNUNET_RECLAIM_AttributeResult proc
The continuation to call with the results.
Definition: reclaim_api.c:197
struct GNUNET_RECLAIM_Handle * h
Main handle to access the idp.
Definition: reclaim_api.c:119
struct GNUNET_RECLAIM_AttributeIterator * it_tail
Tail of active iterations.
Definition: reclaim_api.c:270
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void * proc_cls
Closure for proc.
Definition: reclaim_api.c:202
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
Ask for next result of ticket iteration for the given operation.
Definition: reclaim.h:237
static void force_reconnect(struct GNUNET_RECLAIM_Handle *handle)
Disconnect from service and then reconnect.
Definition: reclaim_api.c:344
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static void reconnect(struct GNUNET_RECLAIM_Handle *h)
Try again to connect to the service.
Definition: reclaim_api.c:734
Common type definitions for the identity provider service and API.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:247
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
void GNUNET_RECLAIM_ATTRIBUTE_list_destroy(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
Destroy claim list.
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
Definition: reclaim_api.c:300
GNUNET_RECLAIM_ContinuationWithStatus rvk_cb
Revocation result callback.
Definition: reclaim_api.c:77
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
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:1253
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:260
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_revoke(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls)
Revoked an issued ticket.
Definition: reclaim_api.c:1240
Handle for a attribute iterator operation.
Definition: reclaim_api.c:167
void(* GNUNET_RECLAIM_AttributeResult)(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
Callback used to notify the client of attribute results.
void(* GNUNET_RECLAIM_ContinuationWithStatus)(void *cls, int32_t success, const char *emsg)
Continuation called to notify client about result of the operation.
struct GNUNET_RECLAIM_AttributeIterator * next
Kept in a DLL.
Definition: reclaim_api.c:172
void(* GNUNET_RECLAIM_TicketCallback)(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
Method called when a token has been issued.
const struct GNUNET_MessageHeader * msg
Message to send to the service.
Definition: reclaim_api.c:62
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:209
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an attribute.
Definition: reclaim_api.c:897
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:393
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:228
Stop ticket iteration for the given operation.
Definition: reclaim.h:254
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:192
struct GNUNET_RECLAIM_Ticket ticket
The ticket to revoke.
Definition: reclaim.h:329
struct GNUNET_MQ_Envelope * env
Envelope with the message for this queue entry.
Definition: reclaim_api.c:87
static int check_consume_ticket_result(void *cls, const struct ConsumeTicketResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT.
Definition: reclaim_api.c:455
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_issue(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, GNUNET_RECLAIM_TicketCallback cb, void *cb_cls)
Issues a ticket to another relying party.
Definition: reclaim_api.c:1052
static void handle_consume_ticket_result(void *cls, const struct ConsumeTicketResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT.
Definition: reclaim_api.c:480
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:155
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:149
uint32_t r_id_gen
Request Id generator.
Definition: reclaim_api.c:305
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:160
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:175
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:51
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:55
static void handle_attribute_result(void *cls, const struct AttributeResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT.
Definition: reclaim_api.c:560
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:170
Ticket issue message.
Definition: reclaim.h:271
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE
void * cls
Closure for tr_cb.
Definition: reclaim_api.c:139
Message handler for a specific message type.
static int res
Attribute store/delete response message.
Definition: reclaim.h:103
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:321
uint64_t exp
The expiration interval of the attribute.
Definition: reclaim.h:60
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:281
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
uint32_t attr_len
length of serialized attribute list
Definition: reclaim.h:296
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_RECLAIM_Ticket ticket
The ticket to consume.
Definition: reclaim.h:398
Ask for next result of attribute iteration for the given operation.
Definition: reclaim.h:182
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:84
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Private key of the zone.
Definition: reclaim_api.c:223
GNUNET_RECLAIM_TicketCallback tr_cb
Ticket result callback.
Definition: reclaim_api.c:82
static void handle_ticket_result(void *cls, const struct TicketResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT.
Definition: reclaim_api.c:635
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:255
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
GNUNET_RECLAIM_AttributeResult ar_cb
Attribute result callback.
Definition: reclaim_api.c:72
static void handle_success_response(void *cls, const struct SuccessResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE.
Definition: reclaim_api.c:415
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
struct GNUNET_RECLAIM_TicketIterator * next
Kept in a DLL.
Definition: reclaim_api.c:109
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START
#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
struct GNUNET_CLIENT_Connection * client
Socket (if available).
Definition: reclaim_api.c:245
Handle to a message queue.
Definition: mq.c:85
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP
static void handle_revoke_ticket_result(void *cls, const struct RevokeTicketResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT.
Definition: reclaim_api.c:698
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
Get required size for serialization buffer.
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: reclaim_api.c:240
Ticket revoke message.
Definition: reclaim.h:335
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: reclaim_api.c:144
GNUNET_RECLAIM_TicketCallback tr_cb
The continuation to call with the results.
Definition: reclaim_api.c:134
configuration data
Definition: configuration.c:85
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:218
void GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1021
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:225
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
struct GNUNET_RECLAIM_AttributeIterator * it_head
Head of active iterations.
Definition: reclaim_api.c:265
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:345
void GNUNET_MQ_send_copy(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MQ_Envelope *ev)
Send a copy of a message with the given message queue.
Definition: mq.c:432
Attribute is returned from the idp.
Definition: reclaim.h:124
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:139
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:212
A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
struct GNUNET_TIME_Relative reconnect_backoff
Time for next connect retry.
Definition: reclaim_api.c:295
Start a ticket iteration for the given identity.
Definition: reclaim.h:215
Handle for a ticket iterator operation.
Definition: reclaim_api.c:104
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:424
Entry in list of pending tasks.
Definition: scheduler.c:134
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:409
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:149
static char * rp
Relying party.
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
Header for all communications.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_consume(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_AttributeResult cb, void *cb_cls)
Consumes an issued ticket.
Definition: reclaim_api.c:1101
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, char *result)
Serialize an attribute.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
static void free_it(struct GNUNET_RECLAIM_AttributeIterator *it)
Free it.
Definition: reclaim_api.c:363
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:264
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
struct GNUNET_RECLAIM_Handle * h
Main handle to access the service.
Definition: reclaim_api.c:182
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the reclaim service.
Definition: reclaim_api.c:779
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:129
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * next
DLL.
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:380
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
uint32_t success
Revocation result.
Definition: reclaim.h:350
struct GNUNET_RECLAIM_TicketIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:114
size_t GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size(const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
Get required size for serialization buffer.
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:124
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:50
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:388
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
size_t GNUNET_RECLAIM_ATTRIBUTE_list_serialize(const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, char *result)
Serialize an attribute list.
struct GNUNET_RECLAIM_TicketIterator * ticket_it_head
Head of active iterations.
Definition: reclaim_api.c:275
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * GNUNET_RECLAIM_ATTRIBUTE_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
static void reconnect_task(void *cls)
Reconnect.
Definition: reclaim_api.c:329
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:187
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:113
#define GNUNET_free(ptr)
Wrapper around free.
Ticket revoke message.
Definition: reclaim.h:304
Time for relative time used by GNUnet, in microseconds.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
Definition: reclaim_api.c:399
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET
uint32_t r_id
request id
Definition: reclaim_api.c:92
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966