GNUnet 0.22.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 {
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
688static 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
714static void
716{
717 static struct GNUNET_CRYPTO_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);
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
799static 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
825static void
826handle_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);
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;
889 att = GNUNET_RECLAIM_credential_deserialize (buf, att_len);
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
916static int
918{
919 size_t msg_len;
920 size_t pres_len;
921 size_t tkt_len;
922 size_t rp_uri_len;
923
924 msg_len = ntohs (msg->header.size);
925 pres_len = ntohs (msg->presentations_len);
926 tkt_len = ntohs (msg->tkt_len);
927 rp_uri_len = ntohs (msg->rp_uri_len);
928 if (msg_len != sizeof(*msg) + pres_len + tkt_len + rp_uri_len)
929 {
930 GNUNET_break (0);
931 return GNUNET_SYSERR;
932 }
933 return GNUNET_OK;
934}
935
936
944static void
946{
947 struct GNUNET_RECLAIM_Handle *handle = cls;
950 struct GNUNET_RECLAIM_PresentationList *presentation;
951 uint32_t r_id = ntohl (msg->id);
952 struct GNUNET_RECLAIM_Ticket *ticket = NULL;
953 size_t pres_len;
954 size_t tkt_len;
955 size_t rp_uri_len;
956 size_t tb_read = 0;
957 char *buf;
958 char *rp_uri = NULL;
959
960 tkt_len = ntohs (msg->tkt_len);
961 rp_uri_len = ntohs (msg->rp_uri_len);
962 pres_len = ntohs (msg->presentations_len);
963 for (op = handle->op_head; NULL != op; op = op->next)
964 if (op->r_id == r_id)
965 break;
966 for (it = handle->ticket_it_head; NULL != it; it = it->next)
967 if (it->r_id == r_id)
968 break;
969 if ((NULL == op) && (NULL == it))
970 return;
971 buf = (char*) &msg[1];
972 if (0 < tkt_len)
973 {
974 ticket = (struct GNUNET_RECLAIM_Ticket*) buf;
975 buf += tkt_len;
976 tb_read += tkt_len;
977 }
978 if (0 < rp_uri_len)
979 rp_uri = buf;
980 if (NULL != op)
981 {
982 if (0 < pres_len)
984 buf,
985 pres_len);
986 GNUNET_CONTAINER_DLL_remove (handle->op_head, handle->op_tail, op);
987 if (0 == tb_read)
988 {
989 if (NULL != op->ti_cb)
990 op->ti_cb (op->cls, NULL, NULL);
991 }
992 else
993 {
994 if (NULL != op->ti_cb)
995 op->ti_cb (op->cls,
996 ticket,
997 (0 < pres_len) ? presentation : NULL);
998 }
999 if (0 < pres_len)
1001 free_op (op);
1002 return;
1003 }
1004 else if (NULL != it)
1005 {
1006 if (0 == tkt_len)
1007 {
1008 GNUNET_CONTAINER_DLL_remove (handle->ticket_it_head,
1009 handle->ticket_it_tail,
1010 it);
1011 it->finish_cb (it->finish_cb_cls);
1012 GNUNET_free (it);
1013 }
1014 else
1015 {
1016 if (NULL != it->tr_cb)
1017 it->tr_cb (it->cls, ticket, rp_uri);
1018 }
1019 return;
1020 }
1021 GNUNET_break (0);
1022}
1023
1024
1032static void
1034 const struct RevokeTicketResultMessage *msg)
1035{
1036 struct GNUNET_RECLAIM_Handle *h = cls;
1038 uint32_t r_id = ntohl (msg->id);
1039 int32_t success;
1040
1041 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing revocation result.\n");
1042
1043
1044 for (op = h->op_head; NULL != op; op = op->next)
1045 if (op->r_id == r_id)
1046 break;
1047 if (NULL == op)
1048 return;
1049 success = ntohl (msg->success);
1050 {
1051 if (NULL != op->rvk_cb)
1052 {
1053 op->rvk_cb (op->cls, success, NULL);
1054 }
1055 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
1056 free_op (op);
1057 return;
1058 }
1059 GNUNET_assert (0);
1060}
1061
1062
1068static void
1070{
1072 { GNUNET_MQ_hd_fixed_size (success_response,
1074 struct SuccessResultMessage,
1075 h),
1076 GNUNET_MQ_hd_var_size (attribute_result,
1079 h),
1080 GNUNET_MQ_hd_var_size (credential_result,
1083 h),
1084 GNUNET_MQ_hd_var_size (ticket_result,
1086 struct TicketResultMessage,
1087 h),
1088 GNUNET_MQ_hd_var_size (consume_ticket_result,
1091 h),
1092 GNUNET_MQ_hd_fixed_size (revoke_ticket_result,
1095 h),
1098
1099 GNUNET_assert (NULL == h->mq);
1100 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to reclaim service.\n");
1101
1102 h->mq =
1104 if (NULL == h->mq)
1105 return;
1106 for (op = h->op_head; NULL != op; op = op->next)
1107 GNUNET_MQ_send_copy (h->mq, op->env);
1108}
1109
1110
1117struct GNUNET_RECLAIM_Handle *
1119{
1120 struct GNUNET_RECLAIM_Handle *h;
1121
1123 h->cfg = cfg;
1124 reconnect (h);
1125 if (NULL == h->mq)
1126 {
1127 GNUNET_free (h);
1128 return NULL;
1129 }
1130 return h;
1131}
1132
1133
1134void
1136{
1137 struct GNUNET_RECLAIM_Handle *h = op->h;
1138
1139 GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
1140 free_op (op);
1141}
1142
1143
1149void
1151{
1152 GNUNET_assert (NULL != h);
1153 if (NULL != h->mq)
1154 {
1156 h->mq = NULL;
1157 }
1158 if (NULL != h->reconnect_task)
1159 {
1161 h->reconnect_task = NULL;
1162 }
1163 GNUNET_assert (NULL == h->op_head);
1164 GNUNET_free (h);
1165}
1166
1167
1170 struct GNUNET_RECLAIM_Handle *h,
1171 const struct GNUNET_CRYPTO_PrivateKey *pkey,
1172 const struct GNUNET_RECLAIM_Attribute *attr,
1173 const struct GNUNET_TIME_Relative *exp_interval,
1175 void *cont_cls)
1176{
1178 struct AttributeStoreMessage *sam;
1179 size_t attr_len;
1180 size_t key_len;
1181 ssize_t written;
1182 char *buf;
1183
1185 op->h = h;
1186 op->as_cb = cont;
1187 op->cls = cont_cls;
1188 op->r_id = h->r_id_gen++;
1189 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1192 op->env = GNUNET_MQ_msg_extra (sam,
1193 attr_len + key_len,
1195 sam->key_len = htons (key_len);
1196 buf = (char *) &sam[1];
1198 GNUNET_assert (0 < written);
1199 buf += written;
1200 sam->id = htonl (op->r_id);
1202
1204
1205 sam->attr_len = htons (attr_len);
1206 if (NULL != h->mq)
1207 GNUNET_MQ_send_copy (h->mq, op->env);
1208 return op;
1209}
1210
1211
1214 struct GNUNET_RECLAIM_Handle *h,
1215 const struct GNUNET_CRYPTO_PrivateKey *pkey,
1216 const struct GNUNET_RECLAIM_Attribute *attr,
1218 void *cont_cls)
1219{
1221 struct AttributeDeleteMessage *dam;
1222 size_t attr_len;
1223 size_t key_len;
1224 ssize_t written;
1225 char *buf;
1226
1228 op->h = h;
1229 op->as_cb = cont;
1230 op->cls = cont_cls;
1231 op->r_id = h->r_id_gen++;
1232 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1235 op->env = GNUNET_MQ_msg_extra (dam,
1236 attr_len + key_len,
1238 dam->key_len = htons (key_len);
1239 buf = (char *) &dam[1];
1241 GNUNET_assert (0 < written);
1242 buf += written;
1243 dam->id = htonl (op->r_id);
1245
1246 dam->attr_len = htons (attr_len);
1247 if (NULL != h->mq)
1248 GNUNET_MQ_send_copy (h->mq, op->env);
1249 return op;
1250}
1251
1252
1255 struct GNUNET_RECLAIM_Handle *h,
1256 const struct GNUNET_CRYPTO_PrivateKey *pkey,
1258 const struct GNUNET_TIME_Relative *exp_interval,
1260 void *cont_cls)
1261{
1263 struct AttributeStoreMessage *sam;
1264 size_t attr_len;
1265 size_t key_len;
1266 ssize_t written;
1267 char *buf;
1268
1270 op->h = h;
1271 op->as_cb = cont;
1272 op->cls = cont_cls;
1273 op->r_id = h->r_id_gen++;
1275 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1277 op->env = GNUNET_MQ_msg_extra (sam,
1278 attr_len + key_len,
1280 sam->key_len = htons (key_len);
1281 buf = (char *) &sam[1];
1283 GNUNET_assert (0 <= written);
1284 buf += written;
1285 sam->id = htonl (op->r_id);
1287
1289
1290 sam->attr_len = htons (attr_len);
1291 if (NULL != h->mq)
1292 GNUNET_MQ_send_copy (h->mq, op->env);
1293 return op;
1294}
1295
1296
1299 struct GNUNET_RECLAIM_Handle *h,
1300 const struct GNUNET_CRYPTO_PrivateKey *pkey,
1301 const struct GNUNET_RECLAIM_Credential *attr,
1303 void *cont_cls)
1304{
1306 struct AttributeDeleteMessage *dam;
1307 size_t attr_len;
1308 size_t key_len;
1309 ssize_t written;
1310 char *buf;
1311
1313 op->h = h;
1314 op->as_cb = cont;
1315 op->cls = cont_cls;
1316 op->r_id = h->r_id_gen++;
1318 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1320 op->env = GNUNET_MQ_msg_extra (dam,
1321 attr_len + key_len,
1323 dam->key_len = htons (key_len);
1324 buf = (char *) &dam[1];
1326 GNUNET_assert (0 <= written);
1327 buf += written;
1328 dam->id = htonl (op->r_id);
1330
1331 dam->attr_len = htons (attr_len);
1332 if (NULL != h->mq)
1333 GNUNET_MQ_send_copy (h->mq, op->env);
1334 return op;
1335}
1336
1337
1340 struct GNUNET_RECLAIM_Handle *h,
1341 const struct GNUNET_CRYPTO_PrivateKey *identity,
1343 void *error_cb_cls,
1345 void *proc_cls,
1347 void *finish_cb_cls)
1348{
1350 struct GNUNET_MQ_Envelope *env;
1352 uint32_t rid;
1353 size_t key_len;
1354
1355 rid = h->r_id_gen++;
1357 it->h = h;
1358 it->error_cb = error_cb;
1359 it->error_cb_cls = error_cb_cls;
1360 it->finish_cb = finish_cb;
1361 it->finish_cb_cls = finish_cb_cls;
1362 it->proc = proc;
1363 it->proc_cls = proc_cls;
1364 it->r_id = rid;
1365 it->identity = *identity;
1367 GNUNET_CONTAINER_DLL_insert_tail (h->it_head, h->it_tail, it);
1368 env =
1370 key_len,
1372 msg->id = htonl (rid);
1373 msg->key_len = htons (key_len);
1375 if (NULL == h->mq)
1376 it->env = env;
1377 else
1378 GNUNET_MQ_send (h->mq, env);
1379 return it;
1380}
1381
1382
1383void
1385{
1386 struct GNUNET_RECLAIM_Handle *h = it->h;
1388 struct GNUNET_MQ_Envelope *env;
1389
1390 env =
1392 msg->id = htonl (it->r_id);
1393 GNUNET_MQ_send (h->mq, env);
1394}
1395
1396
1397void
1399{
1400 struct GNUNET_RECLAIM_Handle *h = it->h;
1401 struct GNUNET_MQ_Envelope *env;
1403
1404 if (NULL != h->mq)
1405 {
1406 env =
1408 msg->id = htonl (it->r_id);
1409 GNUNET_MQ_send (h->mq, env);
1410 }
1411 free_it (it);
1412}
1413
1414
1417 struct GNUNET_RECLAIM_Handle *h,
1418 const struct GNUNET_CRYPTO_PrivateKey *identity,
1420 void *error_cb_cls,
1422 void *proc_cls,
1424 void *finish_cb_cls)
1425{
1427 struct GNUNET_MQ_Envelope *env;
1429 uint32_t rid;
1430 size_t key_len;
1431
1432 rid = h->r_id_gen++;
1434 ait->h = h;
1435 ait->error_cb = error_cb;
1436 ait->error_cb_cls = error_cb_cls;
1437 ait->finish_cb = finish_cb;
1438 ait->finish_cb_cls = finish_cb_cls;
1439 ait->proc = proc;
1440 ait->proc_cls = proc_cls;
1441 ait->r_id = rid;
1442 ait->identity = *identity;
1444 GNUNET_CONTAINER_DLL_insert_tail (h->ait_head, h->ait_tail, ait);
1445 env =
1447 key_len,
1449 ;
1450 msg->id = htonl (rid);
1451 msg->key_len = htons (key_len);
1453 if (NULL == h->mq)
1454 ait->env = env;
1455 else
1456 GNUNET_MQ_send (h->mq, env);
1457 return ait;
1458}
1459
1460
1461void
1464{
1465 struct GNUNET_RECLAIM_Handle *h = ait->h;
1467 struct GNUNET_MQ_Envelope *env;
1468
1469 env =
1471 msg->id = htonl (ait->r_id);
1472 GNUNET_MQ_send (h->mq, env);
1473}
1474
1475
1476void
1479{
1480 struct GNUNET_RECLAIM_Handle *h = ait->h;
1481 struct GNUNET_MQ_Envelope *env;
1483
1484 if (NULL != h->mq)
1485 {
1486 env =
1489 msg->id = htonl (ait->r_id);
1490 GNUNET_MQ_send (h->mq, env);
1491 }
1492 free_ait (ait);
1493}
1494
1495
1498 struct GNUNET_RECLAIM_Handle *h,
1499 const struct GNUNET_CRYPTO_PrivateKey *iss,
1500 const char *rp,
1501 const struct GNUNET_RECLAIM_AttributeList *attrs,
1503 void *cb_cls)
1504{
1506 struct IssueTicketMessage *tim;
1507 size_t attr_len;
1508 size_t key_len;
1509 size_t rpk_len;
1510 ssize_t written;
1511 char *buf;
1512
1514 op->h = h;
1515 op->ti_cb = cb;
1516 op->cls = cb_cls;
1517 op->r_id = h->r_id_gen++;
1519 rpk_len = strlen (rp) + 1;
1520 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1522 op->env = GNUNET_MQ_msg_extra (tim,
1523 attr_len + key_len + rpk_len,
1525 tim->key_len = htons (key_len);
1526 tim->rp_uri_len = htons (rpk_len);
1527 buf = (char *) &tim[1];
1529 GNUNET_assert (0 <= written);
1530 buf += written;
1531 memcpy (buf, rp, rpk_len);
1532 written = rpk_len;
1533 GNUNET_assert (0 <= written);
1534 buf += written;
1535 tim->id = htonl (op->r_id);
1536
1538 tim->attr_len = htons (attr_len);
1539 if (NULL != h->mq)
1540 GNUNET_MQ_send_copy (h->mq, op->env);
1541 return op;
1542}
1543
1544
1547 struct GNUNET_RECLAIM_Handle *h,
1548 const struct GNUNET_RECLAIM_Ticket *ticket,
1549 const char *rp_uri,
1551 void *cb_cls)
1552{
1554 struct ConsumeTicketMessage *ctm;
1555 size_t tkt_len;
1556 size_t rp_uri_len;
1557 char *buf;
1558
1560 op->h = h;
1561 op->atr_cb = cb;
1562 op->cls = cb_cls;
1563 op->r_id = h->r_id_gen++;
1564 tkt_len = strlen (ticket->gns_name) + 1;
1565 rp_uri_len = strlen (rp_uri) + 1;
1566 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1567 op->env = GNUNET_MQ_msg_extra (ctm,
1570 buf = (char*) &ctm[1];
1571 ctm->rp_uri_len = htons (rp_uri_len);
1572 ctm->tkt_len = htons (tkt_len);
1573 memcpy (buf, ticket, tkt_len);
1574 buf += tkt_len;
1575 memcpy (buf, rp_uri, rp_uri_len);
1576 ctm->id = htonl (op->r_id);
1577 if (NULL != h->mq)
1578 GNUNET_MQ_send_copy (h->mq, op->env);
1579 else
1580 reconnect (h);
1581 return op;
1582}
1583
1584
1587 struct GNUNET_RECLAIM_Handle *h,
1588 const struct GNUNET_CRYPTO_PrivateKey *identity,
1590 void *error_cb_cls,
1592 void *proc_cls,
1594 void *finish_cb_cls)
1595{
1597 struct GNUNET_MQ_Envelope *env;
1599 uint32_t rid;
1600 size_t key_len;
1601
1602 rid = h->r_id_gen++;
1604 it->h = h;
1605 it->error_cb = error_cb;
1606 it->error_cb_cls = error_cb_cls;
1607 it->finish_cb = finish_cb;
1608 it->finish_cb_cls = finish_cb_cls;
1609 it->tr_cb = proc;
1610 it->cls = proc_cls;
1611 it->r_id = rid;
1612
1614 GNUNET_CONTAINER_DLL_insert_tail (h->ticket_it_head, h->ticket_it_tail, it);
1616 key_len,
1618 ;
1619 msg->id = htonl (rid);
1620 msg->key_len = htons (key_len);
1622 &msg[1],
1623 key_len);
1624 if (NULL == h->mq)
1625 it->env = env;
1626 else
1627 GNUNET_MQ_send (h->mq, env);
1628 return it;
1629}
1630
1631
1638void
1640{
1641 struct GNUNET_RECLAIM_Handle *h = it->h;
1643 struct GNUNET_MQ_Envelope *env;
1644
1646 msg->id = htonl (it->r_id);
1647 GNUNET_MQ_send (h->mq, env);
1648}
1649
1650
1658void
1660{
1661 struct GNUNET_RECLAIM_Handle *h = it->h;
1662 struct GNUNET_MQ_Envelope *env;
1664
1665 if (NULL != h->mq)
1666 {
1667 env =
1669 msg->id = htonl (it->r_id);
1670 GNUNET_MQ_send (h->mq, env);
1671 }
1672 GNUNET_free (it);
1673}
1674
1675
1691 struct GNUNET_RECLAIM_Handle *h,
1692 const struct GNUNET_CRYPTO_PrivateKey *identity,
1693 const struct GNUNET_RECLAIM_Ticket *ticket,
1695 void *cb_cls)
1696{
1698 struct RevokeTicketMessage *msg;
1699 uint32_t rid;
1700 size_t key_len;
1701 size_t tkt_len;
1702 ssize_t written;
1703 char *buf;
1704
1705 rid = h->r_id_gen++;
1707 op->h = h;
1708 op->rvk_cb = cb;
1709 op->cls = cb_cls;
1710 op->r_id = rid;
1711 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
1713 tkt_len = strlen (ticket->gns_name) + 1;
1714 op->env = GNUNET_MQ_msg_extra (msg,
1715 key_len + tkt_len,
1717 msg->id = htonl (rid);
1718 msg->key_len = htons (key_len);
1719 msg->tkt_len = htons (tkt_len);
1720 buf = (char*) &msg[1];
1722 buf,
1723 key_len);
1724 GNUNET_assert (0 <= written);
1725 buf += written;
1726 memcpy (buf, ticket, tkt_len);
1727 if (NULL != h->mq)
1728 {
1729 GNUNET_MQ_send (h->mq, op->env);
1730 op->env = NULL;
1731 }
1732 return op;
1733}
1734
1735
1736/* 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:480
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:143
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:98
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
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:1060
#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.
#define GNUNET_log(kind,...)
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:64
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:172
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:102
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ 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:384
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:305
#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:700
#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:1150
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:1254
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:1639
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_consume(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_RECLAIM_Ticket *ticket, const char *rp_uri, GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls)
Consumes an issued ticket.
Definition: reclaim_api.c:1546
void GNUNET_RECLAIM_cancel(struct GNUNET_RECLAIM_Operation *op)
Cancel an identity provider operation.
Definition: reclaim_api.c:1135
void GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1398
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:1462
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:1339
void(* GNUNET_RECLAIM_TicketCallback)(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket, const char *rp_uri)
Method called when a token has been issued.
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.
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:1690
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:1384
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_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the reclaim service.
Definition: reclaim_api.c:1118
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:1169
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:1213
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_Operation * GNUNET_RECLAIM_ticket_issue(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *iss, const char *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:1497
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 identities (relying parties)
Definition: reclaim_api.c:1586
void GNUNET_RECLAIM_get_credentials_stop(struct GNUNET_RECLAIM_CredentialIterator *ait)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1477
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:1298
void GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1659
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:1416
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:979
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:1276
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
#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:945
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: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: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: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:1033
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:1069
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: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: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:529
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:538
uint16_t rp_uri_len
RP URI length.
Definition: reclaim.h:548
uint16_t tkt_len
The length of the ticket.
Definition: reclaim.h:543
Attribute list is returned from the idp.
Definition: reclaim.h:560
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.
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.
char gns_name[63 *2+2]
The ticket.
Entry in list of pending tasks.
Definition: scheduler.c:135
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 rp_uri_len
The length of the relying party URI.
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