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 
46 
51 
56 
61  const struct GNUNET_MessageHeader *msg;
62 
67 
72 
77 
82 
87 
91  uint32_t r_id;
92 
96  void *cls;
97 };
98 
99 
108 
113 
118 
123 
128 
133 
137  void *cls;
138 
143 
148 
154 
158  uint32_t r_id;
159 };
160 
161 
170 
175 
180 
185 
190 
195 
199  void *proc_cls;
200 
205 
210 
216 
221 
225  uint32_t r_id;
226 };
227 
228 
237 
241  struct GNUNET_CLIENT_Connection *client;
242 
246  void *cb_cls;
247 
252 
257 
262 
267 
272 
277 
281  struct GNUNET_CLIENT_TransmitHandle *th;
282 
287 
291  struct GNUNET_TIME_Relative reconnect_backoff;
292 
297 
301  uint32_t r_id_gen;
302 
307 };
308 
309 
315 static void
317 
318 
324 static void
326 {
327  struct GNUNET_RECLAIM_Handle *handle = cls;
328 
329  handle->reconnect_task = NULL;
330  reconnect(handle);
331 }
332 
333 
339 static void
341 {
342  GNUNET_MQ_destroy(handle->mq);
343  handle->mq = NULL;
344  handle->reconnect_backoff =
346  handle->reconnect_task =
349  handle);
350 }
351 
352 
358 static void
360 {
361  struct GNUNET_RECLAIM_Handle *h = it->h;
362 
364  if (NULL != it->env)
365  GNUNET_MQ_discard(it->env);
366  GNUNET_free(it);
367 }
368 
374 static void
376 {
377  if (NULL == op)
378  return;
379  if (NULL != op->env)
380  GNUNET_MQ_discard(op->env);
381  GNUNET_free(op);
382 }
383 
384 
393 static void
395 {
396  struct GNUNET_RECLAIM_Handle *handle = cls;
397 
398  force_reconnect(handle);
399 }
400 
401 
409 static void
411 {
412  struct GNUNET_RECLAIM_Handle *h = cls;
414  uint32_t r_id = ntohl(msg->id);
415  int res;
416  const char *emsg;
417 
418  for (op = h->op_head; NULL != op; op = op->next)
419  if (op->r_id == r_id)
420  break;
421  if (NULL == op)
422  return;
423 
424  res = ntohl(msg->op_result);
426  "Received SUCCESS_RESPONSE with result %d\n",
427  res);
428 
429  /* TODO: add actual error message to response... */
430  if (GNUNET_SYSERR == res)
431  emsg = _("failed to store record\n");
432  else
433  emsg = NULL;
434  if (NULL != op->as_cb)
435  op->as_cb(op->cls, res, emsg);
437  free_op(op);
438 }
439 
440 
449 static int
451  const struct ConsumeTicketResultMessage *msg)
452 {
453  size_t msg_len;
454  size_t attrs_len;
455 
456  msg_len = ntohs(msg->header.size);
457  attrs_len = ntohs(msg->attrs_len);
458  if (msg_len != sizeof(struct ConsumeTicketResultMessage) + attrs_len)
459  {
460  GNUNET_break(0);
461  return GNUNET_SYSERR;
462  }
463  return GNUNET_OK;
464 }
465 
466 
474 static void
476  const struct ConsumeTicketResultMessage *msg)
477 {
478  struct GNUNET_RECLAIM_Handle *h = cls;
480  size_t attrs_len;
481  uint32_t r_id = ntohl(msg->id);
482 
483  attrs_len = ntohs(msg->attrs_len);
484  LOG(GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
485 
486 
487  for (op = h->op_head; NULL != op; op = op->next)
488  if (op->r_id == r_id)
489  break;
490  if (NULL == op)
491  return;
492 
493  {
496  attrs =
497  GNUNET_RECLAIM_ATTRIBUTE_list_deserialize((char *)&msg[1], attrs_len);
498  if (NULL != op->ar_cb)
499  {
500  if (NULL == attrs)
501  {
502  op->ar_cb(op->cls, &msg->identity, NULL);
503  }
504  else
505  {
506  for (le = attrs->list_head; NULL != le; le = le->next)
507  op->ar_cb(op->cls, &msg->identity, le->claim);
509  attrs = NULL;
510  }
511  op->ar_cb(op->cls, NULL, NULL);
512  }
514  free_op(op);
515  GNUNET_free_non_null(attrs);
516  return;
517  }
518  GNUNET_assert(0);
519 }
520 
521 
530 static int
532 {
533  size_t msg_len;
534  size_t attr_len;
535 
536  msg_len = ntohs(msg->header.size);
537  attr_len = ntohs(msg->attr_len);
538  if (msg_len != sizeof(struct AttributeResultMessage) + attr_len)
539  {
540  GNUNET_break(0);
541  return GNUNET_SYSERR;
542  }
543  return GNUNET_OK;
544 }
545 
546 
554 static void
556 {
557  static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
558  struct GNUNET_RECLAIM_Handle *h = cls;
561  size_t attr_len;
562  uint32_t r_id = ntohl(msg->id);
563 
564  attr_len = ntohs(msg->attr_len);
565  LOG(GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
566 
567 
568  for (it = h->it_head; NULL != it; it = it->next)
569  if (it->r_id == r_id)
570  break;
571  for (op = h->op_head; NULL != op; op = op->next)
572  if (op->r_id == r_id)
573  break;
574  if ((NULL == it) && (NULL == op))
575  return;
576 
577  if ((0 ==
578  (memcmp(&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
579  {
580  if ((NULL == it) && (NULL == op))
581  {
582  GNUNET_break(0);
583  force_reconnect(h);
584  return;
585  }
586  if (NULL != it)
587  {
588  if (NULL != it->finish_cb)
589  it->finish_cb(it->finish_cb_cls);
590  free_it(it);
591  }
592  if (NULL != op)
593  {
594  if (NULL != op->ar_cb)
595  op->ar_cb(op->cls, NULL, NULL);
597  free_op(op);
598  }
599  return;
600  }
601 
602  {
603  struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
604  attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize((char *)&msg[1], attr_len);
605  if (NULL != it)
606  {
607  if (NULL != it->proc)
608  it->proc(it->proc_cls, &msg->identity, attr);
609  }
610  else if (NULL != op)
611  {
612  if (NULL != op->ar_cb)
613  op->ar_cb(op->cls, &msg->identity, attr);
614  }
615  GNUNET_free(attr);
616  return;
617  }
618  GNUNET_assert(0);
619 }
620 
621 
629 static void
631 {
632  struct GNUNET_RECLAIM_Handle *handle = cls;
635  uint32_t r_id = ntohl(msg->id);
636  static const struct GNUNET_RECLAIM_Ticket ticket;
637 
638  for (op = handle->op_head; NULL != op; op = op->next)
639  if (op->r_id == r_id)
640  break;
641  for (it = handle->ticket_it_head; NULL != it; it = it->next)
642  if (it->r_id == r_id)
643  break;
644  if ((NULL == op) && (NULL == it))
645  return;
646  if (NULL != op)
647  {
648  GNUNET_CONTAINER_DLL_remove(handle->op_head, handle->op_tail, op);
649  if (0 ==
650  memcmp(&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
651  {
652  if (NULL != op->tr_cb)
653  op->tr_cb(op->cls, NULL);
654  }
655  else
656  {
657  if (NULL != op->tr_cb)
658  op->tr_cb(op->cls, &msg->ticket);
659  }
660  free_op(op);
661  return;
662  }
663  else if (NULL != it)
664  {
665  if (0 ==
666  memcmp(&msg->ticket, &ticket, sizeof(struct GNUNET_RECLAIM_Ticket)))
667  {
669  handle->ticket_it_tail,
670  it);
671  it->finish_cb(it->finish_cb_cls);
672  GNUNET_free(it);
673  }
674  else
675  {
676  if (NULL != it->tr_cb)
677  it->tr_cb(it->cls, &msg->ticket);
678  }
679  return;
680  }
681  GNUNET_break(0);
682 }
683 
684 
692 static void
694  const struct RevokeTicketResultMessage *msg)
695 {
696  struct GNUNET_RECLAIM_Handle *h = cls;
698  uint32_t r_id = ntohl(msg->id);
699  int32_t success;
700 
701  LOG(GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n");
702 
703 
704  for (op = h->op_head; NULL != op; op = op->next)
705  if (op->r_id == r_id)
706  break;
707  if (NULL == op)
708  return;
709  success = ntohl(msg->success);
710  {
711  if (NULL != op->rvk_cb)
712  {
713  op->rvk_cb(op->cls, success, NULL);
714  }
716  free_op(op);
717  return;
718  }
719  GNUNET_assert(0);
720 }
721 
722 
728 static void
730 {
731  struct GNUNET_MQ_MessageHandler handlers[] =
732  { GNUNET_MQ_hd_fixed_size(success_response,
734  struct SuccessResultMessage,
735  h),
736  GNUNET_MQ_hd_var_size(attribute_result,
738  struct AttributeResultMessage,
739  h),
740  GNUNET_MQ_hd_fixed_size(ticket_result,
742  struct TicketResultMessage,
743  h),
744  GNUNET_MQ_hd_var_size(consume_ticket_result,
747  h),
748  GNUNET_MQ_hd_fixed_size(revoke_ticket_result,
751  h),
754 
755  GNUNET_assert(NULL == h->mq);
756  LOG(GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
757 
758  h->mq =
759  GNUNET_CLIENT_connect(h->cfg, "reclaim", handlers, &mq_error_handler, h);
760  if (NULL == h->mq)
761  return;
762  for (op = h->op_head; NULL != op; op = op->next)
763  GNUNET_MQ_send_copy(h->mq, op->env);
764 }
765 
766 
773 struct GNUNET_RECLAIM_Handle *
775 {
776  struct GNUNET_RECLAIM_Handle *h;
777 
778  h = GNUNET_new(struct GNUNET_RECLAIM_Handle);
779  h->cfg = cfg;
780  reconnect(h);
781  if (NULL == h->mq)
782  {
783  GNUNET_free(h);
784  return NULL;
785  }
786  return h;
787 }
788 
789 
798 void
800 {
801  struct GNUNET_RECLAIM_Handle *h = op->h;
802 
804  free_op(op);
805 }
806 
807 
813 void
815 {
816  GNUNET_assert(NULL != h);
817  if (NULL != h->mq)
818  {
819  GNUNET_MQ_destroy(h->mq);
820  h->mq = NULL;
821  }
822  if (NULL != h->reconnect_task)
823  {
825  h->reconnect_task = NULL;
826  }
827  GNUNET_assert(NULL == h->op_head);
828  GNUNET_free(h);
829 }
830 
845  struct GNUNET_RECLAIM_Handle *h,
846  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
847  const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
848  const struct GNUNET_TIME_Relative *exp_interval,
850  void *cont_cls)
851 {
853  struct AttributeStoreMessage *sam;
854  size_t attr_len;
855 
857  op->h = h;
858  op->as_cb = cont;
859  op->cls = cont_cls;
860  op->r_id = h->r_id_gen++;
863  op->env = GNUNET_MQ_msg_extra(sam,
864  attr_len,
866  sam->identity = *pkey;
867  sam->id = htonl(op->r_id);
868  sam->exp = GNUNET_htonll(exp_interval->rel_value_us);
869 
870  GNUNET_RECLAIM_ATTRIBUTE_serialize(attr, (char *)&sam[1]);
871 
872  sam->attr_len = htons(attr_len);
873  if (NULL != h->mq)
874  GNUNET_MQ_send_copy(h->mq, op->env);
875  return op;
876 }
877 
878 
892  struct GNUNET_RECLAIM_Handle *h,
893  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
894  const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
896  void *cont_cls)
897 {
899  struct AttributeDeleteMessage *dam;
900  size_t attr_len;
901 
903  op->h = h;
904  op->as_cb = cont;
905  op->cls = cont_cls;
906  op->r_id = h->r_id_gen++;
909  op->env = GNUNET_MQ_msg_extra(dam,
910  attr_len,
912  dam->identity = *pkey;
913  dam->id = htonl(op->r_id);
914  GNUNET_RECLAIM_ATTRIBUTE_serialize(attr, (char *)&dam[1]);
915 
916  dam->attr_len = htons(attr_len);
917  if (NULL != h->mq)
918  GNUNET_MQ_send_copy(h->mq, op->env);
919  return op;
920 }
921 
922 
949  struct GNUNET_RECLAIM_Handle *h,
952  void *error_cb_cls,
954  void *proc_cls,
956  void *finish_cb_cls)
957 {
959  struct GNUNET_MQ_Envelope *env;
961  uint32_t rid;
962 
963  rid = h->r_id_gen++;
965  it->h = h;
966  it->error_cb = error_cb;
967  it->error_cb_cls = error_cb_cls;
968  it->finish_cb = finish_cb;
969  it->finish_cb_cls = finish_cb_cls;
970  it->proc = proc;
971  it->proc_cls = proc_cls;
972  it->r_id = rid;
973  it->identity = *identity;
975  env =
977  msg->id = htonl(rid);
978  msg->identity = *identity;
979  if (NULL == h->mq)
980  it->env = env;
981  else
982  GNUNET_MQ_send(h->mq, env);
983  return it;
984 }
985 
986 
993 void
995 {
996  struct GNUNET_RECLAIM_Handle *h = it->h;
998  struct GNUNET_MQ_Envelope *env;
999 
1000  env =
1002  msg->id = htonl(it->r_id);
1003  GNUNET_MQ_send(h->mq, env);
1004 }
1005 
1006 
1014 void
1016 {
1017  struct GNUNET_RECLAIM_Handle *h = it->h;
1018  struct GNUNET_MQ_Envelope *env;
1020 
1021  if (NULL != h->mq)
1022  {
1023  env =
1025  msg->id = htonl(it->r_id);
1026  GNUNET_MQ_send(h->mq, env);
1027  }
1028  free_it(it);
1029 }
1030 
1031 
1045 struct GNUNET_RECLAIM_Operation *
1047  struct GNUNET_RECLAIM_Handle *h,
1048  const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
1049  const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
1050  const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
1052  void *cb_cls)
1053 {
1054  struct GNUNET_RECLAIM_Operation *op;
1055  struct IssueTicketMessage *tim;
1056  size_t attr_len;
1057 
1058  fprintf(stderr, "Issuing ticket\n");
1059  op = GNUNET_new(struct GNUNET_RECLAIM_Operation);
1060  op->h = h;
1061  op->tr_cb = cb;
1062  op->cls = cb_cls;
1063  op->r_id = h->r_id_gen++;
1066  op->env = GNUNET_MQ_msg_extra(tim,
1067  attr_len,
1069  tim->identity = *iss;
1070  tim->rp = *rp;
1071  tim->id = htonl(op->r_id);
1072 
1073  GNUNET_RECLAIM_ATTRIBUTE_list_serialize(attrs, (char *)&tim[1]);
1074 
1075  tim->attr_len = htons(attr_len);
1076  if (NULL != h->mq)
1077  GNUNET_MQ_send_copy(h->mq, op->env);
1078  return op;
1079 }
1080 
1081 
1094 struct GNUNET_RECLAIM_Operation *
1096  struct GNUNET_RECLAIM_Handle *h,
1098  const struct GNUNET_RECLAIM_Ticket *ticket,
1100  void *cb_cls)
1101 {
1102  struct GNUNET_RECLAIM_Operation *op;
1103  struct ConsumeTicketMessage *ctm;
1104 
1105  op = GNUNET_new(struct GNUNET_RECLAIM_Operation);
1106  op->h = h;
1107  op->ar_cb = cb;
1108  op->cls = cb_cls;
1109  op->r_id = h->r_id_gen++;
1112  ctm->identity = *identity;
1113  ctm->id = htonl(op->r_id);
1114  ctm->ticket = *ticket;
1115  if (NULL != h->mq)
1116  GNUNET_MQ_send_copy(h->mq, op->env);
1117  return op;
1118 }
1119 
1120 
1140  struct GNUNET_RECLAIM_Handle *h,
1143  void *error_cb_cls,
1145  void *proc_cls,
1147  void *finish_cb_cls)
1148 {
1149  struct GNUNET_RECLAIM_TicketIterator *it;
1150  struct GNUNET_MQ_Envelope *env;
1152  uint32_t rid;
1153 
1154  rid = h->r_id_gen++;
1156  it->h = h;
1157  it->error_cb = error_cb;
1158  it->error_cb_cls = error_cb_cls;
1159  it->finish_cb = finish_cb;
1160  it->finish_cb_cls = finish_cb_cls;
1161  it->tr_cb = proc;
1162  it->cls = proc_cls;
1163  it->r_id = rid;
1166  msg->id = htonl(rid);
1167  msg->identity = *identity;
1168  if (NULL == h->mq)
1169  it->env = env;
1170  else
1171  GNUNET_MQ_send(h->mq, env);
1172  return it;
1173 }
1174 
1175 
1182 void
1184 {
1185  struct GNUNET_RECLAIM_Handle *h = it->h;
1187  struct GNUNET_MQ_Envelope *env;
1188 
1190  msg->id = htonl(it->r_id);
1191  GNUNET_MQ_send(h->mq, env);
1192 }
1193 
1194 
1202 void
1204 {
1205  struct GNUNET_RECLAIM_Handle *h = it->h;
1206  struct GNUNET_MQ_Envelope *env;
1208 
1209  if (NULL != h->mq)
1210  {
1211  env =
1213  msg->id = htonl(it->r_id);
1214  GNUNET_MQ_send(h->mq, env);
1215  }
1216  GNUNET_free(it);
1217 }
1218 
1219 
1233 struct GNUNET_RECLAIM_Operation *
1235  struct GNUNET_RECLAIM_Handle *h,
1237  const struct GNUNET_RECLAIM_Ticket *ticket,
1239  void *cb_cls)
1240 {
1241  struct GNUNET_RECLAIM_Operation *op;
1242  struct RevokeTicketMessage *msg;
1243  uint32_t rid;
1244 
1245  rid = h->r_id_gen++;
1246  op = GNUNET_new(struct GNUNET_RECLAIM_Operation);
1247  op->h = h;
1248  op->rvk_cb = cb;
1249  op->cls = cb_cls;
1250  op->r_id = rid;
1253  msg->id = htonl(rid);
1254  msg->identity = *identity;
1255  msg->ticket = *ticket;
1256  if (NULL != h->mq)
1257  {
1258  GNUNET_MQ_send(h->mq, op->env);
1259  op->env = NULL;
1260  }
1261  return op;
1262 }
1263 
1264 
1265 /* 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:276
#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:531
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:353
Ticket result message.
Definition: reclaim.h:344
Handle to the service.
Definition: reclaim_api.c:232
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:307
The authorization ticket.
struct GNUNET_CRYPTO_EcdsaPublicKey rp
Requesting party.
Definition: reclaim.h:280
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:64
struct GNUNET_RECLAIM_Handle * h
Main handle.
Definition: reclaim_api.c:45
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:948
struct GNUNET_RECLAIM_Ticket ticket
The new ticket.
Definition: reclaim.h:358
struct GNUNET_RECLAIM_Operation * prev
We keep operations in a DLL.
Definition: reclaim_api.c:55
Attribute list is returned from the idp.
Definition: reclaim.h:389
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:246
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:96
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT
GNUNET_RECLAIM_ContinuationWithStatus as_cb
Continuation to invoke after attribute store call.
Definition: reclaim_api.c:66
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:222
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:844
Ticket consume message.
Definition: reclaim.h:364
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:1139
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:900
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:92
struct GNUNET_SCHEDULER_Task * reconnect_task
Task doing exponential back-off trying to reconnect.
Definition: reclaim_api.c:286
Start a attribute iteration for the given identity.
Definition: reclaim.h:156
GNUNET_MQ_Error
Error codes for the queue.
int in_receive
Are we polling for incoming messages right now?
Definition: reclaim_api.c:306
Stop attribute iteration for the given operation.
Definition: reclaim.h:193
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:115
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:302
#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:130
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:398
struct GNUNET_CLIENT_TransmitHandle * th
Currently pending transmission request, or NULL for none.
Definition: reclaim_api.c:281
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT
Use to delete an identity attribute.
Definition: reclaim.h:73
void GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h)
Disconnect from service.
Definition: reclaim_api.c:814
struct GNUNET_RECLAIM_AttributeIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:174
void GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op)
Cancel an operation.
Definition: reclaim_api.c:799
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:127
#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:1183
#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:1203
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#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:189
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:994
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:87
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:204
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:327
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:275
GNUNET_RECLAIM_AttributeResult proc
The continuation to call with the results.
Definition: reclaim_api.c:194
struct GNUNET_RECLAIM_Handle * h
Main handle to access the idp.
Definition: reclaim_api.c:117
struct GNUNET_RECLAIM_AttributeIterator * it_tail
Tail of active iterations.
Definition: reclaim_api.c:266
#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:199
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:229
static void force_reconnect(struct GNUNET_RECLAIM_Handle *handle)
Disconnect from service and then reconnect.
Definition: reclaim_api.c:340
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static void reconnect(struct GNUNET_RECLAIM_Handle *h)
Try again to connect to the service.
Definition: reclaim_api.c:729
Common type definitions for the identity provider service and API.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:238
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:296
GNUNET_RECLAIM_ContinuationWithStatus rvk_cb
Revocation result callback.
Definition: reclaim_api.c:76
#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:1237
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:256
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:1234
Handle for a attribute iterator operation.
Definition: reclaim_api.c:165
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:169
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:61
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:202
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:891
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:378
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:225
Stop ticket iteration for the given operation.
Definition: reclaim.h:245
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:186
struct GNUNET_RECLAIM_Ticket ticket
The ticket to revoke.
Definition: reclaim.h:317
struct GNUNET_MQ_Envelope * env
Envelope with the message for this queue entry.
Definition: reclaim_api.c:86
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:450
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:1046
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:475
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:153
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:147
uint32_t r_id_gen
Request Id generator.
Definition: reclaim_api.c:301
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:158
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:170
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:50
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:54
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:555
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:165
Ticket issue message.
Definition: reclaim.h:261
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE
void * cls
Closure for tr_cb.
Definition: reclaim_api.c:137
Message handler for a specific message type.
static int res
Attribute store/delete response message.
Definition: reclaim.h:101
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:319
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:59
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:270
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:285
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_RECLAIM_Ticket ticket
The ticket to consume.
Definition: reclaim.h:383
Ask for next result of attribute iteration for the given operation.
Definition: reclaim.h:177
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:82
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Private key of the zone.
Definition: reclaim_api.c:220
GNUNET_RECLAIM_TicketCallback tr_cb
Ticket result callback.
Definition: reclaim_api.c:81
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:630
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:251
#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:71
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:410
#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:107
#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:241
Handle to a message queue.
Definition: mq.c:84
#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:693
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:236
Ticket revoke message.
Definition: reclaim.h:323
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: reclaim_api.c:142
GNUNET_RECLAIM_TicketCallback tr_cb
The continuation to call with the results.
Definition: reclaim_api.c:132
configuration data
Definition: configuration.c:83
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:215
void GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1015
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:217
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:261
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:332
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:430
Attribute is returned from the idp.
Definition: reclaim.h:121
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:135
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:209
A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
struct GNUNET_TIME_Relative reconnect_backoff
Time for next connect retry.
Definition: reclaim_api.c:291
Start a ticket iteration for the given identity.
Definition: reclaim.h:208
Handle for a ticket iterator operation.
Definition: reclaim_api.c:103
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:408
Entry in list of pending tasks.
Definition: scheduler.c:131
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:393
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:145
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:1095
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:821
static void free_it(struct GNUNET_RECLAIM_AttributeIterator *it)
Free it.
Definition: reclaim_api.c:359
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:351
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:254
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:179
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the reclaim service.
Definition: reclaim_api.c:774
struct GNUNET_MessageHeader header
Message header.
Definition: reclaim.h:125
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * next
DLL.
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:375
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
uint32_t success
Revocation result.
Definition: reclaim.h:337
struct GNUNET_RECLAIM_TicketIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:112
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:122
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:49
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:373
#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:271
#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:325
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:184
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:110
#define GNUNET_free(ptr)
Wrapper around free.
Ticket revoke message.
Definition: reclaim.h:293
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:394
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET
uint32_t r_id
request id
Definition: reclaim_api.c:91
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956