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  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket 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  {
502  attrs =
503  GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *) &msg[1], attrs_len);
504  if (NULL != op->ar_cb)
505  {
506  if (NULL == attrs)
507  {
508  op->ar_cb (op->cls, &msg->identity, NULL, NULL, NULL);
509  }
510  else
511  {
512  for (le = attrs->list_head; NULL != le; le = le->next)
513  {
514  if (le->reference != NULL && le->attest == NULL)
515  {
516  for (le2 = attrs->list_head; NULL != le2; le2 = le2->next)
517  {
518  if (le2->attest != NULL && le2->attest->id == le->reference->id_attest)
519  {
520  op->ar_cb (op->cls, &msg->identity, le->claim, le2->attest, le->reference);
521  break;
522  }
523 
524  }
525  }
526  }
528  attrs = NULL;
529  }
530  op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
531  }
533  free_op (op);
534  GNUNET_free_non_null (attrs);
535  return;
536  }
537  GNUNET_assert (0);
538 }
539 
540 
549 static int
551 {
552  size_t msg_len;
553  size_t attr_len;
554 
555  msg_len = ntohs (msg->header.size);
556  attr_len = ntohs (msg->attr_len);
557  if (msg_len != sizeof(struct AttributeResultMessage) + attr_len)
558  {
559  GNUNET_break (0);
560  return GNUNET_SYSERR;
561  }
562  return GNUNET_OK;
563 }
564 
565 
573 static void
575 {
576  static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
577  struct GNUNET_RECLAIM_Handle *h = cls;
580  size_t attr_len;
581  uint32_t r_id = ntohl (msg->id);
582 
583  attr_len = ntohs (msg->attr_len);
584  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
585 
586 
587  for (it = h->it_head; NULL != it; it = it->next)
588  if (it->r_id == r_id)
589  break;
590  for (op = h->op_head; NULL != op; op = op->next)
591  if (op->r_id == r_id)
592  break;
593  if ((NULL == it) && (NULL == op))
594  return;
595 
596  if ((0 ==
597  (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
598  {
599  if ((NULL == it) && (NULL == op))
600  {
601  GNUNET_break (0);
602  force_reconnect (h);
603  return;
604  }
605  if (NULL != it)
606  {
607  if (NULL != it->finish_cb)
608  it->finish_cb (it->finish_cb_cls);
609  free_it (it);
610  }
611  if (NULL != op)
612  {
613  if (NULL != op->ar_cb)
614  op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
616  free_op (op);
617  }
618  return;
619  }
620 
621  {
622  struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
623  attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &msg[1], attr_len);
624  if (NULL != it)
625  {
626  if (NULL != it->proc)
627  it->proc (it->proc_cls, &msg->identity, attr, NULL, NULL);
628  }
629  else if (NULL != op)
630  {
631  if (NULL != op->ar_cb)
632  op->ar_cb (op->cls, &msg->identity, attr, NULL, NULL);
633  }
634  GNUNET_free (attr);
635  return;
636  }
637  GNUNET_assert (0);
638 }
639 
648 static int
650 {
651  size_t msg_len;
652  size_t attr_len;
653 
654  msg_len = ntohs (msg->header.size);
655  attr_len = ntohs (msg->attr_len);
656  if (msg_len != sizeof(struct AttributeResultMessage) + attr_len)
657  {
658  GNUNET_break (0);
659  return GNUNET_SYSERR;
660  }
661  return GNUNET_OK;
662 }
663 
664 
672 static void
674 {
675  static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
676  struct GNUNET_RECLAIM_Handle *h = cls;
679  size_t attr_len;
680  uint32_t r_id = ntohl (msg->id);
681 
682  attr_len = ntohs (msg->attr_len);
683  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attestation result.\n");
684 
685 
686  for (it = h->it_head; NULL != it; it = it->next)
687  if (it->r_id == r_id)
688  break;
689  for (op = h->op_head; NULL != op; op = op->next)
690  if (op->r_id == r_id)
691  break;
692  if ((NULL == it) && (NULL == op))
693  return;
694 
695  if ((0 ==
696  (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
697  {
698  if ((NULL == it) && (NULL == op))
699  {
700  GNUNET_break (0);
701  force_reconnect (h);
702  return;
703  }
704  if (NULL != it)
705  {
706  if (NULL != it->finish_cb)
707  it->finish_cb (it->finish_cb_cls);
708  free_it (it);
709  }
710  if (NULL != op)
711  {
712  if (NULL != op->ar_cb)
713  op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
715  free_op (op);
716  }
717  return;
718  }
719 
720  {
722  attr = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &msg[1], attr_len);
723  if (NULL != it)
724  {
725  if (NULL != it->proc)
726  it->proc (it->proc_cls, &msg->identity, NULL, attr, NULL);
727  }
728  else if (NULL != op)
729  {
730  if (NULL != op->ar_cb)
731  op->ar_cb (op->cls, &msg->identity, NULL, attr, NULL);
732  }
733  GNUNET_free (attr);
734  return;
735  }
736  GNUNET_assert (0);
737 }
738 
747 static int
749 {
750  size_t msg_len;
751  size_t attr_len;
752  size_t ref_len;
753 
754  msg_len = ntohs (msg->header.size);
755  attr_len = ntohs (msg->attest_len);
756  ref_len = ntohs (msg->ref_len);
757  if (msg_len != sizeof(struct ReferenceResultMessage) + attr_len + ref_len)
758  {
759  GNUNET_break (0);
760  return GNUNET_SYSERR;
761  }
762  return GNUNET_OK;
763 }
764 
772 static void
774 {
775  static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
776  struct GNUNET_RECLAIM_Handle *h = cls;
779  size_t attest_len;
780  size_t ref_len;
781  uint32_t r_id = ntohl (msg->id);
782  attest_len = ntohs (msg->attest_len);
783  ref_len = ntohs (msg->ref_len);
784  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing reference result.\n");
785  for (it = h->it_head; NULL != it; it = it->next)
786  if (it->r_id == r_id)
787  break;
788  for (op = h->op_head; NULL != op; op = op->next)
789  if (op->r_id == r_id)
790  break;
791  if ((NULL == it) && (NULL == op))
792  return;
793 
794  if ((0 ==
795  (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
796  {
797  if ((NULL == it) && (NULL == op))
798  {
799  GNUNET_break (0);
800  force_reconnect (h);
801  return;
802  }
803  if (NULL != it)
804  {
805  if (NULL != it->finish_cb)
806  it->finish_cb (it->finish_cb_cls);
807  free_it (it);
808  }
809  if (NULL != op)
810  {
811  if (NULL != op->ar_cb)
812  op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
814  free_op (op);
815  }
816  return;
817  }
818 
819  {
821  struct GNUNET_RECLAIM_ATTESTATION_Claim *attest;
822  attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &msg[1],
823  attest_len);
824  ref = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &msg[1]
825  + attest_len,
826  ref_len);
827  if (NULL != it)
828  {
829  if (NULL != it->proc)
830  it->proc (it->proc_cls, &msg->identity, NULL, attest, ref);
831  }
832  else if (NULL != op)
833  {
834  if (NULL != op->ar_cb)
835  op->ar_cb (op->cls, &msg->identity, NULL, attest, ref);
836  }
837  GNUNET_free (ref);
838  GNUNET_free (attest);
839  return;
840  }
841  GNUNET_assert (0);
842 }
843 
851 static void
853 {
854  struct GNUNET_RECLAIM_Handle *handle = cls;
857  uint32_t r_id = ntohl (msg->id);
858  static const struct GNUNET_RECLAIM_Ticket ticket;
859 
860  for (op = handle->op_head; NULL != op; op = op->next)
861  if (op->r_id == r_id)
862  break;
863  for (it = handle->ticket_it_head; NULL != it; it = it->next)
864  if (it->r_id == r_id)
865  break;
866  if ((NULL == op) && (NULL == it))
867  return;
868  if (NULL != op)
869  {
870  GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
871  if (0 ==
872  memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
873  {
874  if (NULL != op->tr_cb)
875  op->tr_cb (op->cls, NULL);
876  }
877  else
878  {
879  if (NULL != op->tr_cb)
880  op->tr_cb (op->cls, &msg->ticket);
881  }
882  free_op (op);
883  return;
884  }
885  else if (NULL != it)
886  {
887  if (0 ==
888  memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
889  {
891  handle->ticket_it_tail,
892  it);
893  it->finish_cb (it->finish_cb_cls);
894  GNUNET_free (it);
895  }
896  else
897  {
898  if (NULL != it->tr_cb)
899  it->tr_cb (it->cls, &msg->ticket);
900  }
901  return;
902  }
903  GNUNET_break (0);
904 }
905 
906 
914 static void
916  const struct RevokeTicketResultMessage *msg)
917 {
918  struct GNUNET_RECLAIM_Handle *h = cls;
920  uint32_t r_id = ntohl (msg->id);
921  int32_t success;
922 
923  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n");
924 
925 
926  for (op = h->op_head; NULL != op; op = op->next)
927  if (op->r_id == r_id)
928  break;
929  if (NULL == op)
930  return;
931  success = ntohl (msg->success);
932  {
933  if (NULL != op->rvk_cb)
934  {
935  op->rvk_cb (op->cls, success, NULL);
936  }
938  free_op (op);
939  return;
940  }
941  GNUNET_assert (0);
942 }
943 
944 
950 static void
952 {
953  struct GNUNET_MQ_MessageHandler handlers[] =
954  { GNUNET_MQ_hd_fixed_size (success_response,
956  struct SuccessResultMessage,
957  h),
958  GNUNET_MQ_hd_var_size (attribute_result,
960  struct AttributeResultMessage,
961  h),
962  GNUNET_MQ_hd_var_size (attestation_result,
964  struct AttributeResultMessage,
965  h),
966  GNUNET_MQ_hd_var_size (reference_result,
968  struct ReferenceResultMessage,
969  h),
970  GNUNET_MQ_hd_fixed_size (ticket_result,
972  struct TicketResultMessage,
973  h),
974  GNUNET_MQ_hd_var_size (consume_ticket_result,
977  h),
978  GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
981  h),
984 
985  GNUNET_assert (NULL == h->mq);
986  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
987 
988  h->mq =
989  GNUNET_CLIENT_connect (h->cfg, "reclaim", handlers, &mq_error_handler, h);
990  if (NULL == h->mq)
991  return;
992  for (op = h->op_head; NULL != op; op = op->next)
993  GNUNET_MQ_send_copy (h->mq, op->env);
994 }
995 
996 
1003 struct GNUNET_RECLAIM_Handle *
1005 {
1006  struct GNUNET_RECLAIM_Handle *h;
1007 
1008  h = GNUNET_new (struct GNUNET_RECLAIM_Handle);
1009  h->cfg = cfg;
1010  reconnect (h);
1011  if (NULL == h->mq)
1012  {
1013  GNUNET_free (h);
1014  return NULL;
1015  }
1016  return h;
1017 }
1018 
1019 
1028 void
1030 {
1031  struct GNUNET_RECLAIM_Handle *h = op->h;
1032 
1034  free_op (op);
1035 }
1036 
1037 
1043 void
1045 {
1046  GNUNET_assert (NULL != h);
1047  if (NULL != h->mq)
1048  {
1049  GNUNET_MQ_destroy (h->mq);
1050  h->mq = NULL;
1051  }
1052  if (NULL != h->reconnect_task)
1053  {
1055  h->reconnect_task = NULL;
1056  }
1057  GNUNET_assert (NULL == h->op_head);
1058  GNUNET_free (h);
1059 }
1060 
1061 
1074 struct GNUNET_RECLAIM_Operation *
1076  struct GNUNET_RECLAIM_Handle *h,
1077  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1078  const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
1079  const struct GNUNET_TIME_Relative *exp_interval,
1081  void *cont_cls)
1082 {
1083  struct GNUNET_RECLAIM_Operation *op;
1084  struct AttributeStoreMessage *sam;
1085  size_t attr_len;
1086 
1087  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1088  op->h = h;
1089  op->as_cb = cont;
1090  op->cls = cont_cls;
1091  op->r_id = h->r_id_gen++;
1094  op->env = GNUNET_MQ_msg_extra (sam,
1095  attr_len,
1097  sam->identity = *pkey;
1098  sam->id = htonl (op->r_id);
1099  sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
1100 
1101  GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &sam[1]);
1102 
1103  sam->attr_len = htons (attr_len);
1104  if (NULL != h->mq)
1105  GNUNET_MQ_send_copy (h->mq, op->env);
1106  return op;
1107 }
1108 
1109 
1121 struct GNUNET_RECLAIM_Operation *
1123  struct GNUNET_RECLAIM_Handle *h,
1124  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1125  const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
1127  void *cont_cls)
1128 {
1129  struct GNUNET_RECLAIM_Operation *op;
1130  struct AttributeDeleteMessage *dam;
1131  size_t attr_len;
1132 
1133  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1134  op->h = h;
1135  op->as_cb = cont;
1136  op->cls = cont_cls;
1137  op->r_id = h->r_id_gen++;
1140  op->env = GNUNET_MQ_msg_extra (dam,
1141  attr_len,
1143  dam->identity = *pkey;
1144  dam->id = htonl (op->r_id);
1145  GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &dam[1]);
1146 
1147  dam->attr_len = htons (attr_len);
1148  if (NULL != h->mq)
1149  GNUNET_MQ_send_copy (h->mq, op->env);
1150  return op;
1151 }
1152 
1165 struct GNUNET_RECLAIM_Operation *
1167  struct GNUNET_RECLAIM_Handle *h,
1168  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1169  const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr,
1170  const struct GNUNET_TIME_Relative *exp_interval,
1172  void *cont_cls)
1173 {
1174  struct GNUNET_RECLAIM_Operation *op;
1175  struct AttributeStoreMessage *sam;
1176  size_t attr_len;
1177 
1178  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1179  op->h = h;
1180  op->as_cb = cont;
1181  op->cls = cont_cls;
1182  op->r_id = h->r_id_gen++;
1185  op->env = GNUNET_MQ_msg_extra (sam,
1186  attr_len,
1188  sam->identity = *pkey;
1189  sam->id = htonl (op->r_id);
1190  sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
1191 
1192  GNUNET_RECLAIM_ATTESTATION_serialize (attr, (char *) &sam[1]);
1193 
1194  sam->attr_len = htons (attr_len);
1195  if (NULL != h->mq)
1196  GNUNET_MQ_send_copy (h->mq, op->env);
1197  return op;
1198 }
1199 
1211 struct GNUNET_RECLAIM_Operation *
1213  struct GNUNET_RECLAIM_Handle *h,
1214  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1215  const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr,
1217  void *cont_cls)
1218 {
1219  struct GNUNET_RECLAIM_Operation *op;
1220  struct AttributeDeleteMessage *dam;
1221  size_t attr_len;
1222 
1223  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1224  op->h = h;
1225  op->as_cb = cont;
1226  op->cls = cont_cls;
1227  op->r_id = h->r_id_gen++;
1230  op->env = GNUNET_MQ_msg_extra (dam,
1231  attr_len,
1233  dam->identity = *pkey;
1234  dam->id = htonl (op->r_id);
1235  GNUNET_RECLAIM_ATTESTATION_serialize (attr, (char *) &dam[1]);
1236 
1237  dam->attr_len = htons (attr_len);
1238  if (NULL != h->mq)
1239  GNUNET_MQ_send_copy (h->mq, op->env);
1240  return op;
1241 }
1242 
1255 struct GNUNET_RECLAIM_Operation *
1257  struct GNUNET_RECLAIM_Handle *h,
1258  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1259  const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr,
1260  const struct GNUNET_TIME_Relative *exp_interval,
1262  void *cont_cls)
1263 {
1264  struct GNUNET_RECLAIM_Operation *op;
1265  struct AttributeStoreMessage *sam;
1266  size_t attr_len;
1267  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1268  op->h = h;
1269  op->as_cb = cont;
1270  op->cls = cont_cls;
1271  op->r_id = h->r_id_gen++;
1274  op->env = GNUNET_MQ_msg_extra (sam,
1275  attr_len,
1277  sam->identity = *pkey;
1278  sam->id = htonl (op->r_id);
1279  sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
1280 
1281  GNUNET_RECLAIM_ATTESTATION_REF_serialize (attr, (char *) &sam[1]);
1282 
1283  sam->attr_len = htons (attr_len);
1284  if (NULL != h->mq)
1285  GNUNET_MQ_send_copy (h->mq, op->env);
1286  return op;
1287 }
1288 
1300 struct GNUNET_RECLAIM_Operation *
1302  struct GNUNET_RECLAIM_Handle *h,
1303  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1304  const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr,
1306  void *cont_cls)
1307 {
1308 
1309  struct GNUNET_RECLAIM_Operation *op;
1310  struct AttributeDeleteMessage *dam;
1311  size_t attr_len;
1312 
1313  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1314  op->h = h;
1315  op->as_cb = cont;
1316  op->cls = cont_cls;
1317  op->r_id = h->r_id_gen++;
1320  op->env = GNUNET_MQ_msg_extra (dam,
1321  attr_len,
1323  dam->identity = *pkey;
1324  dam->id = htonl (op->r_id);
1325  GNUNET_RECLAIM_ATTESTATION_REF_serialize (attr, (char *) &dam[1]);
1326 
1327  dam->attr_len = htons (attr_len);
1328  if (NULL != h->mq)
1329  GNUNET_MQ_send_copy (h->mq, op->env);
1330  return op;
1331 }
1332 
1359  struct GNUNET_RECLAIM_Handle *h,
1362  void *error_cb_cls,
1364  void *proc_cls,
1366  void *finish_cb_cls)
1367 {
1369  struct GNUNET_MQ_Envelope *env;
1371  uint32_t rid;
1372 
1373  rid = h->r_id_gen++;
1375  it->h = h;
1376  it->error_cb = error_cb;
1377  it->error_cb_cls = error_cb_cls;
1378  it->finish_cb = finish_cb;
1379  it->finish_cb_cls = finish_cb_cls;
1380  it->proc = proc;
1381  it->proc_cls = proc_cls;
1382  it->r_id = rid;
1383  it->identity = *identity;
1385  env =
1387  msg->id = htonl (rid);
1388  msg->identity = *identity;
1389  if (NULL == h->mq)
1390  it->env = env;
1391  else
1392  GNUNET_MQ_send (h->mq, env);
1393  return it;
1394 }
1395 
1396 
1403 void
1405 {
1406  struct GNUNET_RECLAIM_Handle *h = it->h;
1408  struct GNUNET_MQ_Envelope *env;
1409 
1410  env =
1412  msg->id = htonl (it->r_id);
1413  GNUNET_MQ_send (h->mq, env);
1414 }
1415 
1416 
1424 void
1426 {
1427  struct GNUNET_RECLAIM_Handle *h = it->h;
1428  struct GNUNET_MQ_Envelope *env;
1430 
1431  if (NULL != h->mq)
1432  {
1433  env =
1435  msg->id = htonl (it->r_id);
1436  GNUNET_MQ_send (h->mq, env);
1437  }
1438  free_it (it);
1439 }
1440 
1441 
1455 struct GNUNET_RECLAIM_Operation *
1457  struct GNUNET_RECLAIM_Handle *h,
1458  const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
1459  const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
1460  const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
1462  void *cb_cls)
1463 {
1464  struct GNUNET_RECLAIM_Operation *op;
1465  struct IssueTicketMessage *tim;
1466  size_t attr_len;
1467 
1468  fprintf (stderr, "Issuing ticket\n");
1469  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1470  op->h = h;
1471  op->tr_cb = cb;
1472  op->cls = cb_cls;
1473  op->r_id = h->r_id_gen++;
1476  op->env = GNUNET_MQ_msg_extra (tim,
1477  attr_len,
1479  tim->identity = *iss;
1480  tim->rp = *rp;
1481  tim->id = htonl (op->r_id);
1482 
1483  GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, (char *) &tim[1]);
1484 
1485  tim->attr_len = htons (attr_len);
1486  if (NULL != h->mq)
1487  GNUNET_MQ_send_copy (h->mq, op->env);
1488  return op;
1489 }
1490 
1491 
1504 struct GNUNET_RECLAIM_Operation *
1506  struct GNUNET_RECLAIM_Handle *h,
1508  const struct GNUNET_RECLAIM_Ticket *ticket,
1510  void *cb_cls)
1511 {
1512  struct GNUNET_RECLAIM_Operation *op;
1513  struct ConsumeTicketMessage *ctm;
1514 
1515  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1516  op->h = h;
1517  op->ar_cb = cb;
1518  op->cls = cb_cls;
1519  op->r_id = h->r_id_gen++;
1522  ctm->identity = *identity;
1523  ctm->id = htonl (op->r_id);
1524  ctm->ticket = *ticket;
1525  if (NULL != h->mq)
1526  GNUNET_MQ_send_copy (h->mq, op->env);
1527  return op;
1528 }
1529 
1530 
1550  struct GNUNET_RECLAIM_Handle *h,
1553  void *error_cb_cls,
1555  void *proc_cls,
1557  void *finish_cb_cls)
1558 {
1559  struct GNUNET_RECLAIM_TicketIterator *it;
1560  struct GNUNET_MQ_Envelope *env;
1562  uint32_t rid;
1563 
1564  rid = h->r_id_gen++;
1566  it->h = h;
1567  it->error_cb = error_cb;
1568  it->error_cb_cls = error_cb_cls;
1569  it->finish_cb = finish_cb;
1570  it->finish_cb_cls = finish_cb_cls;
1571  it->tr_cb = proc;
1572  it->cls = proc_cls;
1573  it->r_id = rid;
1576  msg->id = htonl (rid);
1577  msg->identity = *identity;
1578  if (NULL == h->mq)
1579  it->env = env;
1580  else
1581  GNUNET_MQ_send (h->mq, env);
1582  return it;
1583 }
1584 
1585 
1592 void
1594 {
1595  struct GNUNET_RECLAIM_Handle *h = it->h;
1597  struct GNUNET_MQ_Envelope *env;
1598 
1600  msg->id = htonl (it->r_id);
1601  GNUNET_MQ_send (h->mq, env);
1602 }
1603 
1604 
1612 void
1614 {
1615  struct GNUNET_RECLAIM_Handle *h = it->h;
1616  struct GNUNET_MQ_Envelope *env;
1618 
1619  if (NULL != h->mq)
1620  {
1621  env =
1623  msg->id = htonl (it->r_id);
1624  GNUNET_MQ_send (h->mq, env);
1625  }
1626  GNUNET_free (it);
1627 }
1628 
1629 
1643 struct GNUNET_RECLAIM_Operation *
1645  struct GNUNET_RECLAIM_Handle *h,
1647  const struct GNUNET_RECLAIM_Ticket *ticket,
1649  void *cb_cls)
1650 {
1651  struct GNUNET_RECLAIM_Operation *op;
1652  struct RevokeTicketMessage *msg;
1653  uint32_t rid;
1654 
1655  rid = h->r_id_gen++;
1656  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1657  op->h = h;
1658  op->rvk_cb = cb;
1659  op->cls = cb_cls;
1660  op->r_id = rid;
1663  msg->id = htonl (rid);
1664  msg->identity = *identity;
1665  msg->ticket = *ticket;
1666  if (NULL != h->mq)
1667  {
1668  GNUNET_MQ_send (h->mq, op->env);
1669  op->env = NULL;
1670  }
1671  return op;
1672 }
1673 
1674 
1675 /* 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:550
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:406
Ticket result message.
Definition: reclaim.h:396
Handle to the service.
Definition: reclaim_api.c:235
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:358
The authorization ticket.
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE
struct GNUNET_CRYPTO_EcdsaPublicKey rp
Requesting party.
Definition: reclaim.h:330
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:1358
struct GNUNET_RECLAIM_Ticket ticket
The new ticket.
Definition: reclaim.h:411
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:443
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
size_t GNUNET_RECLAIM_ATTESTATION_serialize_get_size(const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr)
Get required size for serialization buffer FIXME:
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:269
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:1075
Ticket consume message.
Definition: reclaim.h:417
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:1549
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
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attestation_reference_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an attestation reference.
Definition: reclaim_api.c:1301
Reference plus Attestation is returned from the idp.
Definition: reclaim.h:159
Start a attribute iteration for the given identity.
Definition: reclaim.h:199
GNUNET_MQ_Error
Error codes for the queue.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference.
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:238
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:353
#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
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * GNUNET_RECLAIM_ATTESTATION_REF_deserialize(const char *data, size_t data_size)
Deserialize a reference.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:453
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
void(* GNUNET_RECLAIM_AttributeResult)(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
Callback used to notify the client of attribute results.
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:1044
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:1029
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:1593
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_STORE
#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:1613
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
#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:1404
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:89
static struct GNUNET_TIME_Relative exp_interval
Attribute expiration interval.
uint64_t id_attest
Referenced ID of Attestation.
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:325
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
size_t GNUNET_RECLAIM_ATTESTATION_REF_serialize(const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr, char *result)
Serialize a reference.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attestation_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an attestation.
Definition: reclaim_api.c:1212
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.
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation claim.
Ask for next result of ticket iteration for the given operation.
Definition: reclaim.h:276
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:180
static void reconnect(struct GNUNET_RECLAIM_Handle *h)
Try again to connect to the service.
Definition: reclaim_api.c:951
Common type definitions for the identity provider service and API.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:286
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:1644
#define GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE
Next available: 1500.
Handle for a attribute iterator operation.
Definition: reclaim_api.c:167
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:248
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:1122
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:432
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:293
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:231
struct GNUNET_RECLAIM_Ticket ticket
The ticket to revoke.
Definition: reclaim.h:368
uint16_t ref_len
Length of serialized reference data.
Definition: reclaim.h:179
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:1456
struct GNUNET_RECLAIM_ATTESTATION_Claim * GNUNET_RECLAIM_ATTESTATION_deserialize(const char *data, size_t data_size)
Deserialize an attestation.
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:214
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:574
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:209
Ticket issue message.
Definition: reclaim.h:310
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE
void * cls
Closure for tr_cb.
Definition: reclaim_api.c:139
#define GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_STORE
Message handler for a specific message type.
static int res
Attribute store/delete response message.
Definition: reclaim.h:103
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:189
size_t GNUNET_RECLAIM_ATTESTATION_serialize(const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, char *result)
Serialize an attestation.
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:36
#define GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:320
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:335
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static void handle_attestation_result(void *cls, const struct AttributeResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT.
Definition: reclaim_api.c:673
struct GNUNET_RECLAIM_Ticket ticket
The ticket to consume.
Definition: reclaim.h:437
Ask for next result of attribute iteration for the given operation.
Definition: reclaim.h:221
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:852
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...
static int check_reference_result(void *cls, const struct ReferenceResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT.
Definition: reclaim_api.c:748
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:915
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:374
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:84
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:1425
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT
uint16_t attest_len
Length of serialized attestation data.
Definition: reclaim.h:174
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:264
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:384
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:254
Handle for a ticket iterator operation.
Definition: reclaim_api.c:104
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:463
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:448
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:149
static char * rp
Relying party.
static void handle_reference_result(void *cls, const struct ReferenceResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT.
Definition: reclaim_api.c:773
#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:1505
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
size_t GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size(const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr)
Get required size for serialization buffer.
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:303
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_MessageHeader header
Message header.
Definition: reclaim.h:164
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the reclaim service.
Definition: reclaim_api.c:1004
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:389
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:169
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:427
#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
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attestation_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store an attestation.
Definition: reclaim_api.c:1166
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.
static int check_attestation_result(void *cls, const struct AttributeResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT.
Definition: reclaim_api.c:649
Ticket revoke message.
Definition: reclaim.h:343
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attestation_reference_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store an attestation reference.
Definition: reclaim_api.c:1256
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