diff options
author | Bart Polot <bart.polot+gnunet@gmail.com> | 2017-03-01 18:49:52 +0100 |
---|---|---|
committer | Bart Polot <bart.polot+gnunet@gmail.com> | 2017-03-01 18:49:52 +0100 |
commit | 466f3fe3101c78f5219b63ca8724697757104d87 (patch) | |
tree | 82330dfdd06af141930e64894387d192124c3c47 | |
parent | cef53c8a38a628335e85dbf16c261cccc58512c5 (diff) | |
parent | 13b340c41157eb7d1d37e2d16058ce791a7c768e (diff) | |
download | gnunet-466f3fe3101c78f5219b63ca8724697757104d87.tar.gz gnunet-466f3fe3101c78f5219b63ca8724697757104d87.zip |
Merge branch 'master' of git+ssh://gnunet.org/gnunet
32 files changed, 1131 insertions, 188 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 21d4ee818..e466cbc28 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -40,6 +40,10 @@ CONVERSATION_DIR = conversation | |||
40 | endif | 40 | endif |
41 | endif | 41 | endif |
42 | 42 | ||
43 | if HAVE_SQLITE | ||
44 | SQLITE_DIR = sq | ||
45 | endif | ||
46 | |||
43 | if HAVE_MYSQL | 47 | if HAVE_MYSQL |
44 | MYSQL_DIR = mysql my | 48 | MYSQL_DIR = mysql my |
45 | endif | 49 | endif |
@@ -78,6 +82,7 @@ SUBDIRS = \ | |||
78 | arm \ | 82 | arm \ |
79 | $(TESTING) \ | 83 | $(TESTING) \ |
80 | peerinfo \ | 84 | peerinfo \ |
85 | $(SQLITE_DIR) \ | ||
81 | $(MYSQL_DIR) \ | 86 | $(MYSQL_DIR) \ |
82 | $(POSTGRES_DIR) \ | 87 | $(POSTGRES_DIR) \ |
83 | datacache \ | 88 | datacache \ |
diff --git a/src/block/block.c b/src/block/block.c index d6e61acf6..4b6f3826d 100644 --- a/src/block/block.c +++ b/src/block/block.c | |||
@@ -136,7 +136,7 @@ GNUNET_BLOCK_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
136 | ctx = GNUNET_new (struct GNUNET_BLOCK_Context); | 136 | ctx = GNUNET_new (struct GNUNET_BLOCK_Context); |
137 | ctx->cfg = cfg; | 137 | ctx->cfg = cfg; |
138 | GNUNET_PLUGIN_load_all ("libgnunet_plugin_block_", | 138 | GNUNET_PLUGIN_load_all ("libgnunet_plugin_block_", |
139 | NULL, | 139 | (void *) cfg, |
140 | &add_plugin, | 140 | &add_plugin, |
141 | ctx); | 141 | ctx); |
142 | return ctx; | 142 | return ctx; |
diff --git a/src/block/plugin_block_template.c b/src/block/plugin_block_template.c index 2edca17ec..0105fac38 100644 --- a/src/block/plugin_block_template.c +++ b/src/block/plugin_block_template.c | |||
@@ -157,6 +157,8 @@ block_plugin_template_get_key (void *cls, | |||
157 | 157 | ||
158 | /** | 158 | /** |
159 | * Entry point for the plugin. | 159 | * Entry point for the plugin. |
160 | * | ||
161 | * @param cls a `const struct GNUNET_CONFIGURATION_Handle` | ||
160 | */ | 162 | */ |
161 | void * | 163 | void * |
162 | libgnunet_plugin_block_template_init (void *cls) | 164 | libgnunet_plugin_block_template_init (void *cls) |
@@ -183,7 +185,7 @@ libgnunet_plugin_block_template_init (void *cls) | |||
183 | void * | 185 | void * |
184 | libgnunet_plugin_block_template_done (void *cls) | 186 | libgnunet_plugin_block_template_done (void *cls) |
185 | { | 187 | { |
186 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 188 | struct GNUNET_BLOCK_PluginFunctions *api = cls; |
187 | 189 | ||
188 | GNUNET_free (api); | 190 | GNUNET_free (api); |
189 | return NULL; | 191 | return NULL; |
diff --git a/src/cadet/cadet_api_new.c b/src/cadet/cadet_api_new.c index a62de0a47..2d5d853b3 100644 --- a/src/cadet/cadet_api_new.c +++ b/src/cadet/cadet_api_new.c | |||
@@ -626,7 +626,6 @@ handle_channel_created (void *cls, | |||
626 | struct GNUNET_CADET_LocalChannelDestroyMessage *d_msg; | 626 | struct GNUNET_CADET_LocalChannelDestroyMessage *d_msg; |
627 | struct GNUNET_MQ_Envelope *env; | 627 | struct GNUNET_MQ_Envelope *env; |
628 | 628 | ||
629 | GNUNET_break (0); | ||
630 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 629 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
631 | "No handler for incoming channel %X (on port %s, recently closed?)\n", | 630 | "No handler for incoming channel %X (on port %s, recently closed?)\n", |
632 | ntohl (ccn.channel_of_client), | 631 | ntohl (ccn.channel_of_client), |
@@ -682,16 +681,18 @@ handle_channel_destroy (void *cls, | |||
682 | struct GNUNET_CADET_Handle *h = cls; | 681 | struct GNUNET_CADET_Handle *h = cls; |
683 | struct GNUNET_CADET_Channel *ch; | 682 | struct GNUNET_CADET_Channel *ch; |
684 | 683 | ||
685 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
686 | "Received channel destroy for channel %X from CADET service\n", | ||
687 | ntohl (msg->ccn.channel_of_client)); | ||
688 | ch = find_channel (h, | 684 | ch = find_channel (h, |
689 | msg->ccn); | 685 | msg->ccn); |
690 | if (NULL == ch) | 686 | if (NULL == ch) |
691 | { | 687 | { |
692 | GNUNET_break (0); | 688 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
689 | "Received channel destroy for unknown channel %X from CADET service (recently close?)\n", | ||
690 | ntohl (msg->ccn.channel_of_client)); | ||
693 | return; | 691 | return; |
694 | } | 692 | } |
693 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
694 | "Received channel destroy for channel %X from CADET service\n", | ||
695 | ntohl (msg->ccn.channel_of_client)); | ||
695 | destroy_channel (ch); | 696 | destroy_channel (ch); |
696 | } | 697 | } |
697 | 698 | ||
@@ -708,8 +709,6 @@ static int | |||
708 | check_local_data (void *cls, | 709 | check_local_data (void *cls, |
709 | const struct GNUNET_CADET_LocalData *message) | 710 | const struct GNUNET_CADET_LocalData *message) |
710 | { | 711 | { |
711 | struct GNUNET_CADET_Handle *h = cls; | ||
712 | struct GNUNET_CADET_Channel *ch; | ||
713 | uint16_t size; | 712 | uint16_t size; |
714 | 713 | ||
715 | size = ntohs (message->header.size); | 714 | size = ntohs (message->header.size); |
@@ -718,15 +717,6 @@ check_local_data (void *cls, | |||
718 | GNUNET_break (0); | 717 | GNUNET_break (0); |
719 | return GNUNET_SYSERR; | 718 | return GNUNET_SYSERR; |
720 | } | 719 | } |
721 | |||
722 | ch = find_channel (h, | ||
723 | message->ccn); | ||
724 | if (NULL == ch) | ||
725 | { | ||
726 | GNUNET_break (0); | ||
727 | return GNUNET_SYSERR; | ||
728 | } | ||
729 | |||
730 | return GNUNET_OK; | 720 | return GNUNET_OK; |
731 | } | 721 | } |
732 | 722 | ||
@@ -751,8 +741,9 @@ handle_local_data (void *cls, | |||
751 | message->ccn); | 741 | message->ccn); |
752 | if (NULL == ch) | 742 | if (NULL == ch) |
753 | { | 743 | { |
754 | GNUNET_break (0); | 744 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
755 | reconnect (h); | 745 | "Unknown channel %X for incoming data (recently closed?)\n", |
746 | ntohl (message->ccn.channel_of_client)); | ||
756 | return; | 747 | return; |
757 | } | 748 | } |
758 | 749 | ||
diff --git a/src/cadet/gnunet-service-cadet-new.c b/src/cadet/gnunet-service-cadet-new.c index b0a818c7c..93f53de4c 100644 --- a/src/cadet/gnunet-service-cadet-new.c +++ b/src/cadet/gnunet-service-cadet-new.c | |||
@@ -716,12 +716,18 @@ handle_local_data (void *cls, | |||
716 | msg->ccn); | 716 | msg->ccn); |
717 | if (NULL == ch) | 717 | if (NULL == ch) |
718 | { | 718 | { |
719 | /* Channel does not exist! */ | 719 | /* Channel does not exist (anymore) */ |
720 | GNUNET_break (0); | 720 | LOG (GNUNET_ERROR_TYPE_WARNING, |
721 | GNUNET_SERVICE_client_drop (c->client); | 721 | "Dropping payload for channel %u from client (channel unknown, other endpoint may have disconnected)\n", |
722 | (unsigned int) ntohl (msg->ccn.channel_of_client)); | ||
723 | GNUNET_SERVICE_client_continue (c->client); | ||
722 | return; | 724 | return; |
723 | } | 725 | } |
724 | payload_size = ntohs (msg->header.size) - sizeof (*msg); | 726 | payload_size = ntohs (msg->header.size) - sizeof (*msg); |
727 | GNUNET_STATISTICS_update (stats, | ||
728 | "# payload received from clients", | ||
729 | payload_size, | ||
730 | GNUNET_NO); | ||
725 | buf = (const char *) &msg[1]; | 731 | buf = (const char *) &msg[1]; |
726 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 732 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
727 | "Received %u bytes payload from %s for %s\n", | 733 | "Received %u bytes payload from %s for %s\n", |
@@ -758,9 +764,11 @@ handle_local_ack (void *cls, | |||
758 | msg->ccn); | 764 | msg->ccn); |
759 | if (NULL == ch) | 765 | if (NULL == ch) |
760 | { | 766 | { |
761 | /* Channel does not exist! */ | 767 | /* Channel does not exist (anymore) */ |
762 | GNUNET_break (0); | 768 | LOG (GNUNET_ERROR_TYPE_WARNING, |
763 | GNUNET_SERVICE_client_drop (c->client); | 769 | "Ignoring local ACK for channel %u from client (channel unknown, other endpoint may have disconnected)\n", |
770 | (unsigned int) ntohl (msg->ccn.channel_of_client)); | ||
771 | GNUNET_SERVICE_client_continue (c->client); | ||
764 | return; | 772 | return; |
765 | } | 773 | } |
766 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 774 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/cadet/gnunet-service-cadet-new_channel.c b/src/cadet/gnunet-service-cadet-new_channel.c index c418893a8..8769601c2 100644 --- a/src/cadet/gnunet-service-cadet-new_channel.c +++ b/src/cadet/gnunet-service-cadet-new_channel.c | |||
@@ -1618,7 +1618,8 @@ GCCH_handle_remote_destroy (struct CadetChannel *ch, | |||
1618 | return; | 1618 | return; |
1619 | } | 1619 | } |
1620 | ccc = (NULL != ch->owner) ? ch->owner : ch->dest; | 1620 | ccc = (NULL != ch->owner) ? ch->owner : ch->dest; |
1621 | if (NULL != ccc->head_recv) | 1621 | if ( (NULL != ccc) && |
1622 | (NULL != ccc->head_recv) ) | ||
1622 | { | 1623 | { |
1623 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1624 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1624 | "Lost end of transmission due to remote shutdown on %s\n", | 1625 | "Lost end of transmission due to remote shutdown on %s\n", |
@@ -1626,9 +1627,10 @@ GCCH_handle_remote_destroy (struct CadetChannel *ch, | |||
1626 | /* FIXME: change API to notify client about truncated transmission! */ | 1627 | /* FIXME: change API to notify client about truncated transmission! */ |
1627 | } | 1628 | } |
1628 | ch->destroy = GNUNET_YES; | 1629 | ch->destroy = GNUNET_YES; |
1629 | GSC_handle_remote_channel_destroy (ccc->c, | 1630 | if (NULL != ccc) |
1630 | ccc->ccn, | 1631 | GSC_handle_remote_channel_destroy (ccc->c, |
1631 | ch); | 1632 | ccc->ccn, |
1633 | ch); | ||
1632 | channel_destroy (ch); | 1634 | channel_destroy (ch); |
1633 | } | 1635 | } |
1634 | 1636 | ||
diff --git a/src/cadet/gnunet-service-cadet-new_tunnels.c b/src/cadet/gnunet-service-cadet-new_tunnels.c index bf05fae6b..d50860629 100644 --- a/src/cadet/gnunet-service-cadet-new_tunnels.c +++ b/src/cadet/gnunet-service-cadet-new_tunnels.c | |||
@@ -3082,10 +3082,6 @@ GCT_handle_encrypted (struct CadetTConnection *ct, | |||
3082 | break; | 3082 | break; |
3083 | } | 3083 | } |
3084 | 3084 | ||
3085 | GNUNET_STATISTICS_update (stats, | ||
3086 | "# received encrypted", | ||
3087 | 1, | ||
3088 | GNUNET_NO); | ||
3089 | decrypted_size = -1; | 3085 | decrypted_size = -1; |
3090 | if (CADET_TUNNEL_KEY_OK == t->estate) | 3086 | if (CADET_TUNNEL_KEY_OK == t->estate) |
3091 | { | 3087 | { |
@@ -3166,6 +3162,10 @@ GCT_handle_encrypted (struct CadetTConnection *ct, | |||
3166 | &t->ax); | 3162 | &t->ax); |
3167 | return; | 3163 | return; |
3168 | } | 3164 | } |
3165 | GNUNET_STATISTICS_update (stats, | ||
3166 | "# decrypted bytes", | ||
3167 | decrypted_size, | ||
3168 | GNUNET_NO); | ||
3169 | 3169 | ||
3170 | /* The MST will ultimately call #handle_decrypted() on each message. */ | 3170 | /* The MST will ultimately call #handle_decrypted() on each message. */ |
3171 | t->current_ct = ct; | 3171 | t->current_ct = ct; |
@@ -3217,6 +3217,10 @@ GCT_send (struct CadetTunnel *t, | |||
3217 | &ax_msg[1], | 3217 | &ax_msg[1], |
3218 | message, | 3218 | message, |
3219 | payload_size); | 3219 | payload_size); |
3220 | GNUNET_STATISTICS_update (stats, | ||
3221 | "# encrypted bytes", | ||
3222 | payload_size, | ||
3223 | GNUNET_NO); | ||
3220 | ax_msg->ax_header.Ns = htonl (t->ax.Ns++); | 3224 | ax_msg->ax_header.Ns = htonl (t->ax.Ns++); |
3221 | ax_msg->ax_header.PNs = htonl (t->ax.PNs); | 3225 | ax_msg->ax_header.PNs = htonl (t->ax.PNs); |
3222 | /* FIXME: we should do this once, not once per message; | 3226 | /* FIXME: we should do this once, not once per message; |
diff --git a/src/consensus/gnunet-consensus-profiler.c b/src/consensus/gnunet-consensus-profiler.c index 290263d95..65542f4cd 100644 --- a/src/consensus/gnunet-consensus-profiler.c +++ b/src/consensus/gnunet-consensus-profiler.c | |||
@@ -55,6 +55,8 @@ static struct GNUNET_HashCode session_id; | |||
55 | 55 | ||
56 | static unsigned int peers_done = 0; | 56 | static unsigned int peers_done = 0; |
57 | 57 | ||
58 | static int dist_static; | ||
59 | |||
58 | static unsigned *results_for_peer; | 60 | static unsigned *results_for_peer; |
59 | 61 | ||
60 | /** | 62 | /** |
@@ -217,26 +219,45 @@ do_consensus () | |||
217 | { | 219 | { |
218 | int unique_indices[replication]; | 220 | int unique_indices[replication]; |
219 | unsigned int i; | 221 | unsigned int i; |
222 | unsigned int j; | ||
223 | struct GNUNET_HashCode val; | ||
224 | struct GNUNET_SET_Element element; | ||
220 | 225 | ||
221 | for (i = 0; i < num_values; i++) | 226 | if (dist_static) |
222 | { | 227 | { |
223 | unsigned int j; | 228 | for (i = 0; i < num_values; i++) |
224 | struct GNUNET_HashCode val; | 229 | { |
225 | struct GNUNET_SET_Element element; | ||
226 | 230 | ||
227 | generate_indices (unique_indices); | 231 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &val); |
228 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &val); | ||
229 | 232 | ||
230 | element.data = &val; | 233 | element.data = &val; |
231 | element.size = sizeof (val); | 234 | element.size = sizeof (val); |
232 | for (j = 0; j < replication; j++) | 235 | for (j = 0; j < replication; j++) |
236 | { | ||
237 | GNUNET_CONSENSUS_insert (consensus_handles[j], | ||
238 | &element, | ||
239 | NULL, NULL); | ||
240 | } | ||
241 | } | ||
242 | } | ||
243 | else | ||
244 | { | ||
245 | for (i = 0; i < num_values; i++) | ||
233 | { | 246 | { |
234 | int cid; | 247 | generate_indices (unique_indices); |
248 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &val); | ||
235 | 249 | ||
236 | cid = unique_indices[j]; | 250 | element.data = &val; |
237 | GNUNET_CONSENSUS_insert (consensus_handles[cid], | 251 | element.size = sizeof (val); |
238 | &element, | 252 | for (j = 0; j < replication; j++) |
239 | NULL, NULL); | 253 | { |
254 | int cid; | ||
255 | |||
256 | cid = unique_indices[j]; | ||
257 | GNUNET_CONSENSUS_insert (consensus_handles[cid], | ||
258 | &element, | ||
259 | NULL, NULL); | ||
260 | } | ||
240 | } | 261 | } |
241 | } | 262 | } |
242 | 263 | ||
@@ -513,6 +534,9 @@ main (int argc, char **argv) | |||
513 | { 's', "statistics", NULL, | 534 | { 's', "statistics", NULL, |
514 | gettext_noop ("write statistics to file"), | 535 | gettext_noop ("write statistics to file"), |
515 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &statistics_filename }, | 536 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &statistics_filename }, |
537 | { 'S', "dist-static", NULL, | ||
538 | gettext_noop ("distribute elements to a static subset of good peers"), | ||
539 | GNUNET_YES, &GNUNET_GETOPT_set_one, &dist_static }, | ||
516 | { 'V', "verbose", NULL, | 540 | { 'V', "verbose", NULL, |
517 | gettext_noop ("be more verbose (print received values)"), | 541 | gettext_noop ("be more verbose (print received values)"), |
518 | GNUNET_NO, &GNUNET_GETOPT_set_one, &verbose }, | 542 | GNUNET_NO, &GNUNET_GETOPT_set_one, &verbose }, |
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c index 6662ae8ca..ba84f64a2 100644 --- a/src/consensus/gnunet-service-consensus.c +++ b/src/consensus/gnunet-service-consensus.c | |||
@@ -393,6 +393,14 @@ struct DiffEntry | |||
393 | struct GNUNET_CONTAINER_MultiHashMap *changes; | 393 | struct GNUNET_CONTAINER_MultiHashMap *changes; |
394 | }; | 394 | }; |
395 | 395 | ||
396 | struct SetHandle | ||
397 | { | ||
398 | struct SetHandle *prev; | ||
399 | struct SetHandle *next; | ||
400 | |||
401 | struct GNUNET_SET_Handle *h; | ||
402 | }; | ||
403 | |||
396 | 404 | ||
397 | 405 | ||
398 | /** | 406 | /** |
@@ -499,6 +507,9 @@ struct ConsensusSession | |||
499 | * Bounded Eppstein lower bound. | 507 | * Bounded Eppstein lower bound. |
500 | */ | 508 | */ |
501 | uint64_t lower_bound; | 509 | uint64_t lower_bound; |
510 | |||
511 | struct SetHandle *set_handles_head; | ||
512 | struct SetHandle *set_handles_tail; | ||
502 | }; | 513 | }; |
503 | 514 | ||
504 | /** | 515 | /** |
@@ -1153,6 +1164,7 @@ enum EvilnessType | |||
1153 | EVILNESS_CRAM_LEAD, | 1164 | EVILNESS_CRAM_LEAD, |
1154 | EVILNESS_CRAM_ECHO, | 1165 | EVILNESS_CRAM_ECHO, |
1155 | EVILNESS_SLACK, | 1166 | EVILNESS_SLACK, |
1167 | EVILNESS_SLACK_A2A, | ||
1156 | }; | 1168 | }; |
1157 | 1169 | ||
1158 | enum EvilnessSubType | 1170 | enum EvilnessSubType |
@@ -1245,6 +1257,10 @@ get_evilness (struct ConsensusSession *session, struct Evilness *evil) | |||
1245 | { | 1257 | { |
1246 | evil->type = EVILNESS_SLACK; | 1258 | evil->type = EVILNESS_SLACK; |
1247 | } | 1259 | } |
1260 | if (0 == strcmp ("slack-a2a", evil_type_str)) | ||
1261 | { | ||
1262 | evil->type = EVILNESS_SLACK_A2A; | ||
1263 | } | ||
1248 | else if (0 == strcmp ("cram-all", evil_type_str)) | 1264 | else if (0 == strcmp ("cram-all", evil_type_str)) |
1249 | { | 1265 | { |
1250 | evil->type = EVILNESS_CRAM_ALL; | 1266 | evil->type = EVILNESS_CRAM_ALL; |
@@ -1417,6 +1433,19 @@ commit_set (struct ConsensusSession *session, | |||
1417 | "P%u: evil peer: slacking\n", | 1433 | "P%u: evil peer: slacking\n", |
1418 | (unsigned int) session->local_peer_idx); | 1434 | (unsigned int) session->local_peer_idx); |
1419 | /* Do nothing. */ | 1435 | /* Do nothing. */ |
1436 | case EVILNESS_SLACK_A2A: | ||
1437 | if ( (PHASE_KIND_ALL_TO_ALL_2 == task->key.kind ) || | ||
1438 | (PHASE_KIND_ALL_TO_ALL == task->key.kind) ) | ||
1439 | { | ||
1440 | struct GNUNET_SET_Handle *empty_set; | ||
1441 | empty_set = GNUNET_SET_create (cfg, GNUNET_SET_OPERATION_UNION); | ||
1442 | GNUNET_SET_commit (setop->op, empty_set); | ||
1443 | GNUNET_SET_destroy (empty_set); | ||
1444 | } | ||
1445 | else | ||
1446 | { | ||
1447 | GNUNET_SET_commit (setop->op, set->h); | ||
1448 | } | ||
1420 | break; | 1449 | break; |
1421 | case EVILNESS_NONE: | 1450 | case EVILNESS_NONE: |
1422 | GNUNET_SET_commit (setop->op, set->h); | 1451 | GNUNET_SET_commit (setop->op, set->h); |
@@ -1645,6 +1674,12 @@ set_copy_cb (void *cls, struct GNUNET_SET_Handle *copy) | |||
1645 | struct TaskEntry *task = scc->task; | 1674 | struct TaskEntry *task = scc->task; |
1646 | struct SetKey dst_set_key = scc->dst_set_key; | 1675 | struct SetKey dst_set_key = scc->dst_set_key; |
1647 | struct SetEntry *set; | 1676 | struct SetEntry *set; |
1677 | struct SetHandle *sh = GNUNET_new (struct SetHandle); | ||
1678 | |||
1679 | sh->h = copy; | ||
1680 | GNUNET_CONTAINER_DLL_insert (task->step->session->set_handles_head, | ||
1681 | task->step->session->set_handles_tail, | ||
1682 | sh); | ||
1648 | 1683 | ||
1649 | GNUNET_free (scc); | 1684 | GNUNET_free (scc); |
1650 | set = GNUNET_new (struct SetEntry); | 1685 | set = GNUNET_new (struct SetEntry); |
@@ -3134,6 +3169,11 @@ handle_client_join (void *cls, | |||
3134 | client_set = GNUNET_new (struct SetEntry); | 3169 | client_set = GNUNET_new (struct SetEntry); |
3135 | client_set->h = GNUNET_SET_create (cfg, | 3170 | client_set->h = GNUNET_SET_create (cfg, |
3136 | GNUNET_SET_OPERATION_UNION); | 3171 | GNUNET_SET_OPERATION_UNION); |
3172 | struct SetHandle *sh = GNUNET_new (struct SetHandle); | ||
3173 | sh->h = client_set->h; | ||
3174 | GNUNET_CONTAINER_DLL_insert (session->set_handles_head, | ||
3175 | session->set_handles_tail, | ||
3176 | sh); | ||
3137 | client_set->key = ((struct SetKey) { SET_KIND_CURRENT, 0, 0 }); | 3177 | client_set->key = ((struct SetKey) { SET_KIND_CURRENT, 0, 0 }); |
3138 | put_set (session, | 3178 | put_set (session, |
3139 | client_set); | 3179 | client_set); |
@@ -3352,6 +3392,14 @@ client_disconnect_cb (void *cls, | |||
3352 | GNUNET_CONTAINER_DLL_remove (sessions_head, | 3392 | GNUNET_CONTAINER_DLL_remove (sessions_head, |
3353 | sessions_tail, | 3393 | sessions_tail, |
3354 | session); | 3394 | session); |
3395 | |||
3396 | while (session->set_handles_head) | ||
3397 | { | ||
3398 | struct SetHandle *sh = session->set_handles_head; | ||
3399 | session->set_handles_head = sh->next; | ||
3400 | GNUNET_SET_destroy (sh->h); | ||
3401 | GNUNET_free (sh); | ||
3402 | } | ||
3355 | GNUNET_free (session); | 3403 | GNUNET_free (session); |
3356 | } | 3404 | } |
3357 | 3405 | ||
diff --git a/src/consensus/plugin_block_consensus.c b/src/consensus/plugin_block_consensus.c index 0cb64867e..de0f0886f 100644 --- a/src/consensus/plugin_block_consensus.c +++ b/src/consensus/plugin_block_consensus.c | |||
@@ -128,7 +128,7 @@ libgnunet_plugin_block_consensus_init (void *cls) | |||
128 | void * | 128 | void * |
129 | libgnunet_plugin_block_consensus_done (void *cls) | 129 | libgnunet_plugin_block_consensus_done (void *cls) |
130 | { | 130 | { |
131 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 131 | struct GNUNET_BLOCK_PluginFunctions *api = cls; |
132 | 132 | ||
133 | GNUNET_free (api); | 133 | GNUNET_free (api); |
134 | return NULL; | 134 | return NULL; |
diff --git a/src/consensus/test_consensus.conf b/src/consensus/test_consensus.conf index c75205739..881251a66 100644 --- a/src/consensus/test_consensus.conf +++ b/src/consensus/test_consensus.conf | |||
@@ -5,7 +5,7 @@ GNUNET_TEST_HOME = /tmp/test-consensus/ | |||
5 | #OPTIONS = -L INFO | 5 | #OPTIONS = -L INFO |
6 | BINARY = gnunet-service-evil-consensus | 6 | BINARY = gnunet-service-evil-consensus |
7 | 7 | ||
8 | #PREFIX = valgrind | 8 | PREFIX = valgrind |
9 | 9 | ||
10 | #EVIL_SPEC = 0;cram-all;noreplace;5 | 10 | #EVIL_SPEC = 0;cram-all;noreplace;5 |
11 | #EVIL_SPEC = 0;cram;5/1;cram;5 | 11 | #EVIL_SPEC = 0;cram;5/1;cram;5 |
@@ -17,19 +17,22 @@ BINARY = gnunet-service-evil-consensus | |||
17 | RESOURCE_DIAGNOSTICS = resource.log.${PEERID:-master} | 17 | RESOURCE_DIAGNOSTICS = resource.log.${PEERID:-master} |
18 | 18 | ||
19 | [core] | 19 | [core] |
20 | FORECESTART = YES | 20 | FORCESTART = YES |
21 | 21 | ||
22 | [revocation] | 22 | [revocation] |
23 | FORECESTART = NO | 23 | FORCESTART = NO |
24 | 24 | ||
25 | [fs] | 25 | [fs] |
26 | FORECESTART = NO | 26 | FORCESTART = NO |
27 | 27 | ||
28 | [gns] | 28 | [gns] |
29 | FORECESTART = NO | 29 | FORCESTART = NO |
30 | |||
31 | [zonemaster] | ||
32 | FORCESTART = NO | ||
30 | 33 | ||
31 | [hostlist] | 34 | [hostlist] |
32 | FORECESTART = NO | 35 | FORCESTART = NO |
33 | 36 | ||
34 | [cadet] | 37 | [cadet] |
35 | #PREFIX = valgrind | 38 | #PREFIX = valgrind |
@@ -41,7 +44,7 @@ OPTIONS = -LERROR | |||
41 | [set] | 44 | [set] |
42 | #OPTIONS = -L INFO | 45 | #OPTIONS = -L INFO |
43 | #PREFIX = valgrind --leak-check=full | 46 | #PREFIX = valgrind --leak-check=full |
44 | PREFIX = valgrind | 47 | #PREFIX = valgrind |
45 | 48 | ||
46 | [testbed] | 49 | [testbed] |
47 | OVERLAY_TOPOLOGY = CLIQUE | 50 | OVERLAY_TOPOLOGY = CLIQUE |
diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c index 96349ae9d..24f8b21b2 100644 --- a/src/dht/plugin_block_dht.c +++ b/src/dht/plugin_block_dht.c | |||
@@ -237,7 +237,7 @@ libgnunet_plugin_block_dht_init (void *cls) | |||
237 | void * | 237 | void * |
238 | libgnunet_plugin_block_dht_done (void *cls) | 238 | libgnunet_plugin_block_dht_done (void *cls) |
239 | { | 239 | { |
240 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 240 | struct GNUNET_BLOCK_PluginFunctions *api = cls; |
241 | 241 | ||
242 | GNUNET_free (api); | 242 | GNUNET_free (api); |
243 | return NULL; | 243 | return NULL; |
diff --git a/src/fs/plugin_block_fs.c b/src/fs/plugin_block_fs.c index c5e63c9e2..902519f15 100644 --- a/src/fs/plugin_block_fs.c +++ b/src/fs/plugin_block_fs.c | |||
@@ -276,7 +276,7 @@ libgnunet_plugin_block_fs_init (void *cls) | |||
276 | void * | 276 | void * |
277 | libgnunet_plugin_block_fs_done (void *cls) | 277 | libgnunet_plugin_block_fs_done (void *cls) |
278 | { | 278 | { |
279 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 279 | struct GNUNET_BLOCK_PluginFunctions *api = cls; |
280 | 280 | ||
281 | GNUNET_free (api); | 281 | GNUNET_free (api); |
282 | return NULL; | 282 | return NULL; |
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c index 558ded6f4..a42fef953 100644 --- a/src/gns/plugin_block_gns.c +++ b/src/gns/plugin_block_gns.c | |||
@@ -238,7 +238,7 @@ libgnunet_plugin_block_gns_init (void *cls) | |||
238 | void * | 238 | void * |
239 | libgnunet_plugin_block_gns_done (void *cls) | 239 | libgnunet_plugin_block_gns_done (void *cls) |
240 | { | 240 | { |
241 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 241 | struct GNUNET_BLOCK_PluginFunctions *api = cls; |
242 | 242 | ||
243 | GNUNET_free (api); | 243 | GNUNET_free (api); |
244 | return NULL; | 244 | return NULL; |
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h index 3e36f11f0..d8ee68c21 100644 --- a/src/include/gnunet_block_lib.h +++ b/src/include/gnunet_block_lib.h | |||
@@ -112,6 +112,11 @@ enum GNUNET_BLOCK_Type | |||
112 | GNUNET_BLOCK_TYPE_GNS_NAMERECORD = 11, | 112 | GNUNET_BLOCK_TYPE_GNS_NAMERECORD = 11, |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Block type for a revocation message by which a key is revoked. | ||
116 | */ | ||
117 | GNUNET_BLOCK_TYPE_REVOCATION = 12, | ||
118 | |||
119 | /** | ||
115 | * Block to store a cadet regex state | 120 | * Block to store a cadet regex state |
116 | */ | 121 | */ |
117 | GNUNET_BLOCK_TYPE_REGEX = 22, | 122 | GNUNET_BLOCK_TYPE_REGEX = 22, |
diff --git a/src/include/gnunet_plugin_lib.h b/src/include/gnunet_plugin_lib.h index b76b9f9cf..9e3e72a21 100644 --- a/src/include/gnunet_plugin_lib.h +++ b/src/include/gnunet_plugin_lib.h | |||
@@ -87,7 +87,7 @@ GNUNET_PLUGIN_load (const char *library_name, | |||
87 | 87 | ||
88 | 88 | ||
89 | /** | 89 | /** |
90 | * Signature of a function called by 'GNUNET_PLUGIN_load_all'. | 90 | * Signature of a function called by #GNUNET_PLUGIN_load_all(). |
91 | * | 91 | * |
92 | * @param cls closure | 92 | * @param cls closure |
93 | * @param library_name full name of the library (to be used with | 93 | * @param library_name full name of the library (to be used with |
diff --git a/src/include/gnunet_sq_lib.h b/src/include/gnunet_sq_lib.h index 4484c2851..c03f83e07 100644 --- a/src/include/gnunet_sq_lib.h +++ b/src/include/gnunet_sq_lib.h | |||
@@ -252,7 +252,9 @@ struct GNUNET_SQ_ResultSpec | |||
252 | size_t dst_size; | 252 | size_t dst_size; |
253 | 253 | ||
254 | /** | 254 | /** |
255 | * Where to store actual size of the result. | 255 | * Where to store actual size of the result. If left at |
256 | * NULL, will be made to point to @e dst_size before | ||
257 | * @a conv is called. | ||
256 | */ | 258 | */ |
257 | size_t *result_size; | 259 | size_t *result_size; |
258 | 260 | ||
diff --git a/src/multicast/gnunet-service-multicast.c b/src/multicast/gnunet-service-multicast.c index d8a9c8f93..b068f1308 100644 --- a/src/multicast/gnunet-service-multicast.c +++ b/src/multicast/gnunet-service-multicast.c | |||
@@ -518,7 +518,7 @@ replay_req_remove_client (struct Group *grp, struct GNUNET_SERVICE_Client *clien | |||
518 | { | 518 | { |
519 | if (c == client) | 519 | if (c == client) |
520 | { | 520 | { |
521 | GNUNET_CONTAINER_multihashmap_remove (replay_req_client, &key, client); | 521 | GNUNET_CONTAINER_multihashmap_remove (grp_replay_req, &key, client); |
522 | GNUNET_CONTAINER_multihashmap_iterator_destroy (it); | 522 | GNUNET_CONTAINER_multihashmap_iterator_destroy (it); |
523 | return GNUNET_YES; | 523 | return GNUNET_YES; |
524 | } | 524 | } |
diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c index 180c5fc18..c5c8e56b9 100644 --- a/src/pq/pq_result_helper.c +++ b/src/pq/pq_result_helper.c | |||
@@ -77,9 +77,7 @@ extract_varsize_blob (void *cls, | |||
77 | fname); | 77 | fname); |
78 | if (fnum < 0) | 78 | if (fnum < 0) |
79 | { | 79 | { |
80 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 80 | GNUNET_break (0); |
81 | "Field `%s' does not exist in result\n", | ||
82 | fname); | ||
83 | return GNUNET_SYSERR; | 81 | return GNUNET_SYSERR; |
84 | } | 82 | } |
85 | if (PQgetisnull (result, | 83 | if (PQgetisnull (result, |
@@ -156,9 +154,7 @@ extract_fixed_blob (void *cls, | |||
156 | fname); | 154 | fname); |
157 | if (fnum < 0) | 155 | if (fnum < 0) |
158 | { | 156 | { |
159 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 157 | GNUNET_break (0); |
160 | "Field `%s' does not exist in result\n", | ||
161 | fname); | ||
162 | return GNUNET_SYSERR; | 158 | return GNUNET_SYSERR; |
163 | } | 159 | } |
164 | if (PQgetisnull (result, | 160 | if (PQgetisnull (result, |
@@ -173,11 +169,7 @@ extract_fixed_blob (void *cls, | |||
173 | fnum); | 169 | fnum); |
174 | if (*dst_size != len) | 170 | if (*dst_size != len) |
175 | { | 171 | { |
176 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 172 | GNUNET_break (0); |
177 | "Field `%s' has wrong size (got %u, expected %u)\n", | ||
178 | fname, | ||
179 | (unsigned int) len, | ||
180 | (unsigned int) *dst_size); | ||
181 | return GNUNET_SYSERR; | 173 | return GNUNET_SYSERR; |
182 | } | 174 | } |
183 | res = PQgetvalue (result, | 175 | res = PQgetvalue (result, |
@@ -243,9 +235,7 @@ extract_rsa_public_key (void *cls, | |||
243 | fname); | 235 | fname); |
244 | if (fnum < 0) | 236 | if (fnum < 0) |
245 | { | 237 | { |
246 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 238 | GNUNET_break (0); |
247 | "Field `%s' does not exist in result\n", | ||
248 | fname); | ||
249 | return GNUNET_SYSERR; | 239 | return GNUNET_SYSERR; |
250 | } | 240 | } |
251 | if (PQgetisnull (result, | 241 | if (PQgetisnull (result, |
@@ -265,9 +255,7 @@ extract_rsa_public_key (void *cls, | |||
265 | len); | 255 | len); |
266 | if (NULL == *pk) | 256 | if (NULL == *pk) |
267 | { | 257 | { |
268 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 258 | GNUNET_break (0); |
269 | "Field `%s' contains bogus value (fails to decode)\n", | ||
270 | fname); | ||
271 | return GNUNET_SYSERR; | 259 | return GNUNET_SYSERR; |
272 | } | 260 | } |
273 | return GNUNET_OK; | 261 | return GNUNET_OK; |
@@ -346,9 +334,7 @@ extract_rsa_signature (void *cls, | |||
346 | fname); | 334 | fname); |
347 | if (fnum < 0) | 335 | if (fnum < 0) |
348 | { | 336 | { |
349 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 337 | GNUNET_break (0); |
350 | "Field `%s' does not exist in result\n", | ||
351 | fname); | ||
352 | return GNUNET_SYSERR; | 338 | return GNUNET_SYSERR; |
353 | } | 339 | } |
354 | if (PQgetisnull (result, | 340 | if (PQgetisnull (result, |
@@ -368,9 +354,7 @@ extract_rsa_signature (void *cls, | |||
368 | len); | 354 | len); |
369 | if (NULL == *sig) | 355 | if (NULL == *sig) |
370 | { | 356 | { |
371 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 357 | GNUNET_break (0); |
372 | "Field `%s' contains bogus value (fails to decode)\n", | ||
373 | fname); | ||
374 | return GNUNET_SYSERR; | 358 | return GNUNET_SYSERR; |
375 | } | 359 | } |
376 | return GNUNET_OK; | 360 | return GNUNET_OK; |
@@ -449,9 +433,7 @@ extract_string (void *cls, | |||
449 | fname); | 433 | fname); |
450 | if (fnum < 0) | 434 | if (fnum < 0) |
451 | { | 435 | { |
452 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 436 | GNUNET_break (0); |
453 | "Field `%s' does not exist in result\n", | ||
454 | fname); | ||
455 | return GNUNET_SYSERR; | 437 | return GNUNET_SYSERR; |
456 | } | 438 | } |
457 | if (PQgetisnull (result, | 439 | if (PQgetisnull (result, |
@@ -471,9 +453,7 @@ extract_string (void *cls, | |||
471 | len); | 453 | len); |
472 | if (NULL == *str) | 454 | if (NULL == *str) |
473 | { | 455 | { |
474 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 456 | GNUNET_break (0); |
475 | "Field `%s' contains bogus value (fails to decode)\n", | ||
476 | fname); | ||
477 | return GNUNET_SYSERR; | 457 | return GNUNET_SYSERR; |
478 | } | 458 | } |
479 | return GNUNET_OK; | 459 | return GNUNET_OK; |
@@ -583,9 +563,7 @@ extract_uint16 (void *cls, | |||
583 | fname); | 563 | fname); |
584 | if (fnum < 0) | 564 | if (fnum < 0) |
585 | { | 565 | { |
586 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 566 | GNUNET_break (0); |
587 | "Field `%s' does not exist in result\n", | ||
588 | fname); | ||
589 | return GNUNET_SYSERR; | 567 | return GNUNET_SYSERR; |
590 | } | 568 | } |
591 | if (PQgetisnull (result, | 569 | if (PQgetisnull (result, |
@@ -655,9 +633,7 @@ extract_uint32 (void *cls, | |||
655 | fname); | 633 | fname); |
656 | if (fnum < 0) | 634 | if (fnum < 0) |
657 | { | 635 | { |
658 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 636 | GNUNET_break (0); |
659 | "Field `%s' does not exist in result\n", | ||
660 | fname); | ||
661 | return GNUNET_SYSERR; | 637 | return GNUNET_SYSERR; |
662 | } | 638 | } |
663 | if (PQgetisnull (result, | 639 | if (PQgetisnull (result, |
@@ -727,9 +703,7 @@ extract_uint64 (void *cls, | |||
727 | fname); | 703 | fname); |
728 | if (fnum < 0) | 704 | if (fnum < 0) |
729 | { | 705 | { |
730 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 706 | GNUNET_break (0); |
731 | "Field `%s' does not exist in result\n", | ||
732 | fname); | ||
733 | return GNUNET_SYSERR; | 707 | return GNUNET_SYSERR; |
734 | } | 708 | } |
735 | if (PQgetisnull (result, | 709 | if (PQgetisnull (result, |
diff --git a/src/regex/plugin_block_regex.c b/src/regex/plugin_block_regex.c index 0b3ef703e..287ecf905 100644 --- a/src/regex/plugin_block_regex.c +++ b/src/regex/plugin_block_regex.c | |||
@@ -395,7 +395,7 @@ libgnunet_plugin_block_regex_init (void *cls) | |||
395 | void * | 395 | void * |
396 | libgnunet_plugin_block_regex_done (void *cls) | 396 | libgnunet_plugin_block_regex_done (void *cls) |
397 | { | 397 | { |
398 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 398 | struct GNUNET_BLOCK_PluginFunctions *api = cls; |
399 | 399 | ||
400 | GNUNET_free (api); | 400 | GNUNET_free (api); |
401 | return NULL; | 401 | return NULL; |
diff --git a/src/revocation/Makefile.am b/src/revocation/Makefile.am index 541c7120d..82755b485 100644 --- a/src/revocation/Makefile.am +++ b/src/revocation/Makefile.am | |||
@@ -1,6 +1,8 @@ | |||
1 | # This Makefile.am is in the public domain | 1 | # This Makefile.am is in the public domain |
2 | AM_CPPFLAGS = -I$(top_srcdir)/src/include | 2 | AM_CPPFLAGS = -I$(top_srcdir)/src/include |
3 | 3 | ||
4 | plugindir = $(libdir)/gnunet | ||
5 | |||
4 | if MINGW | 6 | if MINGW |
5 | WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols | 7 | WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols |
6 | endif | 8 | endif |
@@ -21,6 +23,20 @@ bin_PROGRAMS = \ | |||
21 | gnunet-revocation | 23 | gnunet-revocation |
22 | 24 | ||
23 | 25 | ||
26 | plugin_LTLIBRARIES = \ | ||
27 | libgnunet_plugin_block_revocation.la | ||
28 | |||
29 | libgnunet_plugin_block_revocation_la_SOURCES = \ | ||
30 | plugin_block_revocation.c | ||
31 | libgnunet_plugin_block_revocation_la_LIBADD = \ | ||
32 | libgnunetrevocation.la \ | ||
33 | $(top_builddir)/src/block/libgnunetblockgroup.la \ | ||
34 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
35 | $(LTLIBINTL) | ||
36 | libgnunet_plugin_block_revocation_la_LDFLAGS = \ | ||
37 | $(GN_PLUGIN_LDFLAGS) | ||
38 | |||
39 | |||
24 | gnunet_revocation_SOURCES = \ | 40 | gnunet_revocation_SOURCES = \ |
25 | gnunet-revocation.c | 41 | gnunet-revocation.c |
26 | gnunet_revocation_LDADD = \ | 42 | gnunet_revocation_LDADD = \ |
@@ -86,4 +102,3 @@ test_local_revocation.py: test_local_revocation.py.in Makefile | |||
86 | 102 | ||
87 | EXTRA_DIST = test_revocation.conf \ | 103 | EXTRA_DIST = test_revocation.conf \ |
88 | test_local_revocation.py.in | 104 | test_local_revocation.py.in |
89 | |||
diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c index 99bec1fc8..9d077f874 100644 --- a/src/revocation/gnunet-service-revocation.c +++ b/src/revocation/gnunet-service-revocation.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include "platform.h" | 38 | #include "platform.h" |
39 | #include <math.h> | 39 | #include <math.h> |
40 | #include "gnunet_util_lib.h" | 40 | #include "gnunet_util_lib.h" |
41 | #include "gnunet_block_lib.h" | ||
41 | #include "gnunet_constants.h" | 42 | #include "gnunet_constants.h" |
42 | #include "gnunet_protocols.h" | 43 | #include "gnunet_protocols.h" |
43 | #include "gnunet_signatures.h" | 44 | #include "gnunet_signatures.h" |
@@ -215,7 +216,7 @@ client_connect_cb (void *cls, | |||
215 | * @param client the new client | 216 | * @param client the new client |
216 | * @param app_cls must alias @a client | 217 | * @param app_cls must alias @a client |
217 | */ | 218 | */ |
218 | static void | 219 | static void |
219 | client_disconnect_cb (void *cls, | 220 | client_disconnect_cb (void *cls, |
220 | struct GNUNET_SERVICE_Client *client, | 221 | struct GNUNET_SERVICE_Client *client, |
221 | void *app_cls) | 222 | void *app_cls) |
@@ -352,7 +353,7 @@ publicize_rm (const struct RevokeMessage *rm) | |||
352 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 353 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
353 | /* add to set for future connections */ | 354 | /* add to set for future connections */ |
354 | e.size = htons (rm->header.size); | 355 | e.size = htons (rm->header.size); |
355 | e.element_type = 0; | 356 | e.element_type = GNUNET_BLOCK_TYPE_REVOCATION; |
356 | e.data = rm; | 357 | e.data = rm; |
357 | if (GNUNET_OK != | 358 | if (GNUNET_OK != |
358 | GNUNET_SET_add_element (revocation_set, | 359 | GNUNET_SET_add_element (revocation_set, |
@@ -452,11 +453,12 @@ add_revocation (void *cls, | |||
452 | GNUNET_break_op (0); | 453 | GNUNET_break_op (0); |
453 | return; | 454 | return; |
454 | } | 455 | } |
455 | if (0 != element->element_type) | 456 | if (GNUNET_BLOCK_TYPE_REVOCATION != element->element_type) |
456 | { | 457 | { |
457 | GNUNET_STATISTICS_update (stats, | 458 | GNUNET_STATISTICS_update (stats, |
458 | gettext_noop ("# unsupported revocations received via set union"), | 459 | gettext_noop ("# unsupported revocations received via set union"), |
459 | 1, GNUNET_NO); | 460 | 1, |
461 | GNUNET_NO); | ||
460 | return; | 462 | return; |
461 | } | 463 | } |
462 | rm = element->data; | 464 | rm = element->data; |
@@ -604,12 +606,12 @@ handle_core_disconnect (void *cls, | |||
604 | void *internal_cls) | 606 | void *internal_cls) |
605 | { | 607 | { |
606 | struct PeerEntry *peer_entry = internal_cls; | 608 | struct PeerEntry *peer_entry = internal_cls; |
607 | 609 | ||
608 | if (0 == memcmp (peer, | 610 | if (0 == memcmp (peer, |
609 | &my_identity, | 611 | &my_identity, |
610 | sizeof (my_identity))) | 612 | sizeof (my_identity))) |
611 | return; | 613 | return; |
612 | GNUNET_assert (NULL != peer_entry); | 614 | GNUNET_assert (NULL != peer_entry); |
613 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 615 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
614 | "Peer `%s' disconnected from us\n", | 616 | "Peer `%s' disconnected from us\n", |
615 | GNUNET_i2s (peer)); | 617 | GNUNET_i2s (peer)); |
@@ -783,7 +785,7 @@ handle_revocation_union_request (void *cls, | |||
783 | static void | 785 | static void |
784 | run (void *cls, | 786 | run (void *cls, |
785 | const struct GNUNET_CONFIGURATION_Handle *c, | 787 | const struct GNUNET_CONFIGURATION_Handle *c, |
786 | struct GNUNET_SERVICE_Handle *service) | 788 | struct GNUNET_SERVICE_Handle *service) |
787 | { | 789 | { |
788 | struct GNUNET_MQ_MessageHandler core_handlers[] = { | 790 | struct GNUNET_MQ_MessageHandler core_handlers[] = { |
789 | GNUNET_MQ_hd_fixed_size (p2p_revoke, | 791 | GNUNET_MQ_hd_fixed_size (p2p_revoke, |
diff --git a/src/revocation/plugin_block_revocation.c b/src/revocation/plugin_block_revocation.c new file mode 100644 index 000000000..eb0766b81 --- /dev/null +++ b/src/revocation/plugin_block_revocation.c | |||
@@ -0,0 +1,257 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2017 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | 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 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file block/plugin_block_revocation.c | ||
23 | * @brief revocation for a block plugin | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | |||
27 | #include "platform.h" | ||
28 | #include "gnunet_signatures.h" | ||
29 | #include "gnunet_block_plugin.h" | ||
30 | #include "gnunet_block_group_lib.h" | ||
31 | #include "revocation.h" | ||
32 | #include "gnunet_revocation_service.h" | ||
33 | |||
34 | #define DEBUG_REVOCATION GNUNET_EXTRA_LOGGING | ||
35 | |||
36 | /** | ||
37 | * Number of bits we set per entry in the bloomfilter. | ||
38 | * Do not change! | ||
39 | */ | ||
40 | #define BLOOMFILTER_K 16 | ||
41 | |||
42 | |||
43 | /** | ||
44 | * How big is the BF we use for DHT blocks? | ||
45 | */ | ||
46 | #define REVOCATION_BF_SIZE 8 | ||
47 | |||
48 | |||
49 | /** | ||
50 | * Context used inside the plugin. | ||
51 | */ | ||
52 | struct InternalContext | ||
53 | { | ||
54 | |||
55 | unsigned int matching_bits; | ||
56 | |||
57 | }; | ||
58 | |||
59 | |||
60 | /** | ||
61 | * Create a new block group. | ||
62 | * | ||
63 | * @param ctx block context in which the block group is created | ||
64 | * @param type type of the block for which we are creating the group | ||
65 | * @param nonce random value used to seed the group creation | ||
66 | * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh | ||
67 | * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh | ||
68 | * @param va variable arguments specific to @a type | ||
69 | * @return block group handle, NULL if block groups are not supported | ||
70 | * by this @a type of block (this is not an error) | ||
71 | */ | ||
72 | static struct GNUNET_BLOCK_Group * | ||
73 | block_plugin_revocation_create_group (void *cls, | ||
74 | enum GNUNET_BLOCK_Type type, | ||
75 | uint32_t nonce, | ||
76 | const void *raw_data, | ||
77 | size_t raw_data_size, | ||
78 | va_list va) | ||
79 | { | ||
80 | unsigned int bf_size; | ||
81 | const char *guard; | ||
82 | |||
83 | guard = va_arg (va, const char *); | ||
84 | if (0 == strcmp (guard, | ||
85 | "seen-set-size")) | ||
86 | bf_size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size (va_arg (va, unsigned int), | ||
87 | BLOOMFILTER_K); | ||
88 | else if (0 == strcmp (guard, | ||
89 | "filter-size")) | ||
90 | bf_size = va_arg (va, unsigned int); | ||
91 | else | ||
92 | { | ||
93 | GNUNET_break (0); | ||
94 | bf_size = REVOCATION_BF_SIZE; | ||
95 | } | ||
96 | GNUNET_break (NULL == va_arg (va, const char *)); | ||
97 | return GNUNET_BLOCK_GROUP_bf_create (cls, | ||
98 | bf_size, | ||
99 | BLOOMFILTER_K, | ||
100 | type, | ||
101 | nonce, | ||
102 | raw_data, | ||
103 | raw_data_size); | ||
104 | } | ||
105 | |||
106 | |||
107 | /** | ||
108 | * Function called to validate a reply or a request. For | ||
109 | * request evaluation, simply pass "NULL" for the reply_block. | ||
110 | * | ||
111 | * @param cls our `struct InternalContext` | ||
112 | * @param ctx context | ||
113 | * @param type block type | ||
114 | * @param group block group to use | ||
115 | * @param eo control flags | ||
116 | * @param query original query (hash) | ||
117 | * @param xquery extrended query data (can be NULL, depending on type) | ||
118 | * @param xquery_size number of bytes in xquery | ||
119 | * @param reply_block response to validate | ||
120 | * @param reply_block_size number of bytes in reply block | ||
121 | * @return characterization of result | ||
122 | */ | ||
123 | static enum GNUNET_BLOCK_EvaluationResult | ||
124 | block_plugin_revocation_evaluate (void *cls, | ||
125 | struct GNUNET_BLOCK_Context *ctx, | ||
126 | enum GNUNET_BLOCK_Type type, | ||
127 | struct GNUNET_BLOCK_Group *group, | ||
128 | enum GNUNET_BLOCK_EvaluationOptions eo, | ||
129 | const struct GNUNET_HashCode *query, | ||
130 | const void *xquery, | ||
131 | size_t xquery_size, | ||
132 | const void *reply_block, | ||
133 | size_t reply_block_size) | ||
134 | { | ||
135 | struct InternalContext *ic = cls; | ||
136 | struct GNUNET_HashCode chash; | ||
137 | const struct RevokeMessage *rm = reply_block; | ||
138 | |||
139 | if (NULL == reply_block) | ||
140 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | ||
141 | if (reply_block_size != sizeof (*rm)) | ||
142 | { | ||
143 | GNUNET_break_op (0); | ||
144 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
145 | } | ||
146 | if (GNUNET_YES != | ||
147 | GNUNET_REVOCATION_check_pow (&rm->public_key, | ||
148 | rm->proof_of_work, | ||
149 | ic->matching_bits)) | ||
150 | { | ||
151 | GNUNET_break_op (0); | ||
152 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
153 | } | ||
154 | if (GNUNET_OK != | ||
155 | GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_REVOCATION, | ||
156 | &rm->purpose, | ||
157 | &rm->signature, | ||
158 | &rm->public_key)) | ||
159 | { | ||
160 | GNUNET_break_op (0); | ||
161 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
162 | } | ||
163 | GNUNET_CRYPTO_hash (&rm->public_key, | ||
164 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), | ||
165 | &chash); | ||
166 | if (GNUNET_YES == | ||
167 | GNUNET_BLOCK_GROUP_bf_test_and_set (group, | ||
168 | &chash)) | ||
169 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; | ||
170 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | ||
171 | } | ||
172 | |||
173 | |||
174 | /** | ||
175 | * Function called to obtain the key for a block. | ||
176 | * | ||
177 | * @param cls closure | ||
178 | * @param type block type | ||
179 | * @param block block to get the key for | ||
180 | * @param block_size number of bytes in block | ||
181 | * @param key set to the key (query) for the given block | ||
182 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported | ||
183 | * (or if extracting a key from a block of this type does not work) | ||
184 | */ | ||
185 | static int | ||
186 | block_plugin_revocation_get_key (void *cls, | ||
187 | enum GNUNET_BLOCK_Type type, | ||
188 | const void *block, | ||
189 | size_t block_size, | ||
190 | struct GNUNET_HashCode *key) | ||
191 | { | ||
192 | const struct RevokeMessage *rm = block; | ||
193 | |||
194 | if (block_size != sizeof (*rm)) | ||
195 | { | ||
196 | GNUNET_break_op (0); | ||
197 | return GNUNET_SYSERR; | ||
198 | } | ||
199 | GNUNET_CRYPTO_hash (&rm->public_key, | ||
200 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), | ||
201 | key); | ||
202 | return GNUNET_OK; | ||
203 | } | ||
204 | |||
205 | |||
206 | /** | ||
207 | * Entry point for the plugin. | ||
208 | * | ||
209 | * @param cls the configuration to use | ||
210 | */ | ||
211 | void * | ||
212 | libgnunet_plugin_block_revocation_init (void *cls) | ||
213 | { | ||
214 | static enum GNUNET_BLOCK_Type types[] = | ||
215 | { | ||
216 | GNUNET_BLOCK_TYPE_REVOCATION, | ||
217 | GNUNET_BLOCK_TYPE_ANY /* end of list */ | ||
218 | }; | ||
219 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | ||
220 | struct GNUNET_BLOCK_PluginFunctions *api; | ||
221 | struct InternalContext *ic; | ||
222 | unsigned long long matching_bits; | ||
223 | |||
224 | if (GNUNET_OK != | ||
225 | GNUNET_CONFIGURATION_get_value_number (cfg, | ||
226 | "REVOCATION", | ||
227 | "WORKBITS", | ||
228 | &matching_bits)) | ||
229 | return NULL; | ||
230 | |||
231 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); | ||
232 | api->evaluate = &block_plugin_revocation_evaluate; | ||
233 | api->get_key = &block_plugin_revocation_get_key; | ||
234 | api->create_group = &block_plugin_revocation_create_group; | ||
235 | api->types = types; | ||
236 | ic = GNUNET_new (struct InternalContext); | ||
237 | ic->matching_bits = (unsigned int) matching_bits; | ||
238 | api->cls = ic; | ||
239 | return api; | ||
240 | } | ||
241 | |||
242 | |||
243 | /** | ||
244 | * Exit point from the plugin. | ||
245 | */ | ||
246 | void * | ||
247 | libgnunet_plugin_block_revocation_done (void *cls) | ||
248 | { | ||
249 | struct GNUNET_BLOCK_PluginFunctions *api = cls; | ||
250 | struct InternalContext *ic = api->cls; | ||
251 | |||
252 | GNUNET_free (ic); | ||
253 | GNUNET_free (api); | ||
254 | return NULL; | ||
255 | } | ||
256 | |||
257 | /* end of plugin_block_revocation.c */ | ||
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c index 30d43e8a1..454ad9784 100644 --- a/src/set/gnunet-service-set.c +++ b/src/set/gnunet-service-set.c | |||
@@ -223,6 +223,9 @@ listener_destroy (struct Listener *listener) | |||
223 | { | 223 | { |
224 | struct GNUNET_SERVICE_Client *client = listener->client; | 224 | struct GNUNET_SERVICE_Client *client = listener->client; |
225 | 225 | ||
226 | GNUNET_MQ_destroy (listener->client_mq); | ||
227 | listener->client_mq = NULL; | ||
228 | |||
226 | listener->client = NULL; | 229 | listener->client = NULL; |
227 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 230 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
228 | "Disconnecting listener client\n"); | 231 | "Disconnecting listener client\n"); |
@@ -611,42 +614,6 @@ client_connect_cb (void *cls, | |||
611 | 614 | ||
612 | 615 | ||
613 | /** | 616 | /** |
614 | * Clean up after a client has disconnected | ||
615 | * | ||
616 | * @param cls closure, unused | ||
617 | * @param client the client to clean up after | ||
618 | * @param internal_cls our client-specific internal data structure | ||
619 | */ | ||
620 | static void | ||
621 | client_disconnect_cb (void *cls, | ||
622 | struct GNUNET_SERVICE_Client *client, | ||
623 | void *internal_cls) | ||
624 | { | ||
625 | struct Listener *listener; | ||
626 | struct Set *set; | ||
627 | |||
628 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
629 | "client disconnected, cleaning up\n"); | ||
630 | set = set_get (client); | ||
631 | if (NULL != set) | ||
632 | { | ||
633 | set->client = NULL; | ||
634 | set_destroy (set); | ||
635 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
636 | "Client's set destroyed\n"); | ||
637 | } | ||
638 | listener = listener_get (client); | ||
639 | if (NULL != listener) | ||
640 | { | ||
641 | listener->client = NULL; | ||
642 | listener_destroy (listener); | ||
643 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
644 | "Client's listener destroyed\n"); | ||
645 | } | ||
646 | } | ||
647 | |||
648 | |||
649 | /** | ||
650 | * Destroy an incoming request from a remote peer | 617 | * Destroy an incoming request from a remote peer |
651 | * | 618 | * |
652 | * @param incoming remote request to destroy | 619 | * @param incoming remote request to destroy |
@@ -681,6 +648,54 @@ incoming_destroy (struct Operation *incoming) | |||
681 | 648 | ||
682 | 649 | ||
683 | /** | 650 | /** |
651 | * Clean up after a client has disconnected | ||
652 | * | ||
653 | * @param cls closure, unused | ||
654 | * @param client the client to clean up after | ||
655 | * @param internal_cls our client-specific internal data structure | ||
656 | */ | ||
657 | static void | ||
658 | client_disconnect_cb (void *cls, | ||
659 | struct GNUNET_SERVICE_Client *client, | ||
660 | void *internal_cls) | ||
661 | { | ||
662 | struct Set *set; | ||
663 | |||
664 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
665 | "client disconnected, cleaning up\n"); | ||
666 | set = set_get (client); | ||
667 | if (NULL != set) | ||
668 | { | ||
669 | set->client = NULL; | ||
670 | set_destroy (set); | ||
671 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
672 | "Client's set destroyed\n"); | ||
673 | } | ||
674 | struct Listener *listener = listener_get (client); | ||
675 | if (NULL != listener) | ||
676 | { | ||
677 | /* destroy all incoming operations whose client just | ||
678 | * got destroyed */ | ||
679 | //struct Operation *op = incoming_head; | ||
680 | /* | ||
681 | while (NULL != op) | ||
682 | { | ||
683 | struct Operation *curr = op; | ||
684 | op = op->next; | ||
685 | if ( (GNUNET_YES == curr->is_incoming) && | ||
686 | (curr->listener == listener) ) | ||
687 | incoming_destroy (curr); | ||
688 | } | ||
689 | */ | ||
690 | listener->client = NULL; | ||
691 | listener_destroy (listener); | ||
692 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
693 | "Client's listener destroyed\n"); | ||
694 | } | ||
695 | } | ||
696 | |||
697 | |||
698 | /** | ||
684 | * Suggest the given request to the listener. The listening client can | 699 | * Suggest the given request to the listener. The listening client can |
685 | * then accept or reject the remote request. | 700 | * then accept or reject the remote request. |
686 | * | 701 | * |
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c index c69aa2a9c..b5b602074 100644 --- a/src/set/gnunet-service-set_union.c +++ b/src/set/gnunet-service-set_union.c | |||
@@ -761,7 +761,8 @@ get_order_from_difference (unsigned int diff) | |||
761 | ibf_order++; | 761 | ibf_order++; |
762 | if (ibf_order > MAX_IBF_ORDER) | 762 | if (ibf_order > MAX_IBF_ORDER) |
763 | ibf_order = MAX_IBF_ORDER; | 763 | ibf_order = MAX_IBF_ORDER; |
764 | return ibf_order; | 764 | // add one for correction |
765 | return ibf_order + 1; | ||
765 | } | 766 | } |
766 | 767 | ||
767 | 768 | ||
@@ -872,6 +873,12 @@ handle_p2p_strata_estimator (void *cls, | |||
872 | GNUNET_assert (NULL != op->state->se); | 873 | GNUNET_assert (NULL != op->state->se); |
873 | diff = strata_estimator_difference (remote_se, | 874 | diff = strata_estimator_difference (remote_se, |
874 | op->state->se); | 875 | op->state->se); |
876 | |||
877 | if (diff > 200) | ||
878 | diff = diff * 3 / 2; | ||
879 | |||
880 | |||
881 | |||
875 | strata_estimator_destroy (remote_se); | 882 | strata_estimator_destroy (remote_se); |
876 | strata_estimator_destroy (op->state->se); | 883 | strata_estimator_destroy (op->state->se); |
877 | op->state->se = NULL; | 884 | op->state->se = NULL; |
@@ -880,6 +887,17 @@ handle_p2p_strata_estimator (void *cls, | |||
880 | diff, | 887 | diff, |
881 | 1<<get_order_from_difference (diff)); | 888 | 1<<get_order_from_difference (diff)); |
882 | 889 | ||
890 | { | ||
891 | char *set_debug; | ||
892 | set_debug = getenv ("GNUNET_SET_BENCHMARK"); | ||
893 | if ( (NULL != set_debug) && (0 == strcmp (set_debug, "1")) ) | ||
894 | { | ||
895 | FILE *f = fopen ("set.log", "a"); | ||
896 | fprintf (f, "%llu\n", (unsigned long long) diff); | ||
897 | fclose (f); | ||
898 | } | ||
899 | } | ||
900 | |||
883 | if ((GNUNET_YES == op->spec->byzantine) && (other_size < op->spec->byzantine_lower_bound)) | 901 | if ((GNUNET_YES == op->spec->byzantine) && (other_size < op->spec->byzantine_lower_bound)) |
884 | { | 902 | { |
885 | GNUNET_break (0); | 903 | GNUNET_break (0); |
@@ -888,12 +906,16 @@ handle_p2p_strata_estimator (void *cls, | |||
888 | } | 906 | } |
889 | 907 | ||
890 | 908 | ||
891 | if ( (GNUNET_YES == op->spec->force_full) || (diff > op->state->initial_size / 2)) | 909 | if ( (GNUNET_YES == op->spec->force_full) || (diff > op->state->initial_size / 4)) |
892 | { | 910 | { |
893 | LOG (GNUNET_ERROR_TYPE_INFO, | 911 | LOG (GNUNET_ERROR_TYPE_INFO, |
894 | "Sending full set (diff=%d, own set=%u)\n", | 912 | "Sending full set (diff=%d, own set=%u)\n", |
895 | diff, | 913 | diff, |
896 | op->state->initial_size); | 914 | op->state->initial_size); |
915 | GNUNET_STATISTICS_update (_GSS_statistics, | ||
916 | "# of full sends", | ||
917 | 1, | ||
918 | GNUNET_NO); | ||
897 | if (op->state->initial_size <= other_size) | 919 | if (op->state->initial_size <= other_size) |
898 | { | 920 | { |
899 | send_full_set (op); | 921 | send_full_set (op); |
@@ -908,6 +930,10 @@ handle_p2p_strata_estimator (void *cls, | |||
908 | } | 930 | } |
909 | else | 931 | else |
910 | { | 932 | { |
933 | GNUNET_STATISTICS_update (_GSS_statistics, | ||
934 | "# of ibf sends", | ||
935 | 1, | ||
936 | GNUNET_NO); | ||
911 | if (GNUNET_OK != | 937 | if (GNUNET_OK != |
912 | send_ibf (op, | 938 | send_ibf (op, |
913 | get_order_from_difference (diff))) | 939 | get_order_from_difference (diff))) |
@@ -1556,10 +1582,14 @@ handle_p2p_full_element (void *cls, | |||
1556 | } | 1582 | } |
1557 | 1583 | ||
1558 | if ( (GNUNET_YES == op->spec->byzantine) && | 1584 | if ( (GNUNET_YES == op->spec->byzantine) && |
1559 | (op->state->received_total > 8) && | 1585 | (op->state->received_total > 384 + op->state->received_fresh * 4) && |
1560 | (op->state->received_fresh < op->state->received_total / 3) ) | 1586 | (op->state->received_fresh < op->state->received_total / 6) ) |
1561 | { | 1587 | { |
1562 | /* The other peer gave us lots of old elements, there's something wrong. */ | 1588 | /* The other peer gave us lots of old elements, there's something wrong. */ |
1589 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
1590 | "Other peer sent only %llu/%llu fresh elements, failing operation\n", | ||
1591 | (unsigned long long) op->state->received_fresh, | ||
1592 | (unsigned long long) op->state->received_total); | ||
1563 | GNUNET_break_op (0); | 1593 | GNUNET_break_op (0); |
1564 | fail_union_operation (op); | 1594 | fail_union_operation (op); |
1565 | return; | 1595 | return; |
diff --git a/src/set/gnunet-set-profiler.c b/src/set/gnunet-set-profiler.c index d83e034a6..8404b191c 100644 --- a/src/set/gnunet-set-profiler.c +++ b/src/set/gnunet-set-profiler.c | |||
@@ -61,6 +61,7 @@ static struct GNUNET_SET_ListenHandle *set_listener; | |||
61 | static int byzantine; | 61 | static int byzantine; |
62 | static int force_delta; | 62 | static int force_delta; |
63 | static int force_full; | 63 | static int force_full; |
64 | static unsigned int element_size = 32; | ||
64 | 65 | ||
65 | /** | 66 | /** |
66 | * Handle to the statistics service. | 67 | * Handle to the statistics service. |
@@ -90,7 +91,7 @@ map_remove_iterator (void *cls, | |||
90 | 91 | ||
91 | GNUNET_assert (NULL != key); | 92 | GNUNET_assert (NULL != key); |
92 | 93 | ||
93 | ret = GNUNET_CONTAINER_multihashmap_remove (m, key, NULL); | 94 | ret = GNUNET_CONTAINER_multihashmap_remove_all (m, key); |
94 | if (GNUNET_OK != ret) | 95 | if (GNUNET_OK != ret) |
95 | printf ("spurious element\n"); | 96 | printf ("spurious element\n"); |
96 | return GNUNET_YES; | 97 | return GNUNET_YES; |
@@ -196,7 +197,7 @@ set_result_cb (void *cls, | |||
196 | GNUNET_assert (0); | 197 | GNUNET_assert (0); |
197 | } | 198 | } |
198 | 199 | ||
199 | if (element->size != sizeof (struct GNUNET_HashCode)) | 200 | if (element->size != element_size) |
200 | { | 201 | { |
201 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 202 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
202 | "wrong element size: %u, expected %u\n", | 203 | "wrong element size: %u, expected %u\n", |
@@ -208,8 +209,10 @@ set_result_cb (void *cls, | |||
208 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set %s: got element (%s)\n", | 209 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set %s: got element (%s)\n", |
209 | info->id, GNUNET_h2s (element->data)); | 210 | info->id, GNUNET_h2s (element->data)); |
210 | GNUNET_assert (NULL != element->data); | 211 | GNUNET_assert (NULL != element->data); |
212 | struct GNUNET_HashCode data_hash; | ||
213 | GNUNET_CRYPTO_hash (element->data, element_size, &data_hash); | ||
211 | GNUNET_CONTAINER_multihashmap_put (info->received, | 214 | GNUNET_CONTAINER_multihashmap_put (info->received, |
212 | element->data, NULL, | 215 | &data_hash, NULL, |
213 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); | 216 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); |
214 | } | 217 | } |
215 | 218 | ||
@@ -261,16 +264,12 @@ set_insert_iterator (void *cls, | |||
261 | void *value) | 264 | void *value) |
262 | { | 265 | { |
263 | struct GNUNET_SET_Handle *set = cls; | 266 | struct GNUNET_SET_Handle *set = cls; |
264 | struct GNUNET_SET_Element *el; | 267 | struct GNUNET_SET_Element el; |
265 | 268 | ||
266 | el = GNUNET_malloc (sizeof (struct GNUNET_SET_Element) + | 269 | el.element_type = 0; |
267 | sizeof (struct GNUNET_HashCode)); | 270 | el.data = value; |
268 | el->element_type = 0; | 271 | el.size = element_size; |
269 | GNUNET_memcpy (&el[1], key, sizeof *key); | 272 | GNUNET_SET_add_element (set, &el, NULL, NULL); |
270 | el->data = &el[1]; | ||
271 | el->size = sizeof *key; | ||
272 | GNUNET_SET_add_element (set, el, NULL, NULL); | ||
273 | GNUNET_free (el); | ||
274 | return GNUNET_YES; | 273 | return GNUNET_YES; |
275 | } | 274 | } |
276 | 275 | ||
@@ -322,6 +321,8 @@ run (void *cls, | |||
322 | 321 | ||
323 | config = cfg; | 322 | config = cfg; |
324 | 323 | ||
324 | GNUNET_assert (element_size > 0); | ||
325 | |||
325 | if (GNUNET_OK != GNUNET_CRYPTO_get_peer_identity (cfg, &local_peer)) | 326 | if (GNUNET_OK != GNUNET_CRYPTO_get_peer_identity (cfg, &local_peer)) |
326 | { | 327 | { |
327 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "could not retrieve host identity\n"); | 328 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "could not retrieve host identity\n"); |
@@ -345,22 +346,28 @@ run (void *cls, | |||
345 | 346 | ||
346 | for (i = 0; i < num_a; i++) | 347 | for (i = 0; i < num_a; i++) |
347 | { | 348 | { |
348 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash); | 349 | char *data = GNUNET_malloc (element_size); |
349 | GNUNET_CONTAINER_multihashmap_put (info1.sent, &hash, NULL, | 350 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, data, element_size); |
351 | GNUNET_CRYPTO_hash (data, element_size, &hash); | ||
352 | GNUNET_CONTAINER_multihashmap_put (info1.sent, &hash, data, | ||
350 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); | 353 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); |
351 | } | 354 | } |
352 | 355 | ||
353 | for (i = 0; i < num_b; i++) | 356 | for (i = 0; i < num_b; i++) |
354 | { | 357 | { |
355 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash); | 358 | char *data = GNUNET_malloc (element_size); |
356 | GNUNET_CONTAINER_multihashmap_put (info2.sent, &hash, NULL, | 359 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, data, element_size); |
360 | GNUNET_CRYPTO_hash (data, element_size, &hash); | ||
361 | GNUNET_CONTAINER_multihashmap_put (info2.sent, &hash, data, | ||
357 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); | 362 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); |
358 | } | 363 | } |
359 | 364 | ||
360 | for (i = 0; i < num_c; i++) | 365 | for (i = 0; i < num_c; i++) |
361 | { | 366 | { |
362 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash); | 367 | char *data = GNUNET_malloc (element_size); |
363 | GNUNET_CONTAINER_multihashmap_put (common_sent, &hash, NULL, | 368 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, data, element_size); |
369 | GNUNET_CRYPTO_hash (data, element_size, &hash); | ||
370 | GNUNET_CONTAINER_multihashmap_put (common_sent, &hash, data, | ||
364 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); | 371 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); |
365 | } | 372 | } |
366 | 373 | ||
@@ -441,6 +448,9 @@ main (int argc, char **argv) | |||
441 | { 'x', "operation", NULL, | 448 | { 'x', "operation", NULL, |
442 | gettext_noop ("operation to execute"), | 449 | gettext_noop ("operation to execute"), |
443 | GNUNET_YES, &GNUNET_GETOPT_set_string, &op_str }, | 450 | GNUNET_YES, &GNUNET_GETOPT_set_string, &op_str }, |
451 | { 'w', "element-size", NULL, | ||
452 | gettext_noop ("element size"), | ||
453 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &element_size }, | ||
444 | { 's', "statistics", NULL, | 454 | { 's', "statistics", NULL, |
445 | gettext_noop ("write statistics to file"), | 455 | gettext_noop ("write statistics to file"), |
446 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &statistics_filename }, | 456 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &statistics_filename }, |
diff --git a/src/set/plugin_block_set_test.c b/src/set/plugin_block_set_test.c index c4f73abe0..01b0c8602 100644 --- a/src/set/plugin_block_set_test.c +++ b/src/set/plugin_block_set_test.c | |||
@@ -114,7 +114,7 @@ libgnunet_plugin_block_set_test_init (void *cls) | |||
114 | void * | 114 | void * |
115 | libgnunet_plugin_block_set_test_done (void *cls) | 115 | libgnunet_plugin_block_set_test_done (void *cls) |
116 | { | 116 | { |
117 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 117 | struct GNUNET_BLOCK_PluginFunctions *api = cls; |
118 | 118 | ||
119 | GNUNET_free (api); | 119 | GNUNET_free (api); |
120 | return NULL; | 120 | return NULL; |
diff --git a/src/set/set_api.c b/src/set/set_api.c index 5b5b1b8ee..04a4e4910 100644 --- a/src/set/set_api.c +++ b/src/set/set_api.c | |||
@@ -349,6 +349,9 @@ handle_iter_done (void *cls, | |||
349 | set->iteration_id++; | 349 | set->iteration_id++; |
350 | iter (set->iterator_cls, | 350 | iter (set->iterator_cls, |
351 | NULL); | 351 | NULL); |
352 | |||
353 | if (GNUNET_YES == set->destroy_requested) | ||
354 | GNUNET_SET_destroy (set); | ||
352 | } | 355 | } |
353 | 356 | ||
354 | 357 | ||
@@ -733,8 +736,7 @@ GNUNET_SET_destroy (struct GNUNET_SET_Handle *set) | |||
733 | /* destroying set while iterator is active is currently | 736 | /* destroying set while iterator is active is currently |
734 | not supported; we should expand the API to allow | 737 | not supported; we should expand the API to allow |
735 | clients to explicitly cancel the iteration! */ | 738 | clients to explicitly cancel the iteration! */ |
736 | GNUNET_assert (NULL == set->iterator); | 739 | if ( (NULL != set->ops_head) || (NULL != set->iterator) ) |
737 | if (NULL != set->ops_head) | ||
738 | { | 740 | { |
739 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 741 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
740 | "Set operations are pending, delaying set destruction\n"); | 742 | "Set operations are pending, delaying set destruction\n"); |
diff --git a/src/sq/sq.c b/src/sq/sq.c index 47fcaf24e..dc4416761 100644 --- a/src/sq/sq.c +++ b/src/sq/sq.c | |||
@@ -75,6 +75,8 @@ GNUNET_SQ_extract_result (sqlite3_stmt *result, | |||
75 | 75 | ||
76 | for (unsigned int i=0;NULL != rs[i].conv; i++) | 76 | for (unsigned int i=0;NULL != rs[i].conv; i++) |
77 | { | 77 | { |
78 | if (NULL == rs[i].result_size) | ||
79 | rs[i].result_size = &rs[i].dst_size; | ||
78 | if (GNUNET_OK != | 80 | if (GNUNET_OK != |
79 | rs[i].conv (rs[i].cls, | 81 | rs[i].conv (rs[i].cls, |
80 | result, | 82 | result, |
diff --git a/src/sq/sq_result_helper.c b/src/sq/sq_result_helper.c index 36ce53317..eaf606aa4 100644 --- a/src/sq/sq_result_helper.c +++ b/src/sq/sq_result_helper.c | |||
@@ -24,26 +24,75 @@ | |||
24 | 24 | ||
25 | 25 | ||
26 | /** | 26 | /** |
27 | * Extract fixed-sized binary data from a Postgres database @a result at row @a row. | 27 | * Extract variable-sized binary data from a Postgres database @a result at row @a row. |
28 | * | 28 | * |
29 | * @param cls closure | 29 | * @param cls closure |
30 | * @param result where to extract data from | 30 | * @param result where to extract data from |
31 | * @param row row to extract data from | ||
32 | * @param column column to extract data from | 31 | * @param column column to extract data from |
33 | * @param[in,out] dst_size where to store size of result, may be NULL | 32 | * @param[in,out] dst_size where to store size of result, may be NULL |
34 | * @param[out] dst where to store the result | 33 | * @param[out] dst where to store the result (actually a `void **`) |
35 | * @return | 34 | * @return |
36 | * #GNUNET_YES if all results could be extracted | 35 | * #GNUNET_YES if all results could be extracted |
37 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 36 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
38 | */ | 37 | */ |
39 | static int | 38 | static int |
40 | extract_fixed_blob (void *cls, | 39 | extract_var_blob (void *cls, |
41 | sqlite3_stmt *result, | 40 | sqlite3_stmt *result, |
42 | int row, | 41 | unsigned int column, |
43 | unsigned int column, | 42 | size_t *dst_size, |
44 | size_t *dst_size, | 43 | void *dst) |
45 | void *dst) | ||
46 | { | 44 | { |
45 | int have; | ||
46 | const void *ret; | ||
47 | void **rdst = (void **) dst; | ||
48 | |||
49 | if (SQLITE_BLOB != | ||
50 | sqlite3_column_type (result, | ||
51 | column)) | ||
52 | { | ||
53 | GNUNET_break (0); | ||
54 | return GNUNET_SYSERR; | ||
55 | } | ||
56 | /* sqlite manual says to invoke 'sqlite3_column_blob()' | ||
57 | before calling sqlite3_column_bytes() */ | ||
58 | ret = sqlite3_column_blob (result, | ||
59 | column); | ||
60 | have = sqlite3_column_bytes (result, | ||
61 | column); | ||
62 | if (have < 0) | ||
63 | { | ||
64 | GNUNET_break (0); | ||
65 | return GNUNET_SYSERR; | ||
66 | } | ||
67 | *dst_size = have; | ||
68 | if (0 == have) | ||
69 | { | ||
70 | *rdst = NULL; | ||
71 | return GNUNET_OK; | ||
72 | } | ||
73 | *rdst = GNUNET_malloc (have); | ||
74 | GNUNET_memcpy (*rdst, | ||
75 | ret, | ||
76 | have); | ||
77 | return GNUNET_OK; | ||
78 | } | ||
79 | |||
80 | |||
81 | /** | ||
82 | * Cleanup memory allocated by #extract_var_blob(). | ||
83 | * | ||
84 | * @param cls pointer to pointer of allocation | ||
85 | */ | ||
86 | static void | ||
87 | clean_var_blob (void *cls) | ||
88 | { | ||
89 | void **dptr = (void **) cls; | ||
90 | |||
91 | if (NULL != *dptr) | ||
92 | { | ||
93 | GNUNET_free (*dptr); | ||
94 | *dptr = NULL; | ||
95 | } | ||
47 | } | 96 | } |
48 | 97 | ||
49 | 98 | ||
@@ -58,6 +107,63 @@ struct GNUNET_SQ_ResultSpec | |||
58 | GNUNET_SQ_result_spec_variable_size (void **dst, | 107 | GNUNET_SQ_result_spec_variable_size (void **dst, |
59 | size_t *sptr) | 108 | size_t *sptr) |
60 | { | 109 | { |
110 | struct GNUNET_SQ_ResultSpec rs = { | ||
111 | .conv = &extract_var_blob, | ||
112 | .cleaner = &clean_var_blob, | ||
113 | .dst = dst, | ||
114 | .cls = dst, | ||
115 | .result_size = sptr, | ||
116 | .num_params = 1 | ||
117 | }; | ||
118 | |||
119 | return rs; | ||
120 | } | ||
121 | |||
122 | |||
123 | /** | ||
124 | * Extract fixed-sized binary data from a Postgres database @a result at row @a row. | ||
125 | * | ||
126 | * @param cls closure | ||
127 | * @param result where to extract data from | ||
128 | * @param column column to extract data from | ||
129 | * @param[in,out] dst_size where to store size of result, may be NULL | ||
130 | * @param[out] dst where to store the result | ||
131 | * @return | ||
132 | * #GNUNET_YES if all results could be extracted | ||
133 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
134 | */ | ||
135 | static int | ||
136 | extract_fixed_blob (void *cls, | ||
137 | sqlite3_stmt *result, | ||
138 | unsigned int column, | ||
139 | size_t *dst_size, | ||
140 | void *dst) | ||
141 | { | ||
142 | int have; | ||
143 | const void *ret; | ||
144 | |||
145 | if (SQLITE_BLOB != | ||
146 | sqlite3_column_type (result, | ||
147 | column)) | ||
148 | { | ||
149 | GNUNET_break (0); | ||
150 | return GNUNET_SYSERR; | ||
151 | } | ||
152 | /* sqlite manual says to invoke 'sqlite3_column_blob()' | ||
153 | before calling sqlite3_column_bytes() */ | ||
154 | ret = sqlite3_column_blob (result, | ||
155 | column); | ||
156 | have = sqlite3_column_bytes (result, | ||
157 | column); | ||
158 | if (*dst_size != have) | ||
159 | { | ||
160 | GNUNET_break (0); | ||
161 | return GNUNET_SYSERR; | ||
162 | } | ||
163 | GNUNET_memcpy (dst, | ||
164 | ret, | ||
165 | have); | ||
166 | return GNUNET_OK; | ||
61 | } | 167 | } |
62 | 168 | ||
63 | 169 | ||
@@ -72,6 +178,76 @@ struct GNUNET_SQ_ResultSpec | |||
72 | GNUNET_SQ_result_spec_fixed_size (void *dst, | 178 | GNUNET_SQ_result_spec_fixed_size (void *dst, |
73 | size_t dst_size) | 179 | size_t dst_size) |
74 | { | 180 | { |
181 | struct GNUNET_SQ_ResultSpec rs = { | ||
182 | .conv = &extract_fixed_blob, | ||
183 | .dst = dst, | ||
184 | .dst_size = dst_size, | ||
185 | .num_params = 1 | ||
186 | }; | ||
187 | |||
188 | return rs; | ||
189 | } | ||
190 | |||
191 | |||
192 | /** | ||
193 | * Extract fixed-sized binary data from a Postgres database @a result at row @a row. | ||
194 | * | ||
195 | * @param cls closure | ||
196 | * @param result where to extract data from | ||
197 | * @param column column to extract data from | ||
198 | * @param[in,out] dst_size where to store size of result, may be NULL | ||
199 | * @param[out] dst where to store the result | ||
200 | * @return | ||
201 | * #GNUNET_YES if all results could be extracted | ||
202 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
203 | */ | ||
204 | static int | ||
205 | extract_utf8_string (void *cls, | ||
206 | sqlite3_stmt *result, | ||
207 | unsigned int column, | ||
208 | size_t *dst_size, | ||
209 | void *dst) | ||
210 | { | ||
211 | const char *text; | ||
212 | char **rdst = dst; | ||
213 | |||
214 | if (SQLITE_TEXT != | ||
215 | sqlite3_column_type (result, | ||
216 | column)) | ||
217 | { | ||
218 | GNUNET_break (0); | ||
219 | return GNUNET_SYSERR; | ||
220 | } | ||
221 | /* sqlite manual guarantees that 'sqlite3_column_text()' | ||
222 | is 0-terminated */ | ||
223 | text = (const char *) sqlite3_column_text (result, | ||
224 | column); | ||
225 | if (NULL == text) | ||
226 | { | ||
227 | GNUNET_break (0); | ||
228 | return GNUNET_SYSERR; | ||
229 | } | ||
230 | *dst_size = strlen (text) + 1; | ||
231 | *rdst = GNUNET_strdup (text); | ||
232 | return GNUNET_OK; | ||
233 | } | ||
234 | |||
235 | |||
236 | /** | ||
237 | * Cleanup memory allocated by #extract_var_blob(). | ||
238 | * | ||
239 | * @param cls pointer to pointer of allocation | ||
240 | */ | ||
241 | static void | ||
242 | clean_utf8_string (void *cls) | ||
243 | { | ||
244 | char **dptr = (char **) cls; | ||
245 | |||
246 | if (NULL != *dptr) | ||
247 | { | ||
248 | GNUNET_free (*dptr); | ||
249 | *dptr = NULL; | ||
250 | } | ||
75 | } | 251 | } |
76 | 252 | ||
77 | 253 | ||
@@ -84,6 +260,87 @@ GNUNET_SQ_result_spec_fixed_size (void *dst, | |||
84 | struct GNUNET_SQ_ResultSpec | 260 | struct GNUNET_SQ_ResultSpec |
85 | GNUNET_SQ_result_spec_string (char **dst) | 261 | GNUNET_SQ_result_spec_string (char **dst) |
86 | { | 262 | { |
263 | struct GNUNET_SQ_ResultSpec rs = { | ||
264 | .conv = &extract_utf8_string, | ||
265 | .cleaner = &clean_utf8_string, | ||
266 | .cls = dst, | ||
267 | .dst = dst, | ||
268 | .num_params = 1 | ||
269 | }; | ||
270 | |||
271 | return rs; | ||
272 | } | ||
273 | |||
274 | |||
275 | /** | ||
276 | * Extract data from a Postgres database @a result at row @a row. | ||
277 | * | ||
278 | * @param cls closure | ||
279 | * @param result where to extract data from | ||
280 | * @param column column to extract data from | ||
281 | * @param[in,out] dst_size where to store size of result, may be NULL | ||
282 | * @param[out] dst where to store the result | ||
283 | * @return | ||
284 | * #GNUNET_YES if all results could be extracted | ||
285 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
286 | */ | ||
287 | static int | ||
288 | extract_rsa_pub (void *cls, | ||
289 | sqlite3_stmt *result, | ||
290 | unsigned int column, | ||
291 | size_t *dst_size, | ||
292 | void *dst) | ||
293 | { | ||
294 | struct GNUNET_CRYPTO_RsaPublicKey **pk = dst; | ||
295 | int have; | ||
296 | const void *ret; | ||
297 | |||
298 | if (SQLITE_BLOB != | ||
299 | sqlite3_column_type (result, | ||
300 | column)) | ||
301 | { | ||
302 | GNUNET_break (0); | ||
303 | return GNUNET_SYSERR; | ||
304 | } | ||
305 | /* sqlite manual says to invoke 'sqlite3_column_blob()' | ||
306 | before calling sqlite3_column_bytes() */ | ||
307 | ret = sqlite3_column_blob (result, | ||
308 | column); | ||
309 | have = sqlite3_column_bytes (result, | ||
310 | column); | ||
311 | if (have < 0) | ||
312 | { | ||
313 | GNUNET_break (0); | ||
314 | return GNUNET_SYSERR; | ||
315 | } | ||
316 | |||
317 | *pk = GNUNET_CRYPTO_rsa_public_key_decode (ret, | ||
318 | have); | ||
319 | if (NULL == *pk) | ||
320 | { | ||
321 | GNUNET_break (0); | ||
322 | return GNUNET_SYSERR; | ||
323 | } | ||
324 | return GNUNET_OK; | ||
325 | } | ||
326 | |||
327 | |||
328 | /** | ||
329 | * Function called to clean up memory allocated | ||
330 | * by a #GNUNET_PQ_ResultConverter. | ||
331 | * | ||
332 | * @param cls closure | ||
333 | */ | ||
334 | static void | ||
335 | clean_rsa_pub (void *cls) | ||
336 | { | ||
337 | struct GNUNET_CRYPTO_RsaPublicKey **pk = cls; | ||
338 | |||
339 | if (NULL != *pk) | ||
340 | { | ||
341 | GNUNET_CRYPTO_rsa_public_key_free (*pk); | ||
342 | *pk = NULL; | ||
343 | } | ||
87 | } | 344 | } |
88 | 345 | ||
89 | 346 | ||
@@ -96,6 +353,87 @@ GNUNET_SQ_result_spec_string (char **dst) | |||
96 | struct GNUNET_SQ_ResultSpec | 353 | struct GNUNET_SQ_ResultSpec |
97 | GNUNET_SQ_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa) | 354 | GNUNET_SQ_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa) |
98 | { | 355 | { |
356 | struct GNUNET_SQ_ResultSpec rs = { | ||
357 | .conv = &extract_rsa_pub, | ||
358 | .cleaner = &clean_rsa_pub, | ||
359 | .dst = rsa, | ||
360 | .cls = rsa, | ||
361 | .num_params = 1 | ||
362 | }; | ||
363 | |||
364 | return rs; | ||
365 | } | ||
366 | |||
367 | |||
368 | /** | ||
369 | * Extract data from a Postgres database @a result at row @a row. | ||
370 | * | ||
371 | * @param cls closure | ||
372 | * @param result where to extract data from | ||
373 | * @param column column to extract data from | ||
374 | * @param[in,out] dst_size where to store size of result, may be NULL | ||
375 | * @param[out] dst where to store the result | ||
376 | * @return | ||
377 | * #GNUNET_YES if all results could be extracted | ||
378 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
379 | */ | ||
380 | static int | ||
381 | extract_rsa_sig (void *cls, | ||
382 | sqlite3_stmt *result, | ||
383 | unsigned int column, | ||
384 | size_t *dst_size, | ||
385 | void *dst) | ||
386 | { | ||
387 | struct GNUNET_CRYPTO_RsaSignature **sig = dst; | ||
388 | int have; | ||
389 | const void *ret; | ||
390 | |||
391 | if (SQLITE_BLOB != | ||
392 | sqlite3_column_type (result, | ||
393 | column)) | ||
394 | { | ||
395 | GNUNET_break (0); | ||
396 | return GNUNET_SYSERR; | ||
397 | } | ||
398 | /* sqlite manual says to invoke 'sqlite3_column_blob()' | ||
399 | before calling sqlite3_column_bytes() */ | ||
400 | ret = sqlite3_column_blob (result, | ||
401 | column); | ||
402 | have = sqlite3_column_bytes (result, | ||
403 | column); | ||
404 | if (have < 0) | ||
405 | { | ||
406 | GNUNET_break (0); | ||
407 | return GNUNET_SYSERR; | ||
408 | } | ||
409 | |||
410 | *sig = GNUNET_CRYPTO_rsa_signature_decode (ret, | ||
411 | have); | ||
412 | if (NULL == *sig) | ||
413 | { | ||
414 | GNUNET_break (0); | ||
415 | return GNUNET_SYSERR; | ||
416 | } | ||
417 | return GNUNET_OK; | ||
418 | } | ||
419 | |||
420 | |||
421 | /** | ||
422 | * Function called to clean up memory allocated | ||
423 | * by a #GNUNET_PQ_ResultConverter. | ||
424 | * | ||
425 | * @param cls result data to clean up | ||
426 | */ | ||
427 | static void | ||
428 | clean_rsa_sig (void *cls) | ||
429 | { | ||
430 | struct GNUNET_CRYPTO_RsaSignature **sig = cls; | ||
431 | |||
432 | if (NULL != *sig) | ||
433 | { | ||
434 | GNUNET_CRYPTO_rsa_signature_free (*sig); | ||
435 | *sig = NULL; | ||
436 | } | ||
99 | } | 437 | } |
100 | 438 | ||
101 | 439 | ||
@@ -108,6 +446,15 @@ GNUNET_SQ_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa) | |||
108 | struct GNUNET_SQ_ResultSpec | 446 | struct GNUNET_SQ_ResultSpec |
109 | GNUNET_SQ_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig) | 447 | GNUNET_SQ_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig) |
110 | { | 448 | { |
449 | struct GNUNET_SQ_ResultSpec rs = { | ||
450 | .conv = &extract_rsa_sig, | ||
451 | .cleaner = &clean_rsa_sig, | ||
452 | .dst = sig, | ||
453 | .cls = sig, | ||
454 | .num_params = 1 | ||
455 | }; | ||
456 | |||
457 | return rs; | ||
111 | } | 458 | } |
112 | 459 | ||
113 | 460 | ||
@@ -120,6 +467,44 @@ GNUNET_SQ_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig) | |||
120 | struct GNUNET_SQ_ResultSpec | 467 | struct GNUNET_SQ_ResultSpec |
121 | GNUNET_SQ_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at) | 468 | GNUNET_SQ_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at) |
122 | { | 469 | { |
470 | return GNUNET_SQ_result_spec_uint64 (&at->abs_value_us); | ||
471 | } | ||
472 | |||
473 | |||
474 | /** | ||
475 | * Extract absolute time value in NBO from a Postgres database @a result at row @a row. | ||
476 | * | ||
477 | * @param cls closure | ||
478 | * @param result where to extract data from | ||
479 | * @param column column to extract data from | ||
480 | * @param[in,out] dst_size where to store size of result, may be NULL | ||
481 | * @param[out] dst where to store the result | ||
482 | * @return | ||
483 | * #GNUNET_YES if all results could be extracted | ||
484 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
485 | */ | ||
486 | static int | ||
487 | extract_abs_time_nbo (void *cls, | ||
488 | sqlite3_stmt *result, | ||
489 | unsigned int column, | ||
490 | size_t *dst_size, | ||
491 | void *dst) | ||
492 | { | ||
493 | struct GNUNET_TIME_AbsoluteNBO *u = dst; | ||
494 | struct GNUNET_TIME_Absolute t; | ||
495 | |||
496 | GNUNET_assert (sizeof (uint64_t) == *dst_size); | ||
497 | if (SQLITE_INTEGER != | ||
498 | sqlite3_column_type (result, | ||
499 | column)) | ||
500 | { | ||
501 | GNUNET_break (0); | ||
502 | return GNUNET_SYSERR; | ||
503 | } | ||
504 | t.abs_value_us = (uint64_t) sqlite3_column_int64 (result, | ||
505 | column); | ||
506 | *u = GNUNET_TIME_absolute_hton (t); | ||
507 | return GNUNET_OK; | ||
123 | } | 508 | } |
124 | 509 | ||
125 | 510 | ||
@@ -132,6 +517,56 @@ GNUNET_SQ_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at) | |||
132 | struct GNUNET_SQ_ResultSpec | 517 | struct GNUNET_SQ_ResultSpec |
133 | GNUNET_SQ_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at) | 518 | GNUNET_SQ_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at) |
134 | { | 519 | { |
520 | struct GNUNET_SQ_ResultSpec rs = { | ||
521 | .conv = &extract_abs_time_nbo, | ||
522 | .dst = at, | ||
523 | .dst_size = sizeof (struct GNUNET_TIME_AbsoluteNBO), | ||
524 | .num_params = 1 | ||
525 | }; | ||
526 | |||
527 | return rs; | ||
528 | } | ||
529 | |||
530 | |||
531 | /** | ||
532 | * Extract 16-bit integer from a Postgres database @a result at row @a row. | ||
533 | * | ||
534 | * @param cls closure | ||
535 | * @param result where to extract data from | ||
536 | * @param column column to extract data from | ||
537 | * @param[in,out] dst_size where to store size of result, may be NULL | ||
538 | * @param[out] dst where to store the result | ||
539 | * @return | ||
540 | * #GNUNET_YES if all results could be extracted | ||
541 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
542 | */ | ||
543 | static int | ||
544 | extract_uint16 (void *cls, | ||
545 | sqlite3_stmt *result, | ||
546 | unsigned int column, | ||
547 | size_t *dst_size, | ||
548 | void *dst) | ||
549 | { | ||
550 | uint64_t v; | ||
551 | uint32_t *u = dst; | ||
552 | |||
553 | GNUNET_assert (sizeof (uint16_t) == *dst_size); | ||
554 | if (SQLITE_INTEGER != | ||
555 | sqlite3_column_type (result, | ||
556 | column)) | ||
557 | { | ||
558 | GNUNET_break (0); | ||
559 | return GNUNET_SYSERR; | ||
560 | } | ||
561 | v = (uint64_t) sqlite3_column_int64 (result, | ||
562 | column); | ||
563 | if (v > UINT16_MAX) | ||
564 | { | ||
565 | GNUNET_break (0); | ||
566 | return GNUNET_SYSERR; | ||
567 | } | ||
568 | *u = (uint16_t) v; | ||
569 | return GNUNET_OK; | ||
135 | } | 570 | } |
136 | 571 | ||
137 | 572 | ||
@@ -144,6 +579,56 @@ GNUNET_SQ_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at) | |||
144 | struct GNUNET_SQ_ResultSpec | 579 | struct GNUNET_SQ_ResultSpec |
145 | GNUNET_SQ_result_spec_uint16 (uint16_t *u16) | 580 | GNUNET_SQ_result_spec_uint16 (uint16_t *u16) |
146 | { | 581 | { |
582 | struct GNUNET_SQ_ResultSpec rs = { | ||
583 | .conv = &extract_uint16, | ||
584 | .dst = u16, | ||
585 | .dst_size = sizeof (uint16_t), | ||
586 | .num_params = 1 | ||
587 | }; | ||
588 | |||
589 | return rs; | ||
590 | } | ||
591 | |||
592 | |||
593 | /** | ||
594 | * Extract 32-bit integer from a Postgres database @a result at row @a row. | ||
595 | * | ||
596 | * @param cls closure | ||
597 | * @param result where to extract data from | ||
598 | * @param column column to extract data from | ||
599 | * @param[in,out] dst_size where to store size of result, may be NULL | ||
600 | * @param[out] dst where to store the result | ||
601 | * @return | ||
602 | * #GNUNET_YES if all results could be extracted | ||
603 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
604 | */ | ||
605 | static int | ||
606 | extract_uint32 (void *cls, | ||
607 | sqlite3_stmt *result, | ||
608 | unsigned int column, | ||
609 | size_t *dst_size, | ||
610 | void *dst) | ||
611 | { | ||
612 | uint64_t v; | ||
613 | uint32_t *u = dst; | ||
614 | |||
615 | GNUNET_assert (sizeof (uint32_t) == *dst_size); | ||
616 | if (SQLITE_INTEGER != | ||
617 | sqlite3_column_type (result, | ||
618 | column)) | ||
619 | { | ||
620 | GNUNET_break (0); | ||
621 | return GNUNET_SYSERR; | ||
622 | } | ||
623 | v = (uint64_t) sqlite3_column_int64 (result, | ||
624 | column); | ||
625 | if (v > UINT32_MAX) | ||
626 | { | ||
627 | GNUNET_break (0); | ||
628 | return GNUNET_SYSERR; | ||
629 | } | ||
630 | *u = (uint32_t) v; | ||
631 | return GNUNET_OK; | ||
147 | } | 632 | } |
148 | 633 | ||
149 | 634 | ||
@@ -156,6 +641,49 @@ GNUNET_SQ_result_spec_uint16 (uint16_t *u16) | |||
156 | struct GNUNET_SQ_ResultSpec | 641 | struct GNUNET_SQ_ResultSpec |
157 | GNUNET_SQ_result_spec_uint32 (uint32_t *u32) | 642 | GNUNET_SQ_result_spec_uint32 (uint32_t *u32) |
158 | { | 643 | { |
644 | struct GNUNET_SQ_ResultSpec rs = { | ||
645 | .conv = &extract_uint32, | ||
646 | .dst = u32, | ||
647 | .dst_size = sizeof (uint32_t), | ||
648 | .num_params = 1 | ||
649 | }; | ||
650 | |||
651 | return rs; | ||
652 | } | ||
653 | |||
654 | |||
655 | /** | ||
656 | * Extract 64-bit integer from a Postgres database @a result at row @a row. | ||
657 | * | ||
658 | * @param cls closure | ||
659 | * @param result where to extract data from | ||
660 | * @param column column to extract data from | ||
661 | * @param[in,out] dst_size where to store size of result, may be NULL | ||
662 | * @param[out] dst where to store the result | ||
663 | * @return | ||
664 | * #GNUNET_YES if all results could be extracted | ||
665 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | ||
666 | */ | ||
667 | static int | ||
668 | extract_uint64 (void *cls, | ||
669 | sqlite3_stmt *result, | ||
670 | unsigned int column, | ||
671 | size_t *dst_size, | ||
672 | void *dst) | ||
673 | { | ||
674 | uint64_t *u = dst; | ||
675 | |||
676 | GNUNET_assert (sizeof (uint64_t) == *dst_size); | ||
677 | if (SQLITE_INTEGER != | ||
678 | sqlite3_column_type (result, | ||
679 | column)) | ||
680 | { | ||
681 | GNUNET_break (0); | ||
682 | return GNUNET_SYSERR; | ||
683 | } | ||
684 | *u = (uint64_t) sqlite3_column_int64 (result, | ||
685 | column); | ||
686 | return GNUNET_OK; | ||
159 | } | 687 | } |
160 | 688 | ||
161 | 689 | ||
@@ -168,6 +696,14 @@ GNUNET_SQ_result_spec_uint32 (uint32_t *u32) | |||
168 | struct GNUNET_SQ_ResultSpec | 696 | struct GNUNET_SQ_ResultSpec |
169 | GNUNET_SQ_result_spec_uint64 (uint64_t *u64) | 697 | GNUNET_SQ_result_spec_uint64 (uint64_t *u64) |
170 | { | 698 | { |
699 | struct GNUNET_SQ_ResultSpec rs = { | ||
700 | .conv = &extract_uint64, | ||
701 | .dst = u64, | ||
702 | .dst_size = sizeof (uint64_t), | ||
703 | .num_params = 1 | ||
704 | }; | ||
705 | |||
706 | return rs; | ||
171 | } | 707 | } |
172 | 708 | ||
173 | 709 | ||
diff --git a/src/topology/friends.c b/src/topology/friends.c index 59c70e4b0..a960fad17 100644 --- a/src/topology/friends.c +++ b/src/topology/friends.c | |||
@@ -58,14 +58,20 @@ GNUNET_FRIENDS_parse (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
58 | return GNUNET_SYSERR; | 58 | return GNUNET_SYSERR; |
59 | } | 59 | } |
60 | if ( (GNUNET_OK != GNUNET_DISK_file_test (fn)) && | 60 | if ( (GNUNET_OK != GNUNET_DISK_file_test (fn)) && |
61 | (GNUNET_OK != GNUNET_DISK_fn_write (fn, NULL, 0, | 61 | (GNUNET_OK != GNUNET_DISK_fn_write (fn, |
62 | NULL, | ||
63 | 0, | ||
62 | GNUNET_DISK_PERM_USER_READ | | 64 | GNUNET_DISK_PERM_USER_READ | |
63 | GNUNET_DISK_PERM_USER_WRITE)) ) | 65 | GNUNET_DISK_PERM_USER_WRITE | |
64 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn); | 66 | GNUNET_DISK_OPEN_CREATE)) ) |
67 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
68 | "write", | ||
69 | fn); | ||
65 | if ( (GNUNET_OK != | 70 | if ( (GNUNET_OK != |
66 | GNUNET_DISK_file_size (fn, | 71 | GNUNET_DISK_file_size (fn, |
67 | &fsize, | 72 | &fsize, |
68 | GNUNET_NO, GNUNET_YES)) || | 73 | GNUNET_NO, |
74 | GNUNET_YES)) || | ||
69 | (0 == fsize) ) | 75 | (0 == fsize) ) |
70 | { | 76 | { |
71 | GNUNET_free (fn); | 77 | GNUNET_free (fn); |
@@ -93,8 +99,8 @@ GNUNET_FRIENDS_parse (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
93 | pos++; | 99 | pos++; |
94 | if (GNUNET_OK != | 100 | if (GNUNET_OK != |
95 | GNUNET_CRYPTO_eddsa_public_key_from_string (&data[start], | 101 | GNUNET_CRYPTO_eddsa_public_key_from_string (&data[start], |
96 | pos - start, | 102 | pos - start, |
97 | &pid.public_key)) | 103 | &pid.public_key)) |
98 | { | 104 | { |
99 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 105 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
100 | _("Syntax error in FRIENDS file at offset %llu, skipping bytes `%.*s'.\n"), | 106 | _("Syntax error in FRIENDS file at offset %llu, skipping bytes `%.*s'.\n"), |
diff --git a/src/util/service_new.c b/src/util/service_new.c index 8371f7703..22eec0bde 100644 --- a/src/util/service_new.c +++ b/src/util/service_new.c | |||
@@ -2402,8 +2402,8 @@ resume_client_receive (void *cls) | |||
2402 | GNUNET_YES); | 2402 | GNUNET_YES); |
2403 | if (GNUNET_SYSERR == ret) | 2403 | if (GNUNET_SYSERR == ret) |
2404 | { | 2404 | { |
2405 | GNUNET_break (0); | 2405 | if (NULL != c->drop_task) |
2406 | GNUNET_SERVICE_client_drop (c); | 2406 | GNUNET_SERVICE_client_drop (c); |
2407 | return; | 2407 | return; |
2408 | } | 2408 | } |
2409 | if (GNUNET_NO == ret) | 2409 | if (GNUNET_NO == ret) |