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  }
655  op->atr_cb (op->cls, NULL, NULL, NULL);
656  }
657  if (NULL != attrs)
659  if (NULL != pl)
662  free_op (op);
663  return;
664  }
665  GNUNET_assert (0);
666 }
667 
668 
677 static int
679 {
680  size_t msg_len;
681  size_t attr_len;
682 
683  msg_len = ntohs (msg->header.size);
684  attr_len = ntohs (msg->attr_len);
685  if (msg_len != sizeof(struct AttributeResultMessage) + attr_len)
686  {
687  GNUNET_break (0);
688  return GNUNET_SYSERR;
689  }
690  return GNUNET_OK;
691 }
692 
693 
701 static void
703 {
704  static struct GNUNET_IDENTITY_PrivateKey identity_dummy;
705  struct GNUNET_RECLAIM_Handle *h = cls;
708  size_t attr_len;
709  uint32_t r_id = ntohl (msg->id);
710 
711  attr_len = ntohs (msg->attr_len);
712  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
713 
714 
715  for (it = h->it_head; NULL != it; it = it->next)
716  if (it->r_id == r_id)
717  break;
718  for (op = h->op_head; NULL != op; op = op->next)
719  if (op->r_id == r_id)
720  break;
721  if ((NULL == it) && (NULL == op))
722  return;
723 
724  if ((0 ==
725  (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
726  {
727  if ((NULL == it) && (NULL == op))
728  {
729  GNUNET_break (0);
730  force_reconnect (h);
731  return;
732  }
733  if (NULL != it)
734  {
735  if (NULL != it->finish_cb)
736  it->finish_cb (it->finish_cb_cls);
737  free_it (it);
738  }
739  if (NULL != op)
740  {
741  if (NULL != op->ar_cb)
742  op->ar_cb (op->cls, NULL, NULL);
744  free_op (op);
745  }
746  return;
747  }
748 
749  {
750  struct GNUNET_RECLAIM_Attribute *attr;
751  GNUNET_RECLAIM_attribute_deserialize ((char *) &msg[1], attr_len,
752  &attr);
753  if (NULL != it)
754  {
755  if (NULL != it->proc)
756  it->proc (it->proc_cls, &msg->identity, attr);
757  }
758  else if (NULL != op)
759  {
760  if (NULL != op->ar_cb)
761  op->ar_cb (op->cls, &msg->identity, attr);
762  }
763  GNUNET_free (attr);
764  return;
765  }
766  GNUNET_assert (0);
767 }
768 
769 
778 static int
780 {
781  size_t msg_len;
782  size_t cred_len;
783 
784  msg_len = ntohs (msg->header.size);
785  cred_len = ntohs (msg->credential_len);
786  if (msg_len != sizeof(struct CredentialResultMessage) + cred_len)
787  {
788  GNUNET_break (0);
789  return GNUNET_SYSERR;
790  }
791  return GNUNET_OK;
792 }
793 
794 
802 static void
803 handle_credential_result (void *cls, const struct
805 {
806  static struct GNUNET_IDENTITY_PrivateKey identity_dummy;
807  struct GNUNET_RECLAIM_Handle *h = cls;
810  size_t att_len;
811  uint32_t r_id = ntohl (msg->id);
812 
813  att_len = ntohs (msg->credential_len);
814  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing credential result.\n");
815 
816 
817  for (it = h->ait_head; NULL != it; it = it->next)
818  if (it->r_id == r_id)
819  break;
820  for (op = h->op_head; NULL != op; op = op->next)
821  if (op->r_id == r_id)
822  break;
823  if ((NULL == it) && (NULL == op))
824  return;
825 
826  if ((0 ==
827  (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
828  {
829  if ((NULL == it) && (NULL == op))
830  {
831  GNUNET_break (0);
832  force_reconnect (h);
833  return;
834  }
835  if (NULL != it)
836  {
837  if (NULL != it->finish_cb)
838  it->finish_cb (it->finish_cb_cls);
839  free_ait (it);
840  }
841  if (NULL != op)
842  {
843  if (NULL != op->at_cb)
844  op->at_cb (op->cls, NULL, NULL);
846  free_op (op);
847  }
848  return;
849  }
850 
851  {
852  struct GNUNET_RECLAIM_Credential *att;
853  att = GNUNET_RECLAIM_credential_deserialize ((char *) &msg[1], att_len);
854 
855  if (NULL != it)
856  {
857  if (NULL != it->proc)
858  it->proc (it->proc_cls, &msg->identity, att);
859  }
860  else if (NULL != op)
861  {
862  if (NULL != op->at_cb)
863  op->at_cb (op->cls, &msg->identity, att);
864  }
865  GNUNET_free (att);
866  return;
867  }
868  GNUNET_assert (0);
869 }
870 
871 
880 static int
882 {
883  size_t msg_len;
884  size_t pres_len;
885 
886  msg_len = ntohs (msg->header.size);
887  pres_len = ntohs (msg->presentations_len);
888  if (msg_len != sizeof(struct TicketResultMessage) + pres_len)
889  {
890  GNUNET_break (0);
891  return GNUNET_SYSERR;
892  }
893  return GNUNET_OK;
894 }
895 
896 
904 static void
906 {
907  struct GNUNET_RECLAIM_Handle *handle = cls;
910  struct GNUNET_RECLAIM_PresentationList *presentation;
911  uint32_t r_id = ntohl (msg->id);
912  static const struct GNUNET_RECLAIM_Ticket ticket;
913  uint32_t pres_len = ntohs (msg->presentations_len);
914 
915  for (op = handle->op_head; NULL != op; op = op->next)
916  if (op->r_id == r_id)
917  break;
918  for (it = handle->ticket_it_head; NULL != it; it = it->next)
919  if (it->r_id == r_id)
920  break;
921  if ((NULL == op) && (NULL == it))
922  return;
923  if (NULL != op)
924  {
925  if (0 < pres_len)
927  (char*) &msg[1],
928  pres_len);
929  GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
930  if (0 ==
931  memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
932  {
933  if (NULL != op->ti_cb)
934  op->ti_cb (op->cls, NULL, NULL);
935  }
936  else
937  {
938  if (NULL != op->ti_cb)
939  op->ti_cb (op->cls,
940  &msg->ticket,
941  (0 < pres_len) ? presentation : NULL);
942  }
943  if (0 < pres_len)
945  free_op (op);
946  return;
947  }
948  else if (NULL != it)
949  {
950  if (0 ==
951  memcmp (&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
952  {
954  handle->ticket_it_tail,
955  it);
956  it->finish_cb (it->finish_cb_cls);
957  GNUNET_free (it);
958  }
959  else
960  {
961  if (NULL != it->tr_cb)
962  it->tr_cb (it->cls, &msg->ticket);
963  }
964  return;
965  }
966  GNUNET_break (0);
967 }
968 
969 
977 static void
979  const struct RevokeTicketResultMessage *msg)
980 {
981  struct GNUNET_RECLAIM_Handle *h = cls;
983  uint32_t r_id = ntohl (msg->id);
984  int32_t success;
985 
986  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n");
987 
988 
989  for (op = h->op_head; NULL != op; op = op->next)
990  if (op->r_id == r_id)
991  break;
992  if (NULL == op)
993  return;
994  success = ntohl (msg->success);
995  {
996  if (NULL != op->rvk_cb)
997  {
998  op->rvk_cb (op->cls, success, NULL);
999  }
1001  free_op (op);
1002  return;
1003  }
1004  GNUNET_assert (0);
1005 }
1006 
1007 
1013 static void
1015 {
1016  struct GNUNET_MQ_MessageHandler handlers[] =
1017  { GNUNET_MQ_hd_fixed_size (success_response,
1019  struct SuccessResultMessage,
1020  h),
1021  GNUNET_MQ_hd_var_size (attribute_result,
1023  struct AttributeResultMessage,
1024  h),
1025  GNUNET_MQ_hd_var_size (credential_result,
1027  struct CredentialResultMessage,
1028  h),
1029  GNUNET_MQ_hd_var_size (ticket_result,
1031  struct TicketResultMessage,
1032  h),
1033  GNUNET_MQ_hd_var_size (consume_ticket_result,
1036  h),
1037  GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
1040  h),
1041  GNUNET_MQ_handler_end () };
1042  struct GNUNET_RECLAIM_Operation *op;
1043 
1044  GNUNET_assert (NULL == h->mq);
1045  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
1046 
1047  h->mq =
1048  GNUNET_CLIENT_connect (h->cfg, "reclaim", handlers, &mq_error_handler, h);
1049  if (NULL == h->mq)
1050  return;
1051  for (op = h->op_head; NULL != op; op = op->next)
1052  GNUNET_MQ_send_copy (h->mq, op->env);
1053 }
1054 
1055 
1062 struct GNUNET_RECLAIM_Handle *
1064 {
1065  struct GNUNET_RECLAIM_Handle *h;
1066 
1067  h = GNUNET_new (struct GNUNET_RECLAIM_Handle);
1068  h->cfg = cfg;
1069  reconnect (h);
1070  if (NULL == h->mq)
1071  {
1072  GNUNET_free (h);
1073  return NULL;
1074  }
1075  return h;
1076 }
1077 
1078 
1087 void
1089 {
1090  struct GNUNET_RECLAIM_Handle *h = op->h;
1091 
1093  free_op (op);
1094 }
1095 
1096 
1102 void
1104 {
1105  GNUNET_assert (NULL != h);
1106  if (NULL != h->mq)
1107  {
1108  GNUNET_MQ_destroy (h->mq);
1109  h->mq = NULL;
1110  }
1111  if (NULL != h->reconnect_task)
1112  {
1114  h->reconnect_task = NULL;
1115  }
1116  GNUNET_assert (NULL == h->op_head);
1117  GNUNET_free (h);
1118 }
1119 
1120 
1133 struct GNUNET_RECLAIM_Operation *
1135  struct GNUNET_RECLAIM_Handle *h,
1136  const struct GNUNET_IDENTITY_PrivateKey *pkey,
1137  const struct GNUNET_RECLAIM_Attribute *attr,
1138  const struct GNUNET_TIME_Relative *exp_interval,
1140  void *cont_cls)
1141 {
1142  struct GNUNET_RECLAIM_Operation *op;
1143  struct AttributeStoreMessage *sam;
1144  size_t attr_len;
1145 
1146  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1147  op->h = h;
1148  op->as_cb = cont;
1149  op->cls = cont_cls;
1150  op->r_id = h->r_id_gen++;
1153  op->env = GNUNET_MQ_msg_extra (sam,
1154  attr_len,
1156  sam->identity = *pkey;
1157  sam->id = htonl (op->r_id);
1158  sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
1159 
1160  GNUNET_RECLAIM_attribute_serialize (attr, (char *) &sam[1]);
1161 
1162  sam->attr_len = htons (attr_len);
1163  if (NULL != h->mq)
1164  GNUNET_MQ_send_copy (h->mq, op->env);
1165  return op;
1166 }
1167 
1168 
1180 struct GNUNET_RECLAIM_Operation *
1182  struct GNUNET_RECLAIM_Handle *h,
1183  const struct GNUNET_IDENTITY_PrivateKey *pkey,
1184  const struct GNUNET_RECLAIM_Attribute *attr,
1186  void *cont_cls)
1187 {
1188  struct GNUNET_RECLAIM_Operation *op;
1189  struct AttributeDeleteMessage *dam;
1190  size_t attr_len;
1191 
1192  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1193  op->h = h;
1194  op->as_cb = cont;
1195  op->cls = cont_cls;
1196  op->r_id = h->r_id_gen++;
1199  op->env = GNUNET_MQ_msg_extra (dam,
1200  attr_len,
1202  dam->identity = *pkey;
1203  dam->id = htonl (op->r_id);
1204  GNUNET_RECLAIM_attribute_serialize (attr, (char *) &dam[1]);
1205 
1206  dam->attr_len = htons (attr_len);
1207  if (NULL != h->mq)
1208  GNUNET_MQ_send_copy (h->mq, op->env);
1209  return op;
1210 }
1211 
1212 
1225 struct GNUNET_RECLAIM_Operation *
1227  struct GNUNET_RECLAIM_Handle *h,
1228  const struct GNUNET_IDENTITY_PrivateKey *pkey,
1229  const struct GNUNET_RECLAIM_Credential *attr,
1230  const struct GNUNET_TIME_Relative *exp_interval,
1232  void *cont_cls)
1233 {
1234  struct GNUNET_RECLAIM_Operation *op;
1235  struct AttributeStoreMessage *sam;
1236  size_t attr_len;
1237 
1238  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1239  op->h = h;
1240  op->as_cb = cont;
1241  op->cls = cont_cls;
1242  op->r_id = h->r_id_gen++;
1245  op->env = GNUNET_MQ_msg_extra (sam,
1246  attr_len,
1248  sam->identity = *pkey;
1249  sam->id = htonl (op->r_id);
1250  sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
1251 
1252  GNUNET_RECLAIM_credential_serialize (attr, (char *) &sam[1]);
1253 
1254  sam->attr_len = htons (attr_len);
1255  if (NULL != h->mq)
1256  GNUNET_MQ_send_copy (h->mq, op->env);
1257  return op;
1258 }
1259 
1260 
1272 struct GNUNET_RECLAIM_Operation *
1274  struct GNUNET_RECLAIM_Handle *h,
1275  const struct GNUNET_IDENTITY_PrivateKey *pkey,
1276  const struct GNUNET_RECLAIM_Credential *attr,
1278  void *cont_cls)
1279 {
1280  struct GNUNET_RECLAIM_Operation *op;
1281  struct AttributeDeleteMessage *dam;
1282  size_t attr_len;
1283 
1284  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1285  op->h = h;
1286  op->as_cb = cont;
1287  op->cls = cont_cls;
1288  op->r_id = h->r_id_gen++;
1291  op->env = GNUNET_MQ_msg_extra (dam,
1292  attr_len,
1294  dam->identity = *pkey;
1295  dam->id = htonl (op->r_id);
1296  GNUNET_RECLAIM_credential_serialize (attr, (char *) &dam[1]);
1297 
1298  dam->attr_len = htons (attr_len);
1299  if (NULL != h->mq)
1300  GNUNET_MQ_send_copy (h->mq, op->env);
1301  return op;
1302 }
1303 
1304 
1331  struct GNUNET_RECLAIM_Handle *h,
1332  const struct GNUNET_IDENTITY_PrivateKey *identity,
1334  void *error_cb_cls,
1336  void *proc_cls,
1338  void *finish_cb_cls)
1339 {
1341  struct GNUNET_MQ_Envelope *env;
1343  uint32_t rid;
1344 
1345  rid = h->r_id_gen++;
1347  it->h = h;
1348  it->error_cb = error_cb;
1349  it->error_cb_cls = error_cb_cls;
1350  it->finish_cb = finish_cb;
1351  it->finish_cb_cls = finish_cb_cls;
1352  it->proc = proc;
1353  it->proc_cls = proc_cls;
1354  it->r_id = rid;
1355  it->identity = *identity;
1357  env =
1359  msg->id = htonl (rid);
1360  msg->identity = *identity;
1361  if (NULL == h->mq)
1362  it->env = env;
1363  else
1364  GNUNET_MQ_send (h->mq, env);
1365  return it;
1366 }
1367 
1368 
1375 void
1377 {
1378  struct GNUNET_RECLAIM_Handle *h = it->h;
1380  struct GNUNET_MQ_Envelope *env;
1381 
1382  env =
1384  msg->id = htonl (it->r_id);
1385  GNUNET_MQ_send (h->mq, env);
1386 }
1387 
1388 
1396 void
1398 {
1399  struct GNUNET_RECLAIM_Handle *h = it->h;
1400  struct GNUNET_MQ_Envelope *env;
1402 
1403  if (NULL != h->mq)
1404  {
1405  env =
1407  msg->id = htonl (it->r_id);
1408  GNUNET_MQ_send (h->mq, env);
1409  }
1410  free_it (it);
1411 }
1412 
1413 
1440  struct GNUNET_RECLAIM_Handle *h,
1441  const struct GNUNET_IDENTITY_PrivateKey *identity,
1443  void *error_cb_cls,
1445  void *proc_cls,
1447  void *finish_cb_cls)
1448 {
1450  struct GNUNET_MQ_Envelope *env;
1452  uint32_t rid;
1453 
1454  rid = h->r_id_gen++;
1456  ait->h = h;
1457  ait->error_cb = error_cb;
1458  ait->error_cb_cls = error_cb_cls;
1459  ait->finish_cb = finish_cb;
1460  ait->finish_cb_cls = finish_cb_cls;
1461  ait->proc = proc;
1462  ait->proc_cls = proc_cls;
1463  ait->r_id = rid;
1464  ait->identity = *identity;
1466  env =
1467  GNUNET_MQ_msg (msg,
1469  msg->id = htonl (rid);
1470  msg->identity = *identity;
1471  if (NULL == h->mq)
1472  ait->env = env;
1473  else
1474  GNUNET_MQ_send (h->mq, env);
1475  return ait;
1476 }
1477 
1478 
1485 void
1488 {
1489  struct GNUNET_RECLAIM_Handle *h = ait->h;
1491  struct GNUNET_MQ_Envelope *env;
1492 
1493  env =
1495  msg->id = htonl (ait->r_id);
1496  GNUNET_MQ_send (h->mq, env);
1497 }
1498 
1499 
1507 void
1510 {
1511  struct GNUNET_RECLAIM_Handle *h = ait->h;
1512  struct GNUNET_MQ_Envelope *env;
1514 
1515  if (NULL != h->mq)
1516  {
1517  env =
1518  GNUNET_MQ_msg (msg,
1520  msg->id = htonl (ait->r_id);
1521  GNUNET_MQ_send (h->mq, env);
1522  }
1523  free_ait (ait);
1524 }
1525 
1526 
1540 struct GNUNET_RECLAIM_Operation *
1542  struct GNUNET_RECLAIM_Handle *h,
1543  const struct GNUNET_IDENTITY_PrivateKey *iss,
1544  const struct GNUNET_IDENTITY_PublicKey *rp,
1545  const struct GNUNET_RECLAIM_AttributeList *attrs,
1547  void *cb_cls)
1548 {
1549  struct GNUNET_RECLAIM_Operation *op;
1550  struct IssueTicketMessage *tim;
1551  size_t attr_len;
1552 
1553  fprintf (stderr, "Issuing ticket\n");
1554  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1555  op->h = h;
1556  op->ti_cb = cb;
1557  op->cls = cb_cls;
1558  op->r_id = h->r_id_gen++;
1561  op->env = GNUNET_MQ_msg_extra (tim,
1562  attr_len,
1564  tim->identity = *iss;
1565  tim->rp = *rp;
1566  tim->id = htonl (op->r_id);
1567 
1568  GNUNET_RECLAIM_attribute_list_serialize (attrs, (char *) &tim[1]);
1569 
1570  tim->attr_len = htons (attr_len);
1571  if (NULL != h->mq)
1572  GNUNET_MQ_send_copy (h->mq, op->env);
1573  return op;
1574 }
1575 
1576 
1589 struct GNUNET_RECLAIM_Operation *
1591  struct GNUNET_RECLAIM_Handle *h,
1592  const struct GNUNET_IDENTITY_PrivateKey *identity,
1593  const struct GNUNET_RECLAIM_Ticket *ticket,
1595  void *cb_cls)
1596 {
1597  struct GNUNET_RECLAIM_Operation *op;
1598  struct ConsumeTicketMessage *ctm;
1599 
1600  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1601  op->h = h;
1602  op->atr_cb = cb;
1603  op->cls = cb_cls;
1604  op->r_id = h->r_id_gen++;
1607  ctm->identity = *identity;
1608  ctm->id = htonl (op->r_id);
1609  ctm->ticket = *ticket;
1610  if (NULL != h->mq)
1611  GNUNET_MQ_send_copy (h->mq, op->env);
1612  else
1613  reconnect (h);
1614  return op;
1615 }
1616 
1617 
1637  struct GNUNET_RECLAIM_Handle *h,
1638  const struct GNUNET_IDENTITY_PrivateKey *identity,
1640  void *error_cb_cls,
1642  void *proc_cls,
1644  void *finish_cb_cls)
1645 {
1646  struct GNUNET_RECLAIM_TicketIterator *it;
1647  struct GNUNET_MQ_Envelope *env;
1649  uint32_t rid;
1650 
1651  rid = h->r_id_gen++;
1653  it->h = h;
1654  it->error_cb = error_cb;
1655  it->error_cb_cls = error_cb_cls;
1656  it->finish_cb = finish_cb;
1657  it->finish_cb_cls = finish_cb_cls;
1658  it->tr_cb = proc;
1659  it->cls = proc_cls;
1660  it->r_id = rid;
1663  msg->id = htonl (rid);
1664  msg->identity = *identity;
1665  if (NULL == h->mq)
1666  it->env = env;
1667  else
1668  GNUNET_MQ_send (h->mq, env);
1669  return it;
1670 }
1671 
1672 
1679 void
1681 {
1682  struct GNUNET_RECLAIM_Handle *h = it->h;
1684  struct GNUNET_MQ_Envelope *env;
1685 
1687  msg->id = htonl (it->r_id);
1688  GNUNET_MQ_send (h->mq, env);
1689 }
1690 
1691 
1699 void
1701 {
1702  struct GNUNET_RECLAIM_Handle *h = it->h;
1703  struct GNUNET_MQ_Envelope *env;
1705 
1706  if (NULL != h->mq)
1707  {
1708  env =
1710  msg->id = htonl (it->r_id);
1711  GNUNET_MQ_send (h->mq, env);
1712  }
1713  GNUNET_free (it);
1714 }
1715 
1716 
1730 struct GNUNET_RECLAIM_Operation *
1732  struct GNUNET_RECLAIM_Handle *h,
1733  const struct GNUNET_IDENTITY_PrivateKey *identity,
1734  const struct GNUNET_RECLAIM_Ticket *ticket,
1736  void *cb_cls)
1737 {
1738  struct GNUNET_RECLAIM_Operation *op;
1739  struct RevokeTicketMessage *msg;
1740  uint32_t rid;
1741 
1742  rid = h->r_id_gen++;
1743  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1744  op->h = h;
1745  op->rvk_cb = cb;
1746  op->cls = cb_cls;
1747  op->r_id = rid;
1750  msg->id = htonl (rid);
1751  msg->identity = *identity;
1752  msg->ticket = *ticket;
1753  if (NULL != h->mq)
1754  {
1755  GNUNET_MQ_send (h->mq, op->env);
1756  op->env = NULL;
1757  }
1758  return op;
1759 }
1760 
1761 
1762 /* 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:678
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:1486
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
The authorization ticket.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:288
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize an credential.
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_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.
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:1508
GNUNET_RECLAIM_ContinuationWithStatus as_cb
Continuation to invoke after attribute store call.
Definition: reclaim_api.c:67
Ticket consume message.
Definition: reclaim.h:481
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
struct GNUNET_IDENTITY_PrivateKey identity
Identity.
Definition: reclaim.h:496
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_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
struct GNUNET_RECLAIM_CredentialIterator * GNUNET_RECLAIM_get_credentials_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *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:1439
#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_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:1103
struct GNUNET_RECLAIM_AttributeIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:192
struct GNUNET_IDENTITY_PrivateKey identity
Private key of the zone.
Definition: reclaim_api.c:238
void GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op)
Cancel an operation.
Definition: reclaim_api.c:1088
A private key for an identity as per LSD0001.
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_IDENTITY_PrivateKey identity
Identity.
Definition: reclaim.h:382
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:1680
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:779
#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:1700
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_consume(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls)
Consumes an issued ticket.
Definition: reclaim_api.c:1590
#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
void(* GNUNET_RECLAIM_AttributeResult)(void *cls, const struct GNUNET_IDENTITY_PublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr)
Callback used to notify the client of attribute results.
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:1376
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
void(* GNUNET_RECLAIM_CredentialResult)(void *cls, const struct GNUNET_IDENTITY_PublicKey *identity, const struct GNUNET_RECLAIM_Credential *credential)
Callback used to notify the client of credential results.
struct GNUNET_RECLAIM_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
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_IDENTITY_PrivateKey identity
Private key of the zone.
Definition: reclaim_api.c:305
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
struct GNUNET_IDENTITY_PublicKey identity
The public key of the identity.
Definition: reclaim.h:189
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:178
static void reconnect(struct GNUNET_RECLAIM_Handle *h)
Try again to connect to the service.
Definition: reclaim_api.c:1014
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
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
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
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_AttributeIterator * GNUNET_RECLAIM_get_attributes_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *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:1330
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
struct GNUNET_IDENTITY_PrivateKey identity
Identity.
Definition: reclaim.h:215
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_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:702
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:881
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_IDENTITY_PrivateKey identity
Identity.
Definition: reclaim.h:415
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:905
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.
struct GNUNET_IDENTITY_PrivateKey identity
Identity.
Definition: reclaim.h:326
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...
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
void(* GNUNET_RECLAIM_AttributeTicketResult)(void *cls, const struct GNUNET_IDENTITY_PublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr, const struct GNUNET_RECLAIM_Presentation *presentation)
Callback used to notify the client of attribute results.
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.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_credential_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *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:1226
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const struct GNUNET_RECLAIM_Attribute *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an attribute.
Definition: reclaim_api.c:1181
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:978
An identity key as per LSD0001.
#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.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_revoke(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls)
Revoked an issued ticket.
Definition: reclaim_api.c:1731
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
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_credential_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const struct GNUNET_RECLAIM_Credential *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an credential.
Definition: reclaim_api.c:1273
void GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1397
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:321
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
struct GNUNET_IDENTITY_PrivateKey identity
Identity.
Definition: reclaim.h:94
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
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
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
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *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:1134
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
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:1063
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_issue(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *iss, const struct GNUNET_IDENTITY_PublicKey *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:1541
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:129
struct GNUNET_IDENTITY_PrivateKey identity
Identity.
Definition: reclaim.h:254
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:803
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.
struct GNUNET_RECLAIM_TicketIterator * GNUNET_RECLAIM_ticket_iteration_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *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:1636
Ticket revoke message.
Definition: reclaim.h:400
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_IDENTITY_PublicKey identity
The public key of the identity.
Definition: reclaim.h:154
#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
struct GNUNET_IDENTITY_PublicKey rp
Requesting party.
Definition: reclaim.h:387
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
struct GNUNET_IDENTITY_PrivateKey identity
Identity.
Definition: reclaim.h:65