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"
31 #include "gnunet_reclaim_lib.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 
93 
98 
102  uint32_t r_id;
103 
107  void *cls;
108 };
109 
110 
115 {
120 
125 
130 
135 
140 
145 
149  void *cls;
150 
155 
160 
166 
170  uint32_t r_id;
171 };
172 
173 
178 {
183 
188 
193 
198 
203 
208 
212  void *proc_cls;
213 
218 
223 
229 
234 
238  uint32_t r_id;
239 };
240 
245 {
250 
255 
260 
265 
270 
275 
279  void *proc_cls;
280 
285 
290 
296 
301 
305  uint32_t r_id;
306 };
307 
308 
313 {
318 
322  struct GNUNET_CLIENT_Connection *client;
323 
327  void *cb_cls;
328 
333 
338 
343 
348 
353 
358 
363 
368 
372  struct GNUNET_CLIENT_TransmitHandle *th;
373 
378 
382  struct GNUNET_TIME_Relative reconnect_backoff;
383 
388 
392  uint32_t r_id_gen;
393 
398 };
399 
400 
406 static void
408 
409 
415 static void
417 {
418  struct GNUNET_RECLAIM_Handle *handle = cls;
419 
420  handle->reconnect_task = NULL;
421  reconnect (handle);
422 }
423 
424 
430 static void
432 {
433  GNUNET_MQ_destroy (handle->mq);
434  handle->mq = NULL;
435  handle->reconnect_backoff =
437  handle->reconnect_task =
440  handle);
441 }
442 
443 
449 static void
451 {
452  struct GNUNET_RECLAIM_Handle *h = it->h;
453 
455  if (NULL != it->env)
456  GNUNET_MQ_discard (it->env);
457  GNUNET_free (it);
458 }
459 
460 
466 static void
468 {
469  struct GNUNET_RECLAIM_Handle *h = ait->h;
470 
472  if (NULL != ait->env)
473  GNUNET_MQ_discard (ait->env);
474  GNUNET_free (ait);
475 }
476 
477 
483 static void
485 {
486  if (NULL == op)
487  return;
488  if (NULL != op->env)
489  GNUNET_MQ_discard (op->env);
490  GNUNET_free (op);
491 }
492 
493 
502 static void
504 {
505  struct GNUNET_RECLAIM_Handle *handle = cls;
506 
507  force_reconnect (handle);
508 }
509 
510 
518 static void
520 {
521  struct GNUNET_RECLAIM_Handle *h = cls;
523  uint32_t r_id = ntohl (msg->id);
524  int res;
525  const char *emsg;
526 
527  for (op = h->op_head; NULL != op; op = op->next)
528  if (op->r_id == r_id)
529  break;
530  if (NULL == op)
531  return;
532 
533  res = ntohl (msg->op_result);
535  "Received SUCCESS_RESPONSE with result %d\n",
536  res);
537 
538  /* TODO: add actual error message to response... */
539  if (GNUNET_SYSERR == res)
540  emsg = _ ("failed to store record\n");
541  else
542  emsg = NULL;
543  if (NULL != op->as_cb)
544  op->as_cb (op->cls, res, emsg);
546  free_op (op);
547 }
548 
549 
558 static int
560  const struct ConsumeTicketResultMessage *msg)
561 {
562  size_t msg_len;
563  size_t attrs_len;
564  size_t attests_len;
565 
566  msg_len = ntohs (msg->header.size);
567  attrs_len = ntohs (msg->attrs_len);
568  attests_len = ntohs (msg->attestations_len);
569  if (msg_len !=
570  sizeof(struct ConsumeTicketResultMessage) + attrs_len + attests_len)
571  {
572  GNUNET_break (0);
573  return GNUNET_SYSERR;
574  }
575  return GNUNET_OK;
576 }
577 
578 
586 static void
588  const struct ConsumeTicketResultMessage *msg)
589 {
590  struct GNUNET_RECLAIM_Handle *h = cls;
592  size_t attrs_len;
593  size_t attests_len;
594  uint32_t r_id = ntohl (msg->id);
595  char *read_ptr;
596 
597  attrs_len = ntohs (msg->attrs_len);
598  attests_len = ntohs (msg->attestations_len);
599  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n");
600 
601 
602  for (op = h->op_head; NULL != op; op = op->next)
603  if (op->r_id == r_id)
604  break;
605  if (NULL == op)
606  return;
607 
608  {
609  struct GNUNET_RECLAIM_AttributeList *attrs;
611  struct GNUNET_RECLAIM_AttestationList *attests;
613  attrs =
614  GNUNET_RECLAIM_attribute_list_deserialize ((char *) &msg[1], attrs_len);
615  read_ptr = ((char *) &msg[1]) + attrs_len;
616  attests =
617  GNUNET_RECLAIM_attestation_list_deserialize (read_ptr, attests_len);
618  if (NULL != op->atr_cb)
619  {
620  if (NULL == attrs)
621  {
622  op->atr_cb (op->cls, &msg->identity, NULL, NULL);
623  }
624  else
625  {
626  for (le = attrs->list_head; NULL != le; le = le->next)
627  {
628  if (GNUNET_NO ==
630  {
631  for (ale = attests->list_head; NULL != ale; ale = ale->next)
632  {
633  if (GNUNET_YES ==
635  &ale->attestation->id))
636  {
637  op->atr_cb (op->cls, &msg->identity,
638  le->attribute, ale->attestation);
639  break;
640  }
641 
642  }
643  }
644  else // No attestations
645  {
646  op->atr_cb (op->cls, &msg->identity,
647  le->attribute, NULL);
648  }
649  }
650  if (NULL != attrs)
652  if (NULL != attests)
654  attrs = NULL;
655  attests = NULL;
656  }
657  op->atr_cb (op->cls, NULL, NULL, NULL);
658  }
660  free_op (op);
661  GNUNET_free_non_null (attrs);
662  return;
663  }
664  GNUNET_assert (0);
665 }
666 
667 
676 static int
678 {
679  size_t msg_len;
680  size_t attr_len;
681 
682  msg_len = ntohs (msg->header.size);
683  attr_len = ntohs (msg->attr_len);
684  if (msg_len != sizeof(struct AttributeResultMessage) + attr_len)
685  {
686  GNUNET_break (0);
687  return GNUNET_SYSERR;
688  }
689  return GNUNET_OK;
690 }
691 
692 
700 static void
702 {
703  static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
704  struct GNUNET_RECLAIM_Handle *h = cls;
707  size_t attr_len;
708  uint32_t r_id = ntohl (msg->id);
709 
710  attr_len = ntohs (msg->attr_len);
711  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
712 
713 
714  for (it = h->it_head; NULL != it; it = it->next)
715  if (it->r_id == r_id)
716  break;
717  for (op = h->op_head; NULL != op; op = op->next)
718  if (op->r_id == r_id)
719  break;
720  if ((NULL == it) && (NULL == op))
721  return;
722 
723  if ((0 ==
724  (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
725  {
726  if ((NULL == it) && (NULL == op))
727  {
728  GNUNET_break (0);
729  force_reconnect (h);
730  return;
731  }
732  if (NULL != it)
733  {
734  if (NULL != it->finish_cb)
735  it->finish_cb (it->finish_cb_cls);
736  free_it (it);
737  }
738  if (NULL != op)
739  {
740  if (NULL != op->ar_cb)
741  op->ar_cb (op->cls, NULL, NULL);
743  free_op (op);
744  }
745  return;
746  }
747 
748  {
749  struct GNUNET_RECLAIM_Attribute *attr;
750  attr = GNUNET_RECLAIM_attribute_deserialize ((char *) &msg[1], attr_len);
751  if (NULL != it)
752  {
753  if (NULL != it->proc)
754  it->proc (it->proc_cls, &msg->identity, attr);
755  }
756  else if (NULL != op)
757  {
758  if (NULL != op->ar_cb)
759  op->ar_cb (op->cls, &msg->identity, attr);
760  }
761  GNUNET_free (attr);
762  return;
763  }
764  GNUNET_assert (0);
765 }
766 
767 
776 static int
778 {
779  size_t msg_len;
780  size_t attest_len;
781 
782  msg_len = ntohs (msg->header.size);
783  attest_len = ntohs (msg->attestation_len);
784  if (msg_len != sizeof(struct AttestationResultMessage) + attest_len)
785  {
786  GNUNET_break (0);
787  return GNUNET_SYSERR;
788  }
789  return GNUNET_OK;
790 }
791 
792 
800 static void
801 handle_attestation_result (void *cls, const struct
803 {
804  static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
805  struct GNUNET_RECLAIM_Handle *h = cls;
808  size_t att_len;
809  uint32_t r_id = ntohl (msg->id);
810 
811  att_len = ntohs (msg->attestation_len);
812  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attestation result.\n");
813 
814 
815  for (it = h->ait_head; NULL != it; it = it->next)
816  if (it->r_id == r_id)
817  break;
818  for (op = h->op_head; NULL != op; op = op->next)
819  if (op->r_id == r_id)
820  break;
821  if ((NULL == it) && (NULL == op))
822  return;
823 
824  if ((0 ==
825  (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
826  {
827  if ((NULL == it) && (NULL == op))
828  {
829  GNUNET_break (0);
830  force_reconnect (h);
831  return;
832  }
833  if (NULL != it)
834  {
835  if (NULL != it->finish_cb)
836  it->finish_cb (it->finish_cb_cls);
837  free_ait (it);
838  }
839  if (NULL != op)
840  {
841  if (NULL != op->at_cb)
842  op->at_cb (op->cls, NULL, NULL);
844  free_op (op);
845  }
846  return;
847  }
848 
849  {
850  struct GNUNET_RECLAIM_Attestation *att;
851  att = GNUNET_RECLAIM_attestation_deserialize ((char *) &msg[1], att_len);
852 
853  if (NULL != it)
854  {
855  if (NULL != it->proc)
856  it->proc (it->proc_cls, &msg->identity, att);
857  }
858  else if (NULL != op)
859  {
860  if (NULL != op->at_cb)
861  op->at_cb (op->cls, &msg->identity, att);
862  }
863  GNUNET_free (att);
864  return;
865  }
866  GNUNET_assert (0);
867 }
868 
869 
877 static void
879 {
880  struct GNUNET_RECLAIM_Handle *handle = cls;
883  uint32_t r_id = ntohl (msg->id);
884  static const struct GNUNET_RECLAIM_Ticket ticket;
885 
886  for (op = handle->op_head; NULL != op; op = op->next)
887  if (op->r_id == r_id)
888  break;
889  for (it = handle->ticket_it_head; NULL != it; it = it->next)
890  if (it->r_id == r_id)
891  break;
892  if ((NULL == op) && (NULL == it))
893  return;
894  if (NULL != op)
895  {
896  GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
897  if (0 ==
898  memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
899  {
900  if (NULL != op->tr_cb)
901  op->tr_cb (op->cls, NULL);
902  }
903  else
904  {
905  if (NULL != op->tr_cb)
906  op->tr_cb (op->cls, &msg->ticket);
907  }
908  free_op (op);
909  return;
910  }
911  else if (NULL != it)
912  {
913  if (0 ==
914  memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
915  {
917  handle->ticket_it_tail,
918  it);
919  it->finish_cb (it->finish_cb_cls);
920  GNUNET_free (it);
921  }
922  else
923  {
924  if (NULL != it->tr_cb)
925  it->tr_cb (it->cls, &msg->ticket);
926  }
927  return;
928  }
929  GNUNET_break (0);
930 }
931 
932 
940 static void
942  const struct RevokeTicketResultMessage *msg)
943 {
944  struct GNUNET_RECLAIM_Handle *h = cls;
946  uint32_t r_id = ntohl (msg->id);
947  int32_t success;
948 
949  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n");
950 
951 
952  for (op = h->op_head; NULL != op; op = op->next)
953  if (op->r_id == r_id)
954  break;
955  if (NULL == op)
956  return;
957  success = ntohl (msg->success);
958  {
959  if (NULL != op->rvk_cb)
960  {
961  op->rvk_cb (op->cls, success, NULL);
962  }
964  free_op (op);
965  return;
966  }
967  GNUNET_assert (0);
968 }
969 
970 
976 static void
978 {
979  struct GNUNET_MQ_MessageHandler handlers[] =
980  { GNUNET_MQ_hd_fixed_size (success_response,
982  struct SuccessResultMessage,
983  h),
984  GNUNET_MQ_hd_var_size (attribute_result,
986  struct AttributeResultMessage,
987  h),
988  GNUNET_MQ_hd_var_size (attestation_result,
991  h),
992  GNUNET_MQ_hd_fixed_size (ticket_result,
994  struct TicketResultMessage,
995  h),
996  GNUNET_MQ_hd_var_size (consume_ticket_result,
999  h),
1000  GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
1003  h),
1004  GNUNET_MQ_handler_end () };
1005  struct GNUNET_RECLAIM_Operation *op;
1006 
1007  GNUNET_assert (NULL == h->mq);
1008  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
1009 
1010  h->mq =
1011  GNUNET_CLIENT_connect (h->cfg, "reclaim", handlers, &mq_error_handler, h);
1012  if (NULL == h->mq)
1013  return;
1014  for (op = h->op_head; NULL != op; op = op->next)
1015  GNUNET_MQ_send_copy (h->mq, op->env);
1016 }
1017 
1018 
1025 struct GNUNET_RECLAIM_Handle *
1027 {
1028  struct GNUNET_RECLAIM_Handle *h;
1029 
1030  h = GNUNET_new (struct GNUNET_RECLAIM_Handle);
1031  h->cfg = cfg;
1032  reconnect (h);
1033  if (NULL == h->mq)
1034  {
1035  GNUNET_free (h);
1036  return NULL;
1037  }
1038  return h;
1039 }
1040 
1041 
1050 void
1052 {
1053  struct GNUNET_RECLAIM_Handle *h = op->h;
1054 
1056  free_op (op);
1057 }
1058 
1059 
1065 void
1067 {
1068  GNUNET_assert (NULL != h);
1069  if (NULL != h->mq)
1070  {
1071  GNUNET_MQ_destroy (h->mq);
1072  h->mq = NULL;
1073  }
1074  if (NULL != h->reconnect_task)
1075  {
1077  h->reconnect_task = NULL;
1078  }
1079  GNUNET_assert (NULL == h->op_head);
1080  GNUNET_free (h);
1081 }
1082 
1083 
1096 struct GNUNET_RECLAIM_Operation *
1098  struct GNUNET_RECLAIM_Handle *h,
1099  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1100  const struct GNUNET_RECLAIM_Attribute *attr,
1101  const struct GNUNET_TIME_Relative *exp_interval,
1103  void *cont_cls)
1104 {
1105  struct GNUNET_RECLAIM_Operation *op;
1106  struct AttributeStoreMessage *sam;
1107  size_t attr_len;
1108 
1109  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1110  op->h = h;
1111  op->as_cb = cont;
1112  op->cls = cont_cls;
1113  op->r_id = h->r_id_gen++;
1116  op->env = GNUNET_MQ_msg_extra (sam,
1117  attr_len,
1119  sam->identity = *pkey;
1120  sam->id = htonl (op->r_id);
1121  sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
1122 
1123  GNUNET_RECLAIM_attribute_serialize (attr, (char *) &sam[1]);
1124 
1125  sam->attr_len = htons (attr_len);
1126  if (NULL != h->mq)
1127  GNUNET_MQ_send_copy (h->mq, op->env);
1128  return op;
1129 }
1130 
1131 
1143 struct GNUNET_RECLAIM_Operation *
1145  struct GNUNET_RECLAIM_Handle *h,
1146  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1147  const struct GNUNET_RECLAIM_Attribute *attr,
1149  void *cont_cls)
1150 {
1151  struct GNUNET_RECLAIM_Operation *op;
1152  struct AttributeDeleteMessage *dam;
1153  size_t attr_len;
1154 
1155  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1156  op->h = h;
1157  op->as_cb = cont;
1158  op->cls = cont_cls;
1159  op->r_id = h->r_id_gen++;
1162  op->env = GNUNET_MQ_msg_extra (dam,
1163  attr_len,
1165  dam->identity = *pkey;
1166  dam->id = htonl (op->r_id);
1167  GNUNET_RECLAIM_attribute_serialize (attr, (char *) &dam[1]);
1168 
1169  dam->attr_len = htons (attr_len);
1170  if (NULL != h->mq)
1171  GNUNET_MQ_send_copy (h->mq, op->env);
1172  return op;
1173 }
1174 
1175 
1188 struct GNUNET_RECLAIM_Operation *
1190  struct GNUNET_RECLAIM_Handle *h,
1191  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1192  const struct GNUNET_RECLAIM_Attestation *attr,
1193  const struct GNUNET_TIME_Relative *exp_interval,
1195  void *cont_cls)
1196 {
1197  struct GNUNET_RECLAIM_Operation *op;
1198  struct AttributeStoreMessage *sam;
1199  size_t attr_len;
1200 
1201  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1202  op->h = h;
1203  op->as_cb = cont;
1204  op->cls = cont_cls;
1205  op->r_id = h->r_id_gen++;
1208  op->env = GNUNET_MQ_msg_extra (sam,
1209  attr_len,
1211  sam->identity = *pkey;
1212  sam->id = htonl (op->r_id);
1213  sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
1214 
1215  GNUNET_RECLAIM_attestation_serialize (attr, (char *) &sam[1]);
1216 
1217  sam->attr_len = htons (attr_len);
1218  if (NULL != h->mq)
1219  GNUNET_MQ_send_copy (h->mq, op->env);
1220  return op;
1221 }
1222 
1223 
1235 struct GNUNET_RECLAIM_Operation *
1237  struct GNUNET_RECLAIM_Handle *h,
1238  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1239  const struct GNUNET_RECLAIM_Attestation *attr,
1241  void *cont_cls)
1242 {
1243  struct GNUNET_RECLAIM_Operation *op;
1244  struct AttributeDeleteMessage *dam;
1245  size_t attr_len;
1246 
1247  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1248  op->h = h;
1249  op->as_cb = cont;
1250  op->cls = cont_cls;
1251  op->r_id = h->r_id_gen++;
1254  op->env = GNUNET_MQ_msg_extra (dam,
1255  attr_len,
1257  dam->identity = *pkey;
1258  dam->id = htonl (op->r_id);
1259  GNUNET_RECLAIM_attestation_serialize (attr, (char *) &dam[1]);
1260 
1261  dam->attr_len = htons (attr_len);
1262  if (NULL != h->mq)
1263  GNUNET_MQ_send_copy (h->mq, op->env);
1264  return op;
1265 }
1266 
1267 
1294  struct GNUNET_RECLAIM_Handle *h,
1297  void *error_cb_cls,
1299  void *proc_cls,
1301  void *finish_cb_cls)
1302 {
1304  struct GNUNET_MQ_Envelope *env;
1306  uint32_t rid;
1307 
1308  rid = h->r_id_gen++;
1310  it->h = h;
1311  it->error_cb = error_cb;
1312  it->error_cb_cls = error_cb_cls;
1313  it->finish_cb = finish_cb;
1314  it->finish_cb_cls = finish_cb_cls;
1315  it->proc = proc;
1316  it->proc_cls = proc_cls;
1317  it->r_id = rid;
1318  it->identity = *identity;
1320  env =
1322  msg->id = htonl (rid);
1323  msg->identity = *identity;
1324  if (NULL == h->mq)
1325  it->env = env;
1326  else
1327  GNUNET_MQ_send (h->mq, env);
1328  return it;
1329 }
1330 
1331 
1338 void
1340 {
1341  struct GNUNET_RECLAIM_Handle *h = it->h;
1343  struct GNUNET_MQ_Envelope *env;
1344 
1345  env =
1347  msg->id = htonl (it->r_id);
1348  GNUNET_MQ_send (h->mq, env);
1349 }
1350 
1351 
1359 void
1361 {
1362  struct GNUNET_RECLAIM_Handle *h = it->h;
1363  struct GNUNET_MQ_Envelope *env;
1365 
1366  if (NULL != h->mq)
1367  {
1368  env =
1370  msg->id = htonl (it->r_id);
1371  GNUNET_MQ_send (h->mq, env);
1372  }
1373  free_it (it);
1374 }
1375 
1376 
1403  struct GNUNET_RECLAIM_Handle *h,
1406  void *error_cb_cls,
1408  void *proc_cls,
1410  void *finish_cb_cls)
1411 {
1413  struct GNUNET_MQ_Envelope *env;
1415  uint32_t rid;
1416 
1417  rid = h->r_id_gen++;
1419  ait->h = h;
1420  ait->error_cb = error_cb;
1421  ait->error_cb_cls = error_cb_cls;
1422  ait->finish_cb = finish_cb;
1423  ait->finish_cb_cls = finish_cb_cls;
1424  ait->proc = proc;
1425  ait->proc_cls = proc_cls;
1426  ait->r_id = rid;
1427  ait->identity = *identity;
1429  env =
1430  GNUNET_MQ_msg (msg,
1432  msg->id = htonl (rid);
1433  msg->identity = *identity;
1434  if (NULL == h->mq)
1435  ait->env = env;
1436  else
1437  GNUNET_MQ_send (h->mq, env);
1438  return ait;
1439 }
1440 
1441 
1448 void
1451 {
1452  struct GNUNET_RECLAIM_Handle *h = ait->h;
1454  struct GNUNET_MQ_Envelope *env;
1455 
1456  env =
1458  msg->id = htonl (ait->r_id);
1459  GNUNET_MQ_send (h->mq, env);
1460 }
1461 
1462 
1470 void
1473 {
1474  struct GNUNET_RECLAIM_Handle *h = ait->h;
1475  struct GNUNET_MQ_Envelope *env;
1477 
1478  if (NULL != h->mq)
1479  {
1480  env =
1481  GNUNET_MQ_msg (msg,
1483  msg->id = htonl (ait->r_id);
1484  GNUNET_MQ_send (h->mq, env);
1485  }
1486  free_ait (ait);
1487 }
1488 
1489 
1503 struct GNUNET_RECLAIM_Operation *
1505  struct GNUNET_RECLAIM_Handle *h,
1506  const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
1507  const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
1508  const struct GNUNET_RECLAIM_AttributeList *attrs,
1510  void *cb_cls)
1511 {
1512  struct GNUNET_RECLAIM_Operation *op;
1513  struct IssueTicketMessage *tim;
1514  size_t attr_len;
1515 
1516  fprintf (stderr, "Issuing ticket\n");
1517  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1518  op->h = h;
1519  op->tr_cb = cb;
1520  op->cls = cb_cls;
1521  op->r_id = h->r_id_gen++;
1524  op->env = GNUNET_MQ_msg_extra (tim,
1525  attr_len,
1527  tim->identity = *iss;
1528  tim->rp = *rp;
1529  tim->id = htonl (op->r_id);
1530 
1531  GNUNET_RECLAIM_attribute_list_serialize (attrs, (char *) &tim[1]);
1532 
1533  tim->attr_len = htons (attr_len);
1534  if (NULL != h->mq)
1535  GNUNET_MQ_send_copy (h->mq, op->env);
1536  return op;
1537 }
1538 
1539 
1552 struct GNUNET_RECLAIM_Operation *
1554  struct GNUNET_RECLAIM_Handle *h,
1556  const struct GNUNET_RECLAIM_Ticket *ticket,
1558  void *cb_cls)
1559 {
1560  struct GNUNET_RECLAIM_Operation *op;
1561  struct ConsumeTicketMessage *ctm;
1562 
1563  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1564  op->h = h;
1565  op->atr_cb = cb;
1566  op->cls = cb_cls;
1567  op->r_id = h->r_id_gen++;
1570  ctm->identity = *identity;
1571  ctm->id = htonl (op->r_id);
1572  ctm->ticket = *ticket;
1573  if (NULL != h->mq)
1574  GNUNET_MQ_send_copy (h->mq, op->env);
1575  return op;
1576 }
1577 
1578 
1598  struct GNUNET_RECLAIM_Handle *h,
1601  void *error_cb_cls,
1603  void *proc_cls,
1605  void *finish_cb_cls)
1606 {
1607  struct GNUNET_RECLAIM_TicketIterator *it;
1608  struct GNUNET_MQ_Envelope *env;
1610  uint32_t rid;
1611 
1612  rid = h->r_id_gen++;
1614  it->h = h;
1615  it->error_cb = error_cb;
1616  it->error_cb_cls = error_cb_cls;
1617  it->finish_cb = finish_cb;
1618  it->finish_cb_cls = finish_cb_cls;
1619  it->tr_cb = proc;
1620  it->cls = proc_cls;
1621  it->r_id = rid;
1624  msg->id = htonl (rid);
1625  msg->identity = *identity;
1626  if (NULL == h->mq)
1627  it->env = env;
1628  else
1629  GNUNET_MQ_send (h->mq, env);
1630  return it;
1631 }
1632 
1633 
1640 void
1642 {
1643  struct GNUNET_RECLAIM_Handle *h = it->h;
1645  struct GNUNET_MQ_Envelope *env;
1646 
1648  msg->id = htonl (it->r_id);
1649  GNUNET_MQ_send (h->mq, env);
1650 }
1651 
1652 
1660 void
1662 {
1663  struct GNUNET_RECLAIM_Handle *h = it->h;
1664  struct GNUNET_MQ_Envelope *env;
1666 
1667  if (NULL != h->mq)
1668  {
1669  env =
1671  msg->id = htonl (it->r_id);
1672  GNUNET_MQ_send (h->mq, env);
1673  }
1674  GNUNET_free (it);
1675 }
1676 
1677 
1691 struct GNUNET_RECLAIM_Operation *
1693  struct GNUNET_RECLAIM_Handle *h,
1695  const struct GNUNET_RECLAIM_Ticket *ticket,
1697  void *cb_cls)
1698 {
1699  struct GNUNET_RECLAIM_Operation *op;
1700  struct RevokeTicketMessage *msg;
1701  uint32_t rid;
1702 
1703  rid = h->r_id_gen++;
1704  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1705  op->h = h;
1706  op->rvk_cb = cb;
1707  op->cls = cb_cls;
1708  op->r_id = rid;
1711  msg->id = htonl (rid);
1712  msg->identity = *identity;
1713  msg->ticket = *ticket;
1714  if (NULL != h->mq)
1715  {
1716  GNUNET_MQ_send (h->mq, op->env);
1717  op->env = NULL;
1718  }
1719  return op;
1720 }
1721 
1722 
1723 /* 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:367
#define GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET
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:677
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:463
Ticket result message.
Definition: reclaim.h:453
Handle to the service.
Definition: reclaim_api.c:312
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:415
The authorization ticket.
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE
struct GNUNET_CRYPTO_EcdsaPublicKey rp
Requesting party.
Definition: reclaim.h:387
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:1293
struct GNUNET_RECLAIM_Ticket ticket
The new ticket.
Definition: reclaim.h:468
struct GNUNET_RECLAIM_Operation * prev
We keep operations in a DLL.
Definition: reclaim_api.c:56
struct GNUNET_RECLAIM_AttestationIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:254
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_NEXT
Attribute list is returned from the idp.
Definition: reclaim.h:500
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.
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_AttributeTicketResult cb, void *cb_cls)
Consumes an issued ticket.
Definition: reclaim_api.c:1553
void * cb_cls
Closure for &#39;cb&#39;.
Definition: reclaim_api.c:327
struct GNUNET_RECLAIM_AttestationIterator * GNUNET_RECLAIM_get_attestations_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_AttestationResult proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
List all attestations for a local identity.
Definition: reclaim_api.c:1402
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_STOP
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:271
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:107
#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:326
Ticket consume message.
Definition: reclaim.h:474
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:1597
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
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:1063
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:264
size_t GNUNET_RECLAIM_attestation_serialize(const struct GNUNET_RECLAIM_Attestation *attestation, char *result)
Serialize an attestation.
void GNUNET_RECLAIM_attestation_list_destroy(struct GNUNET_RECLAIM_AttestationList *attestations)
Destroy claim list.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:94
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_Attribute *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an attribute.
Definition: reclaim_api.c:1144
struct GNUNET_SCHEDULER_Task * reconnect_task
Task doing exponential back-off trying to reconnect.
Definition: reclaim_api.c:377
Start a attribute iteration for the given identity.
Definition: reclaim.h:200
GNUNET_RECLAIM_AttributeTicketResult atr_cb
Attribute result callback.
Definition: reclaim_api.c:77
GNUNET_MQ_Error
Error codes for the queue.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:254
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:397
Stop attribute iteration for the given operation.
Definition: reclaim.h:295
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:410
#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:510
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attribute_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:295
struct GNUNET_CLIENT_TransmitHandle * th
Currently pending transmission request, or NULL for none.
Definition: reclaim_api.c:372
#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:1066
struct GNUNET_RECLAIM_AttributeIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:187
void GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op)
Cancel an operation.
Definition: reclaim_api.c:1051
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:139
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:249
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
struct GNUNET_RECLAIM_Attestation * attestation
The attestation.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attestation_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_Attestation *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an attestation.
Definition: reclaim_api.c:1236
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:1641
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_STORE
#define GNUNET_NO
Definition: gnunet_common.h:86
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT
A list of GNUNET_RECLAIM_Attribute structures.
void GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1661
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_START
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
A list of GNUNET_RECLAIM_Attestation structures.
#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:202
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:1339
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:89
static struct GNUNET_TIME_Relative exp_interval
Attribute expiration interval.
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:305
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:217
size_t GNUNET_RECLAIM_attribute_serialize(const struct GNUNET_RECLAIM_Attribute *attr, char *result)
Serialize an attribute.
Use to store an identity attribute.
Definition: reclaim.h:40
GNUNET_RECLAIM_AttestationResult at_cb
Attestation result callback.
Definition: reclaim_api.c:82
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:382
GNUNET_RECLAIM_AttributeResult proc
The continuation to call with the results.
Definition: reclaim_api.c:207
Start a attestation iteration for the given identity.
Definition: reclaim.h:239
struct GNUNET_RECLAIM_Handle * h
Main handle to access the idp.
Definition: reclaim_api.c:129
void GNUNET_RECLAIM_get_attestations_next(struct GNUNET_RECLAIM_AttestationIterator *ait)
Calls the record processor specified in #GNUNET_RECLAIM_get_attestation_start for the next record...
Definition: reclaim_api.c:1449
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:174
struct GNUNET_RECLAIM_AttributeIterator * it_tail
Tail of active iterations.
Definition: reclaim_api.c:347
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
size_t GNUNET_RECLAIM_attribute_serialize_get_size(const struct GNUNET_RECLAIM_Attribute *attr)
Get required size for serialization buffer.
void * proc_cls
Closure for proc.
Definition: reclaim_api.c:212
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
Ask for next result of ticket iteration for the given operation.
Definition: reclaim.h:333
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:269
static void force_reconnect(struct GNUNET_RECLAIM_Handle *handle)
Disconnect from service and then reconnect.
Definition: reclaim_api.c:431
#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:977
Common type definitions for the identity provider service and API.
struct GNUNET_RECLAIM_Handle * h
Main handle to access the service.
Definition: reclaim_api.c:259
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:343
struct GNUNET_RECLAIM_Identifier attestation
Referenced ID of Attestation (may be 0 if self-attested)
struct GNUNET_RECLAIM_AttestationIterator * ait_head
Head of active iterations.
Definition: reclaim_api.c:352
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
Stop attestation iteration for the given operation.
Definition: reclaim.h:278
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
Definition: reclaim_api.c:387
GNUNET_RECLAIM_ContinuationWithStatus rvk_cb
Revocation result callback.
Definition: reclaim_api.c:87
#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:1271
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:337
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:1692
Handle for a attribute iterator operation.
Definition: reclaim_api.c:177
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:182
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:305
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:489
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:238
Stop ticket iteration for the given operation.
Definition: reclaim.h:350
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:232
struct GNUNET_RECLAIM_Attribute * GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
struct GNUNET_RECLAIM_Ticket ticket
The ticket to revoke.
Definition: reclaim.h:425
struct GNUNET_MQ_Envelope * env
Envelope with the message for this queue entry.
Definition: reclaim_api.c:97
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:559
uint16_t attestations_len
Length of attestation data.
Definition: reclaim.h:525
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:587
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:288
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:165
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: reclaim_api.c:284
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:159
uint32_t r_id_gen
Request Id generator.
Definition: reclaim_api.c:392
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:170
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:215
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:701
static void handle_attestation_result(void *cls, const struct AttestationResultMessage *msg)
Handle an incoming message of type #GNUNET_MESSAGE_TYPE_RECLAIM_attestation_RESULT.
Definition: reclaim_api.c:801
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_Attribute *attr, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store an attribute.
Definition: reclaim_api.c:1097
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:210
Ticket issue message.
Definition: reclaim.h:367
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE
struct GNUNET_RECLAIM_Attestation * GNUNET_RECLAIM_attestation_deserialize(const char *data, size_t data_size)
Deserialize an attestation.
void * cls
Closure for tr_cb.
Definition: reclaim_api.c:149
size_t GNUNET_RECLAIM_attestation_serialize_get_size(const struct GNUNET_RECLAIM_Attestation *attestation)
Get required size for serialization buffer.
Message handler for a specific message type.
static int res
uint16_t attestation_len
Length of serialized attribute data.
Definition: reclaim.h:179
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:189
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attestation_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_Attestation *attr, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store an attestation.
Definition: reclaim_api.c:1189
Attribute store/delete response message.
Definition: reclaim.h:103
struct GNUNET_RECLAIM_Identifier id
ID.
static void free_ait(struct GNUNET_RECLAIM_AttestationIterator *ait)
Free it.
Definition: reclaim_api.c:467
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
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:377
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:392
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
struct GNUNET_RECLAIM_Ticket ticket
The ticket to consume.
Definition: reclaim.h:494
size_t GNUNET_RECLAIM_attribute_list_serialize(const struct GNUNET_RECLAIM_AttributeList *attrs, char *result)
Serialize an attribute list.
Ask for next result of attribute iteration for the given operation.
Definition: reclaim.h:222
struct GNUNET_RECLAIM_AttestationListEntry * list_head
List head.
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:233
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
GNUNET_RECLAIM_TicketCallback tr_cb
Ticket result callback.
Definition: reclaim_api.c:92
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:878
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:332
#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:519
#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:119
#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:322
Handle to a message queue.
Definition: mq.c:85
struct GNUNET_RECLAIM_AttestationIterator * next
Kept in a DLL.
Definition: reclaim_api.c:249
#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:941
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: reclaim_api.c:317
Ticket revoke message.
Definition: reclaim.h:431
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:169
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: reclaim_api.c:154
GNUNET_RECLAIM_TicketCallback tr_cb
The continuation to call with the results.
Definition: reclaim_api.c:144
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:228
void GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1360
Handle for a attestation iterator operation.
Definition: reclaim_api.c:244
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT
void(* GNUNET_RECLAIM_AttributeResult)(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr)
Callback used to notify the client of attribute results.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:321
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:342
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:441
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:437
Attribute is returned from the idp.
Definition: reclaim.h:124
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:139
#define GNUNET_RECLAIM_id_is_equal(a, b)
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:222
struct GNUNET_TIME_Relative reconnect_backoff
Time for next connect retry.
Definition: reclaim_api.c:382
Start a ticket iteration for the given identity.
Definition: reclaim.h:311
Handle for a ticket iterator operation.
Definition: reclaim_api.c:114
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:520
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:505
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:154
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:289
size_t GNUNET_RECLAIM_attribute_list_serialize_get_size(const struct GNUNET_RECLAIM_AttributeList *attrs)
Get required size for serialization buffer.
static char * rp
Relying party.
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP
Ask for next result of attestation iteration for the given operation.
Definition: reclaim.h:261
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
Header for all communications.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:831
#define GNUNET_YES
Definition: gnunet_common.h:85
static void free_it(struct GNUNET_RECLAIM_AttributeIterator *it)
Free it.
Definition: reclaim_api.c:450
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
struct GNUNET_RECLAIM_AttestationList * GNUNET_RECLAIM_attestation_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:360
struct GNUNET_RECLAIM_AttestationListEntry * next
DLL.
Attestation is returned from the idp.
Definition: reclaim.h:164
struct GNUNET_RECLAIM_AttestationIterator * ait_tail
Tail of active iterations.
Definition: reclaim_api.c:357
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:192
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the reclaim service.
Definition: reclaim_api.c:1026
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:129
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:484
GNUNET_RECLAIM_AttestationResult proc
The continuation to call with the results.
Definition: reclaim_api.c:274
void(* GNUNET_RECLAIM_AttestationResult)(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Attestation *attestation)
Callback used to notify the client of attestation results.
uint32_t success
Revocation result.
Definition: reclaim.h:446
void(* GNUNET_RECLAIM_AttributeTicketResult)(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr, const struct GNUNET_RECLAIM_Attestation *attestation)
Callback used to notify the client of attribute results.
static int check_attestation_result(void *cls, const struct AttestationResultMessage *msg)
Handle an incoming message of type #GNUNET_MESSAGE_TYPE_RECLAIM_attestation_RESULT.
Definition: reclaim_api.c:777
struct GNUNET_RECLAIM_TicketIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:124
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:134
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:50
void GNUNET_RECLAIM_get_attestations_stop(struct GNUNET_RECLAIM_AttestationIterator *ait)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1471
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:484
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
struct GNUNET_RECLAIM_TicketIterator * ticket_it_head
Head of active iterations.
Definition: reclaim_api.c:362
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE
static void reconnect_task(void *cls)
Reconnect.
Definition: reclaim_api.c:416
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Private key of the zone.
Definition: reclaim_api.c:300
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_AttributeList *attrs, GNUNET_RECLAIM_TicketCallback cb, void *cb_cls)
Issues a ticket to another relying party.
Definition: reclaim_api.c:1504
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:197
void * proc_cls
Closure for proc.
Definition: reclaim_api.c:279
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:400
Time for relative time used by GNUnet, in microseconds.
#define GNUNET_RECLAIM_id_is_zero(a)
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:503
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET
uint32_t r_id
request id
Definition: reclaim_api.c:102
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:974