GNUnet 0.21.0
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_protocols.h"
29#include "gnunet_reclaim_lib.h"
31#include "reclaim.h"
32
33#define LOG(kind, ...) GNUNET_log_from (kind, "reclaim-api", __VA_ARGS__)
34
35
40{
45
50
55
61
66
71
76
81
86
91
96
101
105 uint32_t r_id;
106
110 void *cls;
111};
112
113
118{
123
128
133
138
143
148
152 void *cls;
153
158
163
169
173 uint32_t r_id;
174};
175
176
181{
186
191
196
201
206
211
215 void *proc_cls;
216
221
226
232
237
241 uint32_t r_id;
242};
243
248{
253
258
263
268
273
278
282 void *proc_cls;
283
288
293
299
304
308 uint32_t r_id;
309};
310
311
316{
321
325 struct GNUNET_CLIENT_Connection *client;
326
330 void *cb_cls;
331
336
341
346
351
356
361
366
371
375 struct GNUNET_CLIENT_TransmitHandle *th;
376
381
386
391
395 uint32_t r_id_gen;
396
401};
402
403
409static void
411
412
418static void
419reconnect_task (void *cls)
420{
421 struct GNUNET_RECLAIM_Handle *handle = cls;
422
423 handle->reconnect_task = NULL;
425}
426
427
433static void
435{
437 handle->mq = NULL;
438 handle->reconnect_backoff =
439 GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff);
440 handle->reconnect_task =
441 GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff,
443 handle);
444}
445
446
452static void
454{
455 struct GNUNET_RECLAIM_Handle *h = it->h;
456
457 GNUNET_CONTAINER_DLL_remove (h->it_head, h->it_tail, it);
458 if (NULL != it->env)
460 GNUNET_free (it);
461}
462
463
469static void
471{
472 struct GNUNET_RECLAIM_Handle *h = ait->h;
473
474 GNUNET_CONTAINER_DLL_remove (h->ait_head, h->ait_tail, ait);
475 if (NULL != ait->env)
476 GNUNET_MQ_discard (ait->env);
477 GNUNET_free (ait);
478}
479
480
486static void
488{
489 if (NULL == op)
490 return;
491 if (NULL != op->env)
492 GNUNET_MQ_discard (op->env);
493 GNUNET_free (op);
494}
495
496
505static void
506mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
507{
508 struct GNUNET_RECLAIM_Handle *handle = cls;
509
511}
512
513
521static void
523{
524 struct GNUNET_RECLAIM_Handle *h = cls;
526 uint32_t r_id = ntohl (msg->id);
527 int res;
528 const char *emsg;
529
530 for (op = h->op_head; NULL != op; op = op->next)
531 if (op->r_id == r_id)
532 break;
533 if (NULL == op)
534 return;
535
536 res = ntohl (msg->op_result);
538 "Received SUCCESS_RESPONSE with result %d\n",
539 res);
540
541 /* TODO: add actual error message to response... */
542 if (GNUNET_SYSERR == res)
543 emsg = _ ("failed to store record\n");
544 else
545 emsg = NULL;
546 if (NULL != op->as_cb)
547 op->as_cb (op->cls, res, emsg);
548 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
549 free_op (op);
550}
551
552
561static int
563 const struct ConsumeTicketResultMessage *msg)
564{
565 size_t msg_len;
566 size_t attrs_len;
567 size_t pl_len;
568 size_t key_len;
569
570 msg_len = ntohs (msg->header.size);
571 attrs_len = ntohs (msg->attrs_len);
572 key_len = ntohs (msg->key_len);
573 pl_len = ntohs (msg->presentations_len);
574 if (msg_len != sizeof(*msg) + attrs_len + pl_len + key_len)
575 {
576 GNUNET_break (0);
577 return GNUNET_SYSERR;
578 }
579 return GNUNET_OK;
580}
581
582
590static void
592 const struct ConsumeTicketResultMessage *msg)
593{
595 struct GNUNET_RECLAIM_Handle *h = cls;
597 size_t attrs_len;
598 size_t pl_len;
599 size_t key_len;
600 size_t read;
601 uint32_t r_id = ntohl (msg->id);
602 char *read_ptr;
603
604 attrs_len = ntohs (msg->attrs_len);
605 key_len = ntohs (msg->key_len);
606 pl_len = ntohs (msg->presentations_len);
607 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n");
608
609
610 for (op = h->op_head; NULL != op; op = op->next)
611 if (op->r_id == r_id)
612 break;
613 if (NULL == op)
614 return;
615
616 {
617 struct GNUNET_RECLAIM_AttributeList *attrs;
621 read_ptr = (char *) &msg[1];
624 key_len,
625 &identity,
626 &read));
627 read_ptr += read;
628 attrs =
629 GNUNET_RECLAIM_attribute_list_deserialize (read_ptr, attrs_len);
630 read_ptr += attrs_len;
631 pl = GNUNET_RECLAIM_presentation_list_deserialize (read_ptr, pl_len);
632 if (NULL != op->atr_cb)
633 {
634 if (NULL == attrs)
635 {
636 op->atr_cb (op->cls, &identity, NULL, NULL);
637 }
638 else
639 {
640 for (le = attrs->list_head; NULL != le; le = le->next)
641 {
642 if (GNUNET_NO ==
644 {
645 for (ple = pl->list_head; NULL != ple; ple = ple->next)
646 {
647 if (GNUNET_YES ==
650 {
651 op->atr_cb (op->cls, &identity,
652 le->attribute, ple->presentation);
653 break;
654 }
655
656 }
657 }
658 else // No credentials
659 {
660 op->atr_cb (op->cls, &identity,
661 le->attribute, NULL);
662 }
663 }
664 }
665 op->atr_cb (op->cls, NULL, NULL, NULL);
666 }
667 if (NULL != attrs)
669 if (NULL != pl)
671 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
672 free_op (op);
673 return;
674 }
675 GNUNET_assert (0);
676}
677
678
687static int
689{
690 size_t msg_len;
691 size_t attr_len;
692 size_t key_len;
693
694 msg_len = ntohs (msg->header.size);
695 attr_len = ntohs (msg->attr_len);
696 key_len = ntohs (msg->pkey_len);
697 if (msg_len != sizeof(*msg) + attr_len + key_len)
698 {
699 GNUNET_break (0);
700 return GNUNET_SYSERR;
701 }
702 return GNUNET_OK;
703}
704
705
713static void
715{
716 static struct GNUNET_CRYPTO_PublicKey identity;
717 struct GNUNET_RECLAIM_Handle *h = cls;
720 size_t attr_len;
721 size_t key_len;
722 size_t read;
723 uint32_t r_id = ntohl (msg->id);
724 char *buf;
725
726 attr_len = ntohs (msg->attr_len);
727 key_len = ntohs (msg->pkey_len);
728 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
729
730 for (it = h->it_head; NULL != it; it = it->next)
731 if (it->r_id == r_id)
732 break;
733 for (op = h->op_head; NULL != op; op = op->next)
734 if (op->r_id == r_id)
735 break;
736 if ((NULL == it) && (NULL == op))
737 return;
738
739 buf = (char *) &msg[1];
740 if (0 == key_len)
741 {
742 if ((NULL == it) && (NULL == op))
743 {
744 GNUNET_break (0);
746 return;
747 }
748 if (NULL != it)
749 {
750 if (NULL != it->finish_cb)
751 it->finish_cb (it->finish_cb_cls);
752 free_it (it);
753 }
754 if (NULL != op)
755 {
756 if (NULL != op->ar_cb)
757 op->ar_cb (op->cls, NULL, NULL);
758 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
759 free_op (op);
760 }
761 return;
762 }
763
764 {
765 struct GNUNET_RECLAIM_Attribute *attr;
768 key_len,
769 &identity,
770 &read));
771 buf += read;
772 GNUNET_RECLAIM_attribute_deserialize (buf, attr_len, &attr);
773 if (NULL != it)
774 {
775 if (NULL != it->proc)
776 it->proc (it->proc_cls, &identity, attr);
777 }
778 else if (NULL != op)
779 {
780 if (NULL != op->ar_cb)
781 op->ar_cb (op->cls, &identity, attr);
782 }
783 GNUNET_free (attr);
784 return;
785 }
786 GNUNET_assert (0);
787}
788
789
798static int
800{
801 size_t msg_len;
802 size_t cred_len;
803 size_t key_len;
804
805 msg_len = ntohs (msg->header.size);
806 cred_len = ntohs (msg->credential_len);
807 key_len = ntohs (msg->key_len);
808 if (msg_len != sizeof(*msg) + cred_len + key_len)
809 {
810 GNUNET_break (0);
811 return GNUNET_SYSERR;
812 }
813 return GNUNET_OK;
814}
815
816
824static void
825handle_credential_result (void *cls, const struct
827{
829 struct GNUNET_RECLAIM_Handle *h = cls;
832 size_t att_len;
833 size_t key_len;
834 size_t read;
835 uint32_t r_id = ntohl (msg->id);
836 char *buf;
837
838 key_len = ntohs (msg->key_len);
839 att_len = ntohs (msg->credential_len);
840 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing credential result.\n");
841
842
843 for (it = h->ait_head; NULL != it; it = it->next)
844 if (it->r_id == r_id)
845 break;
846 for (op = h->op_head; NULL != op; op = op->next)
847 if (op->r_id == r_id)
848 break;
849 if ((NULL == it) && (NULL == op))
850 return;
851
852 buf = (char *) &msg[1];
853 if (0 < key_len)
854 {
857 key_len,
858 &identity,
859 &read));
860 buf += read;
861 }
862 if (0 == key_len)
863 {
864 if ((NULL == it) && (NULL == op))
865 {
866 GNUNET_break (0);
868 return;
869 }
870 if (NULL != it)
871 {
872 if (NULL != it->finish_cb)
873 it->finish_cb (it->finish_cb_cls);
874 free_ait (it);
875 }
876 if (NULL != op)
877 {
878 if (NULL != op->at_cb)
879 op->at_cb (op->cls, NULL, NULL);
880 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
881 free_op (op);
882 }
883 return;
884 }
885
886 {
887 struct GNUNET_RECLAIM_Credential *att;
888 att = GNUNET_RECLAIM_credential_deserialize (buf, att_len);
889
890 if (NULL != it)
891 {
892 if (NULL != it->proc)
893 it->proc (it->proc_cls, &identity, att);
894 }
895 else if (NULL != op)
896 {
897 if (NULL != op->at_cb)
898 op->at_cb (op->cls, &identity, att);
899 }
900 GNUNET_free (att);
901 return;
902 }
903 GNUNET_assert (0);
904}
905
906
915static int
917{
918 size_t msg_len;
919 size_t pres_len;
920 size_t tkt_len;
921
922 msg_len = ntohs (msg->header.size);
923 pres_len = ntohs (msg->presentations_len);
924 tkt_len = ntohs (msg->tkt_len);
925 if (msg_len != sizeof(*msg) + pres_len + tkt_len)
926 {
927 GNUNET_break (0);
928 return GNUNET_SYSERR;
929 }
930 return GNUNET_OK;
931}
932
933
941static void
943{
944 struct GNUNET_RECLAIM_Handle *handle = cls;
947 struct GNUNET_RECLAIM_PresentationList *presentation;
948 uint32_t r_id = ntohl (msg->id);
950 size_t pres_len;
951 size_t tkt_len;
952 size_t tb_read;
953 char *buf;
954
955 tkt_len = ntohs (msg->tkt_len);
956 pres_len = ntohs (msg->presentations_len);
957 for (op = handle->op_head; NULL != op; op = op->next)
958 if (op->r_id == r_id)
959 break;
960 for (it = handle->ticket_it_head; NULL != it; it = it->next)
961 if (it->r_id == r_id)
962 break;
963 if ((NULL == op) && (NULL == it))
964 return;
965 buf = (char*) &msg[1];
966 if (0 < tkt_len)
967 {
970 tkt_len,
971 &ticket,
972 &tb_read));
973 buf += tb_read;
974 }
975 if (NULL != op)
976 {
977 if (0 < pres_len)
979 buf,
980 pres_len);
981 GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
982 if (0 == tb_read)
983 {
984 if (NULL != op->ti_cb)
985 op->ti_cb (op->cls, NULL, NULL);
986 }
987 else
988 {
989 if (NULL != op->ti_cb)
990 op->ti_cb (op->cls,
991 &ticket,
992 (0 < pres_len) ? presentation : NULL);
993 }
994 if (0 < pres_len)
996 free_op (op);
997 return;
998 }
999 else if (NULL != it)
1000 {
1001 if (0 == tkt_len)
1002 {
1003 GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head,
1004 handle->ticket_it_tail,
1005 it);
1006 it->finish_cb (it->finish_cb_cls);
1007 GNUNET_free (it);
1008 }
1009 else
1010 {
1011 if (NULL != it->tr_cb)
1012 it->tr_cb (it->cls, &ticket);
1013 }
1014 return;
1015 }
1016 GNUNET_break (0);
1017}
1018
1019
1027static void
1029 const struct RevokeTicketResultMessage *msg)
1030{
1031 struct GNUNET_RECLAIM_Handle *h = cls;
1033 uint32_t r_id = ntohl (msg->id);
1034 int32_t success;
1035
1036 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n");
1037
1038
1039 for (op = h->op_head; NULL != op; op = op->next)
1040 if (op->r_id == r_id)
1041 break;
1042 if (NULL == op)
1043 return;
1044 success = ntohl (msg->success);
1045 {
1046 if (NULL != op->rvk_cb)
1047 {
1048 op->rvk_cb (op->cls, success, NULL);
1049 }
1050 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
1051 free_op (op);
1052 return;
1053 }
1054 GNUNET_assert (0);
1055}
1056
1057
1063static void
1065{
1067 { GNUNET_MQ_hd_fixed_size (success_response,
1069 struct SuccessResultMessage,
1070 h),
1071 GNUNET_MQ_hd_var_size (attribute_result,
1074 h),
1075 GNUNET_MQ_hd_var_size (credential_result,
1078 h),
1079 GNUNET_MQ_hd_var_size (ticket_result,
1081 struct TicketResultMessage,
1082 h),
1083 GNUNET_MQ_hd_var_size (consume_ticket_result,
1086 h),
1087 GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
1090 h),
1093
1094 GNUNET_assert (NULL == h->mq);
1095 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
1096
1097 h->mq =
1099 if (NULL == h->mq)
1100 return;
1101 for (op = h->op_head; NULL != op; op = op->next)
1102 GNUNET_MQ_send_copy (h->mq, op->env);
1103}
1104
1105
1112struct GNUNET_RECLAIM_Handle *
1114{
1115 struct GNUNET_RECLAIM_Handle *h;
1116
1118 h->cfg = cfg;
1119 reconnect (h);
1120 if (NULL == h->mq)
1121 {
1122 GNUNET_free (h);
1123 return NULL;
1124 }
1125 return h;
1126}
1127
1128
1129void
1131{
1132 struct GNUNET_RECLAIM_Handle *h = op->h;
1133
1134 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
1135 free_op (op);
1136}
1137
1138
1144void
1146{
1147 GNUNET_assert (NULL != h);
1148 if (NULL != h->mq)
1149 {
1151 h->mq = NULL;
1152 }
1153 if (NULL != h->reconnect_task)
1154 {
1156 h->reconnect_task = NULL;
1157 }
1158 GNUNET_assert (NULL == h->op_head);
1159 GNUNET_free (h);
1160}
1161
1162
1165 struct GNUNET_RECLAIM_Handle *h,
1166 const struct GNUNET_CRYPTO_PrivateKey *pkey,
1167 const struct GNUNET_RECLAIM_Attribute *attr,
1168 const struct GNUNET_TIME_Relative *exp_interval,
1170 void *cont_cls)
1171{
1173 struct AttributeStoreMessage *sam;
1174 size_t attr_len;
1175 size_t key_len;
1176 ssize_t written;
1177 char *buf;
1178
1180 op->h = h;
1181 op->as_cb = cont;
1182 op->cls = cont_cls;
1183 op->r_id = h->r_id_gen++;
1184 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1187 op->env = GNUNET_MQ_msg_extra (sam,
1188 attr_len + key_len,
1190 sam->key_len = htons (key_len);
1191 buf = (char *) &sam[1];
1193 GNUNET_assert (0 < written);
1194 buf += written;
1195 sam->id = htonl (op->r_id);
1197
1199
1200 sam->attr_len = htons (attr_len);
1201 if (NULL != h->mq)
1202 GNUNET_MQ_send_copy (h->mq, op->env);
1203 return op;
1204}
1205
1206
1209 struct GNUNET_RECLAIM_Handle *h,
1210 const struct GNUNET_CRYPTO_PrivateKey *pkey,
1211 const struct GNUNET_RECLAIM_Attribute *attr,
1213 void *cont_cls)
1214{
1216 struct AttributeDeleteMessage *dam;
1217 size_t attr_len;
1218 size_t key_len;
1219 ssize_t written;
1220 char *buf;
1221
1223 op->h = h;
1224 op->as_cb = cont;
1225 op->cls = cont_cls;
1226 op->r_id = h->r_id_gen++;
1227 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1230 op->env = GNUNET_MQ_msg_extra (dam,
1231 attr_len + key_len,
1233 dam->key_len = htons (key_len);
1234 buf = (char *) &dam[1];
1236 GNUNET_assert (0 < written);
1237 buf += written;
1238 dam->id = htonl (op->r_id);
1240
1241 dam->attr_len = htons (attr_len);
1242 if (NULL != h->mq)
1243 GNUNET_MQ_send_copy (h->mq, op->env);
1244 return op;
1245}
1246
1247
1250 struct GNUNET_RECLAIM_Handle *h,
1251 const struct GNUNET_CRYPTO_PrivateKey *pkey,
1253 const struct GNUNET_TIME_Relative *exp_interval,
1255 void *cont_cls)
1256{
1258 struct AttributeStoreMessage *sam;
1259 size_t attr_len;
1260 size_t key_len;
1261 ssize_t written;
1262 char *buf;
1263
1265 op->h = h;
1266 op->as_cb = cont;
1267 op->cls = cont_cls;
1268 op->r_id = h->r_id_gen++;
1270 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1272 op->env = GNUNET_MQ_msg_extra (sam,
1273 attr_len + key_len,
1275 sam->key_len = htons (key_len);
1276 buf = (char *) &sam[1];
1278 GNUNET_assert (0 <= written);
1279 buf += written;
1280 sam->id = htonl (op->r_id);
1282
1284
1285 sam->attr_len = htons (attr_len);
1286 if (NULL != h->mq)
1287 GNUNET_MQ_send_copy (h->mq, op->env);
1288 return op;
1289}
1290
1291
1294 struct GNUNET_RECLAIM_Handle *h,
1295 const struct GNUNET_CRYPTO_PrivateKey *pkey,
1296 const struct GNUNET_RECLAIM_Credential *attr,
1298 void *cont_cls)
1299{
1301 struct AttributeDeleteMessage *dam;
1302 size_t attr_len;
1303 size_t key_len;
1304 ssize_t written;
1305 char *buf;
1306
1308 op->h = h;
1309 op->as_cb = cont;
1310 op->cls = cont_cls;
1311 op->r_id = h->r_id_gen++;
1313 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1315 op->env = GNUNET_MQ_msg_extra (dam,
1316 attr_len + key_len,
1318 dam->key_len = htons (key_len);
1319 buf = (char *) &dam[1];
1321 GNUNET_assert (0 <= written);
1322 buf += written;
1323 dam->id = htonl (op->r_id);
1325
1326 dam->attr_len = htons (attr_len);
1327 if (NULL != h->mq)
1328 GNUNET_MQ_send_copy (h->mq, op->env);
1329 return op;
1330}
1331
1332
1335 struct GNUNET_RECLAIM_Handle *h,
1336 const struct GNUNET_CRYPTO_PrivateKey *identity,
1338 void *error_cb_cls,
1340 void *proc_cls,
1342 void *finish_cb_cls)
1343{
1345 struct GNUNET_MQ_Envelope *env;
1347 uint32_t rid;
1348 size_t key_len;
1349
1350 rid = h->r_id_gen++;
1352 it->h = h;
1353 it->error_cb = error_cb;
1354 it->error_cb_cls = error_cb_cls;
1355 it->finish_cb = finish_cb;
1356 it->finish_cb_cls = finish_cb_cls;
1357 it->proc = proc;
1358 it->proc_cls = proc_cls;
1359 it->r_id = rid;
1360 it->identity = *identity;
1362 GNUNET_CONTAINER_DLL_insert_tail (h->it_head, h->it_tail, it);
1363 env =
1365 key_len,
1367 msg->id = htonl (rid);
1368 msg->key_len = htons (key_len);
1370 if (NULL == h->mq)
1371 it->env = env;
1372 else
1373 GNUNET_MQ_send (h->mq, env);
1374 return it;
1375}
1376
1377
1378void
1380{
1381 struct GNUNET_RECLAIM_Handle *h = it->h;
1383 struct GNUNET_MQ_Envelope *env;
1384
1385 env =
1387 msg->id = htonl (it->r_id);
1388 GNUNET_MQ_send (h->mq, env);
1389}
1390
1391
1392void
1394{
1395 struct GNUNET_RECLAIM_Handle *h = it->h;
1396 struct GNUNET_MQ_Envelope *env;
1398
1399 if (NULL != h->mq)
1400 {
1401 env =
1403 msg->id = htonl (it->r_id);
1404 GNUNET_MQ_send (h->mq, env);
1405 }
1406 free_it (it);
1407}
1408
1409
1412 struct GNUNET_RECLAIM_Handle *h,
1413 const struct GNUNET_CRYPTO_PrivateKey *identity,
1415 void *error_cb_cls,
1417 void *proc_cls,
1419 void *finish_cb_cls)
1420{
1422 struct GNUNET_MQ_Envelope *env;
1424 uint32_t rid;
1425 size_t key_len;
1426
1427 rid = h->r_id_gen++;
1429 ait->h = h;
1430 ait->error_cb = error_cb;
1431 ait->error_cb_cls = error_cb_cls;
1432 ait->finish_cb = finish_cb;
1433 ait->finish_cb_cls = finish_cb_cls;
1434 ait->proc = proc;
1435 ait->proc_cls = proc_cls;
1436 ait->r_id = rid;
1437 ait->identity = *identity;
1439 GNUNET_CONTAINER_DLL_insert_tail (h->ait_head, h->ait_tail, ait);
1440 env =
1442 key_len,
1444 msg->id = htonl (rid);
1445 msg->key_len = htons (key_len);
1447 if (NULL == h->mq)
1448 ait->env = env;
1449 else
1450 GNUNET_MQ_send (h->mq, env);
1451 return ait;
1452}
1453
1454
1455void
1458{
1459 struct GNUNET_RECLAIM_Handle *h = ait->h;
1461 struct GNUNET_MQ_Envelope *env;
1462
1463 env =
1465 msg->id = htonl (ait->r_id);
1466 GNUNET_MQ_send (h->mq, env);
1467}
1468
1469
1470void
1473{
1474 struct GNUNET_RECLAIM_Handle *h = ait->h;
1475 struct GNUNET_MQ_Envelope *env;
1477
1478 if (NULL != h->mq)
1479 {
1480 env =
1483 msg->id = htonl (ait->r_id);
1484 GNUNET_MQ_send (h->mq, env);
1485 }
1486 free_ait (ait);
1487}
1488
1489
1492 struct GNUNET_RECLAIM_Handle *h,
1493 const struct GNUNET_CRYPTO_PrivateKey *iss,
1494 const struct GNUNET_CRYPTO_PublicKey *rp,
1495 const struct GNUNET_RECLAIM_AttributeList *attrs,
1497 void *cb_cls)
1498{
1500 struct IssueTicketMessage *tim;
1501 size_t attr_len;
1502 size_t key_len;
1503 size_t rpk_len;
1504 ssize_t written;
1505 char *buf;
1506
1508 op->h = h;
1509 op->ti_cb = cb;
1510 op->cls = cb_cls;
1511 op->r_id = h->r_id_gen++;
1514 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1516 op->env = GNUNET_MQ_msg_extra (tim,
1517 attr_len + key_len + rpk_len,
1519 tim->key_len = htons (key_len);
1520 tim->pkey_len = htons (rpk_len);
1521 buf = (char *) &tim[1];
1523 GNUNET_assert (0 <= written);
1524 buf += written;
1525 written = GNUNET_CRYPTO_write_public_key_to_buffer (rp, buf, rpk_len);
1526 GNUNET_assert (0 <= written);
1527 buf += written;
1528 tim->id = htonl (op->r_id);
1529
1531 tim->attr_len = htons (attr_len);
1532 if (NULL != h->mq)
1533 GNUNET_MQ_send_copy (h->mq, op->env);
1534 return op;
1535}
1536
1537
1552 struct GNUNET_RECLAIM_Handle *h,
1553 const struct GNUNET_CRYPTO_PrivateKey *identity,
1554 const struct GNUNET_RECLAIM_Ticket *ticket,
1556 void *cb_cls)
1557{
1559 struct ConsumeTicketMessage *ctm;
1560 size_t key_len;
1561 size_t tkt_len;
1562 char *buf;
1563
1565 op->h = h;
1566 op->atr_cb = cb;
1567 op->cls = cb_cls;
1568 op->r_id = h->r_id_gen++;
1571 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1572 op->env = GNUNET_MQ_msg_extra (ctm,
1573 key_len + tkt_len,
1575 ctm->key_len = htons (key_len);
1576 buf = (char*) &ctm[1];
1578 buf += key_len;
1579 ctm->tkt_len = htons (tkt_len);
1581 ctm->id = htonl (op->r_id);
1582 if (NULL != h->mq)
1583 GNUNET_MQ_send_copy (h->mq, op->env);
1584 else
1585 reconnect (h);
1586 return op;
1587}
1588
1589
1592 struct GNUNET_RECLAIM_Handle *h,
1593 const struct GNUNET_CRYPTO_PrivateKey *identity,
1595 void *error_cb_cls,
1597 void *proc_cls,
1599 void *finish_cb_cls)
1600{
1602 struct GNUNET_MQ_Envelope *env;
1604 uint32_t rid;
1605 size_t key_len;
1606
1607 rid = h->r_id_gen++;
1609 it->h = h;
1610 it->error_cb = error_cb;
1611 it->error_cb_cls = error_cb_cls;
1612 it->finish_cb = finish_cb;
1613 it->finish_cb_cls = finish_cb_cls;
1614 it->tr_cb = proc;
1615 it->cls = proc_cls;
1616 it->r_id = rid;
1617
1619 GNUNET_CONTAINER_DLL_insert_tail (h->ticket_it_head, h->ticket_it_tail, it);
1621 key_len,
1623 msg->id = htonl (rid);
1624 msg->key_len = htons (key_len);
1626 &msg[1],
1627 key_len);
1628 if (NULL == h->mq)
1629 it->env = env;
1630 else
1631 GNUNET_MQ_send (h->mq, env);
1632 return it;
1633}
1634
1635
1642void
1644{
1645 struct GNUNET_RECLAIM_Handle *h = it->h;
1647 struct GNUNET_MQ_Envelope *env;
1648
1650 msg->id = htonl (it->r_id);
1651 GNUNET_MQ_send (h->mq, env);
1652}
1653
1654
1662void
1664{
1665 struct GNUNET_RECLAIM_Handle *h = it->h;
1666 struct GNUNET_MQ_Envelope *env;
1668
1669 if (NULL != h->mq)
1670 {
1671 env =
1673 msg->id = htonl (it->r_id);
1674 GNUNET_MQ_send (h->mq, env);
1675 }
1676 GNUNET_free (it);
1677}
1678
1679
1695 struct GNUNET_RECLAIM_Handle *h,
1696 const struct GNUNET_CRYPTO_PrivateKey *identity,
1697 const struct GNUNET_RECLAIM_Ticket *ticket,
1699 void *cb_cls)
1700{
1702 struct RevokeTicketMessage *msg;
1703 uint32_t rid;
1704 size_t key_len;
1705 size_t tkt_len;
1706 ssize_t written;
1707 char *buf;
1708
1709 rid = h->r_id_gen++;
1711 op->h = h;
1712 op->rvk_cb = cb;
1713 op->cls = cb_cls;
1714 op->r_id = rid;
1715 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1718 op->env = GNUNET_MQ_msg_extra (msg,
1719 key_len + tkt_len,
1721 msg->id = htonl (rid);
1722 msg->key_len = htons (key_len);
1723 msg->tkt_len = htons (tkt_len);
1724 buf = (char*) &msg[1];
1726 buf,
1727 key_len);
1728 GNUNET_assert (0 <= written);
1729 buf += written;
1731 buf,
1732 tkt_len);
1733 if (NULL != h->mq)
1734 {
1735 GNUNET_MQ_send (h->mq, op->env);
1736 op->env = NULL;
1737 }
1738 return op;
1739}
1740
1741size_t
1744{
1745 size_t size = sizeof (tkt->rnd);
1748 return size;
1749}
1750
1753 size_t len,
1754 struct GNUNET_RECLAIM_Ticket *tkt,
1755 size_t *tb_read)
1756{
1757 const char *tmp = buffer;
1758 size_t read = 0;
1759 size_t left = len;
1760 if (GNUNET_SYSERR ==
1762 left,
1763 &tkt->identity,
1764 &read))
1765 return GNUNET_SYSERR;
1766 left -= read;
1767 tmp += read;
1768 if (GNUNET_SYSERR ==
1770 left,
1771 &tkt->audience,
1772 &read))
1773 return GNUNET_SYSERR;
1774 left -= read;
1775 tmp += read;
1776 if (left < sizeof (tkt->rnd))
1777 return GNUNET_SYSERR;
1778 memcpy (&tkt->rnd, tmp, sizeof (tkt->rnd));
1779 *tb_read = tmp - (char*) buffer + sizeof (tkt->rnd);
1780 return GNUNET_OK;
1781}
1782
1783
1784ssize_t
1787 void *buffer,
1788 size_t len)
1789{
1790 char *tmp = buffer;
1791 size_t left = len;
1792 ssize_t written = 0;
1794 buffer,
1795 left);
1796 if (0 > written)
1797 return written;
1798 left -= written;
1799 tmp += written;
1801 tmp,
1802 left);
1803 if (0 > written)
1804 return written;
1805 left -= written;
1806 tmp += written;
1807 if (left < sizeof (tkt->rnd))
1808 return -1;
1809 memcpy (tmp, &tkt->rnd, sizeof (tkt->rnd));
1810 return tmp - (char*) buffer + sizeof (tkt->rnd);
1811}
1812
1813
1814
1815/* end of reclaim_api.c */
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
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 struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
static char * pkey
Public key of the zone to look in, in ASCII.
static char * res
Currently read line or NULL on EOF.
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 struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
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_CRYPTO_public_key_get_length(const struct GNUNET_CRYPTO_PublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_PublicKey.
Definition: crypto_pkey.c:68
#define GNUNET_log(kind,...)
ssize_t GNUNET_CRYPTO_write_public_key_to_buffer(const struct GNUNET_CRYPTO_PublicKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_PublicKey to a compact buffer.
Definition: crypto_pkey.c:128
ssize_t GNUNET_CRYPTO_private_key_get_length(const struct GNUNET_CRYPTO_PrivateKey *key)
Get the compacted length of a GNUNET_CRYPTO_PrivateKey.
Definition: crypto_pkey.c:47
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
ssize_t GNUNET_CRYPTO_write_private_key_to_buffer(const struct GNUNET_CRYPTO_PrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_PrivateKey to a compact buffer.
Definition: crypto_pkey.c:171
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PublicKey from a compact buffer.
Definition: crypto_pkey.c:103
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:63
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#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_PresentationList * GNUNET_RECLAIM_presentation_list_deserialize(const char *data, size_t data_size)
Deserialize a presentation list.
#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_Credential * GNUNET_RECLAIM_credential_deserialize(const char *data, size_t data_size)
Deserialize an credential.
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:1145
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_credential_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_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:1249
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:1643
void(* GNUNET_RECLAIM_TicketCallback)(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
Method called when a token has been issued.
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:1752
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_issue(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *iss, const struct GNUNET_CRYPTO_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:1491
void GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op)
Cancel an identity provider operation.
Definition: reclaim_api.c:1130
void GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1393
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:1456
struct GNUNET_RECLAIM_AttributeIterator * GNUNET_RECLAIM_get_attributes_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_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:1334
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:1785
void(* GNUNET_RECLAIM_AttributeResult)(void *cls, const struct GNUNET_CRYPTO_PublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr)
Callback used to notify the client of attribute results.
void(* GNUNET_RECLAIM_CredentialResult)(void *cls, const struct GNUNET_CRYPTO_PublicKey *identity, const struct GNUNET_RECLAIM_Credential *credential)
Callback used to notify the client of credential results.
size_t GNUNET_RECLAIM_ticket_serialize_get_size(const struct GNUNET_RECLAIM_Ticket *tkt)
Get serialized ticket size.
Definition: reclaim_api.c:1742
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_revoke(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls)
Revoked an issued ticket.
Definition: reclaim_api.c:1694
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:1379
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_ticket_consume(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls)
Consumes an issued ticket.
Definition: reclaim_api.c:1551
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the reclaim service.
Definition: reclaim_api.c:1113
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_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:1164
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *pkey, const struct GNUNET_RECLAIM_Attribute *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an attribute.
Definition: reclaim_api.c:1208
void(* GNUNET_RECLAIM_AttributeTicketResult)(void *cls, const struct GNUNET_CRYPTO_PublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr, const struct GNUNET_RECLAIM_Presentation *presentation)
Callback used to notify the client of attribute results.
struct GNUNET_RECLAIM_TicketIterator * GNUNET_RECLAIM_ticket_iteration_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_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:1591
void GNUNET_RECLAIM_get_credentials_stop(struct GNUNET_RECLAIM_CredentialIterator *ait)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1471
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_credential_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *pkey, const struct GNUNET_RECLAIM_Credential *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete a credential.
Definition: reclaim_api.c:1293
void GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1663
struct GNUNET_RECLAIM_CredentialIterator * GNUNET_RECLAIM_get_credentials_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_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:1411
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
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:1272
#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:178
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:942
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:799
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:916
static void free_it(struct GNUNET_RECLAIM_AttributeIterator *it)
Free it.
Definition: reclaim_api.c:453
static void force_reconnect(struct GNUNET_RECLAIM_Handle *handle)
Disconnect from service and then reconnect.
Definition: reclaim_api.c:434
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:714
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:688
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:506
static void free_ait(struct GNUNET_RECLAIM_CredentialIterator *ait)
Free it.
Definition: reclaim_api.c:470
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:1028
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:562
static void reconnect(struct GNUNET_RECLAIM_Handle *h)
Try again to connect to the service.
Definition: reclaim_api.c:1064
static void free_op(struct GNUNET_RECLAIM_Operation *op)
Free op.
Definition: reclaim_api.c:487
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:825
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:522
#define LOG(kind,...)
Definition: reclaim_api.c:33
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:591
static void reconnect_task(void *cls)
Reconnect.
Definition: reclaim_api.c:419
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
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:181
struct GNUNET_RECLAIM_Handle * h
Main handle to access the service.
Definition: reclaim_api.c:195
struct GNUNET_RECLAIM_AttributeIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:190
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:225
GNUNET_RECLAIM_AttributeResult proc
The continuation to call with the results.
Definition: reclaim_api.c:210
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:231
struct GNUNET_CRYPTO_PrivateKey identity
Private key of the zone.
Definition: reclaim_api.c:236
void * proc_cls
Closure for proc.
Definition: reclaim_api.c:215
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: reclaim_api.c:220
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:200
struct GNUNET_RECLAIM_AttributeIterator * next
Kept in a DLL.
Definition: reclaim_api.c:185
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:241
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:205
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:248
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: reclaim_api.c:287
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:267
void * proc_cls
Closure for proc.
Definition: reclaim_api.c:282
GNUNET_RECLAIM_CredentialResult proc
The continuation to call with the results.
Definition: reclaim_api.c:277
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:272
struct GNUNET_RECLAIM_CredentialIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:257
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:308
struct GNUNET_RECLAIM_CredentialIterator * next
Kept in a DLL.
Definition: reclaim_api.c:252
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:298
struct GNUNET_CRYPTO_PrivateKey identity
Private key of the zone.
Definition: reclaim_api.c:303
struct GNUNET_RECLAIM_Handle * h
Main handle to access the service.
Definition: reclaim_api.c:262
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:292
Handle to the service.
Definition: reclaim_api.c:316
uint32_t r_id_gen
Request Id generator.
Definition: reclaim_api.c:395
struct GNUNET_TIME_Relative reconnect_backoff
Time for next connect retry.
Definition: reclaim_api.c:385
struct GNUNET_RECLAIM_AttributeIterator * it_tail
Tail of active iterations.
Definition: reclaim_api.c:350
struct GNUNET_RECLAIM_AttributeIterator * it_head
Head of active iterations.
Definition: reclaim_api.c:345
struct GNUNET_RECLAIM_CredentialIterator * ait_head
Head of active iterations.
Definition: reclaim_api.c:355
struct GNUNET_RECLAIM_CredentialIterator * ait_tail
Tail of active iterations.
Definition: reclaim_api.c:360
struct GNUNET_RECLAIM_TicketIterator * ticket_it_head
Head of active iterations.
Definition: reclaim_api.c:365
int in_receive
Are we polling for incoming messages right now?
Definition: reclaim_api.c:400
struct GNUNET_CLIENT_Connection * client
Socket (if available).
Definition: reclaim_api.c:325
struct GNUNET_RECLAIM_TicketIterator * ticket_it_tail
Tail of active iterations.
Definition: reclaim_api.c:370
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: reclaim_api.c:320
struct GNUNET_RECLAIM_Operation * op_head
Head of active operations.
Definition: reclaim_api.c:335
struct GNUNET_MQ_Handle * mq
Connection to service (if available).
Definition: reclaim_api.c:390
struct GNUNET_RECLAIM_Operation * op_tail
Tail of active operations.
Definition: reclaim_api.c:340
struct GNUNET_SCHEDULER_Task * reconnect_task
Task doing exponential back-off trying to reconnect.
Definition: reclaim_api.c:380
void * cb_cls
Closure for 'cb'.
Definition: reclaim_api.c:330
struct GNUNET_CLIENT_TransmitHandle * th
Currently pending transmission request, or NULL for none.
Definition: reclaim_api.c:375
Handle for an operation with the service.
Definition: reclaim_api.c:40
GNUNET_RECLAIM_CredentialResult at_cb
Credential result callback.
Definition: reclaim_api.c:80
struct GNUNET_RECLAIM_Operation * prev
We keep operations in a DLL.
Definition: reclaim_api.c:54
struct GNUNET_MQ_Envelope * env
Envelope with the message for this queue entry.
Definition: reclaim_api.c:100
struct GNUNET_RECLAIM_Operation * next
We keep operations in a DLL.
Definition: reclaim_api.c:49
GNUNET_RECLAIM_ContinuationWithStatus as_cb
Continuation to invoke after attribute store call.
Definition: reclaim_api.c:65
GNUNET_RECLAIM_ContinuationWithStatus rvk_cb
Revocation result callback.
Definition: reclaim_api.c:85
const struct GNUNET_MessageHeader * msg
Message to send to the service.
Definition: reclaim_api.c:60
struct GNUNET_RECLAIM_Handle * h
Main handle.
Definition: reclaim_api.c:44
GNUNET_RECLAIM_AttributeTicketResult atr_cb
Attribute result callback.
Definition: reclaim_api.c:75
uint32_t r_id
request id
Definition: reclaim_api.c:105
GNUNET_RECLAIM_TicketCallback tr_cb
Ticket result callback.
Definition: reclaim_api.c:90
GNUNET_RECLAIM_AttributeResult ar_cb
Attribute result callback.
Definition: reclaim_api.c:70
GNUNET_RECLAIM_IssueTicketCallback ti_cb
Ticket issue result callback.
Definition: reclaim_api.c:95
void * cls
Closure for cont or cb.
Definition: reclaim_api.c:110
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:118
GNUNET_RECLAIM_TicketCallback tr_cb
The continuation to call with the results.
Definition: reclaim_api.c:147
uint32_t r_id
The operation id this zone iteration operation has.
Definition: reclaim_api.c:173
void * error_cb_cls
Closure for error_cb.
Definition: reclaim_api.c:162
struct GNUNET_RECLAIM_Handle * h
Main handle to access the idp.
Definition: reclaim_api.c:132
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
Definition: reclaim_api.c:137
void * finish_cb_cls
Closure for finish_cb.
Definition: reclaim_api.c:142
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
Definition: reclaim_api.c:168
void * cls
Closure for tr_cb.
Definition: reclaim_api.c:152
struct GNUNET_RECLAIM_TicketIterator * prev
Kept in a DLL.
Definition: reclaim_api.c:127
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: reclaim_api.c:157
struct GNUNET_RECLAIM_TicketIterator * next
Kept in a DLL.
Definition: reclaim_api.c:122
The authorization ticket.
struct GNUNET_CRYPTO_PublicKey audience
The ticket audience (= relying party)
struct GNUNET_RECLAIM_Identifier rnd
The ticket random identifier.
struct GNUNET_CRYPTO_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.
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Definition: vpn_api.c:44
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