GNUnet  0.10.x
gnunet-service-reclaim.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2012-2015 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  */
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
29 #include "gnunet_constants.h"
30 #include "gnunet_gnsrecord_lib.h"
31 #include "gnunet_protocols.h"
33 #include "gnunet_reclaim_service.h"
34 #include "gnunet_signatures.h"
35 #include "reclaim.h"
36 
37 
42 
47 
51 static const struct GNUNET_CONFIGURATION_Handle *cfg;
52 
56 struct IdpClient;
57 
66 
71 
75  struct IdpClient *client;
76 
80  uint32_t r_id;
81 
86 };
87 
88 
97 
102 
106  struct IdpClient *client;
107 
112 
117 
121  uint32_t request_id;
122 };
123 
124 
128 struct IdpClient {
132  struct IdpClient *prev;
133 
137  struct IdpClient *next;
138 
143 
148 
155 
162 
167 
172 
177 
182 
187 
192 
197 
202 
207 
216 
221 };
222 
223 
232 
237 
241  struct IdpClient *client;
242 
247 
248 
253 
258 
263 
268 
273 
277  char *label;
278 
282  uint32_t r_id;
283 };
284 
285 
294 
299 
303  struct IdpClient *client;
304 
309 
313  struct GNUNET_CRYPTO_EcdsaPublicKey identity_pkey;
314 
319 
324 
329 
333  uint32_t r_id;
334 };
335 
336 
345 
350 
354  struct IdpClient *client;
355 
359  uint32_t r_id;
360 
365 };
366 
367 
376 
381 
385  struct IdpClient *client;
386 
391 
395  uint32_t r_id;
396 };
397 
398 
407 
412 
416  struct IdpClient *client;
417 
421  uint32_t r_id;
422 };
423 
424 
428 static struct IdpClient *client_list_head = NULL;
429 
433 static struct IdpClient *client_list_tail = NULL;
434 
435 
441 static void
443 {
444  struct TicketRecordsEntry *le;
445 
446  if (NULL != adh->ns_it)
448  if (NULL != adh->ns_qe)
450  if (NULL != adh->label)
451  GNUNET_free(adh->label);
452  if (NULL != adh->claim)
453  GNUNET_free(adh->claim);
454  while (NULL != (le = adh->tickets_to_update_head))
455  {
458  le);
459  if (NULL != le->label)
460  GNUNET_free(le->label);
461  if (NULL != le->data)
462  GNUNET_free(le->data);
463  GNUNET_free(le);
464  }
465  GNUNET_free(adh);
466 }
467 
468 
474 static void
476 {
477  if (NULL != ash->ns_qe)
479  if (NULL != ash->claim)
480  GNUNET_free(ash->claim);
481  GNUNET_free(ash);
482 }
483 
484 
490 static void
492 {
493  struct AttributeIterator *ai;
494  struct TicketIteration *ti;
495  struct TicketRevocationOperation *rop;
496  struct TicketIssueOperation *iss;
497  struct ConsumeTicketOperation *ct;
498  struct AttributeStoreHandle *as;
499  struct AttributeDeleteHandle *adh;
500 
501  while (NULL != (iss = idp->issue_op_head))
502  {
504  GNUNET_free(iss);
505  }
506  while (NULL != (ct = idp->consume_op_head))
507  {
509  idp->consume_op_tail,
510  ct);
511  if (NULL != ct->ch)
513  GNUNET_free(ct);
514  }
515  while (NULL != (as = idp->store_op_head))
516  {
518  cleanup_as_handle(as);
519  }
520  while (NULL != (adh = idp->delete_op_head))
521  {
523  cleanup_adh(adh);
524  }
525 
526  while (NULL != (ai = idp->attr_iter_head))
527  {
529  GNUNET_free(ai);
530  }
531  while (NULL != (rop = idp->revoke_op_head))
532  {
534  if (NULL != rop->rh)
536  GNUNET_free(rop);
537  }
538  while (NULL != (ti = idp->ticket_iter_head))
539  {
541  idp->ticket_iter_tail,
542  ti);
543  if (NULL != ti->iter)
545  GNUNET_free(ti);
546  }
547  GNUNET_free(idp);
548 }
549 
550 
554 static void
556 {
557  struct IdpClient *cl;
558 
559  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
560 
561  while (NULL != (cl = client_list_head))
562  {
563  GNUNET_CONTAINER_DLL_remove(client_list_head,
564  client_list_tail,
565  cl);
566  cleanup_client(cl);
567  }
569  if (NULL != timeout_task)
570  GNUNET_SCHEDULER_cancel(timeout_task);
571  if (NULL != nsh)
573 }
574 
575 
581 static void
582 do_shutdown(void *cls)
583 {
584  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Shutting down...\n");
585  cleanup();
586 }
587 
588 
597 static void
599  uint32_t r_id,
600  const struct GNUNET_RECLAIM_Ticket *ticket,
601  uint32_t success)
602 {
603  struct TicketResultMessage *irm;
604  struct GNUNET_MQ_Envelope *env;
605 
606  env = GNUNET_MQ_msg(irm,
608  if (NULL != ticket)
609  {
610  irm->ticket = *ticket;
611  }
612  // TODO add success member
613  irm->id = htonl(r_id);
614  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
615  GNUNET_MQ_send(client->mq, env);
616 }
617 
618 
627 static void
630  int32_t success,
631  const char *emsg)
632 {
633  struct TicketIssueOperation *tio = cls;
634 
635  if (GNUNET_OK != success)
636  {
637  send_ticket_result(tio->client, tio->r_id, NULL, GNUNET_SYSERR);
639  tio->client->issue_op_tail,
640  tio);
641  GNUNET_free(tio);
642  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Error issuing ticket: %s\n", emsg);
643  return;
644  }
645  send_ticket_result(tio->client, tio->r_id, ticket, GNUNET_SYSERR);
647  tio->client->issue_op_tail,
648  tio);
649  GNUNET_free(tio);
650 }
651 
652 
660 static int
661 check_issue_ticket_message(void *cls, const struct IssueTicketMessage *im)
662 {
663  uint16_t size;
664 
665  size = ntohs(im->header.size);
666  if (size <= sizeof(struct IssueTicketMessage))
667  {
668  GNUNET_break(0);
669  return GNUNET_SYSERR;
670  }
671  return GNUNET_OK;
672 }
673 
674 
681 static void
683 {
684  struct TicketIssueOperation *tio;
685  struct IdpClient *idp = cls;
687  size_t attrs_len;
688 
689  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n");
690  tio = GNUNET_new(struct TicketIssueOperation);
691  attrs_len = ntohs(im->attr_len);
692  attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize((char *)&im[1], attrs_len);
693  tio->r_id = ntohl(im->id);
694  tio->client = idp;
696  RECLAIM_TICKETS_issue(&im->identity,
697  attrs,
698  &im->rp,
700  tio);
703 }
704 
705 
706 
707 /**********************************************************
708 * Revocation
709 **********************************************************/
710 
717 static void
718 revoke_result_cb(void *cls, int32_t success)
719 {
720  struct TicketRevocationOperation *rop = cls;
721  struct GNUNET_MQ_Envelope *env;
722  struct RevokeTicketResultMessage *trm;
723 
724  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending REVOKE_TICKET_RESULT message\n");
725  rop->rh = NULL;
727  trm->id = htonl(rop->r_id);
728  trm->success = htonl(success);
729  GNUNET_MQ_send(rop->client->mq, env);
731  rop->client->revoke_op_tail,
732  rop);
733  GNUNET_free(rop);
734 }
735 
736 
744 static int
746 {
747  uint16_t size;
748 
749  size = ntohs(im->header.size);
750  if (size != sizeof(struct RevokeTicketMessage))
751  {
752  GNUNET_break(0);
753  return GNUNET_SYSERR;
754  }
755  return GNUNET_OK;
756 }
757 
758 
765 static void
767 {
768  struct TicketRevocationOperation *rop;
769  struct IdpClient *idp = cls;
770 
771  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n");
773  rop->r_id = ntohl(rm->id);
774  rop->client = idp;
776  rop->rh
779 }
780 
781 
791 static void
794  const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
795  int32_t success,
796  const char *emsg)
797 {
798  struct ConsumeTicketOperation *cop = cls;
799  struct ConsumeTicketResultMessage *crm;
800  struct GNUNET_MQ_Envelope *env;
801  char *data_tmp;
802  size_t attrs_len;
803 
804  if (GNUNET_OK != success)
805  {
806  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg);
807  }
809  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending CONSUME_TICKET_RESULT message\n");
810  env = GNUNET_MQ_msg_extra(crm,
811  attrs_len,
813  crm->id = htonl(cop->r_id);
814  crm->attrs_len = htons(attrs_len);
815  crm->identity = *identity;
816  crm->result = htonl(success);
817  data_tmp = (char *)&crm[1];
819  GNUNET_MQ_send(cop->client->mq, env);
821  cop->client->consume_op_tail,
822  cop);
823  GNUNET_free(cop);
824 }
825 
826 
833 static int
835 {
836  uint16_t size;
837 
838  size = ntohs(cm->header.size);
839  if (size != sizeof(struct ConsumeTicketMessage))
840  {
841  GNUNET_break(0);
842  return GNUNET_SYSERR;
843  }
844  return GNUNET_OK;
845 }
846 
847 
854 static void
856 {
857  struct ConsumeTicketOperation *cop;
858  struct IdpClient *idp = cls;
859 
860  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n");
861  cop = GNUNET_new(struct ConsumeTicketOperation);
862  cop->r_id = ntohl(cm->id);
863  cop->client = idp;
864  cop->ch
868 }
869 
870 /*****************************************
871 * Attribute store
872 *****************************************/
873 
874 
882 static void
883 attr_store_cont(void *cls, int32_t success, const char *emsg)
884 {
885  struct AttributeStoreHandle *ash = cls;
886  struct GNUNET_MQ_Envelope *env;
887  struct SuccessResultMessage *acr_msg;
888 
889  ash->ns_qe = NULL;
891  ash->client->store_op_tail,
892  ash);
893 
894  if (GNUNET_SYSERR == success)
895  {
897  "Failed to store attribute %s\n",
898  emsg);
899  cleanup_as_handle(ash);
901  return;
902  }
903 
904  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
906  acr_msg->id = htonl(ash->r_id);
907  acr_msg->op_result = htonl(GNUNET_OK);
908  GNUNET_MQ_send(ash->client->mq, env);
909  cleanup_as_handle(ash);
910 }
911 
912 
918 static void
919 attr_store_task(void *cls)
920 {
921  struct AttributeStoreHandle *ash = cls;
922  struct GNUNET_GNSRECORD_Data rd[1];
923  char *buf;
924  char *label;
925  size_t buf_size;
926 
927  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n");
929  buf = GNUNET_malloc(buf_size);
930  // Give the ash a new id if unset
931  if (0 == ash->claim->id)
932  ash->claim->id
935  label
936  = GNUNET_STRINGS_data_to_string_alloc(&ash->claim->id, sizeof(uint64_t));
937  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
938 
939  rd[0].data_size = buf_size;
940  rd[0].data = buf;
943  rd[0].expiration_time = ash->exp.rel_value_us;
945  &ash->identity,
946  label,
947  1,
948  rd,
950  ash);
951  GNUNET_free(buf);
952  GNUNET_free(label);
953 }
954 
955 
962 static int
964  const struct AttributeStoreMessage *sam)
965 {
966  uint16_t size;
967 
968  size = ntohs(sam->header.size);
969  if (size <= sizeof(struct AttributeStoreMessage))
970  {
971  GNUNET_break(0);
972  return GNUNET_SYSERR;
973  }
974  return GNUNET_OK;
975 }
976 
977 
984 static void
986  const struct AttributeStoreMessage *sam)
987 {
988  struct AttributeStoreHandle *ash;
989  struct IdpClient *idp = cls;
990  size_t data_len;
991 
992  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n");
993 
994  data_len = ntohs(sam->attr_len);
995 
996  ash = GNUNET_new(struct AttributeStoreHandle);
997  ash->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize((char *)&sam[1], data_len);
998 
999  ash->r_id = ntohl(sam->id);
1000  ash->identity = sam->identity;
1001  ash->exp.rel_value_us = GNUNET_ntohll(sam->exp);
1002  GNUNET_CRYPTO_ecdsa_key_get_public(&sam->identity, &ash->identity_pkey);
1003 
1005  ash->client = idp;
1008 }
1009 
1010 
1017 static void
1018 send_delete_response(struct AttributeDeleteHandle *adh, int32_t success)
1019 {
1020  struct GNUNET_MQ_Envelope *env;
1021  struct SuccessResultMessage *acr_msg;
1022 
1024  adh->client->delete_op_tail,
1025  adh);
1026 
1027  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1029  acr_msg->id = htonl(adh->r_id);
1030  acr_msg->op_result = htonl(success);
1031  GNUNET_MQ_send(adh->client->mq, env);
1032 }
1033 
1034 
1045 static void
1046 ticket_iter(void *cls,
1047  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1048  const char *label,
1049  unsigned int rd_count,
1050  const struct GNUNET_GNSRECORD_Data *rd)
1051 {
1052  struct AttributeDeleteHandle *adh = cls;
1053  struct TicketRecordsEntry *le;
1054  int has_changed = GNUNET_NO;
1055 
1056  for (int i = 0; i < rd_count; i++)
1057  {
1058  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
1059  continue;
1060  if (0 != memcmp(rd[i].data, &adh->claim->id, sizeof(uint64_t)))
1061  continue;
1063  "Attribute to delete found (%s)\n",
1064  adh->label);
1065  has_changed = GNUNET_YES;
1066  break;
1067  }
1068  if (GNUNET_YES == has_changed)
1069  {
1070  le = GNUNET_new(struct TicketRecordsEntry);
1071  le->data_size = GNUNET_GNSRECORD_records_get_size(rd_count, rd);
1072  le->data = GNUNET_malloc(le->data_size);
1073  le->rd_count = rd_count;
1074  le->label = GNUNET_strdup(label);
1075  GNUNET_GNSRECORD_records_serialize(rd_count, rd, le->data_size, le->data);
1078  le);
1079  }
1081 }
1082 
1083 
1088 static void
1089 update_tickets(void *cls);
1090 
1091 
1099 static void
1100 ticket_updated(void *cls, int32_t success, const char *emsg)
1101 {
1102  struct AttributeDeleteHandle *adh = cls;
1103 
1104  adh->ns_qe = NULL;
1106 }
1107 
1108 
1116 static void
1117 update_tickets(void *cls)
1118 {
1119  struct AttributeDeleteHandle *adh = cls;
1120  struct TicketRecordsEntry *le;
1121 
1122  if (NULL == adh->tickets_to_update_head)
1123  {
1125  "Finished updatding tickets, success\n");
1127  cleanup_adh(adh);
1128  return;
1129  }
1131  "Updating %s\n",
1133  le = adh->tickets_to_update_head;
1136  le);
1137  struct GNUNET_GNSRECORD_Data rd[le->rd_count];
1138  struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1];
1140  le->data,
1141  le->rd_count,
1142  rd))
1143  {
1145  "Unable to deserialize record data!\n");
1147  cleanup_adh(adh);
1148  return;
1149  }
1150  int j = 0;
1151  for (int i = 0; i < le->rd_count; i++)
1152  {
1154  && (0 == memcmp(rd[i].data, &adh->claim->id, sizeof(uint64_t))))
1155  continue;
1156  rd_new[j] = rd[i];
1157  j++;
1158  }
1160  &adh->identity,
1161  le->label,
1162  j,
1163  rd_new,
1164  &ticket_updated,
1165  adh);
1166  GNUNET_free(le->label);
1167  GNUNET_free(le->data);
1168  GNUNET_free(le);
1169 }
1170 
1171 
1177 static void
1179 {
1180  struct AttributeDeleteHandle *adh = cls;
1181 
1182  adh->ns_it = NULL;
1184 }
1185 
1186 
1192 static void
1194 {
1195  struct AttributeDeleteHandle *adh = cls;
1196 
1197  adh->ns_it = NULL;
1199  "Namestore error on delete %s\n",
1200  adh->label);
1202  cleanup_adh(adh);
1203 }
1204 
1205 
1212 static void
1214 {
1215  struct AttributeDeleteHandle *adh = cls;
1216 
1218  &adh->identity,
1219  &ticket_iter_err,
1220  adh,
1221  &ticket_iter,
1222  adh,
1223  &ticket_iter_fin,
1224  adh);
1225 }
1226 
1227 
1235 static void
1236 attr_delete_cont(void *cls, int32_t success, const char *emsg)
1237 {
1238  struct AttributeDeleteHandle *adh = cls;
1239 
1240  adh->ns_qe = NULL;
1241  if (GNUNET_SYSERR == success)
1242  {
1244  "Error deleting attribute %s\n",
1245  adh->label);
1247  cleanup_adh(adh);
1248  return;
1249  }
1250  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1252 }
1253 
1254 
1261 static int
1263  const struct AttributeDeleteMessage *dam)
1264 {
1265  uint16_t size;
1266 
1267  size = ntohs(dam->header.size);
1268  if (size <= sizeof(struct AttributeDeleteMessage))
1269  {
1270  GNUNET_break(0);
1271  return GNUNET_SYSERR;
1272  }
1273  return GNUNET_OK;
1274 }
1275 
1276 
1283 static void
1285  const struct AttributeDeleteMessage *dam)
1286 {
1287  struct AttributeDeleteHandle *adh;
1288  struct IdpClient *idp = cls;
1289  size_t data_len;
1290 
1291  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n");
1292 
1293  data_len = ntohs(dam->attr_len);
1294 
1295  adh = GNUNET_new(struct AttributeDeleteHandle);
1296  adh->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize((char *)&dam[1], data_len);
1297 
1298  adh->r_id = ntohl(dam->id);
1299  adh->identity = dam->identity;
1300  adh->label
1301  = GNUNET_STRINGS_data_to_string_alloc(&adh->claim->id, sizeof(uint64_t));
1303  adh->client = idp;
1306  &adh->identity,
1307  adh->label,
1308  0,
1309  NULL,
1311  adh);
1312 }
1313 
1314 
1315 /*************************************************
1316 * Attrubute iteration
1317 *************************************************/
1318 
1319 
1325 static void
1327 {
1328  struct AttributeIterator *ai = cls;
1329  struct GNUNET_MQ_Envelope *env;
1330  struct AttributeResultMessage *arm;
1331 
1332  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
1334  arm->id = htonl(ai->request_id);
1335  arm->attr_len = htons(0);
1336  GNUNET_MQ_send(ai->client->mq, env);
1338  ai->client->attr_iter_tail,
1339  ai);
1340  GNUNET_free(ai);
1341 }
1342 
1348 static void
1350 {
1351  struct AttributeIterator *ai = cls;
1352 
1353  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n");
1354  attr_iter_finished(ai);
1355 }
1356 
1357 
1367 static void
1368 attr_iter_cb(void *cls,
1369  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1370  const char *label,
1371  unsigned int rd_count,
1372  const struct GNUNET_GNSRECORD_Data *rd)
1373 {
1374  struct AttributeIterator *ai = cls;
1375  struct AttributeResultMessage *arm;
1376  struct GNUNET_MQ_Envelope *env;
1377  char *data_tmp;
1378 
1379  if (rd_count != 1)
1380  {
1382  return;
1383  }
1384 
1386  {
1388  return;
1389  }
1390  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", label);
1391  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
1392  env = GNUNET_MQ_msg_extra(arm,
1393  rd->data_size,
1395  arm->id = htonl(ai->request_id);
1396  arm->attr_len = htons(rd->data_size);
1398  data_tmp = (char *)&arm[1];
1399  GNUNET_memcpy(data_tmp, rd->data, rd->data_size);
1400  GNUNET_MQ_send(ai->client->mq, env);
1401 }
1402 
1403 
1410 static void
1412  const struct AttributeIterationStartMessage *ais_msg)
1413 {
1414  struct IdpClient *idp = cls;
1415  struct AttributeIterator *ai;
1416 
1418  "Received ATTRIBUTE_ITERATION_START message\n");
1419  ai = GNUNET_new(struct AttributeIterator);
1420  ai->request_id = ntohl(ais_msg->id);
1421  ai->client = idp;
1422  ai->identity = ais_msg->identity;
1423 
1426  &ai->identity,
1427  &attr_iter_error,
1428  ai,
1429  &attr_iter_cb,
1430  ai,
1432  ai);
1434 }
1435 
1436 
1443 static void
1445  const struct AttributeIterationStopMessage *ais_msg)
1446 {
1447  struct IdpClient *idp = cls;
1448  struct AttributeIterator *ai;
1449  uint32_t rid;
1450 
1452  "Received `%s' message\n",
1453  "ATTRIBUTE_ITERATION_STOP");
1454  rid = ntohl(ais_msg->id);
1455  for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
1456  if (ai->request_id == rid)
1457  break;
1458  if (NULL == ai)
1459  {
1460  GNUNET_break(0);
1462  return;
1463  }
1465  GNUNET_free(ai);
1467 }
1468 
1469 
1476 static void
1478  const struct AttributeIterationNextMessage *ais_msg)
1479 {
1480  struct IdpClient *idp = cls;
1481  struct AttributeIterator *ai;
1482  uint32_t rid;
1483 
1485  "Received ATTRIBUTE_ITERATION_NEXT message\n");
1486  rid = ntohl(ais_msg->id);
1487  for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
1488  if (ai->request_id == rid)
1489  break;
1490  if (NULL == ai)
1491  {
1492  GNUNET_break(0);
1494  return;
1495  }
1498 }
1499 
1500 /******************************************************
1501 * Ticket iteration
1502 ******************************************************/
1503 
1510 static void
1512 {
1513  struct TicketIteration *ti = cls;
1514  struct GNUNET_MQ_Envelope *env;
1515  struct TicketResultMessage *trm;
1516 
1518  if (NULL == ticket)
1519  {
1520  /* send empty response to indicate end of list */
1522  ti->client->ticket_iter_tail,
1523  ti);
1524  }
1525  else
1526  {
1527  trm->ticket = *ticket;
1528  }
1529  trm->id = htonl(ti->r_id);
1530  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
1531  GNUNET_MQ_send(ti->client->mq, env);
1532  if (NULL == ticket)
1533  GNUNET_free(ti);
1534 }
1535 
1536 
1543 static void
1545  void *cls,
1546  const struct TicketIterationStartMessage *tis_msg)
1547 {
1548  struct IdpClient *client = cls;
1549  struct TicketIteration *ti;
1550 
1552  "Received TICKET_ITERATION_START message\n");
1553  ti = GNUNET_new(struct TicketIteration);
1554  ti->r_id = ntohl(tis_msg->id);
1555  ti->client = client;
1556 
1558  client->ticket_iter_tail,
1559  ti);
1560  ti->iter
1563 }
1564 
1565 
1572 static void
1574  const struct TicketIterationStopMessage *tis_msg)
1575 {
1576  struct IdpClient *client = cls;
1577  struct TicketIteration *ti;
1578  uint32_t rid;
1579 
1581  "Received `%s' message\n",
1582  "TICKET_ITERATION_STOP");
1583  rid = ntohl(tis_msg->id);
1584  for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
1585  if (ti->r_id == rid)
1586  break;
1587  if (NULL == ti)
1588  {
1589  GNUNET_break(0);
1591  return;
1592  }
1595  client->ticket_iter_tail,
1596  ti);
1597  GNUNET_free(ti);
1599 }
1600 
1601 
1608 static void
1610  const struct TicketIterationNextMessage *tis_msg)
1611 {
1612  struct IdpClient *client = cls;
1613  struct TicketIteration *ti;
1614  uint32_t rid;
1615 
1617  "Received TICKET_ITERATION_NEXT message\n");
1618  rid = ntohl(tis_msg->id);
1619  for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
1620  if (ti->r_id == rid)
1621  break;
1622  if (NULL == ti)
1623  {
1624  GNUNET_break(0);
1626  return;
1627  }
1630 }
1631 
1632 
1640 static void
1641 run(void *cls,
1642  const struct GNUNET_CONFIGURATION_Handle *c,
1643  struct GNUNET_SERVICE_Handle *server)
1644 {
1645  cfg = c;
1646 
1647  if (GNUNET_OK != RECLAIM_TICKETS_init(cfg))
1648  {
1650  "Unable to initialize TICKETS subsystem.\n");
1652  return;
1653  }
1654  // Connect to identity and namestore services
1655  nsh = GNUNET_NAMESTORE_connect(cfg);
1656  if (NULL == nsh)
1657  {
1659  "error connecting to namestore");
1660  }
1661 
1663 }
1664 
1665 
1673 static void
1675  struct GNUNET_SERVICE_Client *client,
1676  void *app_ctx)
1677 {
1678  struct IdpClient *idp = app_ctx;
1679 
1680  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
1681  GNUNET_CONTAINER_DLL_remove(client_list_head,
1682  client_list_tail,
1683  idp);
1684  cleanup_client(idp);
1685 }
1686 
1687 
1696 static void *
1698  struct GNUNET_SERVICE_Client *client,
1699  struct GNUNET_MQ_Handle *mq)
1700 {
1701  struct IdpClient *idp;
1702 
1703  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
1704  idp = GNUNET_new(struct IdpClient);
1705  idp->client = client;
1706  idp->mq = mq;
1707  GNUNET_CONTAINER_DLL_insert(client_list_head,
1708  client_list_tail,
1709  idp);
1710  return idp;
1711 }
1712 
1713 
1718  "reclaim",
1720  &run,
1723  NULL,
1724  GNUNET_MQ_hd_var_size(attribute_store_message,
1726  struct AttributeStoreMessage,
1727  NULL),
1728  GNUNET_MQ_hd_var_size(attribute_delete_message,
1730  struct AttributeDeleteMessage,
1731  NULL),
1736  NULL),
1737  GNUNET_MQ_hd_fixed_size(iteration_next,
1740  NULL),
1741  GNUNET_MQ_hd_fixed_size(iteration_stop,
1744  NULL),
1745  GNUNET_MQ_hd_var_size(issue_ticket_message,
1747  struct IssueTicketMessage,
1748  NULL),
1749  GNUNET_MQ_hd_var_size(consume_ticket_message,
1751  struct ConsumeTicketMessage,
1752  NULL),
1753  GNUNET_MQ_hd_fixed_size(ticket_iteration_start,
1756  NULL),
1757  GNUNET_MQ_hd_fixed_size(ticket_iteration_next,
1760  NULL),
1761  GNUNET_MQ_hd_fixed_size(ticket_iteration_stop,
1764  NULL),
1765  GNUNET_MQ_hd_var_size(revoke_ticket_message,
1767  struct RevokeTicketMessage,
1768  NULL),
1770 /* end of gnunet-service-reclaim.c */
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Handle for attribute deletion request.
struct TicketIteration * ticket_iter_tail
Tail of DLL of ticket iteration ops.
#define GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:353
static void attr_delete_cont(void *cls, int32_t success, const char *emsg)
Attribute deleted callback.
Ticket result message.
Definition: reclaim.h:344
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:307
The authorization ticket.
static void update_tickets(void *cls)
Recursion prototype for function.
GNUNET_NETWORK_STRUCT_END ssize_t GNUNET_GNSRECORD_records_get_size(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Calculate how many bytes we will need to serialize the given records.
static void revoke_result_cb(void *cls, int32_t success)
Handles revocation result.
static struct GNUNET_CADET_ListTunnels * tio
Active tunnel listing operation.
Definition: gnunet-cadet.c:112
struct GNUNET_RECLAIM_Ticket ticket
The new ticket.
Definition: reclaim.h:358
static void handle_ticket_iteration_start(void *cls, const struct TicketIterationStartMessage *tis_msg)
Client requests a ticket iteration.
struct TicketRecordsEntry * tickets_to_update_tail
Tickets to update.
struct TicketIssueOperation * prev
DLL.
Attribute list is returned from the idp.
Definition: reclaim.h:389
static void ticket_iter_err(void *cls)
Error collecting affected tickets.
uint64_t rel_value_us
The actual value.
struct IdpClient * client
Client connection.
Ticket revocation request handle.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET.
Definition: reclaim.h:297
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT
static void consume_result_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, int32_t success, const char *emsg)
Handle a ticket consume result.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:222
Ticket consume message.
Definition: reclaim.h:364
Handle to a service.
Definition: service.c:114
struct ConsumeTicketOperation * consume_op_head
Head of DLL of ticket consume ops.
An idp client.
static void ticket_iter(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Namestore iteration within attribute deletion.
Start a attribute iteration for the given identity.
Definition: reclaim.h:156
struct AttributeIterator * attr_iter_tail
Tail of the DLL of Attribute iteration operations in progress initiated by this client.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
Ticket issue operation handle.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1284
ssize_t GNUNET_GNSRECORD_records_serialize(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, size_t dest_size, char *dest)
Serialize the given records to the given destination buffer.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT)...
static void attr_iter_error(void *cls)
Error iterating over attributes.
static int check_attribute_store_message(void *cls, const struct AttributeStoreMessage *sam)
Check an attribute store message.
Stop attribute iteration for the given operation.
Definition: reclaim.h:193
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:115
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR
Record type for identity attributes (of RECLAIM).
void RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter)
Stop a running ticket iteration.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:302
struct RECLAIM_TICKETS_Iterator * iter
The ticket iterator.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:130
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:398
struct AttributeIterator * prev
Previous element in the DLL.
struct TicketRevocationOperation * revoke_op_tail
Tail of DLL of ticket revocation ops.
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT
struct AttributeDeleteHandle * prev
DLL.
static void attr_store_cont(void *cls, int32_t success, const char *emsg)
Attribute store result handler.
Use to delete an identity attribute.
Definition: reclaim.h:73
struct IdpClient * client
Client connection.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
static void handle_attribute_store_message(void *cls, const struct AttributeStoreMessage *sam)
Handle an attribute store message.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
Called whenever a client is disconnected.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
#define GNUNET_NO
Definition: gnunet_common.h:78
static void handle_attribute_delete_message(void *cls, const struct AttributeDeleteMessage *dam)
Handle attribute deletion.
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
size_t data_size
Number of bytes in data.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record...
Private ECC key encoded for transmission.
struct TicketIssueOperation * issue_op_head
Head of DLL of ticket issue ops.
static void cleanup_client(struct IdpClient *idp)
Cleanup client.
uint32_t r_id
The operation id fot the iteration in the response for the client.
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:87
int GNUNET_GNSRECORD_records_deserialize(size_t len, const char *src, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *dest)
Deserialize the given records to the given destination.
uint32_t result
Result.
Definition: reclaim.h:403
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
struct RECLAIM_TICKETS_Iterator * RECLAIM_TICKETS_iteration_start(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, RECLAIM_TICKETS_TicketIter cb, void *cb_cls)
Iterate over all tickets issued by an identity.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Key of the zone we are iterating over.
uint32_t r_id
request id
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
Use to store an identity attribute.
Definition: reclaim.h:40
struct AttributeStoreHandle * store_op_head
Head of DLL of attribute store ops.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Add a client to our list of active clients.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET.
Definition: reclaim.h:265
struct IdpClient * client
Client which intiated this zone iteration.
static void handle_consume_ticket_message(void *cls, const struct ConsumeTicketMessage *cm)
Handle a consume ticket message.
struct RECLAIM_TICKETS_RevokeHandle * rh
Revocation handle.
Ask for next result of ticket iteration for the given operation.
Definition: reclaim.h:229
struct GNUNET_SERVICE_Client * client
The client.
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
struct TicketIteration * ticket_iter_head
Head of DLL of ticket iteration ops.
static void cleanup_as_handle(struct AttributeStoreHandle *ash)
Cleanup attribute store handle.
Handle to a client that is connected to a service.
Definition: service.c:246
Common type definitions for the identity provider service and API.
static char * zone
Name of the zone we manage.
static void handle_iteration_start(void *cls, const struct AttributeIterationStartMessage *ais_msg)
Iterate over zone to get attributes.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:238
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Iterator.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
void GNUNET_RECLAIM_ATTRIBUTE_list_destroy(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
Destroy claim list.
static void handle_ticket_iteration_next(void *cls, const struct TicketIterationNextMessage *tis_msg)
Client requests next result.
struct AttributeStoreHandle * prev
DLL.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
Handle for a zone iterator operation.
uint32_t r_id
request id
static void cleanup()
Cleanup task.
static void attr_store_task(void *cls)
Add a new attribute.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:202
const void * data
Binary value stored in the DNS record.
struct GNUNET_TIME_Relative exp
The attribute expiration interval.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:77
static void send_delete_response(struct AttributeDeleteHandle *adh, int32_t success)
Send a deletion success response.
struct AttributeIterator * next
Next element in the DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to store.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
static void ticket_iter_fin(void *cls)
Done collecting affected tickets, start updating.
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:378
Connection to the NAMESTORE service.
struct TicketIteration * prev
DLL.
Stop ticket iteration for the given operation.
Definition: reclaim.h:245
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:186
uint64_t expiration_time
Expiration time for the DNS record.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
struct GNUNET_RECLAIM_Ticket ticket
The ticket to revoke.
Definition: reclaim.h:317
unsigned int rd_count
Record count.
Handle to a consume operation.
static struct IdpClient * client_list_head
Client list.
Handle for attribute store request.
struct ConsumeTicketOperation * next
DLL.
static char buf[2048]
void RECLAIM_TICKETS_iteration_next(struct RECLAIM_TICKETS_Iterator *iter)
Continue ticket iteration.
struct AttributeStoreHandle * store_op_tail
Tail of DLL of attribute store ops.
static void issue_ticket_result_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket, int32_t success, const char *emsg)
Issue ticket result.
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:170
struct IdpClient * client
Client connection.
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:54
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:165
Ticket issue message.
Definition: reclaim.h:261
struct IdpClient * prev
DLL.
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2315
struct GNUNET_CRYPTO_EcdsaPublicKey identity_pkey
Identity pubkey.
struct IdpClient * client
Client connection.
struct TicketRevocationOperation * next
DLL.
struct TicketIteration * next
DLL.
Attribute store/delete response message.
Definition: reclaim.h:101
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:44
void RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth)
Cancel a consume operation.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
uint32_t request_id
The operation id fot the zone iteration in the response for the client.
static void handle_revoke_ticket_message(void *cls, const struct RevokeTicketMessage *rm)
Handle a revocation message to a ticket.
uint32_t attr_len
length of serialized attribute list
Definition: reclaim.h:285
struct RECLAIM_TICKETS_ConsumeHandle * ch
Ticket consume handle.
static void start_ticket_update(void *cls)
Start processing tickets which may still contain reference to deleted attribute.
char * label
Attribute label.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_RECLAIM_Ticket ticket
The ticket to consume.
Definition: reclaim.h:383
static unsigned int size
Size of the "table".
Definition: peer.c:66
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:241
An QueueEntry used to store information for a pending NAMESTORE record operation. ...
Definition: namestore_api.c:53
Ask for next result of attribute iteration for the given operation.
Definition: reclaim.h:177
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
struct IdpClient * client
Client connection.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct ConsumeTicketOperation * consume_op_tail
Tail of DLL of ticket consume ops.
void RECLAIM_TICKETS_issue(const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, RECLAIM_TICKETS_TicketResult cb, void *cb_cls)
Issue a new reclaim ticket, thereby authorizing the audience to access the set of provided attributes...
struct TicketRevocationOperation * revoke_op_head
Head of DLL of ticket revocation ops.
static void iteration_start()
struct TicketRevocationOperation * prev
DLL.
GNUNET_SERVICE_MAIN("reclaim", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(attribute_store_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, struct AttributeStoreMessage, NULL), GNUNET_MQ_hd_var_size(attribute_delete_message, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, struct AttributeDeleteMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, struct AttributeIterationStartMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, struct AttributeIterationNextMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, struct AttributeIterationStopMessage, NULL), GNUNET_MQ_hd_var_size(issue_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, struct IssueTicketMessage, NULL), GNUNET_MQ_hd_var_size(consume_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, struct ConsumeTicketMessage, NULL), GNUNET_MQ_hd_fixed_size(ticket_iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, struct TicketIterationStartMessage, NULL), GNUNET_MQ_hd_fixed_size(ticket_iteration_next, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, struct TicketIterationNextMessage, NULL), GNUNET_MQ_hd_fixed_size(ticket_iteration_stop, GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP, struct TicketIterationStopMessage, NULL), GNUNET_MQ_hd_var_size(revoke_ticket_message, GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET, struct RevokeTicketMessage, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
static void ticket_updated(void *cls, int32_t success, const char *emsg)
Callback called when a ticket was updated.
static void handle_ticket_iteration_stop(void *cls, const struct TicketIterationStopMessage *tis_msg)
Client has had enough tickets.
void RECLAIM_TICKETS_revoke_cancel(struct RECLAIM_TICKETS_RevokeHandle *rh)
Cancel a revocation.
struct AttributeDeleteHandle * delete_op_head
Head of DLL of attribute delete ops.
struct TicketIssueOperation * issue_op_tail
Tail of DLL of ticket issue ops.
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START
#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
Handle to a message queue.
Definition: mq.c:84
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP
A ticket iteration operation.
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:418
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
Get required size for serialization buffer.
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START
Ticket revocation request handle.
static void handle_iteration_next(void *cls, const struct AttributeIterationNextMessage *ais_msg)
Client requests next attribute from iterator.
uint32_t record_type
Type of the GNS/DNS record.
Ticket revoke message.
Definition: reclaim.h:323
struct RECLAIM_TICKETS_RevokeHandle * RECLAIM_TICKETS_revoke(const struct GNUNET_RECLAIM_Ticket *ticket, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, RECLAIM_TICKETS_RevokeCallback cb, void *cb_cls)
Revoke a ticket.
configuration data
Definition: configuration.c:83
struct AttributeStoreHandle * next
DLL.
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:217
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:332
void RECLAIM_TICKETS_deinit(void)
Close handles and clean up.
Attribute is returned from the idp.
Definition: reclaim.h:121
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:135
A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
Start a ticket iteration for the given identity.
Definition: reclaim.h:208
struct AttributeDeleteHandle * next
DLL.
struct RECLAIM_TICKETS_ConsumeHandle * RECLAIM_TICKETS_consume(const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, const struct GNUNET_RECLAIM_Ticket *ticket, RECLAIM_TICKETS_ConsumeCallback cb, void *cb_cls)
Consume a ticket.
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:408
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:131
struct AttributeDeleteHandle * delete_op_tail
Tail of DLL of attribute delete ops.
static void attr_iter_cb(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Got record.
Handle for ticket consume request.
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The public key of the identity.
Definition: reclaim.h:145
static void handle_issue_ticket_message(void *cls, const struct IssueTicketMessage *im)
Handle ticket issue message.
static struct GNUNET_NAMESTORE_Handle * nsh
Namestore handle.
#define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP
struct AttributeIterator * attr_iter_head
Head of the DLL of Attribute iteration operations in progress initiated by this client.
#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
static int check_consume_ticket_message(void *cls, const struct ConsumeTicketMessage *cm)
Check a consume ticket message.
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, char *result)
Serialize an attribute.
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
QueueEntry.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:351
static void cleanup_adh(struct AttributeDeleteHandle *adh)
Cleanup attribute delete handle.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:254
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:921
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET.
Definition: reclaim.h:368
static void send_ticket_result(const struct IdpClient *client, uint32_t r_id, const struct GNUNET_RECLAIM_Ticket *ticket, uint32_t success)
Sends a ticket result message to the client.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
static void do_shutdown(void *cls)
Shutdown task.
This flag is currently unused; former RF_PENDING flag.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute to delete.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *server)
Main function that will be run.
struct IdpClient * next
DLL.
struct TicketIssueOperation * next
DLL.
static int check_revoke_ticket_message(void *cls, const struct RevokeTicketMessage *im)
Check revocation message format.
static void attr_iter_finished(void *cls)
Done iterating over attributes.
struct IdpClient * client
IDP client which intiated this zone iteration.
uint32_t data
The data value.
static void ticket_iter_cb(void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
Got a ticket.
int RECLAIM_TICKETS_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize tickets component.
uint32_t success
Revocation result.
Definition: reclaim.h:337
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2234
size_t GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size(const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
Get required size for serialization buffer.
static int check_attribute_delete_message(void *cls, const struct AttributeDeleteMessage *dam)
Check attribute delete message format.
struct ConsumeTicketOperation * prev
DLL.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:373
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(const char *data, size_t data_size)
Deserialize an attribute list.
static struct IdpClient * client_list_tail
Client list.
size_t GNUNET_RECLAIM_ATTRIBUTE_list_serialize(const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, char *result)
Serialize an attribute list.
An attribute iteration operation.
#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * GNUNET_RECLAIM_ATTRIBUTE_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
#define GNUNET_malloc(size)
Wrapper around malloc.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:110
static int check_issue_ticket_message(void *cls, const struct IssueTicketMessage *im)
Check issue ticket message.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_NAMESTORE_ZoneIterator * ns_it
Namestore iterator.
static void handle_iteration_stop(void *cls, const struct AttributeIterationStopMessage *ais_msg)
Handle iteration stop message from client.
Ticket revoke message.
Definition: reclaim.h:293
Time for relative time used by GNUnet, in microseconds.
#define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
High-quality operations are desired.