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 
62 {
67 
72 
76  struct IdpClient *client;
77 
81  uint32_t r_id;
82 
87 };
88 
89 
94 {
99 
104 
108  struct IdpClient *client;
109 
114 
119 
123  uint32_t request_id;
124 };
125 
126 
130 struct IdpClient
131 {
135  struct IdpClient *prev;
136 
140  struct IdpClient *next;
141 
146 
151 
158 
165 
170 
175 
180 
185 
190 
195 
200 
205 
210 
219 
224 };
225 
226 
231 {
236 
241 
245  struct IdpClient *client;
246 
251 
252 
257 
262 
267 
272 
277 
281  char *label;
282 
286  uint32_t r_id;
287 };
288 
289 
294 {
299 
304 
308  struct IdpClient *client;
309 
314 
318  struct GNUNET_CRYPTO_EcdsaPublicKey identity_pkey;
319 
324 
329 
334 
338  uint32_t r_id;
339 };
340 
341 
346 {
351 
356 
360  struct IdpClient *client;
361 
365  uint32_t r_id;
366 
371 };
372 
373 
378 {
383 
388 
392  struct IdpClient *client;
393 
398 
402  uint32_t r_id;
403 };
404 
405 
410 {
415 
420 
424  struct IdpClient *client;
425 
429  uint32_t r_id;
430 };
431 
432 
436 static struct IdpClient *client_list_head = NULL;
437 
441 static struct IdpClient *client_list_tail = NULL;
442 
443 
449 static void
451 {
452  struct TicketRecordsEntry *le;
453  if (NULL != adh->ns_it)
455  if (NULL != adh->ns_qe)
457  if (NULL != adh->label)
458  GNUNET_free (adh->label);
459  if (NULL != adh->claim)
460  GNUNET_free (adh->claim);
461  while (NULL != (le = adh->tickets_to_update_head)) {
464  le);
465  if (NULL != le->label)
466  GNUNET_free (le->label);
467  if (NULL != le->data)
468  GNUNET_free (le->data);
469  GNUNET_free (le);
470  }
471  GNUNET_free (adh);
472 }
473 
474 
480 static void
482 {
483  if (NULL != ash->ns_qe)
485  if (NULL != ash->claim)
486  GNUNET_free (ash->claim);
487  GNUNET_free (ash);
488 }
489 
490 
496 static void
498 {
499  struct AttributeIterator *ai;
500  struct TicketIteration *ti;
501  struct TicketRevocationOperation *rop;
502  struct TicketIssueOperation *iss;
503  struct ConsumeTicketOperation *ct;
504  struct AttributeStoreHandle *as;
505  struct AttributeDeleteHandle *adh;
506 
507  while (NULL != (iss = idp->issue_op_head)) {
509  GNUNET_free (iss);
510  }
511  while (NULL != (ct = idp->consume_op_head)) {
513  idp->consume_op_tail,
514  ct);
515  if (NULL != ct->ch)
517  GNUNET_free (ct);
518  }
519  while (NULL != (as = idp->store_op_head)) {
521  cleanup_as_handle (as);
522  }
523  while (NULL != (adh = idp->delete_op_head)) {
525  cleanup_adh (adh);
526  }
527 
528  while (NULL != (ai = idp->attr_iter_head)) {
530  GNUNET_free (ai);
531  }
532  while (NULL != (rop = idp->revoke_op_head)) {
534  if (NULL != rop->rh)
536  GNUNET_free (rop);
537  }
538  while (NULL != (ti = idp->ticket_iter_head)) {
540  idp->ticket_iter_tail,
541  ti);
542  if (NULL != ti->iter)
544  GNUNET_free (ti);
545  }
546  GNUNET_free (idp);
547 }
548 
549 
553 static void
555 {
556  struct IdpClient *cl;
557  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
558 
559  while (NULL != (cl = client_list_head))
560  {
561  GNUNET_CONTAINER_DLL_remove (client_list_head,
562  client_list_tail,
563  cl);
564  cleanup_client (cl);
565  }
567  if (NULL != timeout_task)
568  GNUNET_SCHEDULER_cancel (timeout_task);
569  if (NULL != nsh)
571 }
572 
573 
579 static void
580 do_shutdown (void *cls)
581 {
582  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down...\n");
583  cleanup ();
584 }
585 
586 
595 static void
597  uint32_t r_id,
598  const struct GNUNET_RECLAIM_Ticket *ticket,
599  uint32_t success)
600 {
601  struct TicketResultMessage *irm;
602  struct GNUNET_MQ_Envelope *env;
603 
604  env = GNUNET_MQ_msg (irm,
606  if (NULL != ticket) {
607  irm->ticket = *ticket;
608  }
609  // TODO add success member
610  irm->id = htonl (r_id);
611  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
612  GNUNET_MQ_send (client->mq, env);
613 }
614 
615 
624 static void
627  int32_t success,
628  const char *emsg)
629 {
630  struct TicketIssueOperation *tio = cls;
631  if (GNUNET_OK != success) {
632  send_ticket_result (tio->client, tio->r_id, NULL, GNUNET_SYSERR);
634  tio->client->issue_op_tail,
635  tio);
636  GNUNET_free (tio);
637  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error issuing ticket: %s\n", emsg);
638  return;
639  }
640  send_ticket_result (tio->client, tio->r_id, ticket, GNUNET_SYSERR);
642  tio->client->issue_op_tail,
643  tio);
644  GNUNET_free (tio);
645 }
646 
647 
655 static int
656 check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
657 {
658  uint16_t size;
659 
660  size = ntohs (im->header.size);
661  if (size <= sizeof (struct IssueTicketMessage)) {
662  GNUNET_break (0);
663  return GNUNET_SYSERR;
664  }
665  return GNUNET_OK;
666 }
667 
668 
675 static void
676 handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
677 {
678  struct TicketIssueOperation *tio;
679  struct IdpClient *idp = cls;
681  size_t attrs_len;
682 
683  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n");
684  tio = GNUNET_new (struct TicketIssueOperation);
685  attrs_len = ntohs (im->attr_len);
686  attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char *)&im[1], attrs_len);
687  tio->r_id = ntohl (im->id);
688  tio->client = idp;
690  RECLAIM_TICKETS_issue (&im->identity,
691  attrs,
692  &im->rp,
694  tio);
697 }
698 
699 
700 
701 /**********************************************************
702  * Revocation
703  **********************************************************/
704 
711 static void
712 revoke_result_cb (void *cls, int32_t success)
713 {
714  struct TicketRevocationOperation *rop = cls;
715  struct GNUNET_MQ_Envelope *env;
716  struct RevokeTicketResultMessage *trm;
717 
718  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending REVOKE_TICKET_RESULT message\n");
719  rop->rh = NULL;
721  trm->id = htonl (rop->r_id);
722  trm->success = htonl (success);
723  GNUNET_MQ_send (rop->client->mq, env);
725  rop->client->revoke_op_tail,
726  rop);
727  GNUNET_free (rop);
728 }
729 
730 
738 static int
740 {
741  uint16_t size;
742 
743  size = ntohs (im->header.size);
744  if (size != sizeof (struct RevokeTicketMessage)) {
745  GNUNET_break (0);
746  return GNUNET_SYSERR;
747  }
748  return GNUNET_OK;
749 }
750 
751 
758 static void
760 {
761  struct TicketRevocationOperation *rop;
762  struct IdpClient *idp = cls;
763 
764  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n");
765  rop = GNUNET_new (struct TicketRevocationOperation);
766  rop->r_id = ntohl (rm->id);
767  rop->client = idp;
769  rop->rh
772 }
773 
774 
784 static void
785 consume_result_cb (void *cls,
787  const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs,
788  int32_t success,
789  const char *emsg)
790 {
791  struct ConsumeTicketOperation *cop = cls;
792  struct ConsumeTicketResultMessage *crm;
793  struct GNUNET_MQ_Envelope *env;
794  char *data_tmp;
795  size_t attrs_len;
796  if (GNUNET_OK != success) {
797  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg);
798  }
800  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending CONSUME_TICKET_RESULT message\n");
801  env = GNUNET_MQ_msg_extra (crm,
802  attrs_len,
804  crm->id = htonl (cop->r_id);
805  crm->attrs_len = htons (attrs_len);
806  crm->identity = *identity;
807  crm->result = htonl (success);
808  data_tmp = (char *)&crm[1];
809  GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, data_tmp);
810  GNUNET_MQ_send (cop->client->mq, env);
812  cop->client->consume_op_tail,
813  cop);
814  GNUNET_free (cop);
815 }
816 
817 
824 static int
826 {
827  uint16_t size;
828 
829  size = ntohs (cm->header.size);
830  if (size != sizeof (struct ConsumeTicketMessage)) {
831  GNUNET_break (0);
832  return GNUNET_SYSERR;
833  }
834  return GNUNET_OK;
835 }
836 
837 
844 static void
846 {
847  struct ConsumeTicketOperation *cop;
848  struct IdpClient *idp = cls;
849 
850  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n");
851  cop = GNUNET_new (struct ConsumeTicketOperation);
852  cop->r_id = ntohl (cm->id);
853  cop->client = idp;
854  cop->ch
858 }
859 
860 /*****************************************
861  * Attribute store
862  *****************************************/
863 
864 
872 static void
873 attr_store_cont (void *cls, int32_t success, const char *emsg)
874 {
875  struct AttributeStoreHandle *ash = cls;
876  struct GNUNET_MQ_Envelope *env;
877  struct SuccessResultMessage *acr_msg;
878 
879  ash->ns_qe = NULL;
881  ash->client->store_op_tail,
882  ash);
883 
884  if (GNUNET_SYSERR == success) {
886  "Failed to store attribute %s\n",
887  emsg);
888  cleanup_as_handle (ash);
890  return;
891  }
892 
893  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
895  acr_msg->id = htonl (ash->r_id);
896  acr_msg->op_result = htonl (GNUNET_OK);
897  GNUNET_MQ_send (ash->client->mq, env);
898  cleanup_as_handle (ash);
899 }
900 
901 
907 static void
908 attr_store_task (void *cls)
909 {
910  struct AttributeStoreHandle *ash = cls;
911  struct GNUNET_GNSRECORD_Data rd[1];
912  char *buf;
913  char *label;
914  size_t buf_size;
915 
916  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing attribute\n");
918  buf = GNUNET_malloc (buf_size);
919  // Give the ash a new id if unset
920  if (0 == ash->claim->id)
921  ash->claim->id
924  label
925  = GNUNET_STRINGS_data_to_string_alloc (&ash->claim->id, sizeof (uint64_t));
926  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting with label %s\n", label);
927 
928  rd[0].data_size = buf_size;
929  rd[0].data = buf;
932  rd[0].expiration_time = ash->exp.rel_value_us;
934  &ash->identity,
935  label,
936  1,
937  rd,
939  ash);
940  GNUNET_free (buf);
941  GNUNET_free (label);
942 }
943 
944 
951 static int
953  const struct AttributeStoreMessage *sam)
954 {
955  uint16_t size;
956 
957  size = ntohs (sam->header.size);
958  if (size <= sizeof (struct AttributeStoreMessage)) {
959  GNUNET_break (0);
960  return GNUNET_SYSERR;
961  }
962  return GNUNET_OK;
963 }
964 
965 
972 static void
974  const struct AttributeStoreMessage *sam)
975 {
976  struct AttributeStoreHandle *ash;
977  struct IdpClient *idp = cls;
978  size_t data_len;
979  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n");
980 
981  data_len = ntohs (sam->attr_len);
982 
983  ash = GNUNET_new (struct AttributeStoreHandle);
984  ash->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *)&sam[1], data_len);
985 
986  ash->r_id = ntohl (sam->id);
987  ash->identity = sam->identity;
988  ash->exp.rel_value_us = GNUNET_ntohll (sam->exp);
989  GNUNET_CRYPTO_ecdsa_key_get_public (&sam->identity, &ash->identity_pkey);
990 
992  ash->client = idp;
995 }
996 
997 
1004 static void
1005 send_delete_response (struct AttributeDeleteHandle *adh, int32_t success)
1006 {
1007  struct GNUNET_MQ_Envelope *env;
1008  struct SuccessResultMessage *acr_msg;
1009 
1011  adh->client->delete_op_tail,
1012  adh);
1013 
1014  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
1016  acr_msg->id = htonl (adh->r_id);
1017  acr_msg->op_result = htonl (success);
1018  GNUNET_MQ_send (adh->client->mq, env);
1019 }
1020 
1021 
1032 static void
1033 ticket_iter (void *cls,
1034  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1035  const char *label,
1036  unsigned int rd_count,
1037  const struct GNUNET_GNSRECORD_Data *rd)
1038 {
1039  struct AttributeDeleteHandle *adh = cls;
1040  struct TicketRecordsEntry *le;
1041  int has_changed = GNUNET_NO;
1042 
1043  for (int i = 0; i < rd_count; i++) {
1044  if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
1045  continue;
1046  if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof (uint64_t)))
1047  continue;
1049  "Attribute to delete found (%s)\n",
1050  adh->label);
1051  has_changed = GNUNET_YES;
1052  break;
1053  }
1054  if (GNUNET_YES == has_changed) {
1055  le = GNUNET_new (struct TicketRecordsEntry);
1056  le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
1057  le->data = GNUNET_malloc (le->data_size);
1058  le->rd_count = rd_count;
1059  le->label = GNUNET_strdup (label);
1060  GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data);
1063  le);
1064  }
1066 }
1067 
1068 
1073 static void
1074 update_tickets (void *cls);
1075 
1076 
1084 static void
1085 ticket_updated (void *cls, int32_t success, const char *emsg)
1086 {
1087  struct AttributeDeleteHandle *adh = cls;
1088  adh->ns_qe = NULL;
1090 }
1091 
1092 
1100 static void
1101 update_tickets (void *cls)
1102 {
1103  struct AttributeDeleteHandle *adh = cls;
1104  struct TicketRecordsEntry *le;
1105  if (NULL == adh->tickets_to_update_head) {
1107  "Finished updatding tickets, success\n");
1109  cleanup_adh (adh);
1110  return;
1111  }
1113  "Updating %s\n",
1115  le = adh->tickets_to_update_head;
1118  le);
1119  struct GNUNET_GNSRECORD_Data rd[le->rd_count];
1120  struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1];
1122  le->data,
1123  le->rd_count,
1124  rd))
1125  {
1127  "Unable to deserialize record data!\n");
1129  cleanup_adh (adh);
1130  return;
1131  }
1132  int j = 0;
1133  for (int i = 0; i < le->rd_count; i++) {
1135  && (0 == memcmp (rd[i].data, &adh->claim->id, sizeof (uint64_t))))
1136  continue;
1137  rd_new[j] = rd[i];
1138  j++;
1139  }
1141  &adh->identity,
1142  le->label,
1143  j,
1144  rd_new,
1145  &ticket_updated,
1146  adh);
1147  GNUNET_free (le->label);
1148  GNUNET_free (le->data);
1149  GNUNET_free (le);
1150 }
1151 
1152 
1158 static void
1159 ticket_iter_fin (void *cls)
1160 {
1161  struct AttributeDeleteHandle *adh = cls;
1162  adh->ns_it = NULL;
1164 }
1165 
1166 
1172 static void
1173 ticket_iter_err (void *cls)
1174 {
1175  struct AttributeDeleteHandle *adh = cls;
1176  adh->ns_it = NULL;
1178  "Namestore error on delete %s\n",
1179  adh->label);
1181  cleanup_adh (adh);
1182 }
1183 
1184 
1191 static void
1193 {
1194  struct AttributeDeleteHandle *adh = cls;
1196  &adh->identity,
1197  &ticket_iter_err,
1198  adh,
1199  &ticket_iter,
1200  adh,
1201  &ticket_iter_fin,
1202  adh);
1203 }
1204 
1205 
1213 static void
1214 attr_delete_cont (void *cls, int32_t success, const char *emsg)
1215 {
1216  struct AttributeDeleteHandle *adh = cls;
1217  adh->ns_qe = NULL;
1218  if (GNUNET_SYSERR == success) {
1220  "Error deleting attribute %s\n",
1221  adh->label);
1223  cleanup_adh (adh);
1224  return;
1225  }
1226  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n");
1228 }
1229 
1230 
1237 static int
1239  const struct AttributeDeleteMessage *dam)
1240 {
1241  uint16_t size;
1242 
1243  size = ntohs (dam->header.size);
1244  if (size <= sizeof (struct AttributeDeleteMessage)) {
1245  GNUNET_break (0);
1246  return GNUNET_SYSERR;
1247  }
1248  return GNUNET_OK;
1249 }
1250 
1251 
1258 static void
1260  const struct AttributeDeleteMessage *dam)
1261 {
1262  struct AttributeDeleteHandle *adh;
1263  struct IdpClient *idp = cls;
1264  size_t data_len;
1265  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n");
1266 
1267  data_len = ntohs (dam->attr_len);
1268 
1269  adh = GNUNET_new (struct AttributeDeleteHandle);
1270  adh->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *)&dam[1], data_len);
1271 
1272  adh->r_id = ntohl (dam->id);
1273  adh->identity = dam->identity;
1274  adh->label
1275  = GNUNET_STRINGS_data_to_string_alloc (&adh->claim->id, sizeof (uint64_t));
1277  adh->client = idp;
1280  &adh->identity,
1281  adh->label,
1282  0,
1283  NULL,
1285  adh);
1286 }
1287 
1288 
1289 /*************************************************
1290  * Attrubute iteration
1291  *************************************************/
1292 
1293 
1299 static void
1301 {
1302  struct AttributeIterator *ai = cls;
1303  struct GNUNET_MQ_Envelope *env;
1304  struct AttributeResultMessage *arm;
1305 
1306  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
1308  arm->id = htonl (ai->request_id);
1309  arm->attr_len = htons (0);
1310  GNUNET_MQ_send (ai->client->mq, env);
1312  ai->client->attr_iter_tail,
1313  ai);
1314  GNUNET_free (ai);
1315 }
1316 
1322 static void
1323 attr_iter_error (void *cls)
1324 {
1325  struct AttributeIterator *ai = cls;
1326 
1327  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to iterate over attributes\n");
1328  attr_iter_finished (ai);
1329 }
1330 
1331 
1341 static void
1342 attr_iter_cb (void *cls,
1343  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
1344  const char *label,
1345  unsigned int rd_count,
1346  const struct GNUNET_GNSRECORD_Data *rd)
1347 {
1348  struct AttributeIterator *ai = cls;
1349  struct AttributeResultMessage *arm;
1350  struct GNUNET_MQ_Envelope *env;
1351  char *data_tmp;
1352 
1353  if (rd_count != 1) {
1355  return;
1356  }
1357 
1360  return;
1361  }
1362  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", label);
1363  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
1364  env = GNUNET_MQ_msg_extra (arm,
1365  rd->data_size,
1367  arm->id = htonl (ai->request_id);
1368  arm->attr_len = htons (rd->data_size);
1370  data_tmp = (char *)&arm[1];
1371  GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
1372  GNUNET_MQ_send (ai->client->mq, env);
1373 }
1374 
1375 
1382 static void
1384  const struct AttributeIterationStartMessage *ais_msg)
1385 {
1386  struct IdpClient *idp = cls;
1387  struct AttributeIterator *ai;
1388 
1390  "Received ATTRIBUTE_ITERATION_START message\n");
1391  ai = GNUNET_new (struct AttributeIterator);
1392  ai->request_id = ntohl (ais_msg->id);
1393  ai->client = idp;
1394  ai->identity = ais_msg->identity;
1395 
1398  &ai->identity,
1399  &attr_iter_error,
1400  ai,
1401  &attr_iter_cb,
1402  ai,
1404  ai);
1406 }
1407 
1408 
1415 static void
1417  const struct AttributeIterationStopMessage *ais_msg)
1418 {
1419  struct IdpClient *idp = cls;
1420  struct AttributeIterator *ai;
1421  uint32_t rid;
1422 
1424  "Received `%s' message\n",
1425  "ATTRIBUTE_ITERATION_STOP");
1426  rid = ntohl (ais_msg->id);
1427  for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
1428  if (ai->request_id == rid)
1429  break;
1430  if (NULL == ai) {
1431  GNUNET_break (0);
1433  return;
1434  }
1436  GNUNET_free (ai);
1438 }
1439 
1440 
1447 static void
1449  const struct AttributeIterationNextMessage *ais_msg)
1450 {
1451  struct IdpClient *idp = cls;
1452  struct AttributeIterator *ai;
1453  uint32_t rid;
1454 
1456  "Received ATTRIBUTE_ITERATION_NEXT message\n");
1457  rid = ntohl (ais_msg->id);
1458  for (ai = idp->attr_iter_head; NULL != ai; ai = ai->next)
1459  if (ai->request_id == rid)
1460  break;
1461  if (NULL == ai) {
1462  GNUNET_break (0);
1464  return;
1465  }
1468 }
1469 
1470 /******************************************************
1471  * Ticket iteration
1472  ******************************************************/
1473 
1480 static void
1482 {
1483  struct TicketIteration *ti = cls;
1484  struct GNUNET_MQ_Envelope *env;
1485  struct TicketResultMessage *trm;
1486 
1488  if (NULL == ticket) {
1489  /* send empty response to indicate end of list */
1491  ti->client->ticket_iter_tail,
1492  ti);
1493  } else {
1494  trm->ticket = *ticket;
1495  }
1496  trm->id = htonl (ti->r_id);
1497  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
1498  GNUNET_MQ_send (ti->client->mq, env);
1499  if (NULL == ticket)
1500  GNUNET_free (ti);
1501 }
1502 
1503 
1510 static void
1512  void *cls,
1513  const struct TicketIterationStartMessage *tis_msg)
1514 {
1515  struct IdpClient *client = cls;
1516  struct TicketIteration *ti;
1517 
1519  "Received TICKET_ITERATION_START message\n");
1520  ti = GNUNET_new (struct TicketIteration);
1521  ti->r_id = ntohl (tis_msg->id);
1522  ti->client = client;
1523 
1525  client->ticket_iter_tail,
1526  ti);
1527  ti->iter
1530 }
1531 
1532 
1539 static void
1541  const struct TicketIterationStopMessage *tis_msg)
1542 {
1543  struct IdpClient *client = cls;
1544  struct TicketIteration *ti;
1545  uint32_t rid;
1546 
1548  "Received `%s' message\n",
1549  "TICKET_ITERATION_STOP");
1550  rid = ntohl (tis_msg->id);
1551  for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
1552  if (ti->r_id == rid)
1553  break;
1554  if (NULL == ti) {
1555  GNUNET_break (0);
1557  return;
1558  }
1561  client->ticket_iter_tail,
1562  ti);
1563  GNUNET_free (ti);
1565 }
1566 
1567 
1574 static void
1576  const struct TicketIterationNextMessage *tis_msg)
1577 {
1578  struct IdpClient *client = cls;
1579  struct TicketIteration *ti;
1580  uint32_t rid;
1581 
1583  "Received TICKET_ITERATION_NEXT message\n");
1584  rid = ntohl (tis_msg->id);
1585  for (ti = client->ticket_iter_head; NULL != ti; ti = ti->next)
1586  if (ti->r_id == rid)
1587  break;
1588  if (NULL == ti) {
1589  GNUNET_break (0);
1591  return;
1592  }
1595 }
1596 
1597 
1605 static void
1606 run (void *cls,
1607  const struct GNUNET_CONFIGURATION_Handle *c,
1608  struct GNUNET_SERVICE_Handle *server)
1609 {
1610  cfg = c;
1611 
1612  if (GNUNET_OK != RECLAIM_TICKETS_init (cfg)) {
1614  "Unable to initialize TICKETS subsystem.\n");
1616  return;
1617  }
1618  // Connect to identity and namestore services
1619  nsh = GNUNET_NAMESTORE_connect (cfg);
1620  if (NULL == nsh) {
1622  "error connecting to namestore");
1623  }
1624 
1626 }
1627 
1628 
1636 static void
1638  struct GNUNET_SERVICE_Client *client,
1639  void *app_ctx)
1640 {
1641  struct IdpClient *idp = app_ctx;
1642  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
1643  GNUNET_CONTAINER_DLL_remove (client_list_head,
1644  client_list_tail,
1645  idp);
1646  cleanup_client (idp);
1647 }
1648 
1649 
1658 static void *
1660  struct GNUNET_SERVICE_Client *client,
1661  struct GNUNET_MQ_Handle *mq)
1662 {
1663  struct IdpClient *idp;
1664  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
1665  idp = GNUNET_new (struct IdpClient);
1666  idp->client = client;
1667  idp->mq = mq;
1668  GNUNET_CONTAINER_DLL_insert (client_list_head,
1669  client_list_tail,
1670  idp);
1671  return idp;
1672 }
1673 
1674 
1679  "reclaim",
1681  &run,
1684  NULL,
1685  GNUNET_MQ_hd_var_size (attribute_store_message,
1687  struct AttributeStoreMessage,
1688  NULL),
1689  GNUNET_MQ_hd_var_size (attribute_delete_message,
1691  struct AttributeDeleteMessage,
1692  NULL),
1697  NULL),
1698  GNUNET_MQ_hd_fixed_size (iteration_next,
1701  NULL),
1702  GNUNET_MQ_hd_fixed_size (iteration_stop,
1705  NULL),
1706  GNUNET_MQ_hd_var_size (issue_ticket_message,
1708  struct IssueTicketMessage,
1709  NULL),
1710  GNUNET_MQ_hd_var_size (consume_ticket_message,
1712  struct ConsumeTicketMessage,
1713  NULL),
1714  GNUNET_MQ_hd_fixed_size (ticket_iteration_start,
1717  NULL),
1718  GNUNET_MQ_hd_fixed_size (ticket_iteration_next,
1721  NULL),
1722  GNUNET_MQ_hd_fixed_size (ticket_iteration_stop,
1725  NULL),
1726  GNUNET_MQ_hd_var_size (revoke_ticket_message,
1728  struct RevokeTicketMessage,
1729  NULL),
1731 /* 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:367
static void attr_delete_cont(void *cls, int32_t success, const char *emsg)
Attribute deleted callback.
Ticket result message.
Definition: reclaim.h:357
struct GNUNET_CRYPTO_EcdsaPrivateKey identity
Identity.
Definition: reclaim.h:319
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:372
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:404
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:309
#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:230
Ticket consume message.
Definition: reclaim.h:378
Handle to a service.
Definition: service.c:116
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:160
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:1293
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:199
int32_t op_result
GNUNET_SYSERR on failure, GNUNET_OK on success
Definition: reclaim.h:118
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR
Record type for identity attributes (of RECLAIM).
void RECLAIM_TICKETS_iteration_stop(struct RECLAIM_TICKETS_Iterator *iter)
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:314
struct RECLAIM_TICKETS_Iterator * iter
The ticket iterator.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:134
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:414
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:74
struct IdpClient * client
Client connection.
#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:81
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:78
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:89
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:419
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)
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:524
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:276
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:237
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:249
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:247
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:209
#define GNUNET_memcpy(dst, src, n)
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:79
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:393
Connection to the NAMESTORE service.
struct TicketIteration * prev
DLL.
Stop ticket iteration for the given operation.
Definition: reclaim.h:254
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:192
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:1273
struct GNUNET_RECLAIM_Ticket ticket
The ticket to revoke.
Definition: reclaim.h:329
unsigned int rd_count
Record count.
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)
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:175
struct IdpClient * client
Client connection.
uint32_t attr_len
The length of the attribute.
Definition: reclaim.h:55
struct TicketRecordsEntry * tickets_to_update_head
Tickets to update.
uint32_t id
Unique identifier for this request (for key collisions).
Definition: reclaim.h:170
Ticket issue message.
Definition: reclaim.h:271
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:2618
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:103
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: reclaim.h:45
void RECLAIM_TICKETS_consume_cancel(struct RECLAIM_TICKETS_ConsumeHandle *cth)
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:296
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:79
struct GNUNET_RECLAIM_Ticket ticket
The ticket to consume.
Definition: reclaim.h:398
static unsigned int size
Size of the "table".
Definition: peer.c:67
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:182
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)
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)
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:85
#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:434
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:335
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)
configuration data
Definition: configuration.c:85
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:225
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:345
void RECLAIM_TICKETS_deinit(void)
Attribute is returned from the idp.
Definition: reclaim.h:124
uint16_t attr_len
Length of serialized attribute data.
Definition: reclaim.h:139
A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
Start a ticket iteration for the given identity.
Definition: reclaim.h:215
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)
uint16_t attrs_len
Length of serialized attribute data.
Definition: reclaim.h:424
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:134
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:149
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:80
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:353
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:264
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:988
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET.
Definition: reclaim.h:383
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)
uint32_t success
Revocation result.
Definition: reclaim.h:350
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
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:388
#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:113
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:304
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:965
High-quality operations are desired.