GNUnet  0.10.x
reclaim_api.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2016 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "gnunet_constants.h"
29 #include "gnunet_mq_lib.h"
30 #include "gnunet_protocols.h"
32 #include "gnunet_reclaim_service.h"
33 #include "reclaim.h"
34 
35 #define LOG(kind, ...) GNUNET_log_from (kind, "reclaim-api", __VA_ARGS__)
36 
37 
42 {
43 
48 
53 
58 
63  const struct GNUNET_MessageHeader *msg;
64 
69 
74 
79 
84 
89 
93  uint32_t r_id;
94 
98  void *cls;
99 };
100 
101 
106 {
107 
112 
117 
122 
127 
132 
137 
141  void *cls;
142 
147 
152 
158 
162  uint32_t r_id;
163 };
164 
165 
170 {
171 
176 
181 
186 
191 
196 
201 
205  void *proc_cls;
206 
211 
216 
222 
227 
231  uint32_t r_id;
232 };
233 
234 
239 {
244 
248  struct GNUNET_CLIENT_Connection *client;
249 
253  void *cb_cls;
254 
259 
264 
269 
274 
279 
284 
288  struct GNUNET_CLIENT_TransmitHandle *th;
289 
294 
298  struct GNUNET_TIME_Relative reconnect_backoff;
299 
304 
308  uint32_t r_id_gen;
309 
314 };
315 
316 
322 static void
324 
325 
331 static void
333 {
334  struct GNUNET_RECLAIM_Handle *handle = cls;
335 
336  handle->reconnect_task = NULL;
337  reconnect (handle);
338 }
339 
340 
346 static void
348 {
349  GNUNET_MQ_destroy (handle->mq);
350  handle->mq = NULL;
351  handle->reconnect_backoff =
353  handle->reconnect_task =
356  handle);
357 }
358 
359 
365 static void
367 {
368  struct GNUNET_RECLAIM_Handle *h = it->h;
369 
371  if (NULL != it->env)
372  GNUNET_MQ_discard (it->env);
373  GNUNET_free (it);
374 }
375 
381 static void
383 {
384  if (NULL == op)
385  return;
386  if (NULL != op->env)
387  GNUNET_MQ_discard (op->env);
388  GNUNET_free (op);
389 }
390 
391 
400 static void
402 {
403  struct GNUNET_RECLAIM_Handle *handle = cls;
404  force_reconnect (handle);
405 }
406 
407 
415 static void
417 {
418  struct GNUNET_RECLAIM_Handle *h = cls;
420  uint32_t r_id = ntohl (msg->id);
421  int res;
422  const char *emsg;
423 
424  for (op = h->op_head; NULL != op; op = op->next)
425  if (op->r_id == r_id)
426  break;
427  if (NULL == op)
428  return;
429 
430  res = ntohl (msg->op_result);
432  "Received SUCCESS_RESPONSE with result %d\n",
433  res);
434 
435  /* TODO: add actual error message to response... */
436  if (GNUNET_SYSERR == res)
437  emsg = _ ("failed to store record\n");
438  else
439  emsg = NULL;
440  if (NULL != op->as_cb)
441  op->as_cb (op->cls, res, emsg);
443  free_op (op);
444 }
445 
446 
455 static int
457  const struct ConsumeTicketResultMessage *msg)
458 {
459  size_t msg_len;
460  size_t attrs_len;
461 
462  msg_len = ntohs (msg->header.size);
463  attrs_len = ntohs (msg->attrs_len);
464  if (msg_len != sizeof (struct ConsumeTicketResultMessage) + attrs_len)
465  {
466  GNUNET_break (0);
467  return GNUNET_SYSERR;
468  }
469  return GNUNET_OK;
470 }
471 
472 
480 static void
482  const struct ConsumeTicketResultMessage *msg)
483 {
484  struct GNUNET_RECLAIM_Handle *h = cls;
486  size_t attrs_len;
487  uint32_t r_id = ntohl (msg->id);
488 
489  attrs_len = ntohs (msg->attrs_len);
490  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
491 
492 
493  for (op = h->op_head; NULL != op; op = op->next)
494  if (op->r_id == r_id)
495  break;
496  if (NULL == op)
497  return;
498 
499  {
502  attrs =
503  GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *) &msg[1], attrs_len);
504  if (NULL != op->ar_cb)
505  {
506  if (NULL == attrs)
507  {
508  op->ar_cb (op->cls, &msg->identity, NULL);
509  }
510  else
511  {
512  for (le = attrs->list_head; NULL != le; le = le->next)
513  op->ar_cb (op->cls, &msg->identity, le->claim);
515  attrs = NULL;
516  }
517  op->ar_cb (op->cls, NULL, NULL);
518  }
520  free_op (op);
521  GNUNET_free_non_null (attrs);
522  return;
523  }
524  GNUNET_assert (0);
525 }
526 
527 
536 static int
538 {
539  size_t msg_len;
540  size_t attr_len;
541 
542  msg_len = ntohs (msg->header.size);
543  attr_len = ntohs (msg->attr_len);
544  if (msg_len != sizeof (struct AttributeResultMessage) + attr_len)
545  {
546  GNUNET_break (0);
547  return GNUNET_SYSERR;
548  }
549  return GNUNET_OK;
550 }
551 
552 
560 static void
562 {
563  static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
564  struct GNUNET_RECLAIM_Handle *h = cls;
567  size_t attr_len;
568  uint32_t r_id = ntohl (msg->id);
569 
570  attr_len = ntohs (msg->attr_len);
571  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
572 
573 
574  for (it = h->it_head; NULL != it; it = it->next)
575  if (it->r_id == r_id)
576  break;
577  for (op = h->op_head; NULL != op; op = op->next)
578  if (op->r_id == r_id)
579  break;
580  if ((NULL == it) && (NULL == op))
581  return;
582 
583  if ((0 ==
584  (memcmp (&msg->identity, &identity_dummy, sizeof (identity_dummy)))))
585  {
586  if ((NULL == it) && (NULL == op))
587  {
588  GNUNET_break (0);
589  force_reconnect (h);
590  return;
591  }
592  if (NULL != it)
593  {
594  if (NULL != it->finish_cb)
595  it->finish_cb (it->finish_cb_cls);
596  free_it (it);
597  }
598  if (NULL != op)
599  {
600  if (NULL != op->ar_cb)
601  op->ar_cb (op->cls, NULL, NULL);
603  free_op (op);
604  }
605  return;
606  }
607 
608  {
609  struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
610  attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &msg[1], attr_len);
611  if (NULL != it)
612  {
613  if (NULL != it->proc)
614  it->proc (it->proc_cls, &msg->identity, attr);
615  }
616  else if (NULL != op)
617  {
618  if (NULL != op->ar_cb)
619  op->ar_cb (op->cls, &msg->identity, attr);
620  }
621  GNUNET_free (attr);
622  return;
623  }
624  GNUNET_assert (0);
625 }
626 
627 
635 static void
637 {
638  struct GNUNET_RECLAIM_Handle *handle = cls;
641  uint32_t r_id = ntohl (msg->id);
642  static const struct GNUNET_RECLAIM_Ticket ticket;
643  for (op = handle->op_head; NULL != op; op = op->next)
644  if (op->r_id == r_id)
645  break;
646  for (it = handle->ticket_it_head; NULL != it; it = it->next)
647  if (it->r_id == r_id)
648  break;
649  if ((NULL == op) && (NULL == it))
650  return;
651  if (NULL != op)
652  {
653  GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
654  if (0 ==
655  memcmp (&msg->ticket, &ticket, sizeof (struct GNUNET_RECLAIM_Ticket)))
656  {
657  if (NULL != op->tr_cb)
658  op->tr_cb (op->cls, NULL);
659  }
660  else
661  {
662  if (NULL != op->tr_cb)
663  op->tr_cb (op->cls, &msg->ticket);
664  }
665  free_op (op);
666  return;
667  }
668  else if (NULL != it)
669  {
670  if (0 ==
671  memcmp (&msg->ticket, &ticket, sizeof (struct GNUNET_RECLAIM_Ticket)))
672  {
674  handle->ticket_it_tail,
675  it);
676  it->finish_cb (it->finish_cb_cls);
677  GNUNET_free (it);
678  }
679  else
680  {
681  if (NULL != it->tr_cb)
682  it->tr_cb (it->cls, &msg->ticket);
683  }
684  return;
685  }
686  GNUNET_break (0);
687 }
688 
689 
697 static void
699  const struct RevokeTicketResultMessage *msg)
700 {
701  struct GNUNET_RECLAIM_Handle *h = cls;
703  uint32_t r_id = ntohl (msg->id);
704  int32_t success;
705 
706  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n");
707 
708 
709  for (op = h->op_head; NULL != op; op = op->next)
710  if (op->r_id == r_id)
711  break;
712  if (NULL == op)
713  return;
714  success = ntohl (msg->success);
715  {
716  if (NULL != op->rvk_cb)
717  {
718  op->rvk_cb (op->cls, success, NULL);
719  }
721  free_op (op);
722  return;
723  }
724  GNUNET_assert (0);
725 }
726 
727 
733 static void
735 {
736  struct GNUNET_MQ_MessageHandler handlers[] =
737  {GNUNET_MQ_hd_fixed_size (success_response,
739  struct SuccessResultMessage,
740  h),
741  GNUNET_MQ_hd_var_size (attribute_result,
743  struct AttributeResultMessage,
744  h),
745  GNUNET_MQ_hd_fixed_size (ticket_result,
747  struct TicketResultMessage,
748  h),
749  GNUNET_MQ_hd_var_size (consume_ticket_result,
752  h),
753  GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
756  h),
759 
760  GNUNET_assert (NULL == h->mq);
761  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
762 
763  h->mq =
764  GNUNET_CLIENT_connect (h->cfg, "reclaim", handlers, &mq_error_handler, h);
765  if (NULL == h->mq)
766  return;
767  for (op = h->op_head; NULL != op; op = op->next)
768  GNUNET_MQ_send_copy (h->mq, op->env);
769 }
770 
771 
778 struct GNUNET_RECLAIM_Handle *
780 {
781  struct GNUNET_RECLAIM_Handle *h;
782 
783  h = GNUNET_new (struct GNUNET_RECLAIM_Handle);
784  h->cfg = cfg;
785  reconnect (h);
786  if (NULL == h->mq)
787  {
788  GNUNET_free (h);
789  return NULL;
790  }
791  return h;
792 }
793 
794 
803 void
805 {
806  struct GNUNET_RECLAIM_Handle *h = op->h;
807 
809  free_op (op);
810 }
811 
812 
818 void
820 {
821  GNUNET_assert (NULL != h);
822  if (NULL != h->mq)
823  {
824  GNUNET_MQ_destroy (h->mq);
825  h->mq = NULL;
826  }
827  if (NULL != h->reconnect_task)
828  {
830  h->reconnect_task = NULL;
831  }
832  GNUNET_assert (NULL == h->op_head);
833  GNUNET_free (h);
834 }
835 
850  struct GNUNET_RECLAIM_Handle *h,
851  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
852  const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
853  const struct GNUNET_TIME_Relative *exp_interval,
855  void *cont_cls)
856 {
858  struct AttributeStoreMessage *sam;
859  size_t attr_len;
860 
861  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
862  op->h = h;
863  op->as_cb = cont;
864  op->cls = cont_cls;
865  op->r_id = h->r_id_gen++;
868  op->env = GNUNET_MQ_msg_extra (sam,
869  attr_len,
871  sam->identity = *pkey;
872  sam->id = htonl (op->r_id);
873  sam->exp = GNUNET_htonll (exp_interval->rel_value_us);
874 
875  GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &sam[1]);
876 
877  sam->attr_len = htons (attr_len);
878  if (NULL != h->mq)
879  GNUNET_MQ_send_copy (h->mq, op->env);
880  return op;
881 }
882 
883 
897  struct GNUNET_RECLAIM_Handle *h,
898  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
899  const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
901  void *cont_cls)
902 {
904  struct AttributeDeleteMessage *dam;
905  size_t attr_len;
906 
907  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
908  op->h = h;
909  op->as_cb = cont;
910  op->cls = cont_cls;
911  op->r_id = h->r_id_gen++;
914  op->env = GNUNET_MQ_msg_extra (dam,
915  attr_len,
917  dam->identity = *pkey;
918  dam->id = htonl (op->r_id);
919  GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *) &dam[1]);
920 
921  dam->attr_len = htons (attr_len);
922  if (NULL != h->mq)
923  GNUNET_MQ_send_copy (h->mq, op->env);
924  return op;
925 }
926 
927 
954  struct GNUNET_RECLAIM_Handle *h,
957  void *error_cb_cls,
959  void *proc_cls,
961  void *finish_cb_cls)
962 {
964  struct GNUNET_MQ_Envelope *env;
966  uint32_t rid;
967 
968  rid = h->r_id_gen++;
970  it->h = h;
971  it->error_cb = error_cb;
972  it->error_cb_cls = error_cb_cls;
973  it->finish_cb = finish_cb;
974  it->finish_cb_cls = finish_cb_cls;
975  it->proc = proc;
976  it->proc_cls = proc_cls;
977  it->r_id = rid;
978  it->identity = *identity;
980  env =
982  msg->id = htonl (rid);
983  msg->identity = *identity;
984  if (NULL == h->mq)
985  it->env = env;
986  else
987  GNUNET_MQ_send (h->mq, env);
988  return it;
989 }
990 
991 
998 void
1000 {
1001  struct GNUNET_RECLAIM_Handle *h = it->h;
1003  struct GNUNET_MQ_Envelope *env;
1004 
1005  env =
1007  msg->id = htonl (it->r_id);
1008  GNUNET_MQ_send (h->mq, env);
1009 }
1010 
1011 
1019 void
1021 {
1022  struct GNUNET_RECLAIM_Handle *h = it->h;
1023  struct GNUNET_MQ_Envelope *env;
1025 
1026  if (NULL != h->mq)
1027  {
1028  env =
1030  msg->id = htonl (it->r_id);
1031  GNUNET_MQ_send (h->mq, env);
1032  }
1033  free_it (it);
1034 }
1035 
1036 
1050 struct GNUNET_RECLAIM_Operation *
1052  struct GNUNET_RECLAIM_Handle *h,
1053  const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
1054  const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
1055  const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
1057  void *cb_cls)
1058 {
1059  struct GNUNET_RECLAIM_Operation *op;
1060  struct IssueTicketMessage *tim;
1061  size_t attr_len;
1062  fprintf (stderr, "Issuing ticket\n");
1063  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1064  op->h = h;
1065  op->tr_cb = cb;
1066  op->cls = cb_cls;
1067  op->r_id = h->r_id_gen++;
1070  op->env = GNUNET_MQ_msg_extra (tim,
1071  attr_len,
1073  tim->identity = *iss;
1074  tim->rp = *rp;
1075  tim->id = htonl (op->r_id);
1076 
1077  GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, (char *) &tim[1]);
1078 
1079  tim->attr_len = htons (attr_len);
1080  if (NULL != h->mq)
1081  GNUNET_MQ_send_copy (h->mq, op->env);
1082  return op;
1083 }
1084 
1085 
1098 struct GNUNET_RECLAIM_Operation *
1100  struct GNUNET_RECLAIM_Handle *h,
1102  const struct GNUNET_RECLAIM_Ticket *ticket,
1104  void *cb_cls)
1105 {
1106  struct GNUNET_RECLAIM_Operation *op;
1107  struct ConsumeTicketMessage *ctm;
1108 
1109  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1110  op->h = h;
1111  op->ar_cb = cb;
1112  op->cls = cb_cls;
1113  op->r_id = h->r_id_gen++;
1116  ctm->identity = *identity;
1117  ctm->id = htonl (op->r_id);
1118  ctm->ticket = *ticket;
1119  if (NULL != h->mq)
1120  GNUNET_MQ_send_copy (h->mq, op->env);
1121  return op;
1122 }
1123 
1124 
1144  struct GNUNET_RECLAIM_Handle *h,
1147  void *error_cb_cls,
1149  void *proc_cls,
1151  void *finish_cb_cls)
1152 {
1153  struct GNUNET_RECLAIM_TicketIterator *it;
1154  struct GNUNET_MQ_Envelope *env;
1156  uint32_t rid;
1157 
1158  rid = h->r_id_gen++;
1160  it->h = h;
1161  it->error_cb = error_cb;
1162  it->error_cb_cls = error_cb_cls;
1163  it->finish_cb = finish_cb;
1164  it->finish_cb_cls = finish_cb_cls;
1165  it->tr_cb = proc;
1166  it->cls = proc_cls;
1167  it->r_id = rid;
1170  msg->id = htonl (rid);
1171  msg->identity = *identity;
1172  if (NULL == h->mq)
1173  it->env = env;
1174  else
1175  GNUNET_MQ_send (h->mq, env);
1176  return it;
1177 }
1178 
1179 
1186 void
1188 {
1189  struct GNUNET_RECLAIM_Handle *h = it->h;
1191  struct GNUNET_MQ_Envelope *env;
1192 
1194  msg->id = htonl (it->r_id);
1195  GNUNET_MQ_send (h->mq, env);
1196 }
1197 
1198 
1206 void
1208 {
1209  struct GNUNET_RECLAIM_Handle *h = it->h;
1210  struct GNUNET_MQ_Envelope *env;
1212 
1213  if (NULL != h->mq)
1214  {
1215  env =
1217  msg->id = htonl (it->r_id);
1218  GNUNET_MQ_send (h->mq, env);
1219  }
1220  GNUNET_free (it);
1221 }
1222 
1223 
1237 struct GNUNET_RECLAIM_Operation *
1239  struct GNUNET_RECLAIM_Handle *h,
1241  const struct GNUNET_RECLAIM_Ticket *ticket,
1243  void *cb_cls)
1244 {
1245  struct GNUNET_RECLAIM_Operation *op;
1246  struct RevokeTicketMessage *msg;
1247  uint32_t rid;
1248 
1249  rid = h->r_id_gen++;
1250  op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
1251  op->h = h;
1252  op->rvk_cb = cb;
1253  op->cls = cb_cls;
1254  op->r_id = rid;
1257  msg->id = htonl (rid);
1258  msg->identity = *identity;
1259  msg->ticket = *ticket;
1260  if (NULL != h->mq)
1261  {
1262  GNUNET_MQ_send (h->mq, op->env);
1263  op->env = NULL;
1264  }
1265  return op;
1266 }
1267 
1268 
1269 /* end of reclaim_api.c */
#define LOG(kind,...)
Definition: reclaim_api.c:35
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_RECLAIM_TicketIterator * ticket_it_tail
Tail of active iterations.
Definition: reclaim_api.c:283
#define GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
static int check_attribute_result(void *cls, const struct AttributeResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT.
Definition: reclaim_api.c:537
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:367
Ticket result message.
Definition: reclaim.h:357
Handle to the service.
Definition: reclaim_api.c:238
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:319
The authorization ticket.
struct GNUNET_CRYPTO_EcdsaPublicKey rp
Requesting party.
Definition: reclaim.h:291
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:65
struct GNUNET_RECLAIM_Handle * h
Main handle.
Definition: reclaim_api.c:47
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:953
struct GNUNET_RECLAIM_Ticket ticket
The new ticket.
Definition: reclaim.h:372
struct GNUNET_RECLAIM_Operation * prev
We keep operations in a DLL.
Definition: reclaim_api.c:57
Attribute list is returned from the idp.
Definition: reclaim.h:404
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:253
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:98
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT
GNUNET_RECLAIM_ContinuationWithStatus as_cb
Continuation to invoke after attribute store call.
Definition: reclaim_api.c:68
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:230
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store an attribute.
Definition: reclaim_api.c:849
Ticket consume message.
Definition: reclaim.h:378
struct GNUNET_RECLAIM_TicketIterator * GNUNET_RECLAIM_ticket_iteration_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_TicketCallback proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Lists all tickets that have been issued to remote identites (relying parties)
Definition: reclaim_api.c:1143
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:901
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:94
struct GNUNET_SCHEDULER_Task * reconnect_task
Task doing exponential back-off trying to reconnect.
Definition: reclaim_api.c:293
Start a attribute iteration for the given identity.
Definition: reclaim.h:160
GNUNET_MQ_Error
Error codes for the queue.
int in_receive
Are we polling for incoming messages right now?
Definition: reclaim_api.c:313
Stop attribute iteration for the given operation.
Definition: reclaim.h:199
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:118
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:314
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:134
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:414
struct GNUNET_CLIENT_TransmitHandle * th
Currently pending transmission request, or NULL for none.
Definition: reclaim_api.c:288
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT
Use to delete an identity attribute.
Definition: reclaim.h:74
void GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h)
Disconnect from service.
Definition: reclaim_api.c:819
struct GNUNET_RECLAIM_AttributeIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:180
void GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op)
Cancel an operation.
Definition: reclaim_api.c:804
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:131
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
void GNUNET_RECLAIM_ticket_iteration_next(struct GNUNET_RECLAIM_TicketIterator *it)
Calls the ticket processor specified in GNUNET_RECLAIM_ticket_iteration_start for the next record...
Definition: reclaim_api.c:1187
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT
void GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1207
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:195
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:999
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:210
Use to store an identity attribute.
Definition: reclaim.h:40
static void error_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *data)
Definition: gnunet_gst.c:311
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:286
GNUNET_RECLAIM_AttributeResult proc
The continuation to call with the results.
Definition: reclaim_api.c:200
struct GNUNET_RECLAIM_Handle * h
Main handle to access the idp.
Definition: reclaim_api.c:121
struct GNUNET_RECLAIM_AttributeIterator * it_tail
Tail of active iterations.
Definition: reclaim_api.c:273
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void * proc_cls
Closure for proc.
Definition: reclaim_api.c:205
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
Ask for next result of ticket iteration for the given operation.
Definition: reclaim.h:237
static void force_reconnect(struct GNUNET_RECLAIM_Handle *handle)
Disconnect from service and then reconnect.
Definition: reclaim_api.c:347
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static void reconnect(struct GNUNET_RECLAIM_Handle *h)
Try again to connect to the service.
Definition: reclaim_api.c:734
Common type definitions for the identity provider service and API.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:247
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
void GNUNET_RECLAIM_ATTRIBUTE_list_destroy(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
Destroy claim list.
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
Definition: reclaim_api.c:303
GNUNET_RECLAIM_ContinuationWithStatus rvk_cb
Revocation result callback.
Definition: reclaim_api.c:78
#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:1246
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:263
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:1238
Handle for a attribute iterator operation.
Definition: reclaim_api.c:169
void(* GNUNET_RECLAIM_AttributeResult)(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
Callback used to notify the client of attribute results.
void(* GNUNET_RECLAIM_ContinuationWithStatus)(void *cls, int32_t success, const char *emsg)
Continuation called to notify client about result of the operation.
struct GNUNET_RECLAIM_AttributeIterator * next
Kept in a DLL.
Definition: reclaim_api.c:175
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:63
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:209
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an attribute.
Definition: reclaim_api.c:896
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:393
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:231
Stop ticket iteration for the given operation.
Definition: reclaim.h:254
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:192
struct GNUNET_RECLAIM_Ticket ticket
The ticket to revoke.
Definition: reclaim.h:329
struct GNUNET_MQ_Envelope * env
Envelope with the message for this queue entry.
Definition: reclaim_api.c:88
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:456
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_issue(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, GNUNET_RECLAIM_TicketCallback cb, void *cb_cls)
Issues a ticket to another relying party.
Definition: reclaim_api.c:1051
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:481
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:157
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:151
uint32_t r_id_gen
Request Id generator.
Definition: reclaim_api.c:308
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:162
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:175
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:52
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:561
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:170
Ticket issue message.
Definition: reclaim.h:271
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE
void * cls
Closure for tr_cb.
Definition: reclaim_api.c:141
Message handler for a specific message type.
static int res
Attribute store/delete response message.
Definition: reclaim.h:103
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:321
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
uint64_t exp
The expiration interval of the attribute.
Definition: reclaim.h:60
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:281
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
uint32_t attr_len
length of serialized attribute list
Definition: reclaim.h:296
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_RECLAIM_Ticket ticket
The ticket to consume.
Definition: reclaim.h:398
Ask for next result of attribute iteration for the given operation.
Definition: reclaim.h:182
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:84
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Private key of the zone.
Definition: reclaim_api.c:226
GNUNET_RECLAIM_TicketCallback tr_cb
Ticket result callback.
Definition: reclaim_api.c:83
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:636
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:258
#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:73
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:416
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
struct GNUNET_RECLAIM_TicketIterator * next
Kept in a DLL.
Definition: reclaim_api.c:111
#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:248
Handle to a message queue.
Definition: mq.c:85
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP
static void handle_revoke_ticket_result(void *cls, const struct RevokeTicketResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT.
Definition: reclaim_api.c:698
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
Get required size for serialization buffer.
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: reclaim_api.c:243
Ticket revoke message.
Definition: reclaim.h:335
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: reclaim_api.c:146
GNUNET_RECLAIM_TicketCallback tr_cb
The continuation to call with the results.
Definition: reclaim_api.c:136
configuration data
Definition: configuration.c:85
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:221
void GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1020
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:225
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
struct GNUNET_RECLAIM_AttributeIterator * it_head
Head of active iterations.
Definition: reclaim_api.c:268
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:345
void GNUNET_MQ_send_copy(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MQ_Envelope *ev)
Send a copy of a message with the given message queue.
Definition: mq.c:432
Attribute is returned from the idp.
Definition: reclaim.h:124
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:139
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:215
A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
struct GNUNET_TIME_Relative reconnect_backoff
Time for next connect retry.
Definition: reclaim_api.c:298
Start a ticket iteration for the given identity.
Definition: reclaim.h:215
Handle for a ticket iterator operation.
Definition: reclaim_api.c:105
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:424
Entry in list of pending tasks.
Definition: scheduler.c:134
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:409
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:149
static char * rp
Relying party.
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
Header for all communications.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_consume(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_AttributeResult cb, void *cb_cls)
Consumes an issued ticket.
Definition: reclaim_api.c:1099
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, char *result)
Serialize an attribute.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
static void free_it(struct GNUNET_RECLAIM_AttributeIterator *it)
Free it.
Definition: reclaim_api.c:366
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:264
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
struct GNUNET_RECLAIM_Handle * h
Main handle to access the service.
Definition: reclaim_api.c:185
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the reclaim service.
Definition: reclaim_api.c:779
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:129
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * next
DLL.
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:382
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
uint32_t success
Revocation result.
Definition: reclaim.h:350
struct GNUNET_RECLAIM_TicketIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:116
size_t GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size(const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
Get required size for serialization buffer.
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:126
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:50
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:388
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
size_t GNUNET_RECLAIM_ATTRIBUTE_list_serialize(const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, char *result)
Serialize an attribute list.
struct GNUNET_RECLAIM_TicketIterator * ticket_it_head
Head of active iterations.
Definition: reclaim_api.c:278
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * GNUNET_RECLAIM_ATTRIBUTE_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
static void reconnect_task(void *cls)
Reconnect.
Definition: reclaim_api.c:332
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:190
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:113
#define GNUNET_free(ptr)
Wrapper around free.
Ticket revoke message.
Definition: reclaim.h:304
Time for relative time used by GNUnet, in microseconds.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
Definition: reclaim_api.c:401
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET
uint32_t r_id
request id
Definition: reclaim_api.c:93
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965