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 
103 
107  uint32_t r_id;
108 
112  void *cls;
113 };
114 
115 
120 {
125 
130 
135 
140 
145 
150 
154  void *cls;
155 
160 
165 
171 
175  uint32_t r_id;
176 };
177 
178 
183 {
188 
193 
198 
203 
208 
213 
217  void *proc_cls;
218 
223 
228 
234 
239 
243  uint32_t r_id;
244 };
245 
250 {
255 
260 
265 
270 
275 
280 
284  void *proc_cls;
285 
290 
295 
301 
306 
310  uint32_t r_id;
311 };
312 
313 
318 {
323 
327  struct GNUNET_CLIENT_Connection *client;
328 
332  void *cb_cls;
333 
338 
343 
348 
353 
358 
363 
368 
373 
377  struct GNUNET_CLIENT_TransmitHandle *th;
378 
383 
387  struct GNUNET_TIME_Relative reconnect_backoff;
388 
393 
397  uint32_t r_id_gen;
398 
403 };
404 
405 
411 static void
413 
414 
420 static void
422 {
423  struct GNUNET_RECLAIM_Handle *handle = cls;
424 
425  handle->reconnect_task = NULL;
426  reconnect (handle);
427 }
428 
429 
435 static void
437 {
438  GNUNET_MQ_destroy (handle->mq);
439  handle->mq = NULL;
440  handle->reconnect_backoff =
442  handle->reconnect_task =
445  handle);
446 }
447 
448 
454 static void
456 {
457  struct GNUNET_RECLAIM_Handle *h = it->h;
458 
460  if (NULL != it->env)
461  GNUNET_MQ_discard (it->env);
462  GNUNET_free (it);
463 }
464 
465 
471 static void
473 {
474  struct GNUNET_RECLAIM_Handle *h = ait->h;
475 
477  if (NULL != ait->env)
478  GNUNET_MQ_discard (ait->env);
479  GNUNET_free (ait);
480 }
481 
482 
488 static void
490 {
491  if (NULL == op)
492  return;
493  if (NULL != op->env)
494  GNUNET_MQ_discard (op->env);
495  GNUNET_free (op);
496 }
497 
498 
507 static void
509 {
510  struct GNUNET_RECLAIM_Handle *handle = cls;
511 
512  force_reconnect (handle);
513 }
514 
515 
523 static void
525 {
526  struct GNUNET_RECLAIM_Handle *h = cls;
528  uint32_t r_id = ntohl (msg->id);
529  int res;
530  const char *emsg;
531 
532  for (op = h->op_head; NULL != op; op = op->next)
533  if (op->r_id == r_id)
534  break;
535  if (NULL == op)
536  return;
537 
538  res = ntohl (msg->op_result);
540  "Received SUCCESS_RESPONSE with result %d\n",
541  res);
542 
543  /* TODO: add actual error message to response... */
544  if (GNUNET_SYSERR == res)
545  emsg = _ ("failed to store record\n");
546  else
547  emsg = NULL;
548  if (NULL != op->as_cb)
549  op->as_cb (op->cls, res, emsg);
551  free_op (op);
552 }
553 
554 
563 static int
565  const struct ConsumeTicketResultMessage *msg)
566 {
567  size_t msg_len;
568  size_t attrs_len;
569  size_t pl_len;
570 
571  msg_len = ntohs (msg->header.size);
572  attrs_len = ntohs (msg->attrs_len);
573  pl_len = ntohs (msg->presentations_len);
574  if (msg_len !=
575  sizeof(struct ConsumeTicketResultMessage) + attrs_len + pl_len)
576  {
577  GNUNET_break (0);
578  return GNUNET_SYSERR;
579  }
580  return GNUNET_OK;
581 }
582 
583 
591 static void
593  const struct ConsumeTicketResultMessage *msg)
594 {
595  struct GNUNET_RECLAIM_Handle *h = cls;
597  size_t attrs_len;
598  size_t pl_len;
599  uint32_t r_id = ntohl (msg->id);
600  char *read_ptr;
601 
602  attrs_len = ntohs (msg->attrs_len);
603  pl_len = ntohs (msg->presentations_len);
604  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n");
605 
606 
607  for (op = h->op_head; NULL != op; op = op->next)
608  if (op->r_id == r_id)
609  break;
610  if (NULL == op)
611  return;
612 
613  {
614  struct GNUNET_RECLAIM_AttributeList *attrs;
618  attrs =
619  GNUNET_RECLAIM_attribute_list_deserialize ((char *) &msg[1], attrs_len);
620  read_ptr = ((char *) &msg[1]) + attrs_len;
621  pl = GNUNET_RECLAIM_presentation_list_deserialize (read_ptr, pl_len);
622  if (NULL != op->atr_cb)
623  {
624  if (NULL == attrs)
625  {
626  op->atr_cb (op->cls, &msg->identity, NULL, NULL);
627  }
628  else
629  {
630  for (le = attrs->list_head; NULL != le; le = le->next)
631  {
632  if (GNUNET_NO ==
634  {
635  for (ple = pl->list_head; NULL != ple; ple = ple->next)
636  {
637  if (GNUNET_YES ==
639  &ple->presentation->credential_id))
640  {
641  op->atr_cb (op->cls, &msg->identity,
642  le->attribute, ple->presentation);
643  break;
644  }
645 
646  }
647  }
648  else // No credentials
649  {
650  op->atr_cb (op->cls, &msg->identity,
651  le->attribute, NULL);
652  }
653  }
654  if (NULL != attrs)
656  if (NULL != pl)
658  attrs = NULL;
659  pl = NULL;
660  }
661  op->atr_cb (op->cls, NULL, NULL, NULL);
662  }
664  free_op (op);
665  GNUNET_free (attrs);
666  return;
667  }
668  GNUNET_assert (0);
669 }
670 
671 
680 static int
682 {
683  size_t msg_len;
684  size_t attr_len;
685 
686  msg_len = ntohs (msg->header.size);
687  attr_len = ntohs (msg->attr_len);
688  if (msg_len != sizeof(struct AttributeResultMessage) + attr_len)
689  {
690  GNUNET_break (0);
691  return GNUNET_SYSERR;
692  }
693  return GNUNET_OK;
694 }
695 
696 
704 static void
706 {
707  static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
708  struct GNUNET_RECLAIM_Handle *h = cls;
711  size_t attr_len;
712  uint32_t r_id = ntohl (msg->id);
713 
714  attr_len = ntohs (msg->attr_len);
715  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
716 
717 
718  for (it = h->it_head; NULL != it; it = it->next)
719  if (it->r_id == r_id)
720  break;
721  for (op = h->op_head; NULL != op; op = op->next)
722  if (op->r_id == r_id)
723  break;
724  if ((NULL == it) && (NULL == op))
725  return;
726 
727  if ((0 ==
728  (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
729  {
730  if ((NULL == it) && (NULL == op))
731  {
732  GNUNET_break (0);
733  force_reconnect (h);
734  return;
735  }
736  if (NULL != it)
737  {
738  if (NULL != it->finish_cb)
739  it->finish_cb (it->finish_cb_cls);
740  free_it (it);
741  }
742  if (NULL != op)
743  {
744  if (NULL != op->ar_cb)
745  op->ar_cb (op->cls, NULL, NULL);
747  free_op (op);
748  }
749  return;
750  }
751 
752  {
753  struct GNUNET_RECLAIM_Attribute *attr;
754  GNUNET_RECLAIM_attribute_deserialize ((char *) &msg[1], attr_len,
755  &attr);
756  if (NULL != it)
757  {
758  if (NULL != it->proc)
759  it->proc (it->proc_cls, &msg->identity, attr);
760  }
761  else if (NULL != op)
762  {
763  if (NULL != op->ar_cb)
764  op->ar_cb (op->cls, &msg->identity, attr);
765  }
766  GNUNET_free (attr);
767  return;
768  }
769  GNUNET_assert (0);
770 }
771 
772 
781 static int
783 {
784  size_t msg_len;
785  size_t cred_len;
786 
787  msg_len = ntohs (msg->header.size);
788  cred_len = ntohs (msg->credential_len);
789  if (msg_len != sizeof(struct CredentialResultMessage) + cred_len)
790  {
791  GNUNET_break (0);
792  return GNUNET_SYSERR;
793  }
794  return GNUNET_OK;
795 }
796 
797 
805 static void
806 handle_credential_result (void *cls, const struct
808 {
809  static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
810  struct GNUNET_RECLAIM_Handle *h = cls;
813  size_t att_len;
814  uint32_t r_id = ntohl (msg->id);
815 
816  att_len = ntohs (msg->credential_len);
817  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing credential result.\n");
818 
819 
820  for (it = h->ait_head; NULL != it; it = it->next)
821  if (it->r_id == r_id)
822  break;
823  for (op = h->op_head; NULL != op; op = op->next)
824  if (op->r_id == r_id)
825  break;
826  if ((NULL == it) && (NULL == op))
827  return;
828 
829  if ((0 ==
830  (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
831  {
832  if ((NULL == it) && (NULL == op))
833  {
834  GNUNET_break (0);
835  force_reconnect (h);
836  return;
837  }
838  if (NULL != it)
839  {
840  if (NULL != it->finish_cb)
841  it->finish_cb (it->finish_cb_cls);
842  free_ait (it);
843  }
844  if (NULL != op)
845  {
846  if (NULL != op->at_cb)
847  op->at_cb (op->cls, NULL, NULL);
849  free_op (op);
850  }
851  return;
852  }
853 
854  {
855  struct GNUNET_RECLAIM_Credential *att;
856  att = GNUNET_RECLAIM_credential_deserialize ((char *) &msg[1], att_len);
857 
858  if (NULL != it)
859  {
860  if (NULL != it->proc)
861  it->proc (it->proc_cls, &msg->identity, att);
862  }
863  else if (NULL != op)
864  {
865  if (NULL != op->at_cb)
866  op->at_cb (op->cls, &msg->identity, att);
867  }
868  GNUNET_free (att);
869  return;
870  }
871  GNUNET_assert (0);
872 }
873 
882 static int
884 {
885  size_t msg_len;
886  size_t pres_len;
887 
888  msg_len = ntohs (msg->header.size);
889  pres_len = ntohs (msg->presentations_len);
890  if (msg_len != sizeof(struct TicketResultMessage) + pres_len)
891  {
892  GNUNET_break (0);
893  return GNUNET_SYSERR;
894  }
895  return GNUNET_OK;
896 }
897 
898 
906 static void
908 {
909  struct GNUNET_RECLAIM_Handle *handle = cls;
912  struct GNUNET_RECLAIM_PresentationList *pres;
913  uint32_t r_id = ntohl (msg->id);
914  static const struct GNUNET_RECLAIM_Ticket ticket;
915  uint32_t pres_len = ntohs (msg->presentations_len);
916 
917  for (op = handle->op_head; NULL != op; op = op->next)
918  if (op->r_id == r_id)
919  break;
920  for (it = handle->ticket_it_head; NULL != it; it = it->next)
921  if (it->r_id == r_id)
922  break;
923  if ((NULL == op) && (NULL == it))
924  return;
925  if (NULL != op)
926  {
927  if (0 < pres_len)
928  pres = GNUNET_RECLAIM_presentation_list_deserialize ((char*)&msg[1],
929  pres_len);
930  GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
931  if (0 ==
932  memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
933  {
934  if (NULL != op->ti_cb)
935  op->ti_cb (op->cls, NULL, NULL);
936  }
937  else
938  {
939  if (NULL != op->ti_cb)
940  op->ti_cb (op->cls,
941  &msg->ticket,
942  (0 < pres_len) ? pres : NULL);
943  }
944  if (0 < pres_len)
946  free_op (op);
947  return;
948  }
949  else if (NULL != it)
950  {
951  if (0 ==
952  memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
953  {
955  handle->ticket_it_tail,
956  it);
957  it->finish_cb (it->finish_cb_cls);
958  GNUNET_free (it);
959  }
960  else
961  {
962  if (NULL != it->tr_cb)
963  it->tr_cb (it->cls, &msg->ticket);
964  }
965  return;
966  }
967  GNUNET_break (0);
968 }
969 
970 
978 static void
980  const struct RevokeTicketResultMessage *msg)
981 {
982  struct GNUNET_RECLAIM_Handle *h = cls;
984  uint32_t r_id = ntohl (msg->id);
985  int32_t success;
986 
987  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n");
988 
989 
990  for (op = h->op_head; NULL != op; op = op->next)
991  if (op->r_id == r_id)
992  break;
993  if (NULL == op)
994  return;
995  success = ntohl (msg->success);
996  {
997  if (NULL != op->rvk_cb)
998  {
999  op->rvk_cb (op->cls, success, NULL);
1000  }
1002  free_op (op);
1003  return;
1004  }
1005  GNUNET_assert (0);
1006 }
1007 
1008 
1014 static void
1016 {
1017  struct GNUNET_MQ_MessageHandler handlers[] =
1018  { GNUNET_MQ_hd_fixed_size (success_response,
1020  struct SuccessResultMessage,
1021  h),
1022  GNUNET_MQ_hd_var_size (attribute_result,
1024  struct AttributeResultMessage,
1025  h),
1026  GNUNET_MQ_hd_var_size (credential_result,
1028  struct CredentialResultMessage,
1029  h),
1030  GNUNET_MQ_hd_var_size (ticket_result,
1032  struct TicketResultMessage,
1033  h),
1034  GNUNET_MQ_hd_var_size (consume_ticket_result,
1037  h),
1038  GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
1041  h),
1042  GNUNET_MQ_handler_end () };
1043  struct GNUNET_RECLAIM_Operation *op;
1044 
1045  GNUNET_assert (NULL == h->mq);
1046  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
1047 
1048  h->mq =
1049  GNUNET_CLIENT_connect (h->cfg, "reclaim", handlers, &mq_error_handler, h);
1050  if (NULL == h->mq)
1051  return;
1052  for (op = h->op_head; NULL != op; op = op->next)
1053  GNUNET_MQ_send_copy (h->mq, op->env);
1054 }
1055 
1056 
1063 struct GNUNET_RECLAIM_Handle *
1065 {
1066  struct GNUNET_RECLAIM_Handle *h;
1067 
1068  h = GNUNET_new (struct GNUNET_RECLAIM_Handle);
1069  h->cfg = cfg;
1070  reconnect (h);
1071  if (NULL == h->mq)
1072  {
1073  GNUNET_free (h);
1074  return NULL;
1075  }
1076  return h;
1077 }
1078 
1079 
1088 void
1090 {
1091  struct GNUNET_RECLAIM_Handle *h = op->h;
1092 
1094  free_op (op);
1095 }
1096 
1097 
1103 void
1105 {
1106  GNUNET_assert (NULL != h);
1107  if (NULL != h->mq)
1108  {
1109  GNUNET_MQ_destroy (h->mq);
1110  h->mq = NULL;
1111  }
1112  if (NULL != h->reconnect_task)
1113  {
1115  h->reconnect_task = NULL;
1116  }
1117  GNUNET_assert (NULL == h->op_head);
1118  GNUNET_free (h);
1119 }
1120 
1121 
1134 struct GNUNET_RECLAIM_Operation *
1136  struct GNUNET_RECLAIM_Handle *h,
1137  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1138  const struct GNUNET_RECLAIM_Attribute *attr,
1139  const struct GNUNET_TIME_Relative *exp_interval,
1141  void *cont_cls)
1142 {
1143  struct GNUNET_RECLAIM_Operation *op;
1144  struct AttributeStoreMessage *sam;
1145  size_t attr_len;
1146 
1147  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1148  op->h = h;
1149  op->as_cb = cont;
1150  op->cls = cont_cls;
1151  op->r_id = h->r_id_gen++;
1154  op->env = GNUNET_MQ_msg_extra (sam,
1155  attr_len,
1157  sam->identity = *pkey;
1158  sam->id = htonl (op->r_id);
1159  sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
1160 
1161  GNUNET_RECLAIM_attribute_serialize (attr, (char *) &sam[1]);
1162 
1163  sam->attr_len = htons (attr_len);
1164  if (NULL != h->mq)
1165  GNUNET_MQ_send_copy (h->mq, op->env);
1166  return op;
1167 }
1168 
1169 
1181 struct GNUNET_RECLAIM_Operation *
1183  struct GNUNET_RECLAIM_Handle *h,
1184  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1185  const struct GNUNET_RECLAIM_Attribute *attr,
1187  void *cont_cls)
1188 {
1189  struct GNUNET_RECLAIM_Operation *op;
1190  struct AttributeDeleteMessage *dam;
1191  size_t attr_len;
1192 
1193  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1194  op->h = h;
1195  op->as_cb = cont;
1196  op->cls = cont_cls;
1197  op->r_id = h->r_id_gen++;
1200  op->env = GNUNET_MQ_msg_extra (dam,
1201  attr_len,
1203  dam->identity = *pkey;
1204  dam->id = htonl (op->r_id);
1205  GNUNET_RECLAIM_attribute_serialize (attr, (char *) &dam[1]);
1206 
1207  dam->attr_len = htons (attr_len);
1208  if (NULL != h->mq)
1209  GNUNET_MQ_send_copy (h->mq, op->env);
1210  return op;
1211 }
1212 
1213 
1226 struct GNUNET_RECLAIM_Operation *
1228  struct GNUNET_RECLAIM_Handle *h,
1229  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1230  const struct GNUNET_RECLAIM_Credential *attr,
1231  const struct GNUNET_TIME_Relative *exp_interval,
1233  void *cont_cls)
1234 {
1235  struct GNUNET_RECLAIM_Operation *op;
1236  struct AttributeStoreMessage *sam;
1237  size_t attr_len;
1238 
1239  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1240  op->h = h;
1241  op->as_cb = cont;
1242  op->cls = cont_cls;
1243  op->r_id = h->r_id_gen++;
1246  op->env = GNUNET_MQ_msg_extra (sam,
1247  attr_len,
1249  sam->identity = *pkey;
1250  sam->id = htonl (op->r_id);
1251  sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
1252 
1253  GNUNET_RECLAIM_credential_serialize (attr, (char *) &sam[1]);
1254 
1255  sam->attr_len = htons (attr_len);
1256  if (NULL != h->mq)
1257  GNUNET_MQ_send_copy (h->mq, op->env);
1258  return op;
1259 }
1260 
1261 
1273 struct GNUNET_RECLAIM_Operation *
1275  struct GNUNET_RECLAIM_Handle *h,
1276  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
1277  const struct GNUNET_RECLAIM_Credential *attr,
1279  void *cont_cls)
1280 {
1281  struct GNUNET_RECLAIM_Operation *op;
1282  struct AttributeDeleteMessage *dam;
1283  size_t attr_len;
1284 
1285  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1286  op->h = h;
1287  op->as_cb = cont;
1288  op->cls = cont_cls;
1289  op->r_id = h->r_id_gen++;
1292  op->env = GNUNET_MQ_msg_extra (dam,
1293  attr_len,
1295  dam->identity = *pkey;
1296  dam->id = htonl (op->r_id);
1297  GNUNET_RECLAIM_credential_serialize (attr, (char *) &dam[1]);
1298 
1299  dam->attr_len = htons (attr_len);
1300  if (NULL != h->mq)
1301  GNUNET_MQ_send_copy (h->mq, op->env);
1302  return op;
1303 }
1304 
1305 
1332  struct GNUNET_RECLAIM_Handle *h,
1335  void *error_cb_cls,
1337  void *proc_cls,
1339  void *finish_cb_cls)
1340 {
1342  struct GNUNET_MQ_Envelope *env;
1344  uint32_t rid;
1345 
1346  rid = h->r_id_gen++;
1348  it->h = h;
1349  it->error_cb = error_cb;
1350  it->error_cb_cls = error_cb_cls;
1351  it->finish_cb = finish_cb;
1352  it->finish_cb_cls = finish_cb_cls;
1353  it->proc = proc;
1354  it->proc_cls = proc_cls;
1355  it->r_id = rid;
1356  it->identity = *identity;
1358  env =
1360  msg->id = htonl (rid);
1361  msg->identity = *identity;
1362  if (NULL == h->mq)
1363  it->env = env;
1364  else
1365  GNUNET_MQ_send (h->mq, env);
1366  return it;
1367 }
1368 
1369 
1376 void
1378 {
1379  struct GNUNET_RECLAIM_Handle *h = it->h;
1381  struct GNUNET_MQ_Envelope *env;
1382 
1383  env =
1385  msg->id = htonl (it->r_id);
1386  GNUNET_MQ_send (h->mq, env);
1387 }
1388 
1389 
1397 void
1399 {
1400  struct GNUNET_RECLAIM_Handle *h = it->h;
1401  struct GNUNET_MQ_Envelope *env;
1403 
1404  if (NULL != h->mq)
1405  {
1406  env =
1408  msg->id = htonl (it->r_id);
1409  GNUNET_MQ_send (h->mq, env);
1410  }
1411  free_it (it);
1412 }
1413 
1414 
1441  struct GNUNET_RECLAIM_Handle *h,
1444  void *error_cb_cls,
1446  void *proc_cls,
1448  void *finish_cb_cls)
1449 {
1451  struct GNUNET_MQ_Envelope *env;
1453  uint32_t rid;
1454 
1455  rid = h->r_id_gen++;
1457  ait->h = h;
1458  ait->error_cb = error_cb;
1459  ait->error_cb_cls = error_cb_cls;
1460  ait->finish_cb = finish_cb;
1461  ait->finish_cb_cls = finish_cb_cls;
1462  ait->proc = proc;
1463  ait->proc_cls = proc_cls;
1464  ait->r_id = rid;
1465  ait->identity = *identity;
1467  env =
1468  GNUNET_MQ_msg (msg,
1470  msg->id = htonl (rid);
1471  msg->identity = *identity;
1472  if (NULL == h->mq)
1473  ait->env = env;
1474  else
1475  GNUNET_MQ_send (h->mq, env);
1476  return ait;
1477 }
1478 
1479 
1486 void
1489 {
1490  struct GNUNET_RECLAIM_Handle *h = ait->h;
1492  struct GNUNET_MQ_Envelope *env;
1493 
1494  env =
1496  msg->id = htonl (ait->r_id);
1497  GNUNET_MQ_send (h->mq, env);
1498 }
1499 
1500 
1508 void
1511 {
1512  struct GNUNET_RECLAIM_Handle *h = ait->h;
1513  struct GNUNET_MQ_Envelope *env;
1515 
1516  if (NULL != h->mq)
1517  {
1518  env =
1519  GNUNET_MQ_msg (msg,
1521  msg->id = htonl (ait->r_id);
1522  GNUNET_MQ_send (h->mq, env);
1523  }
1524  free_ait (ait);
1525 }
1526 
1527 
1541 struct GNUNET_RECLAIM_Operation *
1543  struct GNUNET_RECLAIM_Handle *h,
1544  const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
1545  const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
1546  const struct GNUNET_RECLAIM_AttributeList *attrs,
1548  void *cb_cls)
1549 {
1550  struct GNUNET_RECLAIM_Operation *op;
1551  struct IssueTicketMessage *tim;
1552  size_t attr_len;
1553 
1554  fprintf (stderr, "Issuing ticket\n");
1555  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1556  op->h = h;
1557  op->ti_cb = cb;
1558  op->cls = cb_cls;
1559  op->r_id = h->r_id_gen++;
1562  op->env = GNUNET_MQ_msg_extra (tim,
1563  attr_len,
1565  tim->identity = *iss;
1566  tim->rp = *rp;
1567  tim->id = htonl (op->r_id);
1568 
1569  GNUNET_RECLAIM_attribute_list_serialize (attrs, (char *) &tim[1]);
1570 
1571  tim->attr_len = htons (attr_len);
1572  if (NULL != h->mq)
1573  GNUNET_MQ_send_copy (h->mq, op->env);
1574  return op;
1575 }
1576 
1577 
1590 struct GNUNET_RECLAIM_Operation *
1592  struct GNUNET_RECLAIM_Handle *h,
1594  const struct GNUNET_RECLAIM_Ticket *ticket,
1596  void *cb_cls)
1597 {
1598  struct GNUNET_RECLAIM_Operation *op;
1599  struct ConsumeTicketMessage *ctm;
1600 
1601  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1602  op->h = h;
1603  op->atr_cb = cb;
1604  op->cls = cb_cls;
1605  op->r_id = h->r_id_gen++;
1608  ctm->identity = *identity;
1609  ctm->id = htonl (op->r_id);
1610  ctm->ticket = *ticket;
1611  if (NULL != h->mq)
1612  GNUNET_MQ_send_copy (h->mq, op->env);
1613  else
1614  reconnect (h);
1615  return op;
1616 }
1617 
1618 
1638  struct GNUNET_RECLAIM_Handle *h,
1641  void *error_cb_cls,
1643  void *proc_cls,
1645  void *finish_cb_cls)
1646 {
1647  struct GNUNET_RECLAIM_TicketIterator *it;
1648  struct GNUNET_MQ_Envelope *env;
1650  uint32_t rid;
1651 
1652  rid = h->r_id_gen++;
1654  it->h = h;
1655  it->error_cb = error_cb;
1656  it->error_cb_cls = error_cb_cls;
1657  it->finish_cb = finish_cb;
1658  it->finish_cb_cls = finish_cb_cls;
1659  it->tr_cb = proc;
1660  it->cls = proc_cls;
1661  it->r_id = rid;
1664  msg->id = htonl (rid);
1665  msg->identity = *identity;
1666  if (NULL == h->mq)
1667  it->env = env;
1668  else
1669  GNUNET_MQ_send (h->mq, env);
1670  return it;
1671 }
1672 
1673 
1680 void
1682 {
1683  struct GNUNET_RECLAIM_Handle *h = it->h;
1685  struct GNUNET_MQ_Envelope *env;
1686 
1688  msg->id = htonl (it->r_id);
1689  GNUNET_MQ_send (h->mq, env);
1690 }
1691 
1692 
1700 void
1702 {
1703  struct GNUNET_RECLAIM_Handle *h = it->h;
1704  struct GNUNET_MQ_Envelope *env;
1706 
1707  if (NULL != h->mq)
1708  {
1709  env =
1711  msg->id = htonl (it->r_id);
1712  GNUNET_MQ_send (h->mq, env);
1713  }
1714  GNUNET_free (it);
1715 }
1716 
1717 
1731 struct GNUNET_RECLAIM_Operation *
1733  struct GNUNET_RECLAIM_Handle *h,
1735  const struct GNUNET_RECLAIM_Ticket *ticket,
1737  void *cb_cls)
1738 {
1739  struct GNUNET_RECLAIM_Operation *op;
1740  struct RevokeTicketMessage *msg;
1741  uint32_t rid;
1742 
1743  rid = h->r_id_gen++;
1744  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1745  op->h = h;
1746  op->rvk_cb = cb;
1747  op->cls = cb_cls;
1748  op->r_id = rid;
1751  msg->id = htonl (rid);
1752  msg->identity = *identity;
1753  msg->ticket = *ticket;
1754  if (NULL != h->mq)
1755  {
1756  GNUNET_MQ_send (h->mq, op->env);
1757  op->env = NULL;
1758  }
1759  return op;
1760 }
1761 
1762 
1763 /* 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.
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:310
struct GNUNET_RECLAIM_TicketIterator * ticket_it_tail
Tail of active iterations.
Definition: reclaim_api.c:372
#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:681
void(* GNUNET_RECLAIM_CredentialResult)(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Credential *credential)
Callback used to notify the client of credential results.
ssize_t GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size, struct GNUNET_RECLAIM_Attribute **attr)
Deserialize an attribute.
uint16_t credential_len
Length of serialized attribute data.
Definition: reclaim.h:179
void GNUNET_RECLAIM_get_credentials_next(struct GNUNET_RECLAIM_CredentialIterator *ait)
Calls the record processor specified in #GNUNET_RECLAIM_get_credential_start for the next record...
Definition: reclaim_api.c:1487
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:317
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:415
The authorization ticket.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:288
struct GNUNET_CRYPTO_EcdsaPublicKey rp
Requesting party.
Definition: reclaim.h:387
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize an credential.
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_CredentialIterator * ait_tail
Tail of active iterations.
Definition: reclaim_api.c:362
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:1331
struct GNUNET_RECLAIM_Ticket ticket
The new ticket.
Definition: reclaim.h:473
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:507
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:1591
void * cb_cls
Closure for &#39;cb&#39;.
Definition: reclaim_api.c:332
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:112
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT
void GNUNET_RECLAIM_get_credentials_stop(struct GNUNET_RECLAIM_CredentialIterator *ait)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1509
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:481
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:1637
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
uint32_t presentations_len
Length of new presentations created.
Definition: reclaim.h:468
size_t GNUNET_RECLAIM_credential_serialize_get_size(const struct GNUNET_RECLAIM_Credential *credential)
Get required size for serialization buffer.
Stop credential iteration for the given operation.
Definition: reclaim.h:278
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:1182
struct GNUNET_SCHEDULER_Task * reconnect_task
Task doing exponential back-off trying to reconnect.
Definition: reclaim_api.c:382
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:271
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.
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:402
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:517
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:189
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attribute_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:294
struct GNUNET_RECLAIM_PresentationListEntry * next
DLL.
struct GNUNET_CLIENT_TransmitHandle * th
Currently pending transmission request, or NULL for none.
Definition: reclaim_api.c:377
#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:1104
struct GNUNET_RECLAIM_AttributeIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:192
void GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op)
Cancel an operation.
Definition: reclaim_api.c:1089
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:144
struct GNUNET_RECLAIM_PresentationListEntry * list_head
List head.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:300
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT
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:1681
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT.
Definition: reclaim.h:458
static int check_credential_result(void *cls, const struct CredentialResultMessage *msg)
Handle an incoming message of type #GNUNET_MESSAGE_TYPE_RECLAIM_credential_RESULT.
Definition: reclaim_api.c:782
#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:1701
#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:207
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:1377
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:89
static struct GNUNET_TIME_Relative exp_interval
Attribute expiration interval.
Handle for an operation with the service.
Definition: reclaim_api.c:41
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: reclaim_api.c:222
struct GNUNET_RECLAIM_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
struct GNUNET_RECLAIM_CredentialIterator * GNUNET_RECLAIM_get_credentials_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_CredentialResult proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
List all credentials for a local identity.
Definition: reclaim_api.c:1440
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
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:212
struct GNUNET_RECLAIM_Handle * h
Main handle to access the idp.
Definition: reclaim_api.c:134
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:352
#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:217
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
static void force_reconnect(struct GNUNET_RECLAIM_Handle *handle)
Disconnect from service and then reconnect.
Definition: reclaim_api.c:436
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT
#define _(String)
GNU gettext support macro.
Definition: platform.h:184
static void reconnect(struct GNUNET_RECLAIM_Handle *h)
Try again to connect to the service.
Definition: reclaim_api.c:1015
Common type definitions for the identity provider service and API.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:343
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
Definition: reclaim_api.c:392
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:1269
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:342
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:1732
Handle for a attribute iterator operation.
Definition: reclaim_api.c:182
void * proc_cls
Closure for proc.
Definition: reclaim_api.c:284
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:187
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
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:169
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:254
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:496
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:243
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_Ticket ticket
The ticket to revoke.
Definition: reclaim.h:425
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_IssueTicketCallback cb, void *cb_cls)
Issues a ticket to another relying party.
Definition: reclaim_api.c:1542
struct GNUNET_MQ_Envelope * env
Envelope with the message for this queue entry.
Definition: reclaim_api.c:102
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:564
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:592
GNUNET_RECLAIM_CredentialResult proc
The continuation to call with the results.
Definition: reclaim_api.c:279
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE
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:170
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:164
struct GNUNET_RECLAIM_Identifier credential_id
The credential id of which this is a presentation.
uint32_t r_id_gen
Request Id generator.
Definition: reclaim_api.c:397
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:175
#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:705
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:1135
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:210
struct GNUNET_RECLAIM_CredentialIterator * next
Kept in a DLL.
Definition: reclaim_api.c:254
Ticket issue message.
Definition: reclaim.h:367
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE
GNUNET_RECLAIM_IssueTicketCallback ti_cb
Ticket issue result callback.
Definition: reclaim_api.c:97
void * cls
Closure for tr_cb.
Definition: reclaim_api.c:154
Message handler for a specific message type.
static int res
Attribute store/delete response message.
Definition: reclaim.h:103
static int check_ticket_result(void *cls, const struct TicketResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT.
Definition: reclaim_api.c:883
size_t GNUNET_RECLAIM_credential_serialize(const struct GNUNET_RECLAIM_Credential *credential, char *result)
Serialize an credential.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:323
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
void GNUNET_RECLAIM_presentation_list_destroy(struct GNUNET_RECLAIM_PresentationList *presentations)
Destroy presentations list.
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
struct GNUNET_RECLAIM_Ticket ticket
The ticket to consume.
Definition: reclaim.h:501
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
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:84
GNUNET_RECLAIM_CredentialResult at_cb
Credential result callback.
Definition: reclaim_api.c:82
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Private key of the zone.
Definition: reclaim_api.c:238
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START
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:907
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:337
Start a credential iteration for the given identity.
Definition: reclaim.h:239
#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:524
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
void(* GNUNET_RECLAIM_AttributeTicketResult)(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr, const struct GNUNET_RECLAIM_Presentation *presentation)
Callback used to notify the client of attribute results.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Private key of the zone.
Definition: reclaim_api.c:305
uint16_t presentations_len
Length of presentation data.
Definition: reclaim.h:532
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:249
struct GNUNET_RECLAIM_TicketIterator * next
Kept in a DLL.
Definition: reclaim_api.c:124
#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:327
Handle to a message queue.
Definition: mq.c:85
Ask for next result of credential iteration for the given operation.
Definition: reclaim.h:261
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP
struct GNUNET_RECLAIM_Presentation * presentation
The credential.
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:979
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START
struct GNUNET_RECLAIM_Handle * h
Main handle to access the service.
Definition: reclaim_api.c:264
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:274
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: reclaim_api.c:322
A list of GNUNET_RECLAIM_Presentation structures.
Ticket revoke message.
Definition: reclaim.h:431
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: reclaim_api.c:159
GNUNET_RECLAIM_TicketCallback tr_cb
The continuation to call with the results.
Definition: reclaim_api.c:149
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:233
void GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1398
#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:347
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:443
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:227
struct GNUNET_TIME_Relative reconnect_backoff
Time for next connect retry.
Definition: reclaim_api.c:387
void(* GNUNET_RECLAIM_IssueTicketCallback)(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket, const struct GNUNET_RECLAIM_PresentationList *presentations)
Method called when a token has been issued.
Start a ticket iteration for the given identity.
Definition: reclaim.h:311
Handle for a ticket iterator operation.
Definition: reclaim_api.c:119
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:527
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:512
static void free_ait(struct GNUNET_RECLAIM_CredentialIterator *ait)
Free it.
Definition: reclaim_api.c:472
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:154
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
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_credential_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_Credential *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an credential.
Definition: reclaim_api.c:1274
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:269
struct GNUNET_RECLAIM_CredentialIterator * ait_head
Head of active iterations.
Definition: reclaim_api.c:357
#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:837
static void free_it(struct GNUNET_RECLAIM_AttributeIterator *it)
Free it.
Definition: reclaim_api.c:455
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:355
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:360
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_credential_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_Credential *attr, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store an credential.
Definition: reclaim_api.c:1227
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:197
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the reclaim service.
Definition: reclaim_api.c:1064
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:129
Credential is returned from the idp.
Definition: reclaim.h:164
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:489
uint32_t success
Revocation result.
Definition: reclaim.h:446
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_STOP
struct GNUNET_RECLAIM_TicketIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:129
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:139
Handle for a credential iterator operation.
Definition: reclaim_api.c:249
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:491
#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:367
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE
static void reconnect_task(void *cls)
Reconnect.
Definition: reclaim_api.c:421
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
static void handle_credential_result(void *cls, const struct CredentialResultMessage *msg)
Handle an incoming message of type #GNUNET_MESSAGE_TYPE_RECLAIM_credential_RESULT.
Definition: reclaim_api.c:806
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:202
struct GNUNET_RECLAIM_CredentialIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:259
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:113
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_RECLAIM_PresentationList * GNUNET_RECLAIM_presentation_list_deserialize(const char *data, size_t data_size)
Deserialize a presentation list.
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:508
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET
uint32_t r_id
request id
Definition: reclaim_api.c:107
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: reclaim_api.c:289