GNUnet  0.19.2
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_protocols.h"
30 #include "gnunet_reclaim_lib.h"
31 #include "gnunet_reclaim_service.h"
32 #include "reclaim.h"
33 
34 #define LOG(kind, ...) GNUNET_log_from (kind, "reclaim-api", __VA_ARGS__)
35 
36 
41 {
46 
51 
56 
61  const struct GNUNET_MessageHeader *msg;
62 
67 
72 
77 
82 
87 
92 
97 
102 
106  uint32_t r_id;
107 
111  void *cls;
112 };
113 
114 
119 {
124 
129 
134 
139 
144 
149 
153  void *cls;
154 
159 
164 
170 
174  uint32_t r_id;
175 };
176 
177 
182 {
187 
192 
197 
202 
207 
212 
216  void *proc_cls;
217 
222 
227 
233 
238 
242  uint32_t r_id;
243 };
244 
249 {
254 
259 
264 
269 
274 
279 
283  void *proc_cls;
284 
289 
294 
300 
305 
309  uint32_t r_id;
310 };
311 
312 
317 {
322 
326  struct GNUNET_CLIENT_Connection *client;
327 
331  void *cb_cls;
332 
337 
342 
347 
352 
357 
362 
367 
372 
376  struct GNUNET_CLIENT_TransmitHandle *th;
377 
382 
387 
392 
396  uint32_t r_id_gen;
397 
402 };
403 
404 
410 static void
412 
413 
419 static void
420 reconnect_task (void *cls)
421 {
422  struct GNUNET_RECLAIM_Handle *handle = cls;
423 
424  handle->reconnect_task = NULL;
425  reconnect (handle);
426 }
427 
428 
434 static void
436 {
438  handle->mq = NULL;
439  handle->reconnect_backoff =
440  GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff);
442  GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff,
444  handle);
445 }
446 
447 
453 static void
455 {
456  struct GNUNET_RECLAIM_Handle *h = it->h;
457 
458  GNUNET_CONTAINER_DLL_remove (h->it_head, h->it_tail, it);
459  if (NULL != it->env)
460  GNUNET_MQ_discard (it->env);
461  GNUNET_free (it);
462 }
463 
464 
470 static void
472 {
473  struct GNUNET_RECLAIM_Handle *h = ait->h;
474 
475  GNUNET_CONTAINER_DLL_remove (h->ait_head, h->ait_tail, ait);
476  if (NULL != ait->env)
477  GNUNET_MQ_discard (ait->env);
478  GNUNET_free (ait);
479 }
480 
481 
487 static void
489 {
490  if (NULL == op)
491  return;
492  if (NULL != op->env)
493  GNUNET_MQ_discard (op->env);
494  GNUNET_free (op);
495 }
496 
497 
506 static void
507 mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
508 {
509  struct GNUNET_RECLAIM_Handle *handle = cls;
510 
512 }
513 
514 
522 static void
524 {
525  struct GNUNET_RECLAIM_Handle *h = cls;
527  uint32_t r_id = ntohl (msg->id);
528  int res;
529  const char *emsg;
530 
531  for (op = h->op_head; NULL != op; op = op->next)
532  if (op->r_id == r_id)
533  break;
534  if (NULL == op)
535  return;
536 
537  res = ntohl (msg->op_result);
539  "Received SUCCESS_RESPONSE with result %d\n",
540  res);
541 
542  /* TODO: add actual error message to response... */
543  if (GNUNET_SYSERR == res)
544  emsg = _ ("failed to store record\n");
545  else
546  emsg = NULL;
547  if (NULL != op->as_cb)
548  op->as_cb (op->cls, res, emsg);
549  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
550  free_op (op);
551 }
552 
553 
562 static int
564  const struct ConsumeTicketResultMessage *msg)
565 {
566  size_t msg_len;
567  size_t attrs_len;
568  size_t pl_len;
569  size_t key_len;
570 
571  msg_len = ntohs (msg->header.size);
572  attrs_len = ntohs (msg->attrs_len);
573  key_len = ntohs (msg->key_len);
574  pl_len = ntohs (msg->presentations_len);
575  if (msg_len != sizeof(*msg) + attrs_len + pl_len + key_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 {
596  struct GNUNET_RECLAIM_Handle *h = cls;
598  size_t attrs_len;
599  size_t pl_len;
600  size_t key_len;
601  size_t read;
602  uint32_t r_id = ntohl (msg->id);
603  char *read_ptr;
604 
605  attrs_len = ntohs (msg->attrs_len);
606  key_len = ntohs (msg->key_len);
607  pl_len = ntohs (msg->presentations_len);
608  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n");
609 
610 
611  for (op = h->op_head; NULL != op; op = op->next)
612  if (op->r_id == r_id)
613  break;
614  if (NULL == op)
615  return;
616 
617  {
618  struct GNUNET_RECLAIM_AttributeList *attrs;
622  read_ptr = (char *) &msg[1];
625  key_len,
626  &identity,
627  &read));
628  read_ptr += read;
629  attrs =
630  GNUNET_RECLAIM_attribute_list_deserialize (read_ptr, attrs_len);
631  read_ptr += attrs_len;
632  pl = GNUNET_RECLAIM_presentation_list_deserialize (read_ptr, pl_len);
633  if (NULL != op->atr_cb)
634  {
635  if (NULL == attrs)
636  {
637  op->atr_cb (op->cls, &identity, NULL, NULL);
638  }
639  else
640  {
641  for (le = attrs->list_head; NULL != le; le = le->next)
642  {
643  if (GNUNET_NO ==
645  {
646  for (ple = pl->list_head; NULL != ple; ple = ple->next)
647  {
648  if (GNUNET_YES ==
650  &ple->presentation->credential_id))
651  {
652  op->atr_cb (op->cls, &identity,
653  le->attribute, ple->presentation);
654  break;
655  }
656 
657  }
658  }
659  else // No credentials
660  {
661  op->atr_cb (op->cls, &identity,
662  le->attribute, NULL);
663  }
664  }
665  }
666  op->atr_cb (op->cls, NULL, NULL, NULL);
667  }
668  if (NULL != attrs)
670  if (NULL != pl)
672  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
673  free_op (op);
674  return;
675  }
676  GNUNET_assert (0);
677 }
678 
679 
688 static int
690 {
691  size_t msg_len;
692  size_t attr_len;
693  size_t key_len;
694 
695  msg_len = ntohs (msg->header.size);
696  attr_len = ntohs (msg->attr_len);
697  key_len = ntohs (msg->pkey_len);
698  if (msg_len != sizeof(*msg) + attr_len + key_len)
699  {
700  GNUNET_break (0);
701  return GNUNET_SYSERR;
702  }
703  return GNUNET_OK;
704 }
705 
706 
714 static void
716 {
717  static struct GNUNET_IDENTITY_PublicKey identity;
718  struct GNUNET_RECLAIM_Handle *h = cls;
721  size_t attr_len;
722  size_t key_len;
723  size_t read;
724  uint32_t r_id = ntohl (msg->id);
725  char *buf;
726 
727  attr_len = ntohs (msg->attr_len);
728  key_len = ntohs (msg->pkey_len);
729  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
730 
731  for (it = h->it_head; NULL != it; it = it->next)
732  if (it->r_id == r_id)
733  break;
734  for (op = h->op_head; NULL != op; op = op->next)
735  if (op->r_id == r_id)
736  break;
737  if ((NULL == it) && (NULL == op))
738  return;
739 
740  buf = (char *) &msg[1];
741  if (0 == key_len)
742  {
743  if ((NULL == it) && (NULL == op))
744  {
745  GNUNET_break (0);
746  force_reconnect (h);
747  return;
748  }
749  if (NULL != it)
750  {
751  if (NULL != it->finish_cb)
752  it->finish_cb (it->finish_cb_cls);
753  free_it (it);
754  }
755  if (NULL != op)
756  {
757  if (NULL != op->ar_cb)
758  op->ar_cb (op->cls, NULL, NULL);
759  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
760  free_op (op);
761  }
762  return;
763  }
764 
765  {
766  struct GNUNET_RECLAIM_Attribute *attr;
769  key_len,
770  &identity,
771  &read));
772  buf += read;
773  GNUNET_RECLAIM_attribute_deserialize (buf, attr_len, &attr);
774  if (NULL != it)
775  {
776  if (NULL != it->proc)
777  it->proc (it->proc_cls, &identity, attr);
778  }
779  else if (NULL != op)
780  {
781  if (NULL != op->ar_cb)
782  op->ar_cb (op->cls, &identity, attr);
783  }
784  GNUNET_free (attr);
785  return;
786  }
787  GNUNET_assert (0);
788 }
789 
790 
799 static int
801 {
802  size_t msg_len;
803  size_t cred_len;
804  size_t key_len;
805 
806  msg_len = ntohs (msg->header.size);
807  cred_len = ntohs (msg->credential_len);
808  key_len = ntohs (msg->key_len);
809  if (msg_len != sizeof(*msg) + cred_len + key_len)
810  {
811  GNUNET_break (0);
812  return GNUNET_SYSERR;
813  }
814  return GNUNET_OK;
815 }
816 
817 
825 static void
826 handle_credential_result (void *cls, const struct
828 {
830  struct GNUNET_RECLAIM_Handle *h = cls;
833  size_t att_len;
834  size_t key_len;
835  size_t read;
836  uint32_t r_id = ntohl (msg->id);
837  char *buf;
838 
839  key_len = ntohs (msg->key_len);
840  att_len = ntohs (msg->credential_len);
841  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing credential result.\n");
842 
843 
844  for (it = h->ait_head; NULL != it; it = it->next)
845  if (it->r_id == r_id)
846  break;
847  for (op = h->op_head; NULL != op; op = op->next)
848  if (op->r_id == r_id)
849  break;
850  if ((NULL == it) && (NULL == op))
851  return;
852 
853  buf = (char *) &msg[1];
854  if (0 < key_len)
855  {
858  key_len,
859  &identity,
860  &read));
861  buf += read;
862  }
863  if (0 == key_len)
864  {
865  if ((NULL == it) && (NULL == op))
866  {
867  GNUNET_break (0);
868  force_reconnect (h);
869  return;
870  }
871  if (NULL != it)
872  {
873  if (NULL != it->finish_cb)
874  it->finish_cb (it->finish_cb_cls);
875  free_ait (it);
876  }
877  if (NULL != op)
878  {
879  if (NULL != op->at_cb)
880  op->at_cb (op->cls, NULL, NULL);
881  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
882  free_op (op);
883  }
884  return;
885  }
886 
887  {
888  struct GNUNET_RECLAIM_Credential *att;
890 
891  if (NULL != it)
892  {
893  if (NULL != it->proc)
894  it->proc (it->proc_cls, &identity, att);
895  }
896  else if (NULL != op)
897  {
898  if (NULL != op->at_cb)
899  op->at_cb (op->cls, &identity, att);
900  }
901  GNUNET_free (att);
902  return;
903  }
904  GNUNET_assert (0);
905 }
906 
907 
916 static int
917 check_ticket_result (void *cls, const struct TicketResultMessage *msg)
918 {
919  size_t msg_len;
920  size_t pres_len;
921  size_t tkt_len;
922 
923  msg_len = ntohs (msg->header.size);
924  pres_len = ntohs (msg->presentations_len);
925  tkt_len = ntohs (msg->tkt_len);
926  if (msg_len != sizeof(*msg) + pres_len + tkt_len)
927  {
928  GNUNET_break (0);
929  return GNUNET_SYSERR;
930  }
931  return GNUNET_OK;
932 }
933 
934 
942 static void
943 handle_ticket_result (void *cls, const struct TicketResultMessage *msg)
944 {
945  struct GNUNET_RECLAIM_Handle *handle = cls;
948  struct GNUNET_RECLAIM_PresentationList *presentation;
949  uint32_t r_id = ntohl (msg->id);
951  size_t pres_len;
952  size_t tkt_len;
953  size_t tb_read;
954  char *buf;
955 
956  tkt_len = ntohs (msg->tkt_len);
957  pres_len = ntohs (msg->presentations_len);
958  for (op = handle->op_head; NULL != op; op = op->next)
959  if (op->r_id == r_id)
960  break;
961  for (it = handle->ticket_it_head; NULL != it; it = it->next)
962  if (it->r_id == r_id)
963  break;
964  if ((NULL == op) && (NULL == it))
965  return;
966  buf = (char*) &msg[1];
969  tkt_len,
970  &ticket,
971  &tb_read));
972  buf += tb_read;
973  if (NULL != op)
974  {
975  if (0 < pres_len)
977  buf,
978  pres_len);
979  GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
980  if (0 == tb_read)
981  {
982  if (NULL != op->ti_cb)
983  op->ti_cb (op->cls, NULL, NULL);
984  }
985  else
986  {
987  if (NULL != op->ti_cb)
988  op->ti_cb (op->cls,
989  &ticket,
990  (0 < pres_len) ? presentation : NULL);
991  }
992  if (0 < pres_len)
994  free_op (op);
995  return;
996  }
997  else if (NULL != it)
998  {
999  if (0 == tkt_len)
1000  {
1001  GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head,
1002  handle->ticket_it_tail,
1003  it);
1004  it->finish_cb (it->finish_cb_cls);
1005  GNUNET_free (it);
1006  }
1007  else
1008  {
1009  if (NULL != it->tr_cb)
1010  it->tr_cb (it->cls, &ticket);
1011  }
1012  return;
1013  }
1014  GNUNET_break (0);
1015 }
1016 
1017 
1025 static void
1027  const struct RevokeTicketResultMessage *msg)
1028 {
1029  struct GNUNET_RECLAIM_Handle *h = cls;
1030  struct GNUNET_RECLAIM_Operation *op;
1031  uint32_t r_id = ntohl (msg->id);
1032  int32_t success;
1033 
1034  LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n");
1035 
1036 
1037  for (op = h->op_head; NULL != op; op = op->next)
1038  if (op->r_id == r_id)
1039  break;
1040  if (NULL == op)
1041  return;
1042  success = ntohl (msg->success);
1043  {
1044  if (NULL != op->rvk_cb)
1045  {
1046  op->rvk_cb (op->cls, success, NULL);
1047  }
1048  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
1049  free_op (op);
1050  return;
1051  }
1052  GNUNET_assert (0);
1053 }
1054 
1055 
1061 static void
1063 {
1065  { GNUNET_MQ_hd_fixed_size (success_response,
1067  struct SuccessResultMessage,
1068  h),
1069  GNUNET_MQ_hd_var_size (attribute_result,
1071  struct AttributeResultMessage,
1072  h),
1073  GNUNET_MQ_hd_var_size (credential_result,
1075  struct CredentialResultMessage,
1076  h),
1077  GNUNET_MQ_hd_var_size (ticket_result,
1079  struct TicketResultMessage,
1080  h),
1081  GNUNET_MQ_hd_var_size (consume_ticket_result,
1084  h),
1085  GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
1088  h),
1089  GNUNET_MQ_handler_end () };
1090  struct GNUNET_RECLAIM_Operation *op;
1091 
1092  GNUNET_assert (NULL == h->mq);
1093  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
1094 
1095  h->mq =
1097  if (NULL == h->mq)
1098  return;
1099  for (op = h->op_head; NULL != op; op = op->next)
1100  GNUNET_MQ_send_copy (h->mq, op->env);
1101 }
1102 
1103 
1110 struct GNUNET_RECLAIM_Handle *
1112 {
1113  struct GNUNET_RECLAIM_Handle *h;
1114 
1115  h = GNUNET_new (struct GNUNET_RECLAIM_Handle);
1116  h->cfg = cfg;
1117  reconnect (h);
1118  if (NULL == h->mq)
1119  {
1120  GNUNET_free (h);
1121  return NULL;
1122  }
1123  return h;
1124 }
1125 
1126 
1127 void
1129 {
1130  struct GNUNET_RECLAIM_Handle *h = op->h;
1131 
1132  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
1133  free_op (op);
1134 }
1135 
1136 
1142 void
1144 {
1145  GNUNET_assert (NULL != h);
1146  if (NULL != h->mq)
1147  {
1148  GNUNET_MQ_destroy (h->mq);
1149  h->mq = NULL;
1150  }
1151  if (NULL != h->reconnect_task)
1152  {
1154  h->reconnect_task = NULL;
1155  }
1156  GNUNET_assert (NULL == h->op_head);
1157  GNUNET_free (h);
1158 }
1159 
1160 
1161 struct GNUNET_RECLAIM_Operation *
1163  struct GNUNET_RECLAIM_Handle *h,
1164  const struct GNUNET_IDENTITY_PrivateKey *pkey,
1165  const struct GNUNET_RECLAIM_Attribute *attr,
1166  const struct GNUNET_TIME_Relative *exp_interval,
1168  void *cont_cls)
1169 {
1170  struct GNUNET_RECLAIM_Operation *op;
1171  struct AttributeStoreMessage *sam;
1172  size_t attr_len;
1173  size_t key_len;
1174  ssize_t written;
1175  char *buf;
1176 
1178  op->h = h;
1179  op->as_cb = cont;
1180  op->cls = cont_cls;
1181  op->r_id = h->r_id_gen++;
1182  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1185  op->env = GNUNET_MQ_msg_extra (sam,
1186  attr_len + key_len,
1188  sam->key_len = htons (key_len);
1189  buf = (char *) &sam[1];
1191  GNUNET_assert (0 < written);
1192  buf += written;
1193  sam->id = htonl (op->r_id);
1195 
1197 
1198  sam->attr_len = htons (attr_len);
1199  if (NULL != h->mq)
1200  GNUNET_MQ_send_copy (h->mq, op->env);
1201  return op;
1202 }
1203 
1204 
1205 struct GNUNET_RECLAIM_Operation *
1207  struct GNUNET_RECLAIM_Handle *h,
1208  const struct GNUNET_IDENTITY_PrivateKey *pkey,
1209  const struct GNUNET_RECLAIM_Attribute *attr,
1211  void *cont_cls)
1212 {
1213  struct GNUNET_RECLAIM_Operation *op;
1214  struct AttributeDeleteMessage *dam;
1215  size_t attr_len;
1216  size_t key_len;
1217  ssize_t written;
1218  char *buf;
1219 
1221  op->h = h;
1222  op->as_cb = cont;
1223  op->cls = cont_cls;
1224  op->r_id = h->r_id_gen++;
1225  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1228  op->env = GNUNET_MQ_msg_extra (dam,
1229  attr_len + key_len,
1231  dam->key_len = htons (key_len);
1232  buf = (char *) &dam[1];
1234  GNUNET_assert (0 < written);
1235  buf += written;
1236  dam->id = htonl (op->r_id);
1238 
1239  dam->attr_len = htons (attr_len);
1240  if (NULL != h->mq)
1241  GNUNET_MQ_send_copy (h->mq, op->env);
1242  return op;
1243 }
1244 
1245 
1246 struct GNUNET_RECLAIM_Operation *
1248  struct GNUNET_RECLAIM_Handle *h,
1249  const struct GNUNET_IDENTITY_PrivateKey *pkey,
1250  const struct GNUNET_RECLAIM_Credential *credential,
1251  const struct GNUNET_TIME_Relative *exp_interval,
1253  void *cont_cls)
1254 {
1255  struct GNUNET_RECLAIM_Operation *op;
1256  struct AttributeStoreMessage *sam;
1257  size_t attr_len;
1258  size_t key_len;
1259  ssize_t written;
1260  char *buf;
1261 
1263  op->h = h;
1264  op->as_cb = cont;
1265  op->cls = cont_cls;
1266  op->r_id = h->r_id_gen++;
1268  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1270  op->env = GNUNET_MQ_msg_extra (sam,
1271  attr_len + key_len,
1273  sam->key_len = htons (key_len);
1274  buf = (char *) &sam[1];
1276  GNUNET_assert (0 <= written);
1277  buf += written;
1278  sam->id = htonl (op->r_id);
1280 
1282 
1283  sam->attr_len = htons (attr_len);
1284  if (NULL != h->mq)
1285  GNUNET_MQ_send_copy (h->mq, op->env);
1286  return op;
1287 }
1288 
1289 
1290 struct GNUNET_RECLAIM_Operation *
1292  struct GNUNET_RECLAIM_Handle *h,
1293  const struct GNUNET_IDENTITY_PrivateKey *pkey,
1294  const struct GNUNET_RECLAIM_Credential *attr,
1296  void *cont_cls)
1297 {
1298  struct GNUNET_RECLAIM_Operation *op;
1299  struct AttributeDeleteMessage *dam;
1300  size_t attr_len;
1301  size_t key_len;
1302  ssize_t written;
1303  char *buf;
1304 
1306  op->h = h;
1307  op->as_cb = cont;
1308  op->cls = cont_cls;
1309  op->r_id = h->r_id_gen++;
1311  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1313  op->env = GNUNET_MQ_msg_extra (dam,
1314  attr_len + key_len,
1316  dam->key_len = htons (key_len);
1317  buf = (char *) &dam[1];
1319  GNUNET_assert (0 <= written);
1320  buf += written;
1321  dam->id = htonl (op->r_id);
1323 
1324  dam->attr_len = htons (attr_len);
1325  if (NULL != h->mq)
1326  GNUNET_MQ_send_copy (h->mq, op->env);
1327  return op;
1328 }
1329 
1330 
1333  struct GNUNET_RECLAIM_Handle *h,
1334  const struct GNUNET_IDENTITY_PrivateKey *identity,
1336  void *error_cb_cls,
1338  void *proc_cls,
1340  void *finish_cb_cls)
1341 {
1343  struct GNUNET_MQ_Envelope *env;
1345  uint32_t rid;
1346  size_t key_len;
1347 
1348  rid = h->r_id_gen++;
1350  it->h = h;
1351  it->error_cb = error_cb;
1352  it->error_cb_cls = error_cb_cls;
1353  it->finish_cb = finish_cb;
1354  it->finish_cb_cls = finish_cb_cls;
1355  it->proc = proc;
1356  it->proc_cls = proc_cls;
1357  it->r_id = rid;
1358  it->identity = *identity;
1360  GNUNET_CONTAINER_DLL_insert_tail (h->it_head, h->it_tail, it);
1361  env =
1363  key_len,
1365  msg->id = htonl (rid);
1366  msg->key_len = htons (key_len);
1368  if (NULL == h->mq)
1369  it->env = env;
1370  else
1371  GNUNET_MQ_send (h->mq, env);
1372  return it;
1373 }
1374 
1375 
1376 void
1378 {
1379  struct GNUNET_RECLAIM_Handle *h = it->h;
1381  struct GNUNET_MQ_Envelope *env;
1382 
1383  env =
1385  msg->id = htonl (it->r_id);
1386  GNUNET_MQ_send (h->mq, env);
1387 }
1388 
1389 
1390 void
1392 {
1393  struct GNUNET_RECLAIM_Handle *h = it->h;
1394  struct GNUNET_MQ_Envelope *env;
1396 
1397  if (NULL != h->mq)
1398  {
1399  env =
1401  msg->id = htonl (it->r_id);
1402  GNUNET_MQ_send (h->mq, env);
1403  }
1404  free_it (it);
1405 }
1406 
1407 
1410  struct GNUNET_RECLAIM_Handle *h,
1411  const struct GNUNET_IDENTITY_PrivateKey *identity,
1413  void *error_cb_cls,
1415  void *proc_cls,
1417  void *finish_cb_cls)
1418 {
1420  struct GNUNET_MQ_Envelope *env;
1422  uint32_t rid;
1423  size_t key_len;
1424 
1425  rid = h->r_id_gen++;
1427  ait->h = h;
1428  ait->error_cb = error_cb;
1429  ait->error_cb_cls = error_cb_cls;
1430  ait->finish_cb = finish_cb;
1431  ait->finish_cb_cls = finish_cb_cls;
1432  ait->proc = proc;
1433  ait->proc_cls = proc_cls;
1434  ait->r_id = rid;
1435  ait->identity = *identity;
1437  GNUNET_CONTAINER_DLL_insert_tail (h->ait_head, h->ait_tail, ait);
1438  env =
1440  key_len,
1442  msg->id = htonl (rid);
1443  msg->key_len = htons (key_len);
1445  if (NULL == h->mq)
1446  ait->env = env;
1447  else
1448  GNUNET_MQ_send (h->mq, env);
1449  return ait;
1450 }
1451 
1452 
1453 void
1456 {
1457  struct GNUNET_RECLAIM_Handle *h = ait->h;
1459  struct GNUNET_MQ_Envelope *env;
1460 
1461  env =
1463  msg->id = htonl (ait->r_id);
1464  GNUNET_MQ_send (h->mq, env);
1465 }
1466 
1467 
1468 void
1471 {
1472  struct GNUNET_RECLAIM_Handle *h = ait->h;
1473  struct GNUNET_MQ_Envelope *env;
1475 
1476  if (NULL != h->mq)
1477  {
1478  env =
1479  GNUNET_MQ_msg (msg,
1481  msg->id = htonl (ait->r_id);
1482  GNUNET_MQ_send (h->mq, env);
1483  }
1484  free_ait (ait);
1485 }
1486 
1487 
1488 struct GNUNET_RECLAIM_Operation *
1490  struct GNUNET_RECLAIM_Handle *h,
1491  const struct GNUNET_IDENTITY_PrivateKey *iss,
1492  const struct GNUNET_IDENTITY_PublicKey *rp,
1493  const struct GNUNET_RECLAIM_AttributeList *attrs,
1495  void *cb_cls)
1496 {
1497  struct GNUNET_RECLAIM_Operation *op;
1498  struct IssueTicketMessage *tim;
1499  size_t attr_len;
1500  size_t key_len;
1501  size_t rpk_len;
1502  ssize_t written;
1503  char *buf;
1504 
1506  op->h = h;
1507  op->ti_cb = cb;
1508  op->cls = cb_cls;
1509  op->r_id = h->r_id_gen++;
1512  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1514  op->env = GNUNET_MQ_msg_extra (tim,
1515  attr_len + key_len + rpk_len,
1517  tim->key_len = htons (key_len);
1518  tim->pkey_len = htons (rpk_len);
1519  buf = (char *) &tim[1];
1521  GNUNET_assert (0 <= written);
1522  buf += written;
1523  written = GNUNET_IDENTITY_write_public_key_to_buffer (rp, buf, rpk_len);
1524  GNUNET_assert (0 <= written);
1525  buf += written;
1526  tim->id = htonl (op->r_id);
1527 
1529  tim->attr_len = htons (attr_len);
1530  if (NULL != h->mq)
1531  GNUNET_MQ_send_copy (h->mq, op->env);
1532  return op;
1533 }
1534 
1535 
1548 struct GNUNET_RECLAIM_Operation *
1550  struct GNUNET_RECLAIM_Handle *h,
1551  const struct GNUNET_IDENTITY_PrivateKey *identity,
1552  const struct GNUNET_RECLAIM_Ticket *ticket,
1554  void *cb_cls)
1555 {
1556  struct GNUNET_RECLAIM_Operation *op;
1557  struct ConsumeTicketMessage *ctm;
1558  size_t key_len;
1559  size_t tkt_len;
1560  char *buf;
1561 
1563  op->h = h;
1564  op->atr_cb = cb;
1565  op->cls = cb_cls;
1566  op->r_id = h->r_id_gen++;
1569  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1570  op->env = GNUNET_MQ_msg_extra (ctm,
1571  key_len + tkt_len,
1573  ctm->key_len = htons (key_len);
1574  buf = (char*) &ctm[1];
1576  buf += key_len;
1577  ctm->tkt_len = htons (tkt_len);
1579  ctm->id = htonl (op->r_id);
1580  if (NULL != h->mq)
1581  GNUNET_MQ_send_copy (h->mq, op->env);
1582  else
1583  reconnect (h);
1584  return op;
1585 }
1586 
1587 
1590  struct GNUNET_RECLAIM_Handle *h,
1591  const struct GNUNET_IDENTITY_PrivateKey *identity,
1593  void *error_cb_cls,
1595  void *proc_cls,
1597  void *finish_cb_cls)
1598 {
1599  struct GNUNET_RECLAIM_TicketIterator *it;
1600  struct GNUNET_MQ_Envelope *env;
1602  uint32_t rid;
1603  size_t key_len;
1604 
1605  rid = h->r_id_gen++;
1607  it->h = h;
1608  it->error_cb = error_cb;
1609  it->error_cb_cls = error_cb_cls;
1610  it->finish_cb = finish_cb;
1611  it->finish_cb_cls = finish_cb_cls;
1612  it->tr_cb = proc;
1613  it->cls = proc_cls;
1614  it->r_id = rid;
1615 
1617  GNUNET_CONTAINER_DLL_insert_tail (h->ticket_it_head, h->ticket_it_tail, it);
1619  key_len,
1621  msg->id = htonl (rid);
1622  msg->key_len = htons (key_len);
1624  &msg[1],
1625  key_len);
1626  if (NULL == h->mq)
1627  it->env = env;
1628  else
1629  GNUNET_MQ_send (h->mq, env);
1630  return it;
1631 }
1632 
1633 
1640 void
1642 {
1643  struct GNUNET_RECLAIM_Handle *h = it->h;
1645  struct GNUNET_MQ_Envelope *env;
1646 
1648  msg->id = htonl (it->r_id);
1649  GNUNET_MQ_send (h->mq, env);
1650 }
1651 
1652 
1660 void
1662 {
1663  struct GNUNET_RECLAIM_Handle *h = it->h;
1664  struct GNUNET_MQ_Envelope *env;
1666 
1667  if (NULL != h->mq)
1668  {
1669  env =
1671  msg->id = htonl (it->r_id);
1672  GNUNET_MQ_send (h->mq, env);
1673  }
1674  GNUNET_free (it);
1675 }
1676 
1677 
1691 struct GNUNET_RECLAIM_Operation *
1693  struct GNUNET_RECLAIM_Handle *h,
1694  const struct GNUNET_IDENTITY_PrivateKey *identity,
1695  const struct GNUNET_RECLAIM_Ticket *ticket,
1697  void *cb_cls)
1698 {
1699  struct GNUNET_RECLAIM_Operation *op;
1700  struct RevokeTicketMessage *msg;
1701  uint32_t rid;
1702  size_t key_len;
1703  size_t tkt_len;
1704  ssize_t written;
1705  char *buf;
1706 
1707  rid = h->r_id_gen++;
1709  op->h = h;
1710  op->rvk_cb = cb;
1711  op->cls = cb_cls;
1712  op->r_id = rid;
1713  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1716  op->env = GNUNET_MQ_msg_extra (msg,
1717  key_len + tkt_len,
1719  msg->id = htonl (rid);
1720  msg->key_len = htons (key_len);
1721  msg->tkt_len = htons (tkt_len);
1722  buf = (char*) &msg[1];
1724  buf,
1725  key_len);
1726  GNUNET_assert (0 <= written);
1727  buf += written;
1729  buf,
1730  tkt_len);
1731  if (NULL != h->mq)
1732  {
1733  GNUNET_MQ_send (h->mq, op->env);
1734  op->env = NULL;
1735  }
1736  return op;
1737 }
1738 
1739 size_t
1741  GNUNET_RECLAIM_Ticket *tkt)
1742 {
1743  size_t size = sizeof (tkt->rnd);
1746  return size;
1747 }
1748 
1750 GNUNET_RECLAIM_read_ticket_from_buffer (const void *buffer,
1751  size_t len,
1752  struct GNUNET_RECLAIM_Ticket *tkt,
1753  size_t *tb_read)
1754 {
1755  const char *tmp = buffer;
1756  size_t read = 0;
1757  size_t left = len;
1758  if (GNUNET_SYSERR ==
1760  left,
1761  &tkt->identity,
1762  &read))
1763  return GNUNET_SYSERR;
1764  left -= read;
1765  tmp += read;
1766  if (GNUNET_SYSERR ==
1768  left,
1769  &tkt->audience,
1770  &read))
1771  return GNUNET_SYSERR;
1772  left -= read;
1773  tmp += read;
1774  if (left < sizeof (tkt->rnd))
1775  return GNUNET_SYSERR;
1776  memcpy (&tkt->rnd, tmp, sizeof (tkt->rnd));
1777  *tb_read = tmp - (char*) buffer + sizeof (tkt->rnd);
1778  return GNUNET_OK;
1779 }
1780 
1781 
1782 ssize_t
1784  GNUNET_RECLAIM_Ticket *tkt,
1785  void *buffer,
1786  size_t len)
1787 {
1788  char *tmp = buffer;
1789  size_t left = len;
1790  ssize_t written = 0;
1792  buffer,
1793  left);
1794  if (0 > written)
1795  return written;
1796  left -= written;
1797  tmp += written;
1799  tmp,
1800  left);
1801  if (0 > written)
1802  return written;
1803  left -= written;
1804  tmp += written;
1805  if (left < sizeof (tkt->rnd))
1806  return -1;
1807  memcpy (tmp, &tkt->rnd, sizeof (tkt->rnd));
1808  return tmp - (char*) buffer + sizeof (tkt->rnd);
1809 }
1810 
1811 
1812 
1813 /* end of reclaim_api.c */
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static void error_cb(void *cls)
Function called if lookup fails.
Definition: gnunet-abd.c:479
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static int res
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static char * pkey
Public key of the zone to look in, in ASCII.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static struct GNUNET_TIME_Relative exp_interval
Attribute expiration interval.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
static char * rp
Relying party.
static struct GNUNET_RECLAIM_Identifier credential
Credential ID.
static char buf[2048]
Constants for network protocols.
Identity attribute definitions.
reclaim service; implements identity and personal data sharing for GNUnet
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:1057
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
ssize_t GNUNET_IDENTITY_write_public_key_to_buffer(const struct GNUNET_IDENTITY_PublicKey *key, void *buffer, size_t len)
Writes a GNUNET_IDENTITY_PublicKey to a compact buffer.
Definition: identity_api.c:890
ssize_t GNUNET_IDENTITY_public_key_get_length(const struct GNUNET_IDENTITY_PublicKey *key)
Get the compacted length of a GNUNET_IDENTITY_PublicKey.
Definition: identity_api.c:830
ssize_t GNUNET_IDENTITY_write_private_key_to_buffer(const struct GNUNET_IDENTITY_PrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_IDENTITY_PrivateKey to a compact buffer.
Definition: identity_api.c:933
ssize_t GNUNET_IDENTITY_private_key_get_length(const struct GNUNET_IDENTITY_PrivateKey *key)
Get the compacted length of a GNUNET_IDENTITY_PrivateKey.
Definition: identity_api.c:809
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_IDENTITY_PublicKey *key, size_t *kb_read)
Reads a GNUNET_IDENTITY_PublicKey from a compact buffer.
Definition: identity_api.c:865
#define GNUNET_log(kind,...)
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
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:370
GNUNET_MQ_Error
Error codes for the queue.
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:304
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:285
#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:62
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:77
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT
#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_STOP
#define GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_NEXT
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START
#define GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT
#define GNUNET_RECLAIM_id_is_equal(a, b)
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
struct GNUNET_RECLAIM_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize an credential.
#define GNUNET_RECLAIM_id_is_zero(a)
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attribute_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
void GNUNET_RECLAIM_presentation_list_destroy(struct GNUNET_RECLAIM_PresentationList *presentations)
Destroy presentations list.
size_t GNUNET_RECLAIM_attribute_serialize_get_size(const struct GNUNET_RECLAIM_Attribute *attr)
Get required size for serialization buffer.
size_t GNUNET_RECLAIM_attribute_list_serialize(const struct GNUNET_RECLAIM_AttributeList *attrs, char *result)
Serialize an attribute list.
ssize_t GNUNET_RECLAIM_attribute_deserialize(const char *data, size_t data_size, struct GNUNET_RECLAIM_Attribute **attr)
Deserialize an attribute.
size_t GNUNET_RECLAIM_credential_serialize(const struct GNUNET_RECLAIM_Credential *credential, char *result)
Serialize an credential.
struct GNUNET_RECLAIM_PresentationList * GNUNET_RECLAIM_presentation_list_deserialize(const char *data, size_t data_size)
Deserialize a presentation list.
size_t GNUNET_RECLAIM_attribute_list_serialize_get_size(const struct GNUNET_RECLAIM_AttributeList *attrs)
Get required size for serialization buffer.
size_t GNUNET_RECLAIM_credential_serialize_get_size(const struct GNUNET_RECLAIM_Credential *credential)
Get required size for serialization buffer.
size_t GNUNET_RECLAIM_attribute_serialize(const struct GNUNET_RECLAIM_Attribute *attr, char *result)
Serialize an attribute.
void GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h)
Disconnect from service.
Definition: reclaim_api.c:1143
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_credential_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const struct GNUNET_RECLAIM_Credential *credential, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store a credential.
Definition: reclaim_api.c:1247
void(* GNUNET_RECLAIM_ContinuationWithStatus)(void *cls, int32_t success, const char *emsg)
Continuation called to notify client about result of the operation.
void GNUNET_RECLAIM_ticket_iteration_next(struct GNUNET_RECLAIM_TicketIterator *it)
Calls the ticket processor specified in GNUNET_RECLAIM_ticket_iteration_start for the next record.
Definition: reclaim_api.c:1641
void(* GNUNET_RECLAIM_TicketCallback)(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
Method called when a token has been issued.
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:1332
enum GNUNET_GenericReturnValue GNUNET_RECLAIM_read_ticket_from_buffer(const void *buffer, size_t len, struct GNUNET_RECLAIM_Ticket *tkt, size_t *tb_read)
Deserializes a ticket.
Definition: reclaim_api.c:1750
void GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op)
Cancel an identity provider operation.
Definition: reclaim_api.c:1128
void GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1391
void GNUNET_RECLAIM_get_credentials_next(struct GNUNET_RECLAIM_CredentialIterator *ait)
Calls the record processor specified in GNUNET_RECLAIM_get_credentials_start for the next record.
Definition: reclaim_api.c:1454
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:1162
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.
ssize_t GNUNET_RECLAIM_write_ticket_to_buffer(const struct GNUNET_RECLAIM_Ticket *tkt, void *buffer, size_t len)
Serializes a ticket.
Definition: reclaim_api.c:1783
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 a credential.
Definition: reclaim_api.c:1291
size_t GNUNET_RECLAIM_ticket_serialize_get_size(const struct GNUNET_RECLAIM_Ticket *tkt)
Get serialized ticket size.
Definition: reclaim_api.c:1740
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:1409
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:1377
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 a relying party.
Definition: reclaim_api.c:1489
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.
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:1206
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:1692
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:1589
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the reclaim service.
Definition: reclaim_api.c:1111
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.
void GNUNET_RECLAIM_get_credentials_stop(struct GNUNET_RECLAIM_CredentialIterator *ait)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1469
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:1549
void GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1661
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:944
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:1241
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static unsigned int size
Size of the "table".
Definition: peer.c:68
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
Common type definitions for the identity provider service and API.
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:943
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:800
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:917
static void free_it(struct GNUNET_RECLAIM_AttributeIterator *it)
Free it.
Definition: reclaim_api.c:454
static void force_reconnect(struct GNUNET_RECLAIM_Handle *handle)
Disconnect from service and then reconnect.
Definition: reclaim_api.c:435
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:715
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:689
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:507
static void free_ait(struct GNUNET_RECLAIM_CredentialIterator *ait)
Free it.
Definition: reclaim_api.c:471
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:1026
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:563
static void reconnect(struct GNUNET_RECLAIM_Handle *h)
Try again to connect to the service.
Definition: reclaim_api.c:1062
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:488
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:826
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:523
#define LOG(kind,...)
Definition: reclaim_api.c:34
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
static void reconnect_task(void *cls)
Reconnect.
Definition: reclaim_api.c:420
Use to delete an identity attribute.
Definition: reclaim.h:77
uint16_t key_len
The length of the private key.
Definition: reclaim.h:96
uint16_t attr_len
The length of the attribute.
Definition: reclaim.h:91
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:86
Ask for next result of attribute iteration for the given operation.
Definition: reclaim.h:233
Start a attribute iteration for the given identity.
Definition: reclaim.h:202
uint16_t key_len
The length of the private key.
Definition: reclaim.h:221
Stop attribute iteration for the given operation.
Definition: reclaim.h:315
Attribute is returned from the idp.
Definition: reclaim.h:127
Use to store an identity attribute.
Definition: reclaim.h:41
uint64_t exp
The expiration interval of the attribute.
Definition: reclaim.h:50
uint16_t key_len
The length of the private key.
Definition: reclaim.h:65
uint16_t attr_len
The length of the attribute.
Definition: reclaim.h:60
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:55
Ticket consume message.
Definition: reclaim.h:523
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:532
uint16_t key_len
The length of the private key.
Definition: reclaim.h:537
uint16_t tkt_len
The length of the ticket.
Definition: reclaim.h:542
Attribute list is returned from the idp.
Definition: reclaim.h:554
Ask for next result of credential iteration for the given operation.
Definition: reclaim.h:281
Start a credential iteration for the given identity.
Definition: reclaim.h:250
uint16_t key_len
The length of the private key.
Definition: reclaim.h:269
Stop credential iteration for the given operation.
Definition: reclaim.h:298
Credential is returned from the idp.
Definition: reclaim.h:169
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
Definition: arm_api.c:147
struct GNUNET_ARM_Operation * next
This is a doubly-linked list.
Definition: arm_api.c:45
struct GNUNET_ARM_Handle * h
ARM handle.
Definition: arm_api.c:55
struct GNUNET_SCHEDULER_Task * reconnect_task
Task to reconnect to the service.
Definition: dns_api.c:81
struct GNUNET_MQ_Handle * mq
Connection to DNS service, or NULL.
Definition: dns_api.c:61
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
Handle to a message queue.
Definition: mq.c:87
Message handler for a specific message type.
Header for all communications.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
Handle for a attribute iterator operation.
Definition: reclaim_api.c:182
struct GNUNET_RECLAIM_Handle * h
Main handle to access the service.
Definition: reclaim_api.c:196
struct GNUNET_RECLAIM_AttributeIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:191
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:226
GNUNET_RECLAIM_AttributeResult proc
The continuation to call with the results.
Definition: reclaim_api.c:211
struct GNUNET_IDENTITY_PrivateKey identity
Private key of the zone.
Definition: reclaim_api.c:237
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:232
void * proc_cls
Closure for proc.
Definition: reclaim_api.c:216
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: reclaim_api.c:221
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:201
struct GNUNET_RECLAIM_AttributeIterator * next
Kept in a DLL.
Definition: reclaim_api.c:186
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:242
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:206
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
A list of GNUNET_RECLAIM_Attribute structures.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
struct GNUNET_RECLAIM_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
Handle for a credential iterator operation.
Definition: reclaim_api.c:249
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: reclaim_api.c:288
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:268
void * proc_cls
Closure for proc.
Definition: reclaim_api.c:283
GNUNET_RECLAIM_CredentialResult proc
The continuation to call with the results.
Definition: reclaim_api.c:278
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:273
struct GNUNET_RECLAIM_CredentialIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:258
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:309
struct GNUNET_RECLAIM_CredentialIterator * next
Kept in a DLL.
Definition: reclaim_api.c:253
struct GNUNET_IDENTITY_PrivateKey identity
Private key of the zone.
Definition: reclaim_api.c:304
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:299
struct GNUNET_RECLAIM_Handle * h
Main handle to access the service.
Definition: reclaim_api.c:263
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:293
Handle to the service.
Definition: reclaim_api.c:317
uint32_t r_id_gen
Request Id generator.
Definition: reclaim_api.c:396
struct GNUNET_TIME_Relative reconnect_backoff
Time for next connect retry.
Definition: reclaim_api.c:386
struct GNUNET_RECLAIM_AttributeIterator * it_tail
Tail of active iterations.
Definition: reclaim_api.c:351
struct GNUNET_RECLAIM_AttributeIterator * it_head
Head of active iterations.
Definition: reclaim_api.c:346
struct GNUNET_RECLAIM_CredentialIterator * ait_head
Head of active iterations.
Definition: reclaim_api.c:356
struct GNUNET_RECLAIM_CredentialIterator * ait_tail
Tail of active iterations.
Definition: reclaim_api.c:361
struct GNUNET_RECLAIM_TicketIterator * ticket_it_head
Head of active iterations.
Definition: reclaim_api.c:366
int in_receive
Are we polling for incoming messages right now?
Definition: reclaim_api.c:401
struct GNUNET_CLIENT_Connection * client
Socket (if available).
Definition: reclaim_api.c:326
struct GNUNET_RECLAIM_TicketIterator * ticket_it_tail
Tail of active iterations.
Definition: reclaim_api.c:371
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: reclaim_api.c:321
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:336
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
Definition: reclaim_api.c:391
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:341
struct GNUNET_SCHEDULER_Task * reconnect_task
Task doing exponential back-off trying to reconnect.
Definition: reclaim_api.c:381
void * cb_cls
Closure for 'cb'.
Definition: reclaim_api.c:331
struct GNUNET_CLIENT_TransmitHandle * th
Currently pending transmission request, or NULL for none.
Definition: reclaim_api.c:376
Handle for an operation with the service.
Definition: reclaim_api.c:41
GNUNET_RECLAIM_CredentialResult at_cb
Credential result callback.
Definition: reclaim_api.c:81
struct GNUNET_RECLAIM_Operation * prev
We keep operations in a DLL.
Definition: reclaim_api.c:55
struct GNUNET_MQ_Envelope * env
Envelope with the message for this queue entry.
Definition: reclaim_api.c:101
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:50
GNUNET_RECLAIM_ContinuationWithStatus as_cb
Continuation to invoke after attribute store call.
Definition: reclaim_api.c:66
GNUNET_RECLAIM_ContinuationWithStatus rvk_cb
Revocation result callback.
Definition: reclaim_api.c:86
const struct GNUNET_MessageHeader * msg
Message to send to the service.
Definition: reclaim_api.c:61
struct GNUNET_RECLAIM_Handle * h
Main handle.
Definition: reclaim_api.c:45
GNUNET_RECLAIM_AttributeTicketResult atr_cb
Attribute result callback.
Definition: reclaim_api.c:76
uint32_t r_id
request id
Definition: reclaim_api.c:106
GNUNET_RECLAIM_TicketCallback tr_cb
Ticket result callback.
Definition: reclaim_api.c:91
GNUNET_RECLAIM_AttributeResult ar_cb
Attribute result callback.
Definition: reclaim_api.c:71
GNUNET_RECLAIM_IssueTicketCallback ti_cb
Ticket issue result callback.
Definition: reclaim_api.c:96
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:111
struct GNUNET_RECLAIM_Presentation * presentation
The credential.
struct GNUNET_RECLAIM_PresentationListEntry * next
DLL.
A list of GNUNET_RECLAIM_Presentation structures.
struct GNUNET_RECLAIM_PresentationListEntry * list_head
List head.
struct GNUNET_RECLAIM_Identifier credential_id
The credential id of which this is a presentation.
Handle for a ticket iterator operation.
Definition: reclaim_api.c:119
GNUNET_RECLAIM_TicketCallback tr_cb
The continuation to call with the results.
Definition: reclaim_api.c:148
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:174
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:163
struct GNUNET_RECLAIM_Handle * h
Main handle to access the idp.
Definition: reclaim_api.c:133
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:138
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:143
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:169
void * cls
Closure for tr_cb.
Definition: reclaim_api.c:153
struct GNUNET_RECLAIM_TicketIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:128
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: reclaim_api.c:158
struct GNUNET_RECLAIM_TicketIterator * next
Kept in a DLL.
Definition: reclaim_api.c:123
The authorization ticket.
struct GNUNET_RECLAIM_Identifier rnd
The ticket random identifier.
struct GNUNET_IDENTITY_PublicKey audience
The ticket audience (= relying party)
struct GNUNET_IDENTITY_PublicKey identity
The ticket issuer (= the user)
Entry in list of pending tasks.
Definition: scheduler.c:136
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Ticket issue message.
Definition: reclaim.h:396
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:405
uint16_t pkey_len
The length of the relying party public key.
Definition: reclaim.h:425
uint16_t key_len
The length of the identity private key.
Definition: reclaim.h:420
uint16_t attr_len
length of serialized attribute list
Definition: reclaim.h:415
Ticket revoke message.
Definition: reclaim.h:438
uint16_t key_len
The length of the private key.
Definition: reclaim.h:452
uint16_t tkt_len
The length of the ticket.
Definition: reclaim.h:457
Ticket revoke message.
Definition: reclaim.h:470
Attribute store/delete response message.
Definition: reclaim.h:106
Ask for next result of ticket iteration for the given operation.
Definition: reclaim.h:362
Start a ticket iteration for the given identity.
Definition: reclaim.h:331
uint16_t key_len
The length of the private key.
Definition: reclaim.h:350
Stop ticket iteration for the given operation.
Definition: reclaim.h:379
Ticket result message.
Definition: reclaim.h:492