aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2022-12-07 12:47:41 +0100
committert3sserakt <t3ss@posteo.de>2022-12-07 12:47:41 +0100
commitc3793434556c714ee34679ecf6d30de13e0d8758 (patch)
tree548c953ecf6b9e8ba8511830a6a1ddbd9afe8e46 /src
parent34e1c58cb39a649c9a4c551681cedf19807b85f0 (diff)
parent6bebc94d2c7b6eac69b84fde39142d008a643d8d (diff)
downloadgnunet-c3793434556c714ee34679ecf6d30de13e0d8758.tar.gz
gnunet-c3793434556c714ee34679ecf6d30de13e0d8758.zip
Merge branch 'master' of ssh://git.gnunet.org/gnunet
Diffstat (limited to 'src')
-rw-r--r--src/abd/gnunet-service-abd.c1
-rw-r--r--src/arm/mockup-service.c2
-rw-r--r--src/arm/test_gnunet_service_arm.c3
-rw-r--r--src/cadet/cadet.h1
-rw-r--r--src/cadet/desirability_table.c1
-rw-r--r--src/cadet/gnunet-cadet-profiler.c2
-rw-r--r--src/cadet/test_cadet.c2
-rw-r--r--src/cadet/test_cadet_flow.c2
-rw-r--r--src/consensus/consensus_api.c1
-rw-r--r--src/conversation/gnunet_gst.c1
-rw-r--r--src/conversation/gnunet_gst_test.c1
-rw-r--r--src/core/core.h3
-rw-r--r--src/datacache/Makefile.am10
-rw-r--r--src/datacache/datacache-0001.sql48
-rw-r--r--src/datacache/datacache-drop.sql25
-rw-r--r--src/datacache/datacache.conf4
-rw-r--r--src/datacache/plugin_datacache_postgres.c85
-rw-r--r--src/datastore/Makefile.am9
-rw-r--r--src/datastore/datastore-0001.sql49
-rw-r--r--src/datastore/datastore-drop.sql25
-rw-r--r--src/datastore/datastore.conf.in1
-rw-r--r--src/datastore/gnunet-datastore.c2
-rw-r--r--src/datastore/plugin_datastore_mysql.c1
-rw-r--r--src/datastore/plugin_datastore_postgres.c113
-rw-r--r--src/dht/gnunet-service-dht_clients.c6
-rw-r--r--src/dns/gnunet-dns-monitor.c1
-rw-r--r--src/dns/gnunet-dns-redirector.c1
-rw-r--r--src/dns/gnunet-helper-dns.c2
-rw-r--r--src/dns/gnunet-service-dns.c3
-rw-r--r--src/dns/gnunet-zonewalk.c2
-rw-r--r--src/exit/gnunet-daemon-exit.c3
-rw-r--r--src/exit/gnunet-helper-exit.c2
-rw-r--r--src/fragmentation/fragmentation.c1
-rw-r--r--src/fragmentation/fragmentation.h2
-rw-r--r--src/fs/Makefile.am20
-rw-r--r--src/fs/fs.h1
-rw-r--r--src/fs/fs_api.c21
-rw-r--r--src/fs/fs_api.h7
-rw-r--r--src/fs/fs_directory.c65
-rw-r--r--src/fs/fs_dirmetascan.c27
-rw-r--r--src/fs/fs_download.c21
-rw-r--r--src/fs/fs_file_information.c33
-rw-r--r--src/fs/fs_getopt.c44
-rw-r--r--src/fs/fs_list_indexed.c1
-rw-r--r--src/fs/fs_misc.c45
-rw-r--r--src/fs/fs_namespace.c23
-rw-r--r--src/fs/fs_publish.c11
-rw-r--r--src/fs/fs_publish_ksk.c9
-rw-r--r--src/fs/fs_publish_ublock.c8
-rw-r--r--src/fs/fs_publish_ublock.h3
-rw-r--r--src/fs/fs_search.c39
-rw-r--r--src/fs/fs_sharetree.c33
-rw-r--r--src/fs/fs_unindex.c1
-rw-r--r--src/fs/fs_uri.c13
-rw-r--r--src/fs/gnunet-daemon-fsprofiler.c1
-rw-r--r--src/fs/gnunet-directory.c9
-rw-r--r--src/fs/gnunet-download.c1
-rw-r--r--src/fs/gnunet-fs.c1
-rw-r--r--src/fs/gnunet-helper-fs-publish.c45
-rw-r--r--src/fs/gnunet-publish.c27
-rw-r--r--src/fs/gnunet-search.c125
-rw-r--r--src/fs/gnunet-service-fs.c1
-rw-r--r--src/fs/gnunet-service-fs_indexing.c1
-rw-r--r--src/fs/gnunet-service-fs_indexing.h1
-rw-r--r--src/fs/gnunet-unindex.c1
-rw-r--r--src/fs/meta_data.c (renamed from src/util/container_meta_data.c)447
-rw-r--r--src/fs/plugin_block_fs.c1
-rw-r--r--src/fs/test_fs_directory.c50
-rw-r--r--src/fs/test_fs_download.c6
-rw-r--r--src/fs/test_fs_download_persistence.c6
-rw-r--r--src/fs/test_fs_file_information.c8
-rw-r--r--src/fs/test_fs_list_indexed.c6
-rw-r--r--src/fs/test_fs_meta_data.c492
-rw-r--r--src/fs/test_fs_namespace.c18
-rw-r--r--src/fs/test_fs_namespace_list_updateable.c12
-rw-r--r--src/fs/test_fs_publish.c6
-rw-r--r--src/fs/test_fs_publish_persistence.c6
-rw-r--r--src/fs/test_fs_search.c6
-rw-r--r--src/fs/test_fs_search_persistence.c6
-rw-r--r--src/fs/test_fs_search_probes.c6
-rw-r--r--src/fs/test_fs_search_with_and.c6
-rw-r--r--src/fs/test_fs_unindex.c6
-rw-r--r--src/fs/test_fs_unindex_persistence.c6
-rw-r--r--src/gns/gnunet-dns2gns.c2
-rw-r--r--src/gns/gnunet-gns.c1
-rw-r--r--src/gns/gnunet-service-gns.c1
-rw-r--r--src/gns/gnunet-service-gns_interceptor.c1
-rw-r--r--src/gns/gnunet-service-gns_resolver.c3
-rw-r--r--src/gns/nss/nss_gns.c2
-rw-r--r--src/gns/plugin_gnsrecord_gns.c1
-rw-r--r--src/gnsrecord/gnsrecord.c1
-rw-r--r--src/gnsrecord/gnsrecord_crypto.c13
-rw-r--r--src/gnsrecord/gnsrecord_crypto.h2
-rw-r--r--src/gnsrecord/gnsrecord_misc.c4
-rw-r--r--src/gnsrecord/gnsrecord_serialization.c3
-rw-r--r--src/gnsrecord/gnunet-gnsrecord-tvg.c3
-rw-r--r--src/gnsrecord/json_gnsrecord.c4
-rw-r--r--src/gnsrecord/plugin_gnsrecord_dns.c1
-rw-r--r--src/gnsrecord/test_gnsrecord_block_expiration.c2
-rw-r--r--src/gnsrecord/test_gnsrecord_crypto.c1
-rw-r--r--src/gnsrecord/test_gnsrecord_serialization.c1
-rw-r--r--src/identity/gnunet-service-identity.c8
-rw-r--r--src/identity/identity.h16
-rw-r--r--src/identity/identity_api.c19
-rw-r--r--src/identity/plugin_rest_identity.c2
-rw-r--r--src/include/.gitignore3
-rw-r--r--src/include/Makefile.am6
-rw-r--r--src/include/block_dns.h1
-rw-r--r--src/include/block_fs.h1
-rw-r--r--src/include/block_regex.h1
-rw-r--r--src/include/gauger.h1
-rw-r--r--src/include/gettext.h1
-rw-r--r--src/include/gnunet_abd_service.h1
-rw-r--r--src/include/gnunet_arm_service.h1
-rw-r--r--src/include/gnunet_ats_application_service.h1
-rw-r--r--src/include/gnunet_ats_plugin.h1
-rw-r--r--src/include/gnunet_ats_service.h1
-rw-r--r--src/include/gnunet_ats_transport_service.h1
-rw-r--r--src/include/gnunet_bandwidth_lib.h10
-rw-r--r--src/include/gnunet_bio_lib.h63
-rw-r--r--src/include/gnunet_block_group_lib.h1
-rw-r--r--src/include/gnunet_block_lib.h1
-rw-r--r--src/include/gnunet_block_plugin.h1
-rw-r--r--src/include/gnunet_buffer_lib.h4
-rw-r--r--src/include/gnunet_cadet_service.h1
-rw-r--r--src/include/gnunet_child_management_lib.h4
-rw-r--r--src/include/gnunet_client_lib.h5
-rw-r--r--src/include/gnunet_common.h41
-rw-r--r--src/include/gnunet_config.h.in58
-rw-r--r--src/include/gnunet_configuration_lib.h1
-rw-r--r--src/include/gnunet_consensus_service.h1
-rw-r--r--src/include/gnunet_container_lib.h408
-rw-r--r--src/include/gnunet_conversation_service.h1
-rw-r--r--src/include/gnunet_core_service.h1
-rw-r--r--src/include/gnunet_crypto_lib.h6
-rw-r--r--src/include/gnunet_curl_lib.h1
-rw-r--r--src/include/gnunet_datacache_lib.h1
-rw-r--r--src/include/gnunet_datacache_plugin.h1
-rw-r--r--src/include/gnunet_datastore_plugin.h23
-rw-r--r--src/include/gnunet_datastore_service.h1
-rw-r--r--src/include/gnunet_db_lib.h1
-rw-r--r--src/include/gnunet_dht_service.h1
-rw-r--r--src/include/gnunet_dhtu_plugin.h1
-rw-r--r--src/include/gnunet_disk_lib.h6
-rw-r--r--src/include/gnunet_dns_service.h1
-rw-r--r--src/include/gnunet_dnsparser_lib.h7
-rw-r--r--src/include/gnunet_dnsstub_lib.h5
-rw-r--r--src/include/gnunet_fragmentation_lib.h2
-rw-r--r--src/include/gnunet_friends_lib.h1
-rw-r--r--src/include/gnunet_fs_service.h494
-rw-r--r--src/include/gnunet_getopt_lib.h5
-rw-r--r--src/include/gnunet_gns_service.h2
-rw-r--r--src/include/gnunet_gnsrecord_json_lib.h1
-rw-r--r--src/include/gnunet_gnsrecord_lib.h43
-rw-r--r--src/include/gnunet_hello_lib.h1
-rw-r--r--src/include/gnunet_hello_uri_lib.h1
-rw-r--r--src/include/gnunet_helper_lib.h6
-rw-r--r--src/include/gnunet_identity_service.h1
-rw-r--r--src/include/gnunet_json_lib.h1
-rw-r--r--src/include/gnunet_load_lib.h1
-rw-r--r--src/include/gnunet_messenger_service.h4
-rw-r--r--src/include/gnunet_mhd_compat.h3
-rw-r--r--src/include/gnunet_microphone_lib.h1
-rw-r--r--src/include/gnunet_mq_lib.h6
-rw-r--r--src/include/gnunet_mst_lib.h6
-rw-r--r--src/include/gnunet_my_lib.h8
-rw-r--r--src/include/gnunet_mysql_compat.h63
-rw-r--r--src/include/gnunet_mysql_lib.h12
-rw-r--r--src/include/gnunet_namecache_plugin.h1
-rw-r--r--src/include/gnunet_namecache_service.h1
-rw-r--r--src/include/gnunet_namestore_plugin.h84
-rw-r--r--src/include/gnunet_namestore_service.h1
-rw-r--r--src/include/gnunet_nat_auto_service.h1
-rw-r--r--src/include/gnunet_nat_service.h7
-rw-r--r--src/include/gnunet_nc_lib.h6
-rw-r--r--src/include/gnunet_network_lib.h1
-rw-r--r--src/include/gnunet_nse_service.h1
-rw-r--r--src/include/gnunet_op_lib.h5
-rw-r--r--src/include/gnunet_os_lib.h8
-rw-r--r--src/include/gnunet_peer_lib.h5
-rw-r--r--src/include/gnunet_peerinfo_service.h4
-rw-r--r--src/include/gnunet_peerstore_plugin.h1
-rw-r--r--src/include/gnunet_peerstore_service.h1
-rw-r--r--src/include/gnunet_plugin_lib.h7
-rw-r--r--src/include/gnunet_pq_lib.h45
-rw-r--r--src/include/gnunet_program_lib.h5
-rw-r--r--src/include/gnunet_reclaim_lib.h1
-rw-r--r--src/include/gnunet_reclaim_plugin.h1
-rw-r--r--src/include/gnunet_reclaim_service.h1
-rw-r--r--src/include/gnunet_regex_service.h1
-rw-r--r--src/include/gnunet_resolver_service.h1
-rw-r--r--src/include/gnunet_rest_lib.h1
-rw-r--r--src/include/gnunet_rest_plugin.h1
-rw-r--r--src/include/gnunet_revocation_service.h1
-rw-r--r--src/include/gnunet_scalarproduct_service.h1
-rw-r--r--src/include/gnunet_scheduler_lib.h1
-rw-r--r--src/include/gnunet_secretsharing_service.h1
-rw-r--r--src/include/gnunet_service_lib.h7
-rw-r--r--src/include/gnunet_set_service.h1
-rw-r--r--src/include/gnunet_seti_service.h1
-rw-r--r--src/include/gnunet_setu_service.h1
-rw-r--r--src/include/gnunet_signal_lib.h4
-rw-r--r--src/include/gnunet_socks.h1
-rw-r--r--src/include/gnunet_speaker_lib.h1
-rw-r--r--src/include/gnunet_sq_lib.h1
-rw-r--r--src/include/gnunet_statistics_service.h1
-rw-r--r--src/include/gnunet_strings_lib.h9
-rw-r--r--src/include/gnunet_testbed_logger_service.h1
-rw-r--r--src/include/gnunet_testbed_service.h1
-rw-r--r--src/include/gnunet_testing_lib.h1
-rw-r--r--src/include/gnunet_testing_netjail_lib.h9
-rw-r--r--src/include/gnunet_testing_ng_lib.h1
-rw-r--r--src/include/gnunet_time_lib.h1
-rw-r--r--src/include/gnunet_transport_application_service.h1
-rw-r--r--src/include/gnunet_transport_communication_service.h1
-rw-r--r--src/include/gnunet_transport_core_service.h1
-rw-r--r--src/include/gnunet_transport_hello_service.h1
-rw-r--r--src/include/gnunet_transport_manipulation_service.h1
-rw-r--r--src/include/gnunet_transport_monitor_service.h1
-rw-r--r--src/include/gnunet_transport_plugin.h1
-rw-r--r--src/include/gnunet_transport_service.h1
-rw-r--r--src/include/gnunet_tun_lib.h7
-rw-r--r--src/include/gnunet_util_lib.h48
-rw-r--r--src/include/gnunet_vpn_service.h1
-rw-r--r--src/include/platform.h2
-rw-r--r--src/messenger/gnunet-messenger.c2
-rw-r--r--src/messenger/gnunet-service-messenger.c1
-rw-r--r--src/messenger/gnunet-service-messenger.h4
-rw-r--r--src/messenger/gnunet-service-messenger_basement.c1
-rw-r--r--src/messenger/gnunet-service-messenger_ego_store.c1
-rw-r--r--src/messenger/gnunet-service-messenger_ego_store.h2
-rw-r--r--src/messenger/gnunet-service-messenger_handle.c1
-rw-r--r--src/messenger/gnunet-service-messenger_handle.h5
-rw-r--r--src/messenger/gnunet-service-messenger_list_handles.c1
-rw-r--r--src/messenger/gnunet-service-messenger_list_handles.h3
-rw-r--r--src/messenger/gnunet-service-messenger_list_messages.c1
-rw-r--r--src/messenger/gnunet-service-messenger_list_messages.h4
-rw-r--r--src/messenger/gnunet-service-messenger_member.c1
-rw-r--r--src/messenger/gnunet-service-messenger_member_session.c1
-rw-r--r--src/messenger/gnunet-service-messenger_member_session.h3
-rw-r--r--src/messenger/gnunet-service-messenger_member_store.c1
-rw-r--r--src/messenger/gnunet-service-messenger_member_store.h3
-rw-r--r--src/messenger/gnunet-service-messenger_message_handle.c1
-rw-r--r--src/messenger/gnunet-service-messenger_message_handle.h2
-rw-r--r--src/messenger/gnunet-service-messenger_message_kind.c1
-rw-r--r--src/messenger/gnunet-service-messenger_message_kind.h3
-rw-r--r--src/messenger/gnunet-service-messenger_message_recv.c1
-rw-r--r--src/messenger/gnunet-service-messenger_message_recv.h2
-rw-r--r--src/messenger/gnunet-service-messenger_message_send.c1
-rw-r--r--src/messenger/gnunet-service-messenger_message_send.h2
-rw-r--r--src/messenger/gnunet-service-messenger_message_state.c1
-rw-r--r--src/messenger/gnunet-service-messenger_message_state.h2
-rw-r--r--src/messenger/gnunet-service-messenger_message_store.c1
-rw-r--r--src/messenger/gnunet-service-messenger_message_store.h3
-rw-r--r--src/messenger/gnunet-service-messenger_operation.c1
-rw-r--r--src/messenger/gnunet-service-messenger_operation.h3
-rw-r--r--src/messenger/gnunet-service-messenger_operation_store.c1
-rw-r--r--src/messenger/gnunet-service-messenger_operation_store.h4
-rw-r--r--src/messenger/gnunet-service-messenger_room.c1
-rw-r--r--src/messenger/gnunet-service-messenger_room.h4
-rw-r--r--src/messenger/gnunet-service-messenger_service.c1
-rw-r--r--src/messenger/gnunet-service-messenger_service.h4
-rw-r--r--src/messenger/gnunet-service-messenger_tunnel.c1
-rw-r--r--src/messenger/gnunet-service-messenger_tunnel.h3
-rw-r--r--src/messenger/messenger_api.c1
-rw-r--r--src/messenger/messenger_api_contact.c1
-rw-r--r--src/messenger/messenger_api_contact.h2
-rw-r--r--src/messenger/messenger_api_contact_store.c1
-rw-r--r--src/messenger/messenger_api_contact_store.h3
-rw-r--r--src/messenger/messenger_api_handle.c1
-rw-r--r--src/messenger/messenger_api_handle.h4
-rw-r--r--src/messenger/messenger_api_list_tunnels.c1
-rw-r--r--src/messenger/messenger_api_list_tunnels.h3
-rw-r--r--src/messenger/messenger_api_message.c8
-rw-r--r--src/messenger/messenger_api_message.h3
-rw-r--r--src/messenger/messenger_api_room.c1
-rw-r--r--src/messenger/messenger_api_room.h3
-rw-r--r--src/messenger/messenger_api_util.c1
-rw-r--r--src/messenger/messenger_api_util.h4
-rw-r--r--src/messenger/test_messenger.c2
-rw-r--r--src/messenger/test_messenger_adapt.c1
-rw-r--r--src/messenger/test_messenger_anonymous.c2
-rw-r--r--src/messenger/test_messenger_async_client.c1
-rw-r--r--src/messenger/test_messenger_async_p2p.c1
-rw-r--r--src/messenger/test_messenger_growth.c1
-rw-r--r--src/messenger/test_messenger_ring.c1
-rw-r--r--src/messenger/test_messenger_server.c1
-rw-r--r--src/messenger/test_messenger_sync_client.c1
-rw-r--r--src/messenger/test_messenger_sync_p2p.c1
-rw-r--r--src/messenger/test_messenger_worst_client.c1
-rw-r--r--src/messenger/test_messenger_worst_p2p.c1
-rw-r--r--src/messenger/testing_messenger_barrier.c1
-rw-r--r--src/messenger/testing_messenger_setup.c2
-rw-r--r--src/my/my.c1
-rw-r--r--src/my/my_query_helper.c1
-rw-r--r--src/my/my_result_helper.c3
-rw-r--r--src/my/test_my.c1
-rw-r--r--src/mysql/mysql.c1
-rw-r--r--src/namecache/Makefile.am10
-rw-r--r--src/namecache/gnunet-namecache.c1
-rw-r--r--src/namecache/gnunet-service-namecache.c1
-rw-r--r--src/namecache/namecache-0001.sql42
-rw-r--r--src/namecache/namecache-drop.sql25
-rw-r--r--src/namecache/namecache.conf.in3
-rw-r--r--src/namecache/namecache_api.c2
-rw-r--r--src/namecache/plugin_namecache_postgres.c85
-rw-r--r--src/namecache/test_namecache_api_cache_block.c5
-rw-r--r--src/namestore/Makefile.am12
-rw-r--r--src/namestore/gnunet-namestore-dbtool.c55
-rw-r--r--src/namestore/gnunet-namestore.c876
-rw-r--r--src/namestore/gnunet-service-namestore.c26
-rw-r--r--src/namestore/gnunet-zoneimport.c2
-rw-r--r--src/namestore/namestore-0001.sql48
-rw-r--r--src/namestore/namestore-drop.sql25
-rw-r--r--src/namestore/namestore.conf.in3
-rw-r--r--src/namestore/namestore.h66
-rw-r--r--src/namestore/namestore_api.c40
-rw-r--r--src/namestore/namestore_api_monitor.c8
-rw-r--r--src/namestore/perf_namestore_api_import.c1
-rw-r--r--src/namestore/perf_namestore_api_zone_iteration.c1
-rw-r--r--src/namestore/plugin_namestore_postgres.c288
-rw-r--r--src/namestore/plugin_namestore_sqlite.c109
-rw-r--r--src/namestore/test_common.c47
-rw-r--r--src/namestore/test_namestore_api_edit_records.c9
-rw-r--r--src/namestore/test_namestore_api_lookup_nick.c1
-rw-r--r--src/namestore/test_namestore_api_monitoring.c1
-rw-r--r--src/namestore/test_namestore_api_monitoring_existing.c1
-rw-r--r--src/namestore/test_namestore_api_remove.c1
-rw-r--r--src/namestore/test_namestore_api_store.c1
-rw-r--r--src/namestore/test_namestore_api_store_update.c1
-rw-r--r--src/namestore/test_namestore_api_tx_rollback.c1
-rw-r--r--src/namestore/test_namestore_api_zone_iteration.c1
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_nick.c1
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_specific_zone.c1
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_stop.c1
-rw-r--r--src/namestore/test_namestore_api_zone_to_name.c1
-rwxr-xr-x[-rw-r--r--]src/namestore/test_namestore_put_multiple.sh49
-rwxr-xr-xsrc/namestore/test_namestore_put_stdin.sh68
-rw-r--r--src/namestore/test_plugin_namestore.c22
-rw-r--r--src/nat/gnunet-helper-nat-client.c3
-rw-r--r--src/nat/gnunet-helper-nat-server.c3
-rw-r--r--src/nat/nat_api.c7
-rw-r--r--src/peerinfo/peerinfo.h5
-rw-r--r--src/peerstore/peerstore_common.c1
-rw-r--r--src/pq/Makefile.am9
-rw-r--r--src/pq/pq_connect.c2
-rw-r--r--src/pq/pq_eval.c10
-rw-r--r--src/pq/pq_event.c15
-rw-r--r--src/pq/versioning.sql293
-rw-r--r--src/pt/gnunet-daemon-pt.c2
-rw-r--r--src/pt/test_gns_vpn.c10
-rw-r--r--src/reclaim/Makefile.am1
-rw-r--r--src/reclaim/did_core.c1
-rw-r--r--src/reclaim/gnunet-service-reclaim.c44
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c1
-rw-r--r--src/reclaim/pabc_helper.c1
-rw-r--r--src/reclaim/plugin_reclaim_credential_jwt.c13
-rw-r--r--src/reclaim/plugin_rest_openid_connect.c3
-rw-r--r--src/reclaim/reclaim.h83
-rw-r--r--src/reclaim/reclaim_api.c43
-rw-r--r--src/reclaim/reclaim_attribute.c4
-rw-r--r--src/reclaim/reclaim_attribute.h14
-rw-r--r--src/reclaim/reclaim_credential.c8
-rw-r--r--src/reclaim/reclaim_credential.h28
-rw-r--r--src/reclaim/test_reclaim_attribute.c1
-rw-r--r--src/regex/gnunet-regex-simulation-profiler.c1
-rw-r--r--src/regex/perf-regex.c2
-rw-r--r--src/regex/regex_test_random.c2
-rw-r--r--src/regex/test_regex_eval_api.c2
-rw-r--r--src/regex/test_regex_graph_api.c2
-rw-r--r--src/regex/test_regex_integration.c1
-rw-r--r--src/regex/test_regex_iterate_api.c2
-rw-r--r--src/revocation/gnunet-revocation-tvg.c1
-rw-r--r--src/rps/test_service_rps_custommap.c1
-rw-r--r--src/rps/test_service_rps_sampler_elem.c1
-rw-r--r--src/rps/test_service_rps_view.c1
-rw-r--r--src/scalarproduct/gnunet-scalarproduct.c2
-rw-r--r--src/secretsharing/secretsharing_common.c1
-rw-r--r--src/set/gnunet-service-set.c1
-rw-r--r--src/set/ibf.c1
-rw-r--r--src/set/ibf_sim.c1
-rw-r--r--src/seti/gnunet-service-seti.c1
-rw-r--r--src/setu/ibf.c1
-rw-r--r--src/setu/ibf_sim.c1
-rw-r--r--src/statistics/gnunet-service-statistics.c7
-rw-r--r--src/testbed/gnunet-service-testbed.c1
-rw-r--r--src/testbed/gnunet-service-testbed_barriers.c3
-rw-r--r--src/testbed/gnunet-service-testbed_cache.c1
-rw-r--r--src/testbed/gnunet-service-testbed_connectionpool.c1
-rw-r--r--src/testbed/gnunet-service-testbed_links.c1
-rw-r--r--src/testbed/gnunet-service-testbed_oc.c1
-rw-r--r--src/testbed/gnunet-service-testbed_peers.c1
-rw-r--r--src/testbed/testbed_api_operations.h2
-rw-r--r--src/testbed/testbed_api_peers.h2
-rw-r--r--src/testbed/testbed_api_underlay.c1
-rw-r--r--src/testing/gnunet-cmds-helper.c4
-rw-r--r--src/testing/testing.c197
-rw-r--r--src/transport/Makefile.am1
-rw-r--r--src/transport/gnunet-communicator-tcp.c6
-rw-r--r--src/transport/gnunet-helper-transport-bluetooth.c3
-rw-r--r--src/transport/gnunet-helper-transport-wlan.c23
-rw-r--r--src/transport/gnunet-service-tng.c83
-rw-r--r--src/transport/plugin_transport_wlan.h2
-rwxr-xr-xsrc/transport/test_transport_simple_send_dv_inverse.sh9
-rw-r--r--src/transport/transport-testing-filenames.c1
-rw-r--r--src/transport/transport-testing-filenames2.c1
-rw-r--r--src/transport/transport-testing-loggers.c1
-rw-r--r--src/transport/transport-testing-loggers2.c1
-rw-r--r--src/transport/transport-testing-main.c1
-rw-r--r--src/transport/transport-testing-main2.c1
-rw-r--r--src/transport/transport-testing-send.c1
-rw-r--r--src/transport/transport-testing-send2.c1
-rw-r--r--src/transport/transport-testing.c1
-rw-r--r--src/transport/transport-testing2.c1
-rw-r--r--src/transport/transport.h2
-rw-r--r--src/util/Makefile.am8
-rw-r--r--src/util/bandwidth.c1
-rw-r--r--src/util/benchmark.c1
-rw-r--r--src/util/bio.c206
-rw-r--r--src/util/buffer.c2
-rw-r--r--src/util/child_management.c2
-rw-r--r--src/util/client.c1
-rw-r--r--src/util/common_allocation.c3
-rw-r--r--src/util/common_endian.c3
-rw-r--r--src/util/common_logging.c5
-rw-r--r--src/util/compress.c91
-rw-r--r--src/util/configuration.c8
-rw-r--r--src/util/configuration_helper.c1
-rw-r--r--src/util/consttime_memcmp.c1
-rw-r--r--src/util/container_bloomfilter.c1
-rw-r--r--src/util/container_heap.c3
-rw-r--r--src/util/container_multihashmap.c3
-rw-r--r--src/util/container_multihashmap32.c3
-rw-r--r--src/util/container_multipeermap.c1
-rw-r--r--src/util/container_multishortmap.c1
-rw-r--r--src/util/container_multiuuidmap.c1
-rw-r--r--src/util/crypto_crc.c14
-rw-r--r--src/util/crypto_cs.c3
-rw-r--r--src/util/crypto_ecc.c4
-rw-r--r--src/util/crypto_ecc_dlog.c4
-rw-r--r--src/util/crypto_ecc_gnsrecord.c4
-rw-r--r--src/util/crypto_ecc_setup.c1
-rw-r--r--src/util/crypto_edx25519.c4
-rw-r--r--src/util/crypto_hash.c4
-rw-r--r--src/util/crypto_hash_file.c1
-rw-r--r--src/util/crypto_hkdf.c5
-rw-r--r--src/util/crypto_kdf.c5
-rw-r--r--src/util/crypto_mpi.c3
-rw-r--r--src/util/crypto_paillier.c1
-rw-r--r--src/util/crypto_pow.c3
-rw-r--r--src/util/crypto_random.c4
-rw-r--r--src/util/crypto_rsa.c3
-rw-r--r--src/util/crypto_symmetric.c3
-rw-r--r--src/util/disk.c5
-rw-r--r--src/util/disk.h3
-rw-r--r--src/util/dnsparser.c4
-rw-r--r--src/util/dnsstub.c1
-rw-r--r--src/util/getopt.c1
-rw-r--r--src/util/getopt_helpers.c1
-rw-r--r--src/util/gnunet-base32.c1
-rw-r--r--src/util/gnunet-config-diff.c1
-rw-r--r--src/util/gnunet-config.c1
-rw-r--r--src/util/gnunet-crypto-tvg.c1
-rw-r--r--src/util/gnunet-ecc.c1
-rw-r--r--src/util/gnunet-qr.c3
-rw-r--r--src/util/gnunet-resolver.c1
-rw-r--r--src/util/gnunet-scrypt.c1
-rw-r--r--src/util/gnunet-service-resolver.c1
-rw-r--r--src/util/gnunet-timeout.c1
-rw-r--r--src/util/gnunet-uri.c1
-rw-r--r--src/util/helper.c3
-rw-r--r--src/util/load.c1
-rw-r--r--src/util/mq.c1
-rw-r--r--src/util/mst.c1
-rw-r--r--src/util/nc.c1
-rw-r--r--src/util/network.c2
-rw-r--r--src/util/op.c3
-rw-r--r--src/util/os_installation.c3
-rw-r--r--src/util/os_network.c1
-rw-r--r--src/util/os_priority.c1
-rw-r--r--src/util/peer.c3
-rw-r--r--src/util/perf_crypto_asymmetric.c1
-rw-r--r--src/util/perf_crypto_cs.c1
-rw-r--r--src/util/perf_crypto_ecc_dlog.c1
-rw-r--r--src/util/perf_crypto_hash.c1
-rw-r--r--src/util/perf_crypto_paillier.c1
-rw-r--r--src/util/perf_crypto_rsa.c1
-rw-r--r--src/util/perf_crypto_symmetric.c1
-rw-r--r--src/util/perf_malloc.c1
-rw-r--r--src/util/perf_mq.c1
-rw-r--r--src/util/perf_scheduler.c1
-rw-r--r--src/util/plugin.c1
-rw-r--r--src/util/proc_compat.c3
-rw-r--r--src/util/program.c1
-rw-r--r--src/util/regex.c2
-rw-r--r--src/util/resolver_api.c1
-rw-r--r--src/util/scheduler.c1
-rw-r--r--src/util/service.c1
-rw-r--r--src/util/signal.c1
-rw-r--r--src/util/socks.c1
-rw-r--r--src/util/speedup.c1
-rw-r--r--src/util/strings.c5
-rw-r--r--src/util/test_bio.c142
-rw-r--r--src/util/test_child_management.c1
-rw-r--r--src/util/test_client.c1
-rw-r--r--src/util/test_common_allocation.c1
-rw-r--r--src/util/test_common_endian.c1
-rw-r--r--src/util/test_common_logging.c1
-rw-r--r--src/util/test_common_logging_dummy.c5
-rw-r--r--src/util/test_common_logging_runtime_loglevels.c1
-rw-r--r--src/util/test_configuration.c1
-rw-r--r--src/util/test_container_bloomfilter.c1
-rw-r--r--src/util/test_container_dll.c1
-rw-r--r--src/util/test_container_heap.c1
-rw-r--r--src/util/test_container_meta_data.c375
-rw-r--r--src/util/test_container_multihashmap.c1
-rw-r--r--src/util/test_container_multihashmap32.c1
-rw-r--r--src/util/test_container_multipeermap.c1
-rw-r--r--src/util/test_crypto_crc.c1
-rw-r--r--src/util/test_crypto_cs.c1
-rw-r--r--src/util/test_crypto_ecc_dlog.c1
-rw-r--r--src/util/test_crypto_ecdh_ecdsa.c1
-rw-r--r--src/util/test_crypto_ecdh_eddsa.c1
-rw-r--r--src/util/test_crypto_ecdhe.c1
-rw-r--r--src/util/test_crypto_ecdsa.c1
-rw-r--r--src/util/test_crypto_eddsa.c1
-rw-r--r--src/util/test_crypto_edx25519.c1
-rw-r--r--src/util/test_crypto_hash.c1
-rw-r--r--src/util/test_crypto_hash_context.c1
-rw-r--r--src/util/test_crypto_hkdf.c5
-rw-r--r--src/util/test_crypto_kdf.c5
-rw-r--r--src/util/test_crypto_paillier.c1
-rw-r--r--src/util/test_crypto_random.c1
-rw-r--r--src/util/test_crypto_rsa.c1
-rw-r--r--src/util/test_crypto_symmetric.c1
-rw-r--r--src/util/test_disk.c1
-rw-r--r--src/util/test_getopt.c1
-rw-r--r--src/util/test_hexcoder.c2
-rw-r--r--src/util/test_mq.c1
-rw-r--r--src/util/test_os_network.c1
-rw-r--r--src/util/test_os_start_process.c1
-rw-r--r--src/util/test_peer.c1
-rw-r--r--src/util/test_plugin.c1
-rw-r--r--src/util/test_plugin_plug.c1
-rw-r--r--src/util/test_program.c1
-rw-r--r--src/util/test_regex.c1
-rw-r--r--src/util/test_resolver_api.c1
-rw-r--r--src/util/test_scheduler.c1
-rw-r--r--src/util/test_scheduler_delay.c1
-rw-r--r--src/util/test_service.c1
-rw-r--r--src/util/test_socks.c1
-rw-r--r--src/util/test_speedup.c1
-rw-r--r--src/util/test_strings.c1
-rw-r--r--src/util/test_strings_to_data.c1
-rw-r--r--src/util/test_time.c1
-rw-r--r--src/util/test_tun.c1
-rw-r--r--src/util/test_uri.c1
-rw-r--r--src/util/time.c1
-rw-r--r--src/util/tun.c1
-rw-r--r--src/util/uri.c1
-rw-r--r--src/vpn/gnunet-helper-vpn.c2
-rw-r--r--src/vpn/gnunet-service-vpn.c1
-rw-r--r--src/vpn/gnunet-vpn.c1
-rw-r--r--src/zonemaster/gnunet-service-zonemaster.c38
564 files changed, 4686 insertions, 3379 deletions
diff --git a/src/abd/gnunet-service-abd.c b/src/abd/gnunet-service-abd.c
index 407d5bdc3..42b26eb9b 100644
--- a/src/abd/gnunet-service-abd.c
+++ b/src/abd/gnunet-service-abd.c
@@ -32,7 +32,6 @@
32#include "gnunet_protocols.h" 32#include "gnunet_protocols.h"
33#include "gnunet_signatures.h" 33#include "gnunet_signatures.h"
34#include "gnunet_statistics_service.h" 34#include "gnunet_statistics_service.h"
35#include <gnunet_dnsparser_lib.h>
36#include <gnunet_gns_service.h> 35#include <gnunet_gns_service.h>
37#include <gnunet_gnsrecord_lib.h> 36#include <gnunet_gnsrecord_lib.h>
38#include <gnunet_identity_service.h> 37#include <gnunet_identity_service.h>
diff --git a/src/arm/mockup-service.c b/src/arm/mockup-service.c
index 43dd3c92b..3d3f79d35 100644
--- a/src/arm/mockup-service.c
+++ b/src/arm/mockup-service.c
@@ -18,8 +18,8 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#include <stdlib.h>
22#include "platform.h" 21#include "platform.h"
22#include <stdlib.h>
23#include "gnunet_util_lib.h" 23#include "gnunet_util_lib.h"
24#include "gnunet_protocols.h" 24#include "gnunet_protocols.h"
25 25
diff --git a/src/arm/test_gnunet_service_arm.c b/src/arm/test_gnunet_service_arm.c
index 90fb8bfa0..df4ad95c2 100644
--- a/src/arm/test_gnunet_service_arm.c
+++ b/src/arm/test_gnunet_service_arm.c
@@ -26,8 +26,7 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_arm_service.h" 27#include "gnunet_arm_service.h"
28#include "gnunet_resolver_service.h" 28#include "gnunet_resolver_service.h"
29#include "gnunet_os_lib.h" 29#include "gnunet_util_lib.h"
30#include "gnunet_program_lib.h"
31 30
32/** 31/**
33 * Timeout for starting services, very short because of the strange way start works 32 * Timeout for starting services, very short because of the strange way start works
diff --git a/src/cadet/cadet.h b/src/cadet/cadet.h
index 31dad4117..e8caa7d35 100644
--- a/src/cadet/cadet.h
+++ b/src/cadet/cadet.h
@@ -55,7 +55,6 @@ extern "C" {
55 55
56#include "platform.h" 56#include "platform.h"
57#include "gnunet_util_lib.h" 57#include "gnunet_util_lib.h"
58#include "gnunet_peer_lib.h"
59#include "gnunet_core_service.h" 58#include "gnunet_core_service.h"
60#include "gnunet_cadet_service.h" 59#include "gnunet_cadet_service.h"
61#include "gnunet_protocols.h" 60#include "gnunet_protocols.h"
diff --git a/src/cadet/desirability_table.c b/src/cadet/desirability_table.c
index 829c618af..b4db7c2dd 100644
--- a/src/cadet/desirability_table.c
+++ b/src/cadet/desirability_table.c
@@ -5,6 +5,7 @@
5 * for various plausible inputs. 5 * for various plausible inputs.
6 * @author Christian Grothoff 6 * @author Christian Grothoff
7 */ 7 */
8#include "platform.h"
8#include <stdio.h> 9#include <stdio.h>
9 10
10int 11int
diff --git a/src/cadet/gnunet-cadet-profiler.c b/src/cadet/gnunet-cadet-profiler.c
index b84337370..22cbe55dc 100644
--- a/src/cadet/gnunet-cadet-profiler.c
+++ b/src/cadet/gnunet-cadet-profiler.c
@@ -22,8 +22,8 @@
22 * 22 *
23 * @brief Profiler for cadet experiments. 23 * @brief Profiler for cadet experiments.
24 */ 24 */
25#include <stdio.h>
26#include "platform.h" 25#include "platform.h"
26#include <stdio.h>
27#include "cadet_test_lib.h" 27#include "cadet_test_lib.h"
28#include "gnunet_cadet_service.h" 28#include "gnunet_cadet_service.h"
29#include "gnunet_statistics_service.h" 29#include "gnunet_statistics_service.h"
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c
index bdf2ac986..61c09f389 100644
--- a/src/cadet/test_cadet.c
+++ b/src/cadet/test_cadet.c
@@ -23,8 +23,8 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 * @brief Test for the cadet service using mq API. 24 * @brief Test for the cadet service using mq API.
25 */ 25 */
26#include <stdio.h>
27#include "platform.h" 26#include "platform.h"
27#include <stdio.h>
28#include "cadet.h" 28#include "cadet.h"
29#include "cadet_test_lib.h" 29#include "cadet_test_lib.h"
30#include "gnunet_cadet_service.h" 30#include "gnunet_cadet_service.h"
diff --git a/src/cadet/test_cadet_flow.c b/src/cadet/test_cadet_flow.c
index 9f5a45986..441599973 100644
--- a/src/cadet/test_cadet_flow.c
+++ b/src/cadet/test_cadet_flow.c
@@ -23,8 +23,8 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 * @brief Test for flow control of CADET service 24 * @brief Test for flow control of CADET service
25 */ 25 */
26#include <stdio.h>
27#include "platform.h" 26#include "platform.h"
27#include <stdio.h>
28#include "cadet_test_lib.h" 28#include "cadet_test_lib.h"
29#include "gnunet_cadet_service.h" 29#include "gnunet_cadet_service.h"
30#include "gnunet_statistics_service.h" 30#include "gnunet_statistics_service.h"
diff --git a/src/consensus/consensus_api.c b/src/consensus/consensus_api.c
index d0af2d2d9..01d0ad3de 100644
--- a/src/consensus/consensus_api.c
+++ b/src/consensus/consensus_api.c
@@ -26,7 +26,6 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_protocols.h" 28#include "gnunet_protocols.h"
29#include "gnunet_client_lib.h"
30#include "gnunet_consensus_service.h" 29#include "gnunet_consensus_service.h"
31#include "consensus.h" 30#include "consensus.h"
32 31
diff --git a/src/conversation/gnunet_gst.c b/src/conversation/gnunet_gst.c
index d776189cd..48d41a457 100644
--- a/src/conversation/gnunet_gst.c
+++ b/src/conversation/gnunet_gst.c
@@ -22,6 +22,7 @@
22 * @brief FIXME 22 * @brief FIXME
23 * @author Hark 23 * @author Hark
24 */ 24 */
25#include "platform.h"
25#include "gnunet_gst_def.h" 26#include "gnunet_gst_def.h"
26 27
27/** 28/**
diff --git a/src/conversation/gnunet_gst_test.c b/src/conversation/gnunet_gst_test.c
index a7364aece..dd2ef5a38 100644
--- a/src/conversation/gnunet_gst_test.c
+++ b/src/conversation/gnunet_gst_test.c
@@ -23,6 +23,7 @@
23 * @author Hark 23 * @author Hark
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet_gst_def.h" 27#include "gnunet_gst_def.h"
27#include "gnunet_gst.h" 28#include "gnunet_gst.h"
28 29
diff --git a/src/core/core.h b/src/core/core.h
index 4d8619a29..17df7acb7 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -26,9 +26,8 @@
26#ifndef CORE_H 26#ifndef CORE_H
27#define CORE_H 27#define CORE_H
28 28
29#include "gnunet_bandwidth_lib.h"
30#include "gnunet_transport_service.h" 29#include "gnunet_transport_service.h"
31#include "gnunet_crypto_lib.h" 30#include "gnunet_util_lib.h"
32#include "gnunet_time_lib.h" 31#include "gnunet_time_lib.h"
33 32
34/** 33/**
diff --git a/src/datacache/Makefile.am b/src/datacache/Makefile.am
index 4789706ff..14778e0a3 100644
--- a/src/datacache/Makefile.am
+++ b/src/datacache/Makefile.am
@@ -8,6 +8,13 @@ pkgcfgdir= $(pkgdatadir)/config.d/
8dist_pkgcfg_DATA = \ 8dist_pkgcfg_DATA = \
9 datacache.conf 9 datacache.conf
10 10
11sqldir = $(prefix)/share/gnunet/sql/
12
13sql_DATA = \
14 datacache-0001.sql \
15 datacache-drop.sql
16
17
11if USE_COVERAGE 18if USE_COVERAGE
12 AM_CFLAGS = --coverage -O0 19 AM_CFLAGS = --coverage -O0
13 XLIBS = -lgcov 20 XLIBS = -lgcov
@@ -195,4 +202,5 @@ EXTRA_DIST = \
195 test_datacache_data_heap.conf \ 202 test_datacache_data_heap.conf \
196 perf_datacache_data_heap.conf \ 203 perf_datacache_data_heap.conf \
197 test_datacache_data_postgres.conf \ 204 test_datacache_data_postgres.conf \
198 perf_datacache_data_postgres.conf 205 perf_datacache_data_postgres.conf \
206 $(sql_DATA)
diff --git a/src/datacache/datacache-0001.sql b/src/datacache/datacache-0001.sql
new file mode 100644
index 000000000..6567de3c2
--- /dev/null
+++ b/src/datacache/datacache-0001.sql
@@ -0,0 +1,48 @@
1--
2-- This file is part of GNUnet
3-- Copyright (C) 2014--2022 GNUnet e.V.
4--
5-- GNUnet is free software; you can redistribute it and/or modify it under the
6-- terms of the GNU General Public License as published by the Free Software
7-- Foundation; either version 3, or (at your option) any later version.
8--
9-- GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY
10-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12--
13-- You should have received a copy of the GNU General Public License along with
14-- GNUnet; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
15--
16
17-- Everything in one big transaction
18BEGIN;
19
20-- Check patch versioning is in place.
21SELECT _v.register_patch('datacache-0001', NULL, NULL);
22
23-------------------- Schema ----------------------------
24
25CREATE SCHEMA datacache;
26COMMENT ON SCHEMA datacache IS 'gnunet-datacache data';
27
28SET search_path TO datacache;
29
30CREATE TABLE IF NOT EXISTS gn180dc (
31 oid BIGINT GENERATED BY DEFAULT AS IDENTITY,
32 type INT4 NOT NULL,
33 ro INT4 NOT NULL,
34 prox INT4 NOT NULL,
35 expiration_time INT8 NOT NULL,
36 key BYTEA NOT NULL CHECK(LENGTH(key)=64),
37 trunc BYTEA NOT NULL CHECK(LENGTH(trunc)=32),
38 value BYTEA NOT NULL,
39 path BYTEA DEFAULT NULL);
40
41CREATE INDEX IF NOT EXISTS idx_oid
42 ON gn180dc (oid);
43CREATE INDEX IF NOT EXISTS idx_key
44 ON gn180dc (key);
45CREATE INDEX IF NOT EXISTS idx_dt
46 ON gn180dc (expiration_time);
47
48COMMIT;
diff --git a/src/datacache/datacache-drop.sql b/src/datacache/datacache-drop.sql
new file mode 100644
index 000000000..2dd84bca8
--- /dev/null
+++ b/src/datacache/datacache-drop.sql
@@ -0,0 +1,25 @@
1--
2-- This file is part of GNUnet
3-- Copyright (C) 2014--2022 GNUnet e.V.
4--
5-- GNUnet is free software; you can redistribute it and/or modify it under the
6-- terms of the GNU General Public License as published by the Free Software
7-- Foundation; either version 3, or (at your option) any later version.
8--
9-- GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY
10-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12--
13-- You should have received a copy of the GNU General Public License along with
14-- GNUnet; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
15--
16
17-- Everything in one big transaction
18BEGIN;
19
20
21SELECT _v.unregister_patch('datacache-0001');
22
23DROP SCHEMA datacache CASCADE;
24
25COMMIT;
diff --git a/src/datacache/datacache.conf b/src/datacache/datacache.conf
index f9c718eb0..ed5c3da06 100644
--- a/src/datacache/datacache.conf
+++ b/src/datacache/datacache.conf
@@ -1,2 +1,6 @@
1[datacache-postgres] 1[datacache-postgres]
2CONFIG = postgres:///gnunet 2CONFIG = postgres:///gnunet
3
4# Where are the SQL files to setup our tables?
5# Important: this MUST end with a "/"!
6SQL_DIR = $DATADIR/sql/ \ No newline at end of file
diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c
index df5fc4454..8bfd04aea 100644
--- a/src/datacache/plugin_datacache_postgres.c
+++ b/src/datacache/plugin_datacache_postgres.c
@@ -66,64 +66,45 @@ struct Plugin
66static enum GNUNET_GenericReturnValue 66static enum GNUNET_GenericReturnValue
67init_connection (struct Plugin *plugin) 67init_connection (struct Plugin *plugin)
68{ 68{
69 struct GNUNET_PQ_ExecuteStatement es[] = {
70 GNUNET_PQ_make_try_execute (
71 "CREATE TEMPORARY SEQUENCE IF NOT EXISTS gn180dc_oid_seq"),
72 GNUNET_PQ_make_execute ("CREATE TEMPORARY TABLE IF NOT EXISTS gn180dc ("
73 " oid OID NOT NULL DEFAULT nextval('gn180dc_oid_seq'),"
74 " type INT4 NOT NULL,"
75 " ro INT4 NOT NULL,"
76 " prox INT4 NOT NULL,"
77 " expiration_time INT8 NOT NULL,"
78 " key BYTEA NOT NULL CHECK(LENGTH(key)=64),"
79 " trunc BYTEA NOT NULL CHECK(LENGTH(trunc)=32),"
80 " value BYTEA NOT NULL,"
81 " path BYTEA DEFAULT NULL)"),
82 GNUNET_PQ_make_try_execute (
83 "ALTER SEQUENCE gnu011dc_oid_seq OWNED BY gn180dc.oid"),
84 GNUNET_PQ_make_try_execute (
85 "CREATE INDEX IF NOT EXISTS idx_oid ON gn180dc (oid)"),
86 GNUNET_PQ_make_try_execute (
87 "CREATE INDEX IF NOT EXISTS idx_key ON gn180dc (key)"),
88 GNUNET_PQ_make_try_execute (
89 "CREATE INDEX IF NOT EXISTS idx_dt ON gn180dc (expiration_time)"),
90 GNUNET_PQ_make_execute (
91 "ALTER TABLE gn180dc ALTER value SET STORAGE EXTERNAL"),
92 GNUNET_PQ_make_execute ("ALTER TABLE gn180dc ALTER key SET STORAGE PLAIN"),
93 GNUNET_PQ_EXECUTE_STATEMENT_END
94 };
95 struct GNUNET_PQ_PreparedStatement ps[] = { 69 struct GNUNET_PQ_PreparedStatement ps[] = {
96 GNUNET_PQ_make_prepare ("getkt", 70 GNUNET_PQ_make_prepare ("getkt",
97 "SELECT expiration_time,type,ro,value,trunc,path FROM gn180dc " 71 "SELECT expiration_time,type,ro,value,trunc,path"
98 "WHERE key=$1 AND type=$2 AND expiration_time >= $3"), 72 " FROM datacache.gn180dc"
73 " WHERE key=$1 AND type=$2 AND expiration_time >= $3"),
99 GNUNET_PQ_make_prepare ("getk", 74 GNUNET_PQ_make_prepare ("getk",
100 "SELECT expiration_time,type,ro,value,trunc,path FROM gn180dc " 75 "SELECT expiration_time,type,ro,value,trunc,path"
101 "WHERE key=$1 AND expiration_time >= $2"), 76 " FROM datacache.gn180dc"
77 " WHERE key=$1 AND expiration_time >= $2"),
102 GNUNET_PQ_make_prepare ("getex", 78 GNUNET_PQ_make_prepare ("getex",
103 "SELECT LENGTH(value) AS len,oid,key FROM gn180dc" 79 "SELECT LENGTH(value) AS len,oid,key"
80 " FROM datacache.gn180dc"
104 " WHERE expiration_time < $1" 81 " WHERE expiration_time < $1"
105 " ORDER BY expiration_time ASC LIMIT 1"), 82 " ORDER BY expiration_time ASC LIMIT 1"),
106 GNUNET_PQ_make_prepare ("getm", 83 GNUNET_PQ_make_prepare ("getm",
107 "SELECT LENGTH(value) AS len,oid,key FROM gn180dc" 84 "SELECT LENGTH(value) AS len,oid,key"
85 " FROM datacache.gn180dc"
108 " ORDER BY prox ASC, expiration_time ASC LIMIT 1"), 86 " ORDER BY prox ASC, expiration_time ASC LIMIT 1"),
109 GNUNET_PQ_make_prepare ("get_closest", 87 GNUNET_PQ_make_prepare ("get_closest",
110 "(SELECT expiration_time,type,ro,value,trunc,path,key FROM gn180dc" 88 "(SELECT expiration_time,type,ro,value,trunc,path,key"
89 " FROM datacache.gn180dc"
111 " WHERE key >= $1" 90 " WHERE key >= $1"
112 " AND expiration_time >= $2" 91 " AND expiration_time >= $2"
113 " AND ( (type = $3) OR ( 0 = $3) )" 92 " AND ( (type = $3) OR ( 0 = $3) )"
114 " ORDER BY key ASC" 93 " ORDER BY key ASC"
115 " LIMIT $4)" 94 " LIMIT $4)"
116 " UNION " 95 " UNION "
117 "(SELECT expiration_time,type,ro,value,trunc,path,key FROM gn180dc" 96 "(SELECT expiration_time,type,ro,value,trunc,path,key"
97 " FROM datacache.gn180dc"
118 " WHERE key <= $1" 98 " WHERE key <= $1"
119 " AND expiration_time >= $2" 99 " AND expiration_time >= $2"
120 " AND ( (type = $3) OR ( 0 = $3) )" 100 " AND ( (type = $3) OR ( 0 = $3) )"
121 " ORDER BY key DESC" 101 " ORDER BY key DESC"
122 " LIMIT $4)"), 102 " LIMIT $4)"),
123 GNUNET_PQ_make_prepare ("delrow", 103 GNUNET_PQ_make_prepare ("delrow",
124 "DELETE FROM gn180dc WHERE oid=$1"), 104 "DELETE FROM datacache.gn180dc"
105 " WHERE oid=$1"),
125 GNUNET_PQ_make_prepare ("put", 106 GNUNET_PQ_make_prepare ("put",
126 "INSERT INTO gn180dc" 107 "INSERT INTO datacache.gn180dc"
127 " (type, ro, prox, expiration_time, key, value, trunc, path) " 108 " (type, ro, prox, expiration_time, key, value, trunc, path) "
128 "VALUES ($1, $2, $3, $4, $5, $6, $7, $8)"), 109 "VALUES ($1, $2, $3, $4, $5, $6, $7, $8)"),
129 GNUNET_PQ_PREPARED_STATEMENT_END 110 GNUNET_PQ_PREPARED_STATEMENT_END
@@ -131,8 +112,8 @@ init_connection (struct Plugin *plugin)
131 112
132 plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->env->cfg, 113 plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->env->cfg,
133 "datacache-postgres", 114 "datacache-postgres",
115 "datacache-",
134 NULL, 116 NULL,
135 es,
136 ps); 117 ps);
137 if (NULL == plugin->dbh) 118 if (NULL == plugin->dbh)
138 return GNUNET_SYSERR; 119 return GNUNET_SYSERR;
@@ -165,9 +146,12 @@ postgres_plugin_put (void *cls,
165 GNUNET_PQ_query_param_fixed_size (block->data, 146 GNUNET_PQ_query_param_fixed_size (block->data,
166 block->data_size), 147 block->data_size),
167 GNUNET_PQ_query_param_auto_from_type (&block->trunc_peer), 148 GNUNET_PQ_query_param_auto_from_type (&block->trunc_peer),
168 GNUNET_PQ_query_param_fixed_size (block->put_path, 149 (0 == block->put_path_length)
169 block->put_path_length 150 ? GNUNET_PQ_query_param_null ()
170 * sizeof(struct GNUNET_DHT_PathElement)), 151 : GNUNET_PQ_query_param_fixed_size (
152 block->put_path,
153 block->put_path_length
154 * sizeof(struct GNUNET_DHT_PathElement)),
171 GNUNET_PQ_query_param_end 155 GNUNET_PQ_query_param_end
172 }; 156 };
173 enum GNUNET_DB_QueryStatus ret; 157 enum GNUNET_DB_QueryStatus ret;
@@ -226,8 +210,8 @@ handle_results (void *cls,
226 uint32_t bro32; 210 uint32_t bro32;
227 void *data; 211 void *data;
228 struct GNUNET_DATACACHE_Block block; 212 struct GNUNET_DATACACHE_Block block;
229 void *path; 213 void *path = NULL;
230 size_t path_size; 214 size_t path_size = 0;
231 struct GNUNET_PQ_ResultSpec rs[] = { 215 struct GNUNET_PQ_ResultSpec rs[] = {
232 GNUNET_PQ_result_spec_absolute_time ("expiration_time", 216 GNUNET_PQ_result_spec_absolute_time ("expiration_time",
233 &block.expiration_time), 217 &block.expiration_time),
@@ -240,9 +224,11 @@ handle_results (void *cls,
240 &block.data_size), 224 &block.data_size),
241 GNUNET_PQ_result_spec_auto_from_type ("trunc", 225 GNUNET_PQ_result_spec_auto_from_type ("trunc",
242 &block.trunc_peer), 226 &block.trunc_peer),
243 GNUNET_PQ_result_spec_variable_size ("path", 227 GNUNET_PQ_result_spec_allow_null (
244 &path, 228 GNUNET_PQ_result_spec_variable_size ("path",
245 &path_size), 229 &path,
230 &path_size),
231 NULL),
246 GNUNET_PQ_result_spec_end 232 GNUNET_PQ_result_spec_end
247 }; 233 };
248 234
@@ -351,12 +337,12 @@ postgres_plugin_del (void *cls)
351 GNUNET_PQ_query_param_end 337 GNUNET_PQ_query_param_end
352 }; 338 };
353 uint32_t size; 339 uint32_t size;
354 uint32_t oid; 340 uint64_t oid;
355 struct GNUNET_HashCode key; 341 struct GNUNET_HashCode key;
356 struct GNUNET_PQ_ResultSpec rs[] = { 342 struct GNUNET_PQ_ResultSpec rs[] = {
357 GNUNET_PQ_result_spec_uint32 ("len", 343 GNUNET_PQ_result_spec_uint32 ("len",
358 &size), 344 &size),
359 GNUNET_PQ_result_spec_uint32 ("oid", 345 GNUNET_PQ_result_spec_uint64 ("oid",
360 &oid), 346 &oid),
361 GNUNET_PQ_result_spec_auto_from_type ("key", 347 GNUNET_PQ_result_spec_auto_from_type ("key",
362 &key), 348 &key),
@@ -364,7 +350,7 @@ postgres_plugin_del (void *cls)
364 }; 350 };
365 enum GNUNET_DB_QueryStatus res; 351 enum GNUNET_DB_QueryStatus res;
366 struct GNUNET_PQ_QueryParam dparam[] = { 352 struct GNUNET_PQ_QueryParam dparam[] = {
367 GNUNET_PQ_query_param_uint32 (&oid), 353 GNUNET_PQ_query_param_uint64 (&oid),
368 GNUNET_PQ_query_param_end 354 GNUNET_PQ_query_param_end
369 }; 355 };
370 struct GNUNET_TIME_Absolute now; 356 struct GNUNET_TIME_Absolute now;
@@ -617,6 +603,9 @@ libgnunet_plugin_datacache_postgres_done (void *cls)
617 struct GNUNET_DATACACHE_PluginFunctions *api = cls; 603 struct GNUNET_DATACACHE_PluginFunctions *api = cls;
618 struct Plugin *plugin = api->cls; 604 struct Plugin *plugin = api->cls;
619 605
606 GNUNET_break (GNUNET_OK ==
607 GNUNET_PQ_exec_sql (plugin->dbh,
608 "datacache-drop"));
620 GNUNET_PQ_disconnect (plugin->dbh); 609 GNUNET_PQ_disconnect (plugin->dbh);
621 GNUNET_free (plugin); 610 GNUNET_free (plugin);
622 GNUNET_free (api); 611 GNUNET_free (api);
diff --git a/src/datastore/Makefile.am b/src/datastore/Makefile.am
index 07ae004b3..b73a0497b 100644
--- a/src/datastore/Makefile.am
+++ b/src/datastore/Makefile.am
@@ -10,6 +10,12 @@ libexecdir= $(pkglibdir)/libexec/
10pkgcfg_DATA = \ 10pkgcfg_DATA = \
11 datastore.conf 11 datastore.conf
12 12
13sqldir = $(prefix)/share/gnunet/sql/
14
15sql_DATA = \
16 datastore-0001.sql \
17 datastore-drop.sql
18
13if USE_COVERAGE 19if USE_COVERAGE
14 AM_CFLAGS = --coverage -O0 20 AM_CFLAGS = --coverage -O0
15 XLIBS = -lgcov 21 XLIBS = -lgcov
@@ -318,4 +324,5 @@ EXTRA_DIST = \
318 test_plugin_datastore_data_mysql.conf \ 324 test_plugin_datastore_data_mysql.conf \
319 test_datastore_api_data_postgres.conf \ 325 test_datastore_api_data_postgres.conf \
320 perf_plugin_datastore_data_postgres.conf \ 326 perf_plugin_datastore_data_postgres.conf \
321 test_plugin_datastore_data_postgres.conf 327 test_plugin_datastore_data_postgres.conf \
328 $(sql_DATA)
diff --git a/src/datastore/datastore-0001.sql b/src/datastore/datastore-0001.sql
new file mode 100644
index 000000000..0d4758be2
--- /dev/null
+++ b/src/datastore/datastore-0001.sql
@@ -0,0 +1,49 @@
1--
2-- This file is part of GNUnet
3-- Copyright (C) 2014--2022 GNUnet e.V.
4--
5-- GNUnet is free software; you can redistribute it and/or modify it under the
6-- terms of the GNU General Public License as published by the Free Software
7-- Foundation; either version 3, or (at your option) any later version.
8--
9-- GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY
10-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12--
13-- You should have received a copy of the GNU General Public License along with
14-- GNUnet; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
15--
16
17-- Everything in one big transaction
18BEGIN;
19
20-- Check patch versioning is in place.
21SELECT _v.register_patch('datastore-0001', NULL, NULL);
22
23-------------------- Schema ----------------------------
24
25CREATE SCHEMA datastore;
26COMMENT ON SCHEMA datastore IS 'gnunet-datastore data';
27
28SET search_path TO datastore;
29
30CREATE TABLE IF NOT EXISTS gn090 (
31 repl INTEGER NOT NULL DEFAULT 0,
32 type INTEGER NOT NULL DEFAULT 0,
33 prio INTEGER NOT NULL DEFAULT 0,
34 anonLevel INTEGER NOT NULL DEFAULT 0,
35 expire BIGINT NOT NULL DEFAULT 0,
36 rvalue BIGINT NOT NULL DEFAULT 0,
37 hash BYTEA NOT NULL DEFAULT '',
38 vhash BYTEA NOT NULL DEFAULT '',
39 value BYTEA NOT NULL DEFAULT '',
40 oid BIGINT GENERATED BY DEFAULT AS IDENTITY);
41
42CREATE INDEX IF NOT EXISTS oid_hash ON gn090 (oid);
43CREATE INDEX IF NOT EXISTS idx_hash ON gn090 (hash);
44CREATE INDEX IF NOT EXISTS idx_prio_anon ON gn090 (prio,anonLevel);
45CREATE INDEX IF NOT EXISTS idx_prio_hash_anon ON gn090 (prio,hash,anonLevel);
46CREATE INDEX IF NOT EXISTS idx_repl_rvalue ON gn090 (repl,rvalue);
47CREATE INDEX IF NOT EXISTS idx_expire_hash ON gn090 (expire,hash);
48
49COMMIT;
diff --git a/src/datastore/datastore-drop.sql b/src/datastore/datastore-drop.sql
new file mode 100644
index 000000000..67fee303d
--- /dev/null
+++ b/src/datastore/datastore-drop.sql
@@ -0,0 +1,25 @@
1--
2-- This file is part of GNUnet
3-- Copyright (C) 2014--2022 GNUnet e.V.
4--
5-- GNUnet is free software; you can redistribute it and/or modify it under the
6-- terms of the GNU General Public License as published by the Free Software
7-- Foundation; either version 3, or (at your option) any later version.
8--
9-- GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY
10-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12--
13-- You should have received a copy of the GNU General Public License along with
14-- GNUnet; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
15--
16
17-- Everything in one big transaction
18BEGIN;
19
20
21SELECT _v.unregister_patch('datastore-0001');
22
23DROP SCHEMA datastore CASCADE;
24
25COMMIT;
diff --git a/src/datastore/datastore.conf.in b/src/datastore/datastore.conf.in
index 21d24bb52..bcd495c8f 100644
--- a/src/datastore/datastore.conf.in
+++ b/src/datastore/datastore.conf.in
@@ -18,6 +18,7 @@ FILENAME = $GNUNET_DATA_HOME/datastore/sqlite.db
18 18
19[datastore-postgres] 19[datastore-postgres]
20CONFIG = postgres:///gnunet 20CONFIG = postgres:///gnunet
21SQL_DIR = ${DATADIR}/sql/
21 22
22[datastore-mysql] 23[datastore-mysql]
23DATABASE = gnunet 24DATABASE = gnunet
diff --git a/src/datastore/gnunet-datastore.c b/src/datastore/gnunet-datastore.c
index 5901cce54..9a76d1160 100644
--- a/src/datastore/gnunet-datastore.c
+++ b/src/datastore/gnunet-datastore.c
@@ -23,8 +23,8 @@
23 * @brief tool to manipulate datastores 23 * @brief tool to manipulate datastores
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include <inttypes.h>
27#include "platform.h" 26#include "platform.h"
27#include <inttypes.h>
28#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
29#include "gnunet_datastore_service.h" 29#include "gnunet_datastore_service.h"
30 30
diff --git a/src/datastore/plugin_datastore_mysql.c b/src/datastore/plugin_datastore_mysql.c
index 216a6faa4..f62c51778 100644
--- a/src/datastore/plugin_datastore_mysql.c
+++ b/src/datastore/plugin_datastore_mysql.c
@@ -121,6 +121,7 @@
121#include "gnunet_datastore_plugin.h" 121#include "gnunet_datastore_plugin.h"
122#include "gnunet_util_lib.h" 122#include "gnunet_util_lib.h"
123#include "gnunet_mysql_lib.h" 123#include "gnunet_mysql_lib.h"
124#include "gnunet_mysql_compat.h"
124#include "gnunet_my_lib.h" 125#include "gnunet_my_lib.h"
125 126
126#define MAX_DATUM_SIZE 65536 127#define MAX_DATUM_SIZE 65536
diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c
index e49564dd9..5fcacc17b 100644
--- a/src/datastore/plugin_datastore_postgres.c
+++ b/src/datastore/plugin_datastore_postgres.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 Copyright (C) 2009-2017 GNUnet e.V. 3 Copyright (C) 2009-2017, 2022 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 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 6 under the terms of the GNU Affero General Public License as published
@@ -64,102 +64,67 @@ struct Plugin
64 * @param plugin global context 64 * @param plugin global context
65 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 65 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
66 */ 66 */
67static int 67static enum GNUNET_GenericReturnValue
68init_connection (struct Plugin *plugin) 68init_connection (struct Plugin *plugin)
69{ 69{
70 struct GNUNET_PQ_ExecuteStatement es[] = {
71 /* FIXME: PostgreSQL does not have unsigned integers! This is ok for the type column because
72 * we only test equality on it and can cast it to/from uint32_t. For repl, prio, and anonLevel
73 * we do math or inequality tests, so we can't handle the entire range of uint32_t.
74 * This will also cause problems for expiration times after 294247-01-10-04:00:54 UTC.
75 */
76 GNUNET_PQ_make_try_execute (
77 "CREATE SEQUENCE IF NOT EXISTS gn090_oid_seq"),
78 GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS gn090 ("
79 " repl INTEGER NOT NULL DEFAULT 0,"
80 " type INTEGER NOT NULL DEFAULT 0,"
81 " prio INTEGER NOT NULL DEFAULT 0,"
82 " anonLevel INTEGER NOT NULL DEFAULT 0,"
83 " expire BIGINT NOT NULL DEFAULT 0,"
84 " rvalue BIGINT NOT NULL DEFAULT 0,"
85 " hash BYTEA NOT NULL DEFAULT '',"
86 " vhash BYTEA NOT NULL DEFAULT '',"
87 " value BYTEA NOT NULL DEFAULT '',"
88 " oid OID NOT NULL DEFAULT nextval('gn090_oid_seq'))"),
89 GNUNET_PQ_make_try_execute (
90 "ALTER SEQUENCE gn090_oid_seq OWNED BY gn090.oid"),
91 GNUNET_PQ_make_try_execute (
92 "CREATE INDEX IF NOT EXISTS oid_hash ON gn090 (oid)"),
93 GNUNET_PQ_make_try_execute (
94 "CREATE INDEX IF NOT EXISTS idx_hash ON gn090 (hash)"),
95 GNUNET_PQ_make_try_execute (
96 "CREATE INDEX IF NOT EXISTS idx_prio ON gn090 (prio)"),
97 GNUNET_PQ_make_try_execute (
98 "CREATE INDEX IF NOT EXISTS idx_expire ON gn090 (expire)"),
99 GNUNET_PQ_make_try_execute (
100 "CREATE INDEX IF NOT EXISTS idx_prio_anon ON gn090 (prio,anonLevel)"),
101 GNUNET_PQ_make_try_execute (
102 "CREATE INDEX IF NOT EXISTS idx_prio_hash_anon ON gn090 (prio,hash,anonLevel)"),
103 GNUNET_PQ_make_try_execute (
104 "CREATE INDEX IF NOT EXISTS idx_repl_rvalue ON gn090 (repl,rvalue)"),
105 GNUNET_PQ_make_try_execute (
106 "CREATE INDEX IF NOT EXISTS idx_expire_hash ON gn090 (expire,hash)"),
107 GNUNET_PQ_make_execute (
108 "ALTER TABLE gn090 ALTER value SET STORAGE EXTERNAL"),
109 GNUNET_PQ_make_execute ("ALTER TABLE gn090 ALTER hash SET STORAGE PLAIN"),
110 GNUNET_PQ_make_execute ("ALTER TABLE gn090 ALTER vhash SET STORAGE PLAIN"),
111 GNUNET_PQ_EXECUTE_STATEMENT_END
112 };
113
114#define RESULT_COLUMNS "repl, type, prio, anonLevel, expire, hash, value, oid" 70#define RESULT_COLUMNS "repl, type, prio, anonLevel, expire, hash, value, oid"
115 struct GNUNET_PQ_PreparedStatement ps[] = { 71 struct GNUNET_PQ_PreparedStatement ps[] = {
116 GNUNET_PQ_make_prepare ("get", 72 GNUNET_PQ_make_prepare ("get",
117 "SELECT " RESULT_COLUMNS " FROM gn090" 73 "SELECT " RESULT_COLUMNS
74 " FROM datastore.gn090"
118 " WHERE oid >= $1::bigint AND" 75 " WHERE oid >= $1::bigint AND"
119 " (rvalue >= $2 OR 0 = $3::smallint) AND" 76 " (rvalue >= $2 OR 0 = $3::smallint) AND"
120 " (hash = $4 OR 0 = $5::smallint) AND" 77 " (hash = $4 OR 0 = $5::smallint) AND"
121 " (type = $6 OR 0 = $7::smallint)" 78 " (type = $6 OR 0 = $7::smallint)"
122 " ORDER BY oid ASC LIMIT 1"), 79 " ORDER BY oid ASC LIMIT 1"),
123 GNUNET_PQ_make_prepare ("put", 80 GNUNET_PQ_make_prepare ("put",
124 "INSERT INTO gn090 (repl, type, prio, anonLevel, expire, rvalue, hash, vhash, value) " 81 "INSERT INTO datastore.gn090"
82 " (repl, type, prio, anonLevel, expire, rvalue, hash, vhash, value) "
125 "VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)"), 83 "VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)"),
126 GNUNET_PQ_make_prepare ("update", 84 GNUNET_PQ_make_prepare ("update",
127 "UPDATE gn090" 85 "UPDATE datastore.gn090"
128 " SET prio = prio + $1," 86 " SET prio = prio + $1,"
129 " repl = repl + $2," 87 " repl = repl + $2,"
130 " expire = GREATEST(expire, $3)" 88 " expire = GREATEST(expire, $3)"
131 " WHERE hash = $4 AND vhash = $5"), 89 " WHERE hash = $4 AND vhash = $5"),
132 GNUNET_PQ_make_prepare ("decrepl", 90 GNUNET_PQ_make_prepare ("decrepl",
133 "UPDATE gn090 SET repl = GREATEST (repl - 1, 0) " 91 "UPDATE datastore.gn090"
134 "WHERE oid = $1"), 92 " SET repl = GREATEST (repl - 1, 0)"
93 " WHERE oid = $1"),
135 GNUNET_PQ_make_prepare ("select_non_anonymous", 94 GNUNET_PQ_make_prepare ("select_non_anonymous",
136 "SELECT " RESULT_COLUMNS " FROM gn090 " 95 "SELECT " RESULT_COLUMNS
137 "WHERE anonLevel = 0 AND type = $1 AND oid >= $2::bigint " 96 " FROM datastore.gn090"
138 "ORDER BY oid ASC LIMIT 1"), 97 " WHERE anonLevel = 0 AND type = $1 AND oid >= $2::bigint"
98 " ORDER BY oid ASC LIMIT 1"),
139 GNUNET_PQ_make_prepare ("select_expiration_order", 99 GNUNET_PQ_make_prepare ("select_expiration_order",
140 "(SELECT " RESULT_COLUMNS " FROM gn090 " 100 "(SELECT " RESULT_COLUMNS
141 "WHERE expire < $1 ORDER BY prio ASC LIMIT 1) " 101 " FROM datastore.gn090"
102 " WHERE expire < $1 ORDER BY prio ASC LIMIT 1) "
142 "UNION " 103 "UNION "
143 "(SELECT " RESULT_COLUMNS " FROM gn090 " 104 "(SELECT " RESULT_COLUMNS
144 "ORDER BY prio ASC LIMIT 1) " 105 " FROM datastore.gn090"
145 "ORDER BY expire ASC LIMIT 1"), 106 " ORDER BY prio ASC LIMIT 1)"
107 " ORDER BY expire ASC LIMIT 1"),
146 GNUNET_PQ_make_prepare ("select_replication_order", 108 GNUNET_PQ_make_prepare ("select_replication_order",
147 "SELECT " RESULT_COLUMNS " FROM gn090 " 109 "SELECT " RESULT_COLUMNS
148 "ORDER BY repl DESC,RANDOM() LIMIT 1"), 110 " FROM datastore.gn090"
111 " ORDER BY repl DESC,RANDOM() LIMIT 1"),
149 GNUNET_PQ_make_prepare ("delrow", 112 GNUNET_PQ_make_prepare ("delrow",
150 "DELETE FROM gn090 " 113 "DELETE FROM datastore.gn090"
151 "WHERE oid=$1"), 114 " WHERE oid=$1"),
152 GNUNET_PQ_make_prepare ("remove", 115 GNUNET_PQ_make_prepare ("remove",
153 "DELETE FROM gn090" 116 "DELETE FROM datastore.gn090"
154 " WHERE hash = $1 AND" 117 " WHERE hash = $1 AND"
155 " value = $2"), 118 " value = $2"),
156 GNUNET_PQ_make_prepare ("get_keys", 119 GNUNET_PQ_make_prepare ("get_keys",
157 "SELECT hash FROM gn090"), 120 "SELECT hash"
121 " FROM datastore.gn090"),
158 GNUNET_PQ_make_prepare ("estimate_size", 122 GNUNET_PQ_make_prepare ("estimate_size",
159 "SELECT CASE WHEN NOT EXISTS" 123 "SELECT CASE WHEN NOT EXISTS"
160 " (SELECT 1 FROM gn090)" 124 " (SELECT 1 FROM datastore.gn090)"
161 " THEN 0" 125 " THEN 0"
162 " ELSE (SELECT SUM(LENGTH(value))+256*COUNT(*) FROM gn090)" 126 " ELSE (SELECT SUM(LENGTH(value))+256*COUNT(*)"
127 " FROM datastore.gn090)"
163 "END AS total"), 128 "END AS total"),
164 GNUNET_PQ_PREPARED_STATEMENT_END 129 GNUNET_PQ_PREPARED_STATEMENT_END
165 }; 130 };
@@ -167,8 +132,8 @@ init_connection (struct Plugin *plugin)
167 132
168 plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->env->cfg, 133 plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->env->cfg,
169 "datastore-postgres", 134 "datastore-postgres",
135 "datastore-",
170 NULL, 136 NULL,
171 es,
172 ps); 137 ps);
173 if (NULL == plugin->dbh) 138 if (NULL == plugin->dbh)
174 return GNUNET_SYSERR; 139 return GNUNET_SYSERR;
@@ -389,7 +354,7 @@ process_result (void *cls,
389 for (unsigned int i = 0; i < num_results; i++) 354 for (unsigned int i = 0; i < num_results; i++)
390 { 355 {
391 int iret; 356 int iret;
392 uint32_t rowid; 357 uint64_t rowid;
393 uint32_t utype; 358 uint32_t utype;
394 uint32_t anonymity; 359 uint32_t anonymity;
395 uint32_t replication; 360 uint32_t replication;
@@ -406,7 +371,7 @@ process_result (void *cls,
406 GNUNET_PQ_result_spec_absolute_time ("expire", &expiration_time), 371 GNUNET_PQ_result_spec_absolute_time ("expire", &expiration_time),
407 GNUNET_PQ_result_spec_auto_from_type ("hash", &key), 372 GNUNET_PQ_result_spec_auto_from_type ("hash", &key),
408 GNUNET_PQ_result_spec_variable_size ("value", &data, &size), 373 GNUNET_PQ_result_spec_variable_size ("value", &data, &size),
409 GNUNET_PQ_result_spec_uint32 ("oid", &rowid), 374 GNUNET_PQ_result_spec_uint64 ("oid", &rowid),
410 GNUNET_PQ_result_spec_end 375 GNUNET_PQ_result_spec_end
411 }; 376 };
412 377
@@ -439,7 +404,7 @@ process_result (void *cls,
439 if (iret == GNUNET_NO) 404 if (iret == GNUNET_NO)
440 { 405 {
441 struct GNUNET_PQ_QueryParam param[] = { 406 struct GNUNET_PQ_QueryParam param[] = {
442 GNUNET_PQ_query_param_uint32 (&rowid), 407 GNUNET_PQ_query_param_uint64 (&rowid),
443 GNUNET_PQ_query_param_end 408 GNUNET_PQ_query_param_end
444 }; 409 };
445 410
@@ -635,9 +600,8 @@ repl_proc (void *cls,
635 struct ReplCtx *rc = cls; 600 struct ReplCtx *rc = cls;
636 struct Plugin *plugin = rc->plugin; 601 struct Plugin *plugin = rc->plugin;
637 int ret; 602 int ret;
638 uint32_t oid = (uint32_t) uid;
639 struct GNUNET_PQ_QueryParam params[] = { 603 struct GNUNET_PQ_QueryParam params[] = {
640 GNUNET_PQ_query_param_uint32 (&oid), 604 GNUNET_PQ_query_param_uint64 (&uid),
641 GNUNET_PQ_query_param_end 605 GNUNET_PQ_query_param_end
642 }; 606 };
643 enum GNUNET_DB_QueryStatus qret; 607 enum GNUNET_DB_QueryStatus qret;
@@ -940,9 +904,6 @@ libgnunet_plugin_datastore_postgres_init (void *cls)
940 api->get_keys = &postgres_plugin_get_keys; 904 api->get_keys = &postgres_plugin_get_keys;
941 api->drop = &postgres_plugin_drop; 905 api->drop = &postgres_plugin_drop;
942 api->remove_key = &postgres_plugin_remove_key; 906 api->remove_key = &postgres_plugin_remove_key;
943 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO,
944 "datastore-postgres",
945 _ ("Postgres database running\n"));
946 return api; 907 return api;
947} 908}
948 909
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c
index 19b464e63..90bb4d1f7 100644
--- a/src/dht/gnunet-service-dht_clients.c
+++ b/src/dht/gnunet-service-dht_clients.c
@@ -40,7 +40,7 @@
40 * 1: check all external inputs 40 * 1: check all external inputs
41 * 2: check internal computations as well 41 * 2: check internal computations as well
42 */ 42 */
43#define SANITY_CHECKS 2 43#define SANITY_CHECKS 0
44 44
45/** 45/**
46 * Should routing details be logged to stderr (for debugging)? 46 * Should routing details be logged to stderr (for debugging)?
@@ -506,6 +506,7 @@ handle_dht_local_put (void *cls,
506 (unsigned long) (size - sizeof(struct GNUNET_DHT_ClientPutMessage)), 506 (unsigned long) (size - sizeof(struct GNUNET_DHT_ClientPutMessage)),
507 GNUNET_h2s (&dht_msg->key), 507 GNUNET_h2s (&dht_msg->key),
508 (unsigned int) bd.type); 508 (unsigned int) bd.type);
509#if SANITY_CHECKS > 0
509 if (GNUNET_OK != 510 if (GNUNET_OK !=
510 GNUNET_BLOCK_check_block (GDS_block_context, 511 GNUNET_BLOCK_check_block (GDS_block_context,
511 bd.type, 512 bd.type,
@@ -515,6 +516,7 @@ handle_dht_local_put (void *cls,
515 GNUNET_break (0); 516 GNUNET_break (0);
516 return; 517 return;
517 } 518 }
519#endif
518 GNUNET_STATISTICS_update (GDS_stats, 520 GNUNET_STATISTICS_update (GDS_stats,
519 "# PUT requests received from clients", 521 "# PUT requests received from clients",
520 1, 522 1,
@@ -1074,7 +1076,9 @@ GDS_CLIENTS_handle_reply (const struct GNUNET_DATACACHE_Block *bd,
1074 + bd->data_size 1076 + bd->data_size
1075 + (get_path_length + bd->put_path_length) 1077 + (get_path_length + bd->put_path_length)
1076 * sizeof(struct GNUNET_DHT_PathElement); 1078 * sizeof(struct GNUNET_DHT_PathElement);
1079#if SANITY_CHECKS > 1
1077 bool truncated = (0 != (bd->ro & GNUNET_DHT_RO_TRUNCATED)); 1080 bool truncated = (0 != (bd->ro & GNUNET_DHT_RO_TRUNCATED));
1081#endif
1078 1082
1079 if (msize >= GNUNET_MAX_MESSAGE_SIZE) 1083 if (msize >= GNUNET_MAX_MESSAGE_SIZE)
1080 { 1084 {
diff --git a/src/dns/gnunet-dns-monitor.c b/src/dns/gnunet-dns-monitor.c
index 48923b613..c1ef17255 100644
--- a/src/dns/gnunet-dns-monitor.c
+++ b/src/dns/gnunet-dns-monitor.c
@@ -27,7 +27,6 @@
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
29#include "gnunet_dns_service.h" 29#include "gnunet_dns_service.h"
30#include "gnunet_dnsparser_lib.h"
31 30
32/** 31/**
33 * Handle to transport service. 32 * Handle to transport service.
diff --git a/src/dns/gnunet-dns-redirector.c b/src/dns/gnunet-dns-redirector.c
index 835497dba..045207f8c 100644
--- a/src/dns/gnunet-dns-redirector.c
+++ b/src/dns/gnunet-dns-redirector.c
@@ -27,7 +27,6 @@
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
29#include "gnunet_dns_service.h" 29#include "gnunet_dns_service.h"
30#include "gnunet_dnsparser_lib.h"
31 30
32/** 31/**
33 * Handle to DNS service. 32 * Handle to DNS service.
diff --git a/src/dns/gnunet-helper-dns.c b/src/dns/gnunet-helper-dns.c
index f0e39464d..54443cd7a 100644
--- a/src/dns/gnunet-helper-dns.c
+++ b/src/dns/gnunet-helper-dns.c
@@ -72,7 +72,7 @@
72/** 72/**
73 * Need 'struct GNUNET_MessageHeader'. 73 * Need 'struct GNUNET_MessageHeader'.
74 */ 74 */
75#include "gnunet_crypto_lib.h" 75#include "gnunet_util_lib.h"
76#include "gnunet_common.h" 76#include "gnunet_common.h"
77 77
78/** 78/**
diff --git a/src/dns/gnunet-service-dns.c b/src/dns/gnunet-service-dns.c
index 4840c0c95..24566ae21 100644
--- a/src/dns/gnunet-service-dns.c
+++ b/src/dns/gnunet-service-dns.c
@@ -44,10 +44,7 @@
44#include "gnunet_signatures.h" 44#include "gnunet_signatures.h"
45#include "dns.h" 45#include "dns.h"
46#include "gnunet_dns_service.h" 46#include "gnunet_dns_service.h"
47#include "gnunet_dnsparser_lib.h"
48#include "gnunet_dnsstub_lib.h"
49#include "gnunet_statistics_service.h" 47#include "gnunet_statistics_service.h"
50#include "gnunet_tun_lib.h"
51 48
52/** 49/**
53 * Port number for DNS 50 * Port number for DNS
diff --git a/src/dns/gnunet-zonewalk.c b/src/dns/gnunet-zonewalk.c
index 91f8456df..0526df698 100644
--- a/src/dns/gnunet-zonewalk.c
+++ b/src/dns/gnunet-zonewalk.c
@@ -25,8 +25,6 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include <gnunet_util_lib.h> 27#include <gnunet_util_lib.h>
28#include <gnunet_dnsstub_lib.h>
29#include <gnunet_dnsparser_lib.h>
30 28
31/** 29/**
32 * Request we should make. 30 * Request we should make.
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index 425f7c816..eb2380439 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -40,12 +40,9 @@
40#include "gnunet_applications.h" 40#include "gnunet_applications.h"
41#include "gnunet_dht_service.h" 41#include "gnunet_dht_service.h"
42#include "gnunet_cadet_service.h" 42#include "gnunet_cadet_service.h"
43#include "gnunet_dnsparser_lib.h"
44#include "gnunet_dnsstub_lib.h"
45#include "gnunet_statistics_service.h" 43#include "gnunet_statistics_service.h"
46#include "gnunet_constants.h" 44#include "gnunet_constants.h"
47#include "gnunet_signatures.h" 45#include "gnunet_signatures.h"
48#include "gnunet_tun_lib.h"
49#include "gnunet_regex_service.h" 46#include "gnunet_regex_service.h"
50#include "exit.h" 47#include "exit.h"
51#include "block_dns.h" 48#include "block_dns.h"
diff --git a/src/exit/gnunet-helper-exit.c b/src/exit/gnunet-helper-exit.c
index 4f32ea1f1..d9578cfa0 100644
--- a/src/exit/gnunet-helper-exit.c
+++ b/src/exit/gnunet-helper-exit.c
@@ -55,7 +55,7 @@
55/** 55/**
56 * Need 'struct GNUNET_MessageHeader'. 56 * Need 'struct GNUNET_MessageHeader'.
57 */ 57 */
58#include "gnunet_crypto_lib.h" 58#include "gnunet_util_lib.h"
59#include "gnunet_common.h" 59#include "gnunet_common.h"
60 60
61/** 61/**
diff --git a/src/fragmentation/fragmentation.c b/src/fragmentation/fragmentation.c
index a2e097b8b..b35ccc100 100644
--- a/src/fragmentation/fragmentation.c
+++ b/src/fragmentation/fragmentation.c
@@ -23,7 +23,6 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include "gnunet_fragmentation_lib.h"
27#include "gnunet_protocols.h" 26#include "gnunet_protocols.h"
28#include "fragmentation.h" 27#include "fragmentation.h"
29 28
diff --git a/src/fragmentation/fragmentation.h b/src/fragmentation/fragmentation.h
index 2d7abd4f7..1207e4eeb 100644
--- a/src/fragmentation/fragmentation.h
+++ b/src/fragmentation/fragmentation.h
@@ -24,7 +24,9 @@
24 */ 24 */
25#ifndef FRAGMENTATION_H 25#ifndef FRAGMENTATION_H
26#define FRAGMENTATION_H 26#define FRAGMENTATION_H
27
27#include "platform.h" 28#include "platform.h"
29#include "gnunet_util_lib.h"
28#include "gnunet_fragmentation_lib.h" 30#include "gnunet_fragmentation_lib.h"
29 31
30GNUNET_NETWORK_STRUCT_BEGIN 32GNUNET_NETWORK_STRUCT_BEGIN
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am
index 3d8ec2bac..7773c58ee 100644
--- a/src/fs/Makefile.am
+++ b/src/fs/Makefile.am
@@ -40,7 +40,8 @@ libgnunetfs_la_SOURCES = \
40 fs_sharetree.c \ 40 fs_sharetree.c \
41 fs_tree.c fs_tree.h \ 41 fs_tree.c fs_tree.h \
42 fs_unindex.c \ 42 fs_unindex.c \
43 fs_uri.c 43 fs_uri.c \
44 meta_data.c
44 45
45libgnunetfs_la_LIBADD = \ 46libgnunetfs_la_LIBADD = \
46 $(top_builddir)/src/datastore/libgnunetdatastore.la \ 47 $(top_builddir)/src/datastore/libgnunetdatastore.la \
@@ -148,8 +149,9 @@ endif
148gnunet_helper_fs_publish_SOURCES = \ 149gnunet_helper_fs_publish_SOURCES = \
149 gnunet-helper-fs-publish.c 150 gnunet-helper-fs-publish.c
150gnunet_helper_fs_publish_LDADD = \ 151gnunet_helper_fs_publish_LDADD = \
151 $(top_builddir)/src/util/libgnunetutil.la \ 152 libgnunetfs.la \
152 $(GN_LIBINTL) 153 $(top_builddir)/src/util/libgnunetutil.la \
154 $(GN_LIBINTL)
153 155
154if HAVE_LIBEXTRACTOR 156if HAVE_LIBEXTRACTOR
155gnunet_helper_fs_publish_LDADD += \ 157gnunet_helper_fs_publish_LDADD += \
@@ -249,6 +251,7 @@ check_PROGRAMS = \
249 test_fs_unindex \ 251 test_fs_unindex \
250 test_fs_unindex_persistence \ 252 test_fs_unindex_persistence \
251 test_fs_uri \ 253 test_fs_uri \
254 test_fs_meta_data \
252 test_gnunet_service_fs_migration \ 255 test_gnunet_service_fs_migration \
253 test_gnunet_service_fs_p2p \ 256 test_gnunet_service_fs_p2p \
254 test_gnunet_service_fs_p2p_cadet \ 257 test_gnunet_service_fs_p2p_cadet \
@@ -273,7 +276,7 @@ endif
273 276
274 277
275if ENABLE_TEST_RUN 278if ENABLE_TEST_RUN
276AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; $(MONKEY) 279AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
277TESTS = \ 280TESTS = \
278 test_fs_directory \ 281 test_fs_directory \
279 test_fs_download \ 282 test_fs_download \
@@ -294,6 +297,7 @@ TESTS = \
294 test_fs_unindex_persistence \ 297 test_fs_unindex_persistence \
295 test_fs_uri \ 298 test_fs_uri \
296 test_fs_test_lib \ 299 test_fs_test_lib \
300 test_fs_meta_data \
297 test_gnunet_service_fs_migration \ 301 test_gnunet_service_fs_migration \
298 test_gnunet_service_fs_p2p \ 302 test_gnunet_service_fs_p2p \
299 test_gnunet_service_fs_p2p_cadet \ 303 test_gnunet_service_fs_p2p_cadet \
@@ -446,6 +450,13 @@ test_fs_unindex_persistence_LDADD = \
446 libgnunetfs.la \ 450 libgnunetfs.la \
447 $(top_builddir)/src/util/libgnunetutil.la 451 $(top_builddir)/src/util/libgnunetutil.la
448 452
453test_fs_meta_data_SOURCES = \
454 test_fs_meta_data.c
455test_fs_meta_data_LDADD = \
456 libgnunetfs.la \
457 $(top_builddir)/src/util/libgnunetutil.la
458
459
449test_fs_uri_SOURCES = \ 460test_fs_uri_SOURCES = \
450 test_fs_uri.c 461 test_fs_uri.c
451test_fs_uri_LDADD = \ 462test_fs_uri_LDADD = \
@@ -520,7 +531,6 @@ perf_gnunet_service_fs_p2p_respect_LDADD = \
520 libgnunetfs.la \ 531 libgnunetfs.la \
521 $(top_builddir)/src/util/libgnunetutil.la 532 $(top_builddir)/src/util/libgnunetutil.la
522 533
523
524test_gnunet_fs_psd.py: test_gnunet_fs_psd.py.in Makefile 534test_gnunet_fs_psd.py: test_gnunet_fs_psd.py.in Makefile
525 $(AWK) -v bdir="$(bindir)" -v py="$(PYTHON)" -v awkay="$(AWK_BINARY)" -v pfx="$(prefix)" -v prl="$(PERL)" -v sysconfdirectory="$(sysconfdir)" -v pkgdatadirectory="$(pkgdatadir)" -f $(top_srcdir)/bin/dosubst.awk < $(srcdir)/test_gnunet_fs_psd.py.in > test_gnunet_fs_psd.py 535 $(AWK) -v bdir="$(bindir)" -v py="$(PYTHON)" -v awkay="$(AWK_BINARY)" -v pfx="$(prefix)" -v prl="$(PERL)" -v sysconfdirectory="$(sysconfdir)" -v pkgdatadirectory="$(pkgdatadir)" -f $(top_srcdir)/bin/dosubst.awk < $(srcdir)/test_gnunet_fs_psd.py.in > test_gnunet_fs_psd.py
526 chmod +x test_gnunet_fs_psd.py 536 chmod +x test_gnunet_fs_psd.py
diff --git a/src/fs/fs.h b/src/fs/fs.h
index 4c433e774..c3bae65d2 100644
--- a/src/fs/fs.h
+++ b/src/fs/fs.h
@@ -29,6 +29,7 @@
29#include "gnunet_constants.h" 29#include "gnunet_constants.h"
30#include "gnunet_datastore_service.h" 30#include "gnunet_datastore_service.h"
31#include "gnunet_dht_service.h" 31#include "gnunet_dht_service.h"
32
32#include "gnunet_fs_service.h" 33#include "gnunet_fs_service.h"
33#include "gnunet_block_lib.h" 34#include "gnunet_block_lib.h"
34#include "block_fs.h" 35#include "block_fs.h"
diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c
index 6e97a3812..627c58004 100644
--- a/src/fs/fs_api.c
+++ b/src/fs/fs_api.c
@@ -26,6 +26,7 @@
26 26
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
29
29#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
30#include "fs_api.h" 31#include "fs_api.h"
31#include "fs_tree.h" 32#include "fs_tree.h"
@@ -902,7 +903,7 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h,
902 chks = NULL; 903 chks = NULL;
903 skss = NULL; 904 skss = NULL;
904 filename = NULL; 905 filename = NULL;
905 if ((GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "metadata", &ret->meta)) || 906 if ((GNUNET_OK != GNUNET_FS_read_meta_data (rh, "metadata", &ret->meta)) ||
906 (GNUNET_OK != GNUNET_BIO_read_string (rh, "ksk-uri", &ksks, 32 * 1024)) || 907 (GNUNET_OK != GNUNET_BIO_read_string (rh, "ksk-uri", &ksks, 32 * 1024)) ||
907 ((NULL != ksks) && 908 ((NULL != ksks) &&
908 ((NULL == (ret->keywords = GNUNET_FS_uri_parse (ksks, NULL))) || 909 ((NULL == (ret->keywords = GNUNET_FS_uri_parse (ksks, NULL))) ||
@@ -1370,7 +1371,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi)
1370 skss = NULL; 1371 skss = NULL;
1371 struct GNUNET_BIO_WriteSpec ws1[] = { 1372 struct GNUNET_BIO_WriteSpec ws1[] = {
1372 GNUNET_BIO_write_spec_object ("b", &b, sizeof (b)), 1373 GNUNET_BIO_write_spec_object ("b", &b, sizeof (b)),
1373 GNUNET_BIO_write_spec_meta_data ("meta", fi->meta), 1374 GNUNET_FS_write_spec_meta_data ("meta", fi->meta),
1374 GNUNET_BIO_write_spec_string ("ksks", ksks), 1375 GNUNET_BIO_write_spec_string ("ksks", ksks),
1375 GNUNET_BIO_write_spec_string ("chks", chks), 1376 GNUNET_BIO_write_spec_string ("chks", chks),
1376 GNUNET_BIO_write_spec_string ("skss", skss), 1377 GNUNET_BIO_write_spec_string ("skss", skss),
@@ -1571,7 +1572,7 @@ static int
1571fip_signal_resume (void *cls, 1572fip_signal_resume (void *cls,
1572 struct GNUNET_FS_FileInformation *fi, 1573 struct GNUNET_FS_FileInformation *fi,
1573 uint64_t length, 1574 uint64_t length,
1574 struct GNUNET_CONTAINER_MetaData *meta, 1575 struct GNUNET_FS_MetaData *meta,
1575 struct GNUNET_FS_Uri **uri, 1576 struct GNUNET_FS_Uri **uri,
1576 struct GNUNET_FS_BlockOptions *bo, 1577 struct GNUNET_FS_BlockOptions *bo,
1577 int *do_index, 1578 int *do_index,
@@ -2081,7 +2082,7 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc)
2081 uris = GNUNET_FS_uri_to_string (dc->uri); 2082 uris = GNUNET_FS_uri_to_string (dc->uri);
2082 struct GNUNET_BIO_WriteSpec ws1[] = { 2083 struct GNUNET_BIO_WriteSpec ws1[] = {
2083 GNUNET_BIO_write_spec_string ("uris", uris), 2084 GNUNET_BIO_write_spec_string ("uris", uris),
2084 GNUNET_BIO_write_spec_meta_data ("metadata", dc->meta), 2085 GNUNET_FS_write_spec_meta_data ("metadata", dc->meta),
2085 GNUNET_BIO_write_spec_string ("emsg", dc->emsg), 2086 GNUNET_BIO_write_spec_string ("emsg", dc->emsg),
2086 GNUNET_BIO_write_spec_string ("filename", dc->filename), 2087 GNUNET_BIO_write_spec_string ("filename", dc->filename),
2087 GNUNET_BIO_write_spec_string ("temp filename", dc->temp_filename), 2088 GNUNET_BIO_write_spec_string ("temp filename", dc->temp_filename),
@@ -2184,7 +2185,7 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr)
2184 (sr->update_search != NULL) 2185 (sr->update_search != NULL)
2185 ? sr->update_search->serialization 2186 ? sr->update_search->serialization
2186 : NULL), 2187 : NULL),
2187 GNUNET_BIO_write_spec_meta_data ("metadata", sr->meta), 2188 GNUNET_FS_write_spec_meta_data ("metadata", sr->meta),
2188 GNUNET_BIO_write_spec_object ("key", &sr->key, 2189 GNUNET_BIO_write_spec_object ("key", &sr->key,
2189 sizeof(struct GNUNET_HashCode)), 2190 sizeof(struct GNUNET_HashCode)),
2190 GNUNET_BIO_write_spec_int32 ("mandatory missing", 2191 GNUNET_BIO_write_spec_int32 ("mandatory missing",
@@ -2558,7 +2559,7 @@ deserialize_search_result (void *cls, const char *filename)
2558 GNUNET_BIO_read_string (rh, "download-lnk", &download, 16)) || 2559 GNUNET_BIO_read_string (rh, "download-lnk", &download, 16)) ||
2559 (GNUNET_OK != 2560 (GNUNET_OK !=
2560 GNUNET_BIO_read_string (rh, "search-lnk", &update_srch, 16)) || 2561 GNUNET_BIO_read_string (rh, "search-lnk", &update_srch, 16)) ||
2561 (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "result-meta", &sr->meta)) || 2562 (GNUNET_OK != GNUNET_FS_read_meta_data (rh, "result-meta", &sr->meta)) ||
2562 (GNUNET_OK != GNUNET_BIO_read (rh, 2563 (GNUNET_OK != GNUNET_BIO_read (rh,
2563 "result-key", 2564 "result-key",
2564 &sr->key, 2565 &sr->key,
@@ -2655,7 +2656,7 @@ cleanup:
2655 if (NULL != sr->uri) 2656 if (NULL != sr->uri)
2656 GNUNET_FS_uri_destroy (sr->uri); 2657 GNUNET_FS_uri_destroy (sr->uri);
2657 if (NULL != sr->meta) 2658 if (NULL != sr->meta)
2658 GNUNET_CONTAINER_meta_data_destroy (sr->meta); 2659 GNUNET_FS_meta_data_destroy (sr->meta);
2659 GNUNET_free (sr->serialization); 2660 GNUNET_free (sr->serialization);
2660 GNUNET_free (sr); 2661 GNUNET_free (sr);
2661 if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)) 2662 if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
@@ -2778,7 +2779,7 @@ free_result (void *cls, const struct GNUNET_HashCode *key, void *value)
2778 free_search_context (sr->update_search); 2779 free_search_context (sr->update_search);
2779 GNUNET_assert (NULL == sr->update_search); 2780 GNUNET_assert (NULL == sr->update_search);
2780 } 2781 }
2781 GNUNET_CONTAINER_meta_data_destroy (sr->meta); 2782 GNUNET_FS_meta_data_destroy (sr->meta);
2782 GNUNET_FS_uri_destroy (sr->uri); 2783 GNUNET_FS_uri_destroy (sr->uri);
2783 GNUNET_free (sr); 2784 GNUNET_free (sr);
2784 return GNUNET_YES; 2785 return GNUNET_YES;
@@ -2876,7 +2877,7 @@ free_download_context (struct GNUNET_FS_DownloadContext *dc)
2876 struct GNUNET_FS_DownloadContext *dcc; 2877 struct GNUNET_FS_DownloadContext *dcc;
2877 2878
2878 if (NULL != dc->meta) 2879 if (NULL != dc->meta)
2879 GNUNET_CONTAINER_meta_data_destroy (dc->meta); 2880 GNUNET_FS_meta_data_destroy (dc->meta);
2880 if (NULL != dc->uri) 2881 if (NULL != dc->uri)
2881 GNUNET_FS_uri_destroy (dc->uri); 2882 GNUNET_FS_uri_destroy (dc->uri);
2882 GNUNET_free (dc->temp_filename); 2883 GNUNET_free (dc->temp_filename);
@@ -2925,7 +2926,7 @@ deserialize_download (struct GNUNET_FS_Handle *h,
2925 dc->h = h; 2926 dc->h = h;
2926 dc->serialization = GNUNET_strdup (serialization); 2927 dc->serialization = GNUNET_strdup (serialization);
2927 struct GNUNET_BIO_ReadSpec rs[] = { 2928 struct GNUNET_BIO_ReadSpec rs[] = {
2928 GNUNET_BIO_read_spec_meta_data ("download-meta", &dc->meta), 2929 GNUNET_FS_read_spec_meta_data ("download-meta", &dc->meta),
2929 GNUNET_BIO_read_spec_string ("download-emsg", &dc->emsg, 10 * 1024), 2930 GNUNET_BIO_read_spec_string ("download-emsg", &dc->emsg, 10 * 1024),
2930 GNUNET_BIO_read_spec_string ("download-fn", &dc->filename, 10 * 1024), 2931 GNUNET_BIO_read_spec_string ("download-fn", &dc->filename, 10 * 1024),
2931 GNUNET_BIO_read_spec_string ("download-tfn", 2932 GNUNET_BIO_read_spec_string ("download-tfn",
diff --git a/src/fs/fs_api.h b/src/fs/fs_api.h
index 7c0c58bff..fdda91928 100644
--- a/src/fs/fs_api.h
+++ b/src/fs/fs_api.h
@@ -29,6 +29,7 @@
29#include "gnunet_constants.h" 29#include "gnunet_constants.h"
30#include "gnunet_datastore_service.h" 30#include "gnunet_datastore_service.h"
31#include "gnunet_dht_service.h" 31#include "gnunet_dht_service.h"
32
32#include "gnunet_fs_service.h" 33#include "gnunet_fs_service.h"
33#include "gnunet_block_lib.h" 34#include "gnunet_block_lib.h"
34#include "block_fs.h" 35#include "block_fs.h"
@@ -249,7 +250,7 @@ struct GNUNET_FS_FileInformation
249 /** 250 /**
250 * Metadata to use for the file. 251 * Metadata to use for the file.
251 */ 252 */
252 struct GNUNET_CONTAINER_MetaData *meta; 253 struct GNUNET_FS_MetaData *meta;
253 254
254 /** 255 /**
255 * Keywords to use for KBlocks. 256 * Keywords to use for KBlocks.
@@ -525,7 +526,7 @@ struct GNUNET_FS_SearchResult
525 /** 526 /**
526 * Metadata for the search result. 527 * Metadata for the search result.
527 */ 528 */
528 struct GNUNET_CONTAINER_MetaData *meta; 529 struct GNUNET_FS_MetaData *meta;
529 530
530 /** 531 /**
531 * Client info for this search result. 532 * Client info for this search result.
@@ -1801,7 +1802,7 @@ struct GNUNET_FS_DownloadContext
1801 /** 1802 /**
1802 * Known meta-data for the file (can be NULL). 1803 * Known meta-data for the file (can be NULL).
1803 */ 1804 */
1804 struct GNUNET_CONTAINER_MetaData *meta; 1805 struct GNUNET_FS_MetaData *meta;
1805 1806
1806 /** 1807 /**
1807 * Error message, NULL if we're doing OK. 1808 * Error message, NULL if we're doing OK.
diff --git a/src/fs/fs_directory.c b/src/fs/fs_directory.c
index eb7aac5bb..c693f9216 100644
--- a/src/fs/fs_directory.c
+++ b/src/fs/fs_directory.c
@@ -33,6 +33,7 @@
33 * into memory 33 * into memory
34 */ 34 */
35#include "platform.h" 35#include "platform.h"
36
36#include "gnunet_fs_service.h" 37#include "gnunet_fs_service.h"
37#include "fs_api.h" 38#include "fs_api.h"
38 39
@@ -52,15 +53,15 @@
52 */ 53 */
53int 54int
54GNUNET_FS_meta_data_test_for_directory (const struct 55GNUNET_FS_meta_data_test_for_directory (const struct
55 GNUNET_CONTAINER_MetaData *md) 56 GNUNET_FS_MetaData *md)
56{ 57{
57 char *mime; 58 char *mime;
58 int ret; 59 int ret;
59 60
60 if (NULL == md) 61 if (NULL == md)
61 return GNUNET_SYSERR; 62 return GNUNET_SYSERR;
62 mime = GNUNET_CONTAINER_meta_data_get_by_type (md, 63 mime = GNUNET_FS_meta_data_get_by_type (md,
63 EXTRACTOR_METATYPE_MIMETYPE); 64 EXTRACTOR_METATYPE_MIMETYPE);
64 if (NULL == mime) 65 if (NULL == mime)
65 return GNUNET_SYSERR; 66 return GNUNET_SYSERR;
66 ret = (0 == strcasecmp (mime, GNUNET_FS_DIRECTORY_MIME)) ? GNUNET_YES : 67 ret = (0 == strcasecmp (mime, GNUNET_FS_DIRECTORY_MIME)) ? GNUNET_YES :
@@ -77,19 +78,19 @@ GNUNET_FS_meta_data_test_for_directory (const struct
77 * @param md metadata to add mimetype to 78 * @param md metadata to add mimetype to
78 */ 79 */
79void 80void
80GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md) 81GNUNET_FS_meta_data_make_directory (struct GNUNET_FS_MetaData *md)
81{ 82{
82 char *mime; 83 char *mime;
83 84
84 mime = 85 mime =
85 GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE); 86 GNUNET_FS_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE);
86 if (mime != NULL) 87 if (mime != NULL)
87 { 88 {
88 GNUNET_break (0 == strcmp (mime, GNUNET_FS_DIRECTORY_MIME)); 89 GNUNET_break (0 == strcmp (mime, GNUNET_FS_DIRECTORY_MIME));
89 GNUNET_free (mime); 90 GNUNET_free (mime);
90 return; 91 return;
91 } 92 }
92 GNUNET_CONTAINER_meta_data_insert (md, "<gnunet>", 93 GNUNET_FS_meta_data_insert (md, "<gnunet>",
93 EXTRACTOR_METATYPE_MIMETYPE, 94 EXTRACTOR_METATYPE_MIMETYPE,
94 EXTRACTOR_METAFORMAT_UTF8, "text/plain", 95 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
95 GNUNET_FS_DIRECTORY_MIME, 96 GNUNET_FS_DIRECTORY_MIME,
@@ -192,7 +193,7 @@ GNUNET_FS_directory_list_contents (size_t size,
192 uint32_t mdSize; 193 uint32_t mdSize;
193 uint64_t epos; 194 uint64_t epos;
194 struct GNUNET_FS_Uri *uri; 195 struct GNUNET_FS_Uri *uri;
195 struct GNUNET_CONTAINER_MetaData *md; 196 struct GNUNET_FS_MetaData *md;
196 char *filename; 197 char *filename;
197 198
198 if ((offset == 0) && 199 if ((offset == 0) &&
@@ -215,8 +216,8 @@ GNUNET_FS_directory_list_contents (size_t size,
215 _ ("MAGIC mismatch. This is not a GNUnet directory.\n")); 216 _ ("MAGIC mismatch. This is not a GNUnet directory.\n"));
216 return GNUNET_SYSERR; 217 return GNUNET_SYSERR;
217 } 218 }
218 md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[8 + sizeof(uint32_t)], 219 md = GNUNET_FS_meta_data_deserialize (&cdata[8 + sizeof(uint32_t)],
219 mdSize); 220 mdSize);
220 if (md == NULL) 221 if (md == NULL)
221 { 222 {
222 GNUNET_break (0); 223 GNUNET_break (0);
@@ -228,7 +229,7 @@ GNUNET_FS_directory_list_contents (size_t size,
228 md, 229 md,
229 0, 230 0,
230 NULL); 231 NULL);
231 GNUNET_CONTAINER_meta_data_destroy (md); 232 GNUNET_FS_meta_data_destroy (md);
232 pos = 8 + sizeof(uint32_t) + mdSize; 233 pos = 8 + sizeof(uint32_t) + mdSize;
233 } 234 }
234 while (pos < size) 235 while (pos < size)
@@ -283,7 +284,7 @@ GNUNET_FS_directory_list_contents (size_t size,
283 return GNUNET_NO; /* malformed - or partial download */ 284 return GNUNET_NO; /* malformed - or partial download */
284 } 285 }
285 286
286 md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[pos], 287 md = GNUNET_FS_meta_data_deserialize (&cdata[pos],
287 mdSize); 288 mdSize);
288 if (NULL == md) 289 if (NULL == md)
289 { 290 {
@@ -293,11 +294,11 @@ GNUNET_FS_directory_list_contents (size_t size,
293 } 294 }
294 pos += mdSize; 295 pos += mdSize;
295 filename = 296 filename =
296 GNUNET_CONTAINER_meta_data_get_by_type (md, 297 GNUNET_FS_meta_data_get_by_type (md,
297 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 298 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
298 full_data.size = 0; 299 full_data.size = 0;
299 full_data.data = NULL; 300 full_data.data = NULL;
300 GNUNET_CONTAINER_meta_data_iterate (md, 301 GNUNET_FS_meta_data_iterate (md,
301 &find_full_data, 302 &find_full_data,
302 &full_data); 303 &full_data);
303 if (NULL != dep) 304 if (NULL != dep)
@@ -311,7 +312,7 @@ GNUNET_FS_directory_list_contents (size_t size,
311 } 312 }
312 GNUNET_free (full_data.data); 313 GNUNET_free (full_data.data);
313 GNUNET_free (filename); 314 GNUNET_free (filename);
314 GNUNET_CONTAINER_meta_data_destroy (md); 315 GNUNET_FS_meta_data_destroy (md);
315 GNUNET_FS_uri_destroy (uri); 316 GNUNET_FS_uri_destroy (uri);
316 } 317 }
317 return GNUNET_OK; 318 return GNUNET_OK;
@@ -342,7 +343,7 @@ struct GNUNET_FS_DirectoryBuilder
342 /** 343 /**
343 * Meta-data for the directory itself. 344 * Meta-data for the directory itself.
344 */ 345 */
345 struct GNUNET_CONTAINER_MetaData *meta; 346 struct GNUNET_FS_MetaData *meta;
346 347
347 /** 348 /**
348 * Head of linked list of entries. 349 * Head of linked list of entries.
@@ -362,16 +363,16 @@ struct GNUNET_FS_DirectoryBuilder
362 * @param mdir metadata for the directory 363 * @param mdir metadata for the directory
363 */ 364 */
364struct GNUNET_FS_DirectoryBuilder * 365struct GNUNET_FS_DirectoryBuilder *
365GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData 366GNUNET_FS_directory_builder_create (const struct GNUNET_FS_MetaData
366 *mdir) 367 *mdir)
367{ 368{
368 struct GNUNET_FS_DirectoryBuilder *ret; 369 struct GNUNET_FS_DirectoryBuilder *ret;
369 370
370 ret = GNUNET_new (struct GNUNET_FS_DirectoryBuilder); 371 ret = GNUNET_new (struct GNUNET_FS_DirectoryBuilder);
371 if (mdir != NULL) 372 if (mdir != NULL)
372 ret->meta = GNUNET_CONTAINER_meta_data_duplicate (mdir); 373 ret->meta = GNUNET_FS_meta_data_duplicate (mdir);
373 else 374 else
374 ret->meta = GNUNET_CONTAINER_meta_data_create (); 375 ret->meta = GNUNET_FS_meta_data_create ();
375 GNUNET_FS_meta_data_make_directory (ret->meta); 376 GNUNET_FS_meta_data_make_directory (ret->meta);
376 return ret; 377 return ret;
377} 378}
@@ -390,7 +391,7 @@ GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData
390void 391void
391GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld, 392GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
392 const struct GNUNET_FS_Uri *uri, 393 const struct GNUNET_FS_Uri *uri,
393 const struct GNUNET_CONTAINER_MetaData *md, 394 const struct GNUNET_FS_MetaData *md,
394 const void *data) 395 const void *data)
395{ 396{
396 struct GNUNET_FS_Uri *curi; 397 struct GNUNET_FS_Uri *curi;
@@ -404,8 +405,8 @@ GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
404 char *serialized; 405 char *serialized;
405 char *sptr; 406 char *sptr;
406 size_t slen; 407 size_t slen;
407 struct GNUNET_CONTAINER_MetaData *meta; 408 struct GNUNET_FS_MetaData *meta;
408 const struct GNUNET_CONTAINER_MetaData *meta_use; 409 const struct GNUNET_FS_MetaData *meta_use;
409 410
410 GNUNET_assert (! GNUNET_FS_uri_test_ksk (uri)); 411 GNUNET_assert (! GNUNET_FS_uri_test_ksk (uri));
411 if (NULL != data) 412 if (NULL != data)
@@ -431,17 +432,17 @@ GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
431 fsize = 0; /* too large */ 432 fsize = 0; /* too large */
432 uris = GNUNET_FS_uri_to_string (uri); 433 uris = GNUNET_FS_uri_to_string (uri);
433 slen = strlen (uris) + 1; 434 slen = strlen (uris) + 1;
434 mds = GNUNET_CONTAINER_meta_data_get_serialized_size (md); 435 mds = GNUNET_FS_meta_data_get_serialized_size (md);
435 meta_use = md; 436 meta_use = md;
436 meta = NULL; 437 meta = NULL;
437 if (fsize > 0) 438 if (fsize > 0)
438 { 439 {
439 meta = GNUNET_CONTAINER_meta_data_duplicate (md); 440 meta = GNUNET_FS_meta_data_duplicate (md);
440 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>", 441 GNUNET_FS_meta_data_insert (meta, "<gnunet>",
441 EXTRACTOR_METATYPE_GNUNET_FULL_DATA, 442 EXTRACTOR_METATYPE_GNUNET_FULL_DATA,
442 EXTRACTOR_METAFORMAT_BINARY, NULL, data, 443 EXTRACTOR_METAFORMAT_BINARY, NULL, data,
443 fsize); 444 fsize);
444 mdxs = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); 445 mdxs = GNUNET_FS_meta_data_get_serialized_size (meta);
445 if ((slen + sizeof(uint32_t) + mdxs - 1) / DBLOCK_SIZE == 446 if ((slen + sizeof(uint32_t) + mdxs - 1) / DBLOCK_SIZE ==
446 (slen + sizeof(uint32_t) + mds - 1) / DBLOCK_SIZE) 447 (slen + sizeof(uint32_t) + mds - 1) / DBLOCK_SIZE)
447 { 448 {
@@ -461,10 +462,10 @@ GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
461 GNUNET_free (uris); 462 GNUNET_free (uris);
462 sptr = &serialized[slen + sizeof(uint32_t)]; 463 sptr = &serialized[slen + sizeof(uint32_t)];
463 ret = 464 ret =
464 GNUNET_CONTAINER_meta_data_serialize (meta_use, &sptr, mds, 465 GNUNET_FS_meta_data_serialize (meta_use, &sptr, mds,
465 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); 466 GNUNET_FS_META_DATA_SERIALIZE_PART);
466 if (NULL != meta) 467 if (NULL != meta)
467 GNUNET_CONTAINER_meta_data_destroy (meta); 468 GNUNET_FS_meta_data_destroy (meta);
468 if (ret == -1) 469 if (ret == -1)
469 mds = 0; 470 mds = 0;
470 else 471 else
@@ -593,7 +594,7 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
593 uint32_t big; 594 uint32_t big;
594 595
595 size = strlen (GNUNET_DIRECTORY_MAGIC) + sizeof(uint32_t); 596 size = strlen (GNUNET_DIRECTORY_MAGIC) + sizeof(uint32_t);
596 size += GNUNET_CONTAINER_meta_data_get_serialized_size (bld->meta); 597 size += GNUNET_FS_meta_data_get_serialized_size (bld->meta);
597 sizes = NULL; 598 sizes = NULL;
598 perm = NULL; 599 perm = NULL;
599 bes = NULL; 600 bes = NULL;
@@ -643,10 +644,10 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
643 644
644 sptr = &data[off + sizeof(uint32_t)]; 645 sptr = &data[off + sizeof(uint32_t)];
645 ret = 646 ret =
646 GNUNET_CONTAINER_meta_data_serialize (bld->meta, 647 GNUNET_FS_meta_data_serialize (bld->meta,
647 &sptr, 648 &sptr,
648 size - off - sizeof(uint32_t), 649 size - off - sizeof(uint32_t),
649 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); 650 GNUNET_FS_META_DATA_SERIALIZE_FULL);
650 GNUNET_assert (ret != -1); 651 GNUNET_assert (ret != -1);
651 big = htonl (ret); 652 big = htonl (ret);
652 GNUNET_memcpy (&data[off], 653 GNUNET_memcpy (&data[off],
@@ -666,7 +667,7 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
666 GNUNET_free (perm); 667 GNUNET_free (perm);
667 GNUNET_free (bes); 668 GNUNET_free (bes);
668 GNUNET_assert (off == size); 669 GNUNET_assert (off == size);
669 GNUNET_CONTAINER_meta_data_destroy (bld->meta); 670 GNUNET_FS_meta_data_destroy (bld->meta);
670 GNUNET_free (bld); 671 GNUNET_free (bld);
671 return GNUNET_OK; 672 return GNUNET_OK;
672} 673}
diff --git a/src/fs/fs_dirmetascan.c b/src/fs/fs_dirmetascan.c
index 8dd216324..2379e29ce 100644
--- a/src/fs/fs_dirmetascan.c
+++ b/src/fs/fs_dirmetascan.c
@@ -26,6 +26,7 @@
26 * @author Christian Grothoff 26 * @author Christian Grothoff
27 */ 27 */
28#include "platform.h" 28#include "platform.h"
29
29#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
30#include "gnunet_scheduler_lib.h" 31#include "gnunet_scheduler_lib.h"
31#include <pthread.h> 32#include <pthread.h>
@@ -359,26 +360,26 @@ process_helper_msgs (void *cls, const struct GNUNET_MessageHeader *msg)
359 GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED); 360 GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED);
360 if (0 < left) 361 if (0 < left)
361 { 362 {
362 ds->pos->meta = GNUNET_CONTAINER_meta_data_deserialize (end, left); 363 ds->pos->meta = GNUNET_FS_meta_data_deserialize (end, left);
363 if (NULL == ds->pos->meta) 364 if (NULL == ds->pos->meta)
364 { 365 {
365 GNUNET_break (0); 366 GNUNET_break (0);
366 break; 367 break;
367 } 368 }
368 /* having full filenames is too dangerous; always make sure we clean them up */ 369 /* having full filenames is too dangerous; always make sure we clean them up */
369 GNUNET_CONTAINER_meta_data_delete (ds->pos->meta, 370 GNUNET_FS_meta_data_delete (ds->pos->meta,
370 EXTRACTOR_METATYPE_FILENAME, 371 EXTRACTOR_METATYPE_FILENAME,
371 NULL, 372 NULL,
372 0); 373 0);
373 /* instead, put in our 'safer' original filename */ 374 /* instead, put in our 'safer' original filename */
374 GNUNET_CONTAINER_meta_data_insert (ds->pos->meta, 375 GNUNET_FS_meta_data_insert (ds->pos->meta,
375 "<libgnunetfs>", 376 "<libgnunetfs>",
376 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, 377 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
377 EXTRACTOR_METAFORMAT_UTF8, 378 EXTRACTOR_METAFORMAT_UTF8,
378 "text/plain", 379 "text/plain",
379 ds->pos->short_filename, 380 ds->pos->short_filename,
380 strlen (ds->pos->short_filename) 381 strlen (ds->pos->short_filename)
381 + 1); 382 + 1);
382 } 383 }
383 ds->pos->ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data ( 384 ds->pos->ksk_uri = GNUNET_FS_uri_ksk_create_from_meta_data (
384 ds->pos->meta); 385 ds->pos->meta);
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index 102b297c1..2a21e4810 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -24,6 +24,7 @@
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include "gnunet_constants.h" 26#include "gnunet_constants.h"
27
27#include "gnunet_fs_service.h" 28#include "gnunet_fs_service.h"
28#include "fs_api.h" 29#include "fs_api.h"
29#include "fs_tree.h" 30#include "fs_tree.h"
@@ -280,7 +281,7 @@ static void
280trigger_recursive_download (void *cls, 281trigger_recursive_download (void *cls,
281 const char *filename, 282 const char *filename,
282 const struct GNUNET_FS_Uri *uri, 283 const struct GNUNET_FS_Uri *uri,
283 const struct GNUNET_CONTAINER_MetaData *meta, 284 const struct GNUNET_FS_MetaData *meta,
284 size_t length, 285 size_t length,
285 const void *data); 286 const void *data);
286 287
@@ -850,7 +851,7 @@ static void
850trigger_recursive_download (void *cls, 851trigger_recursive_download (void *cls,
851 const char *filename, 852 const char *filename,
852 const struct GNUNET_FS_Uri *uri, 853 const struct GNUNET_FS_Uri *uri,
853 const struct GNUNET_CONTAINER_MetaData *meta, 854 const struct GNUNET_FS_MetaData *meta,
854 size_t length, 855 size_t length,
855 const void *data) 856 const void *data)
856{ 857{
@@ -968,7 +969,7 @@ trigger_recursive_download (void *cls,
968 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 969 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
969 "Triggering recursive download of size %llu with %u bytes MD\n", 970 "Triggering recursive download of size %llu with %u bytes MD\n",
970 (unsigned long long) GNUNET_FS_uri_chk_get_file_size (uri), 971 (unsigned long long) GNUNET_FS_uri_chk_get_file_size (uri),
971 (unsigned int) GNUNET_CONTAINER_meta_data_get_serialized_size ( 972 (unsigned int) GNUNET_FS_meta_data_get_serialized_size (
972 meta)); 973 meta));
973 GNUNET_FS_download_start (dc->h, 974 GNUNET_FS_download_start (dc->h,
974 uri, 975 uri,
@@ -1907,8 +1908,8 @@ GNUNET_FS_download_start_task_ (void *cls)
1907 GNUNET_ERROR_TYPE_DEBUG, 1908 GNUNET_ERROR_TYPE_DEBUG,
1908 "Trying to find embedded meta data for download of size %llu with %u bytes MD\n", 1909 "Trying to find embedded meta data for download of size %llu with %u bytes MD\n",
1909 (unsigned long long) GNUNET_FS_uri_chk_get_file_size (dc->uri), 1910 (unsigned long long) GNUNET_FS_uri_chk_get_file_size (dc->uri),
1910 (unsigned int) GNUNET_CONTAINER_meta_data_get_serialized_size (dc->meta)); 1911 (unsigned int) GNUNET_FS_meta_data_get_serialized_size (dc->meta));
1911 GNUNET_CONTAINER_meta_data_iterate (dc->meta, &match_full_data, dc); 1912 GNUNET_FS_meta_data_iterate (dc->meta, &match_full_data, dc);
1912 if (BRS_DOWNLOAD_UP == dc->top_request->state) 1913 if (BRS_DOWNLOAD_UP == dc->top_request->state)
1913 { 1914 {
1914 if (NULL != dc->rfh) 1915 if (NULL != dc->rfh)
@@ -1996,7 +1997,7 @@ GNUNET_FS_download_signal_suspend_ (void *cls)
1996 dc->active = NULL; 1997 dc->active = NULL;
1997 } 1998 }
1998 GNUNET_free (dc->filename); 1999 GNUNET_free (dc->filename);
1999 GNUNET_CONTAINER_meta_data_destroy (dc->meta); 2000 GNUNET_FS_meta_data_destroy (dc->meta);
2000 GNUNET_FS_uri_destroy (dc->uri); 2001 GNUNET_FS_uri_destroy (dc->uri);
2001 GNUNET_free (dc->temp_filename); 2002 GNUNET_free (dc->temp_filename);
2002 GNUNET_free (dc->serialization); 2003 GNUNET_free (dc->serialization);
@@ -2027,7 +2028,7 @@ GNUNET_FS_download_signal_suspend_ (void *cls)
2027struct GNUNET_FS_DownloadContext * 2028struct GNUNET_FS_DownloadContext *
2028create_download_context (struct GNUNET_FS_Handle *h, 2029create_download_context (struct GNUNET_FS_Handle *h,
2029 const struct GNUNET_FS_Uri *uri, 2030 const struct GNUNET_FS_Uri *uri,
2030 const struct GNUNET_CONTAINER_MetaData *meta, 2031 const struct GNUNET_FS_MetaData *meta,
2031 const char *filename, 2032 const char *filename,
2032 const char *tempname, 2033 const char *tempname,
2033 uint64_t offset, 2034 uint64_t offset,
@@ -2053,7 +2054,7 @@ create_download_context (struct GNUNET_FS_Handle *h,
2053 (unsigned long long) offset); 2054 (unsigned long long) offset);
2054 dc->h = h; 2055 dc->h = h;
2055 dc->uri = GNUNET_FS_uri_dup (uri); 2056 dc->uri = GNUNET_FS_uri_dup (uri);
2056 dc->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 2057 dc->meta = GNUNET_FS_meta_data_duplicate (meta);
2057 dc->client_info = cctx; 2058 dc->client_info = cctx;
2058 dc->start_time = GNUNET_TIME_absolute_get (); 2059 dc->start_time = GNUNET_TIME_absolute_get ();
2059 if (NULL != filename) 2060 if (NULL != filename)
@@ -2098,7 +2099,7 @@ create_download_context (struct GNUNET_FS_Handle *h,
2098struct GNUNET_FS_DownloadContext * 2099struct GNUNET_FS_DownloadContext *
2099GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, 2100GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
2100 const struct GNUNET_FS_Uri *uri, 2101 const struct GNUNET_FS_Uri *uri,
2101 const struct GNUNET_CONTAINER_MetaData *meta, 2102 const struct GNUNET_FS_MetaData *meta,
2102 const char *filename, 2103 const char *filename,
2103 const char *tempname, 2104 const char *tempname,
2104 uint64_t offset, 2105 uint64_t offset,
@@ -2319,7 +2320,7 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, int do_delete)
2319 } 2320 }
2320 GNUNET_free (dc->filename); 2321 GNUNET_free (dc->filename);
2321 } 2322 }
2322 GNUNET_CONTAINER_meta_data_destroy (dc->meta); 2323 GNUNET_FS_meta_data_destroy (dc->meta);
2323 GNUNET_FS_uri_destroy (dc->uri); 2324 GNUNET_FS_uri_destroy (dc->uri);
2324 if (NULL != dc->temp_filename) 2325 if (NULL != dc->temp_filename)
2325 { 2326 {
diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c
index dc5db9d3f..f23b9da2a 100644
--- a/src/fs/fs_file_information.c
+++ b/src/fs/fs_file_information.c
@@ -57,7 +57,8 @@ GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s)
57 * @return "filename" field of the structure (can be NULL) 57 * @return "filename" field of the structure (can be NULL)
58 */ 58 */
59const char * 59const char *
60GNUNET_FS_file_information_get_filename (const struct GNUNET_FS_FileInformation *s) 60GNUNET_FS_file_information_get_filename (const struct
61 GNUNET_FS_FileInformation *s)
61{ 62{
62 return s->filename; 63 return s->filename;
63} 64}
@@ -89,7 +90,7 @@ GNUNET_FS_file_information_create_from_file (
89 void *client_info, 90 void *client_info,
90 const char *filename, 91 const char *filename,
91 const struct GNUNET_FS_Uri *keywords, 92 const struct GNUNET_FS_Uri *keywords,
92 const struct GNUNET_CONTAINER_MetaData *meta, 93 const struct GNUNET_FS_MetaData *meta,
93 int do_index, 94 int do_index,
94 const struct GNUNET_FS_BlockOptions *bo) 95 const struct GNUNET_FS_BlockOptions *bo)
95{ 96{
@@ -132,13 +133,13 @@ GNUNET_FS_file_information_create_from_file (
132/* FIXME: If we assume that on other platforms CRT is UTF-8-aware, then 133/* FIXME: If we assume that on other platforms CRT is UTF-8-aware, then
133 * this should be changed to EXTRACTOR_METAFORMAT_UTF8 134 * this should be changed to EXTRACTOR_METAFORMAT_UTF8
134 */ 135 */
135 GNUNET_CONTAINER_meta_data_insert (ret->meta, 136 GNUNET_FS_meta_data_insert (ret->meta,
136 "<gnunet>", 137 "<gnunet>",
137 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, 138 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
138 EXTRACTOR_METAFORMAT_C_STRING, 139 EXTRACTOR_METAFORMAT_C_STRING,
139 "text/plain", 140 "text/plain",
140 fn, 141 fn,
141 strlen (fn) + 1); 142 strlen (fn) + 1);
142 return ret; 143 return ret;
143} 144}
144 145
@@ -150,7 +151,7 @@ GNUNET_FS_file_information_create_from_data (
150 uint64_t length, 151 uint64_t length,
151 void *data, 152 void *data,
152 const struct GNUNET_FS_Uri *keywords, 153 const struct GNUNET_FS_Uri *keywords,
153 const struct GNUNET_CONTAINER_MetaData *meta, 154 const struct GNUNET_FS_MetaData *meta,
154 int do_index, 155 int do_index,
155 const struct GNUNET_FS_BlockOptions *bo) 156 const struct GNUNET_FS_BlockOptions *bo)
156{ 157{
@@ -180,7 +181,7 @@ GNUNET_FS_file_information_create_from_reader (
180 GNUNET_FS_DataReader reader, 181 GNUNET_FS_DataReader reader,
181 void *reader_cls, 182 void *reader_cls,
182 const struct GNUNET_FS_Uri *keywords, 183 const struct GNUNET_FS_Uri *keywords,
183 const struct GNUNET_CONTAINER_MetaData *meta, 184 const struct GNUNET_FS_MetaData *meta,
184 int do_index, 185 int do_index,
185 const struct GNUNET_FS_BlockOptions *bo) 186 const struct GNUNET_FS_BlockOptions *bo)
186{ 187{
@@ -194,9 +195,9 @@ GNUNET_FS_file_information_create_from_reader (
194 ret = GNUNET_new (struct GNUNET_FS_FileInformation); 195 ret = GNUNET_new (struct GNUNET_FS_FileInformation);
195 ret->h = h; 196 ret->h = h;
196 ret->client_info = client_info; 197 ret->client_info = client_info;
197 ret->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 198 ret->meta = GNUNET_FS_meta_data_duplicate (meta);
198 if (ret->meta == NULL) 199 if (ret->meta == NULL)
199 ret->meta = GNUNET_CONTAINER_meta_data_create (); 200 ret->meta = GNUNET_FS_meta_data_create ();
200 ret->keywords = (keywords == NULL) ? NULL : GNUNET_FS_uri_dup (keywords); 201 ret->keywords = (keywords == NULL) ? NULL : GNUNET_FS_uri_dup (keywords);
201 ret->data.file.reader = reader; 202 ret->data.file.reader = reader;
202 ret->data.file.reader_cls = reader_cls; 203 ret->data.file.reader_cls = reader_cls;
@@ -226,7 +227,7 @@ GNUNET_FS_file_information_create_empty_directory (
226 struct GNUNET_FS_Handle *h, 227 struct GNUNET_FS_Handle *h,
227 void *client_info, 228 void *client_info,
228 const struct GNUNET_FS_Uri *keywords, 229 const struct GNUNET_FS_Uri *keywords,
229 const struct GNUNET_CONTAINER_MetaData *meta, 230 const struct GNUNET_FS_MetaData *meta,
230 const struct GNUNET_FS_BlockOptions *bo, 231 const struct GNUNET_FS_BlockOptions *bo,
231 const char *filename) 232 const char *filename)
232{ 233{
@@ -235,7 +236,7 @@ GNUNET_FS_file_information_create_empty_directory (
235 ret = GNUNET_new (struct GNUNET_FS_FileInformation); 236 ret = GNUNET_new (struct GNUNET_FS_FileInformation);
236 ret->h = h; 237 ret->h = h;
237 ret->client_info = client_info; 238 ret->client_info = client_info;
238 ret->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 239 ret->meta = GNUNET_FS_meta_data_duplicate (meta);
239 ret->keywords = GNUNET_FS_uri_dup (keywords); 240 ret->keywords = GNUNET_FS_uri_dup (keywords);
240 ret->bo = *bo; 241 ret->bo = *bo;
241 ret->is_directory = GNUNET_YES; 242 ret->is_directory = GNUNET_YES;
@@ -392,7 +393,7 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
392 if (NULL != fi->keywords) 393 if (NULL != fi->keywords)
393 GNUNET_FS_uri_destroy (fi->keywords); 394 GNUNET_FS_uri_destroy (fi->keywords);
394 if (NULL != fi->meta) 395 if (NULL != fi->meta)
395 GNUNET_CONTAINER_meta_data_destroy (fi->meta); 396 GNUNET_FS_meta_data_destroy (fi->meta);
396 GNUNET_free (fi->serialization); 397 GNUNET_free (fi->serialization);
397 if (NULL != fi->te) 398 if (NULL != fi->te)
398 { 399 {
diff --git a/src/fs/fs_getopt.c b/src/fs/fs_getopt.c
index 43a02a9fa..0135e2e05 100644
--- a/src/fs/fs_getopt.c
+++ b/src/fs/fs_getopt.c
@@ -24,8 +24,8 @@
24 * @author Igor Wronsky, Christian Grothoff 24 * @author Igor Wronsky, Christian Grothoff
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27
27#include "gnunet_fs_service.h" 28#include "gnunet_fs_service.h"
28#include "gnunet_getopt_lib.h"
29#include "fs_api.h" 29#include "fs_api.h"
30 30
31/* ******************** command-line option parsing API ******************** */ 31/* ******************** command-line option parsing API ******************** */
@@ -164,20 +164,20 @@ getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
164 const char *option, 164 const char *option,
165 const char *value) 165 const char *value)
166{ 166{
167 struct GNUNET_CONTAINER_MetaData **mm = scls; 167 struct GNUNET_FS_MetaData **mm = scls;
168 168
169#if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR 169#if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR
170 enum EXTRACTOR_MetaType type; 170 enum EXTRACTOR_MetaType type;
171 const char *typename; 171 const char *typename;
172 const char *typename_i18n; 172 const char *typename_i18n;
173#endif 173#endif
174 struct GNUNET_CONTAINER_MetaData *meta; 174 struct GNUNET_FS_MetaData *meta;
175 char *tmp; 175 char *tmp;
176 176
177 meta = *mm; 177 meta = *mm;
178 if (meta == NULL) 178 if (meta == NULL)
179 { 179 {
180 meta = GNUNET_CONTAINER_meta_data_create (); 180 meta = GNUNET_FS_meta_data_create ();
181 *mm = meta; 181 *mm = meta;
182 } 182 }
183 183
@@ -197,12 +197,12 @@ getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
197 (tmp[strlen (typename)] == ':') && 197 (tmp[strlen (typename)] == ':') &&
198 (0 == strncmp (typename, tmp, strlen (typename)))) 198 (0 == strncmp (typename, tmp, strlen (typename))))
199 { 199 {
200 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>", type, 200 GNUNET_FS_meta_data_insert (meta, "<gnunet>", type,
201 EXTRACTOR_METAFORMAT_UTF8, 201 EXTRACTOR_METAFORMAT_UTF8,
202 "text/plain", 202 "text/plain",
203 &tmp[strlen (typename) + 1], 203 &tmp[strlen (typename) + 1],
204 strlen (&tmp[strlen (typename) + 1]) 204 strlen (&tmp[strlen (typename) + 1])
205 + 1); 205 + 1);
206 GNUNET_free (tmp); 206 GNUNET_free (tmp);
207 tmp = NULL; 207 tmp = NULL;
208 break; 208 break;
@@ -211,13 +211,13 @@ getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
211 (tmp[strlen (typename_i18n)] == ':') && 211 (tmp[strlen (typename_i18n)] == ':') &&
212 (0 == strncmp (typename_i18n, tmp, strlen (typename_i18n)))) 212 (0 == strncmp (typename_i18n, tmp, strlen (typename_i18n))))
213 { 213 {
214 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>", type, 214 GNUNET_FS_meta_data_insert (meta, "<gnunet>", type,
215 EXTRACTOR_METAFORMAT_UTF8, 215 EXTRACTOR_METAFORMAT_UTF8,
216 "text/plain", 216 "text/plain",
217 &tmp[strlen (typename_i18n) + 1], 217 &tmp[strlen (typename_i18n) + 1],
218 strlen (&tmp 218 strlen (&tmp
219 [strlen (typename_i18n) + 1]) 219 [strlen (typename_i18n) + 1])
220 + 1); 220 + 1);
221 GNUNET_free (tmp); 221 GNUNET_free (tmp);
222 tmp = NULL; 222 tmp = NULL;
223 break; 223 break;
@@ -227,10 +227,10 @@ getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
227 227
228 if (NULL != tmp) 228 if (NULL != tmp)
229 { 229 {
230 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>", 230 GNUNET_FS_meta_data_insert (meta, "<gnunet>",
231 EXTRACTOR_METATYPE_UNKNOWN, 231 EXTRACTOR_METATYPE_UNKNOWN,
232 EXTRACTOR_METAFORMAT_UTF8, "text/plain", 232 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
233 tmp, strlen (tmp) + 1); 233 tmp, strlen (tmp) + 1);
234 GNUNET_free (tmp); 234 GNUNET_free (tmp);
235 printf (_ 235 printf (_
236 ( 236 (
@@ -255,7 +255,7 @@ GNUNET_FS_GETOPT_METADATA (char shortName,
255 const char *name, 255 const char *name,
256 const char *argumentHelp, 256 const char *argumentHelp,
257 const char *description, 257 const char *description,
258 struct GNUNET_CONTAINER_MetaData **meta) 258 struct GNUNET_FS_MetaData **meta)
259{ 259{
260 struct GNUNET_GETOPT_CommandLineOption clo = { 260 struct GNUNET_GETOPT_CommandLineOption clo = {
261 .shortName = shortName, 261 .shortName = shortName,
diff --git a/src/fs/fs_list_indexed.c b/src/fs/fs_list_indexed.c
index eaee4ce55..78816cad1 100644
--- a/src/fs/fs_list_indexed.c
+++ b/src/fs/fs_list_indexed.c
@@ -26,6 +26,7 @@
26 26
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_constants.h" 28#include "gnunet_constants.h"
29
29#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
30#include "gnunet_protocols.h" 31#include "gnunet_protocols.h"
31#include "fs_api.h" 32#include "fs_api.h"
diff --git a/src/fs/fs_misc.c b/src/fs/fs_misc.c
index 2e7816d65..a8e23f042 100644
--- a/src/fs/fs_misc.c
+++ b/src/fs/fs_misc.c
@@ -24,6 +24,7 @@
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include "gnunet_constants.h" 26#include "gnunet_constants.h"
27
27#include "gnunet_fs_service.h" 28#include "gnunet_fs_service.h"
28#include "fs_api.h" 29#include "fs_api.h"
29 30
@@ -35,7 +36,7 @@
35 * @return NULL if meta data is useless for suggesting a filename 36 * @return NULL if meta data is useless for suggesting a filename
36 */ 37 */
37char * 38char *
38GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData 39GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_FS_MetaData
39 *md) 40 *md)
40{ 41{
41 static const char *mimeMap[][2] = { 42 static const char *mimeMap[][2] = {
@@ -111,13 +112,13 @@ GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData
111 const char *ext; 112 const char *ext;
112 113
113 ret = 114 ret =
114 GNUNET_CONTAINER_meta_data_get_by_type (md, 115 GNUNET_FS_meta_data_get_by_type (md,
115 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 116 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
116 if (ret != NULL) 117 if (ret != NULL)
117 return ret; 118 return ret;
118 ext = NULL; 119 ext = NULL;
119 mime = 120 mime =
120 GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE); 121 GNUNET_FS_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE);
121 if (mime != NULL) 122 if (mime != NULL)
122 { 123 {
123 i = 0; 124 i = 0;
@@ -131,24 +132,24 @@ GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData
131 GNUNET_free (mime); 132 GNUNET_free (mime);
132 } 133 }
133 base = 134 base =
134 GNUNET_CONTAINER_meta_data_get_first_by_types (md, 135 GNUNET_FS_meta_data_get_first_by_types (md,
135 EXTRACTOR_METATYPE_TITLE, 136 EXTRACTOR_METATYPE_TITLE,
136 EXTRACTOR_METATYPE_BOOK_TITLE, 137 EXTRACTOR_METATYPE_BOOK_TITLE,
137 EXTRACTOR_METATYPE_ORIGINAL_TITLE, 138 EXTRACTOR_METATYPE_ORIGINAL_TITLE,
138 EXTRACTOR_METATYPE_PACKAGE_NAME, 139 EXTRACTOR_METATYPE_PACKAGE_NAME,
139 EXTRACTOR_METATYPE_URL, 140 EXTRACTOR_METATYPE_URL,
140 EXTRACTOR_METATYPE_URI, 141 EXTRACTOR_METATYPE_URI,
141 EXTRACTOR_METATYPE_DESCRIPTION, 142 EXTRACTOR_METATYPE_DESCRIPTION,
142 EXTRACTOR_METATYPE_ISRC, 143 EXTRACTOR_METATYPE_ISRC,
143 EXTRACTOR_METATYPE_JOURNAL_NAME, 144 EXTRACTOR_METATYPE_JOURNAL_NAME,
144 EXTRACTOR_METATYPE_AUTHOR_NAME, 145 EXTRACTOR_METATYPE_AUTHOR_NAME,
145 EXTRACTOR_METATYPE_SUBJECT, 146 EXTRACTOR_METATYPE_SUBJECT,
146 EXTRACTOR_METATYPE_ALBUM, 147 EXTRACTOR_METATYPE_ALBUM,
147 EXTRACTOR_METATYPE_ARTIST, 148 EXTRACTOR_METATYPE_ARTIST,
148 EXTRACTOR_METATYPE_KEYWORDS, 149 EXTRACTOR_METATYPE_KEYWORDS,
149 EXTRACTOR_METATYPE_COMMENT, 150 EXTRACTOR_METATYPE_COMMENT,
150 EXTRACTOR_METATYPE_UNKNOWN, 151 EXTRACTOR_METATYPE_UNKNOWN,
151 -1); 152 -1);
152 if ((base == NULL) && (ext == NULL)) 153 if ((base == NULL) && (ext == NULL))
153 return NULL; 154 return NULL;
154 if (base == NULL) 155 if (base == NULL)
diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c
index bc94dd1fc..f8b7b91c0 100644
--- a/src/fs/fs_namespace.c
+++ b/src/fs/fs_namespace.c
@@ -28,6 +28,7 @@
28#include "gnunet_constants.h" 28#include "gnunet_constants.h"
29#include "gnunet_signatures.h" 29#include "gnunet_signatures.h"
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31
31#include "gnunet_fs_service.h" 32#include "gnunet_fs_service.h"
32#include "fs_api.h" 33#include "fs_api.h"
33#include "fs_publish_ublock.h" 34#include "fs_publish_ublock.h"
@@ -52,7 +53,7 @@ struct NamespaceUpdateNode
52 /** 53 /**
53 * Metadata for this entry. 54 * Metadata for this entry.
54 */ 55 */
55 struct GNUNET_CONTAINER_MetaData *md; 56 struct GNUNET_FS_MetaData *md;
56 57
57 /** 58 /**
58 * URI of this entry in the namespace. 59 * URI of this entry in the namespace.
@@ -167,7 +168,7 @@ free_update_information_graph (struct GNUNET_FS_UpdateInformationGraph *uig)
167 for (i = 0; i < uig->update_node_count; i++) 168 for (i = 0; i < uig->update_node_count; i++)
168 { 169 {
169 nsn = uig->update_nodes[i]; 170 nsn = uig->update_nodes[i];
170 GNUNET_CONTAINER_meta_data_destroy (nsn->md); 171 GNUNET_FS_meta_data_destroy (nsn->md);
171 GNUNET_FS_uri_destroy (nsn->uri); 172 GNUNET_FS_uri_destroy (nsn->uri);
172 GNUNET_free (nsn->id); 173 GNUNET_free (nsn->id);
173 GNUNET_free (nsn->update); 174 GNUNET_free (nsn->update);
@@ -215,7 +216,7 @@ write_update_information_graph (struct GNUNET_FS_UpdateInformationGraph *uig)
215 uris = GNUNET_FS_uri_to_string (n->uri); 216 uris = GNUNET_FS_uri_to_string (n->uri);
216 struct GNUNET_BIO_WriteSpec ws[] = { 217 struct GNUNET_BIO_WriteSpec ws[] = {
217 GNUNET_BIO_write_spec_string ("fs-namespace-node-id", n->id), 218 GNUNET_BIO_write_spec_string ("fs-namespace-node-id", n->id),
218 GNUNET_BIO_write_spec_meta_data ("fs-namespace-node-meta", n->md), 219 GNUNET_FS_write_spec_meta_data ("fs-namespace-node-meta", n->md),
219 GNUNET_BIO_write_spec_string ("fs-namespace-node-update", n->update), 220 GNUNET_BIO_write_spec_string ("fs-namespace-node-update", n->update),
220 GNUNET_BIO_write_spec_string ("fs-namespace-uris", uris), 221 GNUNET_BIO_write_spec_string ("fs-namespace-uris", uris),
221 GNUNET_BIO_write_spec_end (), 222 GNUNET_BIO_write_spec_end (),
@@ -227,7 +228,7 @@ write_update_information_graph (struct GNUNET_FS_UpdateInformationGraph *uig)
227 } 228 }
228 GNUNET_free (uris); 229 GNUNET_free (uris);
229 } 230 }
230END: 231 END:
231 if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL)) 232 if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL))
232 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 233 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
233 _ ("Failed to write `%s': %s\n"), 234 _ ("Failed to write `%s': %s\n"),
@@ -293,7 +294,7 @@ read_update_information_graph (struct GNUNET_FS_Handle *h,
293 n = GNUNET_new (struct NamespaceUpdateNode); 294 n = GNUNET_new (struct NamespaceUpdateNode);
294 struct GNUNET_BIO_ReadSpec rs[] = { 295 struct GNUNET_BIO_ReadSpec rs[] = {
295 GNUNET_BIO_read_spec_string ("identifier", &n->id, 1024), 296 GNUNET_BIO_read_spec_string ("identifier", &n->id, 1024),
296 GNUNET_BIO_read_spec_meta_data ("meta", &n->md), 297 GNUNET_FS_read_spec_meta_data ("meta", &n->md),
297 GNUNET_BIO_read_spec_string ("update-id", &n->update, 1024), 298 GNUNET_BIO_read_spec_string ("update-id", &n->update, 1024),
298 GNUNET_BIO_read_spec_string ("uri", &uris, 1024 * 2), 299 GNUNET_BIO_read_spec_string ("uri", &uris, 1024 * 2),
299 GNUNET_BIO_read_spec_end (), 300 GNUNET_BIO_read_spec_end (),
@@ -304,7 +305,7 @@ read_update_information_graph (struct GNUNET_FS_Handle *h,
304 GNUNET_free (n->id); 305 GNUNET_free (n->id);
305 GNUNET_free (n->update); 306 GNUNET_free (n->update);
306 if (n->md != NULL) 307 if (n->md != NULL)
307 GNUNET_CONTAINER_meta_data_destroy (n->md); 308 GNUNET_FS_meta_data_destroy (n->md);
308 GNUNET_free (n); 309 GNUNET_free (n);
309 break; 310 break;
310 } 311 }
@@ -316,14 +317,14 @@ read_update_information_graph (struct GNUNET_FS_Handle *h,
316 GNUNET_free (emsg); 317 GNUNET_free (emsg);
317 GNUNET_free (n->id); 318 GNUNET_free (n->id);
318 GNUNET_free (n->update); 319 GNUNET_free (n->update);
319 GNUNET_CONTAINER_meta_data_destroy (n->md); 320 GNUNET_FS_meta_data_destroy (n->md);
320 GNUNET_free (n); 321 GNUNET_free (n);
321 break; 322 break;
322 } 323 }
323 uig->update_nodes[i] = n; 324 uig->update_nodes[i] = n;
324 } 325 }
325 uig->update_node_count = i; 326 uig->update_node_count = i;
326END: 327 END:
327 if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)) 328 if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
328 { 329 {
329 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 330 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -428,7 +429,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
428 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, 429 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
429 const char *identifier, 430 const char *identifier,
430 const char *update, 431 const char *update,
431 const struct GNUNET_CONTAINER_MetaData *meta, 432 const struct GNUNET_FS_MetaData *meta,
432 const struct GNUNET_FS_Uri *uri, 433 const struct GNUNET_FS_Uri *uri,
433 const struct GNUNET_FS_BlockOptions *bo, 434 const struct GNUNET_FS_BlockOptions *bo,
434 enum GNUNET_FS_PublishOptions options, 435 enum GNUNET_FS_PublishOptions options,
@@ -463,7 +464,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
463 psc->nsn = GNUNET_new (struct NamespaceUpdateNode); 464 psc->nsn = GNUNET_new (struct NamespaceUpdateNode);
464 psc->nsn->id = GNUNET_strdup (identifier); 465 psc->nsn->id = GNUNET_strdup (identifier);
465 psc->nsn->update = GNUNET_strdup (update); 466 psc->nsn->update = GNUNET_strdup (update);
466 psc->nsn->md = GNUNET_CONTAINER_meta_data_duplicate (meta); 467 psc->nsn->md = GNUNET_FS_meta_data_duplicate (meta);
467 psc->nsn->uri = GNUNET_FS_uri_dup (uri); 468 psc->nsn->uri = GNUNET_FS_uri_dup (uri);
468 } 469 }
469 psc->uc = GNUNET_FS_publish_ublock_ (h, 470 psc->uc = GNUNET_FS_publish_ublock_ (h,
@@ -502,7 +503,7 @@ GNUNET_FS_publish_sks_cancel (struct GNUNET_FS_PublishSksContext *psc)
502 GNUNET_FS_uri_destroy (psc->uri); 503 GNUNET_FS_uri_destroy (psc->uri);
503 if (NULL != psc->nsn) 504 if (NULL != psc->nsn)
504 { 505 {
505 GNUNET_CONTAINER_meta_data_destroy (psc->nsn->md); 506 GNUNET_FS_meta_data_destroy (psc->nsn->md);
506 GNUNET_FS_uri_destroy (psc->nsn->uri); 507 GNUNET_FS_uri_destroy (psc->nsn->uri);
507 GNUNET_free (psc->nsn->id); 508 GNUNET_free (psc->nsn->id);
508 GNUNET_free (psc->nsn->update); 509 GNUNET_free (psc->nsn->update);
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index 5cdf8f6e8..d1662c78b 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -28,6 +28,7 @@
28#include "gnunet_constants.h" 28#include "gnunet_constants.h"
29#include "gnunet_signatures.h" 29#include "gnunet_signatures.h"
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31
31#include "gnunet_fs_service.h" 32#include "gnunet_fs_service.h"
32#include "fs_api.h" 33#include "fs_api.h"
33#include "fs_tree.h" 34#include "fs_tree.h"
@@ -1098,8 +1099,8 @@ GNUNET_FS_publish_main_ (void *cls)
1098 * related files as well! */ 1099 * related files as well! */
1099 while (NULL != p->dir) 1100 while (NULL != p->dir)
1100 { 1101 {
1101 fn = GNUNET_CONTAINER_meta_data_get_by_type (p->meta, 1102 fn = GNUNET_FS_meta_data_get_by_type (p->meta,
1102 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 1103 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
1103 p = p->dir; 1104 p = p->dir;
1104 if (fn != NULL) 1105 if (fn != NULL)
1105 { 1106 {
@@ -1193,7 +1194,7 @@ static int
1193fip_signal_start (void *cls, 1194fip_signal_start (void *cls,
1194 struct GNUNET_FS_FileInformation *fi, 1195 struct GNUNET_FS_FileInformation *fi,
1195 uint64_t length, 1196 uint64_t length,
1196 struct GNUNET_CONTAINER_MetaData *meta, 1197 struct GNUNET_FS_MetaData *meta,
1197 struct GNUNET_FS_Uri **uri, 1198 struct GNUNET_FS_Uri **uri,
1198 struct GNUNET_FS_BlockOptions *bo, 1199 struct GNUNET_FS_BlockOptions *bo,
1199 int *do_index, 1200 int *do_index,
@@ -1319,7 +1320,7 @@ static int
1319fip_signal_suspend (void *cls, 1320fip_signal_suspend (void *cls,
1320 struct GNUNET_FS_FileInformation *fi, 1321 struct GNUNET_FS_FileInformation *fi,
1321 uint64_t length, 1322 uint64_t length,
1322 struct GNUNET_CONTAINER_MetaData *meta, 1323 struct GNUNET_FS_MetaData *meta,
1323 struct GNUNET_FS_Uri **uri, 1324 struct GNUNET_FS_Uri **uri,
1324 struct GNUNET_FS_BlockOptions *bo, 1325 struct GNUNET_FS_BlockOptions *bo,
1325 int *do_index, 1326 int *do_index,
@@ -1523,7 +1524,7 @@ static int
1523fip_signal_stop (void *cls, 1524fip_signal_stop (void *cls,
1524 struct GNUNET_FS_FileInformation *fi, 1525 struct GNUNET_FS_FileInformation *fi,
1525 uint64_t length, 1526 uint64_t length,
1526 struct GNUNET_CONTAINER_MetaData *meta, 1527 struct GNUNET_FS_MetaData *meta,
1527 struct GNUNET_FS_Uri **uri, 1528 struct GNUNET_FS_Uri **uri,
1528 struct GNUNET_FS_BlockOptions *bo, 1529 struct GNUNET_FS_BlockOptions *bo,
1529 int *do_index, void **client_info) 1530 int *do_index, void **client_info)
diff --git a/src/fs/fs_publish_ksk.c b/src/fs/fs_publish_ksk.c
index dae5ccdf3..3981ad335 100644
--- a/src/fs/fs_publish_ksk.c
+++ b/src/fs/fs_publish_ksk.c
@@ -30,6 +30,7 @@
30#include "gnunet_constants.h" 30#include "gnunet_constants.h"
31#include "gnunet_signatures.h" 31#include "gnunet_signatures.h"
32#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
33
33#include "gnunet_fs_service.h" 34#include "gnunet_fs_service.h"
34#include "fs_api.h" 35#include "fs_api.h"
35#include "fs_tree.h" 36#include "fs_tree.h"
@@ -53,7 +54,7 @@ struct GNUNET_FS_PublishKskContext
53 /** 54 /**
54 * Metadata to use. 55 * Metadata to use.
55 */ 56 */
56 struct GNUNET_CONTAINER_MetaData *meta; 57 struct GNUNET_FS_MetaData *meta;
57 58
58 /** 59 /**
59 * Global FS context. 60 * Global FS context.
@@ -186,7 +187,7 @@ publish_ksk_cont (void *cls)
186struct GNUNET_FS_PublishKskContext * 187struct GNUNET_FS_PublishKskContext *
187GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h, 188GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
188 const struct GNUNET_FS_Uri *ksk_uri, 189 const struct GNUNET_FS_Uri *ksk_uri,
189 const struct GNUNET_CONTAINER_MetaData *meta, 190 const struct GNUNET_FS_MetaData *meta,
190 const struct GNUNET_FS_Uri *uri, 191 const struct GNUNET_FS_Uri *uri,
191 const struct GNUNET_FS_BlockOptions *bo, 192 const struct GNUNET_FS_BlockOptions *bo,
192 enum GNUNET_FS_PublishOptions options, 193 enum GNUNET_FS_PublishOptions options,
@@ -201,7 +202,7 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
201 pkc->options = options; 202 pkc->options = options;
202 pkc->cont = cont; 203 pkc->cont = cont;
203 pkc->cont_cls = cont_cls; 204 pkc->cont_cls = cont_cls;
204 pkc->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 205 pkc->meta = GNUNET_FS_meta_data_duplicate (meta);
205 if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) 206 if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY))
206 { 207 {
207 pkc->dsh = GNUNET_DATASTORE_connect (h->cfg); 208 pkc->dsh = GNUNET_DATASTORE_connect (h->cfg);
@@ -244,7 +245,7 @@ GNUNET_FS_publish_ksk_cancel (struct GNUNET_FS_PublishKskContext *pkc)
244 GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO); 245 GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO);
245 pkc->dsh = NULL; 246 pkc->dsh = NULL;
246 } 247 }
247 GNUNET_CONTAINER_meta_data_destroy (pkc->meta); 248 GNUNET_FS_meta_data_destroy (pkc->meta);
248 GNUNET_FS_uri_destroy (pkc->ksk_uri); 249 GNUNET_FS_uri_destroy (pkc->ksk_uri);
249 GNUNET_FS_uri_destroy (pkc->uri); 250 GNUNET_FS_uri_destroy (pkc->uri);
250 GNUNET_free (pkc); 251 GNUNET_free (pkc);
diff --git a/src/fs/fs_publish_ublock.c b/src/fs/fs_publish_ublock.c
index aed090bb3..ad12d9b08 100644
--- a/src/fs/fs_publish_ublock.c
+++ b/src/fs/fs_publish_ublock.c
@@ -155,7 +155,7 @@ GNUNET_FS_publish_ublock_ (struct GNUNET_FS_Handle *h,
155 const char *label, 155 const char *label,
156 const char *ulabel, 156 const char *ulabel,
157 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, 157 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
158 const struct GNUNET_CONTAINER_MetaData *meta, 158 const struct GNUNET_FS_MetaData *meta,
159 const struct GNUNET_FS_Uri *uri, 159 const struct GNUNET_FS_Uri *uri,
160 const struct GNUNET_FS_BlockOptions *bo, 160 const struct GNUNET_FS_BlockOptions *bo,
161 enum GNUNET_FS_PublishOptions options, 161 enum GNUNET_FS_PublishOptions options,
@@ -181,7 +181,7 @@ GNUNET_FS_publish_ublock_ (struct GNUNET_FS_Handle *h,
181 if (NULL == meta) 181 if (NULL == meta)
182 mdsize = 0; 182 mdsize = 0;
183 else 183 else
184 mdsize = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); 184 mdsize = GNUNET_FS_meta_data_get_serialized_size (meta);
185 GNUNET_assert (mdsize >= 0); 185 GNUNET_assert (mdsize >= 0);
186 uris = GNUNET_FS_uri_to_string (uri); 186 uris = GNUNET_FS_uri_to_string (uri);
187 slen = strlen (uris) + 1; 187 slen = strlen (uris) + 1;
@@ -206,8 +206,8 @@ GNUNET_FS_publish_ublock_ (struct GNUNET_FS_Handle *h,
206 sptr = kbe; 206 sptr = kbe;
207 if (NULL != meta) 207 if (NULL != meta)
208 mdsize = 208 mdsize =
209 GNUNET_CONTAINER_meta_data_serialize (meta, &sptr, mdsize, 209 GNUNET_FS_meta_data_serialize (meta, &sptr, mdsize,
210 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); 210 GNUNET_FS_META_DATA_SERIALIZE_PART);
211 if (-1 == mdsize) 211 if (-1 == mdsize)
212 { 212 {
213 GNUNET_break (0); 213 GNUNET_break (0);
diff --git a/src/fs/fs_publish_ublock.h b/src/fs/fs_publish_ublock.h
index bd1c1a4dd..4adffc6c1 100644
--- a/src/fs/fs_publish_ublock.h
+++ b/src/fs/fs_publish_ublock.h
@@ -30,6 +30,7 @@
30 30
31#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_datastore_service.h" 32#include "gnunet_datastore_service.h"
33
33#include "gnunet_fs_service.h" 34#include "gnunet_fs_service.h"
34#include "gnunet_identity_service.h" 35#include "gnunet_identity_service.h"
35 36
@@ -90,7 +91,7 @@ GNUNET_FS_publish_ublock_ (struct GNUNET_FS_Handle *h,
90 const char *label, 91 const char *label,
91 const char *ulabel, 92 const char *ulabel,
92 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, 93 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
93 const struct GNUNET_CONTAINER_MetaData *meta, 94 const struct GNUNET_FS_MetaData *meta,
94 const struct GNUNET_FS_Uri *uri, 95 const struct GNUNET_FS_Uri *uri,
95 const struct GNUNET_FS_BlockOptions *bo, 96 const struct GNUNET_FS_BlockOptions *bo,
96 enum GNUNET_FS_PublishOptions options, 97 enum GNUNET_FS_PublishOptions options,
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c
index 5538b7838..823f046ed 100644
--- a/src/fs/fs_search.c
+++ b/src/fs/fs_search.c
@@ -24,6 +24,7 @@
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include "gnunet_constants.h" 26#include "gnunet_constants.h"
27
27#include "gnunet_fs_service.h" 28#include "gnunet_fs_service.h"
28#include "gnunet_protocols.h" 29#include "gnunet_protocols.h"
29#include "fs_api.h" 30#include "fs_api.h"
@@ -487,7 +488,7 @@ GNUNET_FS_search_start_probe_ (struct GNUNET_FS_SearchResult *sr)
487struct GNUNET_FS_SearchResult * 488struct GNUNET_FS_SearchResult *
488GNUNET_FS_probe (struct GNUNET_FS_Handle *h, 489GNUNET_FS_probe (struct GNUNET_FS_Handle *h,
489 const struct GNUNET_FS_Uri *uri, 490 const struct GNUNET_FS_Uri *uri,
490 const struct GNUNET_CONTAINER_MetaData *meta, 491 const struct GNUNET_FS_MetaData *meta,
491 void *client_info, 492 void *client_info,
492 uint32_t anonymity) 493 uint32_t anonymity)
493{ 494{
@@ -498,7 +499,7 @@ GNUNET_FS_probe (struct GNUNET_FS_Handle *h,
498 sr = GNUNET_new (struct GNUNET_FS_SearchResult); 499 sr = GNUNET_new (struct GNUNET_FS_SearchResult);
499 sr->h = h; 500 sr->h = h;
500 sr->uri = GNUNET_FS_uri_dup (uri); 501 sr->uri = GNUNET_FS_uri_dup (uri);
501 sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 502 sr->meta = GNUNET_FS_meta_data_duplicate (meta);
502 sr->client_info = client_info; 503 sr->client_info = client_info;
503 sr->anonymity = anonymity; 504 sr->anonymity = anonymity;
504 GNUNET_FS_search_start_probe_ (sr); 505 GNUNET_FS_search_start_probe_ (sr);
@@ -543,7 +544,7 @@ GNUNET_FS_probe_stop (struct GNUNET_FS_SearchResult *sr)
543 GNUNET_assert (NULL == sr->sc); 544 GNUNET_assert (NULL == sr->sc);
544 GNUNET_FS_search_stop_probe_ (sr); 545 GNUNET_FS_search_stop_probe_ (sr);
545 GNUNET_FS_uri_destroy (sr->uri); 546 GNUNET_FS_uri_destroy (sr->uri);
546 GNUNET_CONTAINER_meta_data_destroy (sr->meta); 547 GNUNET_FS_meta_data_destroy (sr->meta);
547 client_info = sr->client_info; 548 client_info = sr->client_info;
548 GNUNET_free (sr); 549 GNUNET_free (sr);
549 return client_info; 550 return client_info;
@@ -564,7 +565,7 @@ static void
564process_ksk_result (struct GNUNET_FS_SearchContext *sc, 565process_ksk_result (struct GNUNET_FS_SearchContext *sc,
565 struct SearchRequestEntry *ent, 566 struct SearchRequestEntry *ent,
566 const struct GNUNET_FS_Uri *uri, 567 const struct GNUNET_FS_Uri *uri,
567 const struct GNUNET_CONTAINER_MetaData *meta) 568 const struct GNUNET_FS_MetaData *meta)
568{ 569{
569 struct GNUNET_HashCode key; 570 struct GNUNET_HashCode key;
570 struct GNUNET_FS_SearchResult *sr; 571 struct GNUNET_FS_SearchResult *sr;
@@ -602,7 +603,7 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc,
602 sr->sc = sc; 603 sr->sc = sc;
603 sr->anonymity = sc->anonymity; 604 sr->anonymity = sc->anonymity;
604 sr->uri = GNUNET_FS_uri_dup (uri); 605 sr->uri = GNUNET_FS_uri_dup (uri);
605 sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 606 sr->meta = GNUNET_FS_meta_data_duplicate (meta);
606 sr->mandatory_missing = sc->mandatory_count; 607 sr->mandatory_missing = sc->mandatory_count;
607 sr->key = key; 608 sr->key = key;
608 sr->keyword_bitmap = GNUNET_malloc ((sc->uri->data.ksk.keywordCount + 7) 609 sr->keyword_bitmap = GNUNET_malloc ((sc->uri->data.ksk.keywordCount + 7)
@@ -612,7 +613,7 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc,
612 } 613 }
613 else 614 else
614 { 615 {
615 GNUNET_CONTAINER_meta_data_merge (sr->meta, meta); 616 GNUNET_FS_meta_data_merge (sr->meta, meta);
616 } 617 }
617 GNUNET_break (GNUNET_OK == 618 GNUNET_break (GNUNET_OK ==
618 GNUNET_CONTAINER_multihashmap_put (ent->results, 619 GNUNET_CONTAINER_multihashmap_put (ent->results,
@@ -685,7 +686,7 @@ static void
685process_sks_result (struct GNUNET_FS_SearchContext *sc, 686process_sks_result (struct GNUNET_FS_SearchContext *sc,
686 const char *id_update, 687 const char *id_update,
687 const struct GNUNET_FS_Uri *uri, 688 const struct GNUNET_FS_Uri *uri,
688 const struct GNUNET_CONTAINER_MetaData *meta) 689 const struct GNUNET_FS_MetaData *meta)
689{ 690{
690 struct GNUNET_FS_Uri uu; 691 struct GNUNET_FS_Uri uu;
691 struct GNUNET_HashCode key; 692 struct GNUNET_HashCode key;
@@ -713,7 +714,7 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc,
713 sr->sc = sc; 714 sr->sc = sc;
714 sr->anonymity = sc->anonymity; 715 sr->anonymity = sc->anonymity;
715 sr->uri = GNUNET_FS_uri_dup (uri); 716 sr->uri = GNUNET_FS_uri_dup (uri);
716 sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); 717 sr->meta = GNUNET_FS_meta_data_duplicate (meta);
717 sr->key = key; 718 sr->key = key;
718 GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, &key, sr, 719 GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, &key, sr,
719 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 720 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
@@ -800,7 +801,7 @@ process_kblock (struct GNUNET_FS_SearchContext *sc,
800 size_t j; 801 size_t j;
801 char pt[size - sizeof(struct UBlock)]; 802 char pt[size - sizeof(struct UBlock)];
802 const char *eos; 803 const char *eos;
803 struct GNUNET_CONTAINER_MetaData *meta; 804 struct GNUNET_FS_MetaData *meta;
804 struct GNUNET_FS_Uri *uri; 805 struct GNUNET_FS_Uri *uri;
805 char *emsg; 806 char *emsg;
806 int i; 807 int i;
@@ -835,9 +836,9 @@ process_kblock (struct GNUNET_FS_SearchContext *sc,
835 } 836 }
836 j = eos - pt + 1; 837 j = eos - pt + 1;
837 if (sizeof(pt) == j) 838 if (sizeof(pt) == j)
838 meta = GNUNET_CONTAINER_meta_data_create (); 839 meta = GNUNET_FS_meta_data_create ();
839 else 840 else
840 meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[j], sizeof(pt) - j); 841 meta = GNUNET_FS_meta_data_deserialize (&pt[j], sizeof(pt) - j);
841 if (NULL == meta) 842 if (NULL == meta)
842 { 843 {
843 GNUNET_break_op (0); /* ublock malformed */ 844 GNUNET_break_op (0); /* ublock malformed */
@@ -850,7 +851,7 @@ process_kblock (struct GNUNET_FS_SearchContext *sc,
850 meta); 851 meta);
851 852
852 /* clean up */ 853 /* clean up */
853 GNUNET_CONTAINER_meta_data_destroy (meta); 854 GNUNET_FS_meta_data_destroy (meta);
854 GNUNET_FS_uri_destroy (uri); 855 GNUNET_FS_uri_destroy (uri);
855} 856}
856 857
@@ -872,7 +873,7 @@ process_sblock (struct GNUNET_FS_SearchContext *sc,
872 size_t len = size - sizeof(struct UBlock); 873 size_t len = size - sizeof(struct UBlock);
873 char pt[len]; 874 char pt[len];
874 struct GNUNET_FS_Uri *uri; 875 struct GNUNET_FS_Uri *uri;
875 struct GNUNET_CONTAINER_MetaData *meta; 876 struct GNUNET_FS_MetaData *meta;
876 const char *id; 877 const char *id;
877 const char *uris; 878 const char *uris;
878 size_t off; 879 size_t off;
@@ -888,8 +889,8 @@ process_sblock (struct GNUNET_FS_SearchContext *sc,
888 GNUNET_break_op (0); /* ublock malformed */ 889 GNUNET_break_op (0); /* ublock malformed */
889 return; 890 return;
890 } 891 }
891 if (NULL == (meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[off], len 892 if (NULL == (meta = GNUNET_FS_meta_data_deserialize (&pt[off], len
892 - off))) 893 - off)))
893 { 894 {
894 GNUNET_break_op (0); /* ublock malformed */ 895 GNUNET_break_op (0); /* ublock malformed */
895 return; 896 return;
@@ -901,14 +902,14 @@ process_sblock (struct GNUNET_FS_SearchContext *sc,
901 uris, emsg); 902 uris, emsg);
902 GNUNET_break_op (0); /* ublock malformed */ 903 GNUNET_break_op (0); /* ublock malformed */
903 GNUNET_free (emsg); 904 GNUNET_free (emsg);
904 GNUNET_CONTAINER_meta_data_destroy (meta); 905 GNUNET_FS_meta_data_destroy (meta);
905 return; 906 return;
906 } 907 }
907 /* process */ 908 /* process */
908 process_sks_result (sc, id, uri, meta); 909 process_sks_result (sc, id, uri, meta);
909 /* clean up */ 910 /* clean up */
910 GNUNET_FS_uri_destroy (uri); 911 GNUNET_FS_uri_destroy (uri);
911 GNUNET_CONTAINER_meta_data_destroy (meta); 912 GNUNET_FS_meta_data_destroy (meta);
912} 913}
913 914
914 915
@@ -1543,7 +1544,7 @@ search_result_suspend (void *cls,
1543 GNUNET_break (NULL == sr->client_info); 1544 GNUNET_break (NULL == sr->client_info);
1544 GNUNET_free (sr->serialization); 1545 GNUNET_free (sr->serialization);
1545 GNUNET_FS_uri_destroy (sr->uri); 1546 GNUNET_FS_uri_destroy (sr->uri);
1546 GNUNET_CONTAINER_meta_data_destroy (sr->meta); 1547 GNUNET_FS_meta_data_destroy (sr->meta);
1547 GNUNET_free (sr->keyword_bitmap); 1548 GNUNET_free (sr->keyword_bitmap);
1548 GNUNET_free (sr); 1549 GNUNET_free (sr);
1549 return GNUNET_OK; 1550 return GNUNET_OK;
@@ -1749,7 +1750,7 @@ search_result_free (void *cls,
1749 GNUNET_break (NULL == sr->client_info); 1750 GNUNET_break (NULL == sr->client_info);
1750 GNUNET_free (sr->serialization); 1751 GNUNET_free (sr->serialization);
1751 GNUNET_FS_uri_destroy (sr->uri); 1752 GNUNET_FS_uri_destroy (sr->uri);
1752 GNUNET_CONTAINER_meta_data_destroy (sr->meta); 1753 GNUNET_FS_meta_data_destroy (sr->meta);
1753 GNUNET_free (sr->keyword_bitmap); 1754 GNUNET_free (sr->keyword_bitmap);
1754 GNUNET_free (sr); 1755 GNUNET_free (sr);
1755 return GNUNET_OK; 1756 return GNUNET_OK;
diff --git a/src/fs/fs_sharetree.c b/src/fs/fs_sharetree.c
index 3610b202e..6c246a3ad 100644
--- a/src/fs/fs_sharetree.c
+++ b/src/fs/fs_sharetree.c
@@ -25,6 +25,7 @@
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 */ 26 */
27#include "platform.h" 27#include "platform.h"
28
28#include "gnunet_fs_service.h" 29#include "gnunet_fs_service.h"
29#include "gnunet_scheduler_lib.h" 30#include "gnunet_scheduler_lib.h"
30#include <pthread.h> 31#include <pthread.h>
@@ -308,13 +309,13 @@ migrate_and_drop_metadata (void *cls, const struct GNUNET_HashCode *key,
308 if (counter->count >= tc->move_threshold) 309 if (counter->count >= tc->move_threshold)
309 { 310 {
310 if (NULL == tc->pos->meta) 311 if (NULL == tc->pos->meta)
311 tc->pos->meta = GNUNET_CONTAINER_meta_data_create (); 312 tc->pos->meta = GNUNET_FS_meta_data_create ();
312 GNUNET_CONTAINER_meta_data_insert (tc->pos->meta, 313 GNUNET_FS_meta_data_insert (tc->pos->meta,
313 counter->plugin_name, 314 counter->plugin_name,
314 counter->type, 315 counter->type,
315 counter->format, 316 counter->format,
316 counter->data_mime_type, counter->data, 317 counter->data_mime_type, counter->data,
317 counter->data_size); 318 counter->data_size);
318 } 319 }
319 GNUNET_assert (GNUNET_YES == 320 GNUNET_assert (GNUNET_YES ==
320 GNUNET_CONTAINER_multihashmap_remove (tc->metacounter, 321 GNUNET_CONTAINER_multihashmap_remove (tc->metacounter,
@@ -356,12 +357,12 @@ share_tree_trim (struct TrimContext *tc,
356 { 357 {
357 /* only use filename if it doesn't match $USER */ 358 /* only use filename if it doesn't match $USER */
358 if (NULL == tree->meta) 359 if (NULL == tree->meta)
359 tree->meta = GNUNET_CONTAINER_meta_data_create (); 360 tree->meta = GNUNET_FS_meta_data_create ();
360 GNUNET_CONTAINER_meta_data_insert (tree->meta, "<libgnunetfs>", 361 GNUNET_FS_meta_data_insert (tree->meta, "<libgnunetfs>",
361 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, 362 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
362 EXTRACTOR_METAFORMAT_UTF8, 363 EXTRACTOR_METAFORMAT_UTF8,
363 "text/plain", tree->short_filename, 364 "text/plain", tree->short_filename,
364 strlen (tree->short_filename) + 1); 365 strlen (tree->short_filename) + 1);
365 } 366 }
366 } 367 }
367 368
@@ -372,8 +373,8 @@ share_tree_trim (struct TrimContext *tc,
372 for (pos = tree->children_head; NULL != pos; pos = pos->next) 373 for (pos = tree->children_head; NULL != pos; pos = pos->next)
373 { 374 {
374 if (NULL != pos->meta) 375 if (NULL != pos->meta)
375 GNUNET_CONTAINER_meta_data_iterate (pos->meta, &add_to_meta_counter, 376 GNUNET_FS_meta_data_iterate (pos->meta, &add_to_meta_counter,
376 tc->metacounter); 377 tc->metacounter);
377 if (NULL != pos->ksk_uri) 378 if (NULL != pos->ksk_uri)
378 GNUNET_FS_uri_ksk_get_keywords (pos->ksk_uri, &add_to_keyword_counter, 379 GNUNET_FS_uri_ksk_get_keywords (pos->ksk_uri, &add_to_keyword_counter,
379 tc->keywordcounter); 380 tc->keywordcounter);
@@ -444,7 +445,7 @@ GNUNET_FS_share_tree_free (struct GNUNET_FS_ShareTreeItem *toplevel)
444 toplevel->parent->children_tail, 445 toplevel->parent->children_tail,
445 toplevel); 446 toplevel);
446 if (NULL != toplevel->meta) 447 if (NULL != toplevel->meta)
447 GNUNET_CONTAINER_meta_data_destroy (toplevel->meta); 448 GNUNET_FS_meta_data_destroy (toplevel->meta);
448 if (NULL != toplevel->ksk_uri) 449 if (NULL != toplevel->ksk_uri)
449 GNUNET_FS_uri_destroy (toplevel->ksk_uri); 450 GNUNET_FS_uri_destroy (toplevel->ksk_uri);
450 GNUNET_free (toplevel->filename); 451 GNUNET_free (toplevel->filename);
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c
index 8c27af9de..68ba667c4 100644
--- a/src/fs/fs_unindex.c
+++ b/src/fs/fs_unindex.c
@@ -26,6 +26,7 @@
26 */ 26 */
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_constants.h" 28#include "gnunet_constants.h"
29
29#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
30#include "gnunet_protocols.h" 31#include "gnunet_protocols.h"
31#include "fs_api.h" 32#include "fs_api.h"
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c
index cdea8b72d..b0be0db4f 100644
--- a/src/fs/fs_uri.c
+++ b/src/fs/fs_uri.c
@@ -81,6 +81,7 @@
81 * 81 *
82 */ 82 */
83#include "platform.h" 83#include "platform.h"
84
84#include "gnunet_fs_service.h" 85#include "gnunet_fs_service.h"
85#include "gnunet_signatures.h" 86#include "gnunet_signatures.h"
86#include "fs_api.h" 87#include "fs_api.h"
@@ -343,7 +344,7 @@ uri_ksk_parse (const char *s, char **emsg)
343 ret->data.ksk.keywordCount = iret; 344 ret->data.ksk.keywordCount = iret;
344 ret->data.ksk.keywords = keywords; 345 ret->data.ksk.keywords = keywords;
345 return ret; 346 return ret;
346CLEANUP: 347 CLEANUP:
347 for (i = 0; i < max; i++) 348 for (i = 0; i < max; i++)
348 GNUNET_free (keywords[i]); 349 GNUNET_free (keywords[i]);
349 GNUNET_free (keywords); 350 GNUNET_free (keywords);
@@ -620,7 +621,7 @@ uri_loc_parse (const char *s, char **emsg)
620 uri->data.loc.contentSignature = sig; 621 uri->data.loc.contentSignature = sig;
621 622
622 return uri; 623 return uri;
623ERR: 624 ERR:
624 return NULL; 625 return NULL;
625} 626}
626 627
@@ -1768,7 +1769,7 @@ gather_uri_data (void *cls,
1768 */ 1769 */
1769struct GNUNET_FS_Uri * 1770struct GNUNET_FS_Uri *
1770GNUNET_FS_uri_ksk_create_from_meta_data ( 1771GNUNET_FS_uri_ksk_create_from_meta_data (
1771 const struct GNUNET_CONTAINER_MetaData *md) 1772 const struct GNUNET_FS_MetaData *md)
1772{ 1773{
1773 struct GNUNET_FS_Uri *ret; 1774 struct GNUNET_FS_Uri *ret;
1774 char *filename; 1775 char *filename;
@@ -1782,10 +1783,10 @@ GNUNET_FS_uri_ksk_create_from_meta_data (
1782 return NULL; 1783 return NULL;
1783 ret = GNUNET_new (struct GNUNET_FS_Uri); 1784 ret = GNUNET_new (struct GNUNET_FS_Uri);
1784 ret->type = GNUNET_FS_URI_KSK; 1785 ret->type = GNUNET_FS_URI_KSK;
1785 ent = GNUNET_CONTAINER_meta_data_iterate (md, NULL, NULL); 1786 ent = GNUNET_FS_meta_data_iterate (md, NULL, NULL);
1786 if (ent > 0) 1787 if (ent > 0)
1787 { 1788 {
1788 full_name = GNUNET_CONTAINER_meta_data_get_first_by_types ( 1789 full_name = GNUNET_FS_meta_data_get_first_by_types (
1789 md, 1790 md,
1790 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, 1791 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
1791 -1); 1792 -1);
@@ -1801,7 +1802,7 @@ GNUNET_FS_uri_ksk_create_from_meta_data (
1801 plus theoretically one more for mime... */ 1802 plus theoretically one more for mime... */
1802 ret->data.ksk.keywords = 1803 ret->data.ksk.keywords =
1803 GNUNET_new_array ((ent + tok_keywords + paren_keywords) * 3, char *); 1804 GNUNET_new_array ((ent + tok_keywords + paren_keywords) * 3, char *);
1804 GNUNET_CONTAINER_meta_data_iterate (md, &gather_uri_data, ret); 1805 GNUNET_FS_meta_data_iterate (md, &gather_uri_data, ret);
1805 } 1806 }
1806 if (tok_keywords > 0) 1807 if (tok_keywords > 0)
1807 ret->data.ksk.keywordCount += 1808 ret->data.ksk.keywordCount +=
diff --git a/src/fs/gnunet-daemon-fsprofiler.c b/src/fs/gnunet-daemon-fsprofiler.c
index fbb7c6028..b99933cfa 100644
--- a/src/fs/gnunet-daemon-fsprofiler.c
+++ b/src/fs/gnunet-daemon-fsprofiler.c
@@ -27,6 +27,7 @@
27 * - how to signal driver that we're done? 27 * - how to signal driver that we're done?
28 */ 28 */
29#include "platform.h" 29#include "platform.h"
30
30#include "gnunet_fs_service.h" 31#include "gnunet_fs_service.h"
31#include "gnunet_statistics_service.h" 32#include "gnunet_statistics_service.h"
32 33
diff --git a/src/fs/gnunet-directory.c b/src/fs/gnunet-directory.c
index ef5c40ae2..ab9f2905a 100644
--- a/src/fs/gnunet-directory.c
+++ b/src/fs/gnunet-directory.c
@@ -23,6 +23,7 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26
26#include "gnunet_fs_service.h" 27#include "gnunet_fs_service.h"
27 28
28static int ret; 29static int ret;
@@ -90,20 +91,20 @@ static void
90print_entry (void *cls, 91print_entry (void *cls,
91 const char *filename, 92 const char *filename,
92 const struct GNUNET_FS_Uri *uri, 93 const struct GNUNET_FS_Uri *uri,
93 const struct GNUNET_CONTAINER_MetaData *meta, 94 const struct GNUNET_FS_MetaData *meta,
94 size_t length, 95 size_t length,
95 const void *data) 96 const void *data)
96{ 97{
97 char *string; 98 char *string;
98 char *name; 99 char *name;
99 100
100 name = GNUNET_CONTAINER_meta_data_get_by_type ( 101 name = GNUNET_FS_meta_data_get_by_type (
101 meta, 102 meta,
102 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 103 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
103 if (uri == NULL) 104 if (uri == NULL)
104 { 105 {
105 printf (_ ("Directory `%s' meta data:\n"), name ? name : ""); 106 printf (_ ("Directory `%s' meta data:\n"), name ? name : "");
106 GNUNET_CONTAINER_meta_data_iterate (meta, &item_printer, NULL); 107 GNUNET_FS_meta_data_iterate (meta, &item_printer, NULL);
107 printf ("\n"); 108 printf ("\n");
108 printf (_ ("Directory `%s' contents:\n"), name ? name : ""); 109 printf (_ ("Directory `%s' contents:\n"), name ? name : "");
109 GNUNET_free (name); 110 GNUNET_free (name);
@@ -112,7 +113,7 @@ print_entry (void *cls,
112 string = GNUNET_FS_uri_to_string (uri); 113 string = GNUNET_FS_uri_to_string (uri);
113 printf ("%s (%s):\n", name ? name : "", string); 114 printf ("%s (%s):\n", name ? name : "", string);
114 GNUNET_free (string); 115 GNUNET_free (string);
115 GNUNET_CONTAINER_meta_data_iterate (meta, &item_printer, NULL); 116 GNUNET_FS_meta_data_iterate (meta, &item_printer, NULL);
116 printf ("\n"); 117 printf ("\n");
117 GNUNET_free (name); 118 GNUNET_free (name);
118} 119}
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c
index eebf8e993..4694077e9 100644
--- a/src/fs/gnunet-download.c
+++ b/src/fs/gnunet-download.c
@@ -26,6 +26,7 @@
26 * @author Igor Wronsky 26 * @author Igor Wronsky
27 */ 27 */
28#include "platform.h" 28#include "platform.h"
29
29#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
30 31
31static int ret; 32static int ret;
diff --git a/src/fs/gnunet-fs.c b/src/fs/gnunet-fs.c
index 0f8f02a1c..21e3c4a40 100644
--- a/src/fs/gnunet-fs.c
+++ b/src/fs/gnunet-fs.c
@@ -23,6 +23,7 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26
26#include "gnunet_fs_service.h" 27#include "gnunet_fs_service.h"
27 28
28/** 29/**
diff --git a/src/fs/gnunet-helper-fs-publish.c b/src/fs/gnunet-helper-fs-publish.c
index ef1a9ce4b..0e07b79dc 100644
--- a/src/fs/gnunet-helper-fs-publish.c
+++ b/src/fs/gnunet-helper-fs-publish.c
@@ -27,6 +27,7 @@
27 * and report the results to stdout. 27 * and report the results to stdout.
28 */ 28 */
29#include "platform.h" 29#include "platform.h"
30
30#include "gnunet_fs_service.h" 31#include "gnunet_fs_service.h"
31 32
32 33
@@ -120,7 +121,7 @@ add_to_md (void *cls,
120 const char *data, 121 const char *data,
121 size_t data_len) 122 size_t data_len)
122{ 123{
123 struct GNUNET_CONTAINER_MetaData *md = cls; 124 struct GNUNET_FS_MetaData *md = cls;
124 125
125 if (((EXTRACTOR_METAFORMAT_UTF8 == format) || 126 if (((EXTRACTOR_METAFORMAT_UTF8 == format) ||
126 (EXTRACTOR_METAFORMAT_C_STRING == format)) && 127 (EXTRACTOR_METAFORMAT_C_STRING == format)) &&
@@ -129,23 +130,23 @@ add_to_md (void *cls,
129 char zdata[data_len + 1]; 130 char zdata[data_len + 1];
130 GNUNET_memcpy (zdata, data, data_len); 131 GNUNET_memcpy (zdata, data, data_len);
131 zdata[data_len] = '\0'; 132 zdata[data_len] = '\0';
132 (void) GNUNET_CONTAINER_meta_data_insert (md, 133 (void) GNUNET_FS_meta_data_insert (md,
133 plugin_name, 134 plugin_name,
134 type, 135 type,
135 format, 136 format,
136 data_mime_type, 137 data_mime_type,
137 zdata, 138 zdata,
138 data_len + 1); 139 data_len + 1);
139 } 140 }
140 else 141 else
141 { 142 {
142 (void) GNUNET_CONTAINER_meta_data_insert (md, 143 (void) GNUNET_FS_meta_data_insert (md,
143 plugin_name, 144 plugin_name,
144 type, 145 type,
145 format, 146 format,
146 data_mime_type, 147 data_mime_type,
147 data, 148 data,
148 data_len); 149 data_len);
149 } 150 }
150 return 0; 151 return 0;
151} 152}
@@ -373,7 +374,7 @@ preprocess_file (const char *filename, struct ScanTreeNode **dst)
373static int 374static int
374extract_files (struct ScanTreeNode *item) 375extract_files (struct ScanTreeNode *item)
375{ 376{
376 struct GNUNET_CONTAINER_MetaData *meta; 377 struct GNUNET_FS_MetaData *meta;
377 ssize_t size; 378 ssize_t size;
378 size_t slen; 379 size_t slen;
379 380
@@ -390,16 +391,16 @@ extract_files (struct ScanTreeNode *item)
390 } 391 }
391 392
392 /* this is the expensive operation, *afterwards* we'll check for aborts */ 393 /* this is the expensive operation, *afterwards* we'll check for aborts */
393 meta = GNUNET_CONTAINER_meta_data_create (); 394 meta = GNUNET_FS_meta_data_create ();
394#if HAVE_LIBEXTRACTOR 395#if HAVE_LIBEXTRACTOR
395 EXTRACTOR_extract (plugins, item->filename, NULL, 0, &add_to_md, meta); 396 EXTRACTOR_extract (plugins, item->filename, NULL, 0, &add_to_md, meta);
396#endif 397#endif
397 slen = strlen (item->filename) + 1; 398 slen = strlen (item->filename) + 1;
398 size = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); 399 size = GNUNET_FS_meta_data_get_serialized_size (meta);
399 if (-1 == size) 400 if (-1 == size)
400 { 401 {
401 /* no meta data */ 402 /* no meta data */
402 GNUNET_CONTAINER_meta_data_destroy (meta); 403 GNUNET_FS_meta_data_destroy (meta);
403 if (GNUNET_OK != 404 if (GNUNET_OK !=
404 write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA, 405 write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA,
405 item->filename, 406 item->filename,
@@ -417,17 +418,17 @@ extract_files (struct ScanTreeNode *item)
417 char *dst = &buf[slen]; 418 char *dst = &buf[slen];
418 419
419 GNUNET_memcpy (buf, item->filename, slen); 420 GNUNET_memcpy (buf, item->filename, slen);
420 size = GNUNET_CONTAINER_meta_data_serialize ( 421 size = GNUNET_FS_meta_data_serialize (
421 meta, 422 meta,
422 &dst, 423 &dst,
423 size, 424 size,
424 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); 425 GNUNET_FS_META_DATA_SERIALIZE_PART);
425 if (size < 0) 426 if (size < 0)
426 { 427 {
427 GNUNET_break (0); 428 GNUNET_break (0);
428 size = 0; 429 size = 0;
429 } 430 }
430 GNUNET_CONTAINER_meta_data_destroy (meta); 431 GNUNET_FS_meta_data_destroy (meta);
431 if (GNUNET_OK != 432 if (GNUNET_OK !=
432 write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA, 433 write_message (GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA,
433 buf, 434 buf,
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c
index c62edcd61..59f16210a 100644
--- a/src/fs/gnunet-publish.c
+++ b/src/fs/gnunet-publish.c
@@ -26,6 +26,7 @@
26 * @author Igor Wronsky 26 * @author Igor Wronsky
27 */ 27 */
28#include "platform.h" 28#include "platform.h"
29
29#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
30#include "gnunet_identity_service.h" 31#include "gnunet_identity_service.h"
31 32
@@ -57,7 +58,7 @@ static struct GNUNET_FS_PublishContext *pc;
57/** 58/**
58 * Meta-data provided via command-line option. 59 * Meta-data provided via command-line option.
59 */ 60 */
60static struct GNUNET_CONTAINER_MetaData *meta; 61static struct GNUNET_FS_MetaData *meta;
61 62
62/** 63/**
63 * Keywords provided via command-line option. 64 * Keywords provided via command-line option.
@@ -175,7 +176,7 @@ do_stop_task (void *cls)
175 } 176 }
176 if (NULL != meta) 177 if (NULL != meta)
177 { 178 {
178 GNUNET_CONTAINER_meta_data_destroy (meta); 179 GNUNET_FS_meta_data_destroy (meta);
179 meta = NULL; 180 meta = NULL;
180 } 181 }
181 if (NULL != uri) 182 if (NULL != uri)
@@ -376,7 +377,7 @@ static int
376publish_inspector (void *cls, 377publish_inspector (void *cls,
377 struct GNUNET_FS_FileInformation *fi, 378 struct GNUNET_FS_FileInformation *fi,
378 uint64_t length, 379 uint64_t length,
379 struct GNUNET_CONTAINER_MetaData *m, 380 struct GNUNET_FS_MetaData *m,
380 struct GNUNET_FS_Uri **uri, 381 struct GNUNET_FS_Uri **uri,
381 struct GNUNET_FS_BlockOptions *bo, 382 struct GNUNET_FS_BlockOptions *bo,
382 int *do_index, 383 int *do_index,
@@ -410,20 +411,20 @@ publish_inspector (void *cls,
410 } 411 }
411 if (NULL != meta) 412 if (NULL != meta)
412 { 413 {
413 GNUNET_CONTAINER_meta_data_merge (m, meta); 414 GNUNET_FS_meta_data_merge (m, meta);
414 GNUNET_CONTAINER_meta_data_destroy (meta); 415 GNUNET_FS_meta_data_destroy (meta);
415 meta = NULL; 416 meta = NULL;
416 } 417 }
417 if (enable_creation_time) 418 if (enable_creation_time)
418 GNUNET_CONTAINER_meta_data_add_publication_date (m); 419 GNUNET_FS_meta_data_add_publication_date (m);
419 if (extract_only) 420 if (extract_only)
420 { 421 {
421 fn = GNUNET_CONTAINER_meta_data_get_by_type ( 422 fn = GNUNET_FS_meta_data_get_by_type (
422 m, 423 m,
423 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 424 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
424 fs = GNUNET_STRINGS_byte_size_fancy (length); 425 fs = GNUNET_STRINGS_byte_size_fancy (length);
425 fprintf (stdout, _ ("Meta data for file `%s' (%s)\n"), fn, fs); 426 fprintf (stdout, _ ("Meta data for file `%s' (%s)\n"), fn, fs);
426 GNUNET_CONTAINER_meta_data_iterate (m, &meta_printer, NULL); 427 GNUNET_FS_meta_data_iterate (m, &meta_printer, NULL);
427 fprintf (stdout, _ ("Keywords for file `%s' (%s)\n"), fn, fs); 428 fprintf (stdout, _ ("Keywords for file `%s' (%s)\n"), fn, fs);
428 GNUNET_free (fn); 429 GNUNET_free (fn);
429 GNUNET_free (fs); 430 GNUNET_free (fs);
@@ -521,11 +522,11 @@ get_file_information (struct GNUNET_FS_ShareTreeItem *item)
521 if (GNUNET_YES == item->is_directory) 522 if (GNUNET_YES == item->is_directory)
522 { 523 {
523 if (NULL == item->meta) 524 if (NULL == item->meta)
524 item->meta = GNUNET_CONTAINER_meta_data_create (); 525 item->meta = GNUNET_FS_meta_data_create ();
525 GNUNET_CONTAINER_meta_data_delete (item->meta, 526 GNUNET_FS_meta_data_delete (item->meta,
526 EXTRACTOR_METATYPE_MIMETYPE, 527 EXTRACTOR_METATYPE_MIMETYPE,
527 NULL, 528 NULL,
528 0); 529 0);
529 GNUNET_FS_meta_data_make_directory (item->meta); 530 GNUNET_FS_meta_data_make_directory (item->meta);
530 if (NULL == item->ksk_uri) 531 if (NULL == item->ksk_uri)
531 { 532 {
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c
index 54f0095ea..a72cf97cc 100644
--- a/src/fs/gnunet-search.c
+++ b/src/fs/gnunet-search.c
@@ -26,15 +26,16 @@
26 * @author Igor Wronsky 26 * @author Igor Wronsky
27 * @author madmurphy 27 * @author madmurphy
28 */ 28 */
29#include "platform.h"
29#include <ctype.h> 30#include <ctype.h>
30#include <inttypes.h> 31#include <inttypes.h>
31#include <limits.h> 32#include <limits.h>
32#include "platform.h" 33
33#include "gnunet_fs_service.h" 34#include "gnunet_fs_service.h"
34 35
35 36
36#define GNUNET_SEARCH_log(kind, ...) \ 37#define GNUNET_SEARCH_log(kind, ...) \
37 GNUNET_log_from(kind, "gnunet-search", __VA_ARGS__) 38 GNUNET_log_from (kind, "gnunet-search", __VA_ARGS__)
38 39
39 40
40/* The default settings that we use for the printed output */ 41/* The default settings that we use for the printed output */
@@ -61,14 +62,16 @@
61#define GENERIC_FILE_MIMETYPE "application/octet-stream" 62#define GENERIC_FILE_MIMETYPE "application/octet-stream"
62 63
63 64
64enum GNUNET_SEARCH_MetadataPrinterFlags { 65enum GNUNET_SEARCH_MetadataPrinterFlags
66{
65 METADATA_PRINTER_FLAG_NONE = 0, 67 METADATA_PRINTER_FLAG_NONE = 0,
66 METADATA_PRINTER_FLAG_ONE_RUN = 1, 68 METADATA_PRINTER_FLAG_ONE_RUN = 1,
67 METADATA_PRINTER_FLAG_HAVE_TYPE = 2 69 METADATA_PRINTER_FLAG_HAVE_TYPE = 2
68}; 70};
69 71
70 72
71struct GNUNET_SEARCH_MetadataPrinterInfo { 73struct GNUNET_SEARCH_MetadataPrinterInfo
74{
72 unsigned int counter; 75 unsigned int counter;
73 unsigned int flags; 76 unsigned int flags;
74 int type; 77 int type;
@@ -132,7 +135,7 @@ static const char *
132print_escape_sequence (const char *const esc) 135print_escape_sequence (const char *const esc)
133{ 136{
134 unsigned int probe; 137 unsigned int probe;
135 const char * cursor = esc + 1; 138 const char *cursor = esc + 1;
136 char tmp; 139 char tmp;
137 switch (*cursor) 140 switch (*cursor)
138 { 141 {
@@ -150,7 +153,7 @@ print_escape_sequence (const char *const esc)
150 /* Possibly hexadecimal code point */ 153 /* Possibly hexadecimal code point */
151 case 'x': 154 case 'x':
152 probe = 0; 155 probe = 0;
153 while (probe < 256 && isxdigit((tmp = *++cursor))) 156 while (probe < 256 && isxdigit ((tmp = *++cursor)))
154 probe = (probe << 4) + tmp - (tmp > 96 ? 87 : tmp > 64 ? 55 : 48); 157 probe = (probe << 4) + tmp - (tmp > 96 ? 87 : tmp > 64 ? 55 : 48);
155 goto maybe_codepoint; 158 goto maybe_codepoint;
156 159
@@ -167,7 +170,7 @@ print_escape_sequence (const char *const esc)
167 default: printf ("\\%c", *cursor); return cursor + 1; 170 default: printf ("\\%c", *cursor); return cursor + 1;
168 } 171 }
169 172
170maybe_codepoint: 173 maybe_codepoint:
171 if (probe < 256) 174 if (probe < 256)
172 putchar (probe); 175 putchar (probe);
173 else 176 else
@@ -212,31 +215,31 @@ item_printer (void *const cls,
212 return 0; 215 return 0;
213 216
214 const char *cursor = meta_format_string; 217 const char *cursor = meta_format_string;
215 const char *next_spec = strchr(cursor, '%'); 218 const char *next_spec = strchr (cursor, '%');
216 const char *next_esc = strchr(cursor, '\\'); 219 const char *next_esc = strchr (cursor, '\\');
217 220
218parse_format: 221 parse_format:
219 222
220 /* If an escape sequence exists before the next format specifier... */ 223 /* If an escape sequence exists before the next format specifier... */
221 if (next_esc && (!next_spec || next_esc < next_spec)) 224 if (next_esc && (! next_spec || next_esc < next_spec))
222 { 225 {
223 if (next_esc > cursor) 226 if (next_esc > cursor)
224 fwrite (cursor, 1, next_esc - cursor, stdout); 227 fwrite (cursor, 1, next_esc - cursor, stdout);
225 228
226 cursor = print_escape_sequence (next_esc); 229 cursor = print_escape_sequence (next_esc);
227 next_esc = strchr(cursor, '\\'); 230 next_esc = strchr (cursor, '\\');
228 goto parse_format; 231 goto parse_format;
229 } 232 }
230 233
231 /* If a format specifier exists before the next escape sequence... */ 234 /* If a format specifier exists before the next escape sequence... */
232 if (next_spec && (!next_esc || next_spec < next_esc)) 235 if (next_spec && (! next_esc || next_spec < next_esc))
233 { 236 {
234 if (next_spec > cursor) 237 if (next_spec > cursor)
235 fwrite (cursor, 1, next_spec - cursor, stdout); 238 fwrite (cursor, 1, next_spec - cursor, stdout);
236 239
237 switch (*++next_spec) 240 switch (*++next_spec)
238 { 241 {
239 case '%': putchar('%'); break; 242 case '%': putchar ('%'); break;
240 case 'i': printf ("%d", type); break; 243 case 'i': printf ("%d", type); break;
241 case 'l': printf ("%lu", (long unsigned int) data_size); break; 244 case 'l': printf ("%lu", (long unsigned int) data_size); break;
242 case 'n': printf ("%u", info->counter); break; 245 case 'n': printf ("%u", info->counter); break;
@@ -249,11 +252,11 @@ parse_format:
249 break; 252 break;
250#endif 253#endif
251 case 'w': printf ("%s", plugin_name); break; 254 case 'w': printf ("%s", plugin_name); break;
252 case '\0': putchar('%'); return 0; 255 case '\0': putchar ('%'); return 0;
253 default: printf ("%%%c", *next_spec); break; 256 default: printf ("%%%c", *next_spec); break;
254 } 257 }
255 cursor = next_spec + 1; 258 cursor = next_spec + 1;
256 next_spec = strchr(cursor, '%'); 259 next_spec = strchr (cursor, '%');
257 goto parse_format; 260 goto parse_format;
258 } 261 }
259 262
@@ -270,7 +273,7 @@ parse_format:
270 * 273 *
271 * @param filename the filename for this result 274 * @param filename the filename for this result
272 * @param uri the `struct GNUNET_FS_Uri` this result refers to 275 * @param uri the `struct GNUNET_FS_Uri` this result refers to
273 * @param metadata the `struct GNUNET_CONTAINER_MetaData` associated with this 276 * @param metadata the `struct GNUNET_FS_MetaData` associated with this
274 result 277 result
275 * @param resultnum the result number 278 * @param resultnum the result number
276 * @param is_directory GNUNET_YES if this is a directory, otherwise GNUNET_NO 279 * @param is_directory GNUNET_YES if this is a directory, otherwise GNUNET_NO
@@ -279,34 +282,34 @@ parse_format:
279static void 282static void
280print_search_result (const char *const filename, 283print_search_result (const char *const filename,
281 const struct GNUNET_FS_Uri *const uri, 284 const struct GNUNET_FS_Uri *const uri,
282 const struct GNUNET_CONTAINER_MetaData *const metadata, 285 const struct GNUNET_FS_MetaData *const metadata,
283 const unsigned int resultnum, 286 const unsigned int resultnum,
284 const int is_directory) 287 const int is_directory)
285{ 288{
286 289
287 const char *cursor = GNUNET_YES == is_directory ? 290 const char *cursor = GNUNET_YES == is_directory ?
288 dir_format_string 291 dir_format_string
289 : format_string; 292 : format_string;
290 293
291 const char *next_spec = strchr(cursor, '%'); 294 const char *next_spec = strchr (cursor, '%');
292 const char *next_esc = strchr(cursor, '\\'); 295 const char *next_esc = strchr (cursor, '\\');
293 char *placeholder; 296 char *placeholder;
294 struct GNUNET_SEARCH_MetadataPrinterInfo info; 297 struct GNUNET_SEARCH_MetadataPrinterInfo info;
295 298
296parse_format: 299 parse_format:
297 /* If an escape sequence exists before the next format specifier... */ 300 /* If an escape sequence exists before the next format specifier... */
298 if (next_esc && (!next_spec || next_esc < next_spec)) 301 if (next_esc && (! next_spec || next_esc < next_spec))
299 { 302 {
300 if (next_esc > cursor) 303 if (next_esc > cursor)
301 fwrite (cursor, 1, next_esc - cursor, stdout); 304 fwrite (cursor, 1, next_esc - cursor, stdout);
302 305
303 cursor = print_escape_sequence (next_esc); 306 cursor = print_escape_sequence (next_esc);
304 next_esc = strchr(cursor, '\\'); 307 next_esc = strchr (cursor, '\\');
305 goto parse_format; 308 goto parse_format;
306 } 309 }
307 310
308 /* If a format specifier exists before the next escape sequence... */ 311 /* If a format specifier exists before the next escape sequence... */
309 if (next_spec && (!next_esc || next_spec < next_esc)) 312 if (next_spec && (! next_esc || next_spec < next_esc))
310 { 313 {
311 if (next_spec > cursor) 314 if (next_spec > cursor)
312 fwrite (cursor, 1, next_spec - cursor, stdout); 315 fwrite (cursor, 1, next_spec - cursor, stdout);
@@ -317,9 +320,9 @@ parse_format:
317 case 'a': 320 case 'a':
318 info.flags = METADATA_PRINTER_FLAG_NONE; 321 info.flags = METADATA_PRINTER_FLAG_NONE;
319 322
320iterate_meta: 323 iterate_meta:
321 info.counter = 0; 324 info.counter = 0;
322 GNUNET_CONTAINER_meta_data_iterate (metadata, &item_printer, &info); 325 GNUNET_FS_meta_data_iterate (metadata, &item_printer, &info);
323 break; 326 break;
324 /* File's name */ 327 /* File's name */
325 case 'f': 328 case 'f':
@@ -337,11 +340,11 @@ iterate_meta:
337 /* File name's length */ 340 /* File name's length */
338 case 'l': 341 case 'l':
339 printf ("%lu", 342 printf ("%lu",
340 (long unsigned int) ( GNUNET_YES == is_directory ? 343 (long unsigned int) (GNUNET_YES == is_directory ?
341 strlen(filename) + 344 strlen (filename)
342 (sizeof(GNUNET_FS_DIRECTORY_EXT) - 1) 345 + (sizeof(GNUNET_FS_DIRECTORY_EXT) - 1)
343 : 346 :
344 strlen(filename))); 347 strlen (filename)));
345 break; 348 break;
346 /* File's mime type */ 349 /* File's mime type */
347 case 'm': 350 case 'm':
@@ -350,7 +353,7 @@ iterate_meta:
350 printf ("%s", GNUNET_FS_DIRECTORY_MIME); 353 printf ("%s", GNUNET_FS_DIRECTORY_MIME);
351 break; 354 break;
352 } 355 }
353 placeholder = GNUNET_CONTAINER_meta_data_get_by_type ( 356 placeholder = GNUNET_FS_meta_data_get_by_type (
354 metadata, 357 metadata,
355 EXTRACTOR_METATYPE_MIMETYPE); 358 EXTRACTOR_METATYPE_MIMETYPE);
356 printf ("%s", placeholder ? placeholder : GENERIC_FILE_MIMETYPE); 359 printf ("%s", placeholder ? placeholder : GENERIC_FILE_MIMETYPE);
@@ -376,7 +379,7 @@ iterate_meta:
376 case '5': case '6': case '7': case '8': case '9': 379 case '5': case '6': case '7': case '8': case '9':
377 cursor = next_spec; 380 cursor = next_spec;
378 info.type = *cursor - 48; 381 info.type = *cursor - 48;
379 while (isdigit(*++cursor) && info.type < (INT_MAX - *cursor + 48) / 10) 382 while (isdigit (*++cursor) && info.type < (INT_MAX - *cursor + 48) / 10)
380 info.type = info.type * 10 + *cursor - 48; 383 info.type = info.type * 10 + *cursor - 48;
381 if (info.type == 0 || *cursor != '#') 384 if (info.type == 0 || *cursor != '#')
382 goto not_a_specifier; 385 goto not_a_specifier;
@@ -391,21 +394,21 @@ iterate_meta:
391 /* Only the first metadata field of type `info.type` */ 394 /* Only the first metadata field of type `info.type` */
392 case 'j': 395 case 'j':
393 next_spec = cursor; 396 next_spec = cursor;
394 info.flags = METADATA_PRINTER_FLAG_HAVE_TYPE | 397 info.flags = METADATA_PRINTER_FLAG_HAVE_TYPE
395 METADATA_PRINTER_FLAG_ONE_RUN; 398 | METADATA_PRINTER_FLAG_ONE_RUN;
396 goto iterate_meta; 399 goto iterate_meta;
397 } 400 }
398 goto not_a_specifier; 401 goto not_a_specifier;
399 402
400 /* All other cases */ 403 /* All other cases */
401 case '%': putchar('%'); break; 404 case '%': putchar ('%'); break;
402 case '\0': putchar('%'); return; 405 case '\0': putchar ('%'); return;
403 406
404not_a_specifier: 407 not_a_specifier:
405 default: printf ("%%%c", *next_spec); break; 408 default: printf ("%%%c", *next_spec); break;
406 } 409 }
407 cursor = next_spec + 1; 410 cursor = next_spec + 1;
408 next_spec = strchr(cursor, '%'); 411 next_spec = strchr (cursor, '%');
409 goto parse_format; 412 goto parse_format;
410 } 413 }
411 414
@@ -439,10 +442,10 @@ clean_task (void *const cls)
439 GNUNET_DISK_PERM_USER_READ 442 GNUNET_DISK_PERM_USER_READ
440 | GNUNET_DISK_PERM_USER_WRITE)) 443 | GNUNET_DISK_PERM_USER_WRITE))
441 { 444 {
442 GNUNET_SEARCH_log(GNUNET_ERROR_TYPE_ERROR, 445 GNUNET_SEARCH_log (GNUNET_ERROR_TYPE_ERROR,
443 _ ("Failed to write directory with search results to " 446 _ ("Failed to write directory with search results to "
444 "`%s'\n"), 447 "`%s'\n"),
445 output_filename); 448 output_filename);
446 } 449 }
447 GNUNET_free (ddata); 450 GNUNET_free (ddata);
448 GNUNET_free (output_filename); 451 GNUNET_free (output_filename);
@@ -490,7 +493,7 @@ progress_cb (void *const cls,
490 break; 493 break;
491 494
492 cnt++; 495 cnt++;
493 filename = GNUNET_CONTAINER_meta_data_get_by_type ( 496 filename = GNUNET_FS_meta_data_get_by_type (
494 info->value.search.specifics.result.meta, 497 info->value.search.specifics.result.meta,
495 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 498 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
496 is_directory = GNUNET_FS_meta_data_test_for_directory ( 499 is_directory = GNUNET_FS_meta_data_test_for_directory (
@@ -501,12 +504,12 @@ progress_cb (void *const cls,
501 filename[strlen (filename) - 1] = '\0'; 504 filename[strlen (filename) - 1] = '\0';
502 GNUNET_DISK_filename_canonicalize (filename); 505 GNUNET_DISK_filename_canonicalize (filename);
503 } 506 }
504 print_search_result ( filename ? 507 print_search_result (filename ?
505 filename 508 filename
506 : is_directory ? 509 : is_directory ?
507 GENERIC_DIRECTORY_NAME 510 GENERIC_DIRECTORY_NAME
508 : 511 :
509 GENERIC_FILE_NAME, 512 GENERIC_FILE_NAME,
510 info->value.search.specifics.result.uri, 513 info->value.search.specifics.result.uri,
511 info->value.search.specifics.result.meta, 514 info->value.search.specifics.result.meta,
512 cnt, 515 cnt,
@@ -528,9 +531,9 @@ progress_cb (void *const cls,
528 break; 531 break;
529 532
530 case GNUNET_FS_STATUS_SEARCH_ERROR: 533 case GNUNET_FS_STATUS_SEARCH_ERROR:
531 GNUNET_SEARCH_log(GNUNET_ERROR_TYPE_ERROR, 534 GNUNET_SEARCH_log (GNUNET_ERROR_TYPE_ERROR,
532 _ ("Error searching: %s.\n"), 535 _ ("Error searching: %s.\n"),
533 info->value.search.specifics.error.message); 536 info->value.search.specifics.error.message);
534 GNUNET_SCHEDULER_shutdown (); 537 GNUNET_SCHEDULER_shutdown ();
535 break; 538 break;
536 539
@@ -539,9 +542,9 @@ progress_cb (void *const cls,
539 break; 542 break;
540 543
541 default: 544 default:
542 GNUNET_SEARCH_log(GNUNET_ERROR_TYPE_ERROR, 545 GNUNET_SEARCH_log (GNUNET_ERROR_TYPE_ERROR,
543 _ ("Unexpected status: %d\n"), 546 _ ("Unexpected status: %d\n"),
544 info->status); 547 info->status);
545 break; 548 break;
546 } 549 }
547 return NULL; 550 return NULL;
@@ -600,7 +603,7 @@ run (void *const cls,
600 ret = 1; 603 ret = 1;
601 return; 604 return;
602 } 605 }
603 if (silent_mode && !output_filename) 606 if (silent_mode && ! output_filename)
604 { 607 {
605 fprintf (stderr, _ ("An output file is mandatory for silent mode.\n")); 608 fprintf (stderr, _ ("An output file is mandatory for silent mode.\n"));
606 ret = 1; 609 ret = 1;
@@ -627,7 +630,7 @@ run (void *const cls,
627 ret = 1; 630 ret = 1;
628 return; 631 return;
629 } 632 }
630 if (!GNUNET_FS_uri_test_ksk (uri) && !GNUNET_FS_uri_test_sks (uri)) 633 if (! GNUNET_FS_uri_test_ksk (uri) && ! GNUNET_FS_uri_test_sks (uri))
631 { 634 {
632 fprintf (stderr, 635 fprintf (stderr,
633 "%s", 636 "%s",
@@ -640,7 +643,7 @@ run (void *const cls,
640 } 643 }
641 if (bookmark_only) 644 if (bookmark_only)
642 { 645 {
643 char * bmstr = GNUNET_FS_uri_to_string (uri); 646 char *bmstr = GNUNET_FS_uri_to_string (uri);
644 printf ("%s\n", bmstr); 647 printf ("%s\n", bmstr);
645 GNUNET_free (bmstr); 648 GNUNET_free (bmstr);
646 GNUNET_FS_uri_destroy (uri); 649 GNUNET_FS_uri_destroy (uri);
@@ -779,15 +782,15 @@ main (int argc, char *const *argv)
779 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 782 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
780 return 12; 783 return 12;
781 784
782 if (GNUNET_SYSERR == 785 if (GNUNET_SYSERR ==
783 GNUNET_PROGRAM_run (argc, 786 GNUNET_PROGRAM_run (argc,
784 argv, 787 argv,
785 "gnunet-search [OPTIONS] KEYWORD1 KEYWORD2 ...", 788 "gnunet-search [OPTIONS] KEYWORD1 KEYWORD2 ...",
786 gettext_noop ("Search for files that have been " 789 gettext_noop ("Search for files that have been "
787 "published on GNUnet\n"), 790 "published on GNUnet\n"),
788 options, 791 options,
789 &run, 792 &run,
790 NULL)) 793 NULL))
791 ret = 1; 794 ret = 1;
792 795
793 GNUNET_free_nz ((void *) argv); 796 GNUNET_free_nz ((void *) argv);
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 7da92ed44..597e89e14 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -30,7 +30,6 @@
30#include "gnunet_dht_service.h" 30#include "gnunet_dht_service.h"
31#include "gnunet_datastore_service.h" 31#include "gnunet_datastore_service.h"
32#include "gnunet_load_lib.h" 32#include "gnunet_load_lib.h"
33#include "gnunet_peer_lib.h"
34#include "gnunet_protocols.h" 33#include "gnunet_protocols.h"
35#include "gnunet_signatures.h" 34#include "gnunet_signatures.h"
36#include "gnunet_statistics_service.h" 35#include "gnunet_statistics_service.h"
diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c
index b88cbe365..8fb34c067 100644
--- a/src/fs/gnunet-service-fs_indexing.c
+++ b/src/fs/gnunet-service-fs_indexing.c
@@ -27,7 +27,6 @@
27#include <float.h> 27#include <float.h>
28#include "gnunet_core_service.h" 28#include "gnunet_core_service.h"
29#include "gnunet_datastore_service.h" 29#include "gnunet_datastore_service.h"
30#include "gnunet_peer_lib.h"
31#include "gnunet_protocols.h" 30#include "gnunet_protocols.h"
32#include "gnunet_signatures.h" 31#include "gnunet_signatures.h"
33#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
diff --git a/src/fs/gnunet-service-fs_indexing.h b/src/fs/gnunet-service-fs_indexing.h
index 546dbb172..244a51900 100644
--- a/src/fs/gnunet-service-fs_indexing.h
+++ b/src/fs/gnunet-service-fs_indexing.h
@@ -29,7 +29,6 @@
29#include "gnunet_block_lib.h" 29#include "gnunet_block_lib.h"
30#include "gnunet_core_service.h" 30#include "gnunet_core_service.h"
31#include "gnunet_datastore_service.h" 31#include "gnunet_datastore_service.h"
32#include "gnunet_peer_lib.h"
33#include "gnunet_protocols.h" 32#include "gnunet_protocols.h"
34#include "gnunet_signatures.h" 33#include "gnunet_signatures.h"
35#include "gnunet_util_lib.h" 34#include "gnunet_util_lib.h"
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c
index afc547127..326f75a63 100644
--- a/src/fs/gnunet-unindex.c
+++ b/src/fs/gnunet-unindex.c
@@ -26,6 +26,7 @@
26 * @author Igor Wronsky 26 * @author Igor Wronsky
27 */ 27 */
28#include "platform.h" 28#include "platform.h"
29
29#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
30 31
31static int ret; 32static int ret;
diff --git a/src/util/container_meta_data.c b/src/fs/meta_data.c
index 52882c5f3..7112a150a 100644
--- a/src/util/container_meta_data.c
+++ b/src/fs/meta_data.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010 GNUnet e.V. 3 Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2022 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 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 6 under the terms of the GNU Affero General Public License as published
@@ -19,103 +19,28 @@
19 */ 19 */
20 20
21/** 21/**
22 * @file util/container_meta_data.c 22 * @file fs/meta_data.c
23 * @brief Storing of meta data 23 * @brief Storing of meta data
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * @author Martin Schanzenbach
25 */ 26 */
26 27
28
27#include "platform.h" 29#include "platform.h"
28#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
29#if HAVE_EXTRACTOR_H
30#include <extractor.h>
31#endif
32#include <zlib.h>
33
34#define LOG(kind, ...) GNUNET_log_from (kind, "util-container-meta-data", \
35 __VA_ARGS__)
36 31
32#include "gnunet_fs_service.h"
37 33
38/** 34/**
39 * Try to compress the given block of data using libz. Only returns 35 * Maximum size allowed for meta data written/read from disk.
40 * the compressed block if compression worked and the new block is 36 * File-sharing limits to 64k, so this should be rather generous.
41 * actually smaller. Decompress using #GNUNET_decompress().
42 *
43 * @param data block to compress; if compression
44 * resulted in a smaller block, the first
45 * bytes of data are updated to the compressed
46 * data
47 * @param old_size number of bytes in data
48 * @param[out] result set to the compressed data, if compression worked
49 * @param[out] new_size set to size of result, if compression worked
50 * @return #GNUNET_YES if compression reduce the size,
51 * #GNUNET_NO if compression did not help
52 */ 37 */
53int 38#define MAX_META_DATA (1024 * 1024)
54GNUNET_try_compression (const char *data,
55 size_t old_size,
56 char **result,
57 size_t *new_size)
58{
59 char *tmp;
60 uLongf dlen;
61
62 *result = NULL;
63 *new_size = 0;
64#ifdef compressBound
65 dlen = compressBound (old_size);
66#else
67 dlen = old_size + (old_size / 100) + 20;
68 /* documentation says 100.1% oldSize + 12 bytes, but we
69 * should be able to overshoot by more to be safe */
70#endif
71 tmp = GNUNET_malloc (dlen);
72 if (Z_OK ==
73 compress2 ((Bytef *) tmp,
74 &dlen,
75 (const Bytef *) data,
76 old_size, 9))
77 {
78 if (dlen < old_size)
79 {
80 *result = tmp;
81 *new_size = dlen;
82 return GNUNET_YES;
83 }
84 }
85 GNUNET_free (tmp);
86 return GNUNET_NO;
87}
88 39
89 40
90/** 41#define LOG(kind, ...) GNUNET_log_from (kind, "fs-meta-data", \
91 * Decompress input, return the decompressed data as output. Dual to 42 __VA_ARGS__)
92 * #GNUNET_try_compression(). Caller must set @a output_size to the 43
93 * number of bytes that were originally compressed.
94 *
95 * @param input compressed data
96 * @param input_size number of bytes in input
97 * @param output_size expected size of the output
98 * @return NULL on error, buffer of @a output_size decompressed bytes otherwise
99 */
100char *
101GNUNET_decompress (const char *input,
102 size_t input_size,
103 size_t output_size)
104{
105 char *output;
106 uLongf olen;
107
108 olen = output_size;
109 output = GNUNET_malloc (olen);
110 if (Z_OK ==
111 uncompress ((Bytef *) output,
112 &olen,
113 (const Bytef *) input,
114 input_size))
115 return output;
116 GNUNET_free (output);
117 return NULL;
118}
119 44
120 45
121/** 46/**
@@ -167,7 +92,7 @@ struct MetaItem
167/** 92/**
168 * Meta data to associate with a file, directory or namespace. 93 * Meta data to associate with a file, directory or namespace.
169 */ 94 */
170struct GNUNET_CONTAINER_MetaData 95struct GNUNET_FS_MetaData
171{ 96{
172 /** 97 /**
173 * Head of linked list of the meta data items. 98 * Head of linked list of the meta data items.
@@ -198,14 +123,14 @@ struct GNUNET_CONTAINER_MetaData
198 123
199 124
200/** 125/**
201 * Create a fresh struct CONTAINER_MetaData token. 126 * Create a fresh struct FS_MetaData token.
202 * 127 *
203 * @return empty meta-data container 128 * @return empty meta-data container
204 */ 129 */
205struct GNUNET_CONTAINER_MetaData * 130struct GNUNET_FS_MetaData *
206GNUNET_CONTAINER_meta_data_create () 131GNUNET_FS_meta_data_create ()
207{ 132{
208 return GNUNET_new (struct GNUNET_CONTAINER_MetaData); 133 return GNUNET_new (struct GNUNET_FS_MetaData);
209} 134}
210 135
211 136
@@ -231,7 +156,7 @@ meta_item_free (struct MetaItem *mi)
231 * @param md meta data that changed 156 * @param md meta data that changed
232 */ 157 */
233static void 158static void
234invalidate_sbuf (struct GNUNET_CONTAINER_MetaData *md) 159invalidate_sbuf (struct GNUNET_FS_MetaData *md)
235{ 160{
236 if (NULL == md->sbuf) 161 if (NULL == md->sbuf)
237 return; 162 return;
@@ -242,7 +167,7 @@ invalidate_sbuf (struct GNUNET_CONTAINER_MetaData *md)
242 167
243 168
244void 169void
245GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md) 170GNUNET_FS_meta_data_destroy (struct GNUNET_FS_MetaData *md)
246{ 171{
247 struct MetaItem *pos; 172 struct MetaItem *pos;
248 173
@@ -259,7 +184,7 @@ GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md)
259 184
260 185
261void 186void
262GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md) 187GNUNET_FS_meta_data_clear (struct GNUNET_FS_MetaData *md)
263{ 188{
264 struct MetaItem *mi; 189 struct MetaItem *mi;
265 190
@@ -271,15 +196,15 @@ GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md)
271 meta_item_free (mi); 196 meta_item_free (mi);
272 } 197 }
273 GNUNET_free (md->sbuf); 198 GNUNET_free (md->sbuf);
274 memset (md, 0, sizeof(struct GNUNET_CONTAINER_MetaData)); 199 memset (md, 0, sizeof(struct GNUNET_FS_MetaData));
275} 200}
276 201
277 202
278int 203int
279GNUNET_CONTAINER_meta_data_test_equal (const struct GNUNET_CONTAINER_MetaData 204GNUNET_FS_meta_data_test_equal (const struct GNUNET_FS_MetaData
280 *md1, 205 *md1,
281 const struct GNUNET_CONTAINER_MetaData 206 const struct GNUNET_FS_MetaData
282 *md2) 207 *md2)
283{ 208{
284 struct MetaItem *i; 209 struct MetaItem *i;
285 struct MetaItem *j; 210 struct MetaItem *j;
@@ -330,12 +255,12 @@ GNUNET_CONTAINER_meta_data_test_equal (const struct GNUNET_CONTAINER_MetaData
330 * data_mime_type and plugin_name are not considered for "exists" checks 255 * data_mime_type and plugin_name are not considered for "exists" checks
331 */ 256 */
332int 257int
333GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, 258GNUNET_FS_meta_data_insert (struct GNUNET_FS_MetaData *md,
334 const char *plugin_name, 259 const char *plugin_name,
335 enum EXTRACTOR_MetaType type, 260 enum EXTRACTOR_MetaType type,
336 enum EXTRACTOR_MetaFormat format, 261 enum EXTRACTOR_MetaFormat format,
337 const char *data_mime_type, const char *data, 262 const char *data_mime_type, const char *data,
338 size_t data_size) 263 size_t data_size)
339{ 264{
340 struct MetaItem *pos; 265 struct MetaItem *pos;
341 struct MetaItem *mi; 266 struct MetaItem *mi;
@@ -405,7 +330,7 @@ GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md,
405/** 330/**
406 * Merge given meta data. 331 * Merge given meta data.
407 * 332 *
408 * @param cls the `struct GNUNET_CONTAINER_MetaData` to merge into 333 * @param cls the `struct GNUNET_FS_MetaData` to merge into
409 * @param plugin_name name of the plugin that produced this value; 334 * @param plugin_name name of the plugin that produced this value;
410 * special values can be used (e.g. '&lt;zlib&gt;' for zlib being 335 * special values can be used (e.g. '&lt;zlib&gt;' for zlib being
411 * used in the main libextractor library and yielding 336 * used in the main libextractor library and yielding
@@ -423,26 +348,26 @@ merge_helper (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type,
423 enum EXTRACTOR_MetaFormat format, const char *data_mime_type, 348 enum EXTRACTOR_MetaFormat format, const char *data_mime_type,
424 const char *data, size_t data_size) 349 const char *data, size_t data_size)
425{ 350{
426 struct GNUNET_CONTAINER_MetaData *md = cls; 351 struct GNUNET_FS_MetaData *md = cls;
427 352
428 (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format, 353 (void) GNUNET_FS_meta_data_insert (md, plugin_name, type, format,
429 data_mime_type, data, data_size); 354 data_mime_type, data, data_size);
430 return 0; 355 return 0;
431} 356}
432 357
433 358
434void 359void
435GNUNET_CONTAINER_meta_data_merge (struct GNUNET_CONTAINER_MetaData *md, 360GNUNET_FS_meta_data_merge (struct GNUNET_FS_MetaData *md,
436 const struct GNUNET_CONTAINER_MetaData *in) 361 const struct GNUNET_FS_MetaData *in)
437{ 362{
438 GNUNET_CONTAINER_meta_data_iterate (in, &merge_helper, md); 363 GNUNET_FS_meta_data_iterate (in, &merge_helper, md);
439} 364}
440 365
441 366
442int 367int
443GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md, 368GNUNET_FS_meta_data_delete (struct GNUNET_FS_MetaData *md,
444 enum EXTRACTOR_MetaType type, 369 enum EXTRACTOR_MetaType type,
445 const char *data, size_t data_size) 370 const char *data, size_t data_size)
446{ 371{
447 struct MetaItem *pos; 372 struct MetaItem *pos;
448 373
@@ -467,21 +392,21 @@ GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md,
467 392
468 393
469void 394void
470GNUNET_CONTAINER_meta_data_add_publication_date (struct 395GNUNET_FS_meta_data_add_publication_date (struct
471 GNUNET_CONTAINER_MetaData *md) 396 GNUNET_FS_MetaData *md)
472{ 397{
473 const char *dat; 398 const char *dat;
474 struct GNUNET_TIME_Absolute t; 399 struct GNUNET_TIME_Absolute t;
475 400
476 t = GNUNET_TIME_absolute_get (); 401 t = GNUNET_TIME_absolute_get ();
477 GNUNET_CONTAINER_meta_data_delete (md, 402 GNUNET_FS_meta_data_delete (md,
478 EXTRACTOR_METATYPE_PUBLICATION_DATE, 403 EXTRACTOR_METATYPE_PUBLICATION_DATE,
479 NULL, 0); 404 NULL, 0);
480 dat = GNUNET_STRINGS_absolute_time_to_string (t); 405 dat = GNUNET_STRINGS_absolute_time_to_string (t);
481 GNUNET_CONTAINER_meta_data_insert (md, "<gnunet>", 406 GNUNET_FS_meta_data_insert (md, "<gnunet>",
482 EXTRACTOR_METATYPE_PUBLICATION_DATE, 407 EXTRACTOR_METATYPE_PUBLICATION_DATE,
483 EXTRACTOR_METAFORMAT_UTF8, "text/plain", 408 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
484 dat, strlen (dat) + 1); 409 dat, strlen (dat) + 1);
485} 410}
486 411
487 412
@@ -494,9 +419,9 @@ GNUNET_CONTAINER_meta_data_add_publication_date (struct
494 * @return number of entries 419 * @return number of entries
495 */ 420 */
496int 421int
497GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md, 422GNUNET_FS_meta_data_iterate (const struct GNUNET_FS_MetaData *md,
498 EXTRACTOR_MetaDataProcessor iter, 423 EXTRACTOR_MetaDataProcessor iter,
499 void *iter_cls) 424 void *iter_cls)
500{ 425{
501 struct MetaItem *pos; 426 struct MetaItem *pos;
502 427
@@ -514,9 +439,9 @@ GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md,
514 439
515 440
516char * 441char *
517GNUNET_CONTAINER_meta_data_get_by_type (const struct 442GNUNET_FS_meta_data_get_by_type (const struct
518 GNUNET_CONTAINER_MetaData *md, 443 GNUNET_FS_MetaData *md,
519 enum EXTRACTOR_MetaType type) 444 enum EXTRACTOR_MetaType type)
520{ 445{
521 struct MetaItem *pos; 446 struct MetaItem *pos;
522 447
@@ -532,9 +457,9 @@ GNUNET_CONTAINER_meta_data_get_by_type (const struct
532 457
533 458
534char * 459char *
535GNUNET_CONTAINER_meta_data_get_first_by_types (const struct 460GNUNET_FS_meta_data_get_first_by_types (const struct
536 GNUNET_CONTAINER_MetaData *md, 461 GNUNET_FS_MetaData *md,
537 ...) 462 ...)
538{ 463{
539 char *ret; 464 char *ret;
540 va_list args; 465 va_list args;
@@ -549,7 +474,7 @@ GNUNET_CONTAINER_meta_data_get_first_by_types (const struct
549 type = va_arg (args, int); 474 type = va_arg (args, int);
550 if (-1 == type) 475 if (-1 == type)
551 break; 476 break;
552 if (NULL != (ret = GNUNET_CONTAINER_meta_data_get_by_type (md, type))) 477 if (NULL != (ret = GNUNET_FS_meta_data_get_by_type (md, type)))
553 break; 478 break;
554 } 479 }
555 va_end (args); 480 va_end (args);
@@ -566,8 +491,8 @@ GNUNET_CONTAINER_meta_data_get_first_by_types (const struct
566 * @return number of bytes in thumbnail, 0 if not available 491 * @return number of bytes in thumbnail, 0 if not available
567 */ 492 */
568size_t 493size_t
569GNUNET_CONTAINER_meta_data_get_thumbnail (const struct GNUNET_CONTAINER_MetaData 494GNUNET_FS_meta_data_get_thumbnail (const struct GNUNET_FS_MetaData
570 *md, unsigned char **thumb) 495 *md, unsigned char **thumb)
571{ 496{
572 struct MetaItem *pos; 497 struct MetaItem *pos;
573 struct MetaItem *match; 498 struct MetaItem *match;
@@ -597,25 +522,25 @@ GNUNET_CONTAINER_meta_data_get_thumbnail (const struct GNUNET_CONTAINER_MetaData
597 522
598 523
599/** 524/**
600 * Duplicate a `struct GNUNET_CONTAINER_MetaData`. 525 * Duplicate a `struct GNUNET_FS_MetaData`.
601 * 526 *
602 * @param md what to duplicate 527 * @param md what to duplicate
603 * @return duplicate meta-data container 528 * @return duplicate meta-data container
604 */ 529 */
605struct GNUNET_CONTAINER_MetaData * 530struct GNUNET_FS_MetaData *
606GNUNET_CONTAINER_meta_data_duplicate (const struct GNUNET_CONTAINER_MetaData 531GNUNET_FS_meta_data_duplicate (const struct GNUNET_FS_MetaData
607 *md) 532 *md)
608{ 533{
609 struct GNUNET_CONTAINER_MetaData *ret; 534 struct GNUNET_FS_MetaData *ret;
610 struct MetaItem *pos; 535 struct MetaItem *pos;
611 536
612 if (NULL == md) 537 if (NULL == md)
613 return NULL; 538 return NULL;
614 ret = GNUNET_CONTAINER_meta_data_create (); 539 ret = GNUNET_FS_meta_data_create ();
615 for (pos = md->items_tail; NULL != pos; pos = pos->prev) 540 for (pos = md->items_tail; NULL != pos; pos = pos->prev)
616 GNUNET_CONTAINER_meta_data_insert (ret, pos->plugin_name, pos->type, 541 GNUNET_FS_meta_data_insert (ret, pos->plugin_name, pos->type,
617 pos->format, pos->mime_type, pos->data, 542 pos->format, pos->mime_type, pos->data,
618 pos->data_size); 543 pos->data_size);
619 return ret; 544 return ret;
620} 545}
621 546
@@ -713,13 +638,13 @@ struct MetaDataEntry
713 * space) 638 * space)
714 */ 639 */
715ssize_t 640ssize_t
716GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData 641GNUNET_FS_meta_data_serialize (const struct GNUNET_FS_MetaData
717 *md, char **target, size_t max, 642 *md, char **target, size_t max,
718 enum 643 enum
719 GNUNET_CONTAINER_MetaDataSerializationOptions 644 GNUNET_FS_MetaDataSerializationOptions
720 opt) 645 opt)
721{ 646{
722 struct GNUNET_CONTAINER_MetaData *vmd; 647 struct GNUNET_FS_MetaData *vmd;
723 struct MetaItem *pos; 648 struct MetaItem *pos;
724 struct MetaDataHeader ihdr; 649 struct MetaDataHeader ihdr;
725 struct MetaDataHeader *hdr; 650 struct MetaDataHeader *hdr;
@@ -753,7 +678,7 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
753 GNUNET_memcpy (*target, md->sbuf, md->sbuf_size); 678 GNUNET_memcpy (*target, md->sbuf, md->sbuf_size);
754 return md->sbuf_size; 679 return md->sbuf_size;
755 } 680 }
756 if (0 == (opt & GNUNET_CONTAINER_META_DATA_SERIALIZE_PART)) 681 if (0 == (opt & GNUNET_FS_META_DATA_SERIALIZE_PART))
757 return GNUNET_SYSERR; /* can say that this will fail */ 682 return GNUNET_SYSERR; /* can say that this will fail */
758 /* need to compute a partial serialization, sbuf useless ... */ 683 /* need to compute a partial serialization, sbuf useless ... */
759 } 684 }
@@ -820,7 +745,7 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
820 for (pos = md->items_head; NULL != pos; pos = pos->next) 745 for (pos = md->items_head; NULL != pos; pos = pos->next)
821 { 746 {
822 comp = GNUNET_NO; 747 comp = GNUNET_NO;
823 if (0 == (opt & GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS)) 748 if (0 == (opt & GNUNET_FS_META_DATA_SERIALIZE_NO_COMPRESS))
824 comp = GNUNET_try_compression ((const char *) &ent[i], 749 comp = GNUNET_try_compression ((const char *) &ent[i],
825 left, 750 left,
826 &cdata, 751 &cdata,
@@ -831,7 +756,7 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
831 /* fill 'sbuf'; this "modifies" md, but since this is only 756 /* fill 'sbuf'; this "modifies" md, but since this is only
832 * an internal cache we will cast away the 'const' instead 757 * an internal cache we will cast away the 'const' instead
833 * of making the API look strange. */ 758 * of making the API look strange. */
834 vmd = (struct GNUNET_CONTAINER_MetaData *) md; 759 vmd = (struct GNUNET_FS_MetaData *) md;
835 hdr = GNUNET_malloc (left + sizeof(struct MetaDataHeader)); 760 hdr = GNUNET_malloc (left + sizeof(struct MetaDataHeader));
836 hdr->size = htonl (left); 761 hdr->size = htonl (left);
837 hdr->entries = htonl (md->item_count); 762 hdr->entries = htonl (md->item_count);
@@ -896,7 +821,7 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
896 return rlen; 821 return rlen;
897 } 822 }
898 823
899 if (0 == (opt & GNUNET_CONTAINER_META_DATA_SERIALIZE_PART)) 824 if (0 == (opt & GNUNET_FS_META_DATA_SERIALIZE_PART))
900 { 825 {
901 /* does not fit! */ 826 /* does not fit! */
902 GNUNET_free (ent); 827 GNUNET_free (ent);
@@ -934,8 +859,8 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
934 859
935 860
936ssize_t 861ssize_t
937GNUNET_CONTAINER_meta_data_get_serialized_size (const struct 862GNUNET_FS_meta_data_get_serialized_size (const struct
938 GNUNET_CONTAINER_MetaData *md) 863 GNUNET_FS_MetaData *md)
939{ 864{
940 ssize_t ret; 865 ssize_t ret;
941 char *ptr; 866 char *ptr;
@@ -944,8 +869,8 @@ GNUNET_CONTAINER_meta_data_get_serialized_size (const struct
944 return md->sbuf_size; 869 return md->sbuf_size;
945 ptr = NULL; 870 ptr = NULL;
946 ret = 871 ret =
947 GNUNET_CONTAINER_meta_data_serialize (md, &ptr, GNUNET_MAX_MALLOC_CHECKED, 872 GNUNET_FS_meta_data_serialize (md, &ptr, GNUNET_MAX_MALLOC_CHECKED,
948 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); 873 GNUNET_FS_META_DATA_SERIALIZE_FULL);
949 if (-1 != ret) 874 if (-1 != ret)
950 GNUNET_free (ptr); 875 GNUNET_free (ptr);
951 return ret; 876 return ret;
@@ -960,10 +885,10 @@ GNUNET_CONTAINER_meta_data_get_serialized_size (const struct
960 * @return MD on success, NULL on error (i.e. 885 * @return MD on success, NULL on error (i.e.
961 * bad format) 886 * bad format)
962 */ 887 */
963struct GNUNET_CONTAINER_MetaData * 888struct GNUNET_FS_MetaData *
964GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size) 889GNUNET_FS_meta_data_deserialize (const char *input, size_t size)
965{ 890{
966 struct GNUNET_CONTAINER_MetaData *md; 891 struct GNUNET_FS_MetaData *md;
967 struct MetaDataHeader hdr; 892 struct MetaDataHeader hdr;
968 struct MetaDataEntry ent; 893 struct MetaDataEntry ent;
969 uint32_t ic; 894 uint32_t ic;
@@ -1038,7 +963,7 @@ GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size)
1038 } 963 }
1039 } 964 }
1040 965
1041 md = GNUNET_CONTAINER_meta_data_create (); 966 md = GNUNET_FS_meta_data_create ();
1042 left = dataSize - ic * sizeof(struct MetaDataEntry); 967 left = dataSize - ic * sizeof(struct MetaDataEntry);
1043 mdata = &cdata[ic * sizeof(struct MetaDataEntry)]; 968 mdata = &cdata[ic * sizeof(struct MetaDataEntry)];
1044 for (i = 0; i < ic; i++) 969 for (i = 0; i < ic; i++)
@@ -1108,14 +1033,200 @@ GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size)
1108 mime_type = NULL; 1033 mime_type = NULL;
1109 else 1034 else
1110 mime_type = &mdata[left]; 1035 mime_type = &mdata[left];
1111 GNUNET_CONTAINER_meta_data_insert (md, plugin_name, 1036 GNUNET_FS_meta_data_insert (md, plugin_name,
1112 (enum EXTRACTOR_MetaType) 1037 (enum EXTRACTOR_MetaType)
1113 ntohl (ent.type), format, mime_type, 1038 ntohl (ent.type), format, mime_type,
1114 meta_data, dlen); 1039 meta_data, dlen);
1115 } 1040 }
1116 GNUNET_free (data); 1041 GNUNET_free (data);
1117 return md; 1042 return md;
1118} 1043}
1119 1044
1045/**
1046 * Read a metadata container.
1047 *
1048 * @param h handle to an open file
1049 * @param what describes what is being read (for error message creation)
1050 * @param result the buffer to store a pointer to the (allocated) metadata
1051 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
1052 */
1053int
1054GNUNET_FS_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
1055 const char *what,
1056 struct GNUNET_FS_MetaData **result)
1057{
1058 uint32_t size;
1059 char *buf;
1060 char *emsg;
1061 struct GNUNET_FS_MetaData *meta;
1062
1063 if (GNUNET_OK != GNUNET_BIO_read_int32 (h,
1064 _ ("metadata length"),
1065 (int32_t *) &size))
1066 return GNUNET_SYSERR;
1067 if (0 == size)
1068 {
1069 *result = NULL;
1070 return GNUNET_OK;
1071 }
1072 if (MAX_META_DATA < size)
1073 {
1074 GNUNET_asprintf (&emsg,
1075 _ (
1076 "Serialized metadata `%s' larger than allowed (%u > %u)\n"),
1077 what,
1078 size,
1079 MAX_META_DATA);
1080 GNUNET_BIO_read_set_error (h, emsg);
1081 GNUNET_free (emsg);
1082 return GNUNET_SYSERR;
1083 }
1084 buf = GNUNET_malloc (size);
1085 if (GNUNET_OK != GNUNET_BIO_read (h, what, buf, size))
1086 {
1087 GNUNET_free (buf);
1088 return GNUNET_SYSERR;
1089 }
1090 meta = GNUNET_FS_meta_data_deserialize (buf, size);
1091 if (NULL == meta)
1092 {
1093 GNUNET_free (buf);
1094 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1095 _ ("Failed to deserialize metadata `%s'"), what);
1096 return GNUNET_SYSERR;
1097 }
1098 GNUNET_free (buf);
1099 *result = meta;
1100 return GNUNET_OK;
1101}
1102
1103/**
1104 * Write a metadata container.
1105 *
1106 * @param h the IO handle to write to
1107 * @param what what is being written (for error message creation)
1108 * @param m metadata to write
1109 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
1110 */
1111enum GNUNET_GenericReturnValue
1112GNUNET_FS_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
1113 const char *what,
1114 const struct GNUNET_FS_MetaData *m)
1115{
1116 ssize_t size;
1117 char *buf;
1118
1119 if (m == NULL)
1120 return GNUNET_BIO_write_int32 (h, _ ("metadata length"), 0);
1121 buf = NULL;
1122 size = GNUNET_FS_meta_data_serialize (m,
1123 &buf,
1124 MAX_META_DATA,
1125 GNUNET_FS_META_DATA_SERIALIZE_PART);
1126 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1127 _ ("Serialized %ld bytes of metadata"),
1128 size);
1129
1130 if (-1 == size)
1131 {
1132 GNUNET_free (buf);
1133 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1134 _ ("Failed to serialize metadata `%s'"),
1135 what);
1136 return GNUNET_SYSERR;
1137 }
1138 if ((GNUNET_OK != GNUNET_BIO_write_int32 (h,
1139 _ ("metadata length"),
1140 (uint32_t) size))
1141 || (GNUNET_OK != GNUNET_BIO_write (h, what, buf, size)))
1142 {
1143 GNUNET_free (buf);
1144 return GNUNET_SYSERR;
1145 }
1146 GNUNET_free (buf);
1147 return GNUNET_OK;
1148}
1149
1150/**
1151 * Function used internally to read a metadata container from within a read
1152 * spec.
1153 *
1154 * @param cls ignored, always NULL
1155 * @param h the IO handle to read from
1156 * @param what what is being read (for error message creation)
1157 * @param target where to store the data
1158 * @param target_size ignored
1159 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
1160 */
1161static int
1162read_spec_handler_meta_data (void *cls,
1163 struct GNUNET_BIO_ReadHandle *h,
1164 const char *what,
1165 void *target,
1166 size_t target_size)
1167{
1168 struct GNUNET_FS_MetaData **result = target;
1169 return GNUNET_FS_read_meta_data (h, what, result);
1170}
1171
1172/**
1173 * Create the specification to read a metadata container.
1174 *
1175 * @param what describes what is being read (for error message creation)
1176 * @param result the buffer to store a pointer to the (allocated) metadata
1177 * @return the read spec
1178 */
1179struct GNUNET_BIO_ReadSpec
1180GNUNET_FS_read_spec_meta_data (const char *what,
1181 struct GNUNET_FS_MetaData **result)
1182{
1183 struct GNUNET_BIO_ReadSpec rs = {
1184 .rh = &read_spec_handler_meta_data,
1185 .cls = NULL,
1186 .target = result,
1187 .size = 0,
1188 };
1189
1190 return rs;
1191}
1192
1193/**
1194 * Function used internally to write a metadata container from within a write
1195 * spec.
1196 *
1197 * @param cls ignored, always NULL
1198 * @param h the IO handle to write to
1199 * @param what what is being written (for error message creation)
1200 * @param source the data to write
1201 * @param source_size ignored
1202 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
1203 */
1204static int
1205write_spec_handler_meta_data (void *cls,
1206 struct GNUNET_BIO_WriteHandle *h,
1207 const char *what,
1208 void *source,
1209 size_t source_size)
1210{
1211 const struct GNUNET_FS_MetaData *m = source;
1212 return GNUNET_FS_write_meta_data (h, what, m);
1213}
1214
1215
1216struct GNUNET_BIO_WriteSpec
1217GNUNET_FS_write_spec_meta_data (const char *what,
1218 const struct GNUNET_FS_MetaData *m)
1219{
1220 struct GNUNET_BIO_WriteSpec ws = {
1221 .wh = &write_spec_handler_meta_data,
1222 .cls = NULL,
1223 .what = what,
1224 .source = (void *) m,
1225 .source_size = 0,
1226 };
1227
1228 return ws;
1229}
1230
1120 1231
1121/* end of container_meta_data.c */ 1232/* end of meta_data.c */
diff --git a/src/fs/plugin_block_fs.c b/src/fs/plugin_block_fs.c
index 11677a6b2..bbd0ff57b 100644
--- a/src/fs/plugin_block_fs.c
+++ b/src/fs/plugin_block_fs.c
@@ -25,6 +25,7 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_block_plugin.h" 27#include "gnunet_block_plugin.h"
28
28#include "gnunet_fs_service.h" 29#include "gnunet_fs_service.h"
29#include "block_fs.h" 30#include "block_fs.h"
30#include "gnunet_signatures.h" 31#include "gnunet_signatures.h"
diff --git a/src/fs/test_fs_directory.c b/src/fs/test_fs_directory.c
index 908e7c555..f5121a3e7 100644
--- a/src/fs/test_fs_directory.c
+++ b/src/fs/test_fs_directory.c
@@ -36,14 +36,14 @@
36struct PCLS 36struct PCLS
37{ 37{
38 struct GNUNET_FS_Uri **uri; 38 struct GNUNET_FS_Uri **uri;
39 struct GNUNET_CONTAINER_MetaData **md; 39 struct GNUNET_FS_MetaData **md;
40 unsigned int pos; 40 unsigned int pos;
41 unsigned int max; 41 unsigned int max;
42}; 42};
43 43
44static void 44static void
45processor (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri, 45processor (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri,
46 const struct GNUNET_CONTAINER_MetaData *md, size_t length, 46 const struct GNUNET_FS_MetaData *md, size_t length,
47 const void *data) 47 const void *data)
48{ 48{
49 struct PCLS *p = cls; 49 struct PCLS *p = cls;
@@ -53,7 +53,7 @@ processor (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri,
53 return; /* ignore directory's meta data */ 53 return; /* ignore directory's meta data */
54 for (i = 0; i < p->max; i++) 54 for (i = 0; i < p->max; i++)
55 { 55 {
56 if (GNUNET_CONTAINER_meta_data_test_equal (p->md[i], md) && 56 if (GNUNET_FS_meta_data_test_equal (p->md[i], md) &&
57 GNUNET_FS_uri_test_equal (p->uri[i], uri)) 57 GNUNET_FS_uri_test_equal (p->uri[i], uri))
58 { 58 {
59 p->pos++; 59 p->pos++;
@@ -71,8 +71,8 @@ testDirectory (unsigned int i)
71 char *data; 71 char *data;
72 size_t dlen; 72 size_t dlen;
73 struct GNUNET_FS_Uri **uris; 73 struct GNUNET_FS_Uri **uris;
74 struct GNUNET_CONTAINER_MetaData **mds; 74 struct GNUNET_FS_MetaData **mds;
75 struct GNUNET_CONTAINER_MetaData *meta; 75 struct GNUNET_FS_MetaData *meta;
76 struct PCLS cls; 76 struct PCLS cls;
77 char *emsg; 77 char *emsg;
78 int p; 78 int p;
@@ -85,29 +85,29 @@ testDirectory (unsigned int i)
85 85
86 cls.max = i; 86 cls.max = i;
87 uris = GNUNET_malloc (sizeof(struct GNUNET_FS_Uri *) * i); 87 uris = GNUNET_malloc (sizeof(struct GNUNET_FS_Uri *) * i);
88 mds = GNUNET_malloc (sizeof(struct GNUNET_CONTAINER_MetaData *) * i); 88 mds = GNUNET_malloc (sizeof(struct GNUNET_FS_MetaData *) * i);
89 meta = GNUNET_CONTAINER_meta_data_create (); 89 meta = GNUNET_FS_meta_data_create ();
90 GNUNET_CONTAINER_meta_data_insert (meta, "<test>", EXTRACTOR_METATYPE_TITLE, 90 GNUNET_FS_meta_data_insert (meta, "<test>", EXTRACTOR_METATYPE_TITLE,
91 EXTRACTOR_METAFORMAT_UTF8, "text/plain", 91 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
92 "A title", strlen ("A title") + 1); 92 "A title", strlen ("A title") + 1);
93 GNUNET_CONTAINER_meta_data_insert (meta, "<test>", 93 GNUNET_FS_meta_data_insert (meta, "<test>",
94 EXTRACTOR_METATYPE_AUTHOR_NAME, 94 EXTRACTOR_METATYPE_AUTHOR_NAME,
95 EXTRACTOR_METAFORMAT_UTF8, "text/plain", 95 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
96 "An author", strlen ("An author") + 1); 96 "An author", strlen ("An author") + 1);
97 for (p = 0; p < i; p++) 97 for (p = 0; p < i; p++)
98 { 98 {
99 mds[p] = GNUNET_CONTAINER_meta_data_create (); 99 mds[p] = GNUNET_FS_meta_data_create ();
100 for (q = 0; q <= p; q++) 100 for (q = 0; q <= p; q++)
101 { 101 {
102 GNUNET_snprintf (txt, sizeof(txt), "%u -- %u\n", p, q); 102 GNUNET_snprintf (txt, sizeof(txt), "%u -- %u\n", p, q);
103 GNUNET_CONTAINER_meta_data_insert (mds[p], "<test>", 103 GNUNET_FS_meta_data_insert (mds[p], "<test>",
104#if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR 104#if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR
105 q % EXTRACTOR_metatype_get_max (), 105 q % EXTRACTOR_metatype_get_max (),
106#else 106#else
107 q % 128, 107 q % 128,
108#endif 108#endif
109 EXTRACTOR_METAFORMAT_UTF8, 109 EXTRACTOR_METAFORMAT_UTF8,
110 "text/plain", txt, strlen (txt) + 1); 110 "text/plain", txt, strlen (txt) + 1);
111 } 111 }
112 GNUNET_snprintf (uri, sizeof(uri), 112 GNUNET_snprintf (uri, sizeof(uri),
113 "gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.%u", 113 "gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.%u",
@@ -116,16 +116,16 @@ testDirectory (unsigned int i)
116 uris[p] = GNUNET_FS_uri_parse (uri, &emsg); 116 uris[p] = GNUNET_FS_uri_parse (uri, &emsg);
117 if (uris[p] == NULL) 117 if (uris[p] == NULL)
118 { 118 {
119 GNUNET_CONTAINER_meta_data_destroy (mds[p]); 119 GNUNET_FS_meta_data_destroy (mds[p]);
120 while (--p > 0) 120 while (--p > 0)
121 { 121 {
122 GNUNET_CONTAINER_meta_data_destroy (mds[p]); 122 GNUNET_FS_meta_data_destroy (mds[p]);
123 GNUNET_FS_uri_destroy (uris[p]); 123 GNUNET_FS_uri_destroy (uris[p]);
124 } 124 }
125 GNUNET_free (mds); 125 GNUNET_free (mds);
126 GNUNET_free (uris); 126 GNUNET_free (uris);
127 GNUNET_free (emsg); 127 GNUNET_free (emsg);
128 GNUNET_CONTAINER_meta_data_destroy (meta); 128 GNUNET_FS_meta_data_destroy (meta);
129 ABORT (); /* error in testcase */ 129 ABORT (); /* error in testcase */
130 } 130 }
131 GNUNET_assert (emsg == NULL); 131 GNUNET_assert (emsg == NULL);
@@ -150,10 +150,10 @@ testDirectory (unsigned int i)
150 GNUNET_assert (cls.pos == i); 150 GNUNET_assert (cls.pos == i);
151 } 151 }
152 GNUNET_free (data); 152 GNUNET_free (data);
153 GNUNET_CONTAINER_meta_data_destroy (meta); 153 GNUNET_FS_meta_data_destroy (meta);
154 for (p = 0; p < i; p++) 154 for (p = 0; p < i; p++)
155 { 155 {
156 GNUNET_CONTAINER_meta_data_destroy (mds[p]); 156 GNUNET_FS_meta_data_destroy (mds[p]);
157 GNUNET_FS_uri_destroy (uris[p]); 157 GNUNET_FS_uri_destroy (uris[p]);
158 } 158 }
159 GNUNET_free (uris); 159 GNUNET_free (uris);
diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c
index 2fe0da77c..fc6b32c0f 100644
--- a/src/fs/test_fs_download.c
+++ b/src/fs/test_fs_download.c
@@ -267,7 +267,7 @@ run (void *cls,
267 "down_bar", 267 "down_bar",
268 }; 268 };
269 char *buf; 269 char *buf;
270 struct GNUNET_CONTAINER_MetaData *meta; 270 struct GNUNET_FS_MetaData *meta;
271 struct GNUNET_FS_Uri *kuri; 271 struct GNUNET_FS_Uri *kuri;
272 struct GNUNET_FS_FileInformation *fi; 272 struct GNUNET_FS_FileInformation *fi;
273 size_t i; 273 size_t i;
@@ -286,7 +286,7 @@ run (void *cls,
286 buf = GNUNET_malloc (FILESIZE); 286 buf = GNUNET_malloc (FILESIZE);
287 for (i = 0; i < FILESIZE; i++) 287 for (i = 0; i < FILESIZE; i++)
288 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 288 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
289 meta = GNUNET_CONTAINER_meta_data_create (); 289 meta = GNUNET_FS_meta_data_create ();
290 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 290 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
291 bo.content_priority = 42; 291 bo.content_priority = 42;
292 bo.anonymity_level = anonymity_level; 292 bo.anonymity_level = anonymity_level;
@@ -322,7 +322,7 @@ run (void *cls,
322 indexed = GNUNET_NO; 322 indexed = GNUNET_NO;
323 } 323 }
324 GNUNET_FS_uri_destroy (kuri); 324 GNUNET_FS_uri_destroy (kuri);
325 GNUNET_CONTAINER_meta_data_destroy (meta); 325 GNUNET_FS_meta_data_destroy (meta);
326 GNUNET_assert (NULL != fi); 326 GNUNET_assert (NULL != fi);
327 timeout_kill = 327 timeout_kill =
328 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_kill_task, NULL); 328 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_kill_task, NULL);
diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c
index 35d4ed441..b66fefd6b 100644
--- a/src/fs/test_fs_download_persistence.c
+++ b/src/fs/test_fs_download_persistence.c
@@ -302,7 +302,7 @@ run (void *cls,
302 "down_bar", 302 "down_bar",
303 }; 303 };
304 char *buf; 304 char *buf;
305 struct GNUNET_CONTAINER_MetaData *meta; 305 struct GNUNET_FS_MetaData *meta;
306 struct GNUNET_FS_Uri *kuri; 306 struct GNUNET_FS_Uri *kuri;
307 struct GNUNET_FS_FileInformation *fi; 307 struct GNUNET_FS_FileInformation *fi;
308 size_t i; 308 size_t i;
@@ -315,7 +315,7 @@ run (void *cls,
315 buf = GNUNET_malloc (FILESIZE); 315 buf = GNUNET_malloc (FILESIZE);
316 for (i = 0; i < FILESIZE; i++) 316 for (i = 0; i < FILESIZE; i++)
317 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 317 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
318 meta = GNUNET_CONTAINER_meta_data_create (); 318 meta = GNUNET_FS_meta_data_create ();
319 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 319 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
320 bo.content_priority = 42; 320 bo.content_priority = 42;
321 bo.anonymity_level = 1; 321 bo.anonymity_level = 1;
@@ -325,7 +325,7 @@ run (void *cls,
325 FILESIZE, buf, kuri, meta, 325 FILESIZE, buf, kuri, meta,
326 GNUNET_NO, &bo); 326 GNUNET_NO, &bo);
327 GNUNET_FS_uri_destroy (kuri); 327 GNUNET_FS_uri_destroy (kuri);
328 GNUNET_CONTAINER_meta_data_destroy (meta); 328 GNUNET_FS_meta_data_destroy (meta);
329 GNUNET_assert (NULL != fi); 329 GNUNET_assert (NULL != fi);
330 timeout_kill = 330 timeout_kill =
331 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_kill_task, NULL); 331 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_kill_task, NULL);
diff --git a/src/fs/test_fs_file_information.c b/src/fs/test_fs_file_information.c
index 22013db27..15380bfc4 100644
--- a/src/fs/test_fs_file_information.c
+++ b/src/fs/test_fs_file_information.c
@@ -49,7 +49,7 @@
49 49
50static int 50static int
51mycleaner (void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, 51mycleaner (void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length,
52 struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, 52 struct GNUNET_FS_MetaData *meta, struct GNUNET_FS_Uri **uri,
53 struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info) 53 struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info)
54{ 54{
55 return GNUNET_OK; 55 return GNUNET_OK;
@@ -67,7 +67,7 @@ run (void *cls, char *const *args, const char *cfgfile,
67 char *fn1; 67 char *fn1;
68 char *fn2; 68 char *fn2;
69 char *buf; 69 char *buf;
70 struct GNUNET_CONTAINER_MetaData *meta; 70 struct GNUNET_FS_MetaData *meta;
71 struct GNUNET_FS_Uri *kuri; 71 struct GNUNET_FS_Uri *kuri;
72 struct GNUNET_FS_FileInformation *fi1; 72 struct GNUNET_FS_FileInformation *fi1;
73 struct GNUNET_FS_FileInformation *fi2; 73 struct GNUNET_FS_FileInformation *fi2;
@@ -100,7 +100,7 @@ run (void *cls, char *const *args, const char *cfgfile,
100 | GNUNET_DISK_PERM_USER_WRITE)); 100 | GNUNET_DISK_PERM_USER_WRITE));
101 GNUNET_free (buf); 101 GNUNET_free (buf);
102 102
103 meta = GNUNET_CONTAINER_meta_data_create (); 103 meta = GNUNET_FS_meta_data_create ();
104 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 104 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
105 bo.content_priority = 42; 105 bo.content_priority = 42;
106 bo.anonymity_level = 1; 106 bo.anonymity_level = 1;
@@ -125,7 +125,7 @@ run (void *cls, char *const *args, const char *cfgfile,
125 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); 125 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1));
126 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); 126 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2));
127 GNUNET_FS_uri_destroy (kuri); 127 GNUNET_FS_uri_destroy (kuri);
128 GNUNET_CONTAINER_meta_data_destroy (meta); 128 GNUNET_FS_meta_data_destroy (meta);
129 GNUNET_assert (NULL != fidir); 129 GNUNET_assert (NULL != fidir);
130 /* FIXME: test more of API! */ 130 /* FIXME: test more of API! */
131 GNUNET_FS_file_information_destroy (fidir, &mycleaner, NULL); 131 GNUNET_FS_file_information_destroy (fidir, &mycleaner, NULL);
diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c
index 2f04a017a..7e06c47f5 100644
--- a/src/fs/test_fs_list_indexed.c
+++ b/src/fs/test_fs_list_indexed.c
@@ -183,7 +183,7 @@ run (void *cls,
183 "down_bar", 183 "down_bar",
184 }; 184 };
185 char *buf; 185 char *buf;
186 struct GNUNET_CONTAINER_MetaData *meta; 186 struct GNUNET_FS_MetaData *meta;
187 struct GNUNET_FS_Uri *kuri; 187 struct GNUNET_FS_Uri *kuri;
188 struct GNUNET_FS_FileInformation *fi1; 188 struct GNUNET_FS_FileInformation *fi1;
189 struct GNUNET_FS_FileInformation *fi2; 189 struct GNUNET_FS_FileInformation *fi2;
@@ -216,7 +216,7 @@ run (void *cls,
216 | GNUNET_DISK_PERM_USER_WRITE)); 216 | GNUNET_DISK_PERM_USER_WRITE));
217 GNUNET_free (buf); 217 GNUNET_free (buf);
218 218
219 meta = GNUNET_CONTAINER_meta_data_create (); 219 meta = GNUNET_FS_meta_data_create ();
220 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 220 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
221 bo.content_priority = 42; 221 bo.content_priority = 42;
222 bo.anonymity_level = 1; 222 bo.anonymity_level = 1;
@@ -241,7 +241,7 @@ run (void *cls,
241 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); 241 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1));
242 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); 242 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2));
243 GNUNET_FS_uri_destroy (kuri); 243 GNUNET_FS_uri_destroy (kuri);
244 GNUNET_CONTAINER_meta_data_destroy (meta); 244 GNUNET_FS_meta_data_destroy (meta);
245 GNUNET_assert (NULL != fidir); 245 GNUNET_assert (NULL != fidir);
246 start = GNUNET_TIME_absolute_get (); 246 start = GNUNET_TIME_absolute_get ();
247 publish = 247 publish =
diff --git a/src/fs/test_fs_meta_data.c b/src/fs/test_fs_meta_data.c
new file mode 100644
index 000000000..4e7439d7b
--- /dev/null
+++ b/src/fs/test_fs_meta_data.c
@@ -0,0 +1,492 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2003, 2004, 2006, 2009, 2010, 2022 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file util/test_fs_meta_data.c
23 * @brief Test for fs_meta_data.c
24 * @author Christian Grothoff
25 * @author Martin Schanzenbach
26 */
27
28
29#include "platform.h"
30#include "gnunet_util_lib.h"
31
32#include "gnunet_fs_service.h"
33
34#define ABORT(m) { fprintf (stderr, "Error at %s:%d\n", __FILE__, __LINE__); \
35 if (m != NULL) GNUNET_FS_meta_data_destroy (m); \
36 return 1; }
37
38
39static int
40testMeta (int i)
41{
42 struct GNUNET_FS_MetaData *m;
43 char val[256];
44 char *sval;
45 int j;
46 unsigned int size;
47
48 m = GNUNET_FS_meta_data_create ();
49 if (GNUNET_OK !=
50 GNUNET_FS_meta_data_insert (m, "<test>", EXTRACTOR_METATYPE_TITLE,
51 EXTRACTOR_METAFORMAT_UTF8,
52 "text/plain", "TestTitle",
53 strlen ("TestTitle") + 1))
54 ABORT (m);
55 if (GNUNET_OK !=
56 GNUNET_FS_meta_data_insert (m, "<test>",
57 EXTRACTOR_METATYPE_AUTHOR_NAME,
58 EXTRACTOR_METAFORMAT_UTF8,
59 "text/plain", "TestTitle",
60 strlen ("TestTitle") + 1))
61 ABORT (m);
62 if (GNUNET_OK == GNUNET_FS_meta_data_insert (m, "<test>",
63 EXTRACTOR_METATYPE_TITLE,
64 EXTRACTOR_METAFORMAT_UTF8,
65 "text/plain",
66 "TestTitle", strlen (
67 "TestTitle") + 1)) /* dup! */
68 ABORT (m);
69 if (GNUNET_OK == GNUNET_FS_meta_data_insert (m, "<test>",
70 EXTRACTOR_METATYPE_AUTHOR_NAME,
71 EXTRACTOR_METAFORMAT_UTF8,
72 "text/plain",
73 "TestTitle", strlen (
74 "TestTitle") + 1)) /* dup! */
75 ABORT (m);
76 if (2 != GNUNET_FS_meta_data_iterate (m, NULL, NULL))
77 ABORT (m);
78 if (GNUNET_OK !=
79 GNUNET_FS_meta_data_delete (m, EXTRACTOR_METATYPE_AUTHOR_NAME,
80 "TestTitle", strlen ("TestTitle") + 1))
81 ABORT (m);
82 if (GNUNET_OK == GNUNET_FS_meta_data_delete (m,
83 EXTRACTOR_METATYPE_AUTHOR_NAME,
84 "TestTitle", strlen (
85 "TestTitle") + 1)) /* already gone */
86 ABORT (m);
87 if (1 != GNUNET_FS_meta_data_iterate (m, NULL, NULL))
88 ABORT (m);
89 if (GNUNET_OK !=
90 GNUNET_FS_meta_data_delete (m, EXTRACTOR_METATYPE_TITLE,
91 "TestTitle", strlen ("TestTitle") + 1))
92 ABORT (m);
93 if (GNUNET_OK == GNUNET_FS_meta_data_delete (m,
94 EXTRACTOR_METATYPE_TITLE,
95 "TestTitle", strlen (
96 "TestTitle") + 1)) /* already gone */
97 ABORT (m);
98 if (0 != GNUNET_FS_meta_data_iterate (m, NULL, NULL))
99 ABORT (m);
100 for (j = 0; j < i; j++)
101 {
102 GNUNET_snprintf (val, sizeof(val), "%s.%d",
103 "A teststring that should compress well.", j);
104 if (GNUNET_OK !=
105 GNUNET_FS_meta_data_insert (m, "<test>",
106 EXTRACTOR_METATYPE_UNKNOWN,
107 EXTRACTOR_METAFORMAT_UTF8,
108 "text/plain", val, strlen (val) + 1))
109 ABORT (m);
110 }
111 if (i != GNUNET_FS_meta_data_iterate (m, NULL, NULL))
112 ABORT (m);
113
114 size = GNUNET_FS_meta_data_get_serialized_size (m);
115 sval = NULL;
116 if (size !=
117 GNUNET_FS_meta_data_serialize (m, &sval, size,
118 GNUNET_FS_META_DATA_SERIALIZE_FULL))
119 {
120 GNUNET_free (sval);
121 ABORT (m);
122 }
123 GNUNET_FS_meta_data_destroy (m);
124 m = GNUNET_FS_meta_data_deserialize (sval, size);
125 GNUNET_free (sval);
126 if (m == NULL)
127 ABORT (m);
128 for (j = 0; j < i; j++)
129 {
130 GNUNET_snprintf (val,
131 sizeof(val),
132 "%s.%d",
133 "A teststring that should compress well.",
134 j);
135 if (GNUNET_OK !=
136 GNUNET_FS_meta_data_delete (m,
137 EXTRACTOR_METATYPE_UNKNOWN,
138 val,
139 strlen (val) + 1))
140 {
141 ABORT (m);
142 }
143 }
144 if (0 != GNUNET_FS_meta_data_iterate (m, NULL, NULL))
145 ABORT (m);
146 GNUNET_FS_meta_data_destroy (m);
147 return 0;
148}
149
150
151static int
152testMetaMore (int i)
153{
154 struct GNUNET_FS_MetaData *meta;
155 int q;
156 char txt[128];
157 char *data;
158 unsigned long long size;
159
160 meta = GNUNET_FS_meta_data_create ();
161 for (q = 0; q <= i; q++)
162 {
163 GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q);
164 GNUNET_FS_meta_data_insert (meta, "<test>",
165 q
166 % 42 /* EXTRACTOR_metatype_get_max () */,
167 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
168 txt, strlen (txt) + 1);
169 }
170 size = GNUNET_FS_meta_data_get_serialized_size (meta);
171 data = GNUNET_malloc (size * 4);
172 if (size !=
173 GNUNET_FS_meta_data_serialize (meta, &data, size * 4,
174 GNUNET_FS_META_DATA_SERIALIZE_FULL))
175 {
176 GNUNET_free (data);
177 ABORT (meta);
178 }
179 GNUNET_FS_meta_data_destroy (meta);
180 GNUNET_free (data);
181 return 0;
182}
183
184
185static int
186testMetaLink ()
187{
188 struct GNUNET_FS_MetaData *m;
189 char *val;
190 unsigned int size;
191
192 m = GNUNET_FS_meta_data_create ();
193 if (GNUNET_OK !=
194 GNUNET_FS_meta_data_insert (m, "<test>",
195 EXTRACTOR_METATYPE_UNKNOWN,
196 EXTRACTOR_METAFORMAT_UTF8,
197 "text/plain", "link",
198 strlen ("link") + 1))
199 ABORT (m);
200 if (GNUNET_OK !=
201 GNUNET_FS_meta_data_insert (m, "<test>",
202 EXTRACTOR_METATYPE_FILENAME,
203 EXTRACTOR_METAFORMAT_UTF8,
204 "text/plain", "lib-link.m4",
205 strlen ("lib-link.m4") + 1))
206 ABORT (m);
207 val = NULL;
208 size =
209 GNUNET_FS_meta_data_serialize (m, &val, (size_t) -1,
210 GNUNET_FS_META_DATA_SERIALIZE_FULL);
211 GNUNET_FS_meta_data_destroy (m);
212 m = GNUNET_FS_meta_data_deserialize (val, size);
213 GNUNET_free (val);
214 if (m == NULL)
215 ABORT (m);
216 GNUNET_FS_meta_data_destroy (m);
217 return 0;
218}
219
220
221static int
222check ()
223{
224 struct GNUNET_FS_MetaData *meta;
225 struct GNUNET_FS_MetaData *meta2;
226 int q;
227 int i = 100;
228 char txt[128];
229 char *str;
230 unsigned char *thumb;
231
232 meta = GNUNET_FS_meta_data_create ();
233 meta2 = GNUNET_FS_meta_data_create ();
234 for (q = 0; q <= i; q++)
235 {
236 GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q);
237 GNUNET_FS_meta_data_insert (meta, "<test>",
238 EXTRACTOR_METATYPE_UNKNOWN,
239 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
240 "TestTitle", strlen ("TestTitle") + 1);
241 GNUNET_FS_meta_data_insert (meta2, "<test>",
242 EXTRACTOR_METATYPE_UNKNOWN,
243 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
244 "TestTitle", strlen ("TestTitle") + 1);
245 }
246
247 // check meta_data_test_equal
248 if (GNUNET_YES != GNUNET_FS_meta_data_test_equal (meta, meta2))
249 {
250 GNUNET_FS_meta_data_destroy (meta2);
251 ABORT (meta);
252 }
253
254 // check meta_data_clear
255 GNUNET_FS_meta_data_clear (meta2);
256 if (0 != GNUNET_FS_meta_data_iterate (meta2, NULL, NULL))
257 {
258 GNUNET_FS_meta_data_destroy (meta2);
259 ABORT (meta);
260 }
261 // check equal branch in meta_data_test_equal
262 if (GNUNET_YES != GNUNET_FS_meta_data_test_equal (meta, meta))
263 {
264 GNUNET_FS_meta_data_destroy (meta2);
265 ABORT (meta);
266 }
267 // check "count" branch in meta_data_test_equal
268 if (GNUNET_NO != GNUNET_FS_meta_data_test_equal (meta, meta2))
269 {
270 GNUNET_FS_meta_data_destroy (meta2);
271 ABORT (meta);
272 }
273
274 // check meta_data_add_publication_date
275 GNUNET_FS_meta_data_add_publication_date (meta2);
276
277 // check meta_data_merge
278 GNUNET_FS_meta_data_clear (meta2);
279 GNUNET_FS_meta_data_merge (meta2, meta);
280 if (100 == GNUNET_FS_meta_data_iterate (meta2, NULL, NULL))
281 {
282 GNUNET_FS_meta_data_destroy (meta2);
283 ABORT (meta);
284 }
285
286 // check meta_data_get_by_type
287 GNUNET_FS_meta_data_clear (meta2);
288 if (NULL !=
289 (str =
290 GNUNET_FS_meta_data_get_by_type (meta2,
291 EXTRACTOR_METATYPE_UNKNOWN)))
292 {
293 GNUNET_FS_meta_data_destroy (meta2);
294 GNUNET_free (str);
295 ABORT (meta);
296 }
297
298 str =
299 GNUNET_FS_meta_data_get_by_type (meta, EXTRACTOR_METATYPE_UNKNOWN);
300 GNUNET_assert (NULL != str);
301 if (str[0] != 'T')
302 {
303 GNUNET_FS_meta_data_destroy (meta2);
304 GNUNET_free (str);
305 ABORT (meta);
306 }
307 GNUNET_free (str);
308
309 // check branch
310 if (NULL !=
311 (str =
312 GNUNET_FS_meta_data_get_by_type (meta,
313 EXTRACTOR_METATYPE_PUBLICATION_DATE)))
314 {
315 GNUNET_free (str);
316 GNUNET_FS_meta_data_destroy (meta2);
317 ABORT (meta);
318 }
319
320 // check meta_data_get_first_by_types
321 str =
322 GNUNET_FS_meta_data_get_first_by_types (meta,
323 EXTRACTOR_METATYPE_UNKNOWN,
324 -1);
325 GNUNET_assert (NULL != str);
326 if (str[0] != 'T')
327 {
328 GNUNET_FS_meta_data_destroy (meta2);
329 GNUNET_free (str);
330 ABORT (meta);
331 }
332 GNUNET_free (str);
333
334 // check meta_data_get_thumbnail
335 if (GNUNET_FS_meta_data_get_thumbnail (meta, &thumb) != 0)
336 {
337 GNUNET_free (thumb);
338 GNUNET_FS_meta_data_destroy (meta2);
339 ABORT (meta);
340 }
341 GNUNET_FS_meta_data_destroy (meta2);
342 // check meta_data_duplicate
343 meta2 = GNUNET_FS_meta_data_duplicate (meta);
344 if (200 == GNUNET_FS_meta_data_iterate (meta2, NULL, NULL))
345 {
346 GNUNET_FS_meta_data_destroy (meta2);
347 ABORT (meta);
348 }
349 GNUNET_FS_meta_data_destroy (meta2);
350 GNUNET_FS_meta_data_destroy (meta);
351 return 0;
352}
353
354
355static int
356test_bigmeta_rw (void)
357{
358 static char meta[1024 * 1024 * 10];
359 struct GNUNET_BIO_WriteHandle *wh;
360 struct GNUNET_BIO_ReadHandle *rh;
361 char *filename = GNUNET_DISK_mktemp ("gnunet_bio");
362 struct GNUNET_FS_MetaData *mdR = NULL;
363
364 memset (meta, 'b', sizeof (meta));
365 meta[sizeof (meta) - 1] = '\0';
366
367 wh = GNUNET_BIO_write_open_file (filename);
368 GNUNET_assert (NULL != wh);
369 if (GNUNET_OK != GNUNET_BIO_write_int32 (wh,
370 "test-bigmeta-rw-int32",
371 sizeof (meta)))
372 {
373 GNUNET_BIO_write_close (wh, NULL);
374 return 1;
375 }
376 if (GNUNET_OK != GNUNET_BIO_write (wh,
377 "test-bigmeta-rw-bytes",
378 meta,
379 sizeof (meta)))
380 {
381 GNUNET_BIO_write_close (wh, NULL);
382 return 1;
383 }
384 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_close (wh, NULL));
385
386 rh = GNUNET_BIO_read_open_file (filename);
387 GNUNET_assert (NULL != rh);
388 GNUNET_assert (GNUNET_SYSERR ==
389 GNUNET_FS_read_meta_data (rh,
390 "test-bigmeta-rw-metadata",
391 &mdR));
392 GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read_close (rh, NULL));
393
394 GNUNET_assert (NULL == mdR);
395
396 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (filename));
397 GNUNET_free (filename);
398 return 0;
399}
400
401static int
402test_fakemeta_rw (void)
403{
404 struct GNUNET_BIO_WriteHandle *wh;
405 struct GNUNET_BIO_ReadHandle *rh;
406 char *filename = GNUNET_DISK_mktemp ("gnunet_bio");
407 struct GNUNET_FS_MetaData *mdR = NULL;
408
409 wh = GNUNET_BIO_write_open_file (filename);
410 GNUNET_assert (NULL != wh);
411 if (GNUNET_OK != GNUNET_BIO_write_int32 (wh,
412 "test-fakestring-rw-int32",
413 2))
414 {
415 GNUNET_BIO_write_close (wh, NULL);
416 return 1;
417 }
418 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_close (wh, NULL));
419
420 rh = GNUNET_BIO_read_open_file (filename);
421 GNUNET_assert (NULL != rh);
422 GNUNET_assert (GNUNET_SYSERR ==
423 GNUNET_FS_read_meta_data (rh,
424 "test-fakestring-rw-metadata",
425 &mdR));
426 GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read_close (rh, NULL));
427
428 GNUNET_assert (NULL == mdR);
429
430 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (filename));
431 GNUNET_free (filename);
432 return 0;
433}
434
435static int
436test_fakebigmeta_rw (void)
437{
438 struct GNUNET_BIO_WriteHandle *wh;
439 struct GNUNET_BIO_ReadHandle *rh;
440 char *filename = GNUNET_DISK_mktemp ("gnunet_bio");
441 struct GNUNET_FS_MetaData *mdR = NULL;
442 int32_t wNum = 1024 * 1024 * 10;
443
444 wh = GNUNET_BIO_write_open_file (filename);
445 GNUNET_assert (NULL != wh);
446 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_int32 (wh,
447 "test-fakebigmeta-rw-int32",
448 wNum));
449 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_close (wh, NULL));
450
451 rh = GNUNET_BIO_read_open_file (filename);
452 GNUNET_assert (NULL != rh);
453 GNUNET_assert (GNUNET_SYSERR ==
454 GNUNET_FS_read_meta_data (rh,
455 "test-fakebigmeta-rw-metadata",
456 &mdR));
457 GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read_close (rh, NULL));
458
459 GNUNET_assert (NULL == mdR);
460
461 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (filename));
462 GNUNET_free (filename);
463 return 0;
464}
465
466int
467main (int argc, char *argv[])
468{
469 int failureCount = 0;
470 int i;
471
472 GNUNET_log_setup ("test-fs-meta-data", "WARNING", NULL);
473 for (i = 0; i < 255; i++)
474 failureCount += testMeta (i);
475 for (i = 1; i < 255; i++)
476 failureCount += testMetaMore (i);
477 failureCount += testMetaLink ();
478 failureCount += test_fakebigmeta_rw ();
479 failureCount += test_fakemeta_rw ();
480 failureCount += test_bigmeta_rw ();
481 int ret = check ();
482
483 if (ret == 1)
484 return 1;
485
486 if (failureCount != 0)
487 return 1;
488 return 0;
489}
490
491
492/* end of test_container_meta_data.c */
diff --git a/src/fs/test_fs_namespace.c b/src/fs/test_fs_namespace.c
index c1e10d575..85d489598 100644
--- a/src/fs/test_fs_namespace.c
+++ b/src/fs/test_fs_namespace.c
@@ -206,7 +206,7 @@ publish_cont (void *cls, const struct GNUNET_FS_Uri *ksk_uri, const char *emsg)
206static void 206static void
207sks_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) 207sks_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
208{ 208{
209 struct GNUNET_CONTAINER_MetaData *meta; 209 struct GNUNET_FS_MetaData *meta;
210 struct GNUNET_FS_Uri *ksk_uri; 210 struct GNUNET_FS_Uri *ksk_uri;
211 char *msg; 211 char *msg;
212 struct GNUNET_FS_BlockOptions bo; 212 struct GNUNET_FS_BlockOptions bo;
@@ -218,7 +218,7 @@ sks_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
218 GNUNET_FS_stop (fs); 218 GNUNET_FS_stop (fs);
219 return; 219 return;
220 } 220 }
221 meta = GNUNET_CONTAINER_meta_data_create (); 221 meta = GNUNET_FS_meta_data_create ();
222 msg = NULL; 222 msg = NULL;
223 ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/ns-search", &msg); 223 ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/ns-search", &msg);
224 GNUNET_assert (NULL == msg); 224 GNUNET_assert (NULL == msg);
@@ -231,14 +231,14 @@ sks_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
231 GNUNET_FS_publish_ksk (fs, ksk_uri, meta, uri, &bo, 231 GNUNET_FS_publish_ksk (fs, ksk_uri, meta, uri, &bo,
232 GNUNET_FS_PUBLISH_OPTION_NONE, &publish_cont, NULL); 232 GNUNET_FS_PUBLISH_OPTION_NONE, &publish_cont, NULL);
233 GNUNET_FS_uri_destroy (ksk_uri); 233 GNUNET_FS_uri_destroy (ksk_uri);
234 GNUNET_CONTAINER_meta_data_destroy (meta); 234 GNUNET_FS_meta_data_destroy (meta);
235} 235}
236 236
237 237
238static void 238static void
239adv_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) 239adv_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
240{ 240{
241 struct GNUNET_CONTAINER_MetaData *meta; 241 struct GNUNET_FS_MetaData *meta;
242 struct GNUNET_CRYPTO_EcdsaPrivateKey ns; 242 struct GNUNET_CRYPTO_EcdsaPrivateKey ns;
243 struct GNUNET_FS_BlockOptions bo; 243 struct GNUNET_FS_BlockOptions bo;
244 244
@@ -250,7 +250,7 @@ adv_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
250 return; 250 return;
251 } 251 }
252 GNUNET_CRYPTO_ecdsa_key_create (&ns); 252 GNUNET_CRYPTO_ecdsa_key_create (&ns);
253 meta = GNUNET_CONTAINER_meta_data_create (); 253 meta = GNUNET_FS_meta_data_create ();
254 sks_expect_uri = GNUNET_FS_uri_dup (uri); 254 sks_expect_uri = GNUNET_FS_uri_dup (uri);
255 bo.content_priority = 1; 255 bo.content_priority = 1;
256 bo.anonymity_level = 1; 256 bo.anonymity_level = 1;
@@ -262,7 +262,7 @@ adv_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
262 GNUNET_FS_publish_sks (fs, 262 GNUNET_FS_publish_sks (fs,
263 &ns, "this", "next", meta, uri, 263 &ns, "this", "next", meta, uri,
264 &bo, GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont, NULL); 264 &bo, GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont, NULL);
265 GNUNET_CONTAINER_meta_data_destroy (meta); 265 GNUNET_FS_meta_data_destroy (meta);
266} 266}
267 267
268 268
@@ -270,11 +270,11 @@ static void
270testNamespace (void) 270testNamespace (void)
271{ 271{
272 struct GNUNET_FS_BlockOptions bo; 272 struct GNUNET_FS_BlockOptions bo;
273 struct GNUNET_CONTAINER_MetaData *meta; 273 struct GNUNET_FS_MetaData *meta;
274 struct GNUNET_FS_Uri *ksk_uri; 274 struct GNUNET_FS_Uri *ksk_uri;
275 struct GNUNET_FS_Uri *sks_uri; 275 struct GNUNET_FS_Uri *sks_uri;
276 276
277 meta = GNUNET_CONTAINER_meta_data_create (); 277 meta = GNUNET_FS_meta_data_create ();
278 ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/testnsa", NULL); 278 ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/testnsa", NULL);
279 bo.content_priority = 1; 279 bo.content_priority = 1;
280 bo.anonymity_level = 1; 280 bo.anonymity_level = 1;
@@ -291,7 +291,7 @@ testNamespace (void)
291 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &do_timeout, 291 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &do_timeout,
292 NULL); 292 NULL);
293 GNUNET_FS_uri_destroy (ksk_uri); 293 GNUNET_FS_uri_destroy (ksk_uri);
294 GNUNET_CONTAINER_meta_data_destroy (meta); 294 GNUNET_FS_meta_data_destroy (meta);
295} 295}
296 296
297 297
diff --git a/src/fs/test_fs_namespace_list_updateable.c b/src/fs/test_fs_namespace_list_updateable.c
index 2132220fb..d883b7bea 100644
--- a/src/fs/test_fs_namespace_list_updateable.c
+++ b/src/fs/test_fs_namespace_list_updateable.c
@@ -35,7 +35,7 @@ static int err;
35 35
36static struct GNUNET_CRYPTO_EcdsaPrivateKey ns; 36static struct GNUNET_CRYPTO_EcdsaPrivateKey ns;
37 37
38static struct GNUNET_CONTAINER_MetaData *meta; 38static struct GNUNET_FS_MetaData *meta;
39 39
40static struct GNUNET_FS_Uri *uri_this; 40static struct GNUNET_FS_Uri *uri_this;
41 41
@@ -59,14 +59,14 @@ do_shutdown ()
59 if (uri_next != NULL) 59 if (uri_next != NULL)
60 GNUNET_FS_uri_destroy (uri_next); 60 GNUNET_FS_uri_destroy (uri_next);
61 if (meta != NULL) 61 if (meta != NULL)
62 GNUNET_CONTAINER_meta_data_destroy (meta); 62 GNUNET_FS_meta_data_destroy (meta);
63} 63}
64 64
65 65
66static void 66static void
67check_next (void *cls, const char *last_id, 67check_next (void *cls, const char *last_id,
68 const struct GNUNET_FS_Uri *last_uri, 68 const struct GNUNET_FS_Uri *last_uri,
69 const struct GNUNET_CONTAINER_MetaData *last_meta, 69 const struct GNUNET_FS_MetaData *last_meta,
70 const char *next_id) 70 const char *next_id)
71{ 71{
72 GNUNET_break (0 == strcmp (last_id, "next")); 72 GNUNET_break (0 == strcmp (last_id, "next"));
@@ -78,7 +78,7 @@ check_next (void *cls, const char *last_id,
78static void 78static void
79check_this_next (void *cls, const char *last_id, 79check_this_next (void *cls, const char *last_id,
80 const struct GNUNET_FS_Uri *last_uri, 80 const struct GNUNET_FS_Uri *last_uri,
81 const struct GNUNET_CONTAINER_MetaData *last_meta, 81 const struct GNUNET_FS_MetaData *last_meta,
82 const char *next_id) 82 const char *next_id)
83{ 83{
84 GNUNET_break (0 == strcmp (last_id, "this")); 84 GNUNET_break (0 == strcmp (last_id, "this"));
@@ -101,7 +101,7 @@ sks_cont_next (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
101static void 101static void
102check_this (void *cls, const char *last_id, 102check_this (void *cls, const char *last_id,
103 const struct GNUNET_FS_Uri *last_uri, 103 const struct GNUNET_FS_Uri *last_uri,
104 const struct GNUNET_CONTAINER_MetaData *last_meta, 104 const struct GNUNET_FS_MetaData *last_meta,
105 const char *next_id) 105 const char *next_id)
106{ 106{
107 GNUNET_break (0 == strcmp (last_id, "this")); 107 GNUNET_break (0 == strcmp (last_id, "this"));
@@ -131,7 +131,7 @@ testNamespace (void)
131 bo.replication_level = 0; 131 bo.replication_level = 0;
132 bo.expiration_time = 132 bo.expiration_time =
133 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); 133 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
134 meta = GNUNET_CONTAINER_meta_data_create (); 134 meta = GNUNET_FS_meta_data_create ();
135 135
136 uri_this = 136 uri_this =
137 GNUNET_FS_uri_parse 137 GNUNET_FS_uri_parse
diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c
index 2ffc722da..0e379bc29 100644
--- a/src/fs/test_fs_publish.c
+++ b/src/fs/test_fs_publish.c
@@ -169,7 +169,7 @@ run (void *cls,
169 "down_bar", 169 "down_bar",
170 }; 170 };
171 char *buf; 171 char *buf;
172 struct GNUNET_CONTAINER_MetaData *meta; 172 struct GNUNET_FS_MetaData *meta;
173 struct GNUNET_FS_Uri *kuri; 173 struct GNUNET_FS_Uri *kuri;
174 struct GNUNET_FS_FileInformation *fi1; 174 struct GNUNET_FS_FileInformation *fi1;
175 struct GNUNET_FS_FileInformation *fi2; 175 struct GNUNET_FS_FileInformation *fi2;
@@ -202,7 +202,7 @@ run (void *cls,
202 | GNUNET_DISK_PERM_USER_WRITE)); 202 | GNUNET_DISK_PERM_USER_WRITE));
203 GNUNET_free (buf); 203 GNUNET_free (buf);
204 204
205 meta = GNUNET_CONTAINER_meta_data_create (); 205 meta = GNUNET_FS_meta_data_create ();
206 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 206 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
207 bo.content_priority = 42; 207 bo.content_priority = 42;
208 bo.anonymity_level = 1; 208 bo.anonymity_level = 1;
@@ -227,7 +227,7 @@ run (void *cls,
227 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); 227 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1));
228 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); 228 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2));
229 GNUNET_FS_uri_destroy (kuri); 229 GNUNET_FS_uri_destroy (kuri);
230 GNUNET_CONTAINER_meta_data_destroy (meta); 230 GNUNET_FS_meta_data_destroy (meta);
231 GNUNET_assert (NULL != fidir); 231 GNUNET_assert (NULL != fidir);
232 start = GNUNET_TIME_absolute_get (); 232 start = GNUNET_TIME_absolute_get ();
233 publish = 233 publish =
diff --git a/src/fs/test_fs_publish_persistence.c b/src/fs/test_fs_publish_persistence.c
index da0209793..e1563f448 100644
--- a/src/fs/test_fs_publish_persistence.c
+++ b/src/fs/test_fs_publish_persistence.c
@@ -242,7 +242,7 @@ run (void *cls,
242 "down_bar", 242 "down_bar",
243 }; 243 };
244 char *buf; 244 char *buf;
245 struct GNUNET_CONTAINER_MetaData *meta; 245 struct GNUNET_FS_MetaData *meta;
246 struct GNUNET_FS_Uri *kuri; 246 struct GNUNET_FS_Uri *kuri;
247 struct GNUNET_FS_FileInformation *fi1; 247 struct GNUNET_FS_FileInformation *fi1;
248 struct GNUNET_FS_FileInformation *fi2; 248 struct GNUNET_FS_FileInformation *fi2;
@@ -276,7 +276,7 @@ run (void *cls,
276 | GNUNET_DISK_PERM_USER_WRITE)); 276 | GNUNET_DISK_PERM_USER_WRITE));
277 GNUNET_free (buf); 277 GNUNET_free (buf);
278 278
279 meta = GNUNET_CONTAINER_meta_data_create (); 279 meta = GNUNET_FS_meta_data_create ();
280 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 280 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
281 bo.content_priority = 42; 281 bo.content_priority = 42;
282 bo.anonymity_level = 1; 282 bo.anonymity_level = 1;
@@ -299,7 +299,7 @@ run (void *cls,
299 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); 299 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1));
300 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); 300 GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2));
301 GNUNET_FS_uri_destroy (kuri); 301 GNUNET_FS_uri_destroy (kuri);
302 GNUNET_CONTAINER_meta_data_destroy (meta); 302 GNUNET_FS_meta_data_destroy (meta);
303 GNUNET_assert (NULL != fidir); 303 GNUNET_assert (NULL != fidir);
304 start = GNUNET_TIME_absolute_get (); 304 start = GNUNET_TIME_absolute_get ();
305 GNUNET_FS_publish_start (fs, fidir, NULL, NULL, NULL, 305 GNUNET_FS_publish_start (fs, fidir, NULL, NULL, NULL,
diff --git a/src/fs/test_fs_search.c b/src/fs/test_fs_search.c
index b392cc8ac..f9266582e 100644
--- a/src/fs/test_fs_search.c
+++ b/src/fs/test_fs_search.c
@@ -204,7 +204,7 @@ run (void *cls,
204 "down_bar" 204 "down_bar"
205 }; 205 };
206 char *buf; 206 char *buf;
207 struct GNUNET_CONTAINER_MetaData *meta; 207 struct GNUNET_FS_MetaData *meta;
208 struct GNUNET_FS_Uri *kuri; 208 struct GNUNET_FS_Uri *kuri;
209 struct GNUNET_FS_BlockOptions bo; 209 struct GNUNET_FS_BlockOptions bo;
210 struct GNUNET_FS_FileInformation *fi; 210 struct GNUNET_FS_FileInformation *fi;
@@ -216,7 +216,7 @@ run (void *cls,
216 buf = GNUNET_malloc (FILESIZE); 216 buf = GNUNET_malloc (FILESIZE);
217 for (i = 0; i < FILESIZE; i++) 217 for (i = 0; i < FILESIZE; i++)
218 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 218 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
219 meta = GNUNET_CONTAINER_meta_data_create (); 219 meta = GNUNET_FS_meta_data_create ();
220 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 220 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
221 bo.content_priority = 42; 221 bo.content_priority = 42;
222 bo.anonymity_level = 1; 222 bo.anonymity_level = 1;
@@ -226,7 +226,7 @@ run (void *cls,
226 FILESIZE, buf, kuri, meta, 226 FILESIZE, buf, kuri, meta,
227 GNUNET_NO, &bo); 227 GNUNET_NO, &bo);
228 GNUNET_FS_uri_destroy (kuri); 228 GNUNET_FS_uri_destroy (kuri);
229 GNUNET_CONTAINER_meta_data_destroy (meta); 229 GNUNET_FS_meta_data_destroy (meta);
230 GNUNET_assert (NULL != fi); 230 GNUNET_assert (NULL != fi);
231 start = GNUNET_TIME_absolute_get (); 231 start = GNUNET_TIME_absolute_get ();
232 publish = 232 publish =
diff --git a/src/fs/test_fs_search_persistence.c b/src/fs/test_fs_search_persistence.c
index d523a6404..4ddd40e73 100644
--- a/src/fs/test_fs_search_persistence.c
+++ b/src/fs/test_fs_search_persistence.c
@@ -269,7 +269,7 @@ run (void *cls,
269 "down_bar" 269 "down_bar"
270 }; 270 };
271 char *buf; 271 char *buf;
272 struct GNUNET_CONTAINER_MetaData *meta; 272 struct GNUNET_FS_MetaData *meta;
273 struct GNUNET_FS_Uri *kuri; 273 struct GNUNET_FS_Uri *kuri;
274 struct GNUNET_FS_FileInformation *fi; 274 struct GNUNET_FS_FileInformation *fi;
275 size_t i; 275 size_t i;
@@ -282,7 +282,7 @@ run (void *cls,
282 buf = GNUNET_malloc (FILESIZE); 282 buf = GNUNET_malloc (FILESIZE);
283 for (i = 0; i < FILESIZE; i++) 283 for (i = 0; i < FILESIZE; i++)
284 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 284 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
285 meta = GNUNET_CONTAINER_meta_data_create (); 285 meta = GNUNET_FS_meta_data_create ();
286 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 286 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
287 bo.content_priority = 42; 287 bo.content_priority = 42;
288 bo.anonymity_level = 1; 288 bo.anonymity_level = 1;
@@ -292,7 +292,7 @@ run (void *cls,
292 FILESIZE, buf, kuri, meta, 292 FILESIZE, buf, kuri, meta,
293 GNUNET_NO, &bo); 293 GNUNET_NO, &bo);
294 GNUNET_FS_uri_destroy (kuri); 294 GNUNET_FS_uri_destroy (kuri);
295 GNUNET_CONTAINER_meta_data_destroy (meta); 295 GNUNET_FS_meta_data_destroy (meta);
296 GNUNET_assert (NULL != fi); 296 GNUNET_assert (NULL != fi);
297 start = GNUNET_TIME_absolute_get (); 297 start = GNUNET_TIME_absolute_get ();
298 publish = 298 publish =
diff --git a/src/fs/test_fs_search_probes.c b/src/fs/test_fs_search_probes.c
index b3c717aa1..776babaee 100644
--- a/src/fs/test_fs_search_probes.c
+++ b/src/fs/test_fs_search_probes.c
@@ -209,7 +209,7 @@ run (void *cls,
209 "down_bar" 209 "down_bar"
210 }; 210 };
211 char *buf; 211 char *buf;
212 struct GNUNET_CONTAINER_MetaData *meta; 212 struct GNUNET_FS_MetaData *meta;
213 struct GNUNET_FS_Uri *kuri; 213 struct GNUNET_FS_Uri *kuri;
214 struct GNUNET_FS_BlockOptions bo; 214 struct GNUNET_FS_BlockOptions bo;
215 struct GNUNET_FS_FileInformation *fi; 215 struct GNUNET_FS_FileInformation *fi;
@@ -222,7 +222,7 @@ run (void *cls,
222 buf = GNUNET_malloc (FILESIZE); 222 buf = GNUNET_malloc (FILESIZE);
223 for (i = 0; i < FILESIZE; i++) 223 for (i = 0; i < FILESIZE; i++)
224 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 224 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
225 meta = GNUNET_CONTAINER_meta_data_create (); 225 meta = GNUNET_FS_meta_data_create ();
226 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 226 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
227 bo.content_priority = 42; 227 bo.content_priority = 42;
228 bo.anonymity_level = 1; 228 bo.anonymity_level = 1;
@@ -232,7 +232,7 @@ run (void *cls,
232 FILESIZE, buf, kuri, meta, 232 FILESIZE, buf, kuri, meta,
233 GNUNET_NO, &bo); 233 GNUNET_NO, &bo);
234 GNUNET_FS_uri_destroy (kuri); 234 GNUNET_FS_uri_destroy (kuri);
235 GNUNET_CONTAINER_meta_data_destroy (meta); 235 GNUNET_FS_meta_data_destroy (meta);
236 GNUNET_assert (NULL != fi); 236 GNUNET_assert (NULL != fi);
237 start = GNUNET_TIME_absolute_get (); 237 start = GNUNET_TIME_absolute_get ();
238 publish = 238 publish =
diff --git a/src/fs/test_fs_search_with_and.c b/src/fs/test_fs_search_with_and.c
index 2187f4531..9c20936b6 100644
--- a/src/fs/test_fs_search_with_and.c
+++ b/src/fs/test_fs_search_with_and.c
@@ -216,7 +216,7 @@ run (void *cls,
216 "down_bar" 216 "down_bar"
217 }; 217 };
218 char *buf; 218 char *buf;
219 struct GNUNET_CONTAINER_MetaData *meta; 219 struct GNUNET_FS_MetaData *meta;
220 struct GNUNET_FS_Uri *kuri; 220 struct GNUNET_FS_Uri *kuri;
221 struct GNUNET_FS_BlockOptions bo; 221 struct GNUNET_FS_BlockOptions bo;
222 struct GNUNET_FS_FileInformation *fi; 222 struct GNUNET_FS_FileInformation *fi;
@@ -233,7 +233,7 @@ run (void *cls,
233 buf = GNUNET_malloc (FILESIZE); 233 buf = GNUNET_malloc (FILESIZE);
234 for (i = 0; i < FILESIZE; i++) 234 for (i = 0; i < FILESIZE; i++)
235 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 235 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
236 meta = GNUNET_CONTAINER_meta_data_create (); 236 meta = GNUNET_FS_meta_data_create ();
237 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 237 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
238 bo.content_priority = 42; 238 bo.content_priority = 42;
239 bo.anonymity_level = 1; 239 bo.anonymity_level = 1;
@@ -243,7 +243,7 @@ run (void *cls,
243 FILESIZE, buf, kuri, meta, 243 FILESIZE, buf, kuri, meta,
244 GNUNET_NO, &bo); 244 GNUNET_NO, &bo);
245 GNUNET_FS_uri_destroy (kuri); 245 GNUNET_FS_uri_destroy (kuri);
246 GNUNET_CONTAINER_meta_data_destroy (meta); 246 GNUNET_FS_meta_data_destroy (meta);
247 GNUNET_assert (NULL != fi); 247 GNUNET_assert (NULL != fi);
248 start = GNUNET_TIME_absolute_get (); 248 start = GNUNET_TIME_absolute_get ();
249 publish = 249 publish =
diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c
index 992672244..dbc33090d 100644
--- a/src/fs/test_fs_unindex.c
+++ b/src/fs/test_fs_unindex.c
@@ -184,7 +184,7 @@ run (void *cls,
184 "down_bar", 184 "down_bar",
185 }; 185 };
186 char *buf; 186 char *buf;
187 struct GNUNET_CONTAINER_MetaData *meta; 187 struct GNUNET_FS_MetaData *meta;
188 struct GNUNET_FS_Uri *kuri; 188 struct GNUNET_FS_Uri *kuri;
189 struct GNUNET_FS_FileInformation *fi; 189 struct GNUNET_FS_FileInformation *fi;
190 size_t i; 190 size_t i;
@@ -203,7 +203,7 @@ run (void *cls,
203 GNUNET_DISK_PERM_USER_READ 203 GNUNET_DISK_PERM_USER_READ
204 | GNUNET_DISK_PERM_USER_WRITE)); 204 | GNUNET_DISK_PERM_USER_WRITE));
205 GNUNET_free (buf); 205 GNUNET_free (buf);
206 meta = GNUNET_CONTAINER_meta_data_create (); 206 meta = GNUNET_FS_meta_data_create ();
207 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 207 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
208 bo.content_priority = 42; 208 bo.content_priority = 42;
209 bo.anonymity_level = 1; 209 bo.anonymity_level = 1;
@@ -213,7 +213,7 @@ run (void *cls,
213 kuri, meta, GNUNET_YES, 213 kuri, meta, GNUNET_YES,
214 &bo); 214 &bo);
215 GNUNET_FS_uri_destroy (kuri); 215 GNUNET_FS_uri_destroy (kuri);
216 GNUNET_CONTAINER_meta_data_destroy (meta); 216 GNUNET_FS_meta_data_destroy (meta);
217 GNUNET_assert (NULL != fi); 217 GNUNET_assert (NULL != fi);
218 start = GNUNET_TIME_absolute_get (); 218 start = GNUNET_TIME_absolute_get ();
219 publish = 219 publish =
diff --git a/src/fs/test_fs_unindex_persistence.c b/src/fs/test_fs_unindex_persistence.c
index 802aaf7ca..b81ce64ab 100644
--- a/src/fs/test_fs_unindex_persistence.c
+++ b/src/fs/test_fs_unindex_persistence.c
@@ -253,7 +253,7 @@ run (void *cls,
253 "down_bar", 253 "down_bar",
254 }; 254 };
255 char *buf; 255 char *buf;
256 struct GNUNET_CONTAINER_MetaData *meta; 256 struct GNUNET_FS_MetaData *meta;
257 struct GNUNET_FS_Uri *kuri; 257 struct GNUNET_FS_Uri *kuri;
258 struct GNUNET_FS_FileInformation *fi; 258 struct GNUNET_FS_FileInformation *fi;
259 size_t i; 259 size_t i;
@@ -273,7 +273,7 @@ run (void *cls,
273 GNUNET_DISK_PERM_USER_READ 273 GNUNET_DISK_PERM_USER_READ
274 | GNUNET_DISK_PERM_USER_WRITE)); 274 | GNUNET_DISK_PERM_USER_WRITE));
275 GNUNET_free (buf); 275 GNUNET_free (buf);
276 meta = GNUNET_CONTAINER_meta_data_create (); 276 meta = GNUNET_FS_meta_data_create ();
277 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); 277 kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords);
278 bo.content_priority = 42; 278 bo.content_priority = 42;
279 bo.anonymity_level = 1; 279 bo.anonymity_level = 1;
@@ -283,7 +283,7 @@ run (void *cls,
283 kuri, meta, GNUNET_YES, 283 kuri, meta, GNUNET_YES,
284 &bo); 284 &bo);
285 GNUNET_FS_uri_destroy (kuri); 285 GNUNET_FS_uri_destroy (kuri);
286 GNUNET_CONTAINER_meta_data_destroy (meta); 286 GNUNET_FS_meta_data_destroy (meta);
287 GNUNET_assert (NULL != fi); 287 GNUNET_assert (NULL != fi);
288 start = GNUNET_TIME_absolute_get (); 288 start = GNUNET_TIME_absolute_get ();
289 publish = 289 publish =
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c
index 960d84fb3..04d320c62 100644
--- a/src/gns/gnunet-dns2gns.c
+++ b/src/gns/gnunet-dns2gns.c
@@ -24,9 +24,7 @@
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include <gnunet_util_lib.h> 26#include <gnunet_util_lib.h>
27#include <gnunet_dnsparser_lib.h>
28#include <gnunet_gns_service.h> 27#include <gnunet_gns_service.h>
29#include <gnunet_dnsstub_lib.h>
30#include "gnunet_vpn_service.h" 28#include "gnunet_vpn_service.h"
31#include "gns.h" 29#include "gns.h"
32 30
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c
index 5cf496808..c71676a08 100644
--- a/src/gns/gnunet-gns.c
+++ b/src/gns/gnunet-gns.c
@@ -37,7 +37,6 @@
37#endif 37#endif
38#endif 38#endif
39#include <gnunet_util_lib.h> 39#include <gnunet_util_lib.h>
40#include <gnunet_dnsparser_lib.h>
41#include <gnunet_gnsrecord_lib.h> 40#include <gnunet_gnsrecord_lib.h>
42#include <gnunet_namestore_service.h> 41#include <gnunet_namestore_service.h>
43#include <gnunet_gns_service.h> 42#include <gnunet_gns_service.h>
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 7e770ce5a..fc8de860d 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -26,7 +26,6 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_dns_service.h" 28#include "gnunet_dns_service.h"
29#include "gnunet_dnsparser_lib.h"
30#include "gnunet_dht_service.h" 29#include "gnunet_dht_service.h"
31#include "gnunet_namecache_service.h" 30#include "gnunet_namecache_service.h"
32#include "gnunet_gnsrecord_lib.h" 31#include "gnunet_gnsrecord_lib.h"
diff --git a/src/gns/gnunet-service-gns_interceptor.c b/src/gns/gnunet-service-gns_interceptor.c
index 86c059c5f..3358692da 100644
--- a/src/gns/gnunet-service-gns_interceptor.c
+++ b/src/gns/gnunet-service-gns_interceptor.c
@@ -26,7 +26,6 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_dns_service.h" 28#include "gnunet_dns_service.h"
29#include "gnunet_dnsparser_lib.h"
30#include "gnunet-service-gns.h" 29#include "gnunet-service-gns.h"
31#include "gnunet-service-gns_resolver.h" 30#include "gnunet-service-gns_resolver.h"
32#include "gnunet-service-gns_interceptor.h" 31#include "gnunet-service-gns_interceptor.h"
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 45d971c85..b6a81b3a1 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -39,15 +39,12 @@
39#endif 39#endif
40#endif 40#endif
41#include "gnunet_util_lib.h" 41#include "gnunet_util_lib.h"
42#include "gnunet_dnsstub_lib.h"
43#include "gnunet_dht_service.h" 42#include "gnunet_dht_service.h"
44#include "gnunet_gnsrecord_lib.h" 43#include "gnunet_gnsrecord_lib.h"
45#include "gnunet_namecache_service.h" 44#include "gnunet_namecache_service.h"
46#include "gnunet_dns_service.h" 45#include "gnunet_dns_service.h"
47#include "gnunet_resolver_service.h" 46#include "gnunet_resolver_service.h"
48#include "gnunet_revocation_service.h" 47#include "gnunet_revocation_service.h"
49#include "gnunet_dnsparser_lib.h"
50#include "gnunet_tun_lib.h"
51#include "gnunet_gns_service.h" 48#include "gnunet_gns_service.h"
52#include "gns.h" 49#include "gns.h"
53#include "gnunet-service-gns.h" 50#include "gnunet-service-gns.h"
diff --git a/src/gns/nss/nss_gns.c b/src/gns/nss/nss_gns.c
index ff34cedd5..b05cfff55 100644
--- a/src/gns/nss/nss_gns.c
+++ b/src/gns/nss/nss_gns.c
@@ -19,7 +19,7 @@
19 USA. 19 USA.
20 ***/ 20 ***/
21 21
22#include <gnunet_config.h> 22#include <gnunet_private_config.h>
23#include <unistd.h> 23#include <unistd.h>
24#include <errno.h> 24#include <errno.h>
25#include <string.h> 25#include <string.h>
diff --git a/src/gns/plugin_gnsrecord_gns.c b/src/gns/plugin_gnsrecord_gns.c
index 296957f19..7c1c9b2e6 100644
--- a/src/gns/plugin_gnsrecord_gns.c
+++ b/src/gns/plugin_gnsrecord_gns.c
@@ -29,7 +29,6 @@
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_gnsrecord_lib.h" 31#include "gnunet_gnsrecord_lib.h"
32#include "gnunet_dnsparser_lib.h"
33#include "gnunet_gnsrecord_plugin.h" 32#include "gnunet_gnsrecord_plugin.h"
34#include <inttypes.h> 33#include <inttypes.h>
35 34
diff --git a/src/gnsrecord/gnsrecord.c b/src/gnsrecord/gnsrecord.c
index ae4223021..c71dc1708 100644
--- a/src/gnsrecord/gnsrecord.c
+++ b/src/gnsrecord/gnsrecord.c
@@ -30,7 +30,6 @@
30#include "gnunet_constants.h" 30#include "gnunet_constants.h"
31#include "gnunet_gnsrecord_lib.h" 31#include "gnunet_gnsrecord_lib.h"
32#include "gnunet_gnsrecord_plugin.h" 32#include "gnunet_gnsrecord_plugin.h"
33#include "gnunet_tun_lib.h"
34 33
35#define LOG(kind, ...) GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__) 34#define LOG(kind, ...) GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__)
36 35
diff --git a/src/gnsrecord/gnsrecord_crypto.c b/src/gnsrecord/gnsrecord_crypto.c
index d794c9cb4..e6036b72b 100644
--- a/src/gnsrecord/gnsrecord_crypto.c
+++ b/src/gnsrecord/gnsrecord_crypto.c
@@ -25,6 +25,7 @@
25 * @author Matthias Wachs 25 * @author Matthias Wachs
26 * @author Christian Grothoff 26 * @author Christian Grothoff
27 */ 27 */
28#include "platform.h"
28#include "gnsrecord_crypto.h" 29#include "gnsrecord_crypto.h"
29 30
30#define LOG(kind, ...) GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__) 31#define LOG(kind, ...) GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__)
@@ -793,7 +794,7 @@ block_decrypt_ecdsa (const struct GNUNET_GNSRECORD_Block *block,
793 continue; 794 continue;
794 } 795 }
795 796
796 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) 797 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW))
797 { 798 {
798 int include_record = GNUNET_YES; 799 int include_record = GNUNET_YES;
799 /* Shadow record, figure out if we have a not expired active record */ 800 /* Shadow record, figure out if we have a not expired active record */
@@ -805,7 +806,7 @@ block_decrypt_ecdsa (const struct GNUNET_GNSRECORD_Block *block,
805 include_record = GNUNET_NO; /* Shadow record is expired */ 806 include_record = GNUNET_NO; /* Shadow record is expired */
806 if ((rd[k].record_type == rd[i].record_type) && 807 if ((rd[k].record_type == rd[i].record_type) &&
807 (rd[k].expiration_time >= now.abs_value_us) && 808 (rd[k].expiration_time >= now.abs_value_us) &&
808 (0 == (rd[k].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD))) 809 (0 == (rd[k].flags & GNUNET_GNSRECORD_RF_SHADOW)))
809 { 810 {
810 include_record = GNUNET_NO; /* We have a non-expired, non-shadow record of the same type */ 811 include_record = GNUNET_NO; /* We have a non-expired, non-shadow record of the same type */
811 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 812 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -815,7 +816,7 @@ block_decrypt_ecdsa (const struct GNUNET_GNSRECORD_Block *block,
815 } 816 }
816 if (GNUNET_YES == include_record) 817 if (GNUNET_YES == include_record)
817 { 818 {
818 rd[i].flags ^= GNUNET_GNSRECORD_RF_SHADOW_RECORD; /* Remove Flag */ 819 rd[i].flags ^= GNUNET_GNSRECORD_RF_SHADOW; /* Remove Flag */
819 if (j != i) 820 if (j != i)
820 rd[j] = rd[i]; 821 rd[j] = rd[i];
821 j++; 822 j++;
@@ -919,7 +920,7 @@ block_decrypt_eddsa (const struct GNUNET_GNSRECORD_Block *block,
919 continue; 920 continue;
920 } 921 }
921 922
922 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) 923 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW))
923 { 924 {
924 int include_record = GNUNET_YES; 925 int include_record = GNUNET_YES;
925 /* Shadow record, figure out if we have a not expired active record */ 926 /* Shadow record, figure out if we have a not expired active record */
@@ -931,7 +932,7 @@ block_decrypt_eddsa (const struct GNUNET_GNSRECORD_Block *block,
931 include_record = GNUNET_NO; /* Shadow record is expired */ 932 include_record = GNUNET_NO; /* Shadow record is expired */
932 if ((rd[k].record_type == rd[i].record_type) && 933 if ((rd[k].record_type == rd[i].record_type) &&
933 (rd[k].expiration_time >= now.abs_value_us) && 934 (rd[k].expiration_time >= now.abs_value_us) &&
934 (0 == (rd[k].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD))) 935 (0 == (rd[k].flags & GNUNET_GNSRECORD_RF_SHADOW)))
935 { 936 {
936 include_record = GNUNET_NO; /* We have a non-expired, non-shadow record of the same type */ 937 include_record = GNUNET_NO; /* We have a non-expired, non-shadow record of the same type */
937 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 938 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -941,7 +942,7 @@ block_decrypt_eddsa (const struct GNUNET_GNSRECORD_Block *block,
941 } 942 }
942 if (GNUNET_YES == include_record) 943 if (GNUNET_YES == include_record)
943 { 944 {
944 rd[i].flags ^= GNUNET_GNSRECORD_RF_SHADOW_RECORD; /* Remove Flag */ 945 rd[i].flags ^= GNUNET_GNSRECORD_RF_SHADOW; /* Remove Flag */
945 if (j != i) 946 if (j != i)
946 rd[j] = rd[i]; 947 rd[j] = rd[i];
947 j++; 948 j++;
diff --git a/src/gnsrecord/gnsrecord_crypto.h b/src/gnsrecord/gnsrecord_crypto.h
index 79a7e6fb9..4f2e4a5ca 100644
--- a/src/gnsrecord/gnsrecord_crypto.h
+++ b/src/gnsrecord/gnsrecord_crypto.h
@@ -31,8 +31,6 @@
31#include "gnunet_signatures.h" 31#include "gnunet_signatures.h"
32#include "gnunet_arm_service.h" 32#include "gnunet_arm_service.h"
33#include "gnunet_gnsrecord_lib.h" 33#include "gnunet_gnsrecord_lib.h"
34#include "gnunet_dnsparser_lib.h"
35#include "gnunet_tun_lib.h"
36 34
37/** 35/**
38 * Information we have in an encrypted block with record data (i.e. in the DHT). 36 * Information we have in an encrypted block with record data (i.e. in the DHT).
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c
index 97ca7b135..fde553a83 100644
--- a/src/gnsrecord/gnsrecord_misc.c
+++ b/src/gnsrecord/gnsrecord_misc.c
@@ -31,8 +31,6 @@
31#include "gnunet_signatures.h" 31#include "gnunet_signatures.h"
32#include "gnunet_arm_service.h" 32#include "gnunet_arm_service.h"
33#include "gnunet_gnsrecord_lib.h" 33#include "gnunet_gnsrecord_lib.h"
34#include "gnunet_dnsparser_lib.h"
35#include "gnunet_tun_lib.h"
36 34
37 35
38#define LOG(kind, ...) GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__) 36#define LOG(kind, ...) GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__)
@@ -173,7 +171,7 @@ GNUNET_GNSRECORD_record_get_expiration_time (unsigned int rd_count,
173 /* Check for shadow record */ 171 /* Check for shadow record */
174 if ((c == c2) || 172 if ((c == c2) ||
175 (rd[c].record_type != rd[c2].record_type) || 173 (rd[c].record_type != rd[c2].record_type) ||
176 (0 == (rd[c2].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD))) 174 (0 == (rd[c2].flags & GNUNET_GNSRECORD_RF_SHADOW)))
177 continue; 175 continue;
178 /* We have a shadow record */ 176 /* We have a shadow record */
179 if (0 != (rd[c2].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) 177 if (0 != (rd[c2].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
diff --git a/src/gnsrecord/gnsrecord_serialization.c b/src/gnsrecord/gnsrecord_serialization.c
index ef7684892..053edfd33 100644
--- a/src/gnsrecord/gnsrecord_serialization.c
+++ b/src/gnsrecord/gnsrecord_serialization.c
@@ -31,9 +31,6 @@
31#include "gnunet_signatures.h" 31#include "gnunet_signatures.h"
32#include "gnunet_arm_service.h" 32#include "gnunet_arm_service.h"
33#include "gnunet_gnsrecord_lib.h" 33#include "gnunet_gnsrecord_lib.h"
34#include "gnunet_dnsparser_lib.h"
35#include "gnunet_tun_lib.h"
36
37 34
38#define LOG(kind, ...) GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__) 35#define LOG(kind, ...) GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__)
39 36
diff --git a/src/gnsrecord/gnunet-gnsrecord-tvg.c b/src/gnsrecord/gnunet-gnsrecord-tvg.c
index 91abe1954..ef111b3bd 100644
--- a/src/gnsrecord/gnunet-gnsrecord-tvg.c
+++ b/src/gnsrecord/gnunet-gnsrecord-tvg.c
@@ -28,10 +28,9 @@
28#include "gnunet_signatures.h" 28#include "gnunet_signatures.h"
29#include "gnunet_gns_service.h" 29#include "gnunet_gns_service.h"
30#include "gnunet_gnsrecord_lib.h" 30#include "gnunet_gnsrecord_lib.h"
31#include "gnunet_dnsparser_lib.h"
32#include "gnunet_testing_lib.h" 31#include "gnunet_testing_lib.h"
33#include <inttypes.h>
34#include "gnsrecord_crypto.h" 32#include "gnsrecord_crypto.h"
33#include <inttypes.h>
35 34
36 35
37static char *d_pkey = 36static char *d_pkey =
diff --git a/src/gnsrecord/json_gnsrecord.c b/src/gnsrecord/json_gnsrecord.c
index 2b840ab30..0725cb1a1 100644
--- a/src/gnsrecord/json_gnsrecord.c
+++ b/src/gnsrecord/json_gnsrecord.c
@@ -168,7 +168,7 @@ parse_record (json_t *data, struct GNUNET_GNSRECORD_Data *rd)
168 if (1 == supplemental) 168 if (1 == supplemental)
169 rd->flags |= GNUNET_GNSRECORD_RF_SUPPLEMENTAL; 169 rd->flags |= GNUNET_GNSRECORD_RF_SUPPLEMENTAL;
170 if (1 == shadow) 170 if (1 == shadow)
171 rd->flags |= GNUNET_GNSRECORD_RF_SHADOW_RECORD; 171 rd->flags |= GNUNET_GNSRECORD_RF_SHADOW;
172 return GNUNET_OK; 172 return GNUNET_OK;
173} 173}
174 174
@@ -353,7 +353,7 @@ GNUNET_GNSRECORD_JSON_from_gnsrecord (const char*rname,
353 GNUNET_JSON_GNSRECORD_FLAG_SUPPLEMENTAL, 353 GNUNET_JSON_GNSRECORD_FLAG_SUPPLEMENTAL,
354 rd[i].flags & GNUNET_GNSRECORD_RF_SUPPLEMENTAL, 354 rd[i].flags & GNUNET_GNSRECORD_RF_SUPPLEMENTAL,
355 GNUNET_JSON_GNSRECORD_FLAG_SUPPLEMENTAL, 355 GNUNET_JSON_GNSRECORD_FLAG_SUPPLEMENTAL,
356 rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD); 356 rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW);
357 GNUNET_free (value_str); 357 GNUNET_free (value_str);
358 if (NULL == record) 358 if (NULL == record)
359 { 359 {
diff --git a/src/gnsrecord/plugin_gnsrecord_dns.c b/src/gnsrecord/plugin_gnsrecord_dns.c
index e8c24501c..5844d9eda 100644
--- a/src/gnsrecord/plugin_gnsrecord_dns.c
+++ b/src/gnsrecord/plugin_gnsrecord_dns.c
@@ -25,7 +25,6 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_dnsparser_lib.h"
29#include "gnunet_gnsrecord_plugin.h" 28#include "gnunet_gnsrecord_plugin.h"
30 29
31 30
diff --git a/src/gnsrecord/test_gnsrecord_block_expiration.c b/src/gnsrecord/test_gnsrecord_block_expiration.c
index d14ce3914..69f7f6aa1 100644
--- a/src/gnsrecord/test_gnsrecord_block_expiration.c
+++ b/src/gnsrecord/test_gnsrecord_block_expiration.c
@@ -79,7 +79,7 @@ run (void *cls, char *const *args, const char *cfgfile,
79 rd[1].record_type = TEST_RECORD_TYPE; 79 rd[1].record_type = TEST_RECORD_TYPE;
80 rd[1].data_size = TEST_RECORD_DATALEN; 80 rd[1].data_size = TEST_RECORD_DATALEN;
81 rd[1].data = GNUNET_malloc (TEST_RECORD_DATALEN); 81 rd[1].data = GNUNET_malloc (TEST_RECORD_DATALEN);
82 rd[1].flags = GNUNET_GNSRECORD_RF_SHADOW_RECORD; 82 rd[1].flags = GNUNET_GNSRECORD_RF_SHADOW;
83 memset ((char *) rd[1].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); 83 memset ((char *) rd[1].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
84 84
85 GNUNET_assert (expiration_abs_shadow.abs_value_us == 85 GNUNET_assert (expiration_abs_shadow.abs_value_us ==
diff --git a/src/gnsrecord/test_gnsrecord_crypto.c b/src/gnsrecord/test_gnsrecord_crypto.c
index ad7b62cc8..5b1032f1e 100644
--- a/src/gnsrecord/test_gnsrecord_crypto.c
+++ b/src/gnsrecord/test_gnsrecord_crypto.c
@@ -23,7 +23,6 @@
23 */ 23 */
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_util_lib.h" 25#include "gnunet_util_lib.h"
26#include "gnunet_dnsparser_lib.h"
27#include "gnunet_gnsrecord_lib.h" 26#include "gnunet_gnsrecord_lib.h"
28 27
29#define RECORDS 5 28#define RECORDS 5
diff --git a/src/gnsrecord/test_gnsrecord_serialization.c b/src/gnsrecord/test_gnsrecord_serialization.c
index d268cb7f3..b06b3a0fe 100644
--- a/src/gnsrecord/test_gnsrecord_serialization.c
+++ b/src/gnsrecord/test_gnsrecord_serialization.c
@@ -24,7 +24,6 @@
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_util_lib.h" 25#include "gnunet_util_lib.h"
26#include "gnunet_gnsrecord_lib.h" 26#include "gnunet_gnsrecord_lib.h"
27#include "gnunet_dnsparser_lib.h"
28 27
29#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100) 28#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100)
30 29
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c
index f1156e0b6..07296a882 100644
--- a/src/identity/gnunet-service-identity.c
+++ b/src/identity/gnunet-service-identity.c
@@ -244,6 +244,7 @@ create_update_message (struct Ego *ego)
244 GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE); 244 GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE);
245 um->name_len = htons (name_len); 245 um->name_len = htons (name_len);
246 um->end_of_list = htons (GNUNET_NO); 246 um->end_of_list = htons (GNUNET_NO);
247 um->key_len = htons (key_len);
247 GNUNET_memcpy (&um[1], ego->identifier, name_len); 248 GNUNET_memcpy (&um[1], ego->identifier, name_len);
248 GNUNET_IDENTITY_write_private_key_to_buffer (&ego->pk, 249 GNUNET_IDENTITY_write_private_key_to_buffer (&ego->pk,
249 ((char*) &um[1]) + name_len, 250 ((char*) &um[1]) + name_len,
@@ -287,6 +288,7 @@ handle_start_message (void *cls,
287 GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE); 288 GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE);
288 ume->end_of_list = htons (GNUNET_YES); 289 ume->end_of_list = htons (GNUNET_YES);
289 ume->name_len = htons (0); 290 ume->name_len = htons (0);
291 ume->key_len = htons (0);
290 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), 292 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
291 env); 293 env);
292 } 294 }
@@ -426,6 +428,7 @@ notify_listeners (struct Ego *ego)
426 um->header.size = htons (sizeof(struct UpdateMessage) + name_len + key_len); 428 um->header.size = htons (sizeof(struct UpdateMessage) + name_len + key_len);
427 um->name_len = htons (name_len); 429 um->name_len = htons (name_len);
428 um->end_of_list = htons (GNUNET_NO); 430 um->end_of_list = htons (GNUNET_NO);
431 um->key_len = htons (key_len);
429 GNUNET_memcpy (&um[1], ego->identifier, name_len); 432 GNUNET_memcpy (&um[1], ego->identifier, name_len);
430 GNUNET_IDENTITY_write_private_key_to_buffer (&ego->pk, 433 GNUNET_IDENTITY_write_private_key_to_buffer (&ego->pk,
431 ((char*) &um[1]) + name_len, 434 ((char*) &um[1]) + name_len,
@@ -458,8 +461,7 @@ check_create_message (void *cls,
458 return GNUNET_SYSERR; 461 return GNUNET_SYSERR;
459 } 462 }
460 name_len = ntohs (msg->name_len); 463 name_len = ntohs (msg->name_len);
461 key_len = ntohl (msg->key_len); 464 key_len = ntohs (msg->key_len);
462 GNUNET_break (0 == ntohs (msg->reserved));
463 if (name_len + key_len + sizeof(struct CreateRequestMessage) != size) 465 if (name_len + key_len + sizeof(struct CreateRequestMessage) != size)
464 { 466 {
465 GNUNET_break (0); 467 GNUNET_break (0);
@@ -494,7 +496,7 @@ handle_create_message (void *cls,
494 size_t kb_read; 496 size_t kb_read;
495 497
496 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREATE message from client\n"); 498 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREATE message from client\n");
497 key_len = ntohl (crm->key_len); 499 key_len = ntohs (crm->key_len);
498 if ((GNUNET_SYSERR == 500 if ((GNUNET_SYSERR ==
499 GNUNET_IDENTITY_read_private_key_from_buffer (&crm[1], 501 GNUNET_IDENTITY_read_private_key_from_buffer (&crm[1],
500 key_len, 502 key_len,
diff --git a/src/identity/identity.h b/src/identity/identity.h
index dc57ee11e..a3193ca2a 100644
--- a/src/identity/identity.h
+++ b/src/identity/identity.h
@@ -128,6 +128,16 @@ struct UpdateMessage
128 */ 128 */
129 uint16_t end_of_list GNUNET_PACKED; 129 uint16_t end_of_list GNUNET_PACKED;
130 130
131 /**
132 * Key length
133 */
134 uint16_t key_len GNUNET_PACKED;
135
136 /**
137 * Reserved (alignment)
138 */
139 uint16_t reserved GNUNET_PACKED;
140
131 /* followed by 0-terminated ego name */ 141 /* followed by 0-terminated ego name */
132 /* followed by the private key */ 142 /* followed by the private key */
133}; 143};
@@ -150,11 +160,9 @@ struct CreateRequestMessage
150 uint16_t name_len GNUNET_PACKED; 160 uint16_t name_len GNUNET_PACKED;
151 161
152 /** 162 /**
153 * Always zero. 163 * Key length
154 */ 164 */
155 uint16_t reserved GNUNET_PACKED; 165 uint16_t key_len GNUNET_PACKED;
156
157 uint32_t key_len GNUNET_PACKED;
158 166
159 /* 167 /*
160 * Followed by the private key 168 * Followed by the private key
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c
index 3fd052277..47a78e2bb 100644
--- a/src/identity/identity_api.c
+++ b/src/identity/identity_api.c
@@ -26,6 +26,7 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_constants.h" 28#include "gnunet_constants.h"
29#include "gnunet_error_codes.h"
29#include "gnunet_protocols.h" 30#include "gnunet_protocols.h"
30#include "gnunet_identity_service.h" 31#include "gnunet_identity_service.h"
31#include "identity.h" 32#include "identity.h"
@@ -197,6 +198,7 @@ GNUNET_IDENTITY_key_get_public (const struct
197 return GNUNET_OK; 198 return GNUNET_OK;
198} 199}
199 200
201
200static enum GNUNET_GenericReturnValue 202static enum GNUNET_GenericReturnValue
201private_key_create (enum GNUNET_IDENTITY_KeyType ktype, 203private_key_create (enum GNUNET_IDENTITY_KeyType ktype,
202 struct GNUNET_IDENTITY_PrivateKey *key) 204 struct GNUNET_IDENTITY_PrivateKey *key)
@@ -410,7 +412,7 @@ handle_identity_update (void *cls,
410 tmp = (const char*) &um[1]; 412 tmp = (const char*) &um[1];
411 str = (0 == name_len) ? NULL : tmp; 413 str = (0 == name_len) ? NULL : tmp;
412 memset (&private_key, 0, sizeof (private_key)); 414 memset (&private_key, 0, sizeof (private_key));
413 key_len = ntohs (um->header.size) - name_len; 415 key_len = ntohs (um->key_len);
414 GNUNET_assert (GNUNET_SYSERR != 416 GNUNET_assert (GNUNET_SYSERR !=
415 GNUNET_IDENTITY_read_private_key_from_buffer (tmp + name_len, 417 GNUNET_IDENTITY_read_private_key_from_buffer (tmp + name_len,
416 key_len, 418 key_len,
@@ -616,13 +618,13 @@ GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h,
616 else 618 else
617 private_key = *privkey; 619 private_key = *privkey;
618 key_len = GNUNET_IDENTITY_private_key_get_length (&private_key); 620 key_len = GNUNET_IDENTITY_private_key_get_length (&private_key);
619 env = GNUNET_MQ_msg_extra (crm, slen + key_len, GNUNET_MESSAGE_TYPE_IDENTITY_CREATE); 621 env = GNUNET_MQ_msg_extra (crm, slen + key_len,
622 GNUNET_MESSAGE_TYPE_IDENTITY_CREATE);
620 crm->name_len = htons (slen); 623 crm->name_len = htons (slen);
621 crm->reserved = htons (0);
622 GNUNET_IDENTITY_write_private_key_to_buffer (&private_key, 624 GNUNET_IDENTITY_write_private_key_to_buffer (&private_key,
623 &crm[1], 625 &crm[1],
624 key_len); 626 key_len);
625 crm->key_len = htonl (key_len); 627 crm->key_len = htons (key_len);
626 op->pk = private_key; 628 op->pk = private_key;
627 GNUNET_memcpy ((char*) &crm[1] + key_len, name, slen); 629 GNUNET_memcpy ((char*) &crm[1] + key_len, name, slen);
628 GNUNET_MQ_send (h->mq, env); 630 GNUNET_MQ_send (h->mq, env);
@@ -840,6 +842,7 @@ GNUNET_IDENTITY_public_key_get_length (const struct
840 return -1; 842 return -1;
841} 843}
842 844
845
843ssize_t 846ssize_t
844GNUNET_IDENTITY_private_key_length_by_type (enum GNUNET_IDENTITY_KeyType kt) 847GNUNET_IDENTITY_private_key_length_by_type (enum GNUNET_IDENTITY_KeyType kt)
845{ 848{
@@ -858,7 +861,6 @@ GNUNET_IDENTITY_private_key_length_by_type (enum GNUNET_IDENTITY_KeyType kt)
858} 861}
859 862
860 863
861
862enum GNUNET_GenericReturnValue 864enum GNUNET_GenericReturnValue
863GNUNET_IDENTITY_read_public_key_from_buffer (const void *buffer, 865GNUNET_IDENTITY_read_public_key_from_buffer (const void *buffer,
864 size_t len, 866 size_t len,
@@ -901,6 +903,7 @@ GNUNET_IDENTITY_write_public_key_to_buffer (const struct
901 return length; 903 return length;
902} 904}
903 905
906
904enum GNUNET_GenericReturnValue 907enum GNUNET_GenericReturnValue
905GNUNET_IDENTITY_read_private_key_from_buffer (const void *buffer, 908GNUNET_IDENTITY_read_private_key_from_buffer (const void *buffer,
906 size_t len, 909 size_t len,
@@ -981,7 +984,6 @@ GNUNET_IDENTITY_signature_get_raw_length_by_type (uint32_t type)
981} 984}
982 985
983 986
984
985ssize_t 987ssize_t
986GNUNET_IDENTITY_read_signature_from_buffer (struct 988GNUNET_IDENTITY_read_signature_from_buffer (struct
987 GNUNET_IDENTITY_Signature *sig, 989 GNUNET_IDENTITY_Signature *sig,
@@ -1019,6 +1021,7 @@ GNUNET_IDENTITY_write_signature_to_buffer (const struct
1019 return length; 1021 return length;
1020} 1022}
1021 1023
1024
1022enum GNUNET_GenericReturnValue 1025enum GNUNET_GenericReturnValue
1023GNUNET_IDENTITY_sign_raw_ (const struct 1026GNUNET_IDENTITY_sign_raw_ (const struct
1024 GNUNET_IDENTITY_PrivateKey *priv, 1027 GNUNET_IDENTITY_PrivateKey *priv,
@@ -1046,7 +1049,6 @@ GNUNET_IDENTITY_sign_raw_ (const struct
1046} 1049}
1047 1050
1048 1051
1049
1050enum GNUNET_GenericReturnValue 1052enum GNUNET_GenericReturnValue
1051GNUNET_IDENTITY_sign_ (const struct 1053GNUNET_IDENTITY_sign_ (const struct
1052 GNUNET_IDENTITY_PrivateKey *priv, 1054 GNUNET_IDENTITY_PrivateKey *priv,
@@ -1133,8 +1135,6 @@ GNUNET_IDENTITY_signature_verify_raw_ (uint32_t purpose,
1133} 1135}
1134 1136
1135 1137
1136
1137
1138ssize_t 1138ssize_t
1139GNUNET_IDENTITY_encrypt (const void *block, 1139GNUNET_IDENTITY_encrypt (const void *block,
1140 size_t size, 1140 size_t size,
@@ -1228,6 +1228,7 @@ GNUNET_IDENTITY_private_key_to_string (const struct
1228 size); 1228 size);
1229} 1229}
1230 1230
1231
1231enum GNUNET_GenericReturnValue 1232enum GNUNET_GenericReturnValue
1232GNUNET_IDENTITY_public_key_from_string (const char *str, 1233GNUNET_IDENTITY_public_key_from_string (const char *str,
1233 struct GNUNET_IDENTITY_PublicKey *key) 1234 struct GNUNET_IDENTITY_PublicKey *key)
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c
index 17d214c15..093a24c39 100644
--- a/src/identity/plugin_rest_identity.c
+++ b/src/identity/plugin_rest_identity.c
@@ -29,7 +29,7 @@
29#include "gnunet_identity_service.h" 29#include "gnunet_identity_service.h"
30#include "gnunet_rest_lib.h" 30#include "gnunet_rest_lib.h"
31#include "identity.h" 31#include "identity.h"
32#include "gnunet_crypto_lib.h" 32#include "gnunet_util_lib.h"
33#include "microhttpd.h" 33#include "microhttpd.h"
34#include <jansson.h> 34#include <jansson.h>
35 35
diff --git a/src/include/.gitignore b/src/include/.gitignore
index 866878f87..b25882925 100644
--- a/src/include/.gitignore
+++ b/src/include/.gitignore
@@ -1,3 +1,6 @@
1gnunet_error_codes.h 1gnunet_error_codes.h
2gnu_name_system_record_flags.h
2gnu_name_system_record_types.h 3gnu_name_system_record_types.h
3gnunet_signatures.h 4gnunet_signatures.h
5!gnunet_config.h.in
6gnunet_config.h
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index 0f091b615..82a81077e 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -4,13 +4,15 @@ SUBDIRS = .
4gnunetincludedir = $(includedir)/gnunet 4gnunetincludedir = $(includedir)/gnunet
5 5
6EXTRA_DIST = \ 6EXTRA_DIST = \
7 platform.h \
7 gauger.h \ 8 gauger.h \
8 block_fs.h \ 9 block_fs.h \
9 block_dns.h \ 10 block_dns.h \
10 block_regex.h 11 block_regex.h
11 12
12gnunetinclude_HEADERS = \ 13gnunetinclude_HEADERS = \
13 platform.h gettext.h \ 14 gnunet_config.h \
15 gettext.h \
14 compat.h \ 16 compat.h \
15 gnunet_abd_service.h \ 17 gnunet_abd_service.h \
16 gnunet_applications.h \ 18 gnunet_applications.h \
@@ -57,6 +59,7 @@ gnunetinclude_HEADERS = \
57 gnunet_gnsrecord_lib.h \ 59 gnunet_gnsrecord_lib.h \
58 gnunet_gnsrecord_json_lib.h \ 60 gnunet_gnsrecord_json_lib.h \
59 gnunet_gnsrecord_plugin.h \ 61 gnunet_gnsrecord_plugin.h \
62 gnu_name_system_record_flags.h \
60 gnu_name_system_record_types.h \ 63 gnu_name_system_record_types.h \
61 gnunet_hello_lib.h \ 64 gnunet_hello_lib.h \
62 gnunet_hello_uri_lib.h \ 65 gnunet_hello_uri_lib.h \
@@ -74,6 +77,7 @@ gnunetinclude_HEADERS = \
74 gnunet_mst_lib.h \ 77 gnunet_mst_lib.h \
75 gnunet_mq_lib.h \ 78 gnunet_mq_lib.h \
76 gnunet_my_lib.h \ 79 gnunet_my_lib.h \
80 gnunet_mysql_compat.h \
77 gnunet_mysql_lib.h \ 81 gnunet_mysql_lib.h \
78 gnunet_namecache_plugin.h \ 82 gnunet_namecache_plugin.h \
79 gnunet_namecache_service.h \ 83 gnunet_namecache_service.h \
diff --git a/src/include/block_dns.h b/src/include/block_dns.h
index 2c573fb20..4ac6d0250 100644
--- a/src/include/block_dns.h
+++ b/src/include/block_dns.h
@@ -33,6 +33,7 @@
33#ifndef BLOCK_DNS_H 33#ifndef BLOCK_DNS_H
34#define BLOCK_DNS_H 34#define BLOCK_DNS_H
35 35
36
36#include "gnunet_util_lib.h" 37#include "gnunet_util_lib.h"
37 38
38GNUNET_NETWORK_STRUCT_BEGIN 39GNUNET_NETWORK_STRUCT_BEGIN
diff --git a/src/include/block_fs.h b/src/include/block_fs.h
index f05bb4a29..b64a83f39 100644
--- a/src/include/block_fs.h
+++ b/src/include/block_fs.h
@@ -34,6 +34,7 @@
34#ifndef BLOCK_FS_H 34#ifndef BLOCK_FS_H
35#define BLOCK_FS_H 35#define BLOCK_FS_H
36 36
37
37#include "gnunet_util_lib.h" 38#include "gnunet_util_lib.h"
38#include "gnunet_fs_service.h" 39#include "gnunet_fs_service.h"
39 40
diff --git a/src/include/block_regex.h b/src/include/block_regex.h
index cc78f2c32..fea19e335 100644
--- a/src/include/block_regex.h
+++ b/src/include/block_regex.h
@@ -36,6 +36,7 @@ extern "C"
36#endif 36#endif
37#endif 37#endif
38 38
39
39#include "gnunet_util_lib.h" 40#include "gnunet_util_lib.h"
40#include <stdint.h> 41#include <stdint.h>
41 42
diff --git a/src/include/gauger.h b/src/include/gauger.h
index 716ce9cb1..f811b335c 100644
--- a/src/include/gauger.h
+++ b/src/include/gauger.h
@@ -11,6 +11,7 @@
11#ifndef __GAUGER_H__ 11#ifndef __GAUGER_H__
12#define __GAUGER_H__ 12#define __GAUGER_H__
13 13
14
14#include <unistd.h> 15#include <unistd.h>
15#include <stdio.h> 16#include <stdio.h>
16#include <sys/wait.h> 17#include <sys/wait.h>
diff --git a/src/include/gettext.h b/src/include/gettext.h
index 458512657..6e98f197a 100644
--- a/src/include/gettext.h
+++ b/src/include/gettext.h
@@ -23,6 +23,7 @@
23#if ENABLE_NLS 23#if ENABLE_NLS
24 24
25/* Get declarations of GNU message catalog functions. */ 25/* Get declarations of GNU message catalog functions. */
26
26#include <libintl.h> 27#include <libintl.h>
27 28
28#else 29#else
diff --git a/src/include/gnunet_abd_service.h b/src/include/gnunet_abd_service.h
index a52ed29ff..75c1757ab 100644
--- a/src/include/gnunet_abd_service.h
+++ b/src/include/gnunet_abd_service.h
@@ -35,6 +35,7 @@
35#ifndef GNUNET_ABD_SERVICE_H 35#ifndef GNUNET_ABD_SERVICE_H
36#define GNUNET_ABD_SERVICE_H 36#define GNUNET_ABD_SERVICE_H
37 37
38
38#include "gnunet_util_lib.h" 39#include "gnunet_util_lib.h"
39#include "gnunet_gns_service.h" 40#include "gnunet_gns_service.h"
40#include "gnunet_identity_service.h" 41#include "gnunet_identity_service.h"
diff --git a/src/include/gnunet_arm_service.h b/src/include/gnunet_arm_service.h
index 9615f8c9d..639e723c5 100644
--- a/src/include/gnunet_arm_service.h
+++ b/src/include/gnunet_arm_service.h
@@ -43,6 +43,7 @@ extern "C"
43#endif 43#endif
44#endif 44#endif
45 45
46
46#include "gnunet_util_lib.h" 47#include "gnunet_util_lib.h"
47 48
48/** 49/**
diff --git a/src/include/gnunet_ats_application_service.h b/src/include/gnunet_ats_application_service.h
index 4d976572e..da7fd4b52 100644
--- a/src/include/gnunet_ats_application_service.h
+++ b/src/include/gnunet_ats_application_service.h
@@ -37,6 +37,7 @@
37#ifndef GNUNET_ATS_APPLICATION_SERVICE_H 37#ifndef GNUNET_ATS_APPLICATION_SERVICE_H
38#define GNUNET_ATS_APPLICATION_SERVICE_H 38#define GNUNET_ATS_APPLICATION_SERVICE_H
39 39
40
40#include "gnunet_constants.h" 41#include "gnunet_constants.h"
41#include "gnunet_util_lib.h" 42#include "gnunet_util_lib.h"
42 43
diff --git a/src/include/gnunet_ats_plugin.h b/src/include/gnunet_ats_plugin.h
index 59d09f690..206f2dd52 100644
--- a/src/include/gnunet_ats_plugin.h
+++ b/src/include/gnunet_ats_plugin.h
@@ -40,6 +40,7 @@
40#ifndef PLUGIN_ATS_H 40#ifndef PLUGIN_ATS_H
41#define PLUGIN_ATS_H 41#define PLUGIN_ATS_H
42 42
43
43#include "gnunet_ats_service.h" 44#include "gnunet_ats_service.h"
44#include "gnunet_statistics_service.h" 45#include "gnunet_statistics_service.h"
45 46
diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h
index 321e621d2..ce149875a 100644
--- a/src/include/gnunet_ats_service.h
+++ b/src/include/gnunet_ats_service.h
@@ -37,6 +37,7 @@
37#ifndef GNUNET_ATS_SERVICE_H 37#ifndef GNUNET_ATS_SERVICE_H
38#define GNUNET_ATS_SERVICE_H 38#define GNUNET_ATS_SERVICE_H
39 39
40
40#include "gnunet_constants.h" 41#include "gnunet_constants.h"
41#include "gnunet_util_lib.h" 42#include "gnunet_util_lib.h"
42#include "gnunet_hello_lib.h" 43#include "gnunet_hello_lib.h"
diff --git a/src/include/gnunet_ats_transport_service.h b/src/include/gnunet_ats_transport_service.h
index fd821baef..b6c7b15ae 100644
--- a/src/include/gnunet_ats_transport_service.h
+++ b/src/include/gnunet_ats_transport_service.h
@@ -34,6 +34,7 @@
34#ifndef GNUNET_ATS_TRANSPORT_SERVICE_H 34#ifndef GNUNET_ATS_TRANSPORT_SERVICE_H
35#define GNUNET_ATS_TRANSPORT_SERVICE_H 35#define GNUNET_ATS_TRANSPORT_SERVICE_H
36 36
37
37#include "gnunet_constants.h" 38#include "gnunet_constants.h"
38#include "gnunet_util_lib.h" 39#include "gnunet_util_lib.h"
39#include "gnunet_nt_lib.h" 40#include "gnunet_nt_lib.h"
diff --git a/src/include/gnunet_bandwidth_lib.h b/src/include/gnunet_bandwidth_lib.h
index 9f173a691..7c854aab5 100644
--- a/src/include/gnunet_bandwidth_lib.h
+++ b/src/include/gnunet_bandwidth_lib.h
@@ -18,6 +18,10 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif
24
21/** 25/**
22 * @addtogroup libgnunetutil 26 * @addtogroup libgnunetutil
23 * Multi-function utilities library for GNUnet programs 27 * Multi-function utilities library for GNUnet programs
@@ -33,6 +37,10 @@
33 * @{ 37 * @{
34 */ 38 */
35 39
40#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
41#error "Only <gnunet_util_lib.h> can be included directly."
42#endif
43
36#ifndef GNUNET_BANDWIDTH_LIB_H 44#ifndef GNUNET_BANDWIDTH_LIB_H
37#define GNUNET_BANDWIDTH_LIB_H 45#define GNUNET_BANDWIDTH_LIB_H
38 46
@@ -43,7 +51,7 @@ extern "C" {
43#endif 51#endif
44#endif 52#endif
45 53
46#include "gnunet_common.h" 54
47#include "gnunet_time_lib.h" 55#include "gnunet_time_lib.h"
48 56
49GNUNET_NETWORK_STRUCT_BEGIN 57GNUNET_NETWORK_STRUCT_BEGIN
diff --git a/src/include/gnunet_bio_lib.h b/src/include/gnunet_bio_lib.h
index 5eefabff2..48a1a512d 100644
--- a/src/include/gnunet_bio_lib.h
+++ b/src/include/gnunet_bio_lib.h
@@ -33,9 +33,14 @@
33 * @{ 33 * @{
34 */ 34 */
35 35
36#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
37#error "Only <gnunet_util_lib.h> can be included directly."
38#endif
39
36#ifndef GNUNET_BIO_LIB_H 40#ifndef GNUNET_BIO_LIB_H
37#define GNUNET_BIO_LIB_H 41#define GNUNET_BIO_LIB_H
38 42
43
39#include "gnunet_container_lib.h" 44#include "gnunet_container_lib.h"
40 45
41#ifdef __cplusplus 46#ifdef __cplusplus
@@ -86,6 +91,15 @@ GNUNET_BIO_read_open_buffer (void *buffer, size_t size);
86int 91int
87GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg); 92GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg);
88 93
94/**
95 * Set read error to handle
96 *
97 * @param h the handle
98 * @param emsg the message
99 */
100void
101GNUNET_BIO_read_set_error (struct GNUNET_BIO_ReadHandle *h, const char* emsg);
102
89 103
90/** 104/**
91 * Read some contents into a buffer. 105 * Read some contents into a buffer.
@@ -120,19 +134,6 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
120 size_t max_length); 134 size_t max_length);
121 135
122 136
123/**
124 * Read a metadata container.
125 *
126 * @param h handle to an open file
127 * @param what describes what is being read (for error message creation)
128 * @param result the buffer to store a pointer to the (allocated) metadata
129 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
130 */
131int
132GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
133 const char *what,
134 struct GNUNET_CONTAINER_MetaData **result);
135
136 137
137/** 138/**
138 * Read a float. 139 * Read a float.
@@ -289,19 +290,6 @@ GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h,
289 const char *s); 290 const char *s);
290 291
291 292
292/**
293 * Write a metadata container.
294 *
295 * @param h the IO handle to write to
296 * @param what what is being written (for error message creation)
297 * @param m metadata to write
298 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
299 */
300int
301GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
302 const char *what,
303 const struct GNUNET_CONTAINER_MetaData *m);
304
305 293
306/** 294/**
307 * Write a float. 295 * Write a float.
@@ -448,17 +436,6 @@ GNUNET_BIO_read_spec_string (const char *what,
448 size_t max_length); 436 size_t max_length);
449 437
450 438
451/**
452 * Create the specification to read a metadata container.
453 *
454 * @param what describes what is being read (for error message creation)
455 * @param result the buffer to store a pointer to the (allocated) metadata
456 * @return the read spec
457 */
458struct GNUNET_BIO_ReadSpec
459GNUNET_BIO_read_spec_meta_data (const char *what,
460 struct GNUNET_CONTAINER_MetaData **result);
461
462 439
463/** 440/**
464 * Create the specification to read an (u)int32_t. 441 * Create the specification to read an (u)int32_t.
@@ -605,18 +582,6 @@ GNUNET_BIO_write_spec_string (const char *what,
605 582
606 583
607/** 584/**
608 * Create the specification to write a metadata container.
609 *
610 * @param what what is being written (for error message creation)
611 * @param m metadata to write
612 * @return the write spec
613 */
614struct GNUNET_BIO_WriteSpec
615GNUNET_BIO_write_spec_meta_data (const char *what,
616 const struct GNUNET_CONTAINER_MetaData *m);
617
618
619/**
620 * Create the specification to write an (u)int32_t. 585 * Create the specification to write an (u)int32_t.
621 * 586 *
622 * @param what describes what is being written (for error message creation) 587 * @param what describes what is being written (for error message creation)
diff --git a/src/include/gnunet_block_group_lib.h b/src/include/gnunet_block_group_lib.h
index 53827f5f4..b1f59899e 100644
--- a/src/include/gnunet_block_group_lib.h
+++ b/src/include/gnunet_block_group_lib.h
@@ -31,6 +31,7 @@
31#ifndef GNUNET_BLOCK_GROUP_LIB_H 31#ifndef GNUNET_BLOCK_GROUP_LIB_H
32#define GNUNET_BLOCK_GROUP_LIB_H 32#define GNUNET_BLOCK_GROUP_LIB_H
33 33
34
34#include "gnunet_util_lib.h" 35#include "gnunet_util_lib.h"
35#include "gnunet_block_lib.h" 36#include "gnunet_block_lib.h"
36 37
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h
index 6a6de712b..fdccbab78 100644
--- a/src/include/gnunet_block_lib.h
+++ b/src/include/gnunet_block_lib.h
@@ -34,6 +34,7 @@
34#ifndef GNUNET_BLOCK_LIB_H 34#ifndef GNUNET_BLOCK_LIB_H
35#define GNUNET_BLOCK_LIB_H 35#define GNUNET_BLOCK_LIB_H
36 36
37
37#include "gnunet_util_lib.h" 38#include "gnunet_util_lib.h"
38#include "gnunet_dht_block_types.h" 39#include "gnunet_dht_block_types.h"
39 40
diff --git a/src/include/gnunet_block_plugin.h b/src/include/gnunet_block_plugin.h
index 7cd744ac4..16e93c780 100644
--- a/src/include/gnunet_block_plugin.h
+++ b/src/include/gnunet_block_plugin.h
@@ -38,6 +38,7 @@
38#ifndef PLUGIN_BLOCK_H 38#ifndef PLUGIN_BLOCK_H
39#define PLUGIN_BLOCK_H 39#define PLUGIN_BLOCK_H
40 40
41
41#include "gnunet_util_lib.h" 42#include "gnunet_util_lib.h"
42#include "gnunet_block_lib.h" 43#include "gnunet_block_lib.h"
43 44
diff --git a/src/include/gnunet_buffer_lib.h b/src/include/gnunet_buffer_lib.h
index 174d2d010..e65981206 100644
--- a/src/include/gnunet_buffer_lib.h
+++ b/src/include/gnunet_buffer_lib.h
@@ -28,6 +28,10 @@
28 * @author Florian Dold 28 * @author Florian Dold
29 */ 29 */
30 30
31#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
32#error "Only <gnunet_util_lib.h> can be included directly."
33#endif
34
31#ifndef GNUNET_BUFFER_LIB_H 35#ifndef GNUNET_BUFFER_LIB_H
32#define GNUNET_BUFFER_LIB_H 36#define GNUNET_BUFFER_LIB_H
33 37
diff --git a/src/include/gnunet_cadet_service.h b/src/include/gnunet_cadet_service.h
index 45c70df3e..acc7bb330 100644
--- a/src/include/gnunet_cadet_service.h
+++ b/src/include/gnunet_cadet_service.h
@@ -45,6 +45,7 @@ extern "C" {
45#endif 45#endif
46#endif 46#endif
47 47
48
48#include "gnunet_util_lib.h" 49#include "gnunet_util_lib.h"
49#include "gnunet_transport_service.h" 50#include "gnunet_transport_service.h"
50 51
diff --git a/src/include/gnunet_child_management_lib.h b/src/include/gnunet_child_management_lib.h
index e7f1271ee..d8f63b60d 100644
--- a/src/include/gnunet_child_management_lib.h
+++ b/src/include/gnunet_child_management_lib.h
@@ -18,6 +18,10 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif
24
21/** 25/**
22 * @addtogroup libgnunetutil 26 * @addtogroup libgnunetutil
23 * Multi-function utilities library for GNUnet programs 27 * Multi-function utilities library for GNUnet programs
diff --git a/src/include/gnunet_client_lib.h b/src/include/gnunet_client_lib.h
index 321810eb4..ab4c7d088 100644
--- a/src/include/gnunet_client_lib.h
+++ b/src/include/gnunet_client_lib.h
@@ -39,6 +39,10 @@
39 * @{ 39 * @{
40 */ 40 */
41 41
42#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
43#error "Only <gnunet_util_lib.h> can be included directly."
44#endif
45
42#ifndef GNUNET_CLIENT_LIB_H 46#ifndef GNUNET_CLIENT_LIB_H
43#define GNUNET_CLIENT_LIB_H 47#define GNUNET_CLIENT_LIB_H
44 48
@@ -50,6 +54,7 @@ extern "C"
50#endif 54#endif
51#endif 55#endif
52 56
57
53#include "gnunet_mq_lib.h" 58#include "gnunet_mq_lib.h"
54 59
55 60
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index 8c58fd6e3..07a847814 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -40,28 +40,37 @@
40#ifndef GNUNET_COMMON_H 40#ifndef GNUNET_COMMON_H
41#define GNUNET_COMMON_H 41#define GNUNET_COMMON_H
42 42
43#include "gnunet_config.h"
44
43#include <stdlib.h> 45#include <stdlib.h>
44#if HAVE_SYS_SOCKET_H
45#include <sys/socket.h> 46#include <sys/socket.h>
46#endif 47#include <sys/un.h>
47#if HAVE_NETINET_IN_H
48#include <netinet/in.h> 48#include <netinet/in.h>
49#endif 49#include <arpa/inet.h>
50#ifdef HAVE_STDINT_H
51#include <stdint.h> 50#include <stdint.h>
52#endif
53#ifdef HAVE_STDARG_H
54#include <stdarg.h> 51#include <stdarg.h>
55#endif
56#ifdef HAVE_SYS_TYPES_H
57#include <sys/types.h> 52#include <sys/types.h>
58#endif
59#ifdef HAVE_SYS_SOCKET_H
60#include <sys/socket.h>
61#endif
62 53
54#if defined(__FreeBSD__)
55
56#include <sys/endian.h>
57#define bswap_32(x) bswap32(x)
58#define bswap_64(x) bswap64(x)
59
60#elif defined(__OpenBSD__)
61
62#define bswap_32(x) swap32(x)
63#define bswap_64(x) swap64(x)
64
65#elif defined(__NetBSD__)
66
67#include <machine/bswap.h>
68#if defined(__BSWAP_RENAME) && !defined(__bswap_32)
69#define bswap_32(x) bswap32(x)
70#define bswap_64(x) bswap64(x)
71#endif
63 72
64#ifdef HAVE_BYTESWAP_H 73#elif defined(__linux__) || defined(GNU)
65#include <byteswap.h> 74#include <byteswap.h>
66#endif 75#endif
67 76
@@ -155,7 +164,7 @@ enum GNUNET_GenericReturnValue
155 */ 164 */
156 165
157#if __BYTE_ORDER == __LITTLE_ENDIAN 166#if __BYTE_ORDER == __LITTLE_ENDIAN
158#ifdef HAVE_BYTESWAP_H 167#if defined(bswap_16) || defined(bswap_32) || defined(bswap_64)
159#define BYTE_SWAP_16(x) bswap_16 (x) 168#define BYTE_SWAP_16(x) bswap_16 (x)
160#define BYTE_SWAP_32(x) bswap_32 (x) 169#define BYTE_SWAP_32(x) bswap_32 (x)
161#define BYTE_SWAP_64(x) bswap_64 (x) 170#define BYTE_SWAP_64(x) bswap_64 (x)
@@ -984,7 +993,7 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
984 } while (0) 993 } while (0)
985 994
986 995
987#if HAVE_STATIC_ASSERT 996#ifdef _Static_assert
988/** 997/**
989 * Assertion to be checked (if supported by C compiler) at 998 * Assertion to be checked (if supported by C compiler) at
990 * compile time, otherwise checked at runtime and resulting 999 * compile time, otherwise checked at runtime and resulting
diff --git a/src/include/gnunet_config.h.in b/src/include/gnunet_config.h.in
new file mode 100644
index 000000000..5dff759ae
--- /dev/null
+++ b/src/include/gnunet_config.h.in
@@ -0,0 +1,58 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2022 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21#ifndef GNUNET_CONFIG_H
22#define GNUNET_CONFIG_H
23
24/**
25 * @author Martin Schanzenbach
26 *
27 * @file
28 * Convenience header including public (!) information on the
29 * installed GNUnet configuration.
30 *
31 */
32
33/* The version of GNUnet */
34#define GNUNET_VERSION "@gnunet_version@"
35
36/* Major version */
37#define GNUNET_MAJOR_VERSION @gnunet_major_version@
38
39/* Micro version */
40#define GNUNET_MINOR_VERSION @gnunet_minor_version@
41
42/* Mico version */
43#define GNUNET_MICRO_VERSION @gnunet_micro_version@
44
45/* Set to 1 is this is an experimental build */
46#define GNUNET_EXPERIMENTAL @enable_experimental@
47
48/* Set to 1 if GnuTLS has DANE support */
49#define GNUNET_CURL_GNUTLS @curl_gnutls@
50
51/**
52 * Set to 1 if file-sharing meta data parsing is built with
53 * libextractor, which means that callers to the API must use also use
54 * libextractor.
55 */
56#define GNUNET_FS_EXTRACTOR_ENABLED @extractor@
57
58#endif
diff --git a/src/include/gnunet_configuration_lib.h b/src/include/gnunet_configuration_lib.h
index 2d26f3c05..3b9be5849 100644
--- a/src/include/gnunet_configuration_lib.h
+++ b/src/include/gnunet_configuration_lib.h
@@ -35,6 +35,7 @@
35#ifndef GNUNET_CONFIGURATION_LIB_H 35#ifndef GNUNET_CONFIGURATION_LIB_H
36#define GNUNET_CONFIGURATION_LIB_H 36#define GNUNET_CONFIGURATION_LIB_H
37 37
38
38#include "gnunet_time_lib.h" 39#include "gnunet_time_lib.h"
39 40
40#ifdef __cplusplus 41#ifdef __cplusplus
diff --git a/src/include/gnunet_consensus_service.h b/src/include/gnunet_consensus_service.h
index 1d2ec63cd..47a928d9c 100644
--- a/src/include/gnunet_consensus_service.h
+++ b/src/include/gnunet_consensus_service.h
@@ -43,6 +43,7 @@ extern "C"
43#endif 43#endif
44#endif 44#endif
45 45
46
46#include "gnunet_common.h" 47#include "gnunet_common.h"
47#include "gnunet_time_lib.h" 48#include "gnunet_time_lib.h"
48#include "gnunet_configuration_lib.h" 49#include "gnunet_configuration_lib.h"
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h
index b31a95fac..1d39f813b 100644
--- a/src/include/gnunet_container_lib.h
+++ b/src/include/gnunet_container_lib.h
@@ -28,11 +28,11 @@
28 * 28 *
29 * @file 29 * @file
30 * Container classes for GNUnet 30 * Container classes for GNUnet
31 * 31 *
32 * @addtogroup container 32 * @addtogroup container
33 * Common data structures in GNUnet programs 33 * Common data structures in GNUnet programs
34 * @{ 34 * @{
35 * 35 *
36 * @defgroup hashmap MultiHashMap 36 * @defgroup hashmap MultiHashMap
37 * Hash map with multiple values per key. 37 * Hash map with multiple values per key.
38 * 38 *
@@ -48,16 +48,19 @@
48 * 48 *
49 * @see [Documentation](https://gnunet.org/mdll-api) 49 * @see [Documentation](https://gnunet.org/mdll-api)
50 * 50 *
51 * @defgroup metadata Metadata 51 *
52 * GNU libextractor key-value pairs
53 *
54 * @} 52 * @}
55 */ 53 */
56 54
55#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
56#error "Only <gnunet_util_lib.h> can be included directly."
57#endif
58
57#ifndef GNUNET_CONTAINER_LIB_H 59#ifndef GNUNET_CONTAINER_LIB_H
58#define GNUNET_CONTAINER_LIB_H 60#define GNUNET_CONTAINER_LIB_H
59 61
60/* add error and config prototypes */ 62/* add error and config prototypes */
63
61#include "gnunet_crypto_lib.h" 64#include "gnunet_crypto_lib.h"
62 65
63 66
@@ -97,114 +100,6 @@ char *
97GNUNET_decompress (const char *input, size_t input_size, size_t output_size); 100GNUNET_decompress (const char *input, size_t input_size, size_t output_size);
98 101
99 102
100#if HAVE_EXTRACTOR_H
101
102#include <extractor.h>
103
104#else
105
106/* definitions from extractor.h we need for the build */
107
108/**
109 * Enumeration defining various sources of keywords. See also
110 * http://dublincore.org/documents/1998/09/dces/
111 */
112enum EXTRACTOR_MetaType
113{
114 EXTRACTOR_METATYPE_RESERVED = 0,
115 EXTRACTOR_METATYPE_MIMETYPE = 1,
116 EXTRACTOR_METATYPE_FILENAME = 2,
117 EXTRACTOR_METATYPE_COMMENT = 3,
118 EXTRACTOR_METATYPE_TITLE = 4,
119 EXTRACTOR_METATYPE_BOOK_TITLE = 5,
120 EXTRACTOR_METATYPE_JOURNAL_NAME = 8,
121 EXTRACTOR_METATYPE_AUTHOR_NAME = 13,
122 EXTRACTOR_METATYPE_PUBLICATION_DATE = 24,
123 EXTRACTOR_METATYPE_URL = 29,
124 EXTRACTOR_METATYPE_URI = 30,
125 EXTRACTOR_METATYPE_ISRC = 31,
126 EXTRACTOR_METATYPE_UNKNOWN = 45,
127 EXTRACTOR_METATYPE_DESCRIPTION = 46,
128 EXTRACTOR_METATYPE_KEYWORDS = 49,
129 EXTRACTOR_METATYPE_SUBJECT = 52,
130 EXTRACTOR_METATYPE_PACKAGE_NAME = 69,
131 EXTRACTOR_METATYPE_THUMBNAIL = 114,
132 EXTRACTOR_METATYPE_ALBUM = 129,
133 EXTRACTOR_METATYPE_ARTIST = 130,
134 EXTRACTOR_METATYPE_ORIGINAL_TITLE = 162,
135 EXTRACTOR_METATYPE_GNUNET_FULL_DATA = 174,
136 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME = 180,
137};
138
139/**
140 * Format in which the extracted meta data is presented.
141 */
142enum EXTRACTOR_MetaFormat
143{
144 /**
145 * Format is unknown.
146 */
147 EXTRACTOR_METAFORMAT_UNKNOWN = 0,
148
149 /**
150 * 0-terminated, UTF-8 encoded string. "data_len"
151 * is strlen(data)+1.
152 */
153 EXTRACTOR_METAFORMAT_UTF8 = 1,
154
155 /**
156 * Some kind of binary format, see given Mime type.
157 */
158 EXTRACTOR_METAFORMAT_BINARY = 2,
159
160 /**
161 * 0-terminated string. The specific encoding is unknown.
162 * "data_len" is strlen (data)+1.
163 */
164 EXTRACTOR_METAFORMAT_C_STRING = 3
165};
166
167
168/**
169 * Type of a function that libextractor calls for each
170 * meta data item found.
171 *
172 * @param cls closure (user-defined)
173 * @param plugin_name name of the plugin that produced this value;
174 * special values can be used (e.g. '&lt;zlib&gt;' for zlib being
175 * used in the main libextractor library and yielding
176 * meta data).
177 * @param type libextractor-type describing the meta data
178 * @param format basic format information about @a data
179 * @param data_mime_type mime-type of @a data (not of the original file);
180 * can be NULL (if mime-type is not known)
181 * @param data actual meta-data found
182 * @param data_len number of bytes in @a data
183 * @return 0 to continue extracting, 1 to abort
184 */
185typedef int (*EXTRACTOR_MetaDataProcessor) (void *cls,
186 const char *plugin_name,
187 enum EXTRACTOR_MetaType type,
188 enum EXTRACTOR_MetaFormat format,
189 const char *data_mime_type,
190 const char *data,
191 size_t data_len);
192
193#endif
194
195#ifndef EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
196/* hack for LE < 0.6.3 */
197#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME 180
198#endif
199
200#ifdef __cplusplus
201extern "C" {
202#if 0 /* keep Emacsens' auto-indent happy */
203}
204#endif
205#endif
206
207
208/* ******************* bloomfilter ***************** */ 103/* ******************* bloomfilter ***************** */
209 104
210/** 105/**
@@ -430,285 +325,6 @@ GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf,
430 unsigned int k); 325 unsigned int k);
431 326
432 327
433/* ****************** metadata ******************* */
434
435/**
436 * @ingroup metadata
437 * Meta data to associate with a file, directory or namespace.
438 */
439struct GNUNET_CONTAINER_MetaData;
440
441
442/**
443 * @ingroup metadata
444 * Create a fresh meta data container.
445 *
446 * @return empty meta-data container
447 */
448struct GNUNET_CONTAINER_MetaData *
449GNUNET_CONTAINER_meta_data_create (void);
450
451
452/**
453 * @ingroup metadata
454 * Duplicate a MetaData token.
455 *
456 * @param md what to duplicate
457 * @return duplicate meta-data container
458 */
459struct GNUNET_CONTAINER_MetaData *
460GNUNET_CONTAINER_meta_data_duplicate (
461 const struct GNUNET_CONTAINER_MetaData *md);
462
463
464/**
465 * @ingroup metadata
466 * Free meta data.
467 *
468 * @param md what to free
469 */
470void
471GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md);
472
473
474/**
475 * @ingroup metadata
476 * Test if two MDs are equal. We consider them equal if
477 * the meta types, formats and content match (we do not
478 * include the mime types and plugins names in this
479 * consideration).
480 *
481 * @param md1 first value to check
482 * @param md2 other value to check
483 * @return #GNUNET_YES if they are equal
484 */
485int
486GNUNET_CONTAINER_meta_data_test_equal (
487 const struct GNUNET_CONTAINER_MetaData *md1,
488 const struct GNUNET_CONTAINER_MetaData *md2);
489
490
491/**
492 * @ingroup metadata
493 * Extend metadata.
494 *
495 * @param md metadata to extend
496 * @param plugin_name name of the plugin that produced this value;
497 * special values can be used (e.g. '&lt;zlib&gt;' for zlib being
498 * used in the main libextractor library and yielding
499 * meta data).
500 * @param type libextractor-type describing the meta data
501 * @param format basic format information about data
502 * @param data_mime_type mime-type of data (not of the original file);
503 * can be NULL (if mime-type is not known)
504 * @param data actual meta-data found
505 * @param data_size number of bytes in data
506 * @return #GNUNET_OK on success, #GNUNET_SYSERR if this entry already exists
507 * data_mime_type and plugin_name are not considered for "exists" checks
508 */
509int
510GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md,
511 const char *plugin_name,
512 enum EXTRACTOR_MetaType type,
513 enum EXTRACTOR_MetaFormat format,
514 const char *data_mime_type,
515 const char *data,
516 size_t data_size);
517
518
519/**
520 * @ingroup metadata
521 * Extend metadata. Merges the meta data from the second argument
522 * into the first, discarding duplicate key-value pairs.
523 *
524 * @param md metadata to extend
525 * @param in metadata to merge
526 */
527void
528GNUNET_CONTAINER_meta_data_merge (struct GNUNET_CONTAINER_MetaData *md,
529 const struct GNUNET_CONTAINER_MetaData *in);
530
531
532/**
533 * @ingroup metadata
534 * Remove an item.
535 *
536 * @param md metadata to manipulate
537 * @param type type of the item to remove
538 * @param data specific value to remove, NULL to remove all
539 * entries of the given type
540 * @param data_size number of bytes in data
541 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the item does not exist in md
542 */
543int
544GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md,
545 enum EXTRACTOR_MetaType type,
546 const char *data,
547 size_t data_size);
548
549
550/**
551 * @ingroup metadata
552 * Remove all items in the container.
553 *
554 * @param md metadata to manipulate
555 */
556void
557GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md);
558
559
560/**
561 * @ingroup metadata
562 * Add the current time as the publication date
563 * to the meta-data.
564 *
565 * @param md metadata to modify
566 */
567void
568GNUNET_CONTAINER_meta_data_add_publication_date (
569 struct GNUNET_CONTAINER_MetaData *md);
570
571
572/**
573 * @ingroup metadata
574 * Iterate over MD entries.
575 *
576 * @param md metadata to inspect
577 * @param iter function to call on each entry, return 0 to continue to iterate
578 * and 1 to abort iteration in this function (GNU libextractor API!)
579 * @param iter_cls closure for @a iter
580 * @return number of entries
581 */
582int
583GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md,
584 EXTRACTOR_MetaDataProcessor iter,
585 void *iter_cls);
586
587
588/**
589 * @ingroup metadata
590 * Get the first MD entry of the given type. Caller
591 * is responsible for freeing the return value.
592 * Also, only meta data items that are strings (0-terminated)
593 * are returned by this function.
594 *
595 * @param md metadata to inspect
596 * @param type type to look for
597 * @return NULL if no entry was found
598 */
599char *
600GNUNET_CONTAINER_meta_data_get_by_type (
601 const struct GNUNET_CONTAINER_MetaData *md,
602 enum EXTRACTOR_MetaType type);
603
604
605/**
606 * @ingroup metadata
607 * Get the first matching MD entry of the given types. Caller is
608 * responsible for freeing the return value. Also, only meta data
609 * items that are strings (0-terminated) are returned by this
610 * function.
611 *
612 * @param md metadata to inspect
613 * @param ... -1-terminated list of types
614 * @return NULL if we do not have any such entry,
615 * otherwise client is responsible for freeing the value!
616 */
617char *
618GNUNET_CONTAINER_meta_data_get_first_by_types (
619 const struct GNUNET_CONTAINER_MetaData *md,
620 ...);
621
622/**
623 * @ingroup metadata
624 * Get a thumbnail from the meta-data (if present). Only matches meta
625 * data with mime type "image" and binary format.
626 *
627 * @param md metadata to inspect
628 * @param thumb will be set to the thumbnail data. Must be
629 * freed by the caller!
630 * @return number of bytes in thumbnail, 0 if not available
631 */
632size_t
633GNUNET_CONTAINER_meta_data_get_thumbnail (
634 const struct GNUNET_CONTAINER_MetaData *md,
635 unsigned char **thumb);
636
637
638/**
639 * @ingroup metadata
640 * Options for metadata serialization.
641 */
642enum GNUNET_CONTAINER_MetaDataSerializationOptions
643{
644 /**
645 * @ingroup metadata
646 * Serialize all of the data.
647 */
648 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL = 0,
649
650 /**
651 * @ingroup metadata
652 * If not enough space is available, it is acceptable
653 * to only serialize some of the metadata.
654 */
655 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART = 1,
656
657 /**
658 * @ingroup metadata
659 * Speed is of the essence, do not allow compression.
660 */
661 GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS = 2
662};
663
664
665/**
666 * @ingroup metadata
667 * Serialize meta-data to target.
668 *
669 * @param md metadata to serialize
670 * @param target where to write the serialized metadata;
671 * *target can be NULL, in which case memory is allocated
672 * @param max maximum number of bytes available
673 * @param opt is it ok to just write SOME of the
674 * meta-data to match the size constraint,
675 * possibly discarding some data?
676 * @return number of bytes written on success,
677 * -1 on error (typically: not enough
678 * space)
679 */
680ssize_t
681GNUNET_CONTAINER_meta_data_serialize (
682 const struct GNUNET_CONTAINER_MetaData *md,
683 char **target,
684 size_t max,
685 enum GNUNET_CONTAINER_MetaDataSerializationOptions opt);
686
687
688/**
689 * @ingroup metadata
690 * Get the size of the full meta-data in serialized form.
691 *
692 * @param md metadata to inspect
693 * @return number of bytes needed for serialization, -1 on error
694 */
695ssize_t
696GNUNET_CONTAINER_meta_data_get_serialized_size (
697 const struct GNUNET_CONTAINER_MetaData *md);
698
699
700/**
701 * @ingroup metadata
702 * Deserialize meta-data. Initializes md.
703 *
704 * @param input serialized meta-data.
705 * @param size number of bytes available
706 * @return MD on success, NULL on error (e.g.
707 * bad format)
708 */
709struct GNUNET_CONTAINER_MetaData *
710GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size);
711
712 328
713/* ******************************* HashMap **************************** */ 329/* ******************************* HashMap **************************** */
714 330
@@ -1264,10 +880,10 @@ GNUNET_CONTAINER_multipeermap_iterator_create (
1264 * position. If there are no elements left, #GNUNET_NO is returned, 880 * position. If there are no elements left, #GNUNET_NO is returned,
1265 * and @a key and @a value are not modified. 881 * and @a key and @a value are not modified.
1266 * 882 *
1267 * This operation is only allowed if no elements have been removed 883 * This operation is only allowed if no elements have been removed
1268 * from the multihashmap since the creation of @a iter, and the map 884 * from the multihashmap since the creation of @a iter, and the map
1269 * has not been destroyed. 885 * has not been destroyed.
1270 * 886 *
1271 * Adding elements may result in repeating or skipping elements. 887 * Adding elements may result in repeating or skipping elements.
1272 * 888 *
1273 * @param iter the iterator to get the next element from 889 * @param iter the iterator to get the next element from
diff --git a/src/include/gnunet_conversation_service.h b/src/include/gnunet_conversation_service.h
index e201c2cf3..7d54914d1 100644
--- a/src/include/gnunet_conversation_service.h
+++ b/src/include/gnunet_conversation_service.h
@@ -61,6 +61,7 @@ extern "C"
61#endif 61#endif
62#endif 62#endif
63 63
64
64#include "gnunet_util_lib.h" 65#include "gnunet_util_lib.h"
65#include "gnunet_identity_service.h" 66#include "gnunet_identity_service.h"
66#include "gnunet_namestore_service.h" 67#include "gnunet_namestore_service.h"
diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h
index 4b824980b..4e188df87 100644
--- a/src/include/gnunet_core_service.h
+++ b/src/include/gnunet_core_service.h
@@ -43,6 +43,7 @@ extern "C" {
43#endif 43#endif
44#endif 44#endif
45 45
46
46#include "gnunet_util_lib.h" 47#include "gnunet_util_lib.h"
47#include "gnunet_transport_service.h" 48#include "gnunet_transport_service.h"
48 49
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 36e6743b3..8d400118a 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -44,6 +44,10 @@
44 * @see [Documentation](https://gnunet.org/crypto-api) 44 * @see [Documentation](https://gnunet.org/crypto-api)
45 */ 45 */
46 46
47#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
48#error "Only <gnunet_util_lib.h> can be included directly."
49#endif
50
47#ifndef GNUNET_CRYPTO_LIB_H 51#ifndef GNUNET_CRYPTO_LIB_H
48#define GNUNET_CRYPTO_LIB_H 52#define GNUNET_CRYPTO_LIB_H
49 53
@@ -54,6 +58,7 @@ extern "C" {
54#endif 58#endif
55#endif 59#endif
56 60
61
57#include <stdbool.h> 62#include <stdbool.h>
58#include <sodium.h> 63#include <sodium.h>
59 64
@@ -62,7 +67,6 @@ extern "C" {
62 */ 67 */
63struct GNUNET_PeerIdentity; 68struct GNUNET_PeerIdentity;
64 69
65#include "gnunet_common.h"
66#include <gcrypt.h> 70#include <gcrypt.h>
67 71
68 72
diff --git a/src/include/gnunet_curl_lib.h b/src/include/gnunet_curl_lib.h
index 92334887d..bdf3843b1 100644
--- a/src/include/gnunet_curl_lib.h
+++ b/src/include/gnunet_curl_lib.h
@@ -32,6 +32,7 @@
32 */ 32 */
33#ifndef GNUNET_CURL_LIB_H 33#ifndef GNUNET_CURL_LIB_H
34#define GNUNET_CURL_LIB_H 34#define GNUNET_CURL_LIB_H
35
35#include <curl/curl.h> 36#include <curl/curl.h>
36#include "gnunet_util_lib.h" 37#include "gnunet_util_lib.h"
37 38
diff --git a/src/include/gnunet_datacache_lib.h b/src/include/gnunet_datacache_lib.h
index 5a876af8c..2c7bf1e8f 100644
--- a/src/include/gnunet_datacache_lib.h
+++ b/src/include/gnunet_datacache_lib.h
@@ -40,6 +40,7 @@
40#ifndef GNUNET_DATACACHE_LIB_H 40#ifndef GNUNET_DATACACHE_LIB_H
41#define GNUNET_DATACACHE_LIB_H 41#define GNUNET_DATACACHE_LIB_H
42 42
43
43#include "gnunet_util_lib.h" 44#include "gnunet_util_lib.h"
44#include "gnunet_block_lib.h" 45#include "gnunet_block_lib.h"
45#include "gnunet_dht_service.h" 46#include "gnunet_dht_service.h"
diff --git a/src/include/gnunet_datacache_plugin.h b/src/include/gnunet_datacache_plugin.h
index 298623cb1..e144e155e 100644
--- a/src/include/gnunet_datacache_plugin.h
+++ b/src/include/gnunet_datacache_plugin.h
@@ -34,6 +34,7 @@
34#ifndef PLUGIN_DATACACHE_H 34#ifndef PLUGIN_DATACACHE_H
35#define PLUGIN_DATACACHE_H 35#define PLUGIN_DATACACHE_H
36 36
37
37#include "gnunet_datacache_lib.h" 38#include "gnunet_datacache_lib.h"
38 39
39#ifdef __cplusplus 40#ifdef __cplusplus
diff --git a/src/include/gnunet_datastore_plugin.h b/src/include/gnunet_datastore_plugin.h
index 3de08b788..c4f31c7ce 100644
--- a/src/include/gnunet_datastore_plugin.h
+++ b/src/include/gnunet_datastore_plugin.h
@@ -34,6 +34,7 @@
34#ifndef PLUGIN_DATASTORE_H 34#ifndef PLUGIN_DATASTORE_H
35#define PLUGIN_DATASTORE_H 35#define PLUGIN_DATASTORE_H
36 36
37
37#include "gnunet_block_lib.h" 38#include "gnunet_block_lib.h"
38#include "gnunet_configuration_lib.h" 39#include "gnunet_configuration_lib.h"
39#include "gnunet_datastore_service.h" 40#include "gnunet_datastore_service.h"
@@ -101,17 +102,17 @@ struct GNUNET_DATASTORE_PluginEnvironment
101 * @return #GNUNET_OK to keep the item 102 * @return #GNUNET_OK to keep the item
102 * #GNUNET_NO to delete the item 103 * #GNUNET_NO to delete the item
103 */ 104 */
104typedef int 105typedef enum GNUNET_GenericReturnValue
105(*PluginDatumProcessor) (void *cls, 106(*PluginDatumProcessor)(void *cls,
106 const struct GNUNET_HashCode *key, 107 const struct GNUNET_HashCode *key,
107 uint32_t size, 108 uint32_t size,
108 const void *data, 109 const void *data,
109 enum GNUNET_BLOCK_Type type, 110 enum GNUNET_BLOCK_Type type,
110 uint32_t priority, 111 uint32_t priority,
111 uint32_t anonymity, 112 uint32_t anonymity,
112 uint32_t replication, 113 uint32_t replication,
113 struct GNUNET_TIME_Absolute expiration, 114 struct GNUNET_TIME_Absolute expiration,
114 uint64_t uid); 115 uint64_t uid);
115 116
116 117
117/** 118/**
diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h
index c2ec9ce1f..153387238 100644
--- a/src/include/gnunet_datastore_service.h
+++ b/src/include/gnunet_datastore_service.h
@@ -42,6 +42,7 @@
42#ifndef GNUNET_DATASTORE_SERVICE_H 42#ifndef GNUNET_DATASTORE_SERVICE_H
43#define GNUNET_DATASTORE_SERVICE_H 43#define GNUNET_DATASTORE_SERVICE_H
44 44
45
45#include "gnunet_util_lib.h" 46#include "gnunet_util_lib.h"
46#include "gnunet_block_lib.h" 47#include "gnunet_block_lib.h"
47 48
diff --git a/src/include/gnunet_db_lib.h b/src/include/gnunet_db_lib.h
index e88e836f6..1ff665c2b 100644
--- a/src/include/gnunet_db_lib.h
+++ b/src/include/gnunet_db_lib.h
@@ -25,6 +25,7 @@
25#ifndef GNUNET_DB_LIB_H 25#ifndef GNUNET_DB_LIB_H
26#define GNUNET_DB_LIB_H 26#define GNUNET_DB_LIB_H
27 27
28
28#include "gnunet_common.h" 29#include "gnunet_common.h"
29 30
30/** 31/**
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h
index 0d1041a88..3d1264991 100644
--- a/src/include/gnunet_dht_service.h
+++ b/src/include/gnunet_dht_service.h
@@ -40,6 +40,7 @@
40#ifndef GNUNET_DHT_SERVICE_H 40#ifndef GNUNET_DHT_SERVICE_H
41#define GNUNET_DHT_SERVICE_H 41#define GNUNET_DHT_SERVICE_H
42 42
43
43#include "gnunet_util_lib.h" 44#include "gnunet_util_lib.h"
44#include "gnunet_block_lib.h" 45#include "gnunet_block_lib.h"
45#include "gnunet_hello_lib.h" 46#include "gnunet_hello_lib.h"
diff --git a/src/include/gnunet_dhtu_plugin.h b/src/include/gnunet_dhtu_plugin.h
index 81b0f1d7b..0503dda1c 100644
--- a/src/include/gnunet_dhtu_plugin.h
+++ b/src/include/gnunet_dhtu_plugin.h
@@ -27,6 +27,7 @@
27#ifndef PLUGIN_DHTU_H 27#ifndef PLUGIN_DHTU_H
28#define PLUGIN_DHTU_H 28#define PLUGIN_DHTU_H
29 29
30
30#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
31 32
32 33
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h
index c76cdc231..b14c5e59d 100644
--- a/src/include/gnunet_disk_lib.h
+++ b/src/include/gnunet_disk_lib.h
@@ -31,6 +31,11 @@
31 * Disk IO APIs 31 * Disk IO APIs
32 * @{ 32 * @{
33 */ 33 */
34
35#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
36#error "Only <gnunet_util_lib.h> can be included directly."
37#endif
38
34#ifndef GNUNET_DISK_LIB_H 39#ifndef GNUNET_DISK_LIB_H
35#define GNUNET_DISK_LIB_H 40#define GNUNET_DISK_LIB_H
36 41
@@ -76,6 +81,7 @@ struct GNUNET_DISK_FileHandle
76 or unsigned long long, this IS platform dependent; 81 or unsigned long long, this IS platform dependent;
77 but "stdlib.h" should be portable 'enough' to be 82 but "stdlib.h" should be portable 'enough' to be
78 unconditionally available... */ 83 unconditionally available... */
84
79#include <stdlib.h> 85#include <stdlib.h>
80#include "gnunet_configuration_lib.h" 86#include "gnunet_configuration_lib.h"
81#include "gnunet_scheduler_lib.h" 87#include "gnunet_scheduler_lib.h"
diff --git a/src/include/gnunet_dns_service.h b/src/include/gnunet_dns_service.h
index fd1319dd9..b5741a7e2 100644
--- a/src/include/gnunet_dns_service.h
+++ b/src/include/gnunet_dns_service.h
@@ -36,6 +36,7 @@
36#ifndef GNUNET_DNS_SERVICE_H 36#ifndef GNUNET_DNS_SERVICE_H
37#define GNUNET_DNS_SERVICE_H 37#define GNUNET_DNS_SERVICE_H
38 38
39
39#include "gnunet_util_lib.h" 40#include "gnunet_util_lib.h"
40 41
41 42
diff --git a/src/include/gnunet_dnsparser_lib.h b/src/include/gnunet_dnsparser_lib.h
index b8b908e84..8064b554b 100644
--- a/src/include/gnunet_dnsparser_lib.h
+++ b/src/include/gnunet_dnsparser_lib.h
@@ -18,6 +18,11 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif
24
25
21/** 26/**
22 * @addtogroup libgnunetutil 27 * @addtogroup libgnunetutil
23 * @{ 28 * @{
@@ -35,8 +40,6 @@
35#ifndef GNUNET_DNSPARSER_LIB_H 40#ifndef GNUNET_DNSPARSER_LIB_H
36#define GNUNET_DNSPARSER_LIB_H 41#define GNUNET_DNSPARSER_LIB_H
37 42
38#include "gnunet_util_lib.h"
39
40/** 43/**
41 * Maximum length of a label in DNS. 44 * Maximum length of a label in DNS.
42 */ 45 */
diff --git a/src/include/gnunet_dnsstub_lib.h b/src/include/gnunet_dnsstub_lib.h
index 4cc5e7fd0..fa5151a8c 100644
--- a/src/include/gnunet_dnsstub_lib.h
+++ b/src/include/gnunet_dnsstub_lib.h
@@ -18,6 +18,10 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif
24
21/** 25/**
22 * @addtogroup libgnunetutil 26 * @addtogroup libgnunetutil
23 * @{ 27 * @{
@@ -34,6 +38,7 @@
34#ifndef GNUNET_DNSSTUB_LIB_H 38#ifndef GNUNET_DNSSTUB_LIB_H
35#define GNUNET_DNSSTUB_LIB_H 39#define GNUNET_DNSSTUB_LIB_H
36 40
41
37#include "gnunet_util_lib.h" 42#include "gnunet_util_lib.h"
38 43
39/** 44/**
diff --git a/src/include/gnunet_fragmentation_lib.h b/src/include/gnunet_fragmentation_lib.h
index bb4a3ee8c..c8e99826a 100644
--- a/src/include/gnunet_fragmentation_lib.h
+++ b/src/include/gnunet_fragmentation_lib.h
@@ -37,8 +37,8 @@
37#ifndef GNUNET_FRAGMENTATION_LIB_H 37#ifndef GNUNET_FRAGMENTATION_LIB_H
38#define GNUNET_FRAGMENTATION_LIB_H 38#define GNUNET_FRAGMENTATION_LIB_H
39 39
40
40#include "gnunet_util_lib.h" 41#include "gnunet_util_lib.h"
41#include "gnunet_bandwidth_lib.h"
42#include "gnunet_statistics_service.h" 42#include "gnunet_statistics_service.h"
43 43
44#ifdef __cplusplus 44#ifdef __cplusplus
diff --git a/src/include/gnunet_friends_lib.h b/src/include/gnunet_friends_lib.h
index 03fa6c72d..4f4d5e88b 100644
--- a/src/include/gnunet_friends_lib.h
+++ b/src/include/gnunet_friends_lib.h
@@ -42,6 +42,7 @@ extern "C"
42#endif 42#endif
43#endif 43#endif
44 44
45
45#include "gnunet_util_lib.h" 46#include "gnunet_util_lib.h"
46 47
47 48
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h
index d9f2ee563..5c271c71f 100644
--- a/src/include/gnunet_fs_service.h
+++ b/src/include/gnunet_fs_service.h
@@ -36,6 +36,8 @@
36#ifndef GNUNET_FS_LIB_H 36#ifndef GNUNET_FS_LIB_H
37#define GNUNET_FS_LIB_H 37#define GNUNET_FS_LIB_H
38 38
39
40#include "gnunet_common.h"
39#include "gnunet_util_lib.h" 41#include "gnunet_util_lib.h"
40 42
41#ifdef __cplusplus 43#ifdef __cplusplus
@@ -69,6 +71,106 @@ extern "C"
69 */ 71 */
70#define GNUNET_FS_VERSION 0x00090300 72#define GNUNET_FS_VERSION 0x00090300
71 73
74#if GNUNET_FS_EXTRACTOR_ENABLED
75
76#include <extractor.h>
77
78#else
79
80/* definitions from extractor.h we need for the build */
81
82/**
83 * Enumeration defining various sources of keywords. See also
84 * http://dublincore.org/documents/1998/09/dces/
85 */
86enum EXTRACTOR_MetaType
87{
88 EXTRACTOR_METATYPE_RESERVED = 0,
89 EXTRACTOR_METATYPE_MIMETYPE = 1,
90 EXTRACTOR_METATYPE_FILENAME = 2,
91 EXTRACTOR_METATYPE_COMMENT = 3,
92 EXTRACTOR_METATYPE_TITLE = 4,
93 EXTRACTOR_METATYPE_BOOK_TITLE = 5,
94 EXTRACTOR_METATYPE_JOURNAL_NAME = 8,
95 EXTRACTOR_METATYPE_AUTHOR_NAME = 13,
96 EXTRACTOR_METATYPE_PUBLICATION_DATE = 24,
97 EXTRACTOR_METATYPE_URL = 29,
98 EXTRACTOR_METATYPE_URI = 30,
99 EXTRACTOR_METATYPE_ISRC = 31,
100 EXTRACTOR_METATYPE_UNKNOWN = 45,
101 EXTRACTOR_METATYPE_DESCRIPTION = 46,
102 EXTRACTOR_METATYPE_KEYWORDS = 49,
103 EXTRACTOR_METATYPE_SUBJECT = 52,
104 EXTRACTOR_METATYPE_PACKAGE_NAME = 69,
105 EXTRACTOR_METATYPE_THUMBNAIL = 114,
106 EXTRACTOR_METATYPE_ALBUM = 129,
107 EXTRACTOR_METATYPE_ARTIST = 130,
108 EXTRACTOR_METATYPE_ORIGINAL_TITLE = 162,
109 EXTRACTOR_METATYPE_GNUNET_FULL_DATA = 174,
110 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME = 180,
111};
112
113/**
114 * Format in which the extracted meta data is presented.
115 */
116enum EXTRACTOR_MetaFormat
117{
118 /**
119 * Format is unknown.
120 */
121 EXTRACTOR_METAFORMAT_UNKNOWN = 0,
122
123 /**
124 * 0-terminated, UTF-8 encoded string. "data_len"
125 * is strlen(data)+1.
126 */
127 EXTRACTOR_METAFORMAT_UTF8 = 1,
128
129 /**
130 * Some kind of binary format, see given Mime type.
131 */
132 EXTRACTOR_METAFORMAT_BINARY = 2,
133
134 /**
135 * 0-terminated string. The specific encoding is unknown.
136 * "data_len" is strlen (data)+1.
137 */
138 EXTRACTOR_METAFORMAT_C_STRING = 3
139};
140
141
142/**
143 * Type of a function that libextractor calls for each
144 * meta data item found.
145 *
146 * @param cls closure (user-defined)
147 * @param plugin_name name of the plugin that produced this value;
148 * special values can be used (e.g. '&lt;zlib&gt;' for zlib being
149 * used in the main libextractor library and yielding
150 * meta data).
151 * @param type libextractor-type describing the meta data
152 * @param format basic format information about @a data
153 * @param data_mime_type mime-type of @a data (not of the original file);
154 * can be NULL (if mime-type is not known)
155 * @param data actual meta-data found
156 * @param data_len number of bytes in @a data
157 * @return 0 to continue extracting, 1 to abort
158 */
159typedef int (*EXTRACTOR_MetaDataProcessor) (void *cls,
160 const char *plugin_name,
161 enum EXTRACTOR_MetaType type,
162 enum EXTRACTOR_MetaFormat format,
163 const char *data_mime_type,
164 const char *data,
165 size_t data_len);
166
167#endif
168
169#ifndef EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME
170/* hack for LE < 0.6.3 */
171#define EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME 180
172#endif
173
72 174
73/* ******************** URI API *********************** */ 175/* ******************** URI API *********************** */
74 176
@@ -91,6 +193,12 @@ extern "C"
91 */ 193 */
92struct GNUNET_FS_Uri; 194struct GNUNET_FS_Uri;
93 195
196/**
197 * @ingroup metadata
198 * Meta data to associate with a file, directory or namespace.
199 */
200struct GNUNET_FS_MetaData;
201
94 202
95/** 203/**
96 * Iterator over keywords 204 * Iterator over keywords
@@ -435,7 +543,7 @@ GNUNET_FS_uri_test_loc (const struct GNUNET_FS_Uri *uri);
435 * @return NULL on error, otherwise a KSK URI 543 * @return NULL on error, otherwise a KSK URI
436 */ 544 */
437struct GNUNET_FS_Uri * 545struct GNUNET_FS_Uri *
438GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData 546GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_FS_MetaData
439 *md); 547 *md);
440 548
441 549
@@ -471,7 +579,7 @@ GNUNET_FS_GETOPT_METADATA (char shortName,
471 const char *name, 579 const char *name,
472 const char *argumentHelp, 580 const char *argumentHelp,
473 const char *description, 581 const char *description,
474 struct GNUNET_CONTAINER_MetaData **meta); 582 struct GNUNET_FS_MetaData **meta);
475 583
476/** 584/**
477 * Command-line option parser function that allows the user to specify 585 * Command-line option parser function that allows the user to specify
@@ -480,7 +588,7 @@ GNUNET_FS_GETOPT_METADATA (char shortName,
480 * the metadata must be passed as the "scls" argument. 588 * the metadata must be passed as the "scls" argument.
481 * 589 *
482 * @param ctx command line processor context 590 * @param ctx command line processor context
483 * @param scls must be of type `struct GNUNET_CONTAINER_MetaData **` 591 * @param scls must be of type `struct GNUNET_FS_MetaData **`
484 * @param option name of the option (typically 'k') 592 * @param option name of the option (typically 'k')
485 * @param value command line argument given 593 * @param value command line argument given
486 * @return #GNUNET_OK on success 594 * @return #GNUNET_OK on success
@@ -1098,7 +1206,7 @@ struct GNUNET_FS_ProgressInfo
1098 /** 1206 /**
1099 * Known metadata for the download. 1207 * Known metadata for the download.
1100 */ 1208 */
1101 const struct GNUNET_CONTAINER_MetaData *meta; 1209 const struct GNUNET_FS_MetaData *meta;
1102 } start; 1210 } start;
1103 1211
1104 /** 1212 /**
@@ -1110,7 +1218,7 @@ struct GNUNET_FS_ProgressInfo
1110 /** 1218 /**
1111 * Known metadata for the download. 1219 * Known metadata for the download.
1112 */ 1220 */
1113 const struct GNUNET_CONTAINER_MetaData *meta; 1221 const struct GNUNET_FS_MetaData *meta;
1114 1222
1115 /** 1223 /**
1116 * Error message, NULL if we have not encountered any error yet. 1224 * Error message, NULL if we have not encountered any error yet.
@@ -1195,7 +1303,7 @@ struct GNUNET_FS_ProgressInfo
1195 /** 1303 /**
1196 * Metadata for the search result. 1304 * Metadata for the search result.
1197 */ 1305 */
1198 const struct GNUNET_CONTAINER_MetaData *meta; 1306 const struct GNUNET_FS_MetaData *meta;
1199 1307
1200 /** 1308 /**
1201 * URI for the search result. 1309 * URI for the search result.
@@ -1223,7 +1331,7 @@ struct GNUNET_FS_ProgressInfo
1223 /** 1331 /**
1224 * Metadata for the search result. 1332 * Metadata for the search result.
1225 */ 1333 */
1226 const struct GNUNET_CONTAINER_MetaData *meta; 1334 const struct GNUNET_FS_MetaData *meta;
1227 1335
1228 /** 1336 /**
1229 * URI for the search result. 1337 * URI for the search result.
@@ -1270,7 +1378,7 @@ struct GNUNET_FS_ProgressInfo
1270 /** 1378 /**
1271 * Metadata for the search result. 1379 * Metadata for the search result.
1272 */ 1380 */
1273 const struct GNUNET_CONTAINER_MetaData *meta; 1381 const struct GNUNET_FS_MetaData *meta;
1274 1382
1275 /** 1383 /**
1276 * URI for the search result. 1384 * URI for the search result.
@@ -1322,7 +1430,7 @@ struct GNUNET_FS_ProgressInfo
1322 /** 1430 /**
1323 * Metadata for the search result. 1431 * Metadata for the search result.
1324 */ 1432 */
1325 const struct GNUNET_CONTAINER_MetaData *meta; 1433 const struct GNUNET_FS_MetaData *meta;
1326 1434
1327 /** 1435 /**
1328 * URI for the search result. 1436 * URI for the search result.
@@ -1350,7 +1458,7 @@ struct GNUNET_FS_ProgressInfo
1350 /** 1458 /**
1351 * Metadata for the search result. 1459 * Metadata for the search result.
1352 */ 1460 */
1353 const struct GNUNET_CONTAINER_MetaData *meta; 1461 const struct GNUNET_FS_MetaData *meta;
1354 1462
1355 /** 1463 /**
1356 * URI for the search result. 1464 * URI for the search result.
@@ -1405,7 +1513,7 @@ struct GNUNET_FS_ProgressInfo
1405 /** 1513 /**
1406 * Metadata for the namespace. 1514 * Metadata for the namespace.
1407 */ 1515 */
1408 const struct GNUNET_CONTAINER_MetaData *meta; 1516 const struct GNUNET_FS_MetaData *meta;
1409 1517
1410 /** 1518 /**
1411 * Public key of the namespace. 1519 * Public key of the namespace.
@@ -1705,7 +1813,7 @@ typedef int
1705(*GNUNET_FS_FileInformationProcessor) (void *cls, 1813(*GNUNET_FS_FileInformationProcessor) (void *cls,
1706 struct GNUNET_FS_FileInformation *fi, 1814 struct GNUNET_FS_FileInformation *fi,
1707 uint64_t length, 1815 uint64_t length,
1708 struct GNUNET_CONTAINER_MetaData *meta, 1816 struct GNUNET_FS_MetaData *meta,
1709 struct GNUNET_FS_Uri **uri, 1817 struct GNUNET_FS_Uri **uri,
1710 struct GNUNET_FS_BlockOptions *bo, 1818 struct GNUNET_FS_BlockOptions *bo,
1711 int *do_index, 1819 int *do_index,
@@ -1770,7 +1878,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
1770 const struct 1878 const struct
1771 GNUNET_FS_Uri *keywords, 1879 GNUNET_FS_Uri *keywords,
1772 const struct 1880 const struct
1773 GNUNET_CONTAINER_MetaData *meta, 1881 GNUNET_FS_MetaData *meta,
1774 int do_index, 1882 int do_index,
1775 const struct 1883 const struct
1776 GNUNET_FS_BlockOptions *bo); 1884 GNUNET_FS_BlockOptions *bo);
@@ -1800,7 +1908,7 @@ GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h,
1800 const struct 1908 const struct
1801 GNUNET_FS_Uri *keywords, 1909 GNUNET_FS_Uri *keywords,
1802 const struct 1910 const struct
1803 GNUNET_CONTAINER_MetaData *meta, 1911 GNUNET_FS_MetaData *meta,
1804 int do_index, 1912 int do_index,
1805 const struct 1913 const struct
1806 GNUNET_FS_BlockOptions *bo); 1914 GNUNET_FS_BlockOptions *bo);
@@ -1859,7 +1967,7 @@ GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h,
1859 const struct GNUNET_FS_Uri 1967 const struct GNUNET_FS_Uri
1860 *keywords, 1968 *keywords,
1861 const struct 1969 const struct
1862 GNUNET_CONTAINER_MetaData *meta, 1970 GNUNET_FS_MetaData *meta,
1863 int do_index, 1971 int do_index,
1864 const struct 1972 const struct
1865 GNUNET_FS_BlockOptions *bo); 1973 GNUNET_FS_BlockOptions *bo);
@@ -1883,7 +1991,7 @@ GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h,
1883 const struct GNUNET_FS_Uri 1991 const struct GNUNET_FS_Uri
1884 *keywords, 1992 *keywords,
1885 const struct 1993 const struct
1886 GNUNET_CONTAINER_MetaData 1994 GNUNET_FS_MetaData
1887 *meta, 1995 *meta,
1888 const struct 1996 const struct
1889 GNUNET_FS_BlockOptions *bo, 1997 GNUNET_FS_BlockOptions *bo,
@@ -2042,7 +2150,7 @@ struct GNUNET_FS_PublishKskContext;
2042struct GNUNET_FS_PublishKskContext * 2150struct GNUNET_FS_PublishKskContext *
2043GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h, 2151GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
2044 const struct GNUNET_FS_Uri *ksk_uri, 2152 const struct GNUNET_FS_Uri *ksk_uri,
2045 const struct GNUNET_CONTAINER_MetaData *meta, 2153 const struct GNUNET_FS_MetaData *meta,
2046 const struct GNUNET_FS_Uri *uri, 2154 const struct GNUNET_FS_Uri *uri,
2047 const struct GNUNET_FS_BlockOptions *bo, 2155 const struct GNUNET_FS_BlockOptions *bo,
2048 enum GNUNET_FS_PublishOptions options, 2156 enum GNUNET_FS_PublishOptions options,
@@ -2084,7 +2192,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
2084 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, 2192 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
2085 const char *identifier, 2193 const char *identifier,
2086 const char *update, 2194 const char *update,
2087 const struct GNUNET_CONTAINER_MetaData *meta, 2195 const struct GNUNET_FS_MetaData *meta,
2088 const struct GNUNET_FS_Uri *uri, 2196 const struct GNUNET_FS_Uri *uri,
2089 const struct GNUNET_FS_BlockOptions *bo, 2197 const struct GNUNET_FS_BlockOptions *bo,
2090 enum GNUNET_FS_PublishOptions options, 2198 enum GNUNET_FS_PublishOptions options,
@@ -2180,7 +2288,7 @@ typedef void (*GNUNET_FS_IdentifierProcessor) (void *cls,
2180 const struct 2288 const struct
2181 GNUNET_FS_Uri *last_uri, 2289 GNUNET_FS_Uri *last_uri,
2182 const struct 2290 const struct
2183 GNUNET_CONTAINER_MetaData * 2291 GNUNET_FS_MetaData *
2184 last_meta, 2292 last_meta,
2185 const char *next_id); 2293 const char *next_id);
2186 2294
@@ -2290,7 +2398,7 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc);
2290struct GNUNET_FS_SearchResult * 2398struct GNUNET_FS_SearchResult *
2291GNUNET_FS_probe (struct GNUNET_FS_Handle *h, 2399GNUNET_FS_probe (struct GNUNET_FS_Handle *h,
2292 const struct GNUNET_FS_Uri *uri, 2400 const struct GNUNET_FS_Uri *uri,
2293 const struct GNUNET_CONTAINER_MetaData *meta, 2401 const struct GNUNET_FS_MetaData *meta,
2294 void *client_info, 2402 void *client_info,
2295 uint32_t anonymity); 2403 uint32_t anonymity);
2296 2404
@@ -2378,7 +2486,7 @@ enum GNUNET_FS_DownloadOptions
2378struct GNUNET_FS_DownloadContext * 2486struct GNUNET_FS_DownloadContext *
2379GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, 2487GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
2380 const struct GNUNET_FS_Uri *uri, 2488 const struct GNUNET_FS_Uri *uri,
2381 const struct GNUNET_CONTAINER_MetaData *meta, 2489 const struct GNUNET_FS_MetaData *meta,
2382 const char *filename, const char *tempname, 2490 const char *filename, const char *tempname,
2383 uint64_t offset, uint64_t length, uint32_t anonymity, 2491 uint64_t offset, uint64_t length, uint32_t anonymity,
2384 enum GNUNET_FS_DownloadOptions options, void *cctx, 2492 enum GNUNET_FS_DownloadOptions options, void *cctx,
@@ -2472,7 +2580,7 @@ GNUNET_FS_download_resume (struct GNUNET_FS_DownloadContext *dc);
2472 * we have no mime-type information (treat as #GNUNET_NO) 2580 * we have no mime-type information (treat as #GNUNET_NO)
2473 */ 2581 */
2474int 2582int
2475GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaData 2583GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_FS_MetaData
2476 *md); 2584 *md);
2477 2585
2478 2586
@@ -2483,7 +2591,7 @@ GNUNET_FS_meta_data_test_for_directory (const struct GNUNET_CONTAINER_MetaData
2483 * @param md metadata to add mimetype to 2591 * @param md metadata to add mimetype to
2484 */ 2592 */
2485void 2593void
2486GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md); 2594GNUNET_FS_meta_data_make_directory (struct GNUNET_FS_MetaData *md);
2487 2595
2488 2596
2489/** 2597/**
@@ -2494,7 +2602,7 @@ GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md);
2494 */ 2602 */
2495char * 2603char *
2496GNUNET_FS_meta_data_suggest_filename (const struct 2604GNUNET_FS_meta_data_suggest_filename (const struct
2497 GNUNET_CONTAINER_MetaData *md); 2605 GNUNET_FS_MetaData *md);
2498 2606
2499 2607
2500/** 2608/**
@@ -2517,7 +2625,7 @@ typedef void (*GNUNET_FS_DirectoryEntryProcessor) (void *cls,
2517 const struct GNUNET_FS_Uri * 2625 const struct GNUNET_FS_Uri *
2518 uri, 2626 uri,
2519 const struct 2627 const struct
2520 GNUNET_CONTAINER_MetaData * 2628 GNUNET_FS_MetaData *
2521 meta, size_t length, 2629 meta, size_t length,
2522 const void *data); 2630 const void *data);
2523 2631
@@ -2560,7 +2668,7 @@ struct GNUNET_FS_DirectoryBuilder;
2560 * @param mdir metadata for the directory 2668 * @param mdir metadata for the directory
2561 */ 2669 */
2562struct GNUNET_FS_DirectoryBuilder * 2670struct GNUNET_FS_DirectoryBuilder *
2563GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData 2671GNUNET_FS_directory_builder_create (const struct GNUNET_FS_MetaData
2564 *mdir); 2672 *mdir);
2565 2673
2566 2674
@@ -2577,7 +2685,7 @@ GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData
2577void 2685void
2578GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld, 2686GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld,
2579 const struct GNUNET_FS_Uri *uri, 2687 const struct GNUNET_FS_Uri *uri,
2580 const struct GNUNET_CONTAINER_MetaData *md, 2688 const struct GNUNET_FS_MetaData *md,
2581 const void *data); 2689 const void *data);
2582 2690
2583 2691
@@ -2692,7 +2800,7 @@ struct GNUNET_FS_ShareTreeItem
2692 /** 2800 /**
2693 * Metadata for this file or directory 2801 * Metadata for this file or directory
2694 */ 2802 */
2695 struct GNUNET_CONTAINER_MetaData *meta; 2803 struct GNUNET_FS_MetaData *meta;
2696 2804
2697 /** 2805 /**
2698 * Keywords for this file or directory (derived from metadata). 2806 * Keywords for this file or directory (derived from metadata).
@@ -2781,6 +2889,336 @@ GNUNET_FS_share_tree_trim (struct GNUNET_FS_ShareTreeItem *toplevel);
2781void 2889void
2782GNUNET_FS_share_tree_free (struct GNUNET_FS_ShareTreeItem *toplevel); 2890GNUNET_FS_share_tree_free (struct GNUNET_FS_ShareTreeItem *toplevel);
2783 2891
2892/**
2893 * Meta data processing
2894 * @defgroup metadata Metadata
2895 * GNU libextractor key-value pairs
2896 */
2897
2898
2899/* ****************** metadata ******************* */
2900
2901
2902/**
2903 * @ingroup metadata
2904 * Create a fresh meta data container.
2905 *
2906 * @return empty meta-data container
2907 */
2908struct GNUNET_FS_MetaData *
2909GNUNET_FS_meta_data_create (void);
2910
2911
2912/**
2913 * @ingroup metadata
2914 * Duplicate a MetaData token.
2915 *
2916 * @param md what to duplicate
2917 * @return duplicate meta-data container
2918 */
2919struct GNUNET_FS_MetaData *
2920GNUNET_FS_meta_data_duplicate (
2921 const struct GNUNET_FS_MetaData *md);
2922
2923
2924/**
2925 * @ingroup metadata
2926 * Free meta data.
2927 *
2928 * @param md what to free
2929 */
2930void
2931GNUNET_FS_meta_data_destroy (struct GNUNET_FS_MetaData *md);
2932
2933
2934/**
2935 * @ingroup metadata
2936 * Test if two MDs are equal. We consider them equal if
2937 * the meta types, formats and content match (we do not
2938 * include the mime types and plugins names in this
2939 * consideration).
2940 *
2941 * @param md1 first value to check
2942 * @param md2 other value to check
2943 * @return #GNUNET_YES if they are equal
2944 */
2945int
2946GNUNET_FS_meta_data_test_equal (
2947 const struct GNUNET_FS_MetaData *md1,
2948 const struct GNUNET_FS_MetaData *md2);
2949
2950
2951/**
2952 * @ingroup metadata
2953 * Extend metadata.
2954 *
2955 * @param md metadata to extend
2956 * @param plugin_name name of the plugin that produced this value;
2957 * special values can be used (e.g. '&lt;zlib&gt;' for zlib being
2958 * used in the main libextractor library and yielding
2959 * meta data).
2960 * @param type libextractor-type describing the meta data
2961 * @param format basic format information about data
2962 * @param data_mime_type mime-type of data (not of the original file);
2963 * can be NULL (if mime-type is not known)
2964 * @param data actual meta-data found
2965 * @param data_size number of bytes in data
2966 * @return #GNUNET_OK on success, #GNUNET_SYSERR if this entry already exists
2967 * data_mime_type and plugin_name are not considered for "exists" checks
2968 */
2969int
2970GNUNET_FS_meta_data_insert (struct GNUNET_FS_MetaData *md,
2971 const char *plugin_name,
2972 enum EXTRACTOR_MetaType type,
2973 enum EXTRACTOR_MetaFormat format,
2974 const char *data_mime_type,
2975 const char *data,
2976 size_t data_size);
2977
2978
2979/**
2980 * @ingroup metadata
2981 * Extend metadata. Merges the meta data from the second argument
2982 * into the first, discarding duplicate key-value pairs.
2983 *
2984 * @param md metadata to extend
2985 * @param in metadata to merge
2986 */
2987void
2988GNUNET_FS_meta_data_merge (struct GNUNET_FS_MetaData *md,
2989 const struct GNUNET_FS_MetaData *in);
2990
2991
2992/**
2993 * @ingroup metadata
2994 * Remove an item.
2995 *
2996 * @param md metadata to manipulate
2997 * @param type type of the item to remove
2998 * @param data specific value to remove, NULL to remove all
2999 * entries of the given type
3000 * @param data_size number of bytes in data
3001 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the item does not exist in md
3002 */
3003int
3004GNUNET_FS_meta_data_delete (struct GNUNET_FS_MetaData *md,
3005 enum EXTRACTOR_MetaType type,
3006 const char *data,
3007 size_t data_size);
3008
3009
3010/**
3011 * @ingroup metadata
3012 * Remove all items in the container.
3013 *
3014 * @param md metadata to manipulate
3015 */
3016void
3017GNUNET_FS_meta_data_clear (struct GNUNET_FS_MetaData *md);
3018
3019
3020/**
3021 * @ingroup metadata
3022 * Add the current time as the publication date
3023 * to the meta-data.
3024 *
3025 * @param md metadata to modify
3026 */
3027void
3028GNUNET_FS_meta_data_add_publication_date (
3029 struct GNUNET_FS_MetaData *md);
3030
3031
3032/**
3033 * @ingroup metadata
3034 * Iterate over MD entries.
3035 *
3036 * @param md metadata to inspect
3037 * @param iter function to call on each entry, return 0 to continue to iterate
3038 * and 1 to abort iteration in this function (GNU libextractor API!)
3039 * @param iter_cls closure for @a iter
3040 * @return number of entries
3041 */
3042int
3043GNUNET_FS_meta_data_iterate (const struct GNUNET_FS_MetaData *md,
3044 EXTRACTOR_MetaDataProcessor iter,
3045 void *iter_cls);
3046
3047
3048/**
3049 * @ingroup metadata
3050 * Get the first MD entry of the given type. Caller
3051 * is responsible for freeing the return value.
3052 * Also, only meta data items that are strings (0-terminated)
3053 * are returned by this function.
3054 *
3055 * @param md metadata to inspect
3056 * @param type type to look for
3057 * @return NULL if no entry was found
3058 */
3059char *
3060GNUNET_FS_meta_data_get_by_type (
3061 const struct GNUNET_FS_MetaData *md,
3062 enum EXTRACTOR_MetaType type);
3063
3064
3065/**
3066 * @ingroup metadata
3067 * Get the first matching MD entry of the given types. Caller is
3068 * responsible for freeing the return value. Also, only meta data
3069 * items that are strings (0-terminated) are returned by this
3070 * function.
3071 *
3072 * @param md metadata to inspect
3073 * @param ... -1-terminated list of types
3074 * @return NULL if we do not have any such entry,
3075 * otherwise client is responsible for freeing the value!
3076 */
3077char *
3078GNUNET_FS_meta_data_get_first_by_types (
3079 const struct GNUNET_FS_MetaData *md,
3080 ...);
3081
3082/**
3083 * @ingroup metadata
3084 * Get a thumbnail from the meta-data (if present). Only matches meta
3085 * data with mime type "image" and binary format.
3086 *
3087 * @param md metadata to inspect
3088 * @param thumb will be set to the thumbnail data. Must be
3089 * freed by the caller!
3090 * @return number of bytes in thumbnail, 0 if not available
3091 */
3092size_t
3093GNUNET_FS_meta_data_get_thumbnail (
3094 const struct GNUNET_FS_MetaData *md,
3095 unsigned char **thumb);
3096
3097
3098/**
3099 * @ingroup metadata
3100 * Options for metadata serialization.
3101 */
3102enum GNUNET_FS_MetaDataSerializationOptions
3103{
3104 /**
3105 * @ingroup metadata
3106 * Serialize all of the data.
3107 */
3108 GNUNET_FS_META_DATA_SERIALIZE_FULL = 0,
3109
3110 /**
3111 * @ingroup metadata
3112 * If not enough space is available, it is acceptable
3113 * to only serialize some of the metadata.
3114 */
3115 GNUNET_FS_META_DATA_SERIALIZE_PART = 1,
3116
3117 /**
3118 * @ingroup metadata
3119 * Speed is of the essence, do not allow compression.
3120 */
3121 GNUNET_FS_META_DATA_SERIALIZE_NO_COMPRESS = 2
3122};
3123
3124
3125/**
3126 * @ingroup metadata
3127 * Serialize meta-data to target.
3128 *
3129 * @param md metadata to serialize
3130 * @param target where to write the serialized metadata;
3131 * *target can be NULL, in which case memory is allocated
3132 * @param max maximum number of bytes available
3133 * @param opt is it ok to just write SOME of the
3134 * meta-data to match the size constraint,
3135 * possibly discarding some data?
3136 * @return number of bytes written on success,
3137 * -1 on error (typically: not enough
3138 * space)
3139 */
3140ssize_t
3141GNUNET_FS_meta_data_serialize (
3142 const struct GNUNET_FS_MetaData *md,
3143 char **target,
3144 size_t max,
3145 enum GNUNET_FS_MetaDataSerializationOptions opt);
3146
3147
3148/**
3149 * @ingroup metadata
3150 * Get the size of the full meta-data in serialized form.
3151 *
3152 * @param md metadata to inspect
3153 * @return number of bytes needed for serialization, -1 on error
3154 */
3155ssize_t
3156GNUNET_FS_meta_data_get_serialized_size (
3157 const struct GNUNET_FS_MetaData *md);
3158
3159
3160/**
3161 * @ingroup metadata
3162 * Deserialize meta-data. Initializes md.
3163 *
3164 * @param input serialized meta-data.
3165 * @param size number of bytes available
3166 * @return MD on success, NULL on error (e.g.
3167 * bad format)
3168 */
3169struct GNUNET_FS_MetaData *
3170GNUNET_FS_meta_data_deserialize (const char *input, size_t size);
3171
3172/**
3173 * Write a metadata container.
3174 *
3175 * @param h the IO handle to write to
3176 * @param what what is being written (for error message creation)
3177 * @param m metadata to write
3178 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
3179 */
3180enum GNUNET_GenericReturnValue
3181GNUNET_FS_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
3182 const char *what,
3183 const struct GNUNET_FS_MetaData *m);
3184
3185/**
3186 * Create the specification to read a metadata container.
3187 *
3188 * @param what describes what is being read (for error message creation)
3189 * @param result the buffer to store a pointer to the (allocated) metadata
3190 * @return the read spec
3191 */
3192struct GNUNET_BIO_ReadSpec
3193GNUNET_FS_read_spec_meta_data (const char *what,
3194 struct GNUNET_FS_MetaData **result);
3195
3196
3197
3198/**
3199 * Create the specification to write a metadata container.
3200 *
3201 * @param what what is being written (for error message creation)
3202 * @param m metadata to write
3203 * @return the write spec
3204 */
3205struct GNUNET_BIO_WriteSpec
3206GNUNET_FS_write_spec_meta_data (const char *what,
3207 const struct GNUNET_FS_MetaData *m);
3208
3209/**
3210 * Read a metadata container.
3211 *
3212 * @param h handle to an open file
3213 * @param what describes what is being read (for error message creation)
3214 * @param result the buffer to store a pointer to the (allocated) metadata
3215 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
3216 */
3217enum GNUNET_GenericReturnValue
3218GNUNET_FS_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
3219 const char *what,
3220 struct GNUNET_FS_MetaData **result);
3221
2784 3222
2785#if 0 /* keep Emacsens' auto-indent happy */ 3223#if 0 /* keep Emacsens' auto-indent happy */
2786{ 3224{
diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h
index 87ad591b7..390e8c153 100644
--- a/src/include/gnunet_getopt_lib.h
+++ b/src/include/gnunet_getopt_lib.h
@@ -33,6 +33,10 @@
33 * @{ 33 * @{
34 */ 34 */
35 35
36#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
37#error "Only <gnunet_util_lib.h> can be included directly."
38#endif
39
36#ifndef GNUNET_GETOPT_LIB_H 40#ifndef GNUNET_GETOPT_LIB_H
37#define GNUNET_GETOPT_LIB_H 41#define GNUNET_GETOPT_LIB_H
38 42
@@ -43,6 +47,7 @@ extern "C" {
43#endif 47#endif
44#endif 48#endif
45 49
50
46#include "gnunet_configuration_lib.h" 51#include "gnunet_configuration_lib.h"
47 52
48/** 53/**
diff --git a/src/include/gnunet_gns_service.h b/src/include/gnunet_gns_service.h
index a32bb77ae..1fcf7aa8b 100644
--- a/src/include/gnunet_gns_service.h
+++ b/src/include/gnunet_gns_service.h
@@ -37,8 +37,8 @@
37#ifndef GNUNET_GNS_SERVICE_H 37#ifndef GNUNET_GNS_SERVICE_H
38#define GNUNET_GNS_SERVICE_H 38#define GNUNET_GNS_SERVICE_H
39 39
40
40#include "gnunet_util_lib.h" 41#include "gnunet_util_lib.h"
41#include "gnunet_dnsparser_lib.h"
42#include "gnunet_identity_service.h" 42#include "gnunet_identity_service.h"
43#include "gnunet_namestore_service.h" 43#include "gnunet_namestore_service.h"
44 44
diff --git a/src/include/gnunet_gnsrecord_json_lib.h b/src/include/gnunet_gnsrecord_json_lib.h
index 833e684f9..1216f1f5e 100644
--- a/src/include/gnunet_gnsrecord_json_lib.h
+++ b/src/include/gnunet_gnsrecord_json_lib.h
@@ -37,6 +37,7 @@
37#ifndef GNUNET_GNSRECORD_JSON_LIB_H 37#ifndef GNUNET_GNSRECORD_JSON_LIB_H
38#define GNUNET_GNSRECORD_JSON_LIB_H 38#define GNUNET_GNSRECORD_JSON_LIB_H
39 39
40
40#include "gnunet_gnsrecord_lib.h" 41#include "gnunet_gnsrecord_lib.h"
41#include "gnunet_json_lib.h" 42#include "gnunet_json_lib.h"
42 43
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h
index 85a42d459..6fc2a05c5 100644
--- a/src/include/gnunet_gnsrecord_lib.h
+++ b/src/include/gnunet_gnsrecord_lib.h
@@ -37,6 +37,7 @@
37#ifndef GNUNET_GNSRECORD_LIB_H 37#ifndef GNUNET_GNSRECORD_LIB_H
38#define GNUNET_GNSRECORD_LIB_H 38#define GNUNET_GNSRECORD_LIB_H
39 39
40
40#include "gnunet_identity_service.h" 41#include "gnunet_identity_service.h"
41 42
42#ifdef __cplusplus 43#ifdef __cplusplus
@@ -69,46 +70,9 @@ extern "C" {
69#include "gnu_name_system_record_types.h" 70#include "gnu_name_system_record_types.h"
70 71
71/** 72/**
72 * Flags that can be set for a record. 73 * Include the record flags generated from GANA
73 * MUST fit into 16 bit.
74 */ 74 */
75enum GNUNET_GNSRECORD_Flags 75#include "gnu_name_system_record_flags.h"
76{
77 /**
78 * No special options.
79 */
80 GNUNET_GNSRECORD_RF_NONE = 0,
81
82 /**
83 * This record is critical. If it cannot be processed
84 * (for example because the record type is unknown)
85 * resolution MUST fail
86 */
87 GNUNET_GNSRECORD_RF_CRITICAL = 1,
88
89 /**
90 * This record should not be used unless all (other) records with an absolute
91 * expiration time have expired.
92 */
93 GNUNET_GNSRECORD_RF_SHADOW_RECORD = 2,
94
95 /**
96 * This is a supplemental record.
97 */
98 GNUNET_GNSRECORD_RF_SUPPLEMENTAL = 4,
99
100 /**
101 * This expiration time of the record is a relative
102 * time (not an absolute time).
103 */
104 GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION = 16384, /* 2^14 */
105
106 /**
107 * This is a private record of this peer and it should
108 * thus not be handed out to other peers.
109 */
110 GNUNET_GNSRECORD_RF_PRIVATE = 32768, /* 2^15 */
111
112 76
113/** 77/**
114 * When comparing flags for record equality for removal, 78 * When comparing flags for record equality for removal,
@@ -122,7 +86,6 @@ enum GNUNET_GNSRECORD_Flags
122 * #GNUNET_GNSRECORD_records_cmp. 86 * #GNUNET_GNSRECORD_records_cmp.
123 */ 87 */
124#define GNUNET_GNSRECORD_RF_RCMP_FLAGS (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION) 88#define GNUNET_GNSRECORD_RF_RCMP_FLAGS (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)
125};
126 89
127/** 90/**
128 * Filter for GNUNET_GNSRECORD_normalize_record_set(). 91 * Filter for GNUNET_GNSRECORD_normalize_record_set().
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h
index 86bf35110..20a61cbfb 100644
--- a/src/include/gnunet_hello_lib.h
+++ b/src/include/gnunet_hello_lib.h
@@ -44,6 +44,7 @@ extern "C" {
44#endif 44#endif
45#endif 45#endif
46 46
47
47#include "gnunet_util_lib.h" 48#include "gnunet_util_lib.h"
48 49
49/** 50/**
diff --git a/src/include/gnunet_hello_uri_lib.h b/src/include/gnunet_hello_uri_lib.h
index 89cd42d31..bba7078e6 100644
--- a/src/include/gnunet_hello_uri_lib.h
+++ b/src/include/gnunet_hello_uri_lib.h
@@ -42,6 +42,7 @@ extern "C" {
42#endif 42#endif
43#endif 43#endif
44 44
45
45#include "gnunet_util_lib.h" 46#include "gnunet_util_lib.h"
46 47
47 48
diff --git a/src/include/gnunet_helper_lib.h b/src/include/gnunet_helper_lib.h
index 3362d698e..2279abb24 100644
--- a/src/include/gnunet_helper_lib.h
+++ b/src/include/gnunet_helper_lib.h
@@ -38,10 +38,14 @@
38 * @{ 38 * @{
39 */ 39 */
40 40
41#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
42#error "Only <gnunet_util_lib.h> can be included directly."
43#endif
44
41#ifndef GNUNET_HELPER_LIB_H 45#ifndef GNUNET_HELPER_LIB_H
42#define GNUNET_HELPER_LIB_H 46#define GNUNET_HELPER_LIB_H
43 47
44#include "gnunet_scheduler_lib.h" 48
45#include "gnunet_mst_lib.h" 49#include "gnunet_mst_lib.h"
46 50
47 51
diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h
index cd745ba51..67327af5d 100644
--- a/src/include/gnunet_identity_service.h
+++ b/src/include/gnunet_identity_service.h
@@ -52,6 +52,7 @@ extern "C" {
52#endif 52#endif
53#endif 53#endif
54 54
55
55#include "gnunet_util_lib.h" 56#include "gnunet_util_lib.h"
56 57
57 58
diff --git a/src/include/gnunet_json_lib.h b/src/include/gnunet_json_lib.h
index 8809afb71..a65293a7c 100644
--- a/src/include/gnunet_json_lib.h
+++ b/src/include/gnunet_json_lib.h
@@ -27,6 +27,7 @@
27#ifndef GNUNET_JSON_LIB_H 27#ifndef GNUNET_JSON_LIB_H
28#define GNUNET_JSON_LIB_H 28#define GNUNET_JSON_LIB_H
29 29
30
30#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
31#include <jansson.h> 32#include <jansson.h>
32#include <microhttpd.h> 33#include <microhttpd.h>
diff --git a/src/include/gnunet_load_lib.h b/src/include/gnunet_load_lib.h
index 397d3aa2d..56cacfbbb 100644
--- a/src/include/gnunet_load_lib.h
+++ b/src/include/gnunet_load_lib.h
@@ -43,6 +43,7 @@ extern "C"
43#endif 43#endif
44#endif 44#endif
45 45
46
46#include "gnunet_common.h" 47#include "gnunet_common.h"
47#include "gnunet_time_lib.h" 48#include "gnunet_time_lib.h"
48 49
diff --git a/src/include/gnunet_messenger_service.h b/src/include/gnunet_messenger_service.h
index 12f021d35..07d22d85c 100644
--- a/src/include/gnunet_messenger_service.h
+++ b/src/include/gnunet_messenger_service.h
@@ -39,11 +39,11 @@ extern "C" {
39#endif 39#endif
40#endif 40#endif
41 41
42
42#include "platform.h" 43#include "platform.h"
43#include "gnunet_configuration_lib.h" 44#include "gnunet_configuration_lib.h"
44#include "gnunet_crypto_lib.h" 45#include "gnunet_util_lib.h"
45#include "gnunet_identity_service.h" 46#include "gnunet_identity_service.h"
46#include "gnunet_mq_lib.h"
47#include "gnunet_protocols.h" 47#include "gnunet_protocols.h"
48#include "gnunet_scheduler_lib.h" 48#include "gnunet_scheduler_lib.h"
49#include "gnunet_time_lib.h" 49#include "gnunet_time_lib.h"
diff --git a/src/include/gnunet_mhd_compat.h b/src/include/gnunet_mhd_compat.h
index 0cfcc6445..7ef297c2f 100644
--- a/src/include/gnunet_mhd_compat.h
+++ b/src/include/gnunet_mhd_compat.h
@@ -25,6 +25,7 @@
25 * MHD compatibility definitions for warning-less compile of 25 * MHD compatibility definitions for warning-less compile of
26 * our code against MHD before and after #MHD_VERSION 0x00097002. 26 * our code against MHD before and after #MHD_VERSION 0x00097002.
27 */ 27 */
28
28#include <microhttpd.h> 29#include <microhttpd.h>
29 30
30#if MHD_VERSION >= 0x00097002 31#if MHD_VERSION >= 0x00097002
@@ -35,7 +36,7 @@
35 36
36#else 37#else
37 38
38/** 39**
39 * Data type to use for functions return an "MHD result". 40 * Data type to use for functions return an "MHD result".
40 */ 41 */
41#define MHD_RESULT int 42#define MHD_RESULT int
diff --git a/src/include/gnunet_microphone_lib.h b/src/include/gnunet_microphone_lib.h
index 479c7a71e..394caed68 100644
--- a/src/include/gnunet_microphone_lib.h
+++ b/src/include/gnunet_microphone_lib.h
@@ -44,6 +44,7 @@ extern "C"
44#endif 44#endif
45#endif 45#endif
46 46
47
47#include "gnunet_util_lib.h" 48#include "gnunet_util_lib.h"
48 49
49/** 50/**
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h
index a06fb4eb7..95e8c619b 100644
--- a/src/include/gnunet_mq_lib.h
+++ b/src/include/gnunet_mq_lib.h
@@ -18,6 +18,11 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif
24
25
21/** 26/**
22 * @addtogroup libgnunetutil 27 * @addtogroup libgnunetutil
23 * Multi-function utilities library for GNUnet programs 28 * Multi-function utilities library for GNUnet programs
@@ -39,6 +44,7 @@
39#ifndef GNUNET_MQ_LIB_H 44#ifndef GNUNET_MQ_LIB_H
40#define GNUNET_MQ_LIB_H 45#define GNUNET_MQ_LIB_H
41 46
47
42#include "gnunet_scheduler_lib.h" 48#include "gnunet_scheduler_lib.h"
43 49
44/** 50/**
diff --git a/src/include/gnunet_mst_lib.h b/src/include/gnunet_mst_lib.h
index ec82ce357..af2dd3353 100644
--- a/src/include/gnunet_mst_lib.h
+++ b/src/include/gnunet_mst_lib.h
@@ -39,6 +39,10 @@
39 * @{ 39 * @{
40 */ 40 */
41 41
42#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
43#error "Only <gnunet_util_lib.h> can be included directly."
44#endif
45
42#ifndef GNUNET_MST_LIB_H 46#ifndef GNUNET_MST_LIB_H
43#define GNUNET_MST_LIB_H 47#define GNUNET_MST_LIB_H
44 48
@@ -50,8 +54,6 @@ extern "C"
50#endif 54#endif
51#endif 55#endif
52 56
53#include "gnunet_common.h"
54
55 57
56/** 58/**
57 * Handle to a message stream tokenizer. 59 * Handle to a message stream tokenizer.
diff --git a/src/include/gnunet_my_lib.h b/src/include/gnunet_my_lib.h
index 96d8cab42..283b2f7e6 100644
--- a/src/include/gnunet_my_lib.h
+++ b/src/include/gnunet_my_lib.h
@@ -18,11 +18,12 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20/** 20/**
21 * @addtogroup lib_extra 21 * @addtogroup lib_extra
22 * @{ 22 * @{
23 * 23 *
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * @author Christophe Genevey 25 * @author Christophe Genevey
26 * @author Martin Schanzenbach
26 * 27 *
27 * @file 28 * @file
28 * Helper library to access a MySQL database 29 * Helper library to access a MySQL database
@@ -34,10 +35,15 @@
34#ifndef GNUNET_MY_LIB_H 35#ifndef GNUNET_MY_LIB_H
35#define GNUNET_MY_LIB_H 36#define GNUNET_MY_LIB_H
36 37
38
37#include "gnunet_util_lib.h" 39#include "gnunet_util_lib.h"
38#include "gnunet_mysql_lib.h" 40#include "gnunet_mysql_lib.h"
39#include <mysql/mysql.h> 41#include <mysql/mysql.h>
40 42
43#ifndef MYSQL_BOOL
44#error "You need to define MYSQL_BOOL. See (or include) gnunet_mysql_compat.h"
45#endif
46
41#ifdef __cplusplus 47#ifdef __cplusplus
42extern "C" 48extern "C"
43{ 49{
diff --git a/src/include/gnunet_mysql_compat.h b/src/include/gnunet_mysql_compat.h
new file mode 100644
index 000000000..bb1e8de8a
--- /dev/null
+++ b/src/include/gnunet_mysql_compat.h
@@ -0,0 +1,63 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2022 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @author Martin Schanzenbach
22 *
23 * @file
24 * MySQL/MariaDB compatibility insanity helper header
25 *
26 * @defgroup mysql MySQL library
27 * Helper library to access a MySQL database.
28 * @{
29 */
30#ifndef GNUNET_MYSQL_COMPAT_H
31#define GNUNET_MYSQL_COMPAT_H
32
33
34#include <mysql/mysql.h>
35
36#ifdef __cplusplus
37extern "C"
38{
39#if 0 /* keep Emacsens' auto-indent happy */
40}
41#endif
42#endif
43
44#ifndef LIBMARIADB
45#if MYSQL_VERSION_ID < 80000
46#define MYSQL_BOOL bool;
47#else
48#define MYSQL_BOOL my_bool; //MySQL < 8 wants this
49#endif
50#else
51#define MYSQL_BOOL my_bool //MariaDB still uses my_bool
52#endif
53
54#if 0 /* keep Emacsens' auto-indent happy */
55{
56#endif
57#ifdef __cplusplus
58}
59#endif
60
61#endif
62
63/** @} */ /* end of group */
diff --git a/src/include/gnunet_mysql_lib.h b/src/include/gnunet_mysql_lib.h
index 8da7e5397..52be3ff11 100644
--- a/src/include/gnunet_mysql_lib.h
+++ b/src/include/gnunet_mysql_lib.h
@@ -30,6 +30,7 @@
30#ifndef GNUNET_MYSQL_LIB_H 30#ifndef GNUNET_MYSQL_LIB_H
31#define GNUNET_MYSQL_LIB_H 31#define GNUNET_MYSQL_LIB_H
32 32
33
33#include "gnunet_util_lib.h" 34#include "gnunet_util_lib.h"
34#include <mysql/mysql.h> 35#include <mysql/mysql.h>
35 36
@@ -41,17 +42,6 @@ extern "C"
41#endif 42#endif
42#endif 43#endif
43 44
44#ifndef LIBMARIADB
45#ifdef HAVE_MYSQL8 && !LIBMARIADB
46 typedef bool MYSQL_BOOL;
47#else
48 typedef my_bool MYSQL_BOOL; //MySQL < 8 wants this
49#endif
50#else
51 typedef my_bool MYSQL_BOOL; //MariaDB still uses my_bool
52#endif
53
54
55/** 45/**
56 * Mysql context. 46 * Mysql context.
57 */ 47 */
diff --git a/src/include/gnunet_namecache_plugin.h b/src/include/gnunet_namecache_plugin.h
index c41c516c8..a3848bf4e 100644
--- a/src/include/gnunet_namecache_plugin.h
+++ b/src/include/gnunet_namecache_plugin.h
@@ -37,6 +37,7 @@
37#ifndef GNUNET_NAMECACHE_PLUGIN_H 37#ifndef GNUNET_NAMECACHE_PLUGIN_H
38#define GNUNET_NAMECACHE_PLUGIN_H 38#define GNUNET_NAMECACHE_PLUGIN_H
39 39
40
40#include "gnunet_util_lib.h" 41#include "gnunet_util_lib.h"
41#include "gnunet_namecache_service.h" 42#include "gnunet_namecache_service.h"
42#include "gnunet_namestore_service.h" 43#include "gnunet_namestore_service.h"
diff --git a/src/include/gnunet_namecache_service.h b/src/include/gnunet_namecache_service.h
index fbc9f7e62..669386c37 100644
--- a/src/include/gnunet_namecache_service.h
+++ b/src/include/gnunet_namecache_service.h
@@ -41,6 +41,7 @@
41#ifndef GNUNET_NAMECACHE_SERVICE_H 41#ifndef GNUNET_NAMECACHE_SERVICE_H
42#define GNUNET_NAMECACHE_SERVICE_H 42#define GNUNET_NAMECACHE_SERVICE_H
43 43
44
44#include "gnunet_util_lib.h" 45#include "gnunet_util_lib.h"
45#include "gnunet_block_lib.h" 46#include "gnunet_block_lib.h"
46#include "gnunet_namestore_service.h" 47#include "gnunet_namestore_service.h"
diff --git a/src/include/gnunet_namestore_plugin.h b/src/include/gnunet_namestore_plugin.h
index 1df0a5eb0..f2bdf7cc6 100644
--- a/src/include/gnunet_namestore_plugin.h
+++ b/src/include/gnunet_namestore_plugin.h
@@ -34,6 +34,7 @@
34#ifndef GNUNET_NAMESTORE_PLUGIN_H 34#ifndef GNUNET_NAMESTORE_PLUGIN_H
35#define GNUNET_NAMESTORE_PLUGIN_H 35#define GNUNET_NAMESTORE_PLUGIN_H
36 36
37
37#include "gnunet_util_lib.h" 38#include "gnunet_util_lib.h"
38#include "gnunet_namestore_service.h" 39#include "gnunet_namestore_service.h"
39 40
@@ -88,12 +89,12 @@ struct GNUNET_NAMESTORE_PluginFunctions
88 * @param rd array of records with data to store 89 * @param rd array of records with data to store
89 * @return #GNUNET_OK on success, else #GNUNET_SYSERR 90 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
90 */ 91 */
91 int 92 enum GNUNET_GenericReturnValue
92 (*store_records) (void *cls, 93 (*store_records)(void *cls,
93 const struct GNUNET_IDENTITY_PrivateKey *zone, 94 const struct GNUNET_IDENTITY_PrivateKey *zone,
94 const char *label, 95 const char *label,
95 unsigned int rd_count, 96 unsigned int rd_count,
96 const struct GNUNET_GNSRECORD_Data *rd); 97 const struct GNUNET_GNSRECORD_Data *rd);
97 98
98 /** 99 /**
99 * Lookup records in the datastore for which we are the authority. 100 * Lookup records in the datastore for which we are the authority.
@@ -105,12 +106,12 @@ struct GNUNET_NAMESTORE_PluginFunctions
105 * @param iter_cls closure for @a iter 106 * @param iter_cls closure for @a iter
106 * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR 107 * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR
107 */ 108 */
108 int 109 enum GNUNET_GenericReturnValue
109 (*lookup_records) (void *cls, 110 (*lookup_records)(void *cls,
110 const struct GNUNET_IDENTITY_PrivateKey *zone, 111 const struct GNUNET_IDENTITY_PrivateKey *zone,
111 const char *label, 112 const char *label,
112 GNUNET_NAMESTORE_RecordIterator iter, 113 GNUNET_NAMESTORE_RecordIterator iter,
113 void *iter_cls); 114 void *iter_cls);
114 115
115 116
116 /** 117 /**
@@ -127,13 +128,13 @@ struct GNUNET_NAMESTORE_PluginFunctions
127 * @param iter_cls closure for @a iter 128 * @param iter_cls closure for @a iter
128 * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, #GNUNET_SYSERR on error 129 * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, #GNUNET_SYSERR on error
129 */ 130 */
130 int 131 enum GNUNET_GenericReturnValue
131 (*iterate_records) (void *cls, 132 (*iterate_records)(void *cls,
132 const struct GNUNET_IDENTITY_PrivateKey *zone, 133 const struct GNUNET_IDENTITY_PrivateKey *zone,
133 uint64_t serial, 134 uint64_t serial,
134 uint64_t limit, 135 uint64_t limit,
135 GNUNET_NAMESTORE_RecordIterator iter, 136 GNUNET_NAMESTORE_RecordIterator iter,
136 void *iter_cls); 137 void *iter_cls);
137 138
138 139
139 /** 140 /**
@@ -147,12 +148,12 @@ struct GNUNET_NAMESTORE_PluginFunctions
147 * @param iter_cls closure for @a iter 148 * @param iter_cls closure for @a iter
148 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error 149 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
149 */ 150 */
150 int 151 enum GNUNET_GenericReturnValue
151 (*zone_to_name) (void *cls, 152 (*zone_to_name)(void *cls,
152 const struct GNUNET_IDENTITY_PrivateKey *zone, 153 const struct GNUNET_IDENTITY_PrivateKey *zone,
153 const struct GNUNET_IDENTITY_PublicKey *value_zone, 154 const struct GNUNET_IDENTITY_PublicKey *value_zone,
154 GNUNET_NAMESTORE_RecordIterator iter, 155 GNUNET_NAMESTORE_RecordIterator iter,
155 void *iter_cls); 156 void *iter_cls);
156 157
157 /** Transaction-based API draft **/ 158 /** Transaction-based API draft **/
158 159
@@ -164,7 +165,7 @@ struct GNUNET_NAMESTORE_PluginFunctions
164 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 165 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
165 */ 166 */
166 enum GNUNET_GenericReturnValue 167 enum GNUNET_GenericReturnValue
167 (*transaction_begin) (void *cls, char **emsg); 168 (*transaction_begin)(void *cls, char **emsg);
168 169
169 /** 170 /**
170 * Abort and roll back a transaction in the database 171 * Abort and roll back a transaction in the database
@@ -174,7 +175,7 @@ struct GNUNET_NAMESTORE_PluginFunctions
174 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 175 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
175 */ 176 */
176 enum GNUNET_GenericReturnValue 177 enum GNUNET_GenericReturnValue
177 (*transaction_rollback) (void *cls, char **emsg); 178 (*transaction_rollback)(void *cls, char **emsg);
178 179
179 /** 180 /**
180 * Commit a transaction in the database 181 * Commit a transaction in the database
@@ -184,7 +185,7 @@ struct GNUNET_NAMESTORE_PluginFunctions
184 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 185 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
185 */ 186 */
186 enum GNUNET_GenericReturnValue 187 enum GNUNET_GenericReturnValue
187 (*transaction_commit) (void *cls, char **emsg); 188 (*transaction_commit)(void *cls, char **emsg);
188 189
189 /** 190 /**
190 * Edit records in the datastore for which we are the authority. 191 * Edit records in the datastore for which we are the authority.
@@ -198,35 +199,32 @@ struct GNUNET_NAMESTORE_PluginFunctions
198 * @param iter_cls closure for @a iter 199 * @param iter_cls closure for @a iter
199 * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR 200 * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR
200 */ 201 */
201 int 202 enum GNUNET_GenericReturnValue
202 (*edit_records) (void *cls, 203 (*edit_records)(void *cls,
203 const struct GNUNET_IDENTITY_PrivateKey *zone, 204 const struct GNUNET_IDENTITY_PrivateKey *zone,
204 const char *label, 205 const char *label,
205 GNUNET_NAMESTORE_RecordIterator iter, 206 GNUNET_NAMESTORE_RecordIterator iter,
206 void *iter_cls); 207 void *iter_cls);
207 208
208 /** 209 /**
209 * Setup the database. 210 * Setup the database.
210 * Note that this will also fail if the database is already initialized.
211 * See reset_database().
212 * 211 *
213 * @param cls closure (internal context for the plugin) 212 * @param cls closure (internal context for the plugin)
214 * @param emsg error message on failure. Will be allocated, must be freed.
215 * @return #GNUNET_OK on success, else fails with #GNUNET_SYSERR 213 * @return #GNUNET_OK on success, else fails with #GNUNET_SYSERR
216 */ 214 */
217 int 215 enum GNUNET_GenericReturnValue
218 (*initialize_database) (void *cls, char **emsg); 216 (*create_tables)(void *cls);
217
219 218
220 /** 219 /**
221 * Re-initializes the database. 220 * Drop existing tables.
222 * DANGEROUS: All existing data in the dabase will be lost! 221 * DANGEROUS: All existing data in the dabase will be lost!
223 * 222 *
224 * @param cls closure (internal context for the plugin) 223 * @param cls closure (internal context for the plugin)
225 * @param emsg error message on failure. Will be allocated, must be freed.
226 * @return #GNUNET_OK on success, else fails with #GNUNET_SYSERR 224 * @return #GNUNET_OK on success, else fails with #GNUNET_SYSERR
227 */ 225 */
228 int 226 enum GNUNET_GenericReturnValue
229 (*reset_database) (void *cls, char **emsg); 227 (*drop_tables)(void *cls);
230}; 228};
231 229
232 230
diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h
index 39449be5d..b93a345c7 100644
--- a/src/include/gnunet_namestore_service.h
+++ b/src/include/gnunet_namestore_service.h
@@ -41,6 +41,7 @@
41#ifndef GNUNET_NAMESTORE_SERVICE_H 41#ifndef GNUNET_NAMESTORE_SERVICE_H
42#define GNUNET_NAMESTORE_SERVICE_H 42#define GNUNET_NAMESTORE_SERVICE_H
43 43
44
44#include "gnunet_error_codes.h" 45#include "gnunet_error_codes.h"
45#include "gnunet_util_lib.h" 46#include "gnunet_util_lib.h"
46#include "gnunet_block_lib.h" 47#include "gnunet_block_lib.h"
diff --git a/src/include/gnunet_nat_auto_service.h b/src/include/gnunet_nat_auto_service.h
index db3a8460d..1c511cac3 100644
--- a/src/include/gnunet_nat_auto_service.h
+++ b/src/include/gnunet_nat_auto_service.h
@@ -34,6 +34,7 @@
34#ifndef GNUNET_NAT_AUTO_SERVICE_H 34#ifndef GNUNET_NAT_AUTO_SERVICE_H
35#define GNUNET_NAT_AUTO_SERVICE_H 35#define GNUNET_NAT_AUTO_SERVICE_H
36 36
37
37#include "gnunet_util_lib.h" 38#include "gnunet_util_lib.h"
38#include "gnunet_nat_service.h" 39#include "gnunet_nat_service.h"
39 40
diff --git a/src/include/gnunet_nat_service.h b/src/include/gnunet_nat_service.h
index e39e2c016..f2854a0be 100644
--- a/src/include/gnunet_nat_service.h
+++ b/src/include/gnunet_nat_service.h
@@ -36,6 +36,7 @@
36#ifndef GNUNET_NAT_SERVICE_H 36#ifndef GNUNET_NAT_SERVICE_H
37#define GNUNET_NAT_SERVICE_H 37#define GNUNET_NAT_SERVICE_H
38 38
39
39#include "gnunet_util_lib.h" 40#include "gnunet_util_lib.h"
40 41
41 42
@@ -385,6 +386,12 @@ GNUNET_NAT_request_reversal (struct GNUNET_NAT_Handle *nh,
385 * handle. This frees the handle, after having sent the needed 386 * handle. This frees the handle, after having sent the needed
386 * commands to close open ports. 387 * commands to close open ports.
387 * 388 *
389 * FIXME: No, the implementation of this API does not do anything beyond
390 * cleaning up the handle.
391 * This is a problem for applications that use #GNUNET_NAT_AddressCallback
392 * and use the app_ctx to store objects, because the callback will never be
393 * called for cleanup on unregister.
394 *
388 * @param nh the handle to unregister 395 * @param nh the handle to unregister
389 */ 396 */
390void 397void
diff --git a/src/include/gnunet_nc_lib.h b/src/include/gnunet_nc_lib.h
index dbd2aa12f..8f4d9a16f 100644
--- a/src/include/gnunet_nc_lib.h
+++ b/src/include/gnunet_nc_lib.h
@@ -17,6 +17,12 @@
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20
21
22#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
23#error "Only <gnunet_util_lib.h> can be included directly."
24#endif
25
20/** 26/**
21 * @addtogroup libgnunetutil 27 * @addtogroup libgnunetutil
22 * Multi-function utilities library for GNUnet programs 28 * Multi-function utilities library for GNUnet programs
diff --git a/src/include/gnunet_network_lib.h b/src/include/gnunet_network_lib.h
index 1e8b7e851..8d71d7764 100644
--- a/src/include/gnunet_network_lib.h
+++ b/src/include/gnunet_network_lib.h
@@ -52,6 +52,7 @@ extern "C"
52 * Include "sys/select.h" because it is required to use 52 * Include "sys/select.h" because it is required to use
53 * "fd_set" in "struct GNUNET_NETWORK_FDSet"! 53 * "fd_set" in "struct GNUNET_NETWORK_FDSet"!
54 */ 54 */
55
55#include <sys/select.h> 56#include <sys/select.h>
56//#endif 57//#endif
57#ifdef HAVE_SYS_SOCKET_H 58#ifdef HAVE_SYS_SOCKET_H
diff --git a/src/include/gnunet_nse_service.h b/src/include/gnunet_nse_service.h
index 7fe57a179..fe9e1f853 100644
--- a/src/include/gnunet_nse_service.h
+++ b/src/include/gnunet_nse_service.h
@@ -50,6 +50,7 @@ extern "C"
50#endif 50#endif
51#endif 51#endif
52 52
53
53#include "gnunet_util_lib.h" 54#include "gnunet_util_lib.h"
54 55
55/** 56/**
diff --git a/src/include/gnunet_op_lib.h b/src/include/gnunet_op_lib.h
index 0e09457cc..e028fb7fb 100644
--- a/src/include/gnunet_op_lib.h
+++ b/src/include/gnunet_op_lib.h
@@ -18,6 +18,10 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif
24
21/** 25/**
22 * @addtogroup libgnunetutil 26 * @addtogroup libgnunetutil
23 * Multi-function utilities library for GNUnet programs 27 * Multi-function utilities library for GNUnet programs
@@ -32,6 +36,7 @@
32#ifndef GNUNET_OP_H 36#ifndef GNUNET_OP_H
33#define GNUNET_OP_H 37#define GNUNET_OP_H
34 38
39
35#include "gnunet_util_lib.h" 40#include "gnunet_util_lib.h"
36 41
37/** 42/**
diff --git a/src/include/gnunet_os_lib.h b/src/include/gnunet_os_lib.h
index fc88e1123..015282054 100644
--- a/src/include/gnunet_os_lib.h
+++ b/src/include/gnunet_os_lib.h
@@ -18,6 +18,10 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif
24
21/** 25/**
22 * @addtogroup libgnunetutil 26 * @addtogroup libgnunetutil
23 * Multi-function utilities library for GNUnet programs 27 * Multi-function utilities library for GNUnet programs
@@ -60,10 +64,6 @@ extern "C"
60#endif 64#endif
61#endif 65#endif
62 66
63#include "gnunet_common.h"
64#include "gnunet_configuration_lib.h"
65#include "gnunet_scheduler_lib.h"
66
67 67
68/** 68/**
69 * Flags that determine which of the standard streams 69 * Flags that determine which of the standard streams
diff --git a/src/include/gnunet_peer_lib.h b/src/include/gnunet_peer_lib.h
index e088743e6..4a67878b9 100644
--- a/src/include/gnunet_peer_lib.h
+++ b/src/include/gnunet_peer_lib.h
@@ -18,6 +18,10 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif
24
21/** 25/**
22 * @addtogroup libgnunetutil 26 * @addtogroup libgnunetutil
23 * Multi-function utilities library for GNUnet programs 27 * Multi-function utilities library for GNUnet programs
@@ -36,6 +40,7 @@
36#ifndef GNUNET_PEER_LIB_H 40#ifndef GNUNET_PEER_LIB_H
37#define GNUNET_PEER_LIB_H 41#define GNUNET_PEER_LIB_H
38 42
43
39#include "gnunet_util_lib.h" 44#include "gnunet_util_lib.h"
40 45
41#ifdef __cplusplus 46#ifdef __cplusplus
diff --git a/src/include/gnunet_peerinfo_service.h b/src/include/gnunet_peerinfo_service.h
index 3be4a6977..806de963c 100644
--- a/src/include/gnunet_peerinfo_service.h
+++ b/src/include/gnunet_peerinfo_service.h
@@ -39,9 +39,9 @@
39#ifndef GNUNET_PEERINFO_SERVICE_H 39#ifndef GNUNET_PEERINFO_SERVICE_H
40#define GNUNET_PEERINFO_SERVICE_H 40#define GNUNET_PEERINFO_SERVICE_H
41 41
42
42#include "gnunet_common.h" 43#include "gnunet_common.h"
43#include "gnunet_configuration_lib.h" 44#include "gnunet_util_lib.h"
44#include "gnunet_crypto_lib.h"
45#include "gnunet_hello_lib.h" 45#include "gnunet_hello_lib.h"
46 46
47#ifdef __cplusplus 47#ifdef __cplusplus
diff --git a/src/include/gnunet_peerstore_plugin.h b/src/include/gnunet_peerstore_plugin.h
index fab3d41f9..2636c3009 100644
--- a/src/include/gnunet_peerstore_plugin.h
+++ b/src/include/gnunet_peerstore_plugin.h
@@ -34,6 +34,7 @@
34#ifndef GNUNET_PEERSTORE_PLUGIN_H 34#ifndef GNUNET_PEERSTORE_PLUGIN_H
35#define GNUNET_PEERSTORE_PLUGIN_H 35#define GNUNET_PEERSTORE_PLUGIN_H
36 36
37
37#include "gnunet_util_lib.h" 38#include "gnunet_util_lib.h"
38#include "gnunet_peerstore_service.h" 39#include "gnunet_peerstore_service.h"
39 40
diff --git a/src/include/gnunet_peerstore_service.h b/src/include/gnunet_peerstore_service.h
index f9b283a9f..c4000c680 100644
--- a/src/include/gnunet_peerstore_service.h
+++ b/src/include/gnunet_peerstore_service.h
@@ -36,6 +36,7 @@
36#ifndef GNUNET_PEERSTORE_SERVICE_H 36#ifndef GNUNET_PEERSTORE_SERVICE_H
37#define GNUNET_PEERSTORE_SERVICE_H 37#define GNUNET_PEERSTORE_SERVICE_H
38 38
39
39#include "gnunet_util_lib.h" 40#include "gnunet_util_lib.h"
40 41
41#ifdef __cplusplus 42#ifdef __cplusplus
diff --git a/src/include/gnunet_plugin_lib.h b/src/include/gnunet_plugin_lib.h
index d5f3f893a..a3135e2cf 100644
--- a/src/include/gnunet_plugin_lib.h
+++ b/src/include/gnunet_plugin_lib.h
@@ -18,6 +18,10 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif
24
21/** 25/**
22 * @addtogroup libgnunetutil 26 * @addtogroup libgnunetutil
23 * Multi-function utilities library for GNUnet programs 27 * Multi-function utilities library for GNUnet programs
@@ -44,9 +48,6 @@ extern "C"
44#endif 48#endif
45#endif 49#endif
46 50
47#include "gnunet_common.h"
48#include "gnunet_configuration_lib.h"
49
50 51
51/** 52/**
52 * Signature of any function exported by a plugin. 53 * Signature of any function exported by a plugin.
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h
index d52c0e40d..4cbc2a139 100644
--- a/src/include/gnunet_pq_lib.h
+++ b/src/include/gnunet_pq_lib.h
@@ -25,6 +25,7 @@
25#ifndef GNUNET_PQ_LIB_H 25#ifndef GNUNET_PQ_LIB_H
26#define GNUNET_PQ_LIB_H 26#define GNUNET_PQ_LIB_H
27 27
28
28#include <libpq-fe.h> 29#include <libpq-fe.h>
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
30#include "gnunet_db_lib.h" 31#include "gnunet_db_lib.h"
@@ -147,6 +148,39 @@ GNUNET_PQ_query_param_bool (bool b);
147 148
148 149
149/** 150/**
151 * Information for an array argument.
152 */
153struct GNUNET_PQ_ArraySpec
154{
155 /**
156 * Number of dimensions of the array
157 */
158 unsigned int ndims;
159
160 /**
161 * Array of @e ndims lengths of the array
162 */
163 unsigned int *lens;
164
165 /**
166 * One-dimensional array of pointers to conversion functions for the
167 * elements in the array.
168 */
169 const struct GNUNET_PQ_QueryParam *ae;
170
171};
172
173
174/**
175 * Generate query parameter for an array.
176 *
177 * @param as array specification
178 */
179struct GNUNET_PQ_QueryParam
180GNUNET_PQ_query_param_array (const struct GNUNET_PQ_ArraySpec *as);
181
182
183/**
150 * Generate fixed-size query parameter with size determined 184 * Generate fixed-size query parameter with size determined
151 * by variable type. 185 * by variable type.
152 * 186 *
@@ -1107,6 +1141,17 @@ GNUNET_PQ_event_notify (struct GNUNET_PQ_Context *db,
1107 1141
1108 1142
1109/** 1143/**
1144 * Compute the channel that one should notify upon
1145 * for the given event specification.
1146 *
1147 * @param es event specification
1148 * @return channel to notify upon
1149 */
1150char *
1151GNUNET_PG_get_event_notify_channel (const struct GNUNET_DB_EventHeaderP *es);
1152
1153
1154/**
1110 * Within the @a db context, run all the SQL files 1155 * Within the @a db context, run all the SQL files
1111 * from the @a load_path from 0000-9999.sql (as long 1156 * from the @a load_path from 0000-9999.sql (as long
1112 * as the files exist contiguously). 1157 * as the files exist contiguously).
diff --git a/src/include/gnunet_program_lib.h b/src/include/gnunet_program_lib.h
index 2d4dc626b..0c51d6cf7 100644
--- a/src/include/gnunet_program_lib.h
+++ b/src/include/gnunet_program_lib.h
@@ -18,6 +18,10 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif
24
21/** 25/**
22 * @addtogroup libgnunetutil 26 * @addtogroup libgnunetutil
23 * Multi-function utilities library for GNUnet programs 27 * Multi-function utilities library for GNUnet programs
@@ -44,6 +48,7 @@ extern "C"
44#endif 48#endif
45#endif 49#endif
46 50
51
47#include "gnunet_configuration_lib.h" 52#include "gnunet_configuration_lib.h"
48#include "gnunet_getopt_lib.h" 53#include "gnunet_getopt_lib.h"
49#include "gnunet_scheduler_lib.h" 54#include "gnunet_scheduler_lib.h"
diff --git a/src/include/gnunet_reclaim_lib.h b/src/include/gnunet_reclaim_lib.h
index 35b58cd0e..e4dec14fa 100644
--- a/src/include/gnunet_reclaim_lib.h
+++ b/src/include/gnunet_reclaim_lib.h
@@ -40,6 +40,7 @@ extern "C" {
40#endif 40#endif
41#endif 41#endif
42 42
43
43#include "gnunet_util_lib.h" 44#include "gnunet_util_lib.h"
44 45
45enum GNUNET_RECLAIM_AttributeType { 46enum GNUNET_RECLAIM_AttributeType {
diff --git a/src/include/gnunet_reclaim_plugin.h b/src/include/gnunet_reclaim_plugin.h
index 331f36f24..f8b2084d2 100644
--- a/src/include/gnunet_reclaim_plugin.h
+++ b/src/include/gnunet_reclaim_plugin.h
@@ -33,6 +33,7 @@
33#ifndef GNUNET_RECLAIM_PLUGIN_H 33#ifndef GNUNET_RECLAIM_PLUGIN_H
34#define GNUNET_RECLAIM_PLUGIN_H 34#define GNUNET_RECLAIM_PLUGIN_H
35 35
36
36#include "gnunet_util_lib.h" 37#include "gnunet_util_lib.h"
37#include "gnunet_reclaim_lib.h" 38#include "gnunet_reclaim_lib.h"
38 39
diff --git a/src/include/gnunet_reclaim_service.h b/src/include/gnunet_reclaim_service.h
index a3f6c19b6..49a006e91 100644
--- a/src/include/gnunet_reclaim_service.h
+++ b/src/include/gnunet_reclaim_service.h
@@ -41,6 +41,7 @@ extern "C" {
41#endif 41#endif
42#endif 42#endif
43 43
44
44#include "gnunet_identity_service.h" 45#include "gnunet_identity_service.h"
45#include "gnunet_reclaim_lib.h" 46#include "gnunet_reclaim_lib.h"
46#include "gnunet_util_lib.h" 47#include "gnunet_util_lib.h"
diff --git a/src/include/gnunet_regex_service.h b/src/include/gnunet_regex_service.h
index b8572156b..093bf2d6a 100644
--- a/src/include/gnunet_regex_service.h
+++ b/src/include/gnunet_regex_service.h
@@ -39,6 +39,7 @@
39#ifndef GNUNET_REGEX_SERVICE_H 39#ifndef GNUNET_REGEX_SERVICE_H
40#define GNUNET_REGEX_SERVICE_H 40#define GNUNET_REGEX_SERVICE_H
41 41
42
42#include "gnunet_util_lib.h" 43#include "gnunet_util_lib.h"
43 44
44#ifdef __cplusplus 45#ifdef __cplusplus
diff --git a/src/include/gnunet_resolver_service.h b/src/include/gnunet_resolver_service.h
index 80c92dc4e..89fec24f5 100644
--- a/src/include/gnunet_resolver_service.h
+++ b/src/include/gnunet_resolver_service.h
@@ -43,6 +43,7 @@ extern "C"
43#endif 43#endif
44#endif 44#endif
45 45
46
46#include "gnunet_configuration_lib.h" 47#include "gnunet_configuration_lib.h"
47#include "gnunet_scheduler_lib.h" 48#include "gnunet_scheduler_lib.h"
48#include "gnunet_time_lib.h" 49#include "gnunet_time_lib.h"
diff --git a/src/include/gnunet_rest_lib.h b/src/include/gnunet_rest_lib.h
index 82448697a..f70500de5 100644
--- a/src/include/gnunet_rest_lib.h
+++ b/src/include/gnunet_rest_lib.h
@@ -34,6 +34,7 @@
34#ifndef GNUNET_REST_LIB_H 34#ifndef GNUNET_REST_LIB_H
35#define GNUNET_REST_LIB_H 35#define GNUNET_REST_LIB_H
36 36
37
37#include "gnunet_util_lib.h" 38#include "gnunet_util_lib.h"
38#include <microhttpd.h> 39#include <microhttpd.h>
39 40
diff --git a/src/include/gnunet_rest_plugin.h b/src/include/gnunet_rest_plugin.h
index acfe879b3..45b391ca1 100644
--- a/src/include/gnunet_rest_plugin.h
+++ b/src/include/gnunet_rest_plugin.h
@@ -32,6 +32,7 @@
32#ifndef GNUNET_REST_PLUGIN_H 32#ifndef GNUNET_REST_PLUGIN_H
33#define GNUNET_REST_PLUGIN_H 33#define GNUNET_REST_PLUGIN_H
34 34
35
35#include "gnunet_util_lib.h" 36#include "gnunet_util_lib.h"
36#include "gnunet_rest_lib.h" 37#include "gnunet_rest_lib.h"
37#include "microhttpd.h" 38#include "microhttpd.h"
diff --git a/src/include/gnunet_revocation_service.h b/src/include/gnunet_revocation_service.h
index b3f6a5090..81a90189b 100644
--- a/src/include/gnunet_revocation_service.h
+++ b/src/include/gnunet_revocation_service.h
@@ -21,6 +21,7 @@
21#ifndef GNUNET_REVOCATION_SERVICE_H_ 21#ifndef GNUNET_REVOCATION_SERVICE_H_
22#define GNUNET_REVOCATION_SERVICE_H_ 22#define GNUNET_REVOCATION_SERVICE_H_
23 23
24
24#include "gnunet_identity_service.h" 25#include "gnunet_identity_service.h"
25 26
26/** 27/**
diff --git a/src/include/gnunet_scalarproduct_service.h b/src/include/gnunet_scalarproduct_service.h
index 7f60bb325..96d12db3f 100644
--- a/src/include/gnunet_scalarproduct_service.h
+++ b/src/include/gnunet_scalarproduct_service.h
@@ -31,6 +31,7 @@
31#ifndef GNUNET_SCALARPRODUCT_SERVICE_H 31#ifndef GNUNET_SCALARPRODUCT_SERVICE_H
32#define GNUNET_SCALARPRODUCT_SERVICE_H 32#define GNUNET_SCALARPRODUCT_SERVICE_H
33#define GCRYPT_NO_DEPRECATED 33#define GCRYPT_NO_DEPRECATED
34
34#include <gcrypt.h> 35#include <gcrypt.h>
35 36
36#ifdef __cplusplus 37#ifdef __cplusplus
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h
index 6492039dd..0118a1535 100644
--- a/src/include/gnunet_scheduler_lib.h
+++ b/src/include/gnunet_scheduler_lib.h
@@ -96,6 +96,7 @@ enum GNUNET_SCHEDULER_Reason
96}; 96};
97 97
98 98
99
99#include "gnunet_time_lib.h" 100#include "gnunet_time_lib.h"
100#include "gnunet_network_lib.h" 101#include "gnunet_network_lib.h"
101 102
diff --git a/src/include/gnunet_secretsharing_service.h b/src/include/gnunet_secretsharing_service.h
index c13cf482a..de629b308 100644
--- a/src/include/gnunet_secretsharing_service.h
+++ b/src/include/gnunet_secretsharing_service.h
@@ -40,6 +40,7 @@ extern "C"
40#endif 40#endif
41#endif 41#endif
42 42
43
43#include "gnunet_common.h" 44#include "gnunet_common.h"
44#include "gnunet_time_lib.h" 45#include "gnunet_time_lib.h"
45#include "gnunet_configuration_lib.h" 46#include "gnunet_configuration_lib.h"
diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h
index 8c8591af0..7c6ce0c0e 100644
--- a/src/include/gnunet_service_lib.h
+++ b/src/include/gnunet_service_lib.h
@@ -18,6 +18,11 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21
22#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
23#error "Only <gnunet_util_lib.h> can be included directly."
24#endif
25
21/** 26/**
22 * @addtogroup libgnunetutil 27 * @addtogroup libgnunetutil
23 * Multi-function utilities library for GNUnet programs 28 * Multi-function utilities library for GNUnet programs
@@ -50,8 +55,8 @@ extern "C"
50#endif 55#endif
51#endif 56#endif
52 57
58#include "gnunet_util_lib.h"
53#include "gnunet_configuration_lib.h" 59#include "gnunet_configuration_lib.h"
54#include "gnunet_mq_lib.h"
55 60
56 61
57/** 62/**
diff --git a/src/include/gnunet_set_service.h b/src/include/gnunet_set_service.h
index 255eef265..6874c9ec4 100644
--- a/src/include/gnunet_set_service.h
+++ b/src/include/gnunet_set_service.h
@@ -47,6 +47,7 @@ extern "C"
47#endif 47#endif
48#endif 48#endif
49 49
50
50#include "gnunet_common.h" 51#include "gnunet_common.h"
51#include "gnunet_time_lib.h" 52#include "gnunet_time_lib.h"
52#include "gnunet_configuration_lib.h" 53#include "gnunet_configuration_lib.h"
diff --git a/src/include/gnunet_seti_service.h b/src/include/gnunet_seti_service.h
index d2c3b59bb..9125ae825 100644
--- a/src/include/gnunet_seti_service.h
+++ b/src/include/gnunet_seti_service.h
@@ -44,6 +44,7 @@ extern "C"
44#endif 44#endif
45#endif 45#endif
46 46
47
47#include "gnunet_common.h" 48#include "gnunet_common.h"
48#include "gnunet_time_lib.h" 49#include "gnunet_time_lib.h"
49#include "gnunet_configuration_lib.h" 50#include "gnunet_configuration_lib.h"
diff --git a/src/include/gnunet_setu_service.h b/src/include/gnunet_setu_service.h
index 89ac3cd07..89a50f138 100644
--- a/src/include/gnunet_setu_service.h
+++ b/src/include/gnunet_setu_service.h
@@ -44,6 +44,7 @@ extern "C"
44#endif 44#endif
45#endif 45#endif
46 46
47
47#include "gnunet_common.h" 48#include "gnunet_common.h"
48#include "gnunet_time_lib.h" 49#include "gnunet_time_lib.h"
49#include "gnunet_configuration_lib.h" 50#include "gnunet_configuration_lib.h"
diff --git a/src/include/gnunet_signal_lib.h b/src/include/gnunet_signal_lib.h
index f70f22403..02fbbf005 100644
--- a/src/include/gnunet_signal_lib.h
+++ b/src/include/gnunet_signal_lib.h
@@ -18,6 +18,10 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif
24
21/** 25/**
22 * @addtogroup libgnunetutil 26 * @addtogroup libgnunetutil
23 * Multi-function utilities library for GNUnet programs 27 * Multi-function utilities library for GNUnet programs
diff --git a/src/include/gnunet_socks.h b/src/include/gnunet_socks.h
index b82943da3..98a27cd1a 100644
--- a/src/include/gnunet_socks.h
+++ b/src/include/gnunet_socks.h
@@ -43,6 +43,7 @@ extern "C"
43#endif 43#endif
44#endif 44#endif
45 45
46
46#include "gnunet_common.h" 47#include "gnunet_common.h"
47 48
48 49
diff --git a/src/include/gnunet_speaker_lib.h b/src/include/gnunet_speaker_lib.h
index cb4d65fb9..c6bb128dd 100644
--- a/src/include/gnunet_speaker_lib.h
+++ b/src/include/gnunet_speaker_lib.h
@@ -44,6 +44,7 @@ extern "C"
44#endif 44#endif
45#endif 45#endif
46 46
47
47#include "gnunet_util_lib.h" 48#include "gnunet_util_lib.h"
48 49
49/** 50/**
diff --git a/src/include/gnunet_sq_lib.h b/src/include/gnunet_sq_lib.h
index 3406b9031..b84e6759a 100644
--- a/src/include/gnunet_sq_lib.h
+++ b/src/include/gnunet_sq_lib.h
@@ -25,6 +25,7 @@
25#ifndef GNUNET_SQ_LIB_H 25#ifndef GNUNET_SQ_LIB_H
26#define GNUNET_SQ_LIB_H 26#define GNUNET_SQ_LIB_H
27 27
28
28#include <sqlite3.h> 29#include <sqlite3.h>
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
30 31
diff --git a/src/include/gnunet_statistics_service.h b/src/include/gnunet_statistics_service.h
index a886c6ed8..0fe09e69a 100644
--- a/src/include/gnunet_statistics_service.h
+++ b/src/include/gnunet_statistics_service.h
@@ -50,6 +50,7 @@ extern "C"
50#endif 50#endif
51#endif 51#endif
52 52
53
53#include "gnunet_util_lib.h" 54#include "gnunet_util_lib.h"
54 55
55/** 56/**
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h
index 7e06768b8..b751ef044 100644
--- a/src/include/gnunet_strings_lib.h
+++ b/src/include/gnunet_strings_lib.h
@@ -18,6 +18,10 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif
24
21/** 25/**
22 * @addtogroup libgnunetutil 26 * @addtogroup libgnunetutil
23 * Multi-function utilities library for GNUnet programs 27 * Multi-function utilities library for GNUnet programs
@@ -37,6 +41,10 @@
37 * @{ 41 * @{
38 */ 42 */
39 43
44#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
45#error "Only <gnunet_util_lib.h> can be included directly."
46#endif
47
40#ifndef GNUNET_STRINGS_LIB_H 48#ifndef GNUNET_STRINGS_LIB_H
41#define GNUNET_STRINGS_LIB_H 49#define GNUNET_STRINGS_LIB_H
42 50
@@ -44,6 +52,7 @@
44 or unsigned long long, this IS platform dependent; 52 or unsigned long long, this IS platform dependent;
45 but "stdlib.h" should be portable 'enough' to be 53 but "stdlib.h" should be portable 'enough' to be
46 unconditionally available... */ 54 unconditionally available... */
55
47#include <stdlib.h> 56#include <stdlib.h>
48#include <sys/socket.h> 57#include <sys/socket.h>
49#include <netinet/in.h> 58#include <netinet/in.h>
diff --git a/src/include/gnunet_testbed_logger_service.h b/src/include/gnunet_testbed_logger_service.h
index 91ede19d8..7ab943b15 100644
--- a/src/include/gnunet_testbed_logger_service.h
+++ b/src/include/gnunet_testbed_logger_service.h
@@ -43,6 +43,7 @@ extern "C"
43#endif 43#endif
44#endif 44#endif
45 45
46
46#include "gnunet_util_lib.h" 47#include "gnunet_util_lib.h"
47 48
48/** 49/**
diff --git a/src/include/gnunet_testbed_service.h b/src/include/gnunet_testbed_service.h
index ef67ab8ca..acd87e2cd 100644
--- a/src/include/gnunet_testbed_service.h
+++ b/src/include/gnunet_testbed_service.h
@@ -38,6 +38,7 @@
38#ifndef GNUNET_TESTBED_SERVICE_H 38#ifndef GNUNET_TESTBED_SERVICE_H
39#define GNUNET_TESTBED_SERVICE_H 39#define GNUNET_TESTBED_SERVICE_H
40 40
41
41#include "gnunet_util_lib.h" 42#include "gnunet_util_lib.h"
42#include "gnunet_testing_lib.h" 43#include "gnunet_testing_lib.h"
43 44
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h
index 2f64c306b..cd9d88822 100644
--- a/src/include/gnunet_testing_lib.h
+++ b/src/include/gnunet_testing_lib.h
@@ -44,6 +44,7 @@
44#ifndef GNUNET_TESTING_LIB_H 44#ifndef GNUNET_TESTING_LIB_H
45#define GNUNET_TESTING_LIB_H 45#define GNUNET_TESTING_LIB_H
46 46
47
47#include "gnunet_util_lib.h" 48#include "gnunet_util_lib.h"
48#include "gnunet_statistics_service.h" 49#include "gnunet_statistics_service.h"
49#include "gnunet_arm_service.h" 50#include "gnunet_arm_service.h"
diff --git a/src/include/gnunet_testing_netjail_lib.h b/src/include/gnunet_testing_netjail_lib.h
index 4f52f5af0..8d1295c98 100644
--- a/src/include/gnunet_testing_netjail_lib.h
+++ b/src/include/gnunet_testing_netjail_lib.h
@@ -27,6 +27,7 @@
27#ifndef GNUNET_TESTING_NETJAIL_LIB_H 27#ifndef GNUNET_TESTING_NETJAIL_LIB_H
28#define GNUNET_TESTING_NETJAIL_LIB_H 28#define GNUNET_TESTING_NETJAIL_LIB_H
29 29
30
30#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
31#include "gnunet_testing_plugin.h" 32#include "gnunet_testing_plugin.h"
32#include "gnunet_testing_ng_lib.h" 33#include "gnunet_testing_ng_lib.h"
@@ -271,7 +272,7 @@ GNUNET_TESTING_get_topo_from_file (const char *filename);
271 * @return The GNUNET_TESTING_NetjailTopology 272 * @return The GNUNET_TESTING_NetjailTopology
272 */ 273 */
273struct GNUNET_TESTING_NetjailTopology * 274struct GNUNET_TESTING_NetjailTopology *
274GNUNET_TESTING_get_topo_from_string (char *data); 275GNUNET_TESTING_get_topo_from_string (const char *data);
275 276
276 277
277/** 278/**
@@ -305,8 +306,8 @@ GNUNET_TESTING_get_node (unsigned int num,
305 * @return The connections of the node. 306 * @return The connections of the node.
306 */ 307 */
307struct GNUNET_TESTING_NodeConnection * 308struct GNUNET_TESTING_NodeConnection *
308GNUNET_TESTING_get_connections (unsigned int num, struct 309GNUNET_TESTING_get_connections (unsigned int num,
309 GNUNET_TESTING_NetjailTopology *topology); 310 const struct GNUNET_TESTING_NetjailTopology *topology);
310 311
311 312
312/** 313/**
@@ -318,7 +319,7 @@ GNUNET_TESTING_get_connections (unsigned int num, struct
318 */ 319 */
319char * 320char *
320GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection, 321GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection,
321 char *prefix); 322 const char *prefix);
322 323
323 324
324/** 325/**
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h
index 9a6c82d90..db89e1a8e 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -27,6 +27,7 @@
27#ifndef GNUNET_TESTING_NG_LIB_H 27#ifndef GNUNET_TESTING_NG_LIB_H
28#define GNUNET_TESTING_NG_LIB_H 28#define GNUNET_TESTING_NG_LIB_H
29 29
30
30#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
31#include "gnunet_testing_plugin.h" 32#include "gnunet_testing_plugin.h"
32#include "gnunet_testing_lib.h" 33#include "gnunet_testing_lib.h"
diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h
index e66ce6ea9..308aadb53 100644
--- a/src/include/gnunet_time_lib.h
+++ b/src/include/gnunet_time_lib.h
@@ -44,6 +44,7 @@ extern "C"
44#endif 44#endif
45#endif 45#endif
46 46
47
47#include "gnunet_common.h" 48#include "gnunet_common.h"
48 49
49/** 50/**
diff --git a/src/include/gnunet_transport_application_service.h b/src/include/gnunet_transport_application_service.h
index 9a6ddd36a..6ec1aa578 100644
--- a/src/include/gnunet_transport_application_service.h
+++ b/src/include/gnunet_transport_application_service.h
@@ -33,6 +33,7 @@
33#ifndef GNUNET_TRANSPORT_APPLICATION_SERVICE_H 33#ifndef GNUNET_TRANSPORT_APPLICATION_SERVICE_H
34#define GNUNET_TRANSPORT_APPLICATION_SERVICE_H 34#define GNUNET_TRANSPORT_APPLICATION_SERVICE_H
35 35
36
36#include "gnunet_constants.h" 37#include "gnunet_constants.h"
37#include "gnunet_util_lib.h" 38#include "gnunet_util_lib.h"
38#include "gnunet_nt_lib.h" 39#include "gnunet_nt_lib.h"
diff --git a/src/include/gnunet_transport_communication_service.h b/src/include/gnunet_transport_communication_service.h
index 6c99de78e..b523f1536 100644
--- a/src/include/gnunet_transport_communication_service.h
+++ b/src/include/gnunet_transport_communication_service.h
@@ -45,6 +45,7 @@ extern "C" {
45#endif 45#endif
46#endif 46#endif
47 47
48
48#include "gnunet_util_lib.h" 49#include "gnunet_util_lib.h"
49#include "gnunet_nt_lib.h" 50#include "gnunet_nt_lib.h"
50 51
diff --git a/src/include/gnunet_transport_core_service.h b/src/include/gnunet_transport_core_service.h
index fc8272892..9153161d3 100644
--- a/src/include/gnunet_transport_core_service.h
+++ b/src/include/gnunet_transport_core_service.h
@@ -43,6 +43,7 @@ extern "C" {
43#endif 43#endif
44#endif 44#endif
45 45
46
46#include "gnunet_util_lib.h" 47#include "gnunet_util_lib.h"
47 48
48/** 49/**
diff --git a/src/include/gnunet_transport_hello_service.h b/src/include/gnunet_transport_hello_service.h
index 6f737de23..03305ec27 100644
--- a/src/include/gnunet_transport_hello_service.h
+++ b/src/include/gnunet_transport_hello_service.h
@@ -46,6 +46,7 @@ extern "C" {
46#endif 46#endif
47#endif 47#endif
48 48
49
49#include "gnunet_util_lib.h" 50#include "gnunet_util_lib.h"
50#include "gnunet_ats_service.h" 51#include "gnunet_ats_service.h"
51 52
diff --git a/src/include/gnunet_transport_manipulation_service.h b/src/include/gnunet_transport_manipulation_service.h
index b77735a61..694ca7dca 100644
--- a/src/include/gnunet_transport_manipulation_service.h
+++ b/src/include/gnunet_transport_manipulation_service.h
@@ -47,6 +47,7 @@ extern "C"
47#endif 47#endif
48#endif 48#endif
49 49
50
50#include "gnunet_util_lib.h" 51#include "gnunet_util_lib.h"
51#include "gnunet_ats_service.h" 52#include "gnunet_ats_service.h"
52 53
diff --git a/src/include/gnunet_transport_monitor_service.h b/src/include/gnunet_transport_monitor_service.h
index c3d98ff53..acf7ade69 100644
--- a/src/include/gnunet_transport_monitor_service.h
+++ b/src/include/gnunet_transport_monitor_service.h
@@ -45,6 +45,7 @@ extern "C"
45#endif 45#endif
46#endif 46#endif
47 47
48
48#include "gnunet_util_lib.h" 49#include "gnunet_util_lib.h"
49#include "gnunet_ats_transport_service.h" 50#include "gnunet_ats_transport_service.h"
50#include "gnunet_transport_communication_service.h" 51#include "gnunet_transport_communication_service.h"
diff --git a/src/include/gnunet_transport_plugin.h b/src/include/gnunet_transport_plugin.h
index 3c857a34c..0ab4a995c 100644
--- a/src/include/gnunet_transport_plugin.h
+++ b/src/include/gnunet_transport_plugin.h
@@ -39,6 +39,7 @@
39#ifndef PLUGIN_TRANSPORT_H 39#ifndef PLUGIN_TRANSPORT_H
40#define PLUGIN_TRANSPORT_H 40#define PLUGIN_TRANSPORT_H
41 41
42
42#include "gnunet_configuration_lib.h" 43#include "gnunet_configuration_lib.h"
43#include "gnunet_scheduler_lib.h" 44#include "gnunet_scheduler_lib.h"
44#include "gnunet_statistics_service.h" 45#include "gnunet_statistics_service.h"
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h
index daa79bf1c..72cdbe0a7 100644
--- a/src/include/gnunet_transport_service.h
+++ b/src/include/gnunet_transport_service.h
@@ -45,6 +45,7 @@ extern "C" {
45#endif 45#endif
46#endif 46#endif
47 47
48
48#include "gnunet_util_lib.h" 49#include "gnunet_util_lib.h"
49#include "gnunet_ats_service.h" 50#include "gnunet_ats_service.h"
50 51
diff --git a/src/include/gnunet_tun_lib.h b/src/include/gnunet_tun_lib.h
index e92d6ae04..17acfe5f8 100644
--- a/src/include/gnunet_tun_lib.h
+++ b/src/include/gnunet_tun_lib.h
@@ -18,6 +18,10 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
22#error "Only <gnunet_util_lib.h> can be included directly."
23#endif
24
21/** 25/**
22 * @addtogroup vpn_suite VPN services and libraries 26 * @addtogroup vpn_suite VPN services and libraries
23 * @{ 27 * @{
@@ -37,9 +41,6 @@
37#ifndef GNUNET_TUN_LIB_H 41#ifndef GNUNET_TUN_LIB_H
38#define GNUNET_TUN_LIB_H 42#define GNUNET_TUN_LIB_H
39 43
40#include "gnunet_common.h"
41#include "gnunet_crypto_lib.h"
42
43 44
44/* see http://www.iana.org/assignments/ethernet-numbers */ 45/* see http://www.iana.org/assignments/ethernet-numbers */
45#ifndef ETH_P_IPV4 46#ifndef ETH_P_IPV4
diff --git a/src/include/gnunet_util_lib.h b/src/include/gnunet_util_lib.h
index ee362f789..ada40a4ca 100644
--- a/src/include/gnunet_util_lib.h
+++ b/src/include/gnunet_util_lib.h
@@ -30,6 +30,10 @@
30#ifndef GNUNET_UTIL_LIB_H 30#ifndef GNUNET_UTIL_LIB_H
31#define GNUNET_UTIL_LIB_H 31#define GNUNET_UTIL_LIB_H
32 32
33#define __GNUNET_UTIL_LIB_H_INSIDE__
34
35#include <sys/socket.h>
36
33#ifdef __cplusplus 37#ifdef __cplusplus
34extern "C" 38extern "C"
35{ 39{
@@ -59,9 +63,10 @@ extern "C"
59 * this service available to anyone but yourself. 63 * this service available to anyone but yourself.
60 */ 64 */
61#define GNUNET_AGPL_URL "https://git.gnunet.org/gnunet.git/tag/?h=v" \ 65#define GNUNET_AGPL_URL "https://git.gnunet.org/gnunet.git/tag/?h=v" \
62 PACKAGE_VERSION 66 GNUNET_VERSION
63
64 67
68#include "gnunet_config.h"
69#include "gnunet_common.h"
65#include "gnunet_crypto_lib.h" 70#include "gnunet_crypto_lib.h"
66#include "gnunet_bandwidth_lib.h" 71#include "gnunet_bandwidth_lib.h"
67#include "gnunet_bio_lib.h" 72#include "gnunet_bio_lib.h"
@@ -88,6 +93,43 @@ extern "C"
88#include "gnunet_child_management_lib.h" 93#include "gnunet_child_management_lib.h"
89#include "gnunet_error_codes.h" 94#include "gnunet_error_codes.h"
90 95
96/**
97 * Try to compress the given block of data using libz. Only returns
98 * the compressed block if compression worked and the new block is
99 * actually smaller. Decompress using #GNUNET_decompress().
100 *
101 * @param data block to compress; if compression
102 * resulted in a smaller block, the first
103 * bytes of data are updated to the compressed
104 * data
105 * @param old_size number of bytes in data
106 * @param[out] result set to the compressed data, if compression worked
107 * @param[out] new_size set to size of result, if compression worked
108 * @return #GNUNET_YES if compression reduce the size,
109 * #GNUNET_NO if compression did not help
110 */
111int
112GNUNET_try_compression (const char *data,
113 size_t old_size,
114 char **result,
115 size_t *new_size);
116
117/**
118 * Decompress input, return the decompressed data as output. Dual to
119 * #GNUNET_try_compression(). Caller must set @a output_size to the
120 * number of bytes that were originally compressed.
121 *
122 * @param input compressed data
123 * @param input_size number of bytes in input
124 * @param output_size expected size of the output
125 * @return NULL on error, buffer of @a output_size decompressed bytes otherwise
126 */
127char *
128GNUNET_decompress (const char *input,
129 size_t input_size,
130 size_t output_size);
131
132
91#if 0 /* keep Emacsens' auto-indent happy */ 133#if 0 /* keep Emacsens' auto-indent happy */
92{ 134{
93#endif 135#endif
@@ -95,4 +137,6 @@ extern "C"
95} 137}
96#endif 138#endif
97 139
140#undef __GNUNET_UTIL_LIB_H_INSIDE__
141
98#endif 142#endif
diff --git a/src/include/gnunet_vpn_service.h b/src/include/gnunet_vpn_service.h
index d493dddd0..f0a04ae1b 100644
--- a/src/include/gnunet_vpn_service.h
+++ b/src/include/gnunet_vpn_service.h
@@ -34,6 +34,7 @@
34#ifndef GNUNET_VPN_SERVICE_H 34#ifndef GNUNET_VPN_SERVICE_H
35#define GNUNET_VPN_SERVICE_H 35#define GNUNET_VPN_SERVICE_H
36 36
37
37#include "gnunet_util_lib.h" 38#include "gnunet_util_lib.h"
38 39
39 40
diff --git a/src/include/platform.h b/src/include/platform.h
index e44f9f51a..deca323d1 100644
--- a/src/include/platform.h
+++ b/src/include/platform.h
@@ -34,7 +34,7 @@
34#ifndef HAVE_USED_CONFIG_H 34#ifndef HAVE_USED_CONFIG_H
35#define HAVE_USED_CONFIG_H 35#define HAVE_USED_CONFIG_H
36#if HAVE_CONFIG_H 36#if HAVE_CONFIG_H
37#include "gnunet_config.h" 37#include "gnunet_private_config.h"
38#endif 38#endif
39#endif 39#endif
40 40
diff --git a/src/messenger/gnunet-messenger.c b/src/messenger/gnunet-messenger.c
index 11b0e091a..9444fa12d 100644
--- a/src/messenger/gnunet-messenger.c
+++ b/src/messenger/gnunet-messenger.c
@@ -23,9 +23,9 @@
23 * @brief Print information about messenger groups. 23 * @brief Print information about messenger groups.
24 */ 24 */
25 25
26#include "platform.h"
26#include <stdio.h> 27#include <stdio.h>
27 28
28#include "platform.h"
29#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
30#include "gnunet_messenger_service.h" 30#include "gnunet_messenger_service.h"
31 31
diff --git a/src/messenger/gnunet-service-messenger.c b/src/messenger/gnunet-service-messenger.c
index a4b46773d..f0bb853d7 100644
--- a/src/messenger/gnunet-service-messenger.c
+++ b/src/messenger/gnunet-service-messenger.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger.h" 27#include "gnunet-service-messenger.h"
27 28
28#include "gnunet-service-messenger_handle.h" 29#include "gnunet-service-messenger_handle.h"
diff --git a/src/messenger/gnunet-service-messenger.h b/src/messenger/gnunet-service-messenger.h
index 253fbaadb..1db5c651c 100644
--- a/src/messenger/gnunet-service-messenger.h
+++ b/src/messenger/gnunet-service-messenger.h
@@ -28,11 +28,7 @@
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_cadet_service.h" 30#include "gnunet_cadet_service.h"
31#include "gnunet_container_lib.h"
32#include "gnunet_crypto_lib.h"
33#include "gnunet_identity_service.h" 31#include "gnunet_identity_service.h"
34#include "gnunet_mq_lib.h"
35#include "gnunet_peer_lib.h"
36#include "gnunet_protocols.h" 32#include "gnunet_protocols.h"
37#include "gnunet_util_lib.h" 33#include "gnunet_util_lib.h"
38 34
diff --git a/src/messenger/gnunet-service-messenger_basement.c b/src/messenger/gnunet-service-messenger_basement.c
index 89aa103ee..ae0dcaa62 100644
--- a/src/messenger/gnunet-service-messenger_basement.c
+++ b/src/messenger/gnunet-service-messenger_basement.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_basement.h" 27#include "gnunet-service-messenger_basement.h"
27 28
28size_t 29size_t
diff --git a/src/messenger/gnunet-service-messenger_ego_store.c b/src/messenger/gnunet-service-messenger_ego_store.c
index 434c418e5..3eb313b08 100644
--- a/src/messenger/gnunet-service-messenger_ego_store.c
+++ b/src/messenger/gnunet-service-messenger_ego_store.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_ego_store.h" 27#include "gnunet-service-messenger_ego_store.h"
27 28
28#include "gnunet-service-messenger_handle.h" 29#include "gnunet-service-messenger_handle.h"
diff --git a/src/messenger/gnunet-service-messenger_ego_store.h b/src/messenger/gnunet-service-messenger_ego_store.h
index dbe6c05b9..a5f8a69d8 100644
--- a/src/messenger/gnunet-service-messenger_ego_store.h
+++ b/src/messenger/gnunet-service-messenger_ego_store.h
@@ -27,7 +27,7 @@
27#define GNUNET_SERVICE_MESSENGER_EGO_STORE_H 27#define GNUNET_SERVICE_MESSENGER_EGO_STORE_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_container_lib.h" 30#include "gnunet_util_lib.h"
31 31
32#include "messenger_api_ego.h" 32#include "messenger_api_ego.h"
33 33
diff --git a/src/messenger/gnunet-service-messenger_handle.c b/src/messenger/gnunet-service-messenger_handle.c
index 28fa022c7..17692761d 100644
--- a/src/messenger/gnunet-service-messenger_handle.c
+++ b/src/messenger/gnunet-service-messenger_handle.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_handle.h" 27#include "gnunet-service-messenger_handle.h"
27 28
28#include "gnunet-service-messenger.h" 29#include "gnunet-service-messenger.h"
diff --git a/src/messenger/gnunet-service-messenger_handle.h b/src/messenger/gnunet-service-messenger_handle.h
index c596f4d3b..edcd2ccd0 100644
--- a/src/messenger/gnunet-service-messenger_handle.h
+++ b/src/messenger/gnunet-service-messenger_handle.h
@@ -28,11 +28,8 @@
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_cadet_service.h" 30#include "gnunet_cadet_service.h"
31#include "gnunet_container_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_crypto_lib.h"
33#include "gnunet_identity_service.h" 32#include "gnunet_identity_service.h"
34#include "gnunet_peer_lib.h"
35#include "gnunet_mq_lib.h"
36 33
37#include "gnunet-service-messenger_service.h" 34#include "gnunet-service-messenger_service.h"
38#include "gnunet-service-messenger_member_session.h" 35#include "gnunet-service-messenger_member_session.h"
diff --git a/src/messenger/gnunet-service-messenger_list_handles.c b/src/messenger/gnunet-service-messenger_list_handles.c
index f2daa2e70..0703c2de6 100644
--- a/src/messenger/gnunet-service-messenger_list_handles.c
+++ b/src/messenger/gnunet-service-messenger_list_handles.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_list_handles.h" 27#include "gnunet-service-messenger_list_handles.h"
27 28
28#include "gnunet-service-messenger_handle.h" 29#include "gnunet-service-messenger_handle.h"
diff --git a/src/messenger/gnunet-service-messenger_list_handles.h b/src/messenger/gnunet-service-messenger_list_handles.h
index f41807d00..8c066519e 100644
--- a/src/messenger/gnunet-service-messenger_list_handles.h
+++ b/src/messenger/gnunet-service-messenger_list_handles.h
@@ -27,8 +27,7 @@
27#define GNUNET_SERVICE_MESSENGER_LIST_HANDLES_H 27#define GNUNET_SERVICE_MESSENGER_LIST_HANDLES_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_crypto_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_container_lib.h"
32 31
33struct GNUNET_MESSENGER_SrvHandle; 32struct GNUNET_MESSENGER_SrvHandle;
34 33
diff --git a/src/messenger/gnunet-service-messenger_list_messages.c b/src/messenger/gnunet-service-messenger_list_messages.c
index 7092dc76f..5bab52806 100644
--- a/src/messenger/gnunet-service-messenger_list_messages.c
+++ b/src/messenger/gnunet-service-messenger_list_messages.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_list_messages.h" 27#include "gnunet-service-messenger_list_messages.h"
27 28
28void 29void
diff --git a/src/messenger/gnunet-service-messenger_list_messages.h b/src/messenger/gnunet-service-messenger_list_messages.h
index e270209c8..5839f63ca 100644
--- a/src/messenger/gnunet-service-messenger_list_messages.h
+++ b/src/messenger/gnunet-service-messenger_list_messages.h
@@ -27,9 +27,7 @@
27#define GNUNET_SERVICE_MESSENGER_LIST_MESSAGES_H 27#define GNUNET_SERVICE_MESSENGER_LIST_MESSAGES_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_crypto_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_container_lib.h"
32#include "gnunet_disk_lib.h"
33 31
34struct GNUNET_MESSENGER_ListMessage 32struct GNUNET_MESSENGER_ListMessage
35{ 33{
diff --git a/src/messenger/gnunet-service-messenger_member.c b/src/messenger/gnunet-service-messenger_member.c
index 976b68fe6..444148831 100644
--- a/src/messenger/gnunet-service-messenger_member.c
+++ b/src/messenger/gnunet-service-messenger_member.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_member.h" 27#include "gnunet-service-messenger_member.h"
27 28
28#include "gnunet-service-messenger_member_session.h" 29#include "gnunet-service-messenger_member_session.h"
diff --git a/src/messenger/gnunet-service-messenger_member_session.c b/src/messenger/gnunet-service-messenger_member_session.c
index d71513046..519ac6f05 100644
--- a/src/messenger/gnunet-service-messenger_member_session.c
+++ b/src/messenger/gnunet-service-messenger_member_session.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_member_session.h" 27#include "gnunet-service-messenger_member_session.h"
27 28
28#include "gnunet-service-messenger_room.h" 29#include "gnunet-service-messenger_room.h"
diff --git a/src/messenger/gnunet-service-messenger_member_session.h b/src/messenger/gnunet-service-messenger_member_session.h
index fcde2c3de..9b4065d05 100644
--- a/src/messenger/gnunet-service-messenger_member_session.h
+++ b/src/messenger/gnunet-service-messenger_member_session.h
@@ -27,8 +27,7 @@
27#define GNUNET_SERVICE_MESSENGER_MEMBER_SESSION_H 27#define GNUNET_SERVICE_MESSENGER_MEMBER_SESSION_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_crypto_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_container_lib.h"
32#include "gnunet_identity_service.h" 31#include "gnunet_identity_service.h"
33#include "gnunet_time_lib.h" 32#include "gnunet_time_lib.h"
34 33
diff --git a/src/messenger/gnunet-service-messenger_member_store.c b/src/messenger/gnunet-service-messenger_member_store.c
index 844130429..fc28babc4 100644
--- a/src/messenger/gnunet-service-messenger_member_store.c
+++ b/src/messenger/gnunet-service-messenger_member_store.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_member_store.h" 27#include "gnunet-service-messenger_member_store.h"
27 28
28#include "gnunet-service-messenger_member.h" 29#include "gnunet-service-messenger_member.h"
diff --git a/src/messenger/gnunet-service-messenger_member_store.h b/src/messenger/gnunet-service-messenger_member_store.h
index c3f6d478a..05b00f39a 100644
--- a/src/messenger/gnunet-service-messenger_member_store.h
+++ b/src/messenger/gnunet-service-messenger_member_store.h
@@ -27,8 +27,7 @@
27#define GNUNET_SERVICE_MESSENGER_MEMBER_STORE_H 27#define GNUNET_SERVICE_MESSENGER_MEMBER_STORE_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_crypto_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_container_lib.h"
32#include "gnunet_identity_service.h" 31#include "gnunet_identity_service.h"
33#include "messenger_api_message.h" 32#include "messenger_api_message.h"
34 33
diff --git a/src/messenger/gnunet-service-messenger_message_handle.c b/src/messenger/gnunet-service-messenger_message_handle.c
index 6016ce438..06b987657 100644
--- a/src/messenger/gnunet-service-messenger_message_handle.c
+++ b/src/messenger/gnunet-service-messenger_message_handle.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_message_handle.h" 27#include "gnunet-service-messenger_message_handle.h"
27 28
28static void 29static void
diff --git a/src/messenger/gnunet-service-messenger_message_handle.h b/src/messenger/gnunet-service-messenger_message_handle.h
index 62940e6b6..0a97cd840 100644
--- a/src/messenger/gnunet-service-messenger_message_handle.h
+++ b/src/messenger/gnunet-service-messenger_message_handle.h
@@ -27,7 +27,7 @@
27#define GNUNET_SERVICE_MESSENGER_MESSAGE_HANDLE_H 27#define GNUNET_SERVICE_MESSENGER_MESSAGE_HANDLE_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_crypto_lib.h" 30#include "gnunet_util_lib.h"
31 31
32#include "gnunet-service-messenger_message_kind.h" 32#include "gnunet-service-messenger_message_kind.h"
33 33
diff --git a/src/messenger/gnunet-service-messenger_message_kind.c b/src/messenger/gnunet-service-messenger_message_kind.c
index 2449b9230..828e84d4f 100644
--- a/src/messenger/gnunet-service-messenger_message_kind.c
+++ b/src/messenger/gnunet-service-messenger_message_kind.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_message_kind.h" 27#include "gnunet-service-messenger_message_kind.h"
27 28
28#include "messenger_api_util.h" 29#include "messenger_api_util.h"
diff --git a/src/messenger/gnunet-service-messenger_message_kind.h b/src/messenger/gnunet-service-messenger_message_kind.h
index d07680dfc..102a70e33 100644
--- a/src/messenger/gnunet-service-messenger_message_kind.h
+++ b/src/messenger/gnunet-service-messenger_message_kind.h
@@ -27,8 +27,7 @@
27#define GNUNET_SERVICE_MESSENGER_MESSAGE_KIND_H 27#define GNUNET_SERVICE_MESSENGER_MESSAGE_KIND_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_container_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_crypto_lib.h"
32#include "gnunet_identity_service.h" 31#include "gnunet_identity_service.h"
33#include "gnunet_time_lib.h" 32#include "gnunet_time_lib.h"
34 33
diff --git a/src/messenger/gnunet-service-messenger_message_recv.c b/src/messenger/gnunet-service-messenger_message_recv.c
index 4e96cf552..94202fdca 100644
--- a/src/messenger/gnunet-service-messenger_message_recv.c
+++ b/src/messenger/gnunet-service-messenger_message_recv.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_message_recv.h" 27#include "gnunet-service-messenger_message_recv.h"
27 28
28#include "gnunet-service-messenger_operation.h" 29#include "gnunet-service-messenger_operation.h"
diff --git a/src/messenger/gnunet-service-messenger_message_recv.h b/src/messenger/gnunet-service-messenger_message_recv.h
index b4304762b..8e5b02504 100644
--- a/src/messenger/gnunet-service-messenger_message_recv.h
+++ b/src/messenger/gnunet-service-messenger_message_recv.h
@@ -27,7 +27,7 @@
27#define GNUNET_SERVICE_MESSENGER_MESSAGE_RECV_H 27#define GNUNET_SERVICE_MESSENGER_MESSAGE_RECV_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_crypto_lib.h" 30#include "gnunet_util_lib.h"
31 31
32#include "gnunet-service-messenger_message_kind.h" 32#include "gnunet-service-messenger_message_kind.h"
33 33
diff --git a/src/messenger/gnunet-service-messenger_message_send.c b/src/messenger/gnunet-service-messenger_message_send.c
index 5cb3cd627..09039758b 100644
--- a/src/messenger/gnunet-service-messenger_message_send.c
+++ b/src/messenger/gnunet-service-messenger_message_send.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_message_send.h" 27#include "gnunet-service-messenger_message_send.h"
27 28
28#include "gnunet-service-messenger_member.h" 29#include "gnunet-service-messenger_member.h"
diff --git a/src/messenger/gnunet-service-messenger_message_send.h b/src/messenger/gnunet-service-messenger_message_send.h
index 8d782c5a6..4f4c6cfc2 100644
--- a/src/messenger/gnunet-service-messenger_message_send.h
+++ b/src/messenger/gnunet-service-messenger_message_send.h
@@ -27,7 +27,7 @@
27#define GNUNET_SERVICE_MESSENGER_MESSAGE_SEND_H 27#define GNUNET_SERVICE_MESSENGER_MESSAGE_SEND_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_crypto_lib.h" 30#include "gnunet_util_lib.h"
31 31
32#include "gnunet-service-messenger_message_kind.h" 32#include "gnunet-service-messenger_message_kind.h"
33 33
diff --git a/src/messenger/gnunet-service-messenger_message_state.c b/src/messenger/gnunet-service-messenger_message_state.c
index 344962d11..b2328588e 100644
--- a/src/messenger/gnunet-service-messenger_message_state.c
+++ b/src/messenger/gnunet-service-messenger_message_state.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_message_state.h" 27#include "gnunet-service-messenger_message_state.h"
27 28
28void 29void
diff --git a/src/messenger/gnunet-service-messenger_message_state.h b/src/messenger/gnunet-service-messenger_message_state.h
index af52b26b6..10e6a2c46 100644
--- a/src/messenger/gnunet-service-messenger_message_state.h
+++ b/src/messenger/gnunet-service-messenger_message_state.h
@@ -27,7 +27,7 @@
27#define GNUNET_SERVICE_MESSENGER_MESSAGE_STATE_H 27#define GNUNET_SERVICE_MESSENGER_MESSAGE_STATE_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_crypto_lib.h" 30#include "gnunet_util_lib.h"
31 31
32#include "messenger_api_message.h" 32#include "messenger_api_message.h"
33#include "gnunet-service-messenger_list_messages.h" 33#include "gnunet-service-messenger_list_messages.h"
diff --git a/src/messenger/gnunet-service-messenger_message_store.c b/src/messenger/gnunet-service-messenger_message_store.c
index 6805cd125..1f77de9ca 100644
--- a/src/messenger/gnunet-service-messenger_message_store.c
+++ b/src/messenger/gnunet-service-messenger_message_store.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_message_store.h" 27#include "gnunet-service-messenger_message_store.h"
27#include "messenger_api_message.h" 28#include "messenger_api_message.h"
28 29
diff --git a/src/messenger/gnunet-service-messenger_message_store.h b/src/messenger/gnunet-service-messenger_message_store.h
index 60efb1380..262d10555 100644
--- a/src/messenger/gnunet-service-messenger_message_store.h
+++ b/src/messenger/gnunet-service-messenger_message_store.h
@@ -27,8 +27,7 @@
27#define GNUNET_SERVICE_MESSENGER_MESSAGE_STORE_H 27#define GNUNET_SERVICE_MESSENGER_MESSAGE_STORE_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_container_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_disk_lib.h"
32 31
33struct GNUNET_MESSENGER_MessageEntry 32struct GNUNET_MESSENGER_MessageEntry
34{ 33{
diff --git a/src/messenger/gnunet-service-messenger_operation.c b/src/messenger/gnunet-service-messenger_operation.c
index 2b92d0c1d..9c4201fdf 100644
--- a/src/messenger/gnunet-service-messenger_operation.c
+++ b/src/messenger/gnunet-service-messenger_operation.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_operation.h" 27#include "gnunet-service-messenger_operation.h"
27 28
28#include "gnunet-service-messenger_operation_store.h" 29#include "gnunet-service-messenger_operation_store.h"
diff --git a/src/messenger/gnunet-service-messenger_operation.h b/src/messenger/gnunet-service-messenger_operation.h
index 8d09ed1b7..b93282d24 100644
--- a/src/messenger/gnunet-service-messenger_operation.h
+++ b/src/messenger/gnunet-service-messenger_operation.h
@@ -28,9 +28,8 @@
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_configuration_lib.h" 30#include "gnunet_configuration_lib.h"
31#include "gnunet_crypto_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_scheduler_lib.h" 32#include "gnunet_scheduler_lib.h"
33#include "gnunet_strings_lib.h"
34#include "gnunet_time_lib.h" 33#include "gnunet_time_lib.h"
35 34
36enum GNUNET_MESSENGER_OperationType 35enum GNUNET_MESSENGER_OperationType
diff --git a/src/messenger/gnunet-service-messenger_operation_store.c b/src/messenger/gnunet-service-messenger_operation_store.c
index 276f0b92b..6a639d69e 100644
--- a/src/messenger/gnunet-service-messenger_operation_store.c
+++ b/src/messenger/gnunet-service-messenger_operation_store.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_operation_store.h" 27#include "gnunet-service-messenger_operation_store.h"
27 28
28#include "gnunet-service-messenger_operation.h" 29#include "gnunet-service-messenger_operation.h"
diff --git a/src/messenger/gnunet-service-messenger_operation_store.h b/src/messenger/gnunet-service-messenger_operation_store.h
index db315f251..16531758c 100644
--- a/src/messenger/gnunet-service-messenger_operation_store.h
+++ b/src/messenger/gnunet-service-messenger_operation_store.h
@@ -27,9 +27,7 @@
27#define GNUNET_SERVICE_MESSENGER_OPERATION_STORE_H 27#define GNUNET_SERVICE_MESSENGER_OPERATION_STORE_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_container_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_crypto_lib.h"
32#include "gnunet_scheduler_lib.h"
33#include "gnunet_time_lib.h" 31#include "gnunet_time_lib.h"
34 32
35struct GNUNET_MESSENGER_SrvRoom; 33struct GNUNET_MESSENGER_SrvRoom;
diff --git a/src/messenger/gnunet-service-messenger_room.c b/src/messenger/gnunet-service-messenger_room.c
index 068597f51..4b734cb40 100644
--- a/src/messenger/gnunet-service-messenger_room.c
+++ b/src/messenger/gnunet-service-messenger_room.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_room.h" 27#include "gnunet-service-messenger_room.h"
27 28
28#include "gnunet-service-messenger_member.h" 29#include "gnunet-service-messenger_member.h"
diff --git a/src/messenger/gnunet-service-messenger_room.h b/src/messenger/gnunet-service-messenger_room.h
index 6767d96cb..2e9382595 100644
--- a/src/messenger/gnunet-service-messenger_room.h
+++ b/src/messenger/gnunet-service-messenger_room.h
@@ -28,10 +28,8 @@
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_cadet_service.h" 30#include "gnunet_cadet_service.h"
31#include "gnunet_container_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_crypto_lib.h"
33#include "gnunet_identity_service.h" 32#include "gnunet_identity_service.h"
34#include "gnunet_mq_lib.h"
35 33
36#include "gnunet_messenger_service.h" 34#include "gnunet_messenger_service.h"
37#include "gnunet-service-messenger_basement.h" 35#include "gnunet-service-messenger_basement.h"
diff --git a/src/messenger/gnunet-service-messenger_service.c b/src/messenger/gnunet-service-messenger_service.c
index 3d5801b09..8dfc258c1 100644
--- a/src/messenger/gnunet-service-messenger_service.c
+++ b/src/messenger/gnunet-service-messenger_service.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_service.h" 27#include "gnunet-service-messenger_service.h"
27#include "gnunet-service-messenger_message_kind.h" 28#include "gnunet-service-messenger_message_kind.h"
28#include "gnunet-service-messenger.h" 29#include "gnunet-service-messenger.h"
diff --git a/src/messenger/gnunet-service-messenger_service.h b/src/messenger/gnunet-service-messenger_service.h
index 55e8b6c50..36df81141 100644
--- a/src/messenger/gnunet-service-messenger_service.h
+++ b/src/messenger/gnunet-service-messenger_service.h
@@ -28,9 +28,7 @@
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_configuration_lib.h" 30#include "gnunet_configuration_lib.h"
31#include "gnunet_crypto_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_container_lib.h"
33#include "gnunet_disk_lib.h"
34#include "gnunet_identity_service.h" 32#include "gnunet_identity_service.h"
35 33
36#include "gnunet-service-messenger_ego_store.h" 34#include "gnunet-service-messenger_ego_store.h"
diff --git a/src/messenger/gnunet-service-messenger_tunnel.c b/src/messenger/gnunet-service-messenger_tunnel.c
index 83973bbbe..8ad7fff1c 100644
--- a/src/messenger/gnunet-service-messenger_tunnel.c
+++ b/src/messenger/gnunet-service-messenger_tunnel.c
@@ -23,6 +23,7 @@
23 * @brief GNUnet MESSENGER service 23 * @brief GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet-service-messenger_tunnel.h" 27#include "gnunet-service-messenger_tunnel.h"
27 28
28#include "gnunet-service-messenger_handle.h" 29#include "gnunet-service-messenger_handle.h"
diff --git a/src/messenger/gnunet-service-messenger_tunnel.h b/src/messenger/gnunet-service-messenger_tunnel.h
index 13cf924f9..2ffa2d04f 100644
--- a/src/messenger/gnunet-service-messenger_tunnel.h
+++ b/src/messenger/gnunet-service-messenger_tunnel.h
@@ -28,8 +28,7 @@
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_cadet_service.h" 30#include "gnunet_cadet_service.h"
31#include "gnunet_peer_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_crypto_lib.h"
33 32
34#include "gnunet-service-messenger_room.h" 33#include "gnunet-service-messenger_room.h"
35#include "gnunet-service-messenger_message_state.h" 34#include "gnunet-service-messenger_message_state.h"
diff --git a/src/messenger/messenger_api.c b/src/messenger/messenger_api.c
index 85092fc43..610c979c4 100644
--- a/src/messenger/messenger_api.c
+++ b/src/messenger/messenger_api.c
@@ -23,6 +23,7 @@
23 * @brief messenger api: client implementation of GNUnet MESSENGER service 23 * @brief messenger api: client implementation of GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "gnunet_messenger_service.h" 27#include "gnunet_messenger_service.h"
27 28
28#include "gnunet-service-messenger.h" 29#include "gnunet-service-messenger.h"
diff --git a/src/messenger/messenger_api_contact.c b/src/messenger/messenger_api_contact.c
index cbca17640..a284c3b08 100644
--- a/src/messenger/messenger_api_contact.c
+++ b/src/messenger/messenger_api_contact.c
@@ -23,6 +23,7 @@
23 * @brief messenger api: client implementation of GNUnet MESSENGER service 23 * @brief messenger api: client implementation of GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "messenger_api_contact.h" 27#include "messenger_api_contact.h"
27 28
28struct GNUNET_MESSENGER_Contact* 29struct GNUNET_MESSENGER_Contact*
diff --git a/src/messenger/messenger_api_contact.h b/src/messenger/messenger_api_contact.h
index 6619d8fa2..e2919bcc3 100644
--- a/src/messenger/messenger_api_contact.h
+++ b/src/messenger/messenger_api_contact.h
@@ -27,7 +27,7 @@
27#define GNUNET_MESSENGER_API_CONTACT_H 27#define GNUNET_MESSENGER_API_CONTACT_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_crypto_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_identity_service.h" 31#include "gnunet_identity_service.h"
32 32
33struct GNUNET_MESSENGER_Contact 33struct GNUNET_MESSENGER_Contact
diff --git a/src/messenger/messenger_api_contact_store.c b/src/messenger/messenger_api_contact_store.c
index 1c10a8fbf..d42155e20 100644
--- a/src/messenger/messenger_api_contact_store.c
+++ b/src/messenger/messenger_api_contact_store.c
@@ -23,6 +23,7 @@
23 * @brief messenger api: client implementation of GNUnet MESSENGER service 23 * @brief messenger api: client implementation of GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "messenger_api_contact_store.h" 27#include "messenger_api_contact_store.h"
27 28
28#include "messenger_api_contact.h" 29#include "messenger_api_contact.h"
diff --git a/src/messenger/messenger_api_contact_store.h b/src/messenger/messenger_api_contact_store.h
index 1cdd3197b..c74a67740 100644
--- a/src/messenger/messenger_api_contact_store.h
+++ b/src/messenger/messenger_api_contact_store.h
@@ -27,8 +27,7 @@
27#define GNUNET_MESSENGER_API_CONTACT_STORE_H 27#define GNUNET_MESSENGER_API_CONTACT_STORE_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_container_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_crypto_lib.h"
32#include "gnunet_identity_service.h" 31#include "gnunet_identity_service.h"
33 32
34struct GNUNET_MESSENGER_Contact; 33struct GNUNET_MESSENGER_Contact;
diff --git a/src/messenger/messenger_api_handle.c b/src/messenger/messenger_api_handle.c
index 242389040..ec8d3dc7a 100644
--- a/src/messenger/messenger_api_handle.c
+++ b/src/messenger/messenger_api_handle.c
@@ -23,6 +23,7 @@
23 * @brief messenger api: client implementation of GNUnet MESSENGER service 23 * @brief messenger api: client implementation of GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "messenger_api_handle.h" 27#include "messenger_api_handle.h"
27 28
28#include "messenger_api_util.h" 29#include "messenger_api_util.h"
diff --git a/src/messenger/messenger_api_handle.h b/src/messenger/messenger_api_handle.h
index 8430f40d5..d246855ff 100644
--- a/src/messenger/messenger_api_handle.h
+++ b/src/messenger/messenger_api_handle.h
@@ -28,10 +28,8 @@
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_cadet_service.h" 30#include "gnunet_cadet_service.h"
31#include "gnunet_container_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_crypto_lib.h"
33#include "gnunet_identity_service.h" 32#include "gnunet_identity_service.h"
34#include "gnunet_peer_lib.h"
35 33
36#include "gnunet_messenger_service.h" 34#include "gnunet_messenger_service.h"
37 35
diff --git a/src/messenger/messenger_api_list_tunnels.c b/src/messenger/messenger_api_list_tunnels.c
index 7e77d8f2f..a4126c286 100644
--- a/src/messenger/messenger_api_list_tunnels.c
+++ b/src/messenger/messenger_api_list_tunnels.c
@@ -23,6 +23,7 @@
23 * @brief messenger api: client and service implementation of GNUnet MESSENGER service 23 * @brief messenger api: client and service implementation of GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "messenger_api_list_tunnels.h" 27#include "messenger_api_list_tunnels.h"
27 28
28void 29void
diff --git a/src/messenger/messenger_api_list_tunnels.h b/src/messenger/messenger_api_list_tunnels.h
index e28935c3e..d2ceeafc2 100644
--- a/src/messenger/messenger_api_list_tunnels.h
+++ b/src/messenger/messenger_api_list_tunnels.h
@@ -27,8 +27,7 @@
27#define GNUNET_MESSENGER_API_LIST_TUNNELS_H 27#define GNUNET_MESSENGER_API_LIST_TUNNELS_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_peer_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_container_lib.h"
32 31
33struct GNUNET_MESSENGER_ListTunnel 32struct GNUNET_MESSENGER_ListTunnel
34{ 33{
diff --git a/src/messenger/messenger_api_message.c b/src/messenger/messenger_api_message.c
index 2e4f46bff..ac63f16ca 100644
--- a/src/messenger/messenger_api_message.c
+++ b/src/messenger/messenger_api_message.c
@@ -23,6 +23,7 @@
23 * @brief messenger api: client and service implementation of GNUnet MESSENGER service 23 * @brief messenger api: client and service implementation of GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "messenger_api_message.h" 27#include "messenger_api_message.h"
27 28
28struct GNUNET_MESSENGER_MessageSignature 29struct GNUNET_MESSENGER_MessageSignature
@@ -539,14 +540,15 @@ encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message,
539} while (0) 540} while (0)
540 541
541#define decode_step_key(src, offset, dst, length) do { \ 542#define decode_step_key(src, offset, dst, length) do { \
543 enum GNUNET_GenericReturnValue result; \
542 size_t read; \ 544 size_t read; \
543 ssize_t result = GNUNET_IDENTITY_read_public_key_from_buffer( \ 545 result = GNUNET_IDENTITY_read_public_key_from_buffer( \
544 src + offset, length - offset, dst, &read \ 546 src + offset, length - offset, dst, &read \
545 ); \ 547 ); \
546 if (result < 0) \ 548 if (GNUNET_SYSERR == result) \
547 GNUNET_break(0); \ 549 GNUNET_break(0); \
548 else \ 550 else \
549 offset += result; \ 551 offset += read; \
550} while (0) 552} while (0)
551 553
552static uint16_t 554static uint16_t
diff --git a/src/messenger/messenger_api_message.h b/src/messenger/messenger_api_message.h
index 209d80a4e..688c72994 100644
--- a/src/messenger/messenger_api_message.h
+++ b/src/messenger/messenger_api_message.h
@@ -27,9 +27,8 @@
27#define GNUNET_MESSENGER_API_MESSAGE_H 27#define GNUNET_MESSENGER_API_MESSAGE_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_crypto_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_identity_service.h" 31#include "gnunet_identity_service.h"
32#include "gnunet_mq_lib.h"
33#include "gnunet_signatures.h" 32#include "gnunet_signatures.h"
34 33
35#include "gnunet_messenger_service.h" 34#include "gnunet_messenger_service.h"
diff --git a/src/messenger/messenger_api_room.c b/src/messenger/messenger_api_room.c
index 6e2d33f48..c3e8bc957 100644
--- a/src/messenger/messenger_api_room.c
+++ b/src/messenger/messenger_api_room.c
@@ -23,6 +23,7 @@
23 * @brief messenger api: client implementation of GNUnet MESSENGER service 23 * @brief messenger api: client implementation of GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "messenger_api_room.h" 27#include "messenger_api_room.h"
27 28
28#include "messenger_api_handle.h" 29#include "messenger_api_handle.h"
diff --git a/src/messenger/messenger_api_room.h b/src/messenger/messenger_api_room.h
index cf8ab782b..d5ffc5c4b 100644
--- a/src/messenger/messenger_api_room.h
+++ b/src/messenger/messenger_api_room.h
@@ -27,8 +27,7 @@
27#define GNUNET_MESSENGER_API_ROOM_H 27#define GNUNET_MESSENGER_API_ROOM_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_container_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_crypto_lib.h"
32 31
33#include "gnunet_messenger_service.h" 32#include "gnunet_messenger_service.h"
34 33
diff --git a/src/messenger/messenger_api_util.c b/src/messenger/messenger_api_util.c
index 52b4e934a..f56e2e201 100644
--- a/src/messenger/messenger_api_util.c
+++ b/src/messenger/messenger_api_util.c
@@ -23,6 +23,7 @@
23 * @brief messenger api: client implementation of GNUnet MESSENGER service 23 * @brief messenger api: client implementation of GNUnet MESSENGER service
24 */ 24 */
25 25
26#include "platform.h"
26#include "messenger_api_util.h" 27#include "messenger_api_util.h"
27 28
28static void 29static void
diff --git a/src/messenger/messenger_api_util.h b/src/messenger/messenger_api_util.h
index 0597b94a8..3d68505a8 100644
--- a/src/messenger/messenger_api_util.h
+++ b/src/messenger/messenger_api_util.h
@@ -28,9 +28,7 @@
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_cadet_service.h" 30#include "gnunet_cadet_service.h"
31#include "gnunet_container_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_crypto_lib.h"
33#include "gnunet_disk_lib.h"
34#include "gnunet_identity_service.h" 32#include "gnunet_identity_service.h"
35#include "gnunet_messenger_service.h" 33#include "gnunet_messenger_service.h"
36 34
diff --git a/src/messenger/test_messenger.c b/src/messenger/test_messenger.c
index 5784dfd82..8758ce562 100644
--- a/src/messenger/test_messenger.c
+++ b/src/messenger/test_messenger.c
@@ -22,8 +22,8 @@
22 * @author Tobias Frisch 22 * @author Tobias Frisch
23 * @brief Test for the messenger service using cadet API. 23 * @brief Test for the messenger service using cadet API.
24 */ 24 */
25#include <stdio.h>
26#include "platform.h" 25#include "platform.h"
26#include <stdio.h>
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_testing_lib.h" 28#include "gnunet_testing_lib.h"
29#include "gnunet_messenger_service.h" 29#include "gnunet_messenger_service.h"
diff --git a/src/messenger/test_messenger_adapt.c b/src/messenger/test_messenger_adapt.c
index 3230af6b7..b19634152 100644
--- a/src/messenger/test_messenger_adapt.c
+++ b/src/messenger/test_messenger_adapt.c
@@ -23,6 +23,7 @@
23 * @brief Test for the messenger service using cadet API. 23 * @brief Test for the messenger service using cadet API.
24 */ 24 */
25 25
26#include "platform.h"
26#include "testing_messenger_setup.h" 27#include "testing_messenger_setup.h"
27 28
28/** 29/**
diff --git a/src/messenger/test_messenger_anonymous.c b/src/messenger/test_messenger_anonymous.c
index 8cb339f0e..13f2b6f0e 100644
--- a/src/messenger/test_messenger_anonymous.c
+++ b/src/messenger/test_messenger_anonymous.c
@@ -22,8 +22,8 @@
22 * @author Tobias Frisch 22 * @author Tobias Frisch
23 * @brief Test for the messenger service using cadet API. 23 * @brief Test for the messenger service using cadet API.
24 */ 24 */
25#include <stdio.h>
26#include "platform.h" 25#include "platform.h"
26#include <stdio.h>
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_testing_lib.h" 28#include "gnunet_testing_lib.h"
29#include "gnunet_messenger_service.h" 29#include "gnunet_messenger_service.h"
diff --git a/src/messenger/test_messenger_async_client.c b/src/messenger/test_messenger_async_client.c
index 8404195dc..580fc1ecb 100644
--- a/src/messenger/test_messenger_async_client.c
+++ b/src/messenger/test_messenger_async_client.c
@@ -23,6 +23,7 @@
23 * @brief Test for the messenger service using cadet API. 23 * @brief Test for the messenger service using cadet API.
24 */ 24 */
25 25
26#include "platform.h"
26#include "testing_messenger_setup.h" 27#include "testing_messenger_setup.h"
27 28
28/** 29/**
diff --git a/src/messenger/test_messenger_async_p2p.c b/src/messenger/test_messenger_async_p2p.c
index 25746f7ff..762be9d49 100644
--- a/src/messenger/test_messenger_async_p2p.c
+++ b/src/messenger/test_messenger_async_p2p.c
@@ -23,6 +23,7 @@
23 * @brief Test for the messenger service using cadet API. 23 * @brief Test for the messenger service using cadet API.
24 */ 24 */
25 25
26#include "platform.h"
26#include "testing_messenger_setup.h" 27#include "testing_messenger_setup.h"
27 28
28/** 29/**
diff --git a/src/messenger/test_messenger_growth.c b/src/messenger/test_messenger_growth.c
index c3f243cbf..4a73e559d 100644
--- a/src/messenger/test_messenger_growth.c
+++ b/src/messenger/test_messenger_growth.c
@@ -23,6 +23,7 @@
23 * @brief Test for the messenger service using cadet API. 23 * @brief Test for the messenger service using cadet API.
24 */ 24 */
25 25
26#include "platform.h"
26#include "testing_messenger_setup.h" 27#include "testing_messenger_setup.h"
27 28
28/** 29/**
diff --git a/src/messenger/test_messenger_ring.c b/src/messenger/test_messenger_ring.c
index 777d79eb8..c6b17861e 100644
--- a/src/messenger/test_messenger_ring.c
+++ b/src/messenger/test_messenger_ring.c
@@ -23,6 +23,7 @@
23 * @brief Test for the messenger service using cadet API. 23 * @brief Test for the messenger service using cadet API.
24 */ 24 */
25 25
26#include "platform.h"
26#include "testing_messenger_setup.h" 27#include "testing_messenger_setup.h"
27 28
28/** 29/**
diff --git a/src/messenger/test_messenger_server.c b/src/messenger/test_messenger_server.c
index 61e96e879..fdd9a3684 100644
--- a/src/messenger/test_messenger_server.c
+++ b/src/messenger/test_messenger_server.c
@@ -23,6 +23,7 @@
23 * @brief Test for the messenger service using cadet API. 23 * @brief Test for the messenger service using cadet API.
24 */ 24 */
25 25
26#include "platform.h"
26#include "testing_messenger_setup.h" 27#include "testing_messenger_setup.h"
27 28
28/** 29/**
diff --git a/src/messenger/test_messenger_sync_client.c b/src/messenger/test_messenger_sync_client.c
index 02d90a61d..74c9548bc 100644
--- a/src/messenger/test_messenger_sync_client.c
+++ b/src/messenger/test_messenger_sync_client.c
@@ -23,6 +23,7 @@
23 * @brief Test for the messenger service using cadet API. 23 * @brief Test for the messenger service using cadet API.
24 */ 24 */
25 25
26#include "platform.h"
26#include "testing_messenger_setup.h" 27#include "testing_messenger_setup.h"
27 28
28/** 29/**
diff --git a/src/messenger/test_messenger_sync_p2p.c b/src/messenger/test_messenger_sync_p2p.c
index 0a900a39e..299d5ff68 100644
--- a/src/messenger/test_messenger_sync_p2p.c
+++ b/src/messenger/test_messenger_sync_p2p.c
@@ -23,6 +23,7 @@
23 * @brief Test for the messenger service using cadet API. 23 * @brief Test for the messenger service using cadet API.
24 */ 24 */
25 25
26#include "platform.h"
26#include "testing_messenger_setup.h" 27#include "testing_messenger_setup.h"
27 28
28/** 29/**
diff --git a/src/messenger/test_messenger_worst_client.c b/src/messenger/test_messenger_worst_client.c
index a3d5aafec..ab535b876 100644
--- a/src/messenger/test_messenger_worst_client.c
+++ b/src/messenger/test_messenger_worst_client.c
@@ -23,6 +23,7 @@
23 * @brief Test for the messenger service using cadet API. 23 * @brief Test for the messenger service using cadet API.
24 */ 24 */
25 25
26#include "platform.h"
26#include "testing_messenger_setup.h" 27#include "testing_messenger_setup.h"
27 28
28/** 29/**
diff --git a/src/messenger/test_messenger_worst_p2p.c b/src/messenger/test_messenger_worst_p2p.c
index 89e54cfbd..0af9489a4 100644
--- a/src/messenger/test_messenger_worst_p2p.c
+++ b/src/messenger/test_messenger_worst_p2p.c
@@ -23,6 +23,7 @@
23 * @brief Test for the messenger service using cadet API. 23 * @brief Test for the messenger service using cadet API.
24 */ 24 */
25 25
26#include "platform.h"
26#include "testing_messenger_setup.h" 27#include "testing_messenger_setup.h"
27 28
28/** 29/**
diff --git a/src/messenger/testing_messenger_barrier.c b/src/messenger/testing_messenger_barrier.c
index a95ea9ef1..60d1fc0fe 100644
--- a/src/messenger/testing_messenger_barrier.c
+++ b/src/messenger/testing_messenger_barrier.c
@@ -23,6 +23,7 @@
23 * @brief Pseudo-barriers for simple event handling 23 * @brief Pseudo-barriers for simple event handling
24 */ 24 */
25 25
26#include "platform.h"
26#include "testing_messenger_barrier.h" 27#include "testing_messenger_barrier.h"
27 28
28struct GNUNET_BarrierHandle 29struct GNUNET_BarrierHandle
diff --git a/src/messenger/testing_messenger_setup.c b/src/messenger/testing_messenger_setup.c
index 3cde8c9bb..65cf12e73 100644
--- a/src/messenger/testing_messenger_setup.c
+++ b/src/messenger/testing_messenger_setup.c
@@ -23,10 +23,10 @@
23 * @brief A simple test-case setup for the messenger service 23 * @brief A simple test-case setup for the messenger service
24 */ 24 */
25 25
26#include "platform.h"
26#include "testing_messenger_setup.h" 27#include "testing_messenger_setup.h"
27 28
28#include <stdio.h> 29#include <stdio.h>
29#include "platform.h"
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_testbed_logger_service.h" 31#include "gnunet_testbed_logger_service.h"
32#include "gnunet_testbed_service.h" 32#include "gnunet_testbed_service.h"
diff --git a/src/my/my.c b/src/my/my.c
index 468a4a47c..b667af4f9 100644
--- a/src/my/my.c
+++ b/src/my/my.c
@@ -25,6 +25,7 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include <mysql/mysql.h> 27#include <mysql/mysql.h>
28#include "gnunet_mysql_compat.h"
28#include "gnunet_my_lib.h" 29#include "gnunet_my_lib.h"
29 30
30 31
diff --git a/src/my/my_query_helper.c b/src/my/my_query_helper.c
index e44caad91..c12970876 100644
--- a/src/my/my_query_helper.c
+++ b/src/my/my_query_helper.c
@@ -25,6 +25,7 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include <mysql/mysql.h> 27#include <mysql/mysql.h>
28#include "gnunet_mysql_compat.h"
28#include "gnunet_my_lib.h" 29#include "gnunet_my_lib.h"
29 30
30 31
diff --git a/src/my/my_result_helper.c b/src/my/my_result_helper.c
index e500c0b27..ceebc6f37 100644
--- a/src/my/my_result_helper.c
+++ b/src/my/my_result_helper.c
@@ -25,6 +25,7 @@
25 25
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_mysql_compat.h"
28#include "gnunet_my_lib.h" 29#include "gnunet_my_lib.h"
29 30
30 31
@@ -524,7 +525,7 @@ pre_extract_string (void *cls,
524 525
525 526
526/** 527/**
527 * Check size of extracted fixed size data from a Mysql database 528 * Check size of extracted fixed size data from a Mysql database
528 * 529 *
529 * @param cls closure 530 * @param cls closure
530 * @param[in,out] rs 531 * @param[in,out] rs
diff --git a/src/my/test_my.c b/src/my/test_my.c
index ffb5a5f13..e646c0fd5 100644
--- a/src/my/test_my.c
+++ b/src/my/test_my.c
@@ -24,6 +24,7 @@
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include <mysql/mysql.h> 26#include <mysql/mysql.h>
27#include "gnunet_mysql_compat.h"
27#include "gnunet_my_lib.h" 28#include "gnunet_my_lib.h"
28#include "gnunet_mysql_lib.h" 29#include "gnunet_mysql_lib.h"
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
diff --git a/src/mysql/mysql.c b/src/mysql/mysql.c
index 4c701905c..056c2f07f 100644
--- a/src/mysql/mysql.c
+++ b/src/mysql/mysql.c
@@ -25,6 +25,7 @@
25#include "platform.h" 25#include "platform.h"
26#include <mysql/mysql.h> 26#include <mysql/mysql.h>
27#include "gnunet_mysql_lib.h" 27#include "gnunet_mysql_lib.h"
28#include "gnunet_mysql_compat.h"
28 29
29/** 30/**
30 * Maximum number of supported parameters for a prepared 31 * Maximum number of supported parameters for a prepared
diff --git a/src/namecache/Makefile.am b/src/namecache/Makefile.am
index 272f16b77..f283d3f64 100644
--- a/src/namecache/Makefile.am
+++ b/src/namecache/Makefile.am
@@ -10,6 +10,13 @@ libexecdir= $(pkglibdir)/libexec/
10pkgcfg_DATA = \ 10pkgcfg_DATA = \
11 namecache.conf 11 namecache.conf
12 12
13sqldir = $(prefix)/share/gnunet/sql/
14
15sql_DATA = \
16 namecache-0001.sql \
17 namecache-drop.sql
18
19
13if USE_COVERAGE 20if USE_COVERAGE
14 AM_CFLAGS = --coverage -O0 21 AM_CFLAGS = --coverage -O0
15 XLIBS = -lgcov 22 XLIBS = -lgcov
@@ -168,4 +175,5 @@ EXTRA_DIST = \
168 test_namecache_api.conf \ 175 test_namecache_api.conf \
169 test_plugin_namecache_sqlite.conf \ 176 test_plugin_namecache_sqlite.conf \
170 test_plugin_namecache_postgres.conf \ 177 test_plugin_namecache_postgres.conf \
171 test_plugin_namecache_flat.conf 178 test_plugin_namecache_flat.conf \
179 $(sql_DATA)
diff --git a/src/namecache/gnunet-namecache.c b/src/namecache/gnunet-namecache.c
index 19f2a5766..e58d3f960 100644
--- a/src/namecache/gnunet-namecache.c
+++ b/src/namecache/gnunet-namecache.c
@@ -27,7 +27,6 @@
27 */ 27 */
28#include "platform.h" 28#include "platform.h"
29#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
30#include "gnunet_dnsparser_lib.h"
31#include "gnunet_identity_service.h" 30#include "gnunet_identity_service.h"
32#include "gnunet_gnsrecord_lib.h" 31#include "gnunet_gnsrecord_lib.h"
33#include "gnunet_namecache_service.h" 32#include "gnunet_namecache_service.h"
diff --git a/src/namecache/gnunet-service-namecache.c b/src/namecache/gnunet-service-namecache.c
index 0d95cddfb..dce843801 100644
--- a/src/namecache/gnunet-service-namecache.c
+++ b/src/namecache/gnunet-service-namecache.c
@@ -26,7 +26,6 @@
26 */ 26 */
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
29#include "gnunet_dnsparser_lib.h"
30#include "gnunet_statistics_service.h" 29#include "gnunet_statistics_service.h"
31#include "gnunet_namecache_service.h" 30#include "gnunet_namecache_service.h"
32#include "gnunet_namecache_plugin.h" 31#include "gnunet_namecache_plugin.h"
diff --git a/src/namecache/namecache-0001.sql b/src/namecache/namecache-0001.sql
new file mode 100644
index 000000000..8509b078f
--- /dev/null
+++ b/src/namecache/namecache-0001.sql
@@ -0,0 +1,42 @@
1--
2-- This file is part of GNUnet
3-- Copyright (C) 2014--2022 GNUnet e.V.
4--
5-- GNUnet is free software; you can redistribute it and/or modify it under the
6-- terms of the GNU General Public License as published by the Free Software
7-- Foundation; either version 3, or (at your option) any later version.
8--
9-- GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY
10-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12--
13-- You should have received a copy of the GNU General Public License along with
14-- GNUnet; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
15--
16
17-- Everything in one big transaction
18BEGIN;
19
20-- Check patch versioning is in place.
21SELECT _v.register_patch('namecache-0001', NULL, NULL);
22
23-------------------- Schema ----------------------------
24
25CREATE SCHEMA datacache;
26COMMENT ON SCHEMA datacache IS 'gnunet-datacache data';
27
28SET search_path TO datacache;
29
30CREATE TABLE IF NOT EXISTS ns096blocks (
31 query BYTEA NOT NULL DEFAULT '',
32 block BYTEA NOT NULL DEFAULT '',
33 expiration_time BIGINT NOT NULL DEFAULT 0);
34
35CREATE INDEX ir_query_hash
36 ON ns096blocks (query,expiration_time);
37
38CREATE INDEX ir_block_expiration
39 ON ns096blocks (expiration_time);
40
41
42COMMIT;
diff --git a/src/namecache/namecache-drop.sql b/src/namecache/namecache-drop.sql
new file mode 100644
index 000000000..197ee78c1
--- /dev/null
+++ b/src/namecache/namecache-drop.sql
@@ -0,0 +1,25 @@
1--
2-- This file is part of GNUnet
3-- Copyright (C) 2014--2022 GNUnet e.V.
4--
5-- GNUnet is free software; you can redistribute it and/or modify it under the
6-- terms of the GNU General Public License as published by the Free Software
7-- Foundation; either version 3, or (at your option) any later version.
8--
9-- GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY
10-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12--
13-- You should have received a copy of the GNU General Public License along with
14-- GNUnet; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
15--
16
17-- Everything in one big transaction
18BEGIN;
19
20
21SELECT _v.unregister_patch('namecache-0001');
22
23DROP SCHEMA namecache CASCADE;
24
25COMMIT;
diff --git a/src/namecache/namecache.conf.in b/src/namecache/namecache.conf.in
index cf1340846..6bf75454b 100644
--- a/src/namecache/namecache.conf.in
+++ b/src/namecache/namecache.conf.in
@@ -24,7 +24,6 @@ FILENAME = $GNUNET_DATA_HOME/namecache/flat.db
24 24
25[namecache-postgres] 25[namecache-postgres]
26CONFIG = postgres:///gnunet 26CONFIG = postgres:///gnunet
27TEMPORARY_TABLE = NO 27SQL_DIR = ${DATADIR}/sql/
28
29 28
30 29
diff --git a/src/namecache/namecache_api.c b/src/namecache/namecache_api.c
index 5e820f8cc..fb4b0e304 100644
--- a/src/namecache/namecache_api.c
+++ b/src/namecache/namecache_api.c
@@ -28,9 +28,7 @@
28 28
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_crypto_lib.h"
32#include "gnunet_constants.h" 31#include "gnunet_constants.h"
33#include "gnunet_dnsparser_lib.h"
34#include "gnunet_gnsrecord_lib.h" 32#include "gnunet_gnsrecord_lib.h"
35#include "gnunet_signatures.h" 33#include "gnunet_signatures.h"
36#include "gnunet_namecache_service.h" 34#include "gnunet_namecache_service.h"
diff --git a/src/namecache/plugin_namecache_postgres.c b/src/namecache/plugin_namecache_postgres.c
index d6d1730ce..cdbe248b6 100644
--- a/src/namecache/plugin_namecache_postgres.c
+++ b/src/namecache/plugin_namecache_postgres.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * This file is part of GNUnet 2 * This file is part of GNUnet
3 * Copyright (C) 2009-2013, 2016, 2017 GNUnet e.V. 3 * Copyright (C) 2009-2013, 2016, 2017, 2022 GNUnet e.V.
4 * 4 *
5 * GNUnet is free software: you can redistribute it and/or modify it 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 6 * under the terms of the GNU Affero General Public License as published
@@ -56,63 +56,34 @@ struct Plugin
56 * @param plugin the plugin context (state for this module) 56 * @param plugin the plugin context (state for this module)
57 * @return #GNUNET_OK on success 57 * @return #GNUNET_OK on success
58 */ 58 */
59static int 59static enum GNUNET_GenericReturnValue
60database_setup (struct Plugin *plugin) 60database_setup (struct Plugin *plugin)
61{ 61{
62 struct GNUNET_PQ_ExecuteStatement es_temporary = 62 struct GNUNET_PQ_PreparedStatement ps[] = {
63 GNUNET_PQ_make_execute ("CREATE TEMPORARY TABLE IF NOT EXISTS ns096blocks (" 63 GNUNET_PQ_make_prepare ("cache_block",
64 " query BYTEA NOT NULL DEFAULT ''," 64 "INSERT INTO namecache.ns096blocks"
65 " block BYTEA NOT NULL DEFAULT ''," 65 " (query, block, expiration_time)"
66 " expiration_time BIGINT NOT NULL DEFAULT 0" 66 " VALUES"
67 ")"); 67 " ($1, $2, $3)"),
68 struct GNUNET_PQ_ExecuteStatement es_default = 68 GNUNET_PQ_make_prepare ("expire_blocks",
69 GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS ns096blocks (" 69 "DELETE FROM namecache.ns096blocks"
70 " query BYTEA NOT NULL DEFAULT ''," 70 " WHERE expiration_time<$1"),
71 " block BYTEA NOT NULL DEFAULT ''," 71 GNUNET_PQ_make_prepare ("delete_block",
72 " expiration_time BIGINT NOT NULL DEFAULT 0" 72 "DELETE FROM namecache.ns096blocks"
73 ")"); 73 " WHERE query=$1 AND expiration_time<=$2"),
74 const struct GNUNET_PQ_ExecuteStatement *cr; 74 GNUNET_PQ_make_prepare ("lookup_block",
75 75 "SELECT block"
76 if (GNUNET_YES == 76 " FROM namecache.ns096blocks"
77 GNUNET_CONFIGURATION_get_value_yesno (plugin->cfg, 77 " WHERE query=$1"
78 " ORDER BY expiration_time DESC LIMIT 1"),
79 GNUNET_PQ_PREPARED_STATEMENT_END
80 };
81
82 plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg,
78 "namecache-postgres", 83 "namecache-postgres",
79 "TEMPORARY_TABLE")) 84 "namecache-",
80 { 85 NULL,
81 cr = &es_temporary; 86 ps);
82 }
83 else
84 {
85 cr = &es_default;
86 }
87 {
88 struct GNUNET_PQ_ExecuteStatement es[] = {
89 *cr,
90 GNUNET_PQ_make_try_execute (
91 "CREATE INDEX ir_query_hash ON ns096blocks (query,expiration_time)"),
92 GNUNET_PQ_make_try_execute (
93 "CREATE INDEX ir_block_expiration ON ns096blocks (expiration_time)"),
94 GNUNET_PQ_EXECUTE_STATEMENT_END
95 };
96 struct GNUNET_PQ_PreparedStatement ps[] = {
97 GNUNET_PQ_make_prepare ("cache_block",
98 "INSERT INTO ns096blocks (query, block, expiration_time) VALUES "
99 "($1, $2, $3)"),
100 GNUNET_PQ_make_prepare ("expire_blocks",
101 "DELETE FROM ns096blocks WHERE expiration_time<$1"),
102 GNUNET_PQ_make_prepare ("delete_block",
103 "DELETE FROM ns096blocks WHERE query=$1 AND expiration_time<=$2"),
104 GNUNET_PQ_make_prepare ("lookup_block",
105 "SELECT block FROM ns096blocks WHERE query=$1"
106 " ORDER BY expiration_time DESC LIMIT 1"),
107 GNUNET_PQ_PREPARED_STATEMENT_END
108 };
109
110 plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg,
111 "namecache-postgres",
112 NULL,
113 es,
114 ps);
115 }
116 if (NULL == plugin->dbh) 87 if (NULL == plugin->dbh)
117 return GNUNET_SYSERR; 88 return GNUNET_SYSERR;
118 return GNUNET_OK; 89 return GNUNET_OK;
@@ -174,7 +145,7 @@ delete_old_block (struct Plugin *plugin,
174 * @param block block to cache 145 * @param block block to cache
175 * @return #GNUNET_OK on success, else #GNUNET_SYSERR 146 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
176 */ 147 */
177static int 148static enum GNUNET_GenericReturnValue
178namecache_postgres_cache_block (void *cls, 149namecache_postgres_cache_block (void *cls,
179 const struct GNUNET_GNSRECORD_Block *block) 150 const struct GNUNET_GNSRECORD_Block *block)
180{ 151{
@@ -222,7 +193,7 @@ namecache_postgres_cache_block (void *cls,
222 * @param iter_cls closure for @a iter 193 * @param iter_cls closure for @a iter
223 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error 194 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
224 */ 195 */
225static int 196static enum GNUNET_GenericReturnValue
226namecache_postgres_lookup_block (void *cls, 197namecache_postgres_lookup_block (void *cls,
227 const struct GNUNET_HashCode *query, 198 const struct GNUNET_HashCode *query,
228 GNUNET_NAMECACHE_BlockCallback iter, 199 GNUNET_NAMECACHE_BlockCallback iter,
diff --git a/src/namecache/test_namecache_api_cache_block.c b/src/namecache/test_namecache_api_cache_block.c
index 2e8940ba3..d83758e7d 100644
--- a/src/namecache/test_namecache_api_cache_block.c
+++ b/src/namecache/test_namecache_api_cache_block.c
@@ -24,7 +24,6 @@
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_namecache_service.h" 25#include "gnunet_namecache_service.h"
26#include "gnunet_testing_lib.h" 26#include "gnunet_testing_lib.h"
27#include "gnunet_dnsparser_lib.h"
28 27
29#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 28#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
30 29
@@ -227,8 +226,8 @@ run (void *cls,
227int 226int
228main (int argc, char *argv[]) 227main (int argc, char *argv[])
229{ 228{
230 GNUNET_DISK_purge_cfg_dir 229 GNUNET_DISK_purge_cfg_dir
231 ("test_namecache_api.conf", 230 ("test_namecache_api.conf",
232 "GNUNET_TEST_HOME"); 231 "GNUNET_TEST_HOME");
233 res = 1; 232 res = 1;
234 if (0 != 233 if (0 !=
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am
index fb2a670bc..98ee228e1 100644
--- a/src/namestore/Makefile.am
+++ b/src/namestore/Makefile.am
@@ -7,6 +7,12 @@ pkgcfgdir= $(pkgdatadir)/config.d/
7 7
8libexecdir= $(pkglibdir)/libexec/ 8libexecdir= $(pkglibdir)/libexec/
9 9
10sqldir = $(prefix)/share/gnunet/sql/
11
12sql_DATA = \
13 namestore-0001.sql \
14 namestore-drop.sql
15
10pkgcfg_DATA = \ 16pkgcfg_DATA = \
11 namestore.conf 17 namestore.conf
12 18
@@ -514,6 +520,7 @@ test_plugin_namestore_postgres_LDADD = \
514 520
515check_SCRIPTS = \ 521check_SCRIPTS = \
516 test_namestore_put.sh \ 522 test_namestore_put.sh \
523 test_namestore_put_stdin.sh \
517 test_namestore_lookup.sh \ 524 test_namestore_lookup.sh \
518 test_namestore_delete.sh \ 525 test_namestore_delete.sh \
519 test_namestore_zonefile_import.sh 526 test_namestore_zonefile_import.sh
@@ -531,5 +538,6 @@ EXTRA_DIST = \
531 test_plugin_namestore_sqlite.conf \ 538 test_plugin_namestore_sqlite.conf \
532 test_plugin_namestore_postgres.conf \ 539 test_plugin_namestore_postgres.conf \
533 test_hostkey \ 540 test_hostkey \
534 example_zonefile \ 541 example_zonefile \
535 $(check_SCRIPTS) 542 $(check_SCRIPTS) \
543 $(sql_DATA)
diff --git a/src/namestore/gnunet-namestore-dbtool.c b/src/namestore/gnunet-namestore-dbtool.c
index a1ecf5e71..835d7a228 100644
--- a/src/namestore/gnunet-namestore-dbtool.c
+++ b/src/namestore/gnunet-namestore-dbtool.c
@@ -59,6 +59,8 @@ do_shutdown (void *cls)
59 if (NULL != pluginname) 59 if (NULL != pluginname)
60 GNUNET_free (pluginname); 60 GNUNET_free (pluginname);
61} 61}
62
63
62/** 64/**
63 * Main function that will be run. 65 * Main function that will be run.
64 * 66 *
@@ -74,7 +76,6 @@ run (void *cls,
74 const struct GNUNET_CONFIGURATION_Handle *cfg) 76 const struct GNUNET_CONFIGURATION_Handle *cfg)
75{ 77{
76 char *db_lib_name; 78 char *db_lib_name;
77 char *emsg;
78 struct GNUNET_NAMESTORE_PluginFunctions *plugin; 79 struct GNUNET_NAMESTORE_PluginFunctions *plugin;
79 80
80 (void) cls; 81 (void) cls;
@@ -86,7 +87,8 @@ run (void *cls,
86 _ ("Superfluous command line arguments (starting with `%s') ignored\n"), 87 _ ("Superfluous command line arguments (starting with `%s') ignored\n"),
87 args[0]); 88 args[0]);
88 89
89 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, (void *) cfg); 90 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
91 (void *) cfg);
90 if (NULL == pluginname) 92 if (NULL == pluginname)
91 { 93 {
92 fprintf (stderr, "No plugin given!\n"); 94 fprintf (stderr, "No plugin given!\n");
@@ -94,11 +96,15 @@ run (void *cls,
94 GNUNET_SCHEDULER_shutdown (); 96 GNUNET_SCHEDULER_shutdown ();
95 return; 97 return;
96 } 98 }
97 GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_namestore_%s", pluginname); 99 GNUNET_asprintf (&db_lib_name,
100 "libgnunet_plugin_namestore_%s",
101 pluginname);
98 plugin = GNUNET_PLUGIN_load (db_lib_name, (void *) cfg); 102 plugin = GNUNET_PLUGIN_load (db_lib_name, (void *) cfg);
99 if (NULL == plugin) 103 if (NULL == plugin)
100 { 104 {
101 fprintf (stderr, "Failed to load %s!\n", db_lib_name); 105 fprintf (stderr,
106 "Failed to load %s!\n",
107 db_lib_name);
102 ret = 1; 108 ret = 1;
103 GNUNET_SCHEDULER_shutdown (); 109 GNUNET_SCHEDULER_shutdown ();
104 GNUNET_free (db_lib_name); 110 GNUNET_free (db_lib_name);
@@ -106,34 +112,33 @@ run (void *cls,
106 } 112 }
107 if (reset) 113 if (reset)
108 { 114 {
109 if (GNUNET_OK != plugin->reset_database (plugin->cls, &emsg)) 115 if (GNUNET_OK !=
116 plugin->drop_tables (plugin->cls))
110 { 117 {
111 // FIXME do we want to return a reason? 118 fprintf (stderr,
112 fprintf (stderr, "Failed to reset database: %s\n", 119 "Failed to reset database\n");
113 emsg);
114 ret = 1; 120 ret = 1;
115 GNUNET_free (emsg);
116 GNUNET_free (db_lib_name); 121 GNUNET_free (db_lib_name);
117 GNUNET_SCHEDULER_shutdown (); 122 GNUNET_SCHEDULER_shutdown ();
118 return; 123 return;
119 } 124 }
120 } 125 }
121 else if (init) 126 if (init || reset)
122 { 127 {
123 if (GNUNET_OK != plugin->initialize_database (plugin->cls, &emsg)) 128 if (GNUNET_OK !=
129 plugin->create_tables (plugin->cls))
124 { 130 {
125 // FIXME do we want to return a reason? 131 fprintf (stderr,
126 fprintf (stderr, "Failed to initialize database: %s\n", 132 "Failed to initialize database\n");
127 emsg);
128 ret = 1; 133 ret = 1;
129 GNUNET_free (emsg);
130 GNUNET_free (db_lib_name); 134 GNUNET_free (db_lib_name);
131 GNUNET_SCHEDULER_shutdown (); 135 GNUNET_SCHEDULER_shutdown ();
132 return; 136 return;
133 } 137 }
134 } 138 }
135 GNUNET_SCHEDULER_shutdown (); 139 GNUNET_SCHEDULER_shutdown ();
136 GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, plugin)); 140 GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name,
141 plugin));
137 GNUNET_free (db_lib_name); 142 GNUNET_free (db_lib_name);
138} 143}
139 144
@@ -148,9 +153,10 @@ run (void *cls,
148int 153int
149main (int argc, char *const *argv) 154main (int argc, char *const *argv)
150{ 155{
151 struct GNUNET_GETOPT_CommandLineOption options[] = 156 struct GNUNET_GETOPT_CommandLineOption options[] = {
152 { GNUNET_GETOPT_option_flag ('i', "init", gettext_noop ( 157 GNUNET_GETOPT_option_flag ('i', "init",
153 "initialize database"), &init), 158 gettext_noop ("initialize database"),
159 &init),
154 GNUNET_GETOPT_option_flag ('r', 160 GNUNET_GETOPT_option_flag ('r',
155 "reset", 161 "reset",
156 gettext_noop ( 162 gettext_noop (
@@ -163,13 +169,18 @@ main (int argc, char *const *argv)
163 gettext_noop ( 169 gettext_noop (
164 "the namestore plugin to work with, e.g. 'sqlite'"), 170 "the namestore plugin to work with, e.g. 'sqlite'"),
165 &pluginname), 171 &pluginname),
166 GNUNET_GETOPT_OPTION_END }; 172 GNUNET_GETOPT_OPTION_END
173 };
167 int lret; 174 int lret;
168 175
169 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 176 if (GNUNET_OK !=
177 GNUNET_STRINGS_get_utf8_args (argc, argv,
178 &argc, &argv))
170 return 2; 179 return 2;
171 180
172 GNUNET_log_setup ("gnunet-namestore-dbtool", "WARNING", NULL); 181 GNUNET_log_setup ("gnunet-namestore-dbtool",
182 "WARNING",
183 NULL);
173 if (GNUNET_OK != 184 if (GNUNET_OK !=
174 (lret = GNUNET_PROGRAM_run (argc, 185 (lret = GNUNET_PROGRAM_run (argc,
175 argv, 186 argv,
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 6444d446d..7288db902 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -27,11 +27,11 @@
27 */ 27 */
28#include "platform.h" 28#include "platform.h"
29#include <gnunet_util_lib.h> 29#include <gnunet_util_lib.h>
30#include <gnunet_dnsparser_lib.h>
31#include <gnunet_identity_service.h> 30#include <gnunet_identity_service.h>
32#include <gnunet_gnsrecord_lib.h> 31#include <gnunet_gnsrecord_lib.h>
33#include <gnunet_gns_service.h> 32#include <gnunet_gns_service.h>
34#include <gnunet_namestore_service.h> 33#include <gnunet_namestore_service.h>
34#include <inttypes.h>
35 35
36/** 36/**
37 * The upper bound for the zone iteration interval 37 * The upper bound for the zone iteration interval
@@ -119,11 +119,6 @@ static struct GNUNET_NAMESTORE_Handle *ns;
119static struct GNUNET_IDENTITY_PrivateKey zone_pkey; 119static struct GNUNET_IDENTITY_PrivateKey zone_pkey;
120 120
121/** 121/**
122 * Handle to identity lookup.
123 */
124static struct GNUNET_IDENTITY_EgoLookup *el;
125
126/**
127 * Identity service handle 122 * Identity service handle
128 */ 123 */
129static struct GNUNET_IDENTITY_Handle *idh; 124static struct GNUNET_IDENTITY_Handle *idh;
@@ -134,11 +129,6 @@ static struct GNUNET_IDENTITY_Handle *idh;
134static char *ego_name; 129static char *ego_name;
135 130
136/** 131/**
137 * Desired action is to add a record.
138 */
139static int add;
140
141/**
142 * Queue entry for the 'add-uri' operation. 132 * Queue entry for the 'add-uri' operation.
143 */ 133 */
144static struct GNUNET_NAMESTORE_QueueEntry *add_qe_uri; 134static struct GNUNET_NAMESTORE_QueueEntry *add_qe_uri;
@@ -168,6 +158,10 @@ static struct MarkedRecord *marked_head;
168 */ 158 */
169static struct MarkedRecord *marked_tail; 159static struct MarkedRecord *marked_tail;
170 160
161/**
162 * Configuration handle
163 */
164const struct GNUNET_CONFIGURATION_Handle *cfg;
171 165
172/** 166/**
173 * Ego list 167 * Ego list
@@ -180,14 +174,24 @@ static struct EgoEntry *ego_head;
180static struct EgoEntry *ego_tail; 174static struct EgoEntry *ego_tail;
181 175
182/** 176/**
177 * List iterator for the 'list' operation.
178 */
179static struct GNUNET_NAMESTORE_ZoneIterator *list_it;
180
181/**
182 * Run in read from stdin mode.
183 */
184static int read_from_stdin;
185
186/**
183 * Desired action is to list records. 187 * Desired action is to list records.
184 */ 188 */
185static int list; 189static int list;
186 190
187/** 191/**
188 * List iterator for the 'list' operation. 192 * Desired action is to add a record.
189 */ 193 */
190static struct GNUNET_NAMESTORE_ZoneIterator *list_it; 194static int add;
191 195
192/** 196/**
193 * Desired action is to remove a record. 197 * Desired action is to remove a record.
@@ -200,7 +204,7 @@ static int del;
200static int is_public; 204static int is_public;
201 205
202/** 206/**
203 * Is record a shadow record (#GNUNET_GNSRECORD_RF_SHADOW_RECORD) 207 * Is record a shadow record (#GNUNET_GNSRECORD_RF_SHADOW)
204 */ 208 */
205static int is_shadow; 209static int is_shadow;
206 210
@@ -210,6 +214,12 @@ static int is_shadow;
210static int omit_private; 214static int omit_private;
211 215
212/** 216/**
217 * Output in recordline format
218 */
219static int output_recordline;
220
221
222/**
213 * Purge zone contents 223 * Purge zone contents
214 */ 224 */
215static int purge_zone; 225static int purge_zone;
@@ -240,6 +250,11 @@ static struct GNUNET_NAMESTORE_QueueEntry *del_qe;
240static struct GNUNET_NAMESTORE_QueueEntry *set_qe; 250static struct GNUNET_NAMESTORE_QueueEntry *set_qe;
241 251
242/** 252/**
253 * Queue entry for begin/commit
254 */
255static struct GNUNET_NAMESTORE_QueueEntry *ns_qe;
256
257/**
243 * Name of the records to add/list/remove. 258 * Name of the records to add/list/remove.
244 */ 259 */
245static char *name; 260static char *name;
@@ -325,37 +340,186 @@ static struct RecordSetEntry *recordset;
325static struct GNUNET_SCHEDULER_Task *purge_task; 340static struct GNUNET_SCHEDULER_Task *purge_task;
326 341
327/** 342/**
328 * Task run on shutdown. Cleans up everything. 343 * Parse expiration time.
329 * 344 *
330 * @param cls unused 345 * @param expirationstring text to parse
346 * @param[out] etime_is_rel set to #GNUNET_YES if time is relative
347 * @param[out] etime set to expiration time (abs or rel)
348 * @return #GNUNET_OK on success
331 */ 349 */
350static int
351parse_expiration (const char *expirationstring,
352 int *etime_is_rel,
353 uint64_t *etime)
354{
355 struct GNUNET_TIME_Relative etime_rel;
356 struct GNUNET_TIME_Absolute etime_abs;
357
358 if (0 == strcmp (expirationstring, "never"))
359 {
360 *etime = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
361 *etime_is_rel = GNUNET_NO;
362 return GNUNET_OK;
363 }
364 if (GNUNET_OK ==
365 GNUNET_STRINGS_fancy_time_to_relative (expirationstring, &etime_rel))
366 {
367 *etime_is_rel = GNUNET_YES;
368 *etime = etime_rel.rel_value_us;
369 if (GNUNET_TIME_relative_cmp (etime_rel, <, WARN_RELATIVE_EXPIRATION_LIMIT))
370 {
371 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
372 "Relative expiration times of less than %s are not recommended. To improve availability, consider increasing this value.\n",
373 GNUNET_STRINGS_relative_time_to_string (
374 WARN_RELATIVE_EXPIRATION_LIMIT, GNUNET_NO));
375 }
376 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
377 "Storing record with relative expiration time of %s\n",
378 GNUNET_STRINGS_relative_time_to_string (etime_rel, GNUNET_NO));
379 return GNUNET_OK;
380 }
381 if (GNUNET_OK ==
382 GNUNET_STRINGS_fancy_time_to_absolute (expirationstring, &etime_abs))
383 {
384 *etime_is_rel = GNUNET_NO;
385 *etime = etime_abs.abs_value_us;
386 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
387 "Storing record with absolute expiration time of %s\n",
388 GNUNET_STRINGS_absolute_time_to_string (etime_abs));
389 return GNUNET_OK;
390 }
391 return GNUNET_SYSERR;
392}
393
394
395static int
396parse_recordline (const char *line)
397{
398 struct RecordSetEntry **head = &recordset;
399 struct RecordSetEntry *r;
400 struct GNUNET_GNSRECORD_Data record;
401 char *cp;
402 char *tok;
403 char *saveptr;
404 void *raw_data;
405
406 cp = GNUNET_strdup (line);
407 tok = strtok_r (cp, " ", &saveptr);
408 if (NULL == tok)
409 {
410 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
411 _ ("Missing entries in record line `%s'.\n"),
412 line);
413 GNUNET_free (cp);
414 return GNUNET_SYSERR;
415 }
416 record.record_type = GNUNET_GNSRECORD_typename_to_number (tok);
417 if (UINT32_MAX == record.record_type)
418 {
419 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Unknown record type `%s'\n"), tok);
420 GNUNET_free (cp);
421 return GNUNET_SYSERR;
422 }
423 tok = strtok_r (NULL, " ", &saveptr);
424 if (NULL == tok)
425 {
426 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
427 _ ("Empty record line argument is not allowed.\n"));
428 GNUNET_free (cp);
429 return GNUNET_SYSERR;
430 }
431 if (1 != sscanf (tok, "%" SCNu64, &record.expiration_time))
432 {
433 fprintf (stderr,
434 _ ("Error parsing expiration time %s.\n"), tok);
435 GNUNET_free (cp);
436 return GNUNET_SYSERR;
437 }
438 tok = strtok_r (NULL, " ", &saveptr);
439 if (NULL == tok)
440 {
441 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
442 _ ("Empty record line argument is not allowed.\n"));
443 GNUNET_free (cp);
444 return GNUNET_SYSERR;
445 }
446 record.flags = GNUNET_GNSRECORD_RF_NONE;
447 if (NULL != strchr (tok, (unsigned char) 'r'))
448 record.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
449 if (NULL == strchr (tok, (unsigned char) 'p')) /* p = public */
450 record.flags |= GNUNET_GNSRECORD_RF_PRIVATE;
451 if (NULL != strchr (tok, (unsigned char) 'S'))
452 record.flags |= GNUNET_GNSRECORD_RF_SUPPLEMENTAL;
453 if (NULL != strchr (tok, (unsigned char) 's'))
454 record.flags |= GNUNET_GNSRECORD_RF_SHADOW;
455 if (NULL != strchr (tok, (unsigned char) 'C'))
456 record.flags |= GNUNET_GNSRECORD_RF_CRITICAL;
457 tok += strlen (tok) + 1;
458 if (GNUNET_OK != GNUNET_GNSRECORD_string_to_value (record.record_type,
459 tok,
460 &raw_data,
461 &record.data_size))
462 {
463 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
464 _ ("Invalid record data for type %s: `%s'.\n"),
465 GNUNET_GNSRECORD_number_to_typename (record.record_type),
466 tok);
467 return GNUNET_SYSERR;
468 }
469
470 r = GNUNET_malloc (sizeof(struct RecordSetEntry) + record.data_size);
471 r->next = *head;
472 record.data = &r[1];
473 memcpy (&r[1], raw_data, record.data_size);
474 GNUNET_free (raw_data);
475 r->record = record;
476 *head = r;
477 return GNUNET_OK;
478}
479
332static void 480static void
333do_shutdown (void *cls) 481reset_handles (void)
334{ 482{
335 struct EgoEntry *ego_entry;
336 struct EgoEntry *ego_tmp;
337 struct MarkedRecord *mrec; 483 struct MarkedRecord *mrec;
338 struct MarkedRecord *mrec_tmp; 484 struct MarkedRecord *mrec_tmp;
339 (void) cls; 485 struct RecordSetEntry *rs_entry;
486
487 rs_entry = recordset;
488 while (NULL != (rs_entry = recordset))
489 {
490 recordset = recordset->next;
491 GNUNET_free (rs_entry);
492 }
493 recordset = NULL;
340 if (NULL != ego_name) 494 if (NULL != ego_name)
341 { 495 {
342 GNUNET_free (ego_name); 496 GNUNET_free (ego_name);
343 ego_name = NULL; 497 ego_name = NULL;
344 } 498 }
345 if (NULL != purge_task) 499 if (NULL != name)
346 { 500 {
347 GNUNET_SCHEDULER_cancel (purge_task); 501 GNUNET_free (name);
348 purge_task = NULL; 502 name = NULL;
349 } 503 }
350 if (NULL != idh) 504 if (NULL != value)
351 { 505 {
352 GNUNET_IDENTITY_disconnect (idh); 506 GNUNET_free (value);
353 idh = NULL; 507 value = NULL;
508 }
509 if (NULL != uri)
510 {
511 GNUNET_free (uri);
512 uri = NULL;
513 }
514 if (NULL != expirationstring)
515 {
516 GNUNET_free (expirationstring);
517 expirationstring = NULL;
354 } 518 }
355 if (NULL != el) 519 if (NULL != purge_task)
356 { 520 {
357 GNUNET_IDENTITY_ego_lookup_cancel (el); 521 GNUNET_SCHEDULER_cancel (purge_task);
358 el = NULL; 522 purge_task = NULL;
359 } 523 }
360 for (mrec = marked_head; NULL != mrec;) 524 for (mrec = marked_head; NULL != mrec;)
361 { 525 {
@@ -364,13 +528,6 @@ do_shutdown (void *cls)
364 GNUNET_free (mrec_tmp->name); 528 GNUNET_free (mrec_tmp->name);
365 GNUNET_free (mrec_tmp); 529 GNUNET_free (mrec_tmp);
366 } 530 }
367 for (ego_entry = ego_head; NULL != ego_entry;)
368 {
369 ego_tmp = ego_entry;
370 ego_entry = ego_entry->next;
371 GNUNET_free (ego_tmp->identifier);
372 GNUNET_free (ego_tmp);
373 }
374 if (NULL != list_it) 531 if (NULL != list_it)
375 { 532 {
376 GNUNET_NAMESTORE_zone_iteration_stop (list_it); 533 GNUNET_NAMESTORE_zone_iteration_stop (list_it);
@@ -401,17 +558,12 @@ do_shutdown (void *cls)
401 GNUNET_NAMESTORE_cancel (del_qe); 558 GNUNET_NAMESTORE_cancel (del_qe);
402 del_qe = NULL; 559 del_qe = NULL;
403 } 560 }
404 if (NULL != ns) 561 if (NULL != reverse_qe)
405 { 562 {
406 GNUNET_NAMESTORE_disconnect (ns); 563 GNUNET_NAMESTORE_cancel (reverse_qe);
407 ns = NULL; 564 reverse_qe = NULL;
408 } 565 }
409 memset (&zone_pkey, 0, sizeof(zone_pkey)); 566 memset (&zone_pkey, 0, sizeof(zone_pkey));
410 if (NULL != uri)
411 {
412 GNUNET_free (uri);
413 uri = NULL;
414 }
415 if (NULL != zm) 567 if (NULL != zm)
416 { 568 {
417 GNUNET_NAMESTORE_zone_monitor_stop (zm); 569 GNUNET_NAMESTORE_zone_monitor_stop (zm);
@@ -422,18 +574,83 @@ do_shutdown (void *cls)
422 GNUNET_free (data); 574 GNUNET_free (data);
423 data = NULL; 575 data = NULL;
424 } 576 }
577 if (NULL != typestring)
578 {
579 GNUNET_free (typestring);
580 typestring = NULL;
581 }
582 list = 0;
583 is_public = 0;
584 is_shadow = 0;
585 purge_zone = 0;
425} 586}
426 587
427 588
589
428/** 590/**
429 * Check if we are finished, and if so, perform shutdown. 591 * Task run on shutdown. Cleans up everything.
592 *
593 * @param cls unused
430 */ 594 */
431static void 595static void
432test_finished () 596do_shutdown (void *cls)
433{ 597{
434 if ((NULL == add_qe) && (NULL == add_qe_uri) && (NULL == get_qe) && 598 struct EgoEntry *ego_entry;
435 (NULL == del_qe) && (NULL == reverse_qe) && (NULL == list_it)) 599 struct EgoEntry *ego_tmp;
436 GNUNET_SCHEDULER_shutdown (); 600 (void) cls;
601
602 reset_handles ();
603 if (NULL != ns_qe)
604 {
605 GNUNET_NAMESTORE_cancel (ns_qe);
606 ns_qe = NULL;
607 }
608 if (NULL != ns)
609 {
610 GNUNET_NAMESTORE_disconnect (ns);
611 ns = NULL;
612 }
613 if (NULL != idh)
614 {
615 GNUNET_IDENTITY_disconnect (idh);
616 idh = NULL;
617 }
618 for (ego_entry = ego_head; NULL != ego_entry;)
619 {
620 ego_tmp = ego_entry;
621 ego_entry = ego_entry->next;
622 GNUNET_free (ego_tmp->identifier);
623 GNUNET_free (ego_tmp);
624 }
625}
626
627static void
628commit_cb (void *cls, enum GNUNET_ErrorCode ec)
629{
630 ns_qe = NULL;
631 if (GNUNET_EC_NONE != ec)
632 {
633 fprintf (stderr, "Failed to commit to namestore: `%s'\n",
634 GNUNET_ErrorCode_get_hint (ec));
635 ret = 1;
636 }
637 GNUNET_SCHEDULER_shutdown ();
638}
639
640static void
641process_command_stdin ();
642
643
644static void
645finish_command (void)
646{
647 reset_handles ();
648 if (read_from_stdin)
649 {
650 process_command_stdin ();
651 return;
652 }
653 ns_qe = GNUNET_NAMESTORE_transaction_commit (ns, &commit_cb, NULL);
437} 654}
438 655
439 656
@@ -452,7 +669,7 @@ add_continuation (void *cls, enum GNUNET_ErrorCode ec)
452 ret = 1; 669 ret = 1;
453 } 670 }
454 ret = 0; 671 ret = 0;
455 test_finished (); 672 finish_command ();
456} 673}
457 674
458 675
@@ -467,7 +684,7 @@ del_continuation (void *cls, enum GNUNET_ErrorCode ec)
467 _ ("Deleting record failed: %s\n"), GNUNET_ErrorCode_get_hint ( 684 _ ("Deleting record failed: %s\n"), GNUNET_ErrorCode_get_hint (
468 ec)); 685 ec));
469 } 686 }
470 test_finished (); 687 finish_command ();
471} 688}
472 689
473static void 690static void
@@ -496,7 +713,7 @@ purge_next_record (void *cls)
496 if (NULL == marked_head) 713 if (NULL == marked_head)
497 { 714 {
498 ret = 0; 715 ret = 0;
499 test_finished (); 716 finish_command ();
500 return; 717 return;
501 } 718 }
502 mrec = marked_head; 719 mrec = marked_head;
@@ -527,7 +744,7 @@ zone_iteration_finished (void *cls)
527 return; 744 return;
528 } 745 }
529 ret = 0; 746 ret = 0;
530 test_finished (); 747 finish_command ();
531} 748}
532 749
533 750
@@ -541,7 +758,7 @@ zone_iteration_error_cb (void *cls)
541 list_it = NULL; 758 list_it = NULL;
542 fprintf (stderr, "Error iterating over zone\n"); 759 fprintf (stderr, "Error iterating over zone\n");
543 ret = 1; 760 ret = 1;
544 test_finished (); 761 finish_command ();
545} 762}
546 763
547static void 764static void
@@ -681,18 +898,33 @@ display_record (const struct GNUNET_IDENTITY_PrivateKey *zone_key,
681 at.abs_value_us = rd[i].expiration_time; 898 at.abs_value_us = rd[i].expiration_time;
682 ets = GNUNET_STRINGS_absolute_time_to_string (at); 899 ets = GNUNET_STRINGS_absolute_time_to_string (at);
683 } 900 }
684 fprintf (stdout, 901 char flgstr[16];
685 "\t%s: %s (%s)\t%s\t%s\n", 902 sprintf (flgstr, "[%s%s%s%s%s]",
686 typestr, 903 (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE) ? "" : "p",
687 s, 904 (rd[i].flags & GNUNET_GNSRECORD_RF_SUPPLEMENTAL) ? "S" : "",
688 ets, 905 (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION) ? "r" : "",
689 (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) ? "PRIVATE" 906 (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW) ? "S" : "",
907 (rd[i].flags & GNUNET_GNSRECORD_RF_CRITICAL) ? "C" : "");
908 if (output_recordline)
909 fprintf (stdout,
910 " %s %" PRIu64 " %s %s\n",
911 typestr,
912 rd[i].expiration_time,
913 flgstr,
914 s);
915 else
916 fprintf (stdout,
917 "\t%s: %s (%s)\t%s\t%s\n",
918 typestr,
919 s,
920 ets,
921 (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) ? "PRIVATE"
690 : "PUBLIC", 922 : "PUBLIC",
691 (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) ? "SHADOW" 923 (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW)) ? "SHADOW"
692 : ""); 924 : "");
693 GNUNET_free (s); 925 GNUNET_free (s);
694 } 926 }
695 fprintf (stdout, "%s", "\n"); 927 // fprintf (stdout, "%s", "\n");
696} 928}
697 929
698static void 930static void
@@ -797,7 +1029,7 @@ display_record_lookup (void *cls,
797 (void) zone_key; 1029 (void) zone_key;
798 get_qe = NULL; 1030 get_qe = NULL;
799 display_record (zone_key, rname, rd_len, rd); 1031 display_record (zone_key, rname, rd_len, rd);
800 test_finished (); 1032 finish_command ();
801} 1033}
802 1034
803 1035
@@ -838,7 +1070,7 @@ lookup_error_cb (void *cls)
838 (void) cls; 1070 (void) cls;
839 get_qe = NULL; 1071 get_qe = NULL;
840 fprintf (stderr, "%s", "Failed to lookup record.\n"); 1072 fprintf (stderr, "%s", "Failed to lookup record.\n");
841 test_finished (); 1073 finish_command ();
842} 1074}
843 1075
844 1076
@@ -852,7 +1084,7 @@ add_error_cb (void *cls)
852 add_qe = NULL; 1084 add_qe = NULL;
853 GNUNET_break (0); 1085 GNUNET_break (0);
854 ret = 1; 1086 ret = 1;
855 test_finished (); 1087 finish_command ();
856} 1088}
857 1089
858 1090
@@ -883,7 +1115,7 @@ get_existing_record (void *cls,
883 { 1115 {
884 GNUNET_break (0); 1116 GNUNET_break (0);
885 ret = 1; 1117 ret = 1;
886 test_finished (); 1118 finish_command ();
887 return; 1119 return;
888 } 1120 }
889 1121
@@ -904,7 +1136,7 @@ get_existing_record (void *cls,
904 "A SOA record exists already under `%s', cannot add a second SOA to the same zone.\n"), 1136 "A SOA record exists already under `%s', cannot add a second SOA to the same zone.\n"),
905 rec_name); 1137 rec_name);
906 ret = 1; 1138 ret = 1;
907 test_finished (); 1139 finish_command ();
908 return; 1140 return;
909 } 1141 }
910 break; 1142 break;
@@ -917,7 +1149,7 @@ get_existing_record (void *cls,
917 rde->data_size = data_size; 1149 rde->data_size = data_size;
918 rde->record_type = type; 1150 rde->record_type = type;
919 if (1 == is_shadow) 1151 if (1 == is_shadow)
920 rde->flags |= GNUNET_GNSRECORD_RF_SHADOW_RECORD; 1152 rde->flags |= GNUNET_GNSRECORD_RF_SHADOW;
921 if (1 != is_public) 1153 if (1 != is_public)
922 rde->flags |= GNUNET_GNSRECORD_RF_PRIVATE; 1154 rde->flags |= GNUNET_GNSRECORD_RF_PRIVATE;
923 rde->expiration_time = etime; 1155 rde->expiration_time = etime;
@@ -974,7 +1206,7 @@ handle_reverse_lookup (void *cls,
974 fprintf (stdout, "%s\n", reverse_pkey); 1206 fprintf (stdout, "%s\n", reverse_pkey);
975 else 1207 else
976 fprintf (stdout, "%s.%s\n", label, ego_name); 1208 fprintf (stdout, "%s.%s\n", label, ego_name);
977 test_finished (); 1209 finish_command ();
978} 1210}
979 1211
980 1212
@@ -988,7 +1220,7 @@ del_lookup_error_cb (void *cls)
988 del_qe = NULL; 1220 del_qe = NULL;
989 GNUNET_break (0); 1221 GNUNET_break (0);
990 ret = 1; 1222 ret = 1;
991 test_finished (); 1223 finish_command ();
992} 1224}
993 1225
994 1226
@@ -1025,7 +1257,7 @@ del_monitor (void *cls,
1025 "There are no records under label `%s' that could be deleted.\n"), 1257 "There are no records under label `%s' that could be deleted.\n"),
1026 label); 1258 label);
1027 ret = 1; 1259 ret = 1;
1028 test_finished (); 1260 finish_command ();
1029 return; 1261 return;
1030 } 1262 }
1031 if ((NULL == value) && (NULL == typestring)) 1263 if ((NULL == value) && (NULL == typestring))
@@ -1067,7 +1299,7 @@ del_monitor (void *cls,
1067 _ ( 1299 _ (
1068 "There are no records under label `%s' that match the request for deletion.\n"), 1300 "There are no records under label `%s' that match the request for deletion.\n"),
1069 label); 1301 label);
1070 test_finished (); 1302 finish_command ();
1071 return; 1303 return;
1072 } 1304 }
1073 /* delete everything but what we copied to 'rdx' */ 1305 /* delete everything but what we copied to 'rdx' */
@@ -1081,59 +1313,6 @@ del_monitor (void *cls,
1081} 1313}
1082 1314
1083 1315
1084/**
1085 * Parse expiration time.
1086 *
1087 * @param expirationstring text to parse
1088 * @param[out] etime_is_rel set to #GNUNET_YES if time is relative
1089 * @param[out] etime set to expiration time (abs or rel)
1090 * @return #GNUNET_OK on success
1091 */
1092static int
1093parse_expiration (const char *expirationstring,
1094 int *etime_is_rel,
1095 uint64_t *etime)
1096{
1097 struct GNUNET_TIME_Relative etime_rel;
1098 struct GNUNET_TIME_Absolute etime_abs;
1099
1100 if (0 == strcmp (expirationstring, "never"))
1101 {
1102 *etime = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
1103 *etime_is_rel = GNUNET_NO;
1104 return GNUNET_OK;
1105 }
1106 if (GNUNET_OK ==
1107 GNUNET_STRINGS_fancy_time_to_relative (expirationstring, &etime_rel))
1108 {
1109 *etime_is_rel = GNUNET_YES;
1110 *etime = etime_rel.rel_value_us;
1111 if (GNUNET_TIME_relative_cmp (etime_rel, <, WARN_RELATIVE_EXPIRATION_LIMIT))
1112 {
1113 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1114 "Relative expiration times of less than %s are not recommended. To improve availability, consider increasing this value.\n",
1115 GNUNET_STRINGS_relative_time_to_string (
1116 WARN_RELATIVE_EXPIRATION_LIMIT, GNUNET_NO));
1117 }
1118 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1119 "Storing record with relative expiration time of %s\n",
1120 GNUNET_STRINGS_relative_time_to_string (etime_rel, GNUNET_NO));
1121 return GNUNET_OK;
1122 }
1123 if (GNUNET_OK ==
1124 GNUNET_STRINGS_fancy_time_to_absolute (expirationstring, &etime_abs))
1125 {
1126 *etime_is_rel = GNUNET_NO;
1127 *etime = etime_abs.abs_value_us;
1128 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1129 "Storing record with absolute expiration time of %s\n",
1130 GNUNET_STRINGS_absolute_time_to_string (etime_abs));
1131 return GNUNET_OK;
1132 }
1133 return GNUNET_SYSERR;
1134}
1135
1136
1137static void 1316static void
1138replace_cont (void *cls, enum GNUNET_ErrorCode ec) 1317replace_cont (void *cls, enum GNUNET_ErrorCode ec)
1139{ 1318{
@@ -1147,7 +1326,7 @@ replace_cont (void *cls, enum GNUNET_ErrorCode ec)
1147 GNUNET_ErrorCode_get_hint (ec)); 1326 GNUNET_ErrorCode_get_hint (ec));
1148 ret = 1; /* fail from 'main' */ 1327 ret = 1; /* fail from 'main' */
1149 } 1328 }
1150 GNUNET_SCHEDULER_shutdown (); 1329 finish_command ();
1151} 1330}
1152 1331
1153 1332
@@ -1173,14 +1352,7 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1173 { 1352 {
1174 /* nothing more to be done */ 1353 /* nothing more to be done */
1175 fprintf (stderr, _ ("No options given\n")); 1354 fprintf (stderr, _ ("No options given\n"));
1176 GNUNET_SCHEDULER_shutdown (); 1355 finish_command ();
1177 return;
1178 }
1179 ns = GNUNET_NAMESTORE_connect (cfg);
1180 if (NULL == ns)
1181 {
1182 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1183 _ ("Failed to connect to namestore\n"));
1184 return; 1356 return;
1185 } 1357 }
1186 1358
@@ -1190,24 +1362,23 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1190 unsigned int rd_count; 1362 unsigned int rd_count;
1191 struct GNUNET_GNSRECORD_Data *rd; 1363 struct GNUNET_GNSRECORD_Data *rd;
1192 1364
1193 if (NULL == ego_name) 1365 /* FIXME: We could easily support append and delete with this as well */
1366 if (! add)
1194 { 1367 {
1195 fprintf (stderr, 1368 fprintf (stderr, _ ("Recordlines only work with option `%s'\n"),
1196 _ ("Missing option `%s' for operation `%s'\n"), 1369 "-a");
1197 "-z",
1198 _ ("replace"));
1199 GNUNET_SCHEDULER_shutdown ();
1200 ret = 1; 1370 ret = 1;
1371 finish_command ();
1201 return; 1372 return;
1202 } 1373 }
1203 if (NULL == name) 1374 if (NULL == name)
1204 { 1375 {
1205 fprintf (stderr, 1376 fprintf (stderr,
1206 _ ("Missing option `%s' for operation `%s'\n"), 1377 _ ("Missing option `%s' for operation `%s'\n"),
1207 "-R", 1378 "-n",
1208 _ ("replace")); 1379 _ ("name"));
1209 GNUNET_SCHEDULER_shutdown ();
1210 ret = 1; 1380 ret = 1;
1381 finish_command ();
1211 return; 1382 return;
1212 } 1383 }
1213 rd_count = 0; 1384 rd_count = 0;
@@ -1235,8 +1406,8 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1235 if (0 == strlen (nickstring)) 1406 if (0 == strlen (nickstring))
1236 { 1407 {
1237 fprintf (stderr, _ ("Invalid nick `%s'\n"), nickstring); 1408 fprintf (stderr, _ ("Invalid nick `%s'\n"), nickstring);
1238 GNUNET_SCHEDULER_shutdown ();
1239 ret = 1; 1409 ret = 1;
1410 finish_command ();
1240 return; 1411 return;
1241 } 1412 }
1242 add = 1; 1413 add = 1;
@@ -1258,8 +1429,8 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1258 _ ("Missing option `%s' for operation `%s'\n"), 1429 _ ("Missing option `%s' for operation `%s'\n"),
1259 "-z", 1430 "-z",
1260 _ ("add")); 1431 _ ("add"));
1261 GNUNET_SCHEDULER_shutdown ();
1262 ret = 1; 1432 ret = 1;
1433 finish_command ();
1263 return; 1434 return;
1264 } 1435 }
1265 if (NULL == name) 1436 if (NULL == name)
@@ -1268,8 +1439,8 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1268 _ ("Missing option `%s' for operation `%s'\n"), 1439 _ ("Missing option `%s' for operation `%s'\n"),
1269 "-n", 1440 "-n",
1270 _ ("add")); 1441 _ ("add"));
1271 GNUNET_SCHEDULER_shutdown ();
1272 ret = 1; 1442 ret = 1;
1443 finish_command ();
1273 return; 1444 return;
1274 } 1445 }
1275 if (NULL == typestring) 1446 if (NULL == typestring)
@@ -1278,16 +1449,16 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1278 _ ("Missing option `%s' for operation `%s'\n"), 1449 _ ("Missing option `%s' for operation `%s'\n"),
1279 "-t", 1450 "-t",
1280 _ ("add")); 1451 _ ("add"));
1281 GNUNET_SCHEDULER_shutdown ();
1282 ret = 1; 1452 ret = 1;
1453 finish_command ();
1283 return; 1454 return;
1284 } 1455 }
1285 type = GNUNET_GNSRECORD_typename_to_number (typestring); 1456 type = GNUNET_GNSRECORD_typename_to_number (typestring);
1286 if (UINT32_MAX == type) 1457 if (UINT32_MAX == type)
1287 { 1458 {
1288 fprintf (stderr, _ ("Unsupported type `%s'\n"), typestring); 1459 fprintf (stderr, _ ("Unsupported type `%s'\n"), typestring);
1289 GNUNET_SCHEDULER_shutdown ();
1290 ret = 1; 1460 ret = 1;
1461 finish_command ();
1291 return; 1462 return;
1292 } 1463 }
1293 if ((GNUNET_DNSPARSER_TYPE_SRV == type) || 1464 if ((GNUNET_DNSPARSER_TYPE_SRV == type) ||
@@ -1297,8 +1468,8 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1297 fprintf (stderr, 1468 fprintf (stderr,
1298 _ ("For DNS record types `SRV', `TLSA' and `OPENPGPKEY'")); 1469 _ ("For DNS record types `SRV', `TLSA' and `OPENPGPKEY'"));
1299 fprintf (stderr, ", please use a `BOX' record instead\n"); 1470 fprintf (stderr, ", please use a `BOX' record instead\n");
1300 GNUNET_SCHEDULER_shutdown ();
1301 ret = 1; 1471 ret = 1;
1472 finish_command ();
1302 return; 1473 return;
1303 } 1474 }
1304 if (NULL == value) 1475 if (NULL == value)
@@ -1308,7 +1479,7 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1308 "-V", 1479 "-V",
1309 _ ("add")); 1480 _ ("add"));
1310 ret = 1; 1481 ret = 1;
1311 GNUNET_SCHEDULER_shutdown (); 1482 finish_command ();
1312 return; 1483 return;
1313 } 1484 }
1314 if (GNUNET_OK != 1485 if (GNUNET_OK !=
@@ -1318,8 +1489,8 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1318 _ ("Value `%s' invalid for record type `%s'\n"), 1489 _ ("Value `%s' invalid for record type `%s'\n"),
1319 value, 1490 value,
1320 typestring); 1491 typestring);
1321 GNUNET_SCHEDULER_shutdown ();
1322 ret = 1; 1492 ret = 1;
1493 finish_command ();
1323 return; 1494 return;
1324 } 1495 }
1325 if (NULL == expirationstring) 1496 if (NULL == expirationstring)
@@ -1328,15 +1499,15 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1328 _ ("Missing option `%s' for operation `%s'\n"), 1499 _ ("Missing option `%s' for operation `%s'\n"),
1329 "-e", 1500 "-e",
1330 _ ("add")); 1501 _ ("add"));
1331 GNUNET_SCHEDULER_shutdown ();
1332 ret = 1; 1502 ret = 1;
1503 finish_command ();
1333 return; 1504 return;
1334 } 1505 }
1335 if (GNUNET_OK != parse_expiration (expirationstring, &etime_is_rel, &etime)) 1506 if (GNUNET_OK != parse_expiration (expirationstring, &etime_is_rel, &etime))
1336 { 1507 {
1337 fprintf (stderr, _ ("Invalid time format `%s'\n"), expirationstring); 1508 fprintf (stderr, _ ("Invalid time format `%s'\n"), expirationstring);
1338 GNUNET_SCHEDULER_shutdown ();
1339 ret = 1; 1509 ret = 1;
1510 finish_command ();
1340 return; 1511 return;
1341 } 1512 }
1342 add_qe = GNUNET_NAMESTORE_records_lookup (ns, 1513 add_qe = GNUNET_NAMESTORE_records_lookup (ns,
@@ -1355,8 +1526,8 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1355 _ ("Missing option `%s' for operation `%s'\n"), 1526 _ ("Missing option `%s' for operation `%s'\n"),
1356 "-z", 1527 "-z",
1357 _ ("del")); 1528 _ ("del"));
1358 GNUNET_SCHEDULER_shutdown ();
1359 ret = 1; 1529 ret = 1;
1530 finish_command ();
1360 return; 1531 return;
1361 } 1532 }
1362 if (NULL == name) 1533 if (NULL == name)
@@ -1365,8 +1536,8 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1365 _ ("Missing option `%s' for operation `%s'\n"), 1536 _ ("Missing option `%s' for operation `%s'\n"),
1366 "-n", 1537 "-n",
1367 _ ("del")); 1538 _ ("del"));
1368 GNUNET_SCHEDULER_shutdown ();
1369 ret = 1; 1539 ret = 1;
1540 finish_command ();
1370 return; 1541 return;
1371 } 1542 }
1372 del_qe = GNUNET_NAMESTORE_records_lookup (ns, 1543 del_qe = GNUNET_NAMESTORE_records_lookup (ns,
@@ -1398,8 +1569,8 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1398 _ ("Missing option `%s' for operation `%s'\n"), 1569 _ ("Missing option `%s' for operation `%s'\n"),
1399 "-z", 1570 "-z",
1400 _ ("purge-zone")); 1571 _ ("purge-zone"));
1401 GNUNET_SCHEDULER_shutdown ();
1402 ret = 1; 1572 ret = 1;
1573 finish_command ();
1403 return; 1574 return;
1404 } 1575 }
1405 list_it = GNUNET_NAMESTORE_zone_iteration_start2 (ns, 1576 list_it = GNUNET_NAMESTORE_zone_iteration_start2 (ns,
@@ -1423,8 +1594,8 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1423 _ ("Missing option `%s' for operation `%s'\n"), 1594 _ ("Missing option `%s' for operation `%s'\n"),
1424 "-z", 1595 "-z",
1425 _ ("list")); 1596 _ ("list"));
1426 GNUNET_SCHEDULER_shutdown ();
1427 ret = 1; 1597 ret = 1;
1598 finish_command ();
1428 return; 1599 return;
1429 } 1600 }
1430 get_qe = GNUNET_NAMESTORE_records_lookup (ns, 1601 get_qe = GNUNET_NAMESTORE_records_lookup (ns,
@@ -1457,8 +1628,8 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1457 _ ("Missing option `%s' for operation `%s'\n"), 1628 _ ("Missing option `%s' for operation `%s'\n"),
1458 "-z", 1629 "-z",
1459 _ ("reverse-pkey")); 1630 _ ("reverse-pkey"));
1460 GNUNET_SCHEDULER_shutdown ();
1461 ret = 1; 1631 ret = 1;
1632 finish_command ();
1462 return; 1633 return;
1463 } 1634 }
1464 if (GNUNET_OK != 1635 if (GNUNET_OK !=
@@ -1468,7 +1639,9 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1468 fprintf (stderr, 1639 fprintf (stderr,
1469 _ ("Invalid public key for reverse lookup `%s'\n"), 1640 _ ("Invalid public key for reverse lookup `%s'\n"),
1470 reverse_pkey); 1641 reverse_pkey);
1471 GNUNET_SCHEDULER_shutdown (); 1642 ret = 1;
1643 finish_command ();
1644 return;
1472 } 1645 }
1473 reverse_qe = GNUNET_NAMESTORE_zone_to_name (ns, 1646 reverse_qe = GNUNET_NAMESTORE_zone_to_name (ns,
1474 &zone_pkey, 1647 &zone_pkey,
@@ -1489,8 +1662,8 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1489 _ ("Missing option `%s' for operation `%s'\n"), 1662 _ ("Missing option `%s' for operation `%s'\n"),
1490 "-z", 1663 "-z",
1491 _ ("uri")); 1664 _ ("uri"));
1492 GNUNET_SCHEDULER_shutdown ();
1493 ret = 1; 1665 ret = 1;
1666 finish_command ();
1494 return; 1667 return;
1495 } 1668 }
1496 1669
@@ -1502,8 +1675,8 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1502 GNUNET_IDENTITY_public_key_from_string (sh, &pkey))) 1675 GNUNET_IDENTITY_public_key_from_string (sh, &pkey)))
1503 { 1676 {
1504 fprintf (stderr, _ ("Invalid URI `%s'\n"), uri); 1677 fprintf (stderr, _ ("Invalid URI `%s'\n"), uri);
1505 GNUNET_SCHEDULER_shutdown ();
1506 ret = 1; 1678 ret = 1;
1679 finish_command ();
1507 return; 1680 return;
1508 } 1681 }
1509 if (NULL == expirationstring) 1682 if (NULL == expirationstring)
@@ -1512,15 +1685,15 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1512 _ ("Missing option `%s' for operation `%s'\n"), 1685 _ ("Missing option `%s' for operation `%s'\n"),
1513 "-e", 1686 "-e",
1514 _ ("add")); 1687 _ ("add"));
1515 GNUNET_SCHEDULER_shutdown ();
1516 ret = 1; 1688 ret = 1;
1689 finish_command ();
1517 return; 1690 return;
1518 } 1691 }
1519 if (GNUNET_OK != parse_expiration (expirationstring, &etime_is_rel, &etime)) 1692 if (GNUNET_OK != parse_expiration (expirationstring, &etime_is_rel, &etime))
1520 { 1693 {
1521 fprintf (stderr, _ ("Invalid time format `%s'\n"), expirationstring); 1694 fprintf (stderr, _ ("Invalid time format `%s'\n"), expirationstring);
1522 GNUNET_SCHEDULER_shutdown ();
1523 ret = 1; 1695 ret = 1;
1696 finish_command ();
1524 return; 1697 return;
1525 } 1698 }
1526 memset (&rd, 0, sizeof(rd)); 1699 memset (&rd, 0, sizeof(rd));
@@ -1531,7 +1704,7 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1531 if (GNUNET_YES == etime_is_rel) 1704 if (GNUNET_YES == etime_is_rel)
1532 rd.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 1705 rd.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1533 if (1 == is_shadow) 1706 if (1 == is_shadow)
1534 rd.flags |= GNUNET_GNSRECORD_RF_SHADOW_RECORD; 1707 rd.flags |= GNUNET_GNSRECORD_RF_SHADOW;
1535 add_qe_uri = GNUNET_NAMESTORE_records_store (ns, 1708 add_qe_uri = GNUNET_NAMESTORE_records_store (ns,
1536 &zone_pkey, 1709 &zone_pkey,
1537 sname, 1710 sname,
@@ -1556,34 +1729,153 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
1556 } 1729 }
1557} 1730}
1558 1731
1732#define MAX_LINE_LEN 4086
1733
1734#define MAX_ARGS 20
1735
1736static int
1737get_identity_for_string (const char *str,
1738 struct GNUNET_IDENTITY_PrivateKey *zk)
1739{
1740 const struct GNUNET_IDENTITY_PrivateKey *privkey;
1741 struct GNUNET_IDENTITY_PublicKey pubkey;
1742 struct GNUNET_IDENTITY_PublicKey ego_pubkey;
1743 struct EgoEntry *ego_entry;
1744
1745 if (GNUNET_OK == GNUNET_IDENTITY_public_key_from_string (str,
1746 &pubkey))
1747 {
1748 for (ego_entry = ego_head;
1749 NULL != ego_entry; ego_entry = ego_entry->next)
1750 {
1751 privkey = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1752 GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &ego_pubkey);
1753 if (0 == memcmp (&ego_pubkey, &pubkey, sizeof (pubkey)))
1754 {
1755 *zk = *privkey;
1756 return GNUNET_OK;
1757 }
1758 }
1759 }
1760 else
1761 {
1762 for (ego_entry = ego_head; NULL != ego_entry; ego_entry = ego_entry->next)
1763 {
1764 /** FIXME: Check for zTLD? **/
1765 if (0 != strcmp (str, ego_entry->identifier))
1766 continue;
1767 *zk = *GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1768 return GNUNET_OK;
1769 }
1770 }
1771 return GNUNET_NO;
1772}
1559 1773
1560/**
1561 * Callback invoked from identity service with ego information.
1562 * An @a ego of NULL means the ego was not found.
1563 *
1564 * @param cls closure with the configuration
1565 * @param ego an ego known to identity service, or NULL
1566 */
1567static void 1774static void
1568identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego) 1775process_command_stdin ()
1569{ 1776{
1570 const struct GNUNET_CONFIGURATION_Handle *cfg = cls; 1777 char buf[MAX_LINE_LEN];
1778 static struct GNUNET_IDENTITY_PrivateKey next_zone_key;
1779 static char next_name[GNUNET_DNSPARSER_MAX_NAME_LENGTH];
1780 static int finished = GNUNET_NO;
1781 static int have_next_zonekey = GNUNET_NO;
1782 int zonekey_set = GNUNET_NO;
1783 char *tmp;
1571 1784
1572 el = NULL;
1573 1785
1574 if (NULL == ego) 1786 if (GNUNET_YES == have_next_zonekey)
1575 { 1787 {
1576 if (NULL != ego_name) 1788 zone_pkey = next_zone_key;
1789 if (NULL != name)
1790 GNUNET_free (name);
1791 name = GNUNET_strdup (next_name);
1792 zonekey_set = GNUNET_YES;
1793 }
1794 while (NULL != fgets (buf, sizeof (buf), stdin))
1795 {
1796 if (1 >= strlen (buf))
1797 continue;
1798 if (buf[strlen (buf) - 1] == '\n')
1799 buf[strlen (buf) - 1] = '\0';
1800 /**
1801 * Check if this is a new name. If yes, and we have records, store them.
1802 */
1803 if (buf[strlen (buf) - 1] == ':')
1577 { 1804 {
1578 fprintf (stderr, 1805 memset (next_name, 0, sizeof (next_name));
1579 _ ("Ego `%s' not known to identity service\n"), 1806 strncpy (next_name, buf, strlen (buf) - 1);
1580 ego_name); 1807 tmp = strchr (next_name, '.');
1808 if (NULL == tmp)
1809 {
1810 fprintf (stderr, "Error parsing name `%s'\n", next_name);
1811 ns_qe = GNUNET_NAMESTORE_transaction_commit (ns, &commit_cb, NULL);
1812 ret = 1;
1813 return;
1814 }
1815 if (GNUNET_OK != get_identity_for_string (tmp + 1, &next_zone_key))
1816 {
1817 fprintf (stderr, "Error parsing zone name `%s'\n", tmp + 1);
1818 ret = 1;
1819 GNUNET_SCHEDULER_shutdown ();
1820 return;
1821 }
1822 *tmp = '\0';
1823 have_next_zonekey = GNUNET_YES;
1824 /* Run a command for the previous record set */
1825 if (NULL != recordset)
1826 {
1827 run_with_zone_pkey (cfg);
1828 return;
1829 }
1830 zone_pkey = next_zone_key;
1831 if (NULL != name)
1832 GNUNET_free (name);
1833 name = GNUNET_strdup (next_name);
1834 zonekey_set = GNUNET_YES;
1835 continue;
1836 }
1837 if (GNUNET_NO == zonekey_set)
1838 {
1839 fprintf (stderr, "Warning, encountered recordline without zone\n");
1840 continue;
1581 } 1841 }
1842 parse_recordline (buf);
1843 }
1844 if (GNUNET_NO == finished)
1845 {
1846 if (NULL != recordset)
1847 {
1848 if (GNUNET_YES == zonekey_set)
1849 {
1850 run_with_zone_pkey (cfg); /** one last time **/
1851 finished = GNUNET_YES;
1852 return;
1853 }
1854 fprintf (stderr, "Warning, encountered recordline without zone\n");
1855 }
1856 }
1857 ns_qe = GNUNET_NAMESTORE_transaction_commit (ns, &commit_cb, NULL);
1858 return;
1859}
1860
1861
1862static void
1863begin_cb (void *cls, enum GNUNET_ErrorCode ec)
1864{
1865 ns_qe = NULL;
1866 if (GNUNET_EC_NONE != ec)
1867 {
1868 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1869 "Failed to start transaction: %s\n",
1870 GNUNET_ErrorCode_get_hint (ec));
1582 GNUNET_SCHEDULER_shutdown (); 1871 GNUNET_SCHEDULER_shutdown ();
1583 ret = -1;
1584 return; 1872 return;
1585 } 1873 }
1586 zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego); 1874 if (read_from_stdin)
1875 {
1876 process_command_stdin ();
1877 return;
1878 }
1587 run_with_zone_pkey (cfg); 1879 run_with_zone_pkey (cfg);
1588} 1880}
1589 1881
@@ -1606,7 +1898,6 @@ id_connect_cb (void *cls,
1606 void **ctx, 1898 void **ctx,
1607 const char *name) 1899 const char *name)
1608{ 1900{
1609 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1610 struct GNUNET_IDENTITY_PublicKey pk; 1901 struct GNUNET_IDENTITY_PublicKey pk;
1611 struct EgoEntry *ego_entry; 1902 struct EgoEntry *ego_entry;
1612 1903
@@ -1621,17 +1912,20 @@ id_connect_cb (void *cls,
1621 GNUNET_CONTAINER_DLL_insert_tail (ego_head, 1912 GNUNET_CONTAINER_DLL_insert_tail (ego_head,
1622 ego_tail, 1913 ego_tail,
1623 ego_entry); 1914 ego_entry);
1915 if ((NULL != ego_name) &&
1916 (0 == strcmp (name, ego_name)))
1917 zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego);
1624 return; 1918 return;
1625 } 1919 }
1626 if (NULL != ego) 1920 if (NULL != ego)
1627 return; 1921 return;
1628 if (NULL == ego_name) 1922 ns_qe = GNUNET_NAMESTORE_transaction_begin (ns, &begin_cb, (void *) cfg);
1629 run_with_zone_pkey (cfg);
1630 else
1631 el = GNUNET_IDENTITY_ego_lookup (cfg, ego_name, &identity_cb, (void *) cfg);
1632} 1923}
1633 1924
1634 1925
1926
1927
1928
1635/** 1929/**
1636 * Main function that will be run. 1930 * Main function that will be run.
1637 * 1931 *
@@ -1644,202 +1938,36 @@ static void
1644run (void *cls, 1938run (void *cls,
1645 char *const *args, 1939 char *const *args,
1646 const char *cfgfile, 1940 const char *cfgfile,
1647 const struct GNUNET_CONFIGURATION_Handle *cfg) 1941 const struct GNUNET_CONFIGURATION_Handle *_cfg)
1648{ 1942{
1649 const char *pkey_str;
1650
1651 (void) cls; 1943 (void) cls;
1652 (void) args; 1944 (void) args;
1653 (void) cfgfile; 1945 (void) cfgfile;
1946 cfg = _cfg;
1654 if (NULL != args[0]) 1947 if (NULL != args[0])
1655 GNUNET_log ( 1948 GNUNET_log (
1656 GNUNET_ERROR_TYPE_WARNING, 1949 GNUNET_ERROR_TYPE_WARNING,
1657 _ ("Superfluous command line arguments (starting with `%s') ignored\n"), 1950 _ ("Superfluous command line arguments (starting with `%s') ignored\n"),
1658 args[0]); 1951 args[0]);
1659 if ((NULL != args[0]) && (NULL == uri))
1660 uri = GNUNET_strdup (args[0]);
1661 1952
1662 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, (void *) cfg); 1953 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, (void *) cfg);
1663 pkey_str = getenv ("GNUNET_NAMESTORE_EGO_PRIVATE_KEY"); 1954 ns = GNUNET_NAMESTORE_connect (cfg);
1664 if (NULL != pkey_str) 1955 if (NULL == ns)
1665 { 1956 {
1666 if (GNUNET_OK != GNUNET_STRINGS_string_to_data (pkey_str, 1957 fprintf (stderr, _ ("Failed to connect to namestore\n"));
1667 strlen (pkey_str), 1958 GNUNET_SCHEDULER_shutdown ();
1668 &zone_pkey,
1669 sizeof(zone_pkey)))
1670 {
1671 fprintf (stderr,
1672 "Malformed private key `%s' in $%s\n",
1673 pkey_str,
1674 "GNUNET_NAMESTORE_EGO_PRIVATE_KEY");
1675 ret = 1;
1676 GNUNET_SCHEDULER_shutdown ();
1677 return;
1678 }
1679 run_with_zone_pkey (cfg);
1680 return; 1959 return;
1681 } 1960 }
1682 idh = GNUNET_IDENTITY_connect (cfg, &id_connect_cb, (void *) cfg); 1961 idh = GNUNET_IDENTITY_connect (cfg, &id_connect_cb, (void *) cfg);
1683 if (NULL == idh) 1962 if (NULL == idh)
1684 fprintf (stderr, _ ("Cannot connect to identity service\n"));
1685 ret = -1;
1686}
1687
1688
1689/**
1690 * Command-line option parser function that allows the user to specify
1691 * a complete record as one argument for adding/removing. A pointer
1692 * to the head of the list of record sets must be passed as the "scls"
1693 * argument.
1694 *
1695 * @param ctx command line processor context
1696 * @param scls must be of type "struct GNUNET_FS_Uri **"
1697 * @param option name of the option (typically 'R')
1698 * @param value command line argument given; format is
1699 * "TTL TYPE FLAGS VALUE" where TTL is an expiration time (rel or abs),
1700 * always given in seconds (without the unit),
1701 * TYPE is a DNS/GNS record type, FLAGS is either "n" for no flags or
1702 * a combination of 's' (shadow) and 'p' (public) and VALUE is the
1703 * value (in human-readable format)
1704 * @return #GNUNET_OK on success
1705 */
1706static int
1707multirecord_process (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
1708 void *scls,
1709 const char *option,
1710 const char *value)
1711{
1712 struct RecordSetEntry **head = scls;
1713 struct RecordSetEntry *r;
1714 struct GNUNET_GNSRECORD_Data record;
1715 char *cp;
1716 char *tok;
1717 char *saveptr;
1718 int etime_is_rel;
1719 void *raw_data;
1720
1721 (void) ctx;
1722 (void) option;
1723 cp = GNUNET_strdup (value);
1724 tok = strtok_r (cp, " ", &saveptr);
1725 if (NULL == tok)
1726 {
1727 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1728 _ ("Empty record line argument is not allowed.\n"));
1729 GNUNET_free (cp);
1730 return GNUNET_SYSERR;
1731 }
1732 {
1733 char *etime_in_s;
1734
1735 GNUNET_asprintf (&etime_in_s, "%s s", tok);
1736 if (GNUNET_OK !=
1737 parse_expiration (etime_in_s, &etime_is_rel, &record.expiration_time))
1738 {
1739 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1740 _ ("Invalid expiration time `%s' (must be without unit)\n"),
1741 tok);
1742 GNUNET_free (cp);
1743 GNUNET_free (etime_in_s);
1744 return GNUNET_SYSERR;
1745 }
1746 GNUNET_free (etime_in_s);
1747 }
1748 tok = strtok_r (NULL, " ", &saveptr);
1749 if (NULL == tok)
1750 {
1751 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1752 _ ("Missing entries in record line `%s'.\n"),
1753 value);
1754 GNUNET_free (cp);
1755 return GNUNET_SYSERR;
1756 }
1757 record.record_type = GNUNET_GNSRECORD_typename_to_number (tok);
1758 if (UINT32_MAX == record.record_type)
1759 {
1760 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Unknown record type `%s'\n"), tok);
1761 GNUNET_free (cp);
1762 return GNUNET_SYSERR;
1763 }
1764 tok = strtok_r (NULL, " ", &saveptr);
1765 if (NULL == tok)
1766 { 1963 {
1767 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1964 ret = -1;
1768 _ ("Missing entries in record line `%s'.\n"), 1965 fprintf (stderr, _ ("Cannot connect to identity service\n"));
1769 value); 1966 GNUNET_SCHEDULER_shutdown ();
1770 GNUNET_free (cp);
1771 return GNUNET_SYSERR;
1772 }
1773 record.flags = GNUNET_GNSRECORD_RF_NONE;
1774 if (etime_is_rel)
1775 record.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1776 if (NULL == strchr (tok, (unsigned char) 'p')) /* p = public */
1777 record.flags |= GNUNET_GNSRECORD_RF_PRIVATE;
1778 if (NULL != strchr (tok, (unsigned char) 's'))
1779 record.flags |= GNUNET_GNSRECORD_RF_SHADOW_RECORD;
1780 /* find beginning of record value */
1781 tok = strchr (&value[tok - cp], (unsigned char) ' ');
1782 if (NULL == tok)
1783 {
1784 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1785 _ ("Missing entries in record line `%s'.\n"),
1786 value);
1787 GNUNET_free (cp);
1788 return GNUNET_SYSERR;
1789 }
1790 GNUNET_free (cp);
1791 tok++; /* skip space */
1792 if (GNUNET_OK != GNUNET_GNSRECORD_string_to_value (record.record_type,
1793 tok,
1794 &raw_data,
1795 &record.data_size))
1796 {
1797 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1798 _ ("Invalid record data for type %s: `%s'.\n"),
1799 GNUNET_GNSRECORD_number_to_typename (record.record_type),
1800 tok);
1801 return GNUNET_SYSERR;
1802 } 1967 }
1803
1804 r = GNUNET_malloc (sizeof(struct RecordSetEntry) + record.data_size);
1805 r->next = *head;
1806 record.data = &r[1];
1807 memcpy (&r[1], raw_data, record.data_size);
1808 GNUNET_free (raw_data);
1809 r->record = record;
1810 *head = r;
1811 return GNUNET_OK;
1812} 1968}
1813 1969
1814 1970
1815/**
1816 * Allow user to specify keywords.
1817 *
1818 * @param shortName short name of the option
1819 * @param name long name of the option
1820 * @param argumentHelp help text for the option argument
1821 * @param description long help text for the option
1822 * @param[out] topKeywords set to the desired value
1823 */
1824struct GNUNET_GETOPT_CommandLineOption
1825multirecord_option (char shortName,
1826 const char *name,
1827 const char *argumentHelp,
1828 const char *description,
1829 struct RecordSetEntry **rs)
1830{
1831 struct GNUNET_GETOPT_CommandLineOption clo = { .shortName = shortName,
1832 .name = name,
1833 .argumentHelp = argumentHelp,
1834 .description = description,
1835 .require_argument = 1,
1836 .processor =
1837 &multirecord_process,
1838 .scls = (void *) rs };
1839
1840 return clo;
1841}
1842
1843 1971
1844/** 1972/**
1845 * The main function for gnunet-namestore. 1973 * The main function for gnunet-namestore.
@@ -1851,6 +1979,7 @@ multirecord_option (char shortName,
1851int 1979int
1852main (int argc, char *const *argv) 1980main (int argc, char *const *argv)
1853{ 1981{
1982 int lret;
1854 struct GNUNET_GETOPT_CommandLineOption options[] = 1983 struct GNUNET_GETOPT_CommandLineOption options[] =
1855 { GNUNET_GETOPT_option_flag ('a', "add", gettext_noop ("add record"), &add), 1984 { GNUNET_GETOPT_option_flag ('a', "add", gettext_noop ("add record"), &add),
1856 GNUNET_GETOPT_option_flag ('d', 1985 GNUNET_GETOPT_option_flag ('d',
@@ -1861,6 +1990,10 @@ main (int argc, char *const *argv)
1861 "display", 1990 "display",
1862 gettext_noop ("display records"), 1991 gettext_noop ("display records"),
1863 &list), 1992 &list),
1993 GNUNET_GETOPT_option_flag ('S',
1994 "from-stdin",
1995 gettext_noop ("read commands from stdin"),
1996 &read_from_stdin),
1864 GNUNET_GETOPT_option_string ( 1997 GNUNET_GETOPT_option_string (
1865 'e', 1998 'e',
1866 "expiration", 1999 "expiration",
@@ -1885,19 +2018,16 @@ main (int argc, char *const *argv)
1885 gettext_noop ( 2018 gettext_noop (
1886 "name of the record to add/delete/display"), 2019 "name of the record to add/delete/display"),
1887 &name), 2020 &name),
1888 GNUNET_GETOPT_option_string ('r', 2021 GNUNET_GETOPT_option_flag ('r',
1889 "reverse", 2022 "recordline",
1890 "PKEY", 2023 gettext_noop ("Output in recordline format"),
2024 &output_recordline),
2025 GNUNET_GETOPT_option_string ('Z',
2026 "zone-to-name",
2027 "KEY",
1891 gettext_noop ( 2028 gettext_noop (
1892 "determine our name for the given PKEY"), 2029 "determine our name for the given KEY"),
1893 &reverse_pkey), 2030 &reverse_pkey),
1894 multirecord_option (
1895 'R',
1896 "replace",
1897 "RECORDLINE",
1898 gettext_noop (
1899 "set record set to values given by (possibly multiple) RECORDLINES; can be specified multiple times"),
1900 &recordset),
1901 GNUNET_GETOPT_option_string ('t', 2031 GNUNET_GETOPT_option_string ('t',
1902 "type", 2032 "type",
1903 "TYPE", 2033 "TYPE",
@@ -1956,7 +2086,7 @@ main (int argc, char *const *argv)
1956 "name of the ego controlling the zone"), 2086 "name of the ego controlling the zone"),
1957 &ego_name), 2087 &ego_name),
1958 GNUNET_GETOPT_OPTION_END }; 2088 GNUNET_GETOPT_OPTION_END };
1959 int lret; 2089
1960 2090
1961 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 2091 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1962 return 2; 2092 return 2;
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 9173d2e4d..d25287c9f 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -26,7 +26,6 @@
26 */ 26 */
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
29#include "gnunet_dnsparser_lib.h"
30#include "gnunet_gns_service.h" 29#include "gnunet_gns_service.h"
31#include "gnunet_namestore_service.h" 30#include "gnunet_namestore_service.h"
32#include "gnunet_namestore_plugin.h" 31#include "gnunet_namestore_plugin.h"
@@ -787,7 +786,7 @@ send_lookup_response_with_filter (struct NamestoreClient *nc,
787 zir_msg->name_len = htons (name_len); 786 zir_msg->name_len = htons (name_len);
788 zir_msg->rd_count = htons (res_count); 787 zir_msg->rd_count = htons (res_count);
789 zir_msg->rd_len = htons ((uint16_t) rd_ser_len); 788 zir_msg->rd_len = htons ((uint16_t) rd_ser_len);
790 zir_msg->key_len = htonl (key_len); 789 zir_msg->key_len = htons (key_len);
791 GNUNET_IDENTITY_write_private_key_to_buffer (zone_key, 790 GNUNET_IDENTITY_write_private_key_to_buffer (zone_key,
792 &zir_msg[1], 791 &zir_msg[1],
793 key_len); 792 key_len);
@@ -1317,8 +1316,8 @@ check_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg)
1317 size_t key_len; 1316 size_t key_len;
1318 1317
1319 (void) cls; 1318 (void) cls;
1320 name_len = ntohl (ll_msg->label_len); 1319 name_len = ntohs (ll_msg->label_len);
1321 key_len = ntohl (ll_msg->key_len); 1320 key_len = ntohs (ll_msg->key_len);
1322 src_size = ntohs (ll_msg->gns_header.header.size); 1321 src_size = ntohs (ll_msg->gns_header.header.size);
1323 if (name_len + key_len != src_size - sizeof(struct LabelLookupMessage)) 1322 if (name_len + key_len != src_size - sizeof(struct LabelLookupMessage))
1324 { 1323 {
@@ -1351,7 +1350,7 @@ handle_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg)
1351 size_t key_len; 1350 size_t key_len;
1352 size_t kb_read; 1351 size_t kb_read;
1353 1352
1354 key_len = ntohl (ll_msg->key_len); 1353 key_len = ntohs (ll_msg->key_len);
1355 if ((GNUNET_SYSERR == 1354 if ((GNUNET_SYSERR ==
1356 GNUNET_IDENTITY_read_private_key_from_buffer (&ll_msg[1], 1355 GNUNET_IDENTITY_read_private_key_from_buffer (&ll_msg[1],
1357 key_len, 1356 key_len,
@@ -1389,7 +1388,7 @@ handle_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg)
1389 rlc.res_rd = NULL; 1388 rlc.res_rd = NULL;
1390 rlc.rd_ser_len = 0; 1389 rlc.rd_ser_len = 0;
1391 rlc.nick = get_nick_record (&zone); 1390 rlc.nick = get_nick_record (&zone);
1392 if (GNUNET_YES != ntohl (ll_msg->is_edit_request)) 1391 if (GNUNET_YES != ntohs (ll_msg->is_edit_request))
1393 res = nc->GSN_database->lookup_records (nc->GSN_database->cls, 1392 res = nc->GSN_database->lookup_records (nc->GSN_database->cls,
1394 &zone, 1393 &zone,
1395 conv_name, 1394 conv_name,
@@ -1412,6 +1411,7 @@ handle_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg)
1412 llr_msg->name_len = htons (name_len); 1411 llr_msg->name_len = htons (name_len);
1413 llr_msg->rd_count = htons (rlc.res_rd_count); 1412 llr_msg->rd_count = htons (rlc.res_rd_count);
1414 llr_msg->rd_len = htons (rlc.rd_ser_len); 1413 llr_msg->rd_len = htons (rlc.rd_ser_len);
1414 llr_msg->reserved = htons (0);
1415 res_name = ((char *) &llr_msg[1]) + key_len; 1415 res_name = ((char *) &llr_msg[1]) + key_len;
1416 if (GNUNET_YES == rlc.found) 1416 if (GNUNET_YES == rlc.found)
1417 llr_msg->found = htons (GNUNET_YES); 1417 llr_msg->found = htons (GNUNET_YES);
@@ -1446,7 +1446,7 @@ check_record_store (void *cls, const struct RecordStoreMessage *rp_msg)
1446 (void) cls; 1446 (void) cls;
1447 msg_size = ntohs (rp_msg->gns_header.header.size); 1447 msg_size = ntohs (rp_msg->gns_header.header.size);
1448 rd_set_count = ntohs (rp_msg->rd_set_count); 1448 rd_set_count = ntohs (rp_msg->rd_set_count);
1449 key_len = ntohl (rp_msg->key_len); 1449 key_len = ntohs (rp_msg->key_len);
1450 1450
1451 min_size_exp = sizeof(*rp_msg) + key_len + sizeof (struct RecordSet) 1451 min_size_exp = sizeof(*rp_msg) + key_len + sizeof (struct RecordSet)
1452 * rd_set_count; 1452 * rd_set_count;
@@ -1739,7 +1739,7 @@ handle_record_store (void *cls, const struct RecordStoreMessage *rp_msg)
1739 struct RecordSet *rs; 1739 struct RecordSet *rs;
1740 enum GNUNET_ErrorCode res; 1740 enum GNUNET_ErrorCode res;
1741 1741
1742 key_len = ntohl (rp_msg->key_len); 1742 key_len = ntohs (rp_msg->key_len);
1743 if ((GNUNET_SYSERR == 1743 if ((GNUNET_SYSERR ==
1744 GNUNET_IDENTITY_read_private_key_from_buffer (&rp_msg[1], 1744 GNUNET_IDENTITY_read_private_key_from_buffer (&rp_msg[1],
1745 key_len, 1745 key_len,
@@ -1993,7 +1993,7 @@ handle_zone_to_name_it (void *cls,
1993 ztnr_msg->rd_len = htons (rd_ser_len); 1993 ztnr_msg->rd_len = htons (rd_ser_len);
1994 ztnr_msg->rd_count = htons (rd_count); 1994 ztnr_msg->rd_count = htons (rd_count);
1995 ztnr_msg->name_len = htons (name_len); 1995 ztnr_msg->name_len = htons (name_len);
1996 ztnr_msg->key_len = htonl (key_len); 1996 ztnr_msg->key_len = htons (key_len);
1997 GNUNET_IDENTITY_write_private_key_to_buffer (zone_key, 1997 GNUNET_IDENTITY_write_private_key_to_buffer (zone_key,
1998 &ztnr_msg[1], 1998 &ztnr_msg[1],
1999 key_len); 1999 key_len);
@@ -2038,7 +2038,7 @@ handle_zone_to_name (void *cls, const struct ZoneToNameMessage *ztn_msg)
2038 ztn_ctx.rid = ntohl (ztn_msg->gns_header.r_id); 2038 ztn_ctx.rid = ntohl (ztn_msg->gns_header.r_id);
2039 ztn_ctx.nc = nc; 2039 ztn_ctx.nc = nc;
2040 ztn_ctx.ec = GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND; 2040 ztn_ctx.ec = GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND;
2041 key_len = ntohl (ztn_msg->key_len); 2041 key_len = ntohs (ztn_msg->key_len);
2042 if ((GNUNET_SYSERR == 2042 if ((GNUNET_SYSERR ==
2043 GNUNET_IDENTITY_read_private_key_from_buffer (&ztn_msg[1], 2043 GNUNET_IDENTITY_read_private_key_from_buffer (&ztn_msg[1],
2044 key_len, 2044 key_len,
@@ -2052,7 +2052,7 @@ handle_zone_to_name (void *cls, const struct ZoneToNameMessage *ztn_msg)
2052 GNUNET_break (0); 2052 GNUNET_break (0);
2053 return; 2053 return;
2054 } 2054 }
2055 pkey_len = ntohl (ztn_msg->pkey_len); 2055 pkey_len = ntohs (ztn_msg->pkey_len);
2056 if ((GNUNET_SYSERR == 2056 if ((GNUNET_SYSERR ==
2057 GNUNET_IDENTITY_read_public_key_from_buffer ((char*) &ztn_msg[1] 2057 GNUNET_IDENTITY_read_public_key_from_buffer ((char*) &ztn_msg[1]
2058 + key_len, 2058 + key_len,
@@ -2259,7 +2259,7 @@ handle_iteration_start (void *cls,
2259 2259
2260 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2260 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2261 "Received ZONE_ITERATION_START message\n"); 2261 "Received ZONE_ITERATION_START message\n");
2262 key_len = ntohl (zis_msg->key_len); 2262 key_len = ntohs (zis_msg->key_len);
2263 zi = GNUNET_new (struct ZoneIteration); 2263 zi = GNUNET_new (struct ZoneIteration);
2264 if (0 < key_len) 2264 if (0 < key_len)
2265 { 2265 {
@@ -2512,7 +2512,7 @@ handle_monitor_start (void *cls, const struct
2512 "Received ZONE_MONITOR_START message\n"); 2512 "Received ZONE_MONITOR_START message\n");
2513 zm = GNUNET_new (struct ZoneMonitor); 2513 zm = GNUNET_new (struct ZoneMonitor);
2514 zm->nc = nc; 2514 zm->nc = nc;
2515 key_len = ntohl (zis_msg->key_len); 2515 key_len = ntohs (zis_msg->key_len);
2516 if (0 < key_len) 2516 if (0 < key_len)
2517 { 2517 {
2518 if ((GNUNET_SYSERR == 2518 if ((GNUNET_SYSERR ==
diff --git a/src/namestore/gnunet-zoneimport.c b/src/namestore/gnunet-zoneimport.c
index 0094baf0e..485df4924 100644
--- a/src/namestore/gnunet-zoneimport.c
+++ b/src/namestore/gnunet-zoneimport.c
@@ -24,8 +24,6 @@
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include <gnunet_util_lib.h> 26#include <gnunet_util_lib.h>
27#include <gnunet_dnsstub_lib.h>
28#include <gnunet_dnsparser_lib.h>
29#include <gnunet_gnsrecord_lib.h> 27#include <gnunet_gnsrecord_lib.h>
30#include <gnunet_namestore_service.h> 28#include <gnunet_namestore_service.h>
31#include <gnunet_statistics_service.h> 29#include <gnunet_statistics_service.h>
diff --git a/src/namestore/namestore-0001.sql b/src/namestore/namestore-0001.sql
new file mode 100644
index 000000000..bdfb31976
--- /dev/null
+++ b/src/namestore/namestore-0001.sql
@@ -0,0 +1,48 @@
1--
2-- This file is part of GNUnet
3-- Copyright (C) 2014--2022 GNUnet e.V.
4--
5-- GNUnet is free software; you can redistribute it and/or modify it under the
6-- terms of the GNU General Public License as published by the Free Software
7-- Foundation; either version 3, or (at your option) any later version.
8--
9-- GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY
10-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12--
13-- You should have received a copy of the GNU General Public License along with
14-- GNUnet; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
15--
16
17-- Everything in one big transaction
18BEGIN;
19
20-- Check patch versioning is in place.
21SELECT _v.register_patch('namestore-0001', NULL, NULL);
22
23-------------------- Schema ----------------------------
24
25CREATE SCHEMA namestore;
26COMMENT ON SCHEMA namestore IS 'gnunet-namestore data';
27
28SET search_path TO namestore;
29
30CREATE TABLE ns098records (
31 seq BIGSERIAL PRIMARY KEY,
32 zone_private_key BYTEA NOT NULL DEFAULT '',
33 pkey BYTEA DEFAULT '',
34 rvalue BYTEA NOT NULL DEFAULT '',
35 record_count INTEGER NOT NULL DEFAULT 0,
36 record_data BYTEA NOT NULL DEFAULT '',
37 label TEXT NOT NULL DEFAULT '',
38 CONSTRAINT zl UNIQUE (zone_private_key,label));
39
40CREATE INDEX IF NOT EXISTS ir_pkey_reverse
41 ON ns098records (zone_private_key,pkey);
42CREATE INDEX IF NOT EXISTS ir_pkey_iter
43 ON ns098records (zone_private_key,seq);
44CREATE INDEX IF NOT EXISTS ir_label
45 ON ns098records (label);
46
47
48COMMIT;
diff --git a/src/namestore/namestore-drop.sql b/src/namestore/namestore-drop.sql
new file mode 100644
index 000000000..231417af8
--- /dev/null
+++ b/src/namestore/namestore-drop.sql
@@ -0,0 +1,25 @@
1--
2-- This file is part of GNUnet
3-- Copyright (C) 2014--2022 GNUnet e.V.
4--
5-- GNUnet is free software; you can redistribute it and/or modify it under the
6-- terms of the GNU General Public License as published by the Free Software
7-- Foundation; either version 3, or (at your option) any later version.
8--
9-- GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY
10-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12--
13-- You should have received a copy of the GNU General Public License along with
14-- GNUnet; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
15--
16
17-- Everything in one big transaction
18BEGIN;
19
20
21SELECT _v.unregister_patch('namestore-0001');
22
23DROP SCHEMA namestore CASCADE;
24
25COMMIT;
diff --git a/src/namestore/namestore.conf.in b/src/namestore/namestore.conf.in
index fe7d4002c..d817f3f95 100644
--- a/src/namestore/namestore.conf.in
+++ b/src/namestore/namestore.conf.in
@@ -27,11 +27,10 @@ FILENAME = $GNUNET_DATA_HOME/namestore/sqlite.db
27[namestore-postgres] 27[namestore-postgres]
28# How to connect to the database 28# How to connect to the database
29CONFIG = postgres:///gnunet 29CONFIG = postgres:///gnunet
30# Use temporary tables
31TEMPORARY_TABLE = NO
32# Use asynchronous commit (SET synchronous_commit TO OFF). 30# Use asynchronous commit (SET synchronous_commit TO OFF).
33ASYNC_COMMIT = NO 31ASYNC_COMMIT = NO
34INIT_ON_CONNECT = YES 32INIT_ON_CONNECT = YES
33SQL_DIR = ${DATADIR}/sql/
35 34
36[uri] 35[uri]
37gns = gnunet-namestore -e 1a -u 36gns = gnunet-namestore -e 1a -u
diff --git a/src/namestore/namestore.h b/src/namestore/namestore.h
index 0b50ac1ab..35d54d317 100644
--- a/src/namestore/namestore.h
+++ b/src/namestore/namestore.h
@@ -98,7 +98,7 @@ struct RecordStoreMessage
98 /** 98 /**
99 * Length of the zone key 99 * Length of the zone key
100 */ 100 */
101 uint32_t key_len GNUNET_PACKED; 101 uint16_t key_len GNUNET_PACKED;
102 102
103 /** 103 /**
104 * Followed by the private zone key 104 * Followed by the private zone key
@@ -138,12 +138,12 @@ struct LabelLookupMessage
138 /** 138 /**
139 * Length of the name 139 * Length of the name
140 */ 140 */
141 uint32_t label_len GNUNET_PACKED; 141 uint16_t label_len GNUNET_PACKED;
142 142
143 /** 143 /**
144 * GNUNET_YES if this lookup corresponds to an edit request 144 * GNUNET_YES if this lookup corresponds to an edit request
145 */ 145 */
146 uint32_t is_edit_request GNUNET_PACKED; 146 uint16_t is_edit_request GNUNET_PACKED;
147 147
148 /** 148 /**
149 * The record filter 149 * The record filter
@@ -153,7 +153,7 @@ struct LabelLookupMessage
153 /** 153 /**
154 * Length of the zone key 154 * Length of the zone key
155 */ 155 */
156 uint32_t key_len GNUNET_PACKED; 156 uint16_t key_len GNUNET_PACKED;
157 157
158 /* followed by: 158 /* followed by:
159 * the private zone key 159 * the private zone key
@@ -194,9 +194,14 @@ struct LabelLookupResponseMessage
194 int16_t found GNUNET_PACKED; 194 int16_t found GNUNET_PACKED;
195 195
196 /** 196 /**
197 * Reserved (alignment)
198 */
199 uint16_t reserved GNUNET_PACKED;
200
201 /**
197 * Length of the zone key 202 * Length of the zone key
198 */ 203 */
199 uint32_t key_len GNUNET_PACKED; 204 uint16_t key_len GNUNET_PACKED;
200 205
201 /* followed by: 206 /* followed by:
202 * the private zone key 207 * the private zone key
@@ -219,12 +224,12 @@ struct ZoneToNameMessage
219 /** 224 /**
220 * Length of the zone key 225 * Length of the zone key
221 */ 226 */
222 uint32_t key_len GNUNET_PACKED; 227 uint16_t key_len GNUNET_PACKED;
223 228
224 /** 229 /**
225 * Length of the public value zone key 230 * Length of the public value zone key
226 */ 231 */
227 uint32_t pkey_len GNUNET_PACKED; 232 uint16_t pkey_len GNUNET_PACKED;
228 233
229 /** 234 /**
230 * Followed by 235 * Followed by
@@ -245,6 +250,14 @@ struct ZoneToNameResponseMessage
245 struct GNUNET_NAMESTORE_Header gns_header; 250 struct GNUNET_NAMESTORE_Header gns_header;
246 251
247 /** 252 /**
253 * result in NBO: #GNUNET_EC_NONE on success,
254 * #GNUNET_EC_NAMESTORE_NO_RESULTS if there were no
255 * results.
256 * Other error messages on error.
257 */
258 int32_t ec GNUNET_PACKED;
259
260 /**
248 * Length of the name 261 * Length of the name
249 */ 262 */
250 uint16_t name_len GNUNET_PACKED; 263 uint16_t name_len GNUNET_PACKED;
@@ -260,17 +273,9 @@ struct ZoneToNameResponseMessage
260 uint16_t rd_count GNUNET_PACKED; 273 uint16_t rd_count GNUNET_PACKED;
261 274
262 /** 275 /**
263 * result in NBO: #GNUNET_EC_NONE on success,
264 * #GNUNET_EC_NAMESTORE_NO_RESULTS if there were no
265 * results.
266 * Other error messages on error.
267 */
268 int32_t ec GNUNET_PACKED;
269
270 /**
271 * Length of the zone key 276 * Length of the zone key
272 */ 277 */
273 uint32_t key_len GNUNET_PACKED; 278 uint16_t key_len GNUNET_PACKED;
274 279
275 /* followed by: 280 /* followed by:
276 * the private zone key 281 * the private zone key
@@ -312,14 +317,9 @@ struct RecordResultMessage
312 uint16_t rd_count GNUNET_PACKED; 317 uint16_t rd_count GNUNET_PACKED;
313 318
314 /** 319 /**
315 * always zero (for alignment)
316 */
317 uint16_t reserved GNUNET_PACKED;
318
319 /**
320 * Length of the zone key 320 * Length of the zone key
321 */ 321 */
322 uint32_t key_len GNUNET_PACKED; 322 uint16_t key_len GNUNET_PACKED;
323 323
324 /* followed by: 324 /* followed by:
325 * the private key of the authority 325 * the private key of the authority
@@ -339,14 +339,14 @@ struct TxControlMessage
339 struct GNUNET_NAMESTORE_Header gns_header; 339 struct GNUNET_NAMESTORE_Header gns_header;
340 340
341 /** 341 /**
342 * The type of control message to send 342 * always zero (for alignment)
343 */ 343 */
344 uint16_t control GNUNET_PACKED; 344 uint16_t reserved GNUNET_PACKED;
345 345
346 /** 346 /**
347 * always zero (for alignment) 347 * The type of control message to send
348 */ 348 */
349 uint16_t reserved GNUNET_PACKED; 349 uint16_t control GNUNET_PACKED;
350 350
351}; 351};
352 352
@@ -392,14 +392,9 @@ struct ZoneMonitorStartMessage
392 uint16_t filter; 392 uint16_t filter;
393 393
394 /** 394 /**
395 * Reserved for alignment
396 */
397 uint16_t reserved;
398
399 /**
400 * Length of the zone key 395 * Length of the zone key
401 */ 396 */
402 uint32_t key_len GNUNET_PACKED; 397 uint16_t key_len GNUNET_PACKED;
403 398
404 /** 399 /**
405 * Followed by the private zone key. 400 * Followed by the private zone key.
@@ -448,14 +443,9 @@ struct ZoneIterationStartMessage
448 uint16_t filter; 443 uint16_t filter;
449 444
450 /** 445 /**
451 * Reserved for alignment
452 */
453 uint16_t reserved;
454
455 /**
456 * Length of the zone key 446 * Length of the zone key
457 */ 447 */
458 uint32_t key_len GNUNET_PACKED; 448 uint16_t key_len GNUNET_PACKED;
459 449
460 /** 450 /**
461 * Followed by the private zone key (optional) 451 * Followed by the private zone key (optional)
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index e020b9e42..df6ba1f33 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -29,9 +29,7 @@
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_error_codes.h" 30#include "gnunet_error_codes.h"
31#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_crypto_lib.h"
33#include "gnunet_constants.h" 32#include "gnunet_constants.h"
34#include "gnunet_dnsparser_lib.h"
35#include "gnunet_arm_service.h" 33#include "gnunet_arm_service.h"
36#include "gnunet_signatures.h" 34#include "gnunet_signatures.h"
37#include "gnunet_gns_service.h" 35#include "gnunet_gns_service.h"
@@ -407,8 +405,13 @@ check_lookup_result (void *cls, const struct LabelLookupResponseMessage *msg)
407 rd_len = ntohs (msg->rd_len); 405 rd_len = ntohs (msg->rd_len);
408 msg_len = ntohs (msg->gns_header.header.size); 406 msg_len = ntohs (msg->gns_header.header.size);
409 name_len = ntohs (msg->name_len); 407 name_len = ntohs (msg->name_len);
410 key_len = ntohl (msg->key_len); 408 key_len = ntohs (msg->key_len);
411 exp_msg_len = sizeof(*msg) + name_len + rd_len + key_len; 409 exp_msg_len = sizeof(*msg) + name_len + rd_len + key_len;
410 if (0 != ntohs (msg->reserved))
411 {
412 GNUNET_break (0);
413 return GNUNET_SYSERR;
414 }
412 if (msg_len != exp_msg_len) 415 if (msg_len != exp_msg_len)
413 { 416 {
414 GNUNET_break (0); 417 GNUNET_break (0);
@@ -463,7 +466,7 @@ handle_lookup_result (void *cls, const struct LabelLookupResponseMessage *msg)
463 rd_len = ntohs (msg->rd_len); 466 rd_len = ntohs (msg->rd_len);
464 rd_count = ntohs (msg->rd_count); 467 rd_count = ntohs (msg->rd_count);
465 name_len = ntohs (msg->name_len); 468 name_len = ntohs (msg->name_len);
466 key_len = ntohl (msg->key_len); 469 key_len = ntohs (msg->key_len);
467 GNUNET_assert (GNUNET_SYSERR != 470 GNUNET_assert (GNUNET_SYSERR !=
468 GNUNET_IDENTITY_read_private_key_from_buffer (&msg[1], 471 GNUNET_IDENTITY_read_private_key_from_buffer (&msg[1],
469 key_len, 472 key_len,
@@ -527,13 +530,8 @@ check_record_result (void *cls, const struct RecordResultMessage *msg)
527 (void) cls; 530 (void) cls;
528 rd_len = ntohs (msg->rd_len); 531 rd_len = ntohs (msg->rd_len);
529 msg_len = ntohs (msg->gns_header.header.size); 532 msg_len = ntohs (msg->gns_header.header.size);
530 key_len = ntohl (msg->key_len); 533 key_len = ntohs (msg->key_len);
531 name_len = ntohs (msg->name_len); 534 name_len = ntohs (msg->name_len);
532 if (0 != ntohs (msg->reserved))
533 {
534 GNUNET_break (0);
535 return GNUNET_SYSERR;
536 }
537 if (msg_len != sizeof(struct RecordResultMessage) + key_len + name_len 535 if (msg_len != sizeof(struct RecordResultMessage) + key_len + name_len
538 + rd_len) 536 + rd_len)
539 { 537 {
@@ -581,7 +579,7 @@ handle_record_result (void *cls, const struct RecordResultMessage *msg)
581 rd_len = ntohs (msg->rd_len); 579 rd_len = ntohs (msg->rd_len);
582 rd_count = ntohs (msg->rd_count); 580 rd_count = ntohs (msg->rd_count);
583 name_len = ntohs (msg->name_len); 581 name_len = ntohs (msg->name_len);
584 key_len = ntohl (msg->key_len); 582 key_len = ntohs (msg->key_len);
585 ze = find_zi (h, ntohl (msg->gns_header.r_id)); 583 ze = find_zi (h, ntohl (msg->gns_header.r_id));
586 qe = find_qe (h, ntohl (msg->gns_header.r_id)); 584 qe = find_qe (h, ntohl (msg->gns_header.r_id));
587 if ((NULL == ze) && (NULL == qe)) 585 if ((NULL == ze) && (NULL == qe))
@@ -710,7 +708,7 @@ check_zone_to_name_response (void *cls,
710 (void) cls; 708 (void) cls;
711 if (GNUNET_EC_NONE != ntohl (msg->ec)) 709 if (GNUNET_EC_NONE != ntohl (msg->ec))
712 return GNUNET_OK; 710 return GNUNET_OK;
713 key_len = ntohl (msg->key_len); 711 key_len = ntohs (msg->key_len);
714 name_len = ntohs (msg->name_len); 712 name_len = ntohs (msg->name_len);
715 rd_ser_len = ntohs (msg->rd_len); 713 rd_ser_len = ntohs (msg->rd_len);
716 if (ntohs (msg->gns_header.header.size) != 714 if (ntohs (msg->gns_header.header.size) !=
@@ -762,7 +760,7 @@ handle_zone_to_name_response (void *cls,
762 return; 760 return;
763 } 761 }
764 res = ntohl (msg->ec); 762 res = ntohl (msg->ec);
765 key_len = ntohl (msg->key_len); 763 key_len = ntohs (msg->key_len);
766 GNUNET_assert (GNUNET_SYSERR != 764 GNUNET_assert (GNUNET_SYSERR !=
767 GNUNET_IDENTITY_read_private_key_from_buffer (&msg[1], 765 GNUNET_IDENTITY_read_private_key_from_buffer (&msg[1],
768 key_len, 766 key_len,
@@ -1140,7 +1138,7 @@ GNUNET_NAMESTORE_records_store2 (
1140 GNUNET_assert (NULL != msg); 1138 GNUNET_assert (NULL != msg);
1141 GNUNET_assert (NULL != env); 1139 GNUNET_assert (NULL != env);
1142 msg->gns_header.r_id = htonl (rid); 1140 msg->gns_header.r_id = htonl (rid);
1143 msg->key_len = htonl (key_len); 1141 msg->key_len = htons (key_len);
1144 msg->rd_set_count = htons ((uint16_t) (*rds_sent)); 1142 msg->rd_set_count = htons ((uint16_t) (*rds_sent));
1145 GNUNET_IDENTITY_write_private_key_to_buffer (pkey, 1143 GNUNET_IDENTITY_write_private_key_to_buffer (pkey,
1146 &msg[1], 1144 &msg[1],
@@ -1230,9 +1228,9 @@ records_lookup (
1230 &msg[1], 1228 &msg[1],
1231 key_len); 1229 key_len);
1232 1230
1233 msg->key_len = htonl (key_len); 1231 msg->key_len = htons (key_len);
1234 msg->is_edit_request = htonl (is_edit_request); 1232 msg->is_edit_request = htons (is_edit_request);
1235 msg->label_len = htonl (label_len); 1233 msg->label_len = htons (label_len);
1236 msg->filter = htons (filter); 1234 msg->filter = htons (filter);
1237 GNUNET_memcpy (((char*) &msg[1]) + key_len, label, label_len); 1235 GNUNET_memcpy (((char*) &msg[1]) + key_len, label, label_len);
1238 if (NULL == h->mq) 1236 if (NULL == h->mq)
@@ -1323,8 +1321,8 @@ GNUNET_NAMESTORE_zone_to_name (
1323 env = GNUNET_MQ_msg_extra (msg, key_len + pkey_len, 1321 env = GNUNET_MQ_msg_extra (msg, key_len + pkey_len,
1324 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME); 1322 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME);
1325 msg->gns_header.r_id = htonl (rid); 1323 msg->gns_header.r_id = htonl (rid);
1326 msg->key_len = htonl (key_len); 1324 msg->key_len = htons (key_len);
1327 msg->pkey_len = htonl (pkey_len); 1325 msg->pkey_len = htons (pkey_len);
1328 GNUNET_IDENTITY_write_private_key_to_buffer (zone, &msg[1], key_len); 1326 GNUNET_IDENTITY_write_private_key_to_buffer (zone, &msg[1], key_len);
1329 GNUNET_IDENTITY_write_public_key_to_buffer (value_zone, 1327 GNUNET_IDENTITY_write_public_key_to_buffer (value_zone,
1330 (char*) &msg[1] + key_len, 1328 (char*) &msg[1] + key_len,
@@ -1375,7 +1373,7 @@ GNUNET_NAMESTORE_zone_iteration_start (
1375 key_len, 1373 key_len,
1376 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START); 1374 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START);
1377 msg->gns_header.r_id = htonl (rid); 1375 msg->gns_header.r_id = htonl (rid);
1378 msg->key_len = htonl (key_len); 1376 msg->key_len = htons (key_len);
1379 if (NULL != zone) 1377 if (NULL != zone)
1380 GNUNET_IDENTITY_write_private_key_to_buffer (zone, &msg[1], key_len); 1378 GNUNET_IDENTITY_write_private_key_to_buffer (zone, &msg[1], key_len);
1381 if (NULL == h->mq) 1379 if (NULL == h->mq)
@@ -1424,7 +1422,7 @@ GNUNET_NAMESTORE_zone_iteration_start2 (
1424 key_len, 1422 key_len,
1425 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START); 1423 GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START);
1426 msg->gns_header.r_id = htonl (rid); 1424 msg->gns_header.r_id = htonl (rid);
1427 msg->key_len = htonl (key_len); 1425 msg->key_len = htons (key_len);
1428 msg->filter = htons ((uint16_t) filter); 1426 msg->filter = htons ((uint16_t) filter);
1429 if (NULL != zone) 1427 if (NULL != zone)
1430 GNUNET_IDENTITY_write_private_key_to_buffer (zone, &msg[1], key_len); 1428 GNUNET_IDENTITY_write_private_key_to_buffer (zone, &msg[1], key_len);
diff --git a/src/namestore/namestore_api_monitor.c b/src/namestore/namestore_api_monitor.c
index 81ea41f7d..a99b386d0 100644
--- a/src/namestore/namestore_api_monitor.c
+++ b/src/namestore/namestore_api_monitor.c
@@ -25,9 +25,7 @@
25 25
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_crypto_lib.h"
29#include "gnunet_constants.h" 28#include "gnunet_constants.h"
30#include "gnunet_dnsparser_lib.h"
31#include "gnunet_arm_service.h" 29#include "gnunet_arm_service.h"
32#include "gnunet_signatures.h" 30#include "gnunet_signatures.h"
33#include "gnunet_namestore_service.h" 31#include "gnunet_namestore_service.h"
@@ -154,7 +152,7 @@ check_result (void *cls, const struct RecordResultMessage *lrm)
154 size_t key_len; 152 size_t key_len;
155 153
156 (void) zm; 154 (void) zm;
157 key_len = ntohl (lrm->key_len); 155 key_len = ntohs (lrm->key_len);
158 (void) cls; 156 (void) cls;
159 if (0 == key_len) 157 if (0 == key_len)
160 { 158 {
@@ -222,7 +220,7 @@ handle_result (void *cls, const struct RecordResultMessage *lrm)
222 const char *name_tmp; 220 const char *name_tmp;
223 const char *rd_ser_tmp; 221 const char *rd_ser_tmp;
224 222
225 key_len = ntohl (lrm->key_len); 223 key_len = ntohs (lrm->key_len);
226 rd_len = ntohs (lrm->rd_len); 224 rd_len = ntohs (lrm->rd_len);
227 rd_count = ntohs (lrm->rd_count); 225 rd_count = ntohs (lrm->rd_count);
228 name_len = ntohs (lrm->name_len); 226 name_len = ntohs (lrm->name_len);
@@ -308,7 +306,7 @@ reconnect (struct GNUNET_NAMESTORE_ZoneMonitor *zm)
308 GNUNET_IDENTITY_write_private_key_to_buffer (&zm->zone, 306 GNUNET_IDENTITY_write_private_key_to_buffer (&zm->zone,
309 &sm[1], 307 &sm[1],
310 zm->key_len); 308 zm->key_len);
311 sm->key_len = htonl (zm->key_len); 309 sm->key_len = htons (zm->key_len);
312 sm->filter = htons (zm->filter); 310 sm->filter = htons (zm->filter);
313 GNUNET_MQ_send (zm->mq, env); 311 GNUNET_MQ_send (zm->mq, env);
314} 312}
diff --git a/src/namestore/perf_namestore_api_import.c b/src/namestore/perf_namestore_api_import.c
index 4452de16c..cde5eaad5 100644
--- a/src/namestore/perf_namestore_api_import.c
+++ b/src/namestore/perf_namestore_api_import.c
@@ -26,7 +26,6 @@
26#include "gnunet_namestore_service.h" 26#include "gnunet_namestore_service.h"
27#include "gnunet_testing_lib.h" 27#include "gnunet_testing_lib.h"
28#include "namestore.h" 28#include "namestore.h"
29#include "gnunet_dnsparser_lib.h"
30 29
31#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 30#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
32 31
diff --git a/src/namestore/perf_namestore_api_zone_iteration.c b/src/namestore/perf_namestore_api_zone_iteration.c
index 33868784f..0e0b6d93b 100644
--- a/src/namestore/perf_namestore_api_zone_iteration.c
+++ b/src/namestore/perf_namestore_api_zone_iteration.c
@@ -26,7 +26,6 @@
26#include "gnunet_namestore_service.h" 26#include "gnunet_namestore_service.h"
27#include "gnunet_testing_lib.h" 27#include "gnunet_testing_lib.h"
28#include "namestore.h" 28#include "namestore.h"
29#include "gnunet_dnsparser_lib.h"
30 29
31#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 30#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
32 31
diff --git a/src/namestore/plugin_namestore_postgres.c b/src/namestore/plugin_namestore_postgres.c
index d453bc977..de819f196 100644
--- a/src/namestore/plugin_namestore_postgres.c
+++ b/src/namestore/plugin_namestore_postgres.c
@@ -45,165 +45,118 @@ struct Plugin
45 const struct GNUNET_CONFIGURATION_Handle *cfg; 45 const struct GNUNET_CONFIGURATION_Handle *cfg;
46 46
47 /** 47 /**
48 * Database is prepared and ready 48 * Postgres database handle.
49 */ 49 */
50 int ready; 50 struct GNUNET_PQ_Context *dbh;
51 51
52 /** 52 /**
53 * Postgres database handle. 53 * Database is prepared and ready
54 */ 54 */
55 struct GNUNET_PQ_Context *dbh; 55 bool ready;
56}; 56};
57 57
58 58
59/** 59/**
60 * Initialize the database connections and associated 60 * Initialize the database connections and associated data structures (create
61 * data structures (create tables and indices 61 * tables and indices as needed as well).
62 * as needed as well).
63 * 62 *
64 * @param plugin the plugin context (state for this module) 63 * @param cls the plugin context (state for this module)
65 * @return #GNUNET_OK on success 64 * @return #GNUNET_OK on success
66 */ 65 */
67static int 66static enum GNUNET_GenericReturnValue
68init_database (struct Plugin *plugin, char **emsg, int drop) 67namestore_postgres_create_tables (void *cls)
69{ 68{
70 struct GNUNET_PQ_ExecuteStatement es_temporary = 69 struct Plugin *plugin = cls;
71 GNUNET_PQ_make_execute ( 70 struct GNUNET_PQ_Context *dbh;
72 "CREATE TEMPORARY TABLE ns098records ("
73 " seq BIGSERIAL PRIMARY KEY,"
74 " zone_private_key BYTEA NOT NULL DEFAULT '',"
75 " pkey BYTEA DEFAULT '',"
76 " rvalue BYTEA NOT NULL DEFAULT '',"
77 " record_count INTEGER NOT NULL DEFAULT 0,"
78 " record_data BYTEA NOT NULL DEFAULT '',"
79 " label TEXT NOT NULL DEFAULT '',"
80 " CONSTRAINT zl UNIQUE (zone_private_key,label)"
81 ")");
82 struct GNUNET_PQ_ExecuteStatement es_default =
83 GNUNET_PQ_make_execute ("CREATE TABLE ns098records ("
84 " seq BIGSERIAL PRIMARY KEY,"
85 " zone_private_key BYTEA NOT NULL DEFAULT '',"
86 " pkey BYTEA DEFAULT '',"
87 " rvalue BYTEA NOT NULL DEFAULT '',"
88 " record_count INTEGER NOT NULL DEFAULT 0,"
89 " record_data BYTEA NOT NULL DEFAULT '',"
90 " label TEXT NOT NULL DEFAULT '',"
91 " CONSTRAINT zl UNIQUE (zone_private_key,label)"
92 ")");
93 const struct GNUNET_PQ_ExecuteStatement *cr;
94 struct GNUNET_PQ_ExecuteStatement sc = GNUNET_PQ_EXECUTE_STATEMENT_END;
95 struct GNUNET_PQ_ExecuteStatement es_drop =
96 GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS ns098records");
97 if (GNUNET_YES ==
98 GNUNET_CONFIGURATION_get_value_yesno (plugin->cfg,
99 "namestore-postgres",
100 "TEMPORARY_TABLE"))
101 cr = &es_temporary;
102 else
103 cr = &es_default;
104 71
105 if (GNUNET_YES == 72 dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg,
106 GNUNET_CONFIGURATION_get_value_yesno (plugin->cfg, 73 "namestore-postgres",
107 "namestore-postgres", 74 "namestore-",
108 "ASYNC_COMMIT")) 75 NULL,
109 sc = GNUNET_PQ_make_try_execute ("SET synchronous_commit TO off"); 76 NULL);
77 if (NULL == dbh)
78 return GNUNET_SYSERR;
79 GNUNET_PQ_disconnect (dbh);
80 return GNUNET_OK;
81}
110 82
83
84/**
85 * Drop existing namestore tables.
86 *
87 * @param cls the plugin context (state for this module)
88 * @return #GNUNET_OK on success
89 */
90static enum GNUNET_GenericReturnValue
91namestore_postgres_drop_tables (void *cls)
92{
93 struct Plugin *plugin = cls;
94 struct GNUNET_PQ_Context *dbh;
95 enum GNUNET_GenericReturnValue ret;
96
97 dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg,
98 "namestore-postgres",
99 NULL,
100 NULL,
101 NULL);
102 if (NULL == dbh)
111 { 103 {
112 struct GNUNET_PQ_ExecuteStatement es[] = { 104 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
113 *cr, 105 "Failed to connect to database\n");
114 GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_pkey_reverse "
115 "ON ns098records (zone_private_key,pkey)"),
116 GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_pkey_iter "
117 "ON ns098records (zone_private_key,seq)"),
118 GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_label "
119 "ON ns098records (label)"),
120 GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS zone_label "
121 "ON ns098records (zone_private_key,label)"),
122 sc,
123 GNUNET_PQ_EXECUTE_STATEMENT_END
124 };
125 struct GNUNET_PQ_ExecuteStatement es_alt[] = {
126 es_drop,
127 *cr,
128 GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_pkey_reverse "
129 "ON ns098records (zone_private_key,pkey)"),
130 GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_pkey_iter "
131 "ON ns098records (zone_private_key,seq)"),
132 GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS ir_label "
133 "ON ns098records (label)"),
134 GNUNET_PQ_make_try_execute ("CREATE INDEX IF NOT EXISTS zone_label "
135 "ON ns098records (zone_private_key,label)"),
136 sc,
137 GNUNET_PQ_EXECUTE_STATEMENT_END
138 };
139 if (GNUNET_NO == drop)
140 {
141 plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg,
142 "namestore-postgres",
143 NULL,
144 es,
145 NULL);
146 }
147 else
148 {
149 plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg,
150 "namestore-postgres",
151 NULL,
152 es_alt,
153 NULL);
154 }
155 }
156 if (NULL == plugin->dbh)
157 {
158 *emsg = GNUNET_strdup ("Failed to connect to PQ database");
159 return GNUNET_SYSERR; 106 return GNUNET_SYSERR;
160 } 107 }
161 GNUNET_PQ_disconnect (plugin->dbh); 108 ret = GNUNET_PQ_exec_sql (dbh,
162 plugin->dbh = NULL; 109 "namestore-drop");
163 return GNUNET_OK; 110 GNUNET_PQ_disconnect (dbh);
111 return ret;
164} 112}
165 113
166 114
167static int 115static enum GNUNET_GenericReturnValue
168database_prepare (struct Plugin *plugin) 116database_prepare (struct Plugin *plugin)
169{ 117{
170 enum GNUNET_GenericReturnValue ret; 118 enum GNUNET_GenericReturnValue ret;
171 if (GNUNET_YES == plugin->ready) 119
120 if (plugin->ready)
172 return GNUNET_OK; 121 return GNUNET_OK;
173 struct GNUNET_PQ_PreparedStatement ps[] = { 122 {
174 GNUNET_PQ_make_prepare ("store_records", 123 struct GNUNET_PQ_PreparedStatement ps[] = {
175 "INSERT INTO ns098records" 124 GNUNET_PQ_make_prepare ("store_records",
176 " (zone_private_key, pkey, rvalue, record_count, record_data, label)" 125 "INSERT INTO namestore.ns098records"
177 " VALUES ($1, $2, $3, $4, $5, $6)" 126 " (zone_private_key, pkey, rvalue, record_count, record_data, label)"
178 " ON CONFLICT ON CONSTRAINT zl" 127 " VALUES ($1, $2, $3, $4, $5, $6)"
179 " DO UPDATE" 128 " ON CONFLICT ON CONSTRAINT zl"
180 " SET pkey=$2,rvalue=$3,record_count=$4,record_data=$5" 129 " DO UPDATE"
181 " WHERE ns098records.zone_private_key = $1" 130 " SET pkey=$2,rvalue=$3,record_count=$4,record_data=$5"
182 " AND ns098records.label = $6"), 131 " WHERE ns098records.zone_private_key = $1"
183 GNUNET_PQ_make_prepare ("delete_records", 132 " AND ns098records.label = $6"),
184 "DELETE FROM ns098records " 133 GNUNET_PQ_make_prepare ("delete_records",
185 "WHERE zone_private_key=$1 AND label=$2"), 134 "DELETE FROM namestore.ns098records "
186 GNUNET_PQ_make_prepare ("zone_to_name", 135 "WHERE zone_private_key=$1 AND label=$2"),
187 "SELECT seq,record_count,record_data,label FROM ns098records" 136 GNUNET_PQ_make_prepare ("zone_to_name",
188 " WHERE zone_private_key=$1 AND pkey=$2"), 137 "SELECT seq,record_count,record_data,label FROM namestore.ns098records"
189 GNUNET_PQ_make_prepare ("iterate_zone", 138 " WHERE zone_private_key=$1 AND pkey=$2"),
190 "SELECT seq,record_count,record_data,label FROM ns098records " 139 GNUNET_PQ_make_prepare ("iterate_zone",
191 "WHERE zone_private_key=$1 AND seq > $2 ORDER BY seq ASC LIMIT $3"), 140 "SELECT seq,record_count,record_data,label FROM namestore.ns098records "
192 GNUNET_PQ_make_prepare ("iterate_all_zones", 141 "WHERE zone_private_key=$1 AND seq > $2 ORDER BY seq ASC LIMIT $3"),
193 "SELECT seq,record_count,record_data,label,zone_private_key" 142 GNUNET_PQ_make_prepare ("iterate_all_zones",
194 " FROM ns098records WHERE seq > $1 ORDER BY seq ASC LIMIT $2"), 143 "SELECT seq,record_count,record_data,label,zone_private_key"
195 GNUNET_PQ_make_prepare ("lookup_label", 144 " FROM namestore.ns098records WHERE seq > $1 ORDER BY seq ASC LIMIT $2"),
196 "SELECT seq,record_count,record_data,label " 145 GNUNET_PQ_make_prepare ("lookup_label",
197 "FROM ns098records WHERE zone_private_key=$1 AND label=$2"), 146 "SELECT seq,record_count,record_data,label "
198 GNUNET_PQ_make_prepare ("edit_set", 147 "FROM namestore.ns098records WHERE zone_private_key=$1 AND label=$2"),
199 "SELECT seq,record_count,record_data,label " 148 GNUNET_PQ_make_prepare ("edit_set",
200 "FROM ns098records WHERE zone_private_key=$1 AND label=$2 FOR UPDATE NOWAIT"), 149 "SELECT seq,record_count,record_data,label "
201 GNUNET_PQ_PREPARED_STATEMENT_END 150 "FROM namestore.ns098records WHERE zone_private_key=$1 AND label=$2 FOR UPDATE NOWAIT"),
202 }; 151 GNUNET_PQ_PREPARED_STATEMENT_END
203 ret = GNUNET_PQ_prepare_statements (plugin->dbh, ps); 152 };
153
154 ret = GNUNET_PQ_prepare_statements (plugin->dbh,
155 ps);
156 }
204 if (GNUNET_OK != ret) 157 if (GNUNET_OK != ret)
205 return ret; 158 return ret;
206 plugin->ready = GNUNET_YES; 159 plugin->ready = true;
207 return GNUNET_OK; 160 return GNUNET_OK;
208} 161}
209 162
@@ -219,32 +172,37 @@ database_prepare (struct Plugin *plugin)
219static enum GNUNET_GenericReturnValue 172static enum GNUNET_GenericReturnValue
220database_connect (struct Plugin *plugin) 173database_connect (struct Plugin *plugin)
221{ 174{
222 char *emsg; 175 struct GNUNET_PQ_ExecuteStatement ess[] = {
176 GNUNET_PQ_make_try_execute ("SET synchronous_commit TO off"),
177 GNUNET_PQ_EXECUTE_STATEMENT_END
178 };
179 struct GNUNET_PQ_ExecuteStatement *es;
180
181 if (GNUNET_YES ==
182 GNUNET_CONFIGURATION_get_value_yesno (plugin->cfg,
183 "namestore-postgres",
184 "ASYNC_COMMIT"))
185 es = &ess[0];
186 else
187 es = &ess[1];
223 188
224 if (GNUNET_YES == 189 if (GNUNET_YES ==
225 GNUNET_CONFIGURATION_get_value_yesno (plugin->cfg, 190 GNUNET_CONFIGURATION_get_value_yesno (plugin->cfg,
226 "namestore-postgres", 191 "namestore-postgres",
227 "INIT_ON_CONNECT")) 192 "INIT_ON_CONNECT"))
228 { 193 {
229 /**
230 * Gracefully fail as this should not be a critical error if the
231 * database is already created
232 */
233 if (GNUNET_OK != 194 if (GNUNET_OK !=
234 init_database (plugin, 195 namestore_postgres_create_tables (plugin))
235 &emsg,
236 GNUNET_NO))
237 { 196 {
238 LOG (GNUNET_ERROR_TYPE_DEBUG, 197 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
239 "Failed to initialize database on connect: `%s'\n", 198 "Failed to create tables\n");
240 emsg); 199 return GNUNET_SYSERR;
241 GNUNET_free (emsg);
242 } 200 }
243 } 201 }
244 plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg, 202 plugin->dbh = GNUNET_PQ_connect_with_cfg (plugin->cfg,
245 "namestore-postgres", 203 "namestore-postgres",
246 NULL, 204 NULL,
247 NULL, 205 es,
248 NULL); 206 NULL);
249 if (NULL == plugin->dbh) 207 if (NULL == plugin->dbh)
250 return GNUNET_SYSERR; 208 return GNUNET_SYSERR;
@@ -263,7 +221,7 @@ database_connect (struct Plugin *plugin)
263 * @param rd array of records with data to store 221 * @param rd array of records with data to store
264 * @return #GNUNET_OK on success, else #GNUNET_SYSERR 222 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
265 */ 223 */
266static int 224static enum GNUNET_GenericReturnValue
267namestore_postgres_store_records (void *cls, 225namestore_postgres_store_records (void *cls,
268 const struct 226 const struct
269 GNUNET_IDENTITY_PrivateKey *zone_key, 227 GNUNET_IDENTITY_PrivateKey *zone_key,
@@ -495,7 +453,7 @@ parse_result_call_iterator (void *cls,
495 * @param method the method to use "lookup_record" or "edit_set" 453 * @param method the method to use "lookup_record" or "edit_set"
496 * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR 454 * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR
497 */ 455 */
498static int 456static enum GNUNET_GenericReturnValue
499lookup_records (void *cls, 457lookup_records (void *cls,
500 const struct 458 const struct
501 GNUNET_IDENTITY_PrivateKey *zone, 459 GNUNET_IDENTITY_PrivateKey *zone,
@@ -545,7 +503,7 @@ lookup_records (void *cls,
545 * @param iter_cls closure for @a iter 503 * @param iter_cls closure for @a iter
546 * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR 504 * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR
547 */ 505 */
548static int 506static enum GNUNET_GenericReturnValue
549namestore_postgres_lookup_records (void *cls, 507namestore_postgres_lookup_records (void *cls,
550 const struct 508 const struct
551 GNUNET_IDENTITY_PrivateKey *zone, 509 GNUNET_IDENTITY_PrivateKey *zone,
@@ -591,7 +549,7 @@ namestore_postgres_edit_records (void *cls,
591 * @param iter_cls closure for @a iter 549 * @param iter_cls closure for @a iter
592 * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, #GNUNET_SYSERR on error 550 * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, #GNUNET_SYSERR on error
593 */ 551 */
594static int 552static enum GNUNET_GenericReturnValue
595namestore_postgres_iterate_records (void *cls, 553namestore_postgres_iterate_records (void *cls,
596 const struct 554 const struct
597 GNUNET_IDENTITY_PrivateKey *zone, 555 GNUNET_IDENTITY_PrivateKey *zone,
@@ -659,7 +617,7 @@ namestore_postgres_iterate_records (void *cls,
659 * @param iter_cls closure for @a iter 617 * @param iter_cls closure for @a iter
660 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error 618 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
661 */ 619 */
662static int 620static enum GNUNET_GenericReturnValue
663namestore_postgres_zone_to_name (void *cls, 621namestore_postgres_zone_to_name (void *cls,
664 const struct 622 const struct
665 GNUNET_IDENTITY_PrivateKey *zone, 623 GNUNET_IDENTITY_PrivateKey *zone,
@@ -760,30 +718,6 @@ namestore_postgres_transaction_commit (void *cls,
760} 718}
761 719
762 720
763static enum GNUNET_GenericReturnValue
764namestore_postgres_initialize_database (void *cls,
765 char **emsg)
766{
767 int ret;
768 ret = init_database (cls, emsg, GNUNET_NO);
769 if (GNUNET_SYSERR == ret)
770 return ret;
771 return database_connect (cls);
772}
773
774
775static enum GNUNET_GenericReturnValue
776namestore_postgres_reset_database (void *cls,
777 char **emsg)
778{
779 int ret;
780 ret = init_database (cls, emsg, GNUNET_YES);
781 if (GNUNET_SYSERR == ret)
782 return ret;
783 return database_connect (cls);
784}
785
786
787/** 721/**
788 * Shutdown database connection and associate data 722 * Shutdown database connection and associate data
789 * structures. 723 * structures.
@@ -821,6 +755,8 @@ libgnunet_plugin_namestore_postgres_init (void *cls)
821 } 755 }
822 api = GNUNET_new (struct GNUNET_NAMESTORE_PluginFunctions); 756 api = GNUNET_new (struct GNUNET_NAMESTORE_PluginFunctions);
823 api->cls = plugin; 757 api->cls = plugin;
758 api->create_tables = &namestore_postgres_create_tables;
759 api->drop_tables = &namestore_postgres_drop_tables;
824 api->store_records = &namestore_postgres_store_records; 760 api->store_records = &namestore_postgres_store_records;
825 api->iterate_records = &namestore_postgres_iterate_records; 761 api->iterate_records = &namestore_postgres_iterate_records;
826 api->zone_to_name = &namestore_postgres_zone_to_name; 762 api->zone_to_name = &namestore_postgres_zone_to_name;
@@ -828,8 +764,6 @@ libgnunet_plugin_namestore_postgres_init (void *cls)
828 api->transaction_begin = &namestore_postgres_transaction_begin; 764 api->transaction_begin = &namestore_postgres_transaction_begin;
829 api->transaction_commit = &namestore_postgres_transaction_commit; 765 api->transaction_commit = &namestore_postgres_transaction_commit;
830 api->transaction_rollback = &namestore_postgres_transaction_rollback; 766 api->transaction_rollback = &namestore_postgres_transaction_rollback;
831 api->initialize_database = &namestore_postgres_initialize_database;
832 api->reset_database = &namestore_postgres_reset_database;
833 api->edit_records = &namestore_postgres_edit_records; 767 api->edit_records = &namestore_postgres_edit_records;
834 LOG (GNUNET_ERROR_TYPE_INFO, 768 LOG (GNUNET_ERROR_TYPE_INFO,
835 "Postgres namestore plugin running\n"); 769 "Postgres namestore plugin running\n");
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c
index 1602da4ab..15a6586b5 100644
--- a/src/namestore/plugin_namestore_sqlite.c
+++ b/src/namestore/plugin_namestore_sqlite.c
@@ -50,13 +50,14 @@
50 * a failure of the command 'cmd' on file 'filename' 50 * a failure of the command 'cmd' on file 'filename'
51 * with the message given by strerror(errno). 51 * with the message given by strerror(errno).
52 */ 52 */
53#define LOG_SQLITE(db, level, cmd) do { GNUNET_log_from (level, \ 53#define LOG_SQLITE(db, level, cmd) do { \
54 "namestore-sqlite", _ ( \ 54 GNUNET_log_from (level, \
55 "`%s' failed at %s:%d with error: %s\n"), \ 55 "namestore-sqlite", _ ( \
56 cmd, \ 56 "`%s' failed at %s:%d with error: %s\n"), \
57 __FILE__, __LINE__, \ 57 cmd, \
58 sqlite3_errmsg ( \ 58 __FILE__, __LINE__, \
59 db->dbh)); \ 59 sqlite3_errmsg ( \
60 db->dbh)); \
60} while (0) 61} while (0)
61 62
62#define LOG(kind, ...) GNUNET_log_from (kind, "namestore-sqlite", __VA_ARGS__) 63#define LOG(kind, ...) GNUNET_log_from (kind, "namestore-sqlite", __VA_ARGS__)
@@ -75,9 +76,9 @@ struct Plugin
75 char *fn; 76 char *fn;
76 77
77 /** 78 /**
78 * Statements prepared, we are ready to go if GNUNET_YES 79 * Statements prepared, we are ready to go if true.
79 */ 80 */
80 int ready; 81 bool ready;
81 82
82 /** 83 /**
83 * Native SQLite database handle. 84 * Native SQLite database handle.
@@ -124,10 +125,10 @@ struct Plugin
124 * @param plugin the plugin context (state for this module) 125 * @param plugin the plugin context (state for this module)
125 * @return #GNUNET_OK on success 126 * @return #GNUNET_OK on success
126 */ 127 */
127static int 128static enum GNUNET_GenericReturnValue
128database_prepare (struct Plugin *plugin) 129database_prepare (struct Plugin *plugin)
129{ 130{
130 if (GNUNET_YES == plugin->ready) 131 if (plugin->ready)
131 return GNUNET_OK; 132 return GNUNET_OK;
132 struct GNUNET_SQ_ExecuteStatement es[] = { 133 struct GNUNET_SQ_ExecuteStatement es[] = {
133 GNUNET_SQ_make_try_execute ("PRAGMA temp_store=MEMORY"), 134 GNUNET_SQ_make_try_execute ("PRAGMA temp_store=MEMORY"),
@@ -264,7 +265,7 @@ database_shutdown (struct Plugin *plugin)
264 * @param rd array of records with data to store 265 * @param rd array of records with data to store
265 * @return #GNUNET_OK on success, else #GNUNET_SYSERR 266 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
266 */ 267 */
267static int 268static enum GNUNET_GenericReturnValue
268namestore_sqlite_store_records (void *cls, 269namestore_sqlite_store_records (void *cls,
269 const struct 270 const struct
270 GNUNET_IDENTITY_PrivateKey *zone_key, 271 GNUNET_IDENTITY_PrivateKey *zone_key,
@@ -421,7 +422,7 @@ namestore_sqlite_store_records (void *cls,
421 * @param iter_cls closure for @a iter 422 * @param iter_cls closure for @a iter
422 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error 423 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
423 */ 424 */
424static int 425static enum GNUNET_GenericReturnValue
425get_records_and_call_iterator (struct Plugin *plugin, 426get_records_and_call_iterator (struct Plugin *plugin,
426 sqlite3_stmt *stmt, 427 sqlite3_stmt *stmt,
427 const struct 428 const struct
@@ -539,7 +540,7 @@ get_records_and_call_iterator (struct Plugin *plugin,
539 * @param iter_cls closure for @a iter 540 * @param iter_cls closure for @a iter
540 * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR 541 * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR
541 */ 542 */
542static int 543static enum GNUNET_GenericReturnValue
543namestore_sqlite_lookup_records (void *cls, 544namestore_sqlite_lookup_records (void *cls,
544 const struct 545 const struct
545 GNUNET_IDENTITY_PrivateKey *zone, 546 GNUNET_IDENTITY_PrivateKey *zone,
@@ -591,7 +592,7 @@ namestore_sqlite_lookup_records (void *cls,
591 * @param iter_cls closure for @a iter 592 * @param iter_cls closure for @a iter
592 * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, #GNUNET_SYSERR on error 593 * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, #GNUNET_SYSERR on error
593 */ 594 */
594static int 595static enum GNUNET_GenericReturnValue
595namestore_sqlite_iterate_records (void *cls, 596namestore_sqlite_iterate_records (void *cls,
596 const struct 597 const struct
597 GNUNET_IDENTITY_PrivateKey *zone, 598 GNUNET_IDENTITY_PrivateKey *zone,
@@ -659,7 +660,7 @@ namestore_sqlite_iterate_records (void *cls,
659 * @param iter_cls closure for @a iter 660 * @param iter_cls closure for @a iter
660 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error 661 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
661 */ 662 */
662static int 663static enum GNUNET_GenericReturnValue
663namestore_sqlite_zone_to_name (void *cls, 664namestore_sqlite_zone_to_name (void *cls,
664 const struct GNUNET_IDENTITY_PrivateKey *zone, 665 const struct GNUNET_IDENTITY_PrivateKey *zone,
665 const struct 666 const struct
@@ -697,6 +698,7 @@ namestore_sqlite_zone_to_name (void *cls,
697 iter_cls); 698 iter_cls);
698} 699}
699 700
701
700/** 702/**
701 * Begin a transaction for a client. 703 * Begin a transaction for a client.
702 * This locks the database. SQLite is unable to discern between different 704 * This locks the database. SQLite is unable to discern between different
@@ -726,6 +728,7 @@ namestore_sqlite_transaction_begin (void *cls,
726 return (SQLITE_OK != rc) ? GNUNET_SYSERR : GNUNET_YES; 728 return (SQLITE_OK != rc) ? GNUNET_SYSERR : GNUNET_YES;
727} 729}
728 730
731
729/** 732/**
730 * Commit a transaction for a client. 733 * Commit a transaction for a client.
731 * This releases the lock on the database. 734 * This releases the lock on the database.
@@ -753,6 +756,7 @@ namestore_sqlite_transaction_rollback (void *cls,
753 return (SQLITE_OK != rc) ? GNUNET_SYSERR : GNUNET_YES; 756 return (SQLITE_OK != rc) ? GNUNET_SYSERR : GNUNET_YES;
754} 757}
755 758
759
756/** 760/**
757 * Roll back a transaction for a client. 761 * Roll back a transaction for a client.
758 * This releases the lock on the database. 762 * This releases the lock on the database.
@@ -780,14 +784,11 @@ namestore_sqlite_transaction_commit (void *cls,
780 return (SQLITE_OK != rc) ? GNUNET_SYSERR : GNUNET_YES; 784 return (SQLITE_OK != rc) ? GNUNET_SYSERR : GNUNET_YES;
781} 785}
782 786
787
783static enum GNUNET_GenericReturnValue 788static enum GNUNET_GenericReturnValue
784init_database (void *cls, char **emsg, int drop) 789namestore_sqlite_create_tables (void *cls)
785{ 790{
786 struct Plugin *plugin = cls; 791 struct Plugin *plugin = cls;
787 struct GNUNET_SQ_ExecuteStatement es_drop[] = {
788 GNUNET_SQ_make_execute ("DROP TABLE IF EXISTS ns098records"),
789 GNUNET_SQ_EXECUTE_STATEMENT_END
790 };
791 struct GNUNET_SQ_ExecuteStatement es[] = { 792 struct GNUNET_SQ_ExecuteStatement es[] = {
792 GNUNET_SQ_make_try_execute ("PRAGMA temp_store=MEMORY"), 793 GNUNET_SQ_make_try_execute ("PRAGMA temp_store=MEMORY"),
793 GNUNET_SQ_make_try_execute ("PRAGMA synchronous=NORMAL"), 794 GNUNET_SQ_make_try_execute ("PRAGMA synchronous=NORMAL"),
@@ -797,7 +798,7 @@ init_database (void *cls, char **emsg, int drop)
797 GNUNET_SQ_make_try_execute ("PRAGMA locking_mode=NORMAL"), 798 GNUNET_SQ_make_try_execute ("PRAGMA locking_mode=NORMAL"),
798 GNUNET_SQ_make_try_execute ("PRAGMA journal_mode=WAL"), 799 GNUNET_SQ_make_try_execute ("PRAGMA journal_mode=WAL"),
799 GNUNET_SQ_make_try_execute ("PRAGMA page_size=4092"), 800 GNUNET_SQ_make_try_execute ("PRAGMA page_size=4092"),
800 GNUNET_SQ_make_execute ("CREATE TABLE ns098records (" 801 GNUNET_SQ_make_execute ("CREATE TABLE IF NOT EXISTS ns098records ("
801 " uid INTEGER PRIMARY KEY," 802 " uid INTEGER PRIMARY KEY,"
802 " zone_private_key BLOB NOT NULL," 803 " zone_private_key BLOB NOT NULL,"
803 " pkey BLOB," 804 " pkey BLOB,"
@@ -812,39 +813,42 @@ init_database (void *cls, char **emsg, int drop)
812 "ON ns098records (zone_private_key,uid)"), 813 "ON ns098records (zone_private_key,uid)"),
813 GNUNET_SQ_EXECUTE_STATEMENT_END 814 GNUNET_SQ_EXECUTE_STATEMENT_END
814 }; 815 };
815 if ((GNUNET_YES == drop) && 816
816 (GNUNET_OK != GNUNET_SQ_exec_statements (plugin->dbh,
817 es_drop)))
818 {
819 GNUNET_asprintf (emsg,
820 _ ("Failed to drop database with: `%s'\n"),
821 sqlite3_errmsg (plugin->dbh));
822 return GNUNET_SYSERR;
823 }
824 if (GNUNET_OK != 817 if (GNUNET_OK !=
825 GNUNET_SQ_exec_statements (plugin->dbh, 818 GNUNET_SQ_exec_statements (plugin->dbh,
826 es)) 819 es))
827 { 820 {
828 GNUNET_asprintf (emsg, 821 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
829 _ ("Failed to setup database with: `%s'\n"), 822 "Failed to setup database with: `%s'\n",
830 sqlite3_errmsg (plugin->dbh)); 823 sqlite3_errmsg (plugin->dbh));
831 return GNUNET_SYSERR; 824 return GNUNET_SYSERR;
832 } 825 }
833 return GNUNET_OK; 826 return GNUNET_OK;
834} 827}
835 828
836enum GNUNET_GenericReturnValue
837namestore_sqlite_initialize_database (void *cls, char **emsg)
838{
839 return init_database (cls, emsg, GNUNET_NO);
840}
841 829
842enum GNUNET_GenericReturnValue 830static enum GNUNET_GenericReturnValue
843namestore_sqlite_reset_database (void *cls, char **emsg) 831namestore_sqlite_drop_tables (void *cls)
844{ 832{
845 return init_database (cls, emsg, GNUNET_YES); 833 struct Plugin *plugin = cls;
834 struct GNUNET_SQ_ExecuteStatement es_drop[] = {
835 GNUNET_SQ_make_execute ("DROP TABLE IF EXISTS ns098records"),
836 GNUNET_SQ_EXECUTE_STATEMENT_END
837 };
838
839 if (GNUNET_OK !=
840 GNUNET_SQ_exec_statements (plugin->dbh,
841 es_drop))
842 {
843 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
844 "Failed to drop database with: `%s'\n",
845 sqlite3_errmsg (plugin->dbh));
846 return GNUNET_SYSERR;
847 }
848 return GNUNET_OK;
846} 849}
847 850
851
848/** 852/**
849 * Initialize the database connections and associated 853 * Initialize the database connections and associated
850 * data structures (create tables and indices 854 * data structures (create tables and indices
@@ -853,11 +857,10 @@ namestore_sqlite_reset_database (void *cls, char **emsg)
853 * @param plugin the plugin context (state for this module) 857 * @param plugin the plugin context (state for this module)
854 * @return #GNUNET_OK on success 858 * @return #GNUNET_OK on success
855 */ 859 */
856static int 860static enum GNUNET_GenericReturnValue
857database_connect (struct Plugin *plugin) 861database_connect (struct Plugin *plugin)
858{ 862{
859 char *sqlite_filename; 863 char *sqlite_filename;
860 char *emsg;
861 864
862 if (GNUNET_OK != 865 if (GNUNET_OK !=
863 GNUNET_CONFIGURATION_get_value_filename (plugin->cfg, 866 GNUNET_CONFIGURATION_get_value_filename (plugin->cfg,
@@ -902,17 +905,9 @@ database_connect (struct Plugin *plugin)
902 "namestore-sqlite", 905 "namestore-sqlite",
903 "INIT_ON_CONNECT")) 906 "INIT_ON_CONNECT"))
904 { 907 {
905 /** 908 if (GNUNET_OK !=
906 * Gracefully fail as this should not be a critical error if the 909 namestore_sqlite_create_tables (plugin))
907 * database is already created 910 return GNUNET_SYSERR;
908 */
909 if (GNUNET_OK != init_database (plugin, &emsg, GNUNET_NO))
910 {
911 LOG (GNUNET_ERROR_TYPE_DEBUG,
912 "Failed to initialize database on connect: `%s'\n",
913 emsg);
914 GNUNET_free (emsg);
915 }
916 } 911 }
917 return GNUNET_OK; 912 return GNUNET_OK;
918} 913}
@@ -949,8 +944,8 @@ libgnunet_plugin_namestore_sqlite_init (void *cls)
949 api->transaction_begin = &namestore_sqlite_transaction_begin; 944 api->transaction_begin = &namestore_sqlite_transaction_begin;
950 api->transaction_commit = &namestore_sqlite_transaction_commit; 945 api->transaction_commit = &namestore_sqlite_transaction_commit;
951 api->transaction_rollback = &namestore_sqlite_transaction_rollback; 946 api->transaction_rollback = &namestore_sqlite_transaction_rollback;
952 api->initialize_database = &namestore_sqlite_initialize_database; 947 api->create_tables = &namestore_sqlite_create_tables;
953 api->reset_database = &namestore_sqlite_reset_database; 948 api->drop_tables = &namestore_sqlite_drop_tables;
954 /** 949 /**
955 * NOTE: Since SQlite does not support SELECT ... FOR UPDATE this is 950 * NOTE: Since SQlite does not support SELECT ... FOR UPDATE this is
956 * just an alias to lookup_records. The BEGIN IMMEDIATE mechanic currently 951 * just an alias to lookup_records. The BEGIN IMMEDIATE mechanic currently
diff --git a/src/namestore/test_common.c b/src/namestore/test_common.c
index fbcb51399..e35c76075 100644
--- a/src/namestore/test_common.c
+++ b/src/namestore/test_common.c
@@ -21,6 +21,7 @@
21 * @file namestore/test_common.c 21 * @file namestore/test_common.c
22 * @brief common functions for testcase setup 22 * @brief common functions for testcase setup
23 */ 23 */
24#include "platform.h"
24#include <gnunet_namestore_plugin.h> 25#include <gnunet_namestore_plugin.h>
25 26
26/** 27/**
@@ -31,35 +32,52 @@ TNC_test_plugin (const char *cfg_name)
31{ 32{
32 char *database; 33 char *database;
33 char *db_lib_name; 34 char *db_lib_name;
34 char *emsg;
35 struct GNUNET_NAMESTORE_PluginFunctions *db; 35 struct GNUNET_NAMESTORE_PluginFunctions *db;
36 struct GNUNET_CONFIGURATION_Handle *cfg; 36 struct GNUNET_CONFIGURATION_Handle *cfg;
37 37
38 cfg = GNUNET_CONFIGURATION_create (); 38 cfg = GNUNET_CONFIGURATION_create ();
39 if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfg_name)) 39 if (GNUNET_OK !=
40 GNUNET_CONFIGURATION_load (cfg,
41 cfg_name))
40 { 42 {
41 GNUNET_break (0); 43 GNUNET_break (0);
42 GNUNET_CONFIGURATION_destroy (cfg); 44 GNUNET_CONFIGURATION_destroy (cfg);
43 return GNUNET_SYSERR; 45 return GNUNET_SYSERR;
44 } 46 }
45 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, 47 if (GNUNET_OK !=
46 "namestore", 48 GNUNET_CONFIGURATION_get_value_string (cfg,
47 "database", 49 "namestore",
48 &database)) 50 "database",
51 &database))
49 { 52 {
50 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n"); 53 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
54 "No database backend configured\n");
51 GNUNET_CONFIGURATION_destroy (cfg); 55 GNUNET_CONFIGURATION_destroy (cfg);
52 return GNUNET_SYSERR; 56 return GNUNET_SYSERR;
53 } 57 }
54 GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_namestore_%s", database); 58 GNUNET_asprintf (&db_lib_name,
59 "libgnunet_plugin_namestore_%s",
60 database);
55 GNUNET_free (database); 61 GNUNET_free (database);
56 db = GNUNET_PLUGIN_load (db_lib_name, (void *) cfg); 62 db = GNUNET_PLUGIN_load (db_lib_name, (void *) cfg);
57 if (NULL != db) 63 if (NULL == db)
64 {
65 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
66 "Failed to load plugin `%s'\n",
67 db_lib_name);
68 }
69 else
58 { 70 {
59 if (GNUNET_OK != db->reset_database (db->cls, &emsg)) 71 if (GNUNET_OK != db->create_tables (db->cls))
60 { 72 {
61 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error resetting database: %s\n", emsg); 73 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
62 GNUNET_free (emsg); 74 "Error creating tables\n");
75 return GNUNET_SYSERR;
76 }
77 if (GNUNET_OK != db->drop_tables (db->cls))
78 {
79 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
80 "Error dropping tables\n");
63 return GNUNET_SYSERR; 81 return GNUNET_SYSERR;
64 } 82 }
65 GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, db)); 83 GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, db));
@@ -71,13 +89,15 @@ TNC_test_plugin (const char *cfg_name)
71 return GNUNET_YES; 89 return GNUNET_YES;
72} 90}
73 91
92
74/** 93/**
75 * General setup logic for starting the tests. Obtains the @a 94 * General setup logic for starting the tests. Obtains the @a
76 * plugin_name and initializes the @a cfg_name. 95 * plugin_name and initializes the @a cfg_name.
77 */ 96 */
78#define SETUP_CFG2(file_template, plugin_name, cfg_name) \ 97#define SETUP_CFG2(file_template, plugin_name, cfg_name) \
79 do \ 98 do \
80 { \ 99 { \
100 GNUNET_log_setup (__FILE__, "WARNING", NULL); \
81 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); \ 101 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); \
82 GNUNET_asprintf (&cfg_name, file_template, plugin_name); \ 102 GNUNET_asprintf (&cfg_name, file_template, plugin_name); \
83 if (! TNC_test_plugin (cfg_name)) \ 103 if (! TNC_test_plugin (cfg_name)) \
@@ -94,6 +114,7 @@ TNC_test_plugin (const char *cfg_name)
94#define SETUP_CFG(plugin_name, cfg_name) \ 114#define SETUP_CFG(plugin_name, cfg_name) \
95 do \ 115 do \
96 { \ 116 { \
117 GNUNET_log_setup (__FILE__, "WARNING", NULL); \
97 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); \ 118 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); \
98 GNUNET_asprintf (&cfg_name, "test_namestore_api_%s.conf", plugin_name); \ 119 GNUNET_asprintf (&cfg_name, "test_namestore_api_%s.conf", plugin_name); \
99 if (! TNC_test_plugin (cfg_name)) \ 120 if (! TNC_test_plugin (cfg_name)) \
diff --git a/src/namestore/test_namestore_api_edit_records.c b/src/namestore/test_namestore_api_edit_records.c
index ee05f498a..fb588f0e1 100644
--- a/src/namestore/test_namestore_api_edit_records.c
+++ b/src/namestore/test_namestore_api_edit_records.c
@@ -24,7 +24,6 @@
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_namestore_service.h" 25#include "gnunet_namestore_service.h"
26#include "gnunet_testing_lib.h" 26#include "gnunet_testing_lib.h"
27#include "gnunet_dnsparser_lib.h"
28 27
29#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 28#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
30 29
@@ -187,7 +186,7 @@ commit_cont_a (void *cls,
187 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 186 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
188 "Name store added record for `%s': %s\n", 187 "Name store added record for `%s': %s\n",
189 name, 188 name,
190 (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); 189 (GNUNET_EC_NONE == ec) ? "SUCCESS" : "FAIL");
191 /** 190 /**
192 * Try again for B 191 * Try again for B
193 */ 192 */
@@ -263,7 +262,7 @@ begin_cont (void *cls,
263{ 262{
264 const char *name = cls; 263 const char *name = cls;
265 264
266 GNUNET_assert (success == GNUNET_YES); 265 GNUNET_assert (GNUNET_EC_NONE == ec);
267 nsqe = GNUNET_NAMESTORE_records_edit (nsh, 266 nsqe = GNUNET_NAMESTORE_records_edit (nsh,
268 &privkey, 267 &privkey,
269 name, 268 name,
@@ -288,7 +287,7 @@ preload_cont (void *cls,
288 GNUNET_break (0); 287 GNUNET_break (0);
289 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 288 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
290 "Namestore could not store record: `%s'\n", 289 "Namestore could not store record: `%s'\n",
291 GNUNET_ErroCode_get_hint (ec)); 290 GNUNET_ErrorCode_get_hint (ec));
292 if (endbadly_task != NULL) 291 if (endbadly_task != NULL)
293 GNUNET_SCHEDULER_cancel (endbadly_task); 292 GNUNET_SCHEDULER_cancel (endbadly_task);
294 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); 293 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
@@ -298,7 +297,7 @@ preload_cont (void *cls,
298 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 297 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
299 "Name store added record for `%s': %s\n", 298 "Name store added record for `%s': %s\n",
300 name, 299 name,
301 (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); 300 (GNUNET_EC_NONE == ec) ? "SUCCESS" : "FAIL");
302 /* We start transaction for A */ 301 /* We start transaction for A */
303 nsqe = GNUNET_NAMESTORE_transaction_begin (nsh, begin_cont, (void *) name); 302 nsqe = GNUNET_NAMESTORE_transaction_begin (nsh, begin_cont, (void *) name);
304 303
diff --git a/src/namestore/test_namestore_api_lookup_nick.c b/src/namestore/test_namestore_api_lookup_nick.c
index 85a7a4025..8fa001196 100644
--- a/src/namestore/test_namestore_api_lookup_nick.c
+++ b/src/namestore/test_namestore_api_lookup_nick.c
@@ -25,7 +25,6 @@
25#include "gnunet_namestore_service.h" 25#include "gnunet_namestore_service.h"
26#include "gnunet_gns_service.h" 26#include "gnunet_gns_service.h"
27#include "gnunet_testing_lib.h" 27#include "gnunet_testing_lib.h"
28#include "gnunet_dnsparser_lib.h"
29 28
30#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 29#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
31 30
diff --git a/src/namestore/test_namestore_api_monitoring.c b/src/namestore/test_namestore_api_monitoring.c
index 018cf89b1..b129c2996 100644
--- a/src/namestore/test_namestore_api_monitoring.c
+++ b/src/namestore/test_namestore_api_monitoring.c
@@ -25,7 +25,6 @@
25#include "gnunet_namestore_service.h" 25#include "gnunet_namestore_service.h"
26#include "gnunet_testing_lib.h" 26#include "gnunet_testing_lib.h"
27#include "namestore.h" 27#include "namestore.h"
28#include "gnunet_dnsparser_lib.h"
29 28
30#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 29#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
31 30
diff --git a/src/namestore/test_namestore_api_monitoring_existing.c b/src/namestore/test_namestore_api_monitoring_existing.c
index 0123613fb..bc03de541 100644
--- a/src/namestore/test_namestore_api_monitoring_existing.c
+++ b/src/namestore/test_namestore_api_monitoring_existing.c
@@ -25,7 +25,6 @@
25#include "gnunet_namestore_service.h" 25#include "gnunet_namestore_service.h"
26#include "gnunet_testing_lib.h" 26#include "gnunet_testing_lib.h"
27#include "namestore.h" 27#include "namestore.h"
28#include "gnunet_dnsparser_lib.h"
29 28
30#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 29#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
31 30
diff --git a/src/namestore/test_namestore_api_remove.c b/src/namestore/test_namestore_api_remove.c
index c6a4549d4..5aab2ebe6 100644
--- a/src/namestore/test_namestore_api_remove.c
+++ b/src/namestore/test_namestore_api_remove.c
@@ -24,7 +24,6 @@
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_namestore_service.h" 25#include "gnunet_namestore_service.h"
26#include "gnunet_testing_lib.h" 26#include "gnunet_testing_lib.h"
27#include "gnunet_dnsparser_lib.h"
28 27
29#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 28#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
30 29
diff --git a/src/namestore/test_namestore_api_store.c b/src/namestore/test_namestore_api_store.c
index f4f1e36d3..d291045e5 100644
--- a/src/namestore/test_namestore_api_store.c
+++ b/src/namestore/test_namestore_api_store.c
@@ -24,7 +24,6 @@
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_namestore_service.h" 25#include "gnunet_namestore_service.h"
26#include "gnunet_testing_lib.h" 26#include "gnunet_testing_lib.h"
27#include "gnunet_dnsparser_lib.h"
28 27
29#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 28#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
30 29
diff --git a/src/namestore/test_namestore_api_store_update.c b/src/namestore/test_namestore_api_store_update.c
index 8f1f33542..bef19385c 100644
--- a/src/namestore/test_namestore_api_store_update.c
+++ b/src/namestore/test_namestore_api_store_update.c
@@ -26,7 +26,6 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_namestore_service.h" 27#include "gnunet_namestore_service.h"
28#include "gnunet_testing_lib.h" 28#include "gnunet_testing_lib.h"
29#include "gnunet_dnsparser_lib.h"
30 29
31#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 30#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
32 31
diff --git a/src/namestore/test_namestore_api_tx_rollback.c b/src/namestore/test_namestore_api_tx_rollback.c
index 3d0884e24..5b4bc6174 100644
--- a/src/namestore/test_namestore_api_tx_rollback.c
+++ b/src/namestore/test_namestore_api_tx_rollback.c
@@ -24,7 +24,6 @@
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_namestore_service.h" 25#include "gnunet_namestore_service.h"
26#include "gnunet_testing_lib.h" 26#include "gnunet_testing_lib.h"
27#include "gnunet_dnsparser_lib.h"
28 27
29#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 28#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
30 29
diff --git a/src/namestore/test_namestore_api_zone_iteration.c b/src/namestore/test_namestore_api_zone_iteration.c
index 6e07f78f2..e072dbef9 100644
--- a/src/namestore/test_namestore_api_zone_iteration.c
+++ b/src/namestore/test_namestore_api_zone_iteration.c
@@ -25,7 +25,6 @@
25#include "gnunet_namestore_service.h" 25#include "gnunet_namestore_service.h"
26#include "gnunet_testing_lib.h" 26#include "gnunet_testing_lib.h"
27#include "namestore.h" 27#include "namestore.h"
28#include "gnunet_dnsparser_lib.h"
29 28
30#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 29#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
31 30
diff --git a/src/namestore/test_namestore_api_zone_iteration_nick.c b/src/namestore/test_namestore_api_zone_iteration_nick.c
index 941d43c28..e371bb312 100644
--- a/src/namestore/test_namestore_api_zone_iteration_nick.c
+++ b/src/namestore/test_namestore_api_zone_iteration_nick.c
@@ -26,7 +26,6 @@
26#include "gnunet_gns_service.h" 26#include "gnunet_gns_service.h"
27#include "gnunet_testing_lib.h" 27#include "gnunet_testing_lib.h"
28#include "namestore.h" 28#include "namestore.h"
29#include "gnunet_dnsparser_lib.h"
30 29
31#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 30#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
32 31
diff --git a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
index daf711c3d..074cd4dbb 100644
--- a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
+++ b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
@@ -26,7 +26,6 @@
26#include "gnunet_namestore_service.h" 26#include "gnunet_namestore_service.h"
27#include "gnunet_testing_lib.h" 27#include "gnunet_testing_lib.h"
28#include "namestore.h" 28#include "namestore.h"
29#include "gnunet_dnsparser_lib.h"
30 29
31#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 30#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
32 31
diff --git a/src/namestore/test_namestore_api_zone_iteration_stop.c b/src/namestore/test_namestore_api_zone_iteration_stop.c
index c51224d91..7efe59648 100644
--- a/src/namestore/test_namestore_api_zone_iteration_stop.c
+++ b/src/namestore/test_namestore_api_zone_iteration_stop.c
@@ -25,7 +25,6 @@
25#include "gnunet_namestore_service.h" 25#include "gnunet_namestore_service.h"
26#include "gnunet_testing_lib.h" 26#include "gnunet_testing_lib.h"
27#include "namestore.h" 27#include "namestore.h"
28#include "gnunet_dnsparser_lib.h"
29 28
30#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 29#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
31 30
diff --git a/src/namestore/test_namestore_api_zone_to_name.c b/src/namestore/test_namestore_api_zone_to_name.c
index c9d781d39..dfdefa039 100644
--- a/src/namestore/test_namestore_api_zone_to_name.c
+++ b/src/namestore/test_namestore_api_zone_to_name.c
@@ -25,7 +25,6 @@
25#include "gnunet_namestore_service.h" 25#include "gnunet_namestore_service.h"
26#include "gnunet_testing_lib.h" 26#include "gnunet_testing_lib.h"
27#include "namestore.h" 27#include "namestore.h"
28#include "gnunet_dnsparser_lib.h"
29 28
30#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 29#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
31 30
diff --git a/src/namestore/test_namestore_put_multiple.sh b/src/namestore/test_namestore_put_multiple.sh
index f33fb1c3a..4c7340440 100644..100755
--- a/src/namestore/test_namestore_put_multiple.sh
+++ b/src/namestore/test_namestore_put_multiple.sh
@@ -24,25 +24,9 @@ if [ 0 -ne $ret ]; then
24 gnunet-identity -C randomtestingid 24 gnunet-identity -C randomtestingid
25fi 25fi
26 26
27function minimize_ttl {
28 ttl=10000000
29 arr=$1
30 # parse each element and update ttl to smallest one
31 for i in "${arr[@]}"
32 do
33 currttl=$(echo -n "$i" | cut -d' ' -f1)
34 if [ "$currttl" -lt "$ttl" ]
35 then
36 ttl=$currttl
37 fi
38
39 done
40 echo "$ttl"
41}
42
43function get_record_type { 27function get_record_type {
44 arr=$1 28 arr=$1
45 typ=$(echo -n "${arr[0]}" | cut -d' ' -f2) 29 typ=$(echo -n "${arr[0]}" | cut -d' ' -f1)
46 echo "$typ" 30 echo "$typ"
47} 31}
48 32
@@ -59,10 +43,14 @@ function testing {
59 typ=$(get_record_type "${records[@]}") 43 typ=$(get_record_type "${records[@]}")
60 for i in "${records[@]}" 44 for i in "${records[@]}"
61 do 45 do
62 recordstring+="-R $i" 46 recordstring+="$i"$'\n'
63 done 47 done
64 #echo "$recordstring" 48 echo "$recordstring"
65 gnunet-namestore -z randomtestingid -n "$label" "$recordstring" 2>&1 /dev/null 49 gnunet-namestore -a -S <<EOF
50$label.randomtestingid:
51 $recordstring
52EOF
53 ret=$?
66 if [ 0 -ne $ret ]; then 54 if [ 0 -ne $ret ]; then
67 echo "failed to add record $label: $recordstring" 55 echo "failed to add record $label: $recordstring"
68 fi 56 fi
@@ -75,26 +63,27 @@ function testing {
75# TEST CASES 63# TEST CASES
76# 1 64# 1
77echo "Testing adding of single A record with -R" 65echo "Testing adding of single A record with -R"
66declare -a arr=('A 1200 [r] 127.0.0.1')
78testing test1 "${arr[@]}" 67testing test1 "${arr[@]}"
79# 2 68# 2
80echo "Testing adding of multiple A records with -R" 69echo "Testing adding of multiple A records with -R"
81declare -a arr=('1200 A n 127.0.0.1' '2400 A n 127.0.0.2') 70declare -a arr=('A 1200 [r] 127.0.0.1' 'A 2400 [r] 127.0.0.2')
82testing test2 "${arr[@]}" 71testing test2 "${arr[@]}"
83# 3 72# 3
84echo "Testing adding of multiple different records with -R" 73echo "Testing adding of multiple different records with -R"
85declare -a arr=('1200 A n 127.0.0.1' '2400 AAAA n 2002::') 74declare -a arr=('A 1200 [r] 127.0.0.1' 'AAAA 2400 [r] 2002::')
86testing test3 "${arr[@]}" 75testing test3 "${arr[@]}"
87# 4 76# 4
88echo "Testing adding of single GNS2DNS record with -R" 77echo "Testing adding of single GNS2DNS record with -R"
89declare -a arr=('86400 GNS2DNS n gnu.org@127.0.0.1') 78declare -a arr=('GNS2DNS 86400 [r] gnu.org@127.0.0.1')
90testing test4 "${arr[@]}" 79testing test4 "${arr[@]}"
91# 5 80# 5
92echo "Testing adding of single GNS2DNS shadow record with -R" 81echo "Testing adding of single GNS2DNS shadow record with -R"
93declare -a arr=('86409 GNS2DNS s gnu.org@127.0.0.250') 82declare -a arr=('GNS2DNS 86409 [rs] gnu.org@127.0.0.250')
94testing test5 "${arr[@]}" 83testing test5 "${arr[@]}"
95# 6 84# 6
96echo "Testing adding of multiple GNS2DNS record with -R" 85echo "Testing adding of multiple GNS2DNS record with -R"
97declare -a arr=('1 GNS2DNS n gnunet.org@127.0.0.1' '3600 GNS2DNS s gnunet.org@127.0.0.2') 86declare -a arr=('GNS2DNS 1 [r] gnunet.org@127.0.0.1' 'GNS2DNS 3600 [s] gnunet.org@127.0.0.2')
98testing test6 "${arr[@]}" 87testing test6 "${arr[@]}"
99val=$(gnunet-gns -t GNS2DNS -u test6.randomtestingid) 88val=$(gnunet-gns -t GNS2DNS -u test6.randomtestingid)
100if [[ $val == *"127.0.0.1"* ]]; then 89if [[ $val == *"127.0.0.1"* ]]; then
@@ -108,16 +97,16 @@ if [[ $val == *"127.0.0.2"* ]]; then
108fi 97fi
109# 7 98# 7
110echo "Testing adding MX record with -R" 99echo "Testing adding MX record with -R"
111declare -a arr=('3600 MX n 10,mail') 100declare -a arr=('MX 3600 [r] 10,mail')
112testing test7 "${arr[@]}" 101testing test7 "${arr[@]}"
113# 8 102# 8
114echo "Testing adding TXT record with -R" 103echo "Testing adding TXT record with -R"
115declare -a arr=('3600 TXT n Pretty_Unicorns') 104declare -a arr=('TXT 3600 [r] Pretty_Unicorns')
116testing test8 "${arr[@]}" 105testing test8 "${arr[@]}"
117# 8 106# 8
118echo "Testing adding TXT record with -R" 107#echo "Testing adding TXT record with -R"
119declare -a arr=('3600 SRV n _autodiscover_old._tcp.bfh.ch.') 108#declare -a arr=('SRV 3600 [r] _autodiscover_old._tcp.bfh.ch.')
120testing test8 "${arr[@]}" 109#testing test8 "${arr[@]}"
121 110
122# CLEANUP 111# CLEANUP
123gnunet-identity -D randomtestingid 112gnunet-identity -D randomtestingid
diff --git a/src/namestore/test_namestore_put_stdin.sh b/src/namestore/test_namestore_put_stdin.sh
new file mode 100755
index 000000000..deb7bc4cb
--- /dev/null
+++ b/src/namestore/test_namestore_put_stdin.sh
@@ -0,0 +1,68 @@
1#!/bin/bash
2CONFIGURATION="test_namestore_api.conf"
3trap "gnunet-arm -e -c $CONFIGURATION" SIGINT
4
5LOCATION=$(which gnunet-config)
6if [ -z $LOCATION ]
7then
8 LOCATION="gnunet-config"
9fi
10$LOCATION --version 1> /dev/null
11if test $? != 0
12then
13 echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
14 exit 77
15fi
16
17rm -rf `$LOCATION -c $CONFIGURATION -s PATHS -o GNUNET_HOME`
18TEST_RECORD_NAME="www3"
19TEST_RECORD_NAME2="www"
20TEST_IP="8.7.6.5"
21TEST_IP2="1.2.3.4"
22
23which timeout &> /dev/null && DO_TIMEOUT="timeout 5"
24
25function start_peer
26{
27 gnunet-arm -s -c $CONFIGURATION
28 gnunet-identity -C testego -c $CONFIGURATION
29 gnunet-identity -C testego2 -c $CONFIGURATION
30}
31
32function stop_peer
33{
34 gnunet-identity -D testego -c $CONFIGURATION
35 gnunet-identity -D testego2 -c $CONFIGURATION
36 gnunet-arm -e -c $CONFIGURATION
37}
38
39
40start_peer
41# Create a public record
42EGOKEY=`gnunet-identity -d | grep testego2 | cut -d' ' -f3`
43gnunet-namestore -a -c $CONFIGURATION -S <<EOF
44$TEST_RECORD_NAME.testego:
45 A 3600000000 [pr] $TEST_IP
46 TXT 21438201833 [r] $TEST_IP2
47
48 TXT 21438201833 [r] aslkdj asdlkjaslkd 232!
49
50$TEST_RECORD_NAME2.testego:
51 AAAA 324241223 [prS] ::dead:beef
52 A 111324241223000000 [pC] 1.1.1.1
53
54www7.$EGOKEY:
55 A 3600000000 [pr] $TEST_IP
56
57EOF
58NAMESTORE_RES=$?
59gnunet-namestore -D -r -c $CONFIGURATION
60stop_peer
61
62if [ $NAMESTORE_RES = 0 ]
63then
64 echo "PASS: Creating name in namestore"
65else
66 echo "FAIL: Creating name in namestore failed with $NAMESTORE_RES."
67 exit 1
68fi
diff --git a/src/namestore/test_plugin_namestore.c b/src/namestore/test_plugin_namestore.c
index e35542ff0..b89cc95d0 100644
--- a/src/namestore/test_plugin_namestore.c
+++ b/src/namestore/test_plugin_namestore.c
@@ -26,7 +26,6 @@
26#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
27#include "gnunet_namestore_plugin.h" 27#include "gnunet_namestore_plugin.h"
28#include "gnunet_testing_lib.h" 28#include "gnunet_testing_lib.h"
29#include "gnunet_dnsparser_lib.h"
30 29
31#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT 30#define TEST_RECORD_TYPE GNUNET_DNSPARSER_TYPE_TXT
32 31
@@ -66,23 +65,30 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg)
66{ 65{
67 struct GNUNET_NAMESTORE_PluginFunctions *ret; 66 struct GNUNET_NAMESTORE_PluginFunctions *ret;
68 char *libname; 67 char *libname;
69 char *emsg;
70 68
71 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 69 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
72 _ ("Loading `%s' namestore plugin\n"), 70 "Loading `%s' namestore plugin\n",
73 plugin_name); 71 plugin_name);
74 GNUNET_asprintf (&libname, "libgnunet_plugin_namestore_%s", plugin_name); 72 GNUNET_asprintf (&libname,
73 "libgnunet_plugin_namestore_%s",
74 plugin_name);
75 if (NULL == (ret = GNUNET_PLUGIN_load (libname, (void *) cfg))) 75 if (NULL == (ret = GNUNET_PLUGIN_load (libname, (void *) cfg)))
76 { 76 {
77 fprintf (stderr, "Failed to load plugin `%s'!\n", plugin_name); 77 fprintf (stderr,
78 "Failed to load plugin `%s'!\n",
79 plugin_name);
78 GNUNET_free (libname); 80 GNUNET_free (libname);
79 return NULL; 81 return NULL;
80 } 82 }
81 GNUNET_free (libname); 83 GNUNET_free (libname);
82 if (GNUNET_OK != ret->reset_database (ret->cls, &emsg)) 84 if (GNUNET_OK != ret->drop_tables (ret->cls))
85 {
86 GNUNET_break (0);
87 return NULL;
88 }
89 if (GNUNET_OK != ret->create_tables (ret->cls))
83 { 90 {
84 fprintf (stderr, "Error resetting database: %s\n", emsg); 91 GNUNET_break (0);
85 GNUNET_free (emsg);
86 return NULL; 92 return NULL;
87 } 93 }
88 return ret; 94 return ret;
diff --git a/src/nat/gnunet-helper-nat-client.c b/src/nat/gnunet-helper-nat-client.c
index 0271d6e0f..0b86aa0d2 100644
--- a/src/nat/gnunet-helper-nat-client.c
+++ b/src/nat/gnunet-helper-nat-client.c
@@ -43,7 +43,8 @@
43 */ 43 */
44#if HAVE_CONFIG_H 44#if HAVE_CONFIG_H
45/* Just needed for HAVE_SOCKADDR_IN_SIN_LEN test macro! */ 45/* Just needed for HAVE_SOCKADDR_IN_SIN_LEN test macro! */
46#include "gnunet_config.h" 46#include "platform.h"
47#include "gnunet_private_config.h"
47#else 48#else
48#define _GNU_SOURCE 49#define _GNU_SOURCE
49#endif 50#endif
diff --git a/src/nat/gnunet-helper-nat-server.c b/src/nat/gnunet-helper-nat-server.c
index 38d7d22c8..d190a5dba 100644
--- a/src/nat/gnunet-helper-nat-server.c
+++ b/src/nat/gnunet-helper-nat-server.c
@@ -44,7 +44,8 @@
44 */ 44 */
45#if HAVE_CONFIG_H 45#if HAVE_CONFIG_H
46/* Just needed for HAVE_SOCKADDR_IN_SIN_LEN test macro! */ 46/* Just needed for HAVE_SOCKADDR_IN_SIN_LEN test macro! */
47#include "gnunet_config.h" 47#include "platform.h"
48#include "gnunet_private_config.h"
48#else 49#else
49#define _GNU_SOURCE 50#define _GNU_SOURCE
50#endif 51#endif
diff --git a/src/nat/nat_api.c b/src/nat/nat_api.c
index 7cf7e6bb3..3072cff7f 100644
--- a/src/nat/nat_api.c
+++ b/src/nat/nat_api.c
@@ -670,13 +670,6 @@ GNUNET_NAT_request_reversal (struct GNUNET_NAT_Handle *nh,
670} 670}
671 671
672 672
673/**
674 * Stop port redirection and public IP address detection for the given
675 * handle. This frees the handle, after having sent the needed
676 * commands to close open ports.
677 *
678 * @param nh the handle to stop
679 */
680void 673void
681GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *nh) 674GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *nh)
682{ 675{
diff --git a/src/peerinfo/peerinfo.h b/src/peerinfo/peerinfo.h
index 7db923d4d..9968733f0 100644
--- a/src/peerinfo/peerinfo.h
+++ b/src/peerinfo/peerinfo.h
@@ -27,10 +27,9 @@
27#ifndef PEERINFO_H 27#ifndef PEERINFO_H
28#define PEERINFO_H 28#define PEERINFO_H
29 29
30#include "gnunet_crypto_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_time_lib.h"
32#include "gnunet_peerinfo_service.h" 31#include "gnunet_peerinfo_service.h"
33 32#include "gnunet_time_lib.h"
34 33
35GNUNET_NETWORK_STRUCT_BEGIN 34GNUNET_NETWORK_STRUCT_BEGIN
36 35
diff --git a/src/peerstore/peerstore_common.c b/src/peerstore/peerstore_common.c
index 070a2a16e..e3bb77d86 100644
--- a/src/peerstore/peerstore_common.c
+++ b/src/peerstore/peerstore_common.c
@@ -23,6 +23,7 @@
23 * @author Omar Tarabai 23 * @author Omar Tarabai
24 */ 24 */
25 25
26#include "platform.h"
26#include "peerstore_common.h" 27#include "peerstore_common.h"
27 28
28/** 29/**
diff --git a/src/pq/Makefile.am b/src/pq/Makefile.am
index 013b20588..d4afe9232 100644
--- a/src/pq/Makefile.am
+++ b/src/pq/Makefile.am
@@ -5,6 +5,14 @@ if USE_COVERAGE
5 AM_CFLAGS = --coverage 5 AM_CFLAGS = --coverage
6endif 6endif
7 7
8sqldir = $(prefix)/share/gnunet/sql/
9
10sql_DATA = \
11 versioning.sql
12
13EXTRA_DIST = \
14 $(sql_DATA)
15
8if HAVE_POSTGRESQL 16if HAVE_POSTGRESQL
9lib_LTLIBRARIES = libgnunetpq.la 17lib_LTLIBRARIES = libgnunetpq.la
10endif 18endif
@@ -27,6 +35,7 @@ libgnunetpq_la_LDFLAGS = \
27 -version-info 3:0:0 35 -version-info 3:0:0
28 36
29if ENABLE_TEST_RUN 37if ENABLE_TEST_RUN
38AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
30TESTS = \ 39TESTS = \
31 test_pq 40 test_pq
32endif 41endif
diff --git a/src/pq/pq_connect.c b/src/pq/pq_connect.c
index a911bf8e1..e8617a5c9 100644
--- a/src/pq/pq_connect.c
+++ b/src/pq/pq_connect.c
@@ -352,6 +352,7 @@ GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db)
352 PQsetNoticeProcessor (db->conn, 352 PQsetNoticeProcessor (db->conn,
353 &pq_notice_processor_cb, 353 &pq_notice_processor_cb,
354 db); 354 db);
355 if (NULL != db->load_path)
355 { 356 {
356 PGresult *res; 357 PGresult *res;
357 ExecStatusType est; 358 ExecStatusType est;
@@ -414,6 +415,7 @@ GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db)
414 { 415 {
415 PGresult *res; 416 PGresult *res;
416 417
418 GNUNET_assert (NULL != db->load_path);
417 res = PQprepare (db->conn, 419 res = PQprepare (db->conn,
418 "gnunet_pq_check_patch", 420 "gnunet_pq_check_patch",
419 "SELECT" 421 "SELECT"
diff --git a/src/pq/pq_eval.c b/src/pq/pq_eval.c
index 5f96ff884..cc16c7864 100644
--- a/src/pq/pq_eval.c
+++ b/src/pq/pq_eval.c
@@ -255,11 +255,11 @@ GNUNET_PQ_eval_prepared_multi_select (struct GNUNET_PQ_Context *db,
255 * codes to `enum GNUNET_DB_QueryStatus`. 255 * codes to `enum GNUNET_DB_QueryStatus`.
256 */ 256 */
257enum GNUNET_DB_QueryStatus 257enum GNUNET_DB_QueryStatus
258GNUNET_PQ_eval_prepared_singleton_select (struct GNUNET_PQ_Context *db, 258GNUNET_PQ_eval_prepared_singleton_select (
259 const char *statement_name, 259 struct GNUNET_PQ_Context *db,
260 const struct 260 const char *statement_name,
261 GNUNET_PQ_QueryParam *params, 261 const struct GNUNET_PQ_QueryParam *params,
262 struct GNUNET_PQ_ResultSpec *rs) 262 struct GNUNET_PQ_ResultSpec *rs)
263{ 263{
264 PGresult *result; 264 PGresult *result;
265 enum GNUNET_DB_QueryStatus qs; 265 enum GNUNET_DB_QueryStatus qs;
diff --git a/src/pq/pq_event.c b/src/pq/pq_event.c
index 0e56c8b70..b0ed6798a 100644
--- a/src/pq/pq_event.c
+++ b/src/pq/pq_event.c
@@ -512,6 +512,21 @@ GNUNET_PQ_event_listen_cancel (struct GNUNET_DB_EventHandler *eh)
512} 512}
513 513
514 514
515char *
516GNUNET_PG_get_event_notify_channel (const struct GNUNET_DB_EventHeaderP *es)
517{
518 char sql[16 + 64 + 8];
519 char *end;
520
521 end = stpcpy (sql,
522 "NOTIFY X");
523 end = es_to_channel (es,
524 end);
525 GNUNET_assert (NULL != end);
526 return GNUNET_strdup (sql);
527}
528
529
515void 530void
516GNUNET_PQ_event_notify (struct GNUNET_PQ_Context *db, 531GNUNET_PQ_event_notify (struct GNUNET_PQ_Context *db,
517 const struct GNUNET_DB_EventHeaderP *es, 532 const struct GNUNET_DB_EventHeaderP *es,
diff --git a/src/pq/versioning.sql b/src/pq/versioning.sql
new file mode 100644
index 000000000..116f409b7
--- /dev/null
+++ b/src/pq/versioning.sql
@@ -0,0 +1,293 @@
1-- LICENSE AND COPYRIGHT
2--
3-- Copyright (C) 2010 Hubert depesz Lubaczewski
4--
5-- This program is distributed under the (Revised) BSD License:
6-- L<http://www.opensource.org/licenses/bsd-license.php>
7--
8-- Redistribution and use in source and binary forms, with or without
9-- modification, are permitted provided that the following conditions
10-- are met:
11--
12-- * Redistributions of source code must retain the above copyright
13-- notice, this list of conditions and the following disclaimer.
14--
15-- * Redistributions in binary form must reproduce the above copyright
16-- notice, this list of conditions and the following disclaimer in the
17-- documentation and/or other materials provided with the distribution.
18--
19-- * Neither the name of Hubert depesz Lubaczewski's Organization
20-- nor the names of its contributors may be used to endorse or
21-- promote products derived from this software without specific
22-- prior written permission.
23--
24-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
28-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30-- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31-- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32-- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34--
35-- Code origin: https://gitlab.com/depesz/Versioning/blob/master/install.versioning.sql
36--
37--
38-- # NAME
39--
40-- **Versioning** - simplistic take on tracking and applying changes to databases.
41--
42-- # DESCRIPTION
43--
44-- This project strives to provide simple way to manage changes to
45-- database.
46--
47-- Instead of making changes on development server, then finding
48-- differences between production and development, deciding which ones
49-- should be installed on production, and finding a way to install them -
50-- you start with writing diffs themselves!
51--
52-- # INSTALLATION
53--
54-- To install versioning simply run install.versioning.sql in your database
55-- (all of them: production, stage, test, devel, ...).
56--
57-- # USAGE
58--
59-- In your files with patches to database, put whole logic in single
60-- transaction, and use \_v.\* functions - usually \_v.register_patch() at
61-- least to make sure everything is OK.
62--
63-- For example. Let's assume you have patch files:
64--
65-- ## 0001.sql:
66--
67-- ```
68-- create table users (id serial primary key, username text);
69-- ```
70--
71-- ## 0002.sql:
72--
73-- ```
74-- insert into users (username) values ('depesz');
75-- ```
76-- To change it to use versioning you would change the files, to this
77-- state:
78--
79-- 0000.sql:
80--
81-- ```
82-- BEGIN;
83-- select _v.register_patch('000-base', NULL, NULL);
84-- create table users (id serial primary key, username text);
85-- COMMIT;
86-- ```
87--
88-- ## 0002.sql:
89--
90-- ```
91-- BEGIN;
92-- select _v.register_patch('001-users', ARRAY['000-base'], NULL);
93-- insert into users (username) values ('depesz');
94-- COMMIT;
95-- ```
96--
97-- This will make sure that patch 001-users can only be applied after
98-- 000-base.
99--
100-- # AVAILABLE FUNCTIONS
101--
102-- ## \_v.register_patch( TEXT )
103--
104-- Registers named patch, or dies if it is already registered.
105--
106-- Returns integer which is id of patch in \_v.patches table - only if it
107-- succeeded.
108--
109-- ## \_v.register_patch( TEXT, TEXT[] )
110--
111-- Same as \_v.register_patch( TEXT ), but checks is all given patches (given as
112-- array in second argument) are already registered.
113--
114-- ## \_v.register_patch( TEXT, TEXT[], TEXT[] )
115--
116-- Same as \_v.register_patch( TEXT, TEXT[] ), but also checks if there are no conflicts with preexisting patches.
117--
118-- Third argument is array of names of patches that conflict with current one. So
119-- if any of them is installed - register_patch will error out.
120--
121-- ## \_v.unregister_patch( TEXT )
122--
123-- Removes information about given patch from the versioning data.
124--
125-- It doesn't remove objects that were created by this patch - just removes
126-- metainformation.
127--
128-- ## \_v.assert_user_is_superuser()
129--
130-- Make sure that current patch is being loaded by superuser.
131--
132-- If it's not - it will raise exception, and break transaction.
133--
134-- ## \_v.assert_user_is_not_superuser()
135--
136-- Make sure that current patch is not being loaded by superuser.
137--
138-- If it is - it will raise exception, and break transaction.
139--
140-- ## \_v.assert_user_is_one_of(TEXT, TEXT, ... )
141--
142-- Make sure that current patch is being loaded by one of listed users.
143--
144-- If ```current_user``` is not listed as one of arguments - function will raise
145-- exception and break the transaction.
146
147BEGIN;
148
149-- This file adds versioning support to database it will be loaded to.
150-- It requires that PL/pgSQL is already loaded - will raise exception otherwise.
151-- All versioning "stuff" (tables, functions) is in "_v" schema.
152
153-- All functions are defined as 'RETURNS SETOF INT4' to be able to make them to RETURN literally nothing (0 rows).
154-- >> RETURNS VOID<< IS similar, but it still outputs "empty line" in psql when calling.
155CREATE SCHEMA IF NOT EXISTS _v;
156COMMENT ON SCHEMA _v IS 'Schema for versioning data and functionality.';
157
158CREATE TABLE IF NOT EXISTS _v.patches (
159 patch_name TEXT PRIMARY KEY,
160 applied_tsz TIMESTAMPTZ NOT NULL DEFAULT now(),
161 applied_by TEXT NOT NULL,
162 requires TEXT[],
163 conflicts TEXT[]
164);
165COMMENT ON TABLE _v.patches IS 'Contains information about what patches are currently applied on database.';
166COMMENT ON COLUMN _v.patches.patch_name IS 'Name of patch, has to be unique for every patch.';
167COMMENT ON COLUMN _v.patches.applied_tsz IS 'When the patch was applied.';
168COMMENT ON COLUMN _v.patches.applied_by IS 'Who applied this patch (PostgreSQL username)';
169COMMENT ON COLUMN _v.patches.requires IS 'List of patches that are required for given patch.';
170COMMENT ON COLUMN _v.patches.conflicts IS 'List of patches that conflict with given patch.';
171
172CREATE OR REPLACE FUNCTION _v.register_patch( IN in_patch_name TEXT, IN in_requirements TEXT[], in_conflicts TEXT[], OUT versioning INT4 ) RETURNS setof INT4 AS $$
173DECLARE
174 t_text TEXT;
175 t_text_a TEXT[];
176 i INT4;
177BEGIN
178 -- Thanks to this we know only one patch will be applied at a time
179 LOCK TABLE _v.patches IN EXCLUSIVE MODE;
180
181 SELECT patch_name INTO t_text FROM _v.patches WHERE patch_name = in_patch_name;
182 IF FOUND THEN
183 RAISE EXCEPTION 'Patch % is already applied!', in_patch_name;
184 END IF;
185
186 t_text_a := ARRAY( SELECT patch_name FROM _v.patches WHERE patch_name = any( in_conflicts ) );
187 IF array_upper( t_text_a, 1 ) IS NOT NULL THEN
188 RAISE EXCEPTION 'Versioning patches conflict. Conflicting patche(s) installed: %.', array_to_string( t_text_a, ', ' );
189 END IF;
190
191 IF array_upper( in_requirements, 1 ) IS NOT NULL THEN
192 t_text_a := '{}';
193 FOR i IN array_lower( in_requirements, 1 ) .. array_upper( in_requirements, 1 ) LOOP
194 SELECT patch_name INTO t_text FROM _v.patches WHERE patch_name = in_requirements[i];
195 IF NOT FOUND THEN
196 t_text_a := t_text_a || in_requirements[i];
197 END IF;
198 END LOOP;
199 IF array_upper( t_text_a, 1 ) IS NOT NULL THEN
200 RAISE EXCEPTION 'Missing prerequisite(s): %.', array_to_string( t_text_a, ', ' );
201 END IF;
202 END IF;
203
204 INSERT INTO _v.patches (patch_name, applied_tsz, applied_by, requires, conflicts ) VALUES ( in_patch_name, now(), current_user, coalesce( in_requirements, '{}' ), coalesce( in_conflicts, '{}' ) );
205 RETURN;
206END;
207$$ language plpgsql;
208COMMENT ON FUNCTION _v.register_patch( TEXT, TEXT[], TEXT[] ) IS 'Function to register patches in database. Raises exception if there are conflicts, prerequisites are not installed or the migration has already been installed.';
209
210CREATE OR REPLACE FUNCTION _v.register_patch( TEXT, TEXT[] ) RETURNS setof INT4 AS $$
211 SELECT _v.register_patch( $1, $2, NULL );
212$$ language sql;
213COMMENT ON FUNCTION _v.register_patch( TEXT, TEXT[] ) IS 'Wrapper to allow registration of patches without conflicts.';
214CREATE OR REPLACE FUNCTION _v.register_patch( TEXT ) RETURNS setof INT4 AS $$
215 SELECT _v.register_patch( $1, NULL, NULL );
216$$ language sql;
217COMMENT ON FUNCTION _v.register_patch( TEXT ) IS 'Wrapper to allow registration of patches without requirements and conflicts.';
218
219CREATE OR REPLACE FUNCTION _v.unregister_patch( IN in_patch_name TEXT, OUT versioning INT4 ) RETURNS setof INT4 AS $$
220DECLARE
221 i INT4;
222 t_text_a TEXT[];
223BEGIN
224 -- Thanks to this we know only one patch will be applied at a time
225 LOCK TABLE _v.patches IN EXCLUSIVE MODE;
226
227 t_text_a := ARRAY( SELECT patch_name FROM _v.patches WHERE in_patch_name = ANY( requires ) );
228 IF array_upper( t_text_a, 1 ) IS NOT NULL THEN
229 RAISE EXCEPTION 'Cannot uninstall %, as it is required by: %.', in_patch_name, array_to_string( t_text_a, ', ' );
230 END IF;
231
232 DELETE FROM _v.patches WHERE patch_name = in_patch_name;
233 GET DIAGNOSTICS i = ROW_COUNT;
234 IF i < 1 THEN
235 RAISE EXCEPTION 'Patch % is not installed, so it can''t be uninstalled!', in_patch_name;
236 END IF;
237
238 RETURN;
239END;
240$$ language plpgsql;
241COMMENT ON FUNCTION _v.unregister_patch( TEXT ) IS 'Function to unregister patches in database. Dies if the patch is not registered, or if unregistering it would break dependencies.';
242
243CREATE OR REPLACE FUNCTION _v.assert_patch_is_applied( IN in_patch_name TEXT ) RETURNS TEXT as $$
244DECLARE
245 t_text TEXT;
246BEGIN
247 SELECT patch_name INTO t_text FROM _v.patches WHERE patch_name = in_patch_name;
248 IF NOT FOUND THEN
249 RAISE EXCEPTION 'Patch % is not applied!', in_patch_name;
250 END IF;
251 RETURN format('Patch %s is applied.', in_patch_name);
252END;
253$$ language plpgsql;
254COMMENT ON FUNCTION _v.assert_patch_is_applied( TEXT ) IS 'Function that can be used to make sure that patch has been applied.';
255
256CREATE OR REPLACE FUNCTION _v.assert_user_is_superuser() RETURNS TEXT as $$
257DECLARE
258 v_super bool;
259BEGIN
260 SELECT usesuper INTO v_super FROM pg_user WHERE usename = current_user;
261 IF v_super THEN
262 RETURN 'assert_user_is_superuser: OK';
263 END IF;
264 RAISE EXCEPTION 'Current user is not superuser - cannot continue.';
265END;
266$$ language plpgsql;
267COMMENT ON FUNCTION _v.assert_user_is_superuser() IS 'Function that can be used to make sure that patch is being applied using superuser account.';
268
269CREATE OR REPLACE FUNCTION _v.assert_user_is_not_superuser() RETURNS TEXT as $$
270DECLARE
271 v_super bool;
272BEGIN
273 SELECT usesuper INTO v_super FROM pg_user WHERE usename = current_user;
274 IF v_super THEN
275 RAISE EXCEPTION 'Current user is superuser - cannot continue.';
276 END IF;
277 RETURN 'assert_user_is_not_superuser: OK';
278END;
279$$ language plpgsql;
280COMMENT ON FUNCTION _v.assert_user_is_not_superuser() IS 'Function that can be used to make sure that patch is being applied using normal (not superuser) account.';
281
282CREATE OR REPLACE FUNCTION _v.assert_user_is_one_of(VARIADIC p_acceptable_users TEXT[] ) RETURNS TEXT as $$
283DECLARE
284BEGIN
285 IF current_user = any( p_acceptable_users ) THEN
286 RETURN 'assert_user_is_one_of: OK';
287 END IF;
288 RAISE EXCEPTION 'User is not one of: % - cannot continue.', p_acceptable_users;
289END;
290$$ language plpgsql;
291COMMENT ON FUNCTION _v.assert_user_is_one_of(TEXT[]) IS 'Function that can be used to make sure that patch is being applied by one of defined users.';
292
293COMMIT;
diff --git a/src/pt/gnunet-daemon-pt.c b/src/pt/gnunet-daemon-pt.c
index 67227b97f..13c5d62fd 100644
--- a/src/pt/gnunet-daemon-pt.c
+++ b/src/pt/gnunet-daemon-pt.c
@@ -25,9 +25,7 @@
25#include "platform.h" 25#include "platform.h"
26#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
27#include "gnunet_dns_service.h" 27#include "gnunet_dns_service.h"
28#include "gnunet_dnsparser_lib.h"
29#include "gnunet_cadet_service.h" 28#include "gnunet_cadet_service.h"
30#include "gnunet_tun_lib.h"
31#include "gnunet_dht_service.h" 29#include "gnunet_dht_service.h"
32#include "gnunet_vpn_service.h" 30#include "gnunet_vpn_service.h"
33#include "gnunet_statistics_service.h" 31#include "gnunet_statistics_service.h"
diff --git a/src/pt/test_gns_vpn.c b/src/pt/test_gns_vpn.c
index d4da622c6..b2797bc83 100644
--- a/src/pt/test_gns_vpn.c
+++ b/src/pt/test_gns_vpn.c
@@ -351,16 +351,14 @@ start_curl (void *cls)
351 */ 351 */
352static void 352static void
353commence_testing (void *cls, 353commence_testing (void *cls,
354 int32_t success, 354 enum GNUNET_ErrorCode ec)
355 const char *emsg)
356{ 355{
357 qe = NULL; 356 qe = NULL;
358 if ((NULL != emsg) && 357 if (GNUNET_EC_NONE != ec)
359 (GNUNET_YES != success))
360 { 358 {
361 fprintf (stderr, 359 fprintf (stderr,
362 "NS failed to create record %s\n", 360 "NS failed to create record %s\n",
363 emsg); 361 GNUNET_ErrorCode_get_hint (ec));
364 GNUNET_SCHEDULER_shutdown (); 362 GNUNET_SCHEDULER_shutdown ();
365 return; 363 return;
366 } 364 }
@@ -857,7 +855,7 @@ main (int argc,
857 &run, 855 &run,
858 NULL)) 856 NULL))
859 return 1; 857 return 1;
860 GNUNET_DISK_purge_cfg_dir ("test_gns_vpn.conf", 858 GNUNET_DISK_purge_cfg_dir ("test_gns_vpn.conf",
861 "GNUNET_TEST_HOME"); 859 "GNUNET_TEST_HOME");
862 return global_ret; 860 return global_ret;
863} 861}
diff --git a/src/reclaim/Makefile.am b/src/reclaim/Makefile.am
index 37af360c8..4c84a8efc 100644
--- a/src/reclaim/Makefile.am
+++ b/src/reclaim/Makefile.am
@@ -188,6 +188,7 @@ endif
188libgnunet_plugin_reclaim_credential_jwt_la_SOURCES = \ 188libgnunet_plugin_reclaim_credential_jwt_la_SOURCES = \
189 plugin_reclaim_credential_jwt.c 189 plugin_reclaim_credential_jwt.c
190libgnunet_plugin_reclaim_credential_jwt_la_LIBADD = \ 190libgnunet_plugin_reclaim_credential_jwt_la_LIBADD = \
191 $(top_builddir)/src/identity/libgnunetidentity.la \
191 $(top_builddir)/src/util/libgnunetutil.la \ 192 $(top_builddir)/src/util/libgnunetutil.la \
192 libgnunetreclaim.la \ 193 libgnunetreclaim.la \
193 -ljansson\ 194 -ljansson\
diff --git a/src/reclaim/did_core.c b/src/reclaim/did_core.c
index f3caff707..4f2bd5a87 100644
--- a/src/reclaim/did_core.c
+++ b/src/reclaim/did_core.c
@@ -27,6 +27,7 @@
27// TODO: DID documents do not have an expiration date. Still we add one 27// TODO: DID documents do not have an expiration date. Still we add one
28// TODO: Store DID document with empty label and own type (maybe DID-Document or JSON??) 28// TODO: Store DID document with empty label and own type (maybe DID-Document or JSON??)
29 29
30#include "platform.h"
30#include "did_core.h" 31#include "did_core.h"
31 32
32struct DID_resolve_return 33struct DID_resolve_return
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index 4c80d6d24..8b468fc8e 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -674,7 +674,7 @@ send_ticket_result (const struct IdpClient *client,
674 buf = (char*) &irm[1]; 674 buf = (char*) &irm[1];
675 if (NULL != ticket) 675 if (NULL != ticket)
676 { 676 {
677 irm->tkt_len = htonl (tkt_len); 677 irm->tkt_len = htons (tkt_len);
678 written = GNUNET_RECLAIM_write_ticket_to_buffer (ticket, buf, tkt_len); 678 written = GNUNET_RECLAIM_write_ticket_to_buffer (ticket, buf, tkt_len);
679 GNUNET_assert (0 <= written); 679 GNUNET_assert (0 <= written);
680 buf += written; 680 buf += written;
@@ -746,8 +746,8 @@ check_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
746 746
747 size = ntohs (im->header.size); 747 size = ntohs (im->header.size);
748 attrs_len = ntohs (im->attr_len); 748 attrs_len = ntohs (im->attr_len);
749 key_len = ntohl (im->key_len); 749 key_len = ntohs (im->key_len);
750 pkey_len = ntohl (im->pkey_len); 750 pkey_len = ntohs (im->pkey_len);
751 if (size != attrs_len + key_len + pkey_len + sizeof(struct 751 if (size != attrs_len + key_len + pkey_len + sizeof(struct
752 IssueTicketMessage)) 752 IssueTicketMessage))
753 { 753 {
@@ -780,7 +780,7 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
780 char *buf; 780 char *buf;
781 781
782 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n"); 782 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ISSUE_TICKET message\n");
783 key_len = ntohl (im->key_len); 783 key_len = ntohs (im->key_len);
784 buf = (char *) &im[1]; 784 buf = (char *) &im[1];
785 if ((GNUNET_SYSERR == 785 if ((GNUNET_SYSERR ==
786 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, 786 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len,
@@ -793,7 +793,7 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im)
793 return; 793 return;
794 } 794 }
795 buf += read; 795 buf += read;
796 pkey_len = ntohl (im->pkey_len); 796 pkey_len = ntohs (im->pkey_len);
797 if ((GNUNET_SYSERR == 797 if ((GNUNET_SYSERR ==
798 GNUNET_IDENTITY_read_public_key_from_buffer (buf, pkey_len, 798 GNUNET_IDENTITY_read_public_key_from_buffer (buf, pkey_len,
799 &rp, &read)) || 799 &rp, &read)) ||
@@ -898,7 +898,7 @@ handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm)
898 char *buf; 898 char *buf;
899 899
900 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n"); 900 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received REVOKE_TICKET message\n");
901 key_len = ntohl (rm->key_len); 901 key_len = ntohs (rm->key_len);
902 buf = (char *) &rm[1]; 902 buf = (char *) &rm[1];
903 if ((GNUNET_SYSERR == 903 if ((GNUNET_SYSERR ==
904 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, 904 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len,
@@ -911,7 +911,7 @@ handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm)
911 return; 911 return;
912 } 912 }
913 buf += read; 913 buf += read;
914 tkt_len = ntohl (rm->tkt_len); 914 tkt_len = ntohs (rm->tkt_len);
915 if ((GNUNET_SYSERR == 915 if ((GNUNET_SYSERR ==
916 GNUNET_RECLAIM_read_ticket_from_buffer (buf, tkt_len, 916 GNUNET_RECLAIM_read_ticket_from_buffer (buf, tkt_len,
917 &ticket, &read)) || 917 &ticket, &read)) ||
@@ -974,8 +974,8 @@ consume_result_cb (void *cls,
974 crm->id = htonl (cop->r_id); 974 crm->id = htonl (cop->r_id);
975 crm->attrs_len = htons (attrs_len); 975 crm->attrs_len = htons (attrs_len);
976 crm->presentations_len = htons (pres_len); 976 crm->presentations_len = htons (pres_len);
977 crm->key_len = htonl (key_len); 977 crm->key_len = htons (key_len);
978 crm->result = htonl (success); 978 crm->result = htons (success);
979 data_tmp = (char *) &crm[1]; 979 data_tmp = (char *) &crm[1];
980 written = GNUNET_IDENTITY_write_public_key_to_buffer (identity, 980 written = GNUNET_IDENTITY_write_public_key_to_buffer (identity,
981 data_tmp, 981 data_tmp,
@@ -1033,7 +1033,7 @@ handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm)
1033 char *buf; 1033 char *buf;
1034 1034
1035 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n"); 1035 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CONSUME_TICKET message\n");
1036 key_len = ntohl (cm->key_len); 1036 key_len = ntohs (cm->key_len);
1037 buf = (char *) &cm[1]; 1037 buf = (char *) &cm[1];
1038 if ((GNUNET_SYSERR == 1038 if ((GNUNET_SYSERR ==
1039 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, 1039 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len,
@@ -1046,7 +1046,7 @@ handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm)
1046 return; 1046 return;
1047 } 1047 }
1048 buf += read; 1048 buf += read;
1049 tkt_len = ntohl (cm->tkt_len); 1049 tkt_len = ntohs (cm->tkt_len);
1050 if ((GNUNET_SYSERR == 1050 if ((GNUNET_SYSERR ==
1051 GNUNET_RECLAIM_read_ticket_from_buffer (buf, tkt_len, 1051 GNUNET_RECLAIM_read_ticket_from_buffer (buf, tkt_len,
1052 &ticket, &read)) || 1052 &ticket, &read)) ||
@@ -1197,7 +1197,7 @@ handle_attribute_store_message (void *cls,
1197 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n"); 1197 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_STORE message\n");
1198 1198
1199 data_len = ntohs (sam->attr_len); 1199 data_len = ntohs (sam->attr_len);
1200 key_len = ntohl (sam->key_len); 1200 key_len = ntohs (sam->key_len);
1201 buf = (char *) &sam[1]; 1201 buf = (char *) &sam[1];
1202 if ((GNUNET_SYSERR == 1202 if ((GNUNET_SYSERR ==
1203 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, 1203 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len,
@@ -1398,7 +1398,7 @@ handle_credential_store_message (void *cls,
1398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_STORE message\n"); 1398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_STORE message\n");
1399 1399
1400 data_len = ntohs (sam->attr_len); 1400 data_len = ntohs (sam->attr_len);
1401 key_len = ntohl (sam->key_len); 1401 key_len = ntohs (sam->key_len);
1402 buf = (char *) &sam[1]; 1402 buf = (char *) &sam[1];
1403 if ((GNUNET_SYSERR == 1403 if ((GNUNET_SYSERR ==
1404 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, 1404 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len,
@@ -1869,7 +1869,7 @@ handle_attribute_delete_message (void *cls,
1869 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n"); 1869 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n");
1870 1870
1871 data_len = ntohs (dam->attr_len); 1871 data_len = ntohs (dam->attr_len);
1872 key_len = ntohl (dam->key_len); 1872 key_len = ntohs (dam->key_len);
1873 buf = (char *) &dam[1]; 1873 buf = (char *) &dam[1];
1874 if ((GNUNET_SYSERR == 1874 if ((GNUNET_SYSERR ==
1875 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, 1875 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len,
@@ -1976,7 +1976,7 @@ handle_credential_delete_message (void *cls,
1976 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_DELETE message\n"); 1976 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREDENTIAL_DELETE message\n");
1977 1977
1978 data_len = ntohs (dam->attr_len); 1978 data_len = ntohs (dam->attr_len);
1979 key_len = ntohl (dam->key_len); 1979 key_len = ntohs (dam->key_len);
1980 buf = (char *) &dam[1]; 1980 buf = (char *) &dam[1];
1981 if ((GNUNET_SYSERR == 1981 if ((GNUNET_SYSERR ==
1982 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len, 1982 GNUNET_IDENTITY_read_private_key_from_buffer (buf, key_len,
@@ -2033,7 +2033,7 @@ attr_iter_finished (void *cls)
2033 env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); 2033 env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT);
2034 arm->id = htonl (ai->request_id); 2034 arm->id = htonl (ai->request_id);
2035 arm->attr_len = htons (0); 2035 arm->attr_len = htons (0);
2036 arm->pkey_len = htonl (0); 2036 arm->pkey_len = htons (0);
2037 GNUNET_MQ_send (ai->client->mq, env); 2037 GNUNET_MQ_send (ai->client->mq, env);
2038 GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head, 2038 GNUNET_CONTAINER_DLL_remove (ai->client->attr_iter_head,
2039 ai->client->attr_iter_tail, 2039 ai->client->attr_iter_tail,
@@ -2099,7 +2099,7 @@ attr_iter_cb (void *cls,
2099 arm->id = htonl (ai->request_id); 2099 arm->id = htonl (ai->request_id);
2100 arm->attr_len = htons (rd->data_size); 2100 arm->attr_len = htons (rd->data_size);
2101 data_tmp = (char *) &arm[1]; 2101 data_tmp = (char *) &arm[1];
2102 arm->pkey_len = htonl (key_len); 2102 arm->pkey_len = htons (key_len);
2103 written = GNUNET_IDENTITY_write_public_key_to_buffer (&identity, 2103 written = GNUNET_IDENTITY_write_public_key_to_buffer (&identity,
2104 data_tmp, 2104 data_tmp,
2105 key_len); 2105 key_len);
@@ -2147,7 +2147,7 @@ handle_iteration_start (void *cls,
2147 2147
2148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2149 "Received ATTRIBUTE_ITERATION_START message\n"); 2149 "Received ATTRIBUTE_ITERATION_START message\n");
2150 key_len = ntohl (ais_msg->key_len); 2150 key_len = ntohs (ais_msg->key_len);
2151 if ((GNUNET_SYSERR == 2151 if ((GNUNET_SYSERR ==
2152 GNUNET_IDENTITY_read_private_key_from_buffer (&ais_msg[1], 2152 GNUNET_IDENTITY_read_private_key_from_buffer (&ais_msg[1],
2153 key_len, 2153 key_len,
@@ -2263,6 +2263,7 @@ cred_iter_finished (void *cls)
2263 env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT); 2263 env = GNUNET_MQ_msg (arm, GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT);
2264 arm->id = htonl (ai->request_id); 2264 arm->id = htonl (ai->request_id);
2265 arm->credential_len = htons (0); 2265 arm->credential_len = htons (0);
2266 arm->key_len = htons (0);
2266 GNUNET_MQ_send (ai->client->mq, env); 2267 GNUNET_MQ_send (ai->client->mq, env);
2267 GNUNET_CONTAINER_DLL_remove (ai->client->cred_iter_head, 2268 GNUNET_CONTAINER_DLL_remove (ai->client->cred_iter_head,
2268 ai->client->cred_iter_tail, 2269 ai->client->cred_iter_tail,
@@ -2327,6 +2328,7 @@ cred_iter_cb (void *cls,
2327 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT); 2328 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_RESULT);
2328 arm->id = htonl (ai->request_id); 2329 arm->id = htonl (ai->request_id);
2329 arm->credential_len = htons (rd->data_size); 2330 arm->credential_len = htons (rd->data_size);
2331 arm->key_len = htons (key_len);
2330 data_tmp = (char *) &arm[1]; 2332 data_tmp = (char *) &arm[1];
2331 written = GNUNET_IDENTITY_write_public_key_to_buffer (&identity, 2333 written = GNUNET_IDENTITY_write_public_key_to_buffer (&identity,
2332 data_tmp, 2334 data_tmp,
@@ -2376,7 +2378,7 @@ handle_credential_iteration_start (void *cls,
2376 2378
2377 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2378 "Received CREDENTIAL_ITERATION_START message\n"); 2380 "Received CREDENTIAL_ITERATION_START message\n");
2379 key_len = ntohl (ais_msg->key_len); 2381 key_len = ntohs (ais_msg->key_len);
2380 if ((GNUNET_SYSERR == 2382 if ((GNUNET_SYSERR ==
2381 GNUNET_IDENTITY_read_private_key_from_buffer (&ais_msg[1], 2383 GNUNET_IDENTITY_read_private_key_from_buffer (&ais_msg[1],
2382 key_len, 2384 key_len,
@@ -2514,7 +2516,7 @@ ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket)
2514 &trm[1], 2516 &trm[1],
2515 tkt_len); 2517 tkt_len);
2516 } 2518 }
2517 trm->tkt_len = htonl (tkt_len); 2519 trm->tkt_len = htons (tkt_len);
2518 trm->id = htonl (ti->r_id); 2520 trm->id = htonl (ti->r_id);
2519 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n"); 2521 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TICKET_RESULT message\n");
2520 GNUNET_MQ_send (ti->client->mq, env); 2522 GNUNET_MQ_send (ti->client->mq, env);
@@ -2560,7 +2562,7 @@ handle_ticket_iteration_start (
2560 2562
2561 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2562 "Received TICKET_ITERATION_START message\n"); 2564 "Received TICKET_ITERATION_START message\n");
2563 key_len = ntohl (tis_msg->key_len); 2565 key_len = ntohs (tis_msg->key_len);
2564 if ((GNUNET_SYSERR == 2566 if ((GNUNET_SYSERR ==
2565 GNUNET_IDENTITY_read_private_key_from_buffer (&tis_msg[1], 2567 GNUNET_IDENTITY_read_private_key_from_buffer (&tis_msg[1],
2566 key_len, 2568 key_len,
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c
index 5e2a5e974..0c2fadd96 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/reclaim/gnunet-service-reclaim_tickets.c
@@ -24,6 +24,7 @@
24 * @brief reclaim tickets 24 * @brief reclaim tickets
25 * 25 *
26 */ 26 */
27#include "platform.h"
27#include <inttypes.h> 28#include <inttypes.h>
28#include "gnunet-service-reclaim_tickets.h" 29#include "gnunet-service-reclaim_tickets.h"
29 30
diff --git a/src/reclaim/pabc_helper.c b/src/reclaim/pabc_helper.c
index e58b8a4f7..65a633f7b 100644
--- a/src/reclaim/pabc_helper.c
+++ b/src/reclaim/pabc_helper.c
@@ -4,6 +4,7 @@
4// https://github.com/ontio/ontology-crypto/wiki/Anonymous-Credential 4// https://github.com/ontio/ontology-crypto/wiki/Anonymous-Credential
5// using the relic library https://github.com/relic-toolkit/relic/ 5// using the relic library https://github.com/relic-toolkit/relic/
6 6
7#include "platform.h"
7#include "pabc_helper.h" 8#include "pabc_helper.h"
8#include <pwd.h> 9#include <pwd.h>
9#include <stdlib.h> 10#include <stdlib.h>
diff --git a/src/reclaim/plugin_reclaim_credential_jwt.c b/src/reclaim/plugin_reclaim_credential_jwt.c
index 5d5e221f9..3eb4bfebf 100644
--- a/src/reclaim/plugin_reclaim_credential_jwt.c
+++ b/src/reclaim/plugin_reclaim_credential_jwt.c
@@ -167,7 +167,20 @@ jwt_parse_attributes (void *cls,
167 167
168 jwt_string = GNUNET_strndup (data, data_size); 168 jwt_string = GNUNET_strndup (data, data_size);
169 const char *jwt_body = strtok (jwt_string, delim); 169 const char *jwt_body = strtok (jwt_string, delim);
170 if (NULL == jwt_body)
171 {
172 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
173 "Failed to parse JSON %s\n", jwt_string);
174 return attrs;
175 }
170 jwt_body = strtok (NULL, delim); 176 jwt_body = strtok (NULL, delim);
177 if (NULL == jwt_body)
178 {
179 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
180 "Failed to parse JSON %s\n", jwt_string);
181 GNUNET_free (jwt_string);
182 return attrs;
183 }
171 GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), 184 GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body),
172 (void **) &decoded_jwt); 185 (void **) &decoded_jwt);
173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decoded JWT: %s\n", decoded_jwt); 186 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decoded JWT: %s\n", decoded_jwt);
diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c
index 4ead538ec..ff882aca1 100644
--- a/src/reclaim/plugin_rest_openid_connect.c
+++ b/src/reclaim/plugin_rest_openid_connect.c
@@ -30,8 +30,7 @@
30#include <jansson.h> 30#include <jansson.h>
31#include <jose/jose.h> 31#include <jose/jose.h>
32 32
33#include "gnunet_buffer_lib.h" 33#include "gnunet_util_lib.h"
34#include "gnunet_strings_lib.h"
35#include "gnunet_gns_service.h" 34#include "gnunet_gns_service.h"
36#include "gnunet_gnsrecord_lib.h" 35#include "gnunet_gnsrecord_lib.h"
37#include "gnunet_identity_service.h" 36#include "gnunet_identity_service.h"
diff --git a/src/reclaim/reclaim.h b/src/reclaim/reclaim.h
index 5813beaf7..9d5118269 100644
--- a/src/reclaim/reclaim.h
+++ b/src/reclaim/reclaim.h
@@ -57,12 +57,12 @@ struct AttributeStoreMessage
57 /** 57 /**
58 * The length of the attribute 58 * The length of the attribute
59 */ 59 */
60 uint32_t attr_len GNUNET_PACKED; 60 uint16_t attr_len GNUNET_PACKED;
61 61
62 /** 62 /**
63 * The length of the private key 63 * The length of the private key
64 */ 64 */
65 uint32_t key_len GNUNET_PACKED; 65 uint16_t key_len GNUNET_PACKED;
66 66
67 /* 67 /*
68 * followed by the zone private key 68 * followed by the zone private key
@@ -88,12 +88,12 @@ struct AttributeDeleteMessage
88 /** 88 /**
89 * The length of the attribute 89 * The length of the attribute
90 */ 90 */
91 uint32_t attr_len GNUNET_PACKED; 91 uint16_t attr_len GNUNET_PACKED;
92 92
93 /** 93 /**
94 * The length of the private key 94 * The length of the private key
95 */ 95 */
96 uint32_t key_len GNUNET_PACKED; 96 uint16_t key_len GNUNET_PACKED;
97 97
98 /* followed by the serialized attribute */ 98 /* followed by the serialized attribute */
99}; 99};
@@ -136,6 +136,11 @@ struct AttributeResultMessage
136 uint32_t id GNUNET_PACKED; 136 uint32_t id GNUNET_PACKED;
137 137
138 /** 138 /**
139 * Reserved (alignment)
140 */
141 uint16_t reserved GNUNET_PACKED;
142
143 /**
139 * Length of serialized attribute data 144 * Length of serialized attribute data
140 */ 145 */
141 uint16_t attr_len GNUNET_PACKED; 146 uint16_t attr_len GNUNET_PACKED;
@@ -146,14 +151,9 @@ struct AttributeResultMessage
146 uint16_t credential_len GNUNET_PACKED; 151 uint16_t credential_len GNUNET_PACKED;
147 152
148 /** 153 /**
149 * always zero (for alignment)
150 */
151 uint16_t reserved GNUNET_PACKED;
152
153 /**
154 * The length of the public key 154 * The length of the public key
155 */ 155 */
156 uint32_t pkey_len GNUNET_PACKED; 156 uint16_t pkey_len GNUNET_PACKED;
157 157
158 /** 158 /**
159 * followed by the public key key. 159 * followed by the public key key.
@@ -183,14 +183,9 @@ struct CredentialResultMessage
183 uint16_t credential_len GNUNET_PACKED; 183 uint16_t credential_len GNUNET_PACKED;
184 184
185 /** 185 /**
186 * always zero (for alignment)
187 */
188 uint16_t reserved GNUNET_PACKED;
189
190 /**
191 * The length of the public key 186 * The length of the public key
192 */ 187 */
193 uint32_t key_len GNUNET_PACKED; 188 uint16_t key_len GNUNET_PACKED;
194 189
195 /** 190 /**
196 * followed by the private key. 191 * followed by the private key.
@@ -216,9 +211,14 @@ struct AttributeIterationStartMessage
216 uint32_t id GNUNET_PACKED; 211 uint32_t id GNUNET_PACKED;
217 212
218 /** 213 /**
214 * Reserved (alignment)
215 */
216 uint16_t reserved GNUNET_PACKED;
217
218 /**
219 * The length of the private key 219 * The length of the private key
220 */ 220 */
221 uint32_t key_len GNUNET_PACKED; 221 uint16_t key_len GNUNET_PACKED;
222 222
223 /** 223 /**
224 * followed by the private key. 224 * followed by the private key.
@@ -259,9 +259,14 @@ struct CredentialIterationStartMessage
259 uint32_t id GNUNET_PACKED; 259 uint32_t id GNUNET_PACKED;
260 260
261 /** 261 /**
262 * Reserved (alignment)
263 */
264 uint16_t reserved GNUNET_PACKED;
265
266 /**
262 * The length of the private key 267 * The length of the private key
263 */ 268 */
264 uint32_t key_len GNUNET_PACKED; 269 uint16_t key_len GNUNET_PACKED;
265 270
266 /** 271 /**
267 * followed by the private key. 272 * followed by the private key.
@@ -335,9 +340,14 @@ struct TicketIterationStartMessage
335 uint32_t id GNUNET_PACKED; 340 uint32_t id GNUNET_PACKED;
336 341
337 /** 342 /**
343 * Reserved (alignment)
344 */
345 uint16_t reserved GNUNET_PACKED;
346
347 /**
338 * The length of the private key 348 * The length of the private key
339 */ 349 */
340 uint32_t key_len GNUNET_PACKED; 350 uint16_t key_len GNUNET_PACKED;
341 351
342 /** 352 /**
343 * followed by the private key. 353 * followed by the private key.
@@ -395,19 +405,24 @@ struct IssueTicketMessage
395 uint32_t id GNUNET_PACKED; 405 uint32_t id GNUNET_PACKED;
396 406
397 /** 407 /**
408 * Reserved (alignment)
409 */
410 uint16_t reserved GNUNET_PACKED;
411
412 /**
398 * length of serialized attribute list 413 * length of serialized attribute list
399 */ 414 */
400 uint32_t attr_len GNUNET_PACKED; 415 uint16_t attr_len GNUNET_PACKED;
401 416
402 /** 417 /**
403 * The length of the identity private key 418 * The length of the identity private key
404 */ 419 */
405 uint32_t key_len GNUNET_PACKED; 420 uint16_t key_len GNUNET_PACKED;
406 421
407 /** 422 /**
408 * The length of the relying party public key 423 * The length of the relying party public key
409 */ 424 */
410 uint32_t pkey_len GNUNET_PACKED; 425 uint16_t pkey_len GNUNET_PACKED;
411 426
412 /** 427 /**
413 * Followed by the private key. 428 * Followed by the private key.
@@ -434,12 +449,12 @@ struct RevokeTicketMessage
434 /** 449 /**
435 * The length of the private key 450 * The length of the private key
436 */ 451 */
437 uint32_t key_len GNUNET_PACKED; 452 uint16_t key_len GNUNET_PACKED;
438 453
439 /** 454 /**
440 * The length of the ticket 455 * The length of the ticket
441 */ 456 */
442 uint32_t tkt_len GNUNET_PACKED; 457 uint16_t tkt_len GNUNET_PACKED;
443 458
444 /** 459 /**
445 * Followed by the serialized ticket. 460 * Followed by the serialized ticket.
@@ -488,12 +503,12 @@ struct TicketResultMessage
488 /** 503 /**
489 * Ticket length 504 * Ticket length
490 */ 505 */
491 uint32_t tkt_len GNUNET_PACKED; 506 uint16_t tkt_len GNUNET_PACKED;
492 507
493 /** 508 /**
494 * Length of new presentations created 509 * Length of new presentations created
495 */ 510 */
496 uint32_t presentations_len GNUNET_PACKED; 511 uint16_t presentations_len GNUNET_PACKED;
497 512
498 /* 513 /*
499 * Followed by the serialized ticket 514 * Followed by the serialized ticket
@@ -519,12 +534,12 @@ struct ConsumeTicketMessage
519 /** 534 /**
520 * The length of the private key 535 * The length of the private key
521 */ 536 */
522 uint32_t key_len GNUNET_PACKED; 537 uint16_t key_len GNUNET_PACKED;
523 538
524 /** 539 /**
525 * The length of the ticket 540 * The length of the ticket
526 */ 541 */
527 uint32_t tkt_len GNUNET_PACKED; 542 uint16_t tkt_len GNUNET_PACKED;
528 543
529 /** 544 /**
530 * Followed by the private key. 545 * Followed by the private key.
@@ -553,6 +568,11 @@ struct ConsumeTicketResultMessage
553 uint32_t result GNUNET_PACKED; 568 uint32_t result GNUNET_PACKED;
554 569
555 /** 570 /**
571 * Reserved (alignment)
572 */
573 uint16_t reserved GNUNET_PACKED;
574
575 /**
556 * Length of serialized attribute data 576 * Length of serialized attribute data
557 */ 577 */
558 uint16_t attrs_len GNUNET_PACKED; 578 uint16_t attrs_len GNUNET_PACKED;
@@ -563,14 +583,9 @@ struct ConsumeTicketResultMessage
563 uint16_t presentations_len; 583 uint16_t presentations_len;
564 584
565 /** 585 /**
566 * always zero (for alignment)
567 */
568 uint16_t reserved GNUNET_PACKED;
569
570 /**
571 * The length of the private key 586 * The length of the private key
572 */ 587 */
573 uint32_t key_len GNUNET_PACKED; 588 uint16_t key_len GNUNET_PACKED;
574 589
575 /** 590 /**
576 * Followed by the private key. 591 * Followed by the private key.
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index efc45e616..fedee3fff 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -26,7 +26,6 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_constants.h" 28#include "gnunet_constants.h"
29#include "gnunet_mq_lib.h"
30#include "gnunet_protocols.h" 29#include "gnunet_protocols.h"
31#include "gnunet_reclaim_lib.h" 30#include "gnunet_reclaim_lib.h"
32#include "gnunet_reclaim_service.h" 31#include "gnunet_reclaim_service.h"
@@ -571,7 +570,7 @@ check_consume_ticket_result (void *cls,
571 570
572 msg_len = ntohs (msg->header.size); 571 msg_len = ntohs (msg->header.size);
573 attrs_len = ntohs (msg->attrs_len); 572 attrs_len = ntohs (msg->attrs_len);
574 key_len = ntohl (msg->key_len); 573 key_len = ntohs (msg->key_len);
575 pl_len = ntohs (msg->presentations_len); 574 pl_len = ntohs (msg->presentations_len);
576 if (msg_len != sizeof(*msg) + attrs_len + pl_len + key_len) 575 if (msg_len != sizeof(*msg) + attrs_len + pl_len + key_len)
577 { 576 {
@@ -604,7 +603,7 @@ handle_consume_ticket_result (void *cls,
604 char *read_ptr; 603 char *read_ptr;
605 604
606 attrs_len = ntohs (msg->attrs_len); 605 attrs_len = ntohs (msg->attrs_len);
607 key_len = ntohl (msg->key_len); 606 key_len = ntohs (msg->key_len);
608 pl_len = ntohs (msg->presentations_len); 607 pl_len = ntohs (msg->presentations_len);
609 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n"); 608 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing ticket result.\n");
610 609
@@ -695,7 +694,7 @@ check_attribute_result (void *cls, const struct AttributeResultMessage *msg)
695 694
696 msg_len = ntohs (msg->header.size); 695 msg_len = ntohs (msg->header.size);
697 attr_len = ntohs (msg->attr_len); 696 attr_len = ntohs (msg->attr_len);
698 key_len = ntohl (msg->pkey_len); 697 key_len = ntohs (msg->pkey_len);
699 if (msg_len != sizeof(*msg) + attr_len + key_len) 698 if (msg_len != sizeof(*msg) + attr_len + key_len)
700 { 699 {
701 GNUNET_break (0); 700 GNUNET_break (0);
@@ -726,7 +725,7 @@ handle_attribute_result (void *cls, const struct AttributeResultMessage *msg)
726 char *buf; 725 char *buf;
727 726
728 attr_len = ntohs (msg->attr_len); 727 attr_len = ntohs (msg->attr_len);
729 key_len = ntohl (msg->pkey_len); 728 key_len = ntohs (msg->pkey_len);
730 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n"); 729 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing attribute result.\n");
731 730
732 for (it = h->it_head; NULL != it; it = it->next) 731 for (it = h->it_head; NULL != it; it = it->next)
@@ -806,7 +805,7 @@ check_credential_result (void *cls, const struct CredentialResultMessage *msg)
806 805
807 msg_len = ntohs (msg->header.size); 806 msg_len = ntohs (msg->header.size);
808 cred_len = ntohs (msg->credential_len); 807 cred_len = ntohs (msg->credential_len);
809 key_len = ntohl (msg->key_len); 808 key_len = ntohs (msg->key_len);
810 if (msg_len != sizeof(*msg) + cred_len + key_len) 809 if (msg_len != sizeof(*msg) + cred_len + key_len)
811 { 810 {
812 GNUNET_break (0); 811 GNUNET_break (0);
@@ -837,7 +836,7 @@ handle_credential_result (void *cls, const struct
837 uint32_t r_id = ntohl (msg->id); 836 uint32_t r_id = ntohl (msg->id);
838 char *buf; 837 char *buf;
839 838
840 key_len = ntohl (msg->key_len); 839 key_len = ntohs (msg->key_len);
841 att_len = ntohs (msg->credential_len); 840 att_len = ntohs (msg->credential_len);
842 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing credential result.\n"); 841 LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing credential result.\n");
843 842
@@ -923,7 +922,7 @@ check_ticket_result (void *cls, const struct TicketResultMessage *msg)
923 922
924 msg_len = ntohs (msg->header.size); 923 msg_len = ntohs (msg->header.size);
925 pres_len = ntohs (msg->presentations_len); 924 pres_len = ntohs (msg->presentations_len);
926 tkt_len = ntohl (msg->tkt_len); 925 tkt_len = ntohs (msg->tkt_len);
927 if (msg_len != sizeof(*msg) + pres_len + tkt_len) 926 if (msg_len != sizeof(*msg) + pres_len + tkt_len)
928 { 927 {
929 GNUNET_break (0); 928 GNUNET_break (0);
@@ -954,7 +953,7 @@ handle_ticket_result (void *cls, const struct TicketResultMessage *msg)
954 size_t tb_read; 953 size_t tb_read;
955 char *buf; 954 char *buf;
956 955
957 tkt_len = ntohl (msg->tkt_len); 956 tkt_len = ntohs (msg->tkt_len);
958 pres_len = ntohs (msg->presentations_len); 957 pres_len = ntohs (msg->presentations_len);
959 for (op = handle->op_head; NULL != op; op = op->next) 958 for (op = handle->op_head; NULL != op; op = op->next)
960 if (op->r_id == r_id) 959 if (op->r_id == r_id)
@@ -1186,7 +1185,7 @@ GNUNET_RECLAIM_attribute_store (
1186 op->env = GNUNET_MQ_msg_extra (sam, 1185 op->env = GNUNET_MQ_msg_extra (sam,
1187 attr_len + key_len, 1186 attr_len + key_len,
1188 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE); 1187 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE);
1189 sam->key_len = htonl (key_len); 1188 sam->key_len = htons (key_len);
1190 buf = (char *) &sam[1]; 1189 buf = (char *) &sam[1];
1191 written = GNUNET_IDENTITY_write_private_key_to_buffer (pkey, buf, key_len); 1190 written = GNUNET_IDENTITY_write_private_key_to_buffer (pkey, buf, key_len);
1192 GNUNET_assert (0 < written); 1191 GNUNET_assert (0 < written);
@@ -1229,7 +1228,7 @@ GNUNET_RECLAIM_attribute_delete (
1229 op->env = GNUNET_MQ_msg_extra (dam, 1228 op->env = GNUNET_MQ_msg_extra (dam,
1230 attr_len + key_len, 1229 attr_len + key_len,
1231 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE); 1230 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE);
1232 dam->key_len = htonl (key_len); 1231 dam->key_len = htons (key_len);
1233 buf = (char *) &dam[1]; 1232 buf = (char *) &dam[1];
1234 written = GNUNET_IDENTITY_write_private_key_to_buffer (pkey, buf, key_len); 1233 written = GNUNET_IDENTITY_write_private_key_to_buffer (pkey, buf, key_len);
1235 GNUNET_assert (0 < written); 1234 GNUNET_assert (0 < written);
@@ -1271,7 +1270,7 @@ GNUNET_RECLAIM_credential_store (
1271 op->env = GNUNET_MQ_msg_extra (sam, 1270 op->env = GNUNET_MQ_msg_extra (sam,
1272 attr_len + key_len, 1271 attr_len + key_len,
1273 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE); 1272 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_STORE);
1274 sam->key_len = htonl (key_len); 1273 sam->key_len = htons (key_len);
1275 buf = (char *) &sam[1]; 1274 buf = (char *) &sam[1];
1276 written = GNUNET_IDENTITY_write_private_key_to_buffer (pkey, buf, key_len); 1275 written = GNUNET_IDENTITY_write_private_key_to_buffer (pkey, buf, key_len);
1277 GNUNET_assert (0 <= written); 1276 GNUNET_assert (0 <= written);
@@ -1314,7 +1313,7 @@ GNUNET_RECLAIM_credential_delete (
1314 op->env = GNUNET_MQ_msg_extra (dam, 1313 op->env = GNUNET_MQ_msg_extra (dam,
1315 attr_len + key_len, 1314 attr_len + key_len,
1316 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE); 1315 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_DELETE);
1317 dam->key_len = htonl (key_len); 1316 dam->key_len = htons (key_len);
1318 buf = (char *) &dam[1]; 1317 buf = (char *) &dam[1];
1319 written = GNUNET_IDENTITY_write_private_key_to_buffer (pkey, buf, key_len); 1318 written = GNUNET_IDENTITY_write_private_key_to_buffer (pkey, buf, key_len);
1320 GNUNET_assert (0 <= written); 1319 GNUNET_assert (0 <= written);
@@ -1364,7 +1363,7 @@ GNUNET_RECLAIM_get_attributes_start (
1364 key_len, 1363 key_len,
1365 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START); 1364 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START);
1366 msg->id = htonl (rid); 1365 msg->id = htonl (rid);
1367 msg->key_len = htonl (key_len); 1366 msg->key_len = htons (key_len);
1368 GNUNET_IDENTITY_write_private_key_to_buffer (identity, &msg[1], key_len); 1367 GNUNET_IDENTITY_write_private_key_to_buffer (identity, &msg[1], key_len);
1369 if (NULL == h->mq) 1368 if (NULL == h->mq)
1370 it->env = env; 1369 it->env = env;
@@ -1441,7 +1440,7 @@ GNUNET_RECLAIM_get_credentials_start (
1441 key_len, 1440 key_len,
1442 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START); 1441 GNUNET_MESSAGE_TYPE_RECLAIM_CREDENTIAL_ITERATION_START);
1443 msg->id = htonl (rid); 1442 msg->id = htonl (rid);
1444 msg->key_len = htonl (key_len); 1443 msg->key_len = htons (key_len);
1445 GNUNET_IDENTITY_write_private_key_to_buffer (identity, &msg[1], key_len); 1444 GNUNET_IDENTITY_write_private_key_to_buffer (identity, &msg[1], key_len);
1446 if (NULL == h->mq) 1445 if (NULL == h->mq)
1447 ait->env = env; 1446 ait->env = env;
@@ -1515,8 +1514,8 @@ GNUNET_RECLAIM_ticket_issue (
1515 op->env = GNUNET_MQ_msg_extra (tim, 1514 op->env = GNUNET_MQ_msg_extra (tim,
1516 attr_len + key_len + rpk_len, 1515 attr_len + key_len + rpk_len,
1517 GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET); 1516 GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET);
1518 tim->key_len = htonl (key_len); 1517 tim->key_len = htons (key_len);
1519 tim->pkey_len = htonl (rpk_len); 1518 tim->pkey_len = htons (rpk_len);
1520 buf = (char *) &tim[1]; 1519 buf = (char *) &tim[1];
1521 written = GNUNET_IDENTITY_write_private_key_to_buffer (iss, buf, key_len); 1520 written = GNUNET_IDENTITY_write_private_key_to_buffer (iss, buf, key_len);
1522 GNUNET_assert (0 <= written); 1521 GNUNET_assert (0 <= written);
@@ -1571,11 +1570,11 @@ GNUNET_RECLAIM_ticket_consume (
1571 op->env = GNUNET_MQ_msg_extra (ctm, 1570 op->env = GNUNET_MQ_msg_extra (ctm,
1572 key_len + tkt_len, 1571 key_len + tkt_len,
1573 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET); 1572 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET);
1574 ctm->key_len = htonl (key_len); 1573 ctm->key_len = htons (key_len);
1575 buf = (char*) &ctm[1]; 1574 buf = (char*) &ctm[1];
1576 GNUNET_IDENTITY_write_private_key_to_buffer (identity, buf, key_len); 1575 GNUNET_IDENTITY_write_private_key_to_buffer (identity, buf, key_len);
1577 buf += key_len; 1576 buf += key_len;
1578 ctm->tkt_len = htonl (tkt_len); 1577 ctm->tkt_len = htons (tkt_len);
1579 GNUNET_RECLAIM_write_ticket_to_buffer (ticket, buf, tkt_len); 1578 GNUNET_RECLAIM_write_ticket_to_buffer (ticket, buf, tkt_len);
1580 ctm->id = htonl (op->r_id); 1579 ctm->id = htonl (op->r_id);
1581 if (NULL != h->mq) 1580 if (NULL != h->mq)
@@ -1620,7 +1619,7 @@ GNUNET_RECLAIM_ticket_iteration_start (
1620 key_len, 1619 key_len,
1621 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START); 1620 GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START);
1622 msg->id = htonl (rid); 1621 msg->id = htonl (rid);
1623 msg->key_len = htonl (key_len); 1622 msg->key_len = htons (key_len);
1624 GNUNET_IDENTITY_write_private_key_to_buffer (identity, 1623 GNUNET_IDENTITY_write_private_key_to_buffer (identity,
1625 &msg[1], 1624 &msg[1],
1626 key_len); 1625 key_len);
@@ -1718,8 +1717,8 @@ GNUNET_RECLAIM_ticket_revoke (
1718 key_len + tkt_len, 1717 key_len + tkt_len,
1719 GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET); 1718 GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET);
1720 msg->id = htonl (rid); 1719 msg->id = htonl (rid);
1721 msg->key_len = htonl (key_len); 1720 msg->key_len = htons (key_len);
1722 msg->tkt_len = htonl (tkt_len); 1721 msg->tkt_len = htons (tkt_len);
1723 buf = (char*) &msg[1]; 1722 buf = (char*) &msg[1];
1724 written = GNUNET_IDENTITY_write_private_key_to_buffer (identity, 1723 written = GNUNET_IDENTITY_write_private_key_to_buffer (identity,
1725 buf, 1724 buf,
diff --git a/src/reclaim/reclaim_attribute.c b/src/reclaim/reclaim_attribute.c
index b5c41b2d1..b235ed945 100644
--- a/src/reclaim/reclaim_attribute.c
+++ b/src/reclaim/reclaim_attribute.c
@@ -472,7 +472,7 @@ GNUNET_RECLAIM_attribute_serialize (
472 char *write_ptr; 472 char *write_ptr;
473 473
474 attr_ser = (struct Attribute *) result; 474 attr_ser = (struct Attribute *) result;
475 attr_ser->attribute_type = htons (attr->type); 475 attr_ser->attribute_type = htonl (attr->type);
476 attr_ser->attribute_flag = htonl (attr->flag); 476 attr_ser->attribute_flag = htonl (attr->flag);
477 attr_ser->attribute_id = attr->id; 477 attr_ser->attribute_id = attr->id;
478 attr_ser->credential_id = attr->credential; 478 attr_ser->credential_id = attr->credential;
@@ -524,7 +524,7 @@ GNUNET_RECLAIM_attribute_deserialize (const char *data, size_t data_size,
524 } 524 }
525 attribute = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attribute) 525 attribute = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attribute)
526 + data_len + name_len + 1); 526 + data_len + name_len + 1);
527 attribute->type = ntohs (attr_ser->attribute_type); 527 attribute->type = ntohl (attr_ser->attribute_type);
528 attribute->flag = ntohl (attr_ser->attribute_flag); 528 attribute->flag = ntohl (attr_ser->attribute_flag);
529 attribute->id = attr_ser->attribute_id; 529 attribute->id = attr_ser->attribute_id;
530 attribute->credential = attr_ser->credential_id; 530 attribute->credential = attr_ser->credential_id;
diff --git a/src/reclaim/reclaim_attribute.h b/src/reclaim/reclaim_attribute.h
index 285d75d83..44d85e61c 100644
--- a/src/reclaim/reclaim_attribute.h
+++ b/src/reclaim/reclaim_attribute.h
@@ -56,14 +56,24 @@ struct Attribute
56 struct GNUNET_RECLAIM_Identifier credential_id; 56 struct GNUNET_RECLAIM_Identifier credential_id;
57 57
58 /** 58 /**
59 * Reserved (alignment)
60 */
61 uint16_t reserved_nl GNUNET_PACKED;
62
63 /**
59 * Name length 64 * Name length
60 */ 65 */
61 uint32_t name_len GNUNET_PACKED; 66 uint16_t name_len GNUNET_PACKED;
67
68 /**
69 * Reserved (alignment)
70 */
71 uint16_t reserved_ds GNUNET_PACKED;
62 72
63 /** 73 /**
64 * Data size 74 * Data size
65 */ 75 */
66 uint32_t data_size GNUNET_PACKED; 76 uint16_t data_size GNUNET_PACKED;
67 77
68 // followed by data_size Attribute value data 78 // followed by data_size Attribute value data
69}; 79};
diff --git a/src/reclaim/reclaim_credential.c b/src/reclaim/reclaim_credential.c
index 6dc1a1fcf..1aad261a1 100644
--- a/src/reclaim/reclaim_credential.c
+++ b/src/reclaim/reclaim_credential.c
@@ -437,7 +437,7 @@ GNUNET_RECLAIM_credential_serialize (
437 char *write_ptr; 437 char *write_ptr;
438 438
439 atts = (struct Credential *) result; 439 atts = (struct Credential *) result;
440 atts->credential_type = htons (credential->type); 440 atts->credential_type = htonl (credential->type);
441 atts->credential_flag = htonl (credential->flag); 441 atts->credential_flag = htonl (credential->flag);
442 atts->credential_id = credential->id; 442 atts->credential_id = credential->id;
443 name_len = strlen (credential->name); 443 name_len = strlen (credential->name);
@@ -488,7 +488,7 @@ GNUNET_RECLAIM_credential_deserialize (const char *data, size_t data_size)
488 } 488 }
489 credential = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Credential) 489 credential = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Credential)
490 + data_len + name_len + 1); 490 + data_len + name_len + 1);
491 credential->type = ntohs (atts->credential_type); 491 credential->type = ntohl (atts->credential_type);
492 credential->flag = ntohl (atts->credential_flag); 492 credential->flag = ntohl (atts->credential_flag);
493 credential->id = atts->credential_id; 493 credential->id = atts->credential_id;
494 credential->data_size = data_len; 494 credential->data_size = data_len;
@@ -856,7 +856,7 @@ GNUNET_RECLAIM_presentation_serialize (
856 char *write_ptr; 856 char *write_ptr;
857 857
858 atts = (struct Presentation *) result; 858 atts = (struct Presentation *) result;
859 atts->presentation_type = htons (presentation->type); 859 atts->presentation_type = htonl (presentation->type);
860 atts->credential_id = presentation->credential_id; 860 atts->credential_id = presentation->credential_id;
861 write_ptr = (char *) &atts[1]; 861 write_ptr = (char *) &atts[1];
862 GNUNET_memcpy (write_ptr, presentation->data, presentation->data_size); 862 GNUNET_memcpy (write_ptr, presentation->data, presentation->data_size);
@@ -895,7 +895,7 @@ GNUNET_RECLAIM_presentation_deserialize (const char *data, size_t data_size)
895 } 895 }
896 presentation = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Presentation) 896 presentation = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Presentation)
897 + data_len); 897 + data_len);
898 presentation->type = ntohs (atts->presentation_type); 898 presentation->type = ntohl (atts->presentation_type);
899 presentation->credential_id = atts->credential_id; 899 presentation->credential_id = atts->credential_id;
900 presentation->data_size = data_len; 900 presentation->data_size = data_len;
901 901
diff --git a/src/reclaim/reclaim_credential.h b/src/reclaim/reclaim_credential.h
index 7704ed968..ffec15445 100644
--- a/src/reclaim/reclaim_credential.h
+++ b/src/reclaim/reclaim_credential.h
@@ -49,14 +49,24 @@ struct Credential
49 struct GNUNET_RECLAIM_Identifier credential_id; 49 struct GNUNET_RECLAIM_Identifier credential_id;
50 50
51 /** 51 /**
52 * Reserved (alignment)
53 */
54 uint16_t nl_reserved;
55
56 /**
52 * Name length 57 * Name length
53 */ 58 */
54 uint32_t name_len; 59 uint16_t name_len;
60
61 /**
62 * Reserved (alignment)
63 */
64 uint16_t dl_reserved;
55 65
56 /** 66 /**
57 * Data size 67 * Data size
58 */ 68 */
59 uint32_t data_size; 69 uint16_t data_size;
60 70
61 // followed by data_size Credential value data 71 // followed by data_size Credential value data
62}; 72};
@@ -83,14 +93,24 @@ struct Presentation
83 struct GNUNET_RECLAIM_Identifier credential_id; 93 struct GNUNET_RECLAIM_Identifier credential_id;
84 94
85 /** 95 /**
96 * Reserved (alignment)
97 */
98 uint16_t reserved_nl GNUNET_PACKED;
99
100 /**
86 * Name length 101 * Name length
87 */ 102 */
88 uint32_t name_len; 103 uint16_t name_len GNUNET_PACKED;
104
105 /**
106 * Reserved (alignment)
107 */
108 uint16_t reserved_ds GNUNET_PACKED;
89 109
90 /** 110 /**
91 * Data size 111 * Data size
92 */ 112 */
93 uint32_t data_size; 113 uint16_t data_size GNUNET_PACKED;
94 114
95 // followed by data_size Presentation value data 115 // followed by data_size Presentation value data
96}; 116};
diff --git a/src/reclaim/test_reclaim_attribute.c b/src/reclaim/test_reclaim_attribute.c
index f8faf8021..0740812eb 100644
--- a/src/reclaim/test_reclaim_attribute.c
+++ b/src/reclaim/test_reclaim_attribute.c
@@ -1,7 +1,6 @@
1#include "platform.h" 1#include "platform.h"
2#include "gnunet_common.h" 2#include "gnunet_common.h"
3#include "gnunet_reclaim_lib.h" 3#include "gnunet_reclaim_lib.h"
4#include "gnunet_container_lib.h"
5 4
6int 5int
7main (int argc, char *argv[]) 6main (int argc, char *argv[])
diff --git a/src/regex/gnunet-regex-simulation-profiler.c b/src/regex/gnunet-regex-simulation-profiler.c
index ab6d65d58..abdb1abeb 100644
--- a/src/regex/gnunet-regex-simulation-profiler.c
+++ b/src/regex/gnunet-regex-simulation-profiler.c
@@ -32,6 +32,7 @@
32#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
33#include "regex_internal_lib.h" 33#include "regex_internal_lib.h"
34#include "gnunet_mysql_lib.h" 34#include "gnunet_mysql_lib.h"
35#include "gnunet_mysql_compat.h"
35#include "gnunet_my_lib.h" 36#include "gnunet_my_lib.h"
36#include <mysql/mysql.h> 37#include <mysql/mysql.h>
37 38
diff --git a/src/regex/perf-regex.c b/src/regex/perf-regex.c
index aea0c054f..fbddc58eb 100644
--- a/src/regex/perf-regex.c
+++ b/src/regex/perf-regex.c
@@ -23,9 +23,9 @@
23 * @brief Test how long it takes to create a automaton from a string regex. 23 * @brief Test how long it takes to create a automaton from a string regex.
24 * @author Bartlomiej Polot 24 * @author Bartlomiej Polot
25 */ 25 */
26#include "platform.h"
26#include <regex.h> 27#include <regex.h>
27#include <time.h> 28#include <time.h>
28#include "platform.h"
29#include "regex_internal_lib.h" 29#include "regex_internal_lib.h"
30#include "regex_test_lib.h" 30#include "regex_test_lib.h"
31 31
diff --git a/src/regex/regex_test_random.c b/src/regex/regex_test_random.c
index 823563d4d..56508b3b4 100644
--- a/src/regex/regex_test_random.c
+++ b/src/regex/regex_test_random.c
@@ -24,7 +24,7 @@
24 */ 24 */
25#include "platform.h" 25#include "platform.h"
26#include "regex_test_lib.h" 26#include "regex_test_lib.h"
27#include "gnunet_crypto_lib.h" 27#include "gnunet_util_lib.h"
28#include "regex_internal.h" 28#include "regex_internal.h"
29 29
30 30
diff --git a/src/regex/test_regex_eval_api.c b/src/regex/test_regex_eval_api.c
index be3649dbd..475bfb7c8 100644
--- a/src/regex/test_regex_eval_api.c
+++ b/src/regex/test_regex_eval_api.c
@@ -22,9 +22,9 @@
22 * @brief test for regex.c 22 * @brief test for regex.c
23 * @author Maximilian Szengel 23 * @author Maximilian Szengel
24 */ 24 */
25#include "platform.h"
25#include <regex.h> 26#include <regex.h>
26#include <time.h> 27#include <time.h>
27#include "platform.h"
28#include "regex_internal_lib.h" 28#include "regex_internal_lib.h"
29#include "regex_test_lib.h" 29#include "regex_test_lib.h"
30#include "regex_internal.h" 30#include "regex_internal.h"
diff --git a/src/regex/test_regex_graph_api.c b/src/regex/test_regex_graph_api.c
index 923bb9f42..5c12ea229 100644
--- a/src/regex/test_regex_graph_api.c
+++ b/src/regex/test_regex_graph_api.c
@@ -22,9 +22,9 @@
22 * @brief test for regex_graph.c 22 * @brief test for regex_graph.c
23 * @author Maximilian Szengel 23 * @author Maximilian Szengel
24 */ 24 */
25#include "platform.h"
25#include <regex.h> 26#include <regex.h>
26#include <time.h> 27#include <time.h>
27#include "platform.h"
28#include "regex_internal_lib.h" 28#include "regex_internal_lib.h"
29#include "regex_test_lib.h" 29#include "regex_test_lib.h"
30#include "regex_internal.h" 30#include "regex_internal.h"
diff --git a/src/regex/test_regex_integration.c b/src/regex/test_regex_integration.c
index 2e6874e4d..1f422e5a3 100644
--- a/src/regex/test_regex_integration.c
+++ b/src/regex/test_regex_integration.c
@@ -27,7 +27,6 @@
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_applications.h" 28#include "gnunet_applications.h"
29#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
30#include "gnunet_tun_lib.h"
31#include "gnunet_testing_lib.h" 30#include "gnunet_testing_lib.h"
32#include "gnunet_regex_service.h" 31#include "gnunet_regex_service.h"
33 32
diff --git a/src/regex/test_regex_iterate_api.c b/src/regex/test_regex_iterate_api.c
index e7ef72b58..4fb4f7817 100644
--- a/src/regex/test_regex_iterate_api.c
+++ b/src/regex/test_regex_iterate_api.c
@@ -22,9 +22,9 @@
22 * @brief test for regex.c 22 * @brief test for regex.c
23 * @author Maximilian Szengel 23 * @author Maximilian Szengel
24 */ 24 */
25#include "platform.h"
25#include <regex.h> 26#include <regex.h>
26#include <time.h> 27#include <time.h>
27#include "platform.h"
28#include "regex_internal_lib.h" 28#include "regex_internal_lib.h"
29#include "regex_block_lib.h" 29#include "regex_block_lib.h"
30#include "regex_internal.h" 30#include "regex_internal.h"
diff --git a/src/revocation/gnunet-revocation-tvg.c b/src/revocation/gnunet-revocation-tvg.c
index a126709ce..e1c9aa044 100644
--- a/src/revocation/gnunet-revocation-tvg.c
+++ b/src/revocation/gnunet-revocation-tvg.c
@@ -27,7 +27,6 @@
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_signatures.h" 28#include "gnunet_signatures.h"
29#include "gnunet_revocation_service.h" 29#include "gnunet_revocation_service.h"
30#include "gnunet_dnsparser_lib.h"
31#include "gnunet_testing_lib.h" 30#include "gnunet_testing_lib.h"
32#include "revocation.h" 31#include "revocation.h"
33#include <inttypes.h> 32#include <inttypes.h>
diff --git a/src/rps/test_service_rps_custommap.c b/src/rps/test_service_rps_custommap.c
index 3d885ca6b..82d75b7e0 100644
--- a/src/rps/test_service_rps_custommap.c
+++ b/src/rps/test_service_rps_custommap.c
@@ -21,6 +21,7 @@
21 * @file rps/test_service_rps_custommap.c 21 * @file rps/test_service_rps_custommap.c
22 * @brief testcase for gnunet-service-rps_peers.c 22 * @brief testcase for gnunet-service-rps_peers.c
23 */ 23 */
24#include "platform.h"
24#include <platform.h> 25#include <platform.h>
25#include "gnunet-service-rps_custommap.h" 26#include "gnunet-service-rps_custommap.h"
26 27
diff --git a/src/rps/test_service_rps_sampler_elem.c b/src/rps/test_service_rps_sampler_elem.c
index 8fef5adaf..afa17611c 100644
--- a/src/rps/test_service_rps_sampler_elem.c
+++ b/src/rps/test_service_rps_sampler_elem.c
@@ -21,6 +21,7 @@
21 * @file rps/test_service_rps_sampler_elem.c 21 * @file rps/test_service_rps_sampler_elem.c
22 * @brief testcase for gnunet-service-rps_sampler_elem.c 22 * @brief testcase for gnunet-service-rps_sampler_elem.c
23 */ 23 */
24#include "platform.h"
24#include <platform.h> 25#include <platform.h>
25#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
26#include "gnunet-service-rps_sampler_elem.h" 27#include "gnunet-service-rps_sampler_elem.h"
diff --git a/src/rps/test_service_rps_view.c b/src/rps/test_service_rps_view.c
index 5a8c00849..bb1413168 100644
--- a/src/rps/test_service_rps_view.c
+++ b/src/rps/test_service_rps_view.c
@@ -21,6 +21,7 @@
21 * @file rps/test_service_rps_view.c 21 * @file rps/test_service_rps_view.c
22 * @brief testcase for gnunet-service-rps_view.c 22 * @brief testcase for gnunet-service-rps_view.c
23 */ 23 */
24#include "platform.h"
24#include <platform.h> 25#include <platform.h>
25#include "gnunet-service-rps_view.h" 26#include "gnunet-service-rps_view.h"
26 27
diff --git a/src/scalarproduct/gnunet-scalarproduct.c b/src/scalarproduct/gnunet-scalarproduct.c
index 07af916b1..5ebab5baf 100644
--- a/src/scalarproduct/gnunet-scalarproduct.c
+++ b/src/scalarproduct/gnunet-scalarproduct.c
@@ -24,10 +24,10 @@
24 * @author Christian M. Fuchs 24 * @author Christian M. Fuchs
25 */ 25 */
26#define GCRYPT_NO_DEPRECATED 26#define GCRYPT_NO_DEPRECATED
27#include "platform.h"
27#include <gcrypt.h> 28#include <gcrypt.h>
28#include <inttypes.h> 29#include <inttypes.h>
29 30
30#include "platform.h"
31#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_scalarproduct_service.h" 32#include "gnunet_scalarproduct_service.h"
33#include "gnunet_protocols.h" 33#include "gnunet_protocols.h"
diff --git a/src/secretsharing/secretsharing_common.c b/src/secretsharing/secretsharing_common.c
index 3003109a4..44b96b1c8 100644
--- a/src/secretsharing/secretsharing_common.c
+++ b/src/secretsharing/secretsharing_common.c
@@ -18,6 +18,7 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20 20
21#include "platform.h"
21#include "secretsharing.h" 22#include "secretsharing.h"
22 23
23/** 24/**
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c
index 208c63a1a..7c522ec34 100644
--- a/src/set/gnunet-service-set.c
+++ b/src/set/gnunet-service-set.c
@@ -23,6 +23,7 @@
23 * @author Florian Dold 23 * @author Florian Dold
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "platform.h"
26#include "gnunet-service-set.h" 27#include "gnunet-service-set.h"
27#include "gnunet-service-set_union.h" 28#include "gnunet-service-set_union.h"
28#include "gnunet-service-set_intersection.h" 29#include "gnunet-service-set_intersection.h"
diff --git a/src/set/ibf.c b/src/set/ibf.c
index 0f7eb6a9f..b6fb52b6b 100644
--- a/src/set/ibf.c
+++ b/src/set/ibf.c
@@ -24,6 +24,7 @@
24 * @author Florian Dold 24 * @author Florian Dold
25 */ 25 */
26 26
27#include "platform.h"
27#include "ibf.h" 28#include "ibf.h"
28 29
29/** 30/**
diff --git a/src/set/ibf_sim.c b/src/set/ibf_sim.c
index 6415d00e1..563ed0fb8 100644
--- a/src/set/ibf_sim.c
+++ b/src/set/ibf_sim.c
@@ -26,6 +26,7 @@
26 * This code was used for some internal experiments, it is not 26 * This code was used for some internal experiments, it is not
27 * build or shipped as part of the GNUnet system. 27 * build or shipped as part of the GNUnet system.
28 */ 28 */
29#include "platform.h"
29#include <stdlib.h> 30#include <stdlib.h>
30#include <stdio.h> 31#include <stdio.h>
31#include <string.h> 32#include <string.h>
diff --git a/src/seti/gnunet-service-seti.c b/src/seti/gnunet-service-seti.c
index af478233b..6db24a5b6 100644
--- a/src/seti/gnunet-service-seti.c
+++ b/src/seti/gnunet-service-seti.c
@@ -23,6 +23,7 @@
23 * @author Florian Dold 23 * @author Florian Dold
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "platform.h"
26#include "gnunet-service-seti_protocol.h" 27#include "gnunet-service-seti_protocol.h"
27#include "gnunet_statistics_service.h" 28#include "gnunet_statistics_service.h"
28#include "gnunet_cadet_service.h" 29#include "gnunet_cadet_service.h"
diff --git a/src/setu/ibf.c b/src/setu/ibf.c
index 3978aa3c6..a55e21764 100644
--- a/src/setu/ibf.c
+++ b/src/setu/ibf.c
@@ -25,6 +25,7 @@
25 * @author Elias Summermatter 25 * @author Elias Summermatter
26 */ 26 */
27 27
28#include "platform.h"
28#include "ibf.h" 29#include "ibf.h"
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
30#define LOG(kind, ...) GNUNET_log_from (kind, "setu", __VA_ARGS__) 31#define LOG(kind, ...) GNUNET_log_from (kind, "setu", __VA_ARGS__)
diff --git a/src/setu/ibf_sim.c b/src/setu/ibf_sim.c
index 6415d00e1..563ed0fb8 100644
--- a/src/setu/ibf_sim.c
+++ b/src/setu/ibf_sim.c
@@ -26,6 +26,7 @@
26 * This code was used for some internal experiments, it is not 26 * This code was used for some internal experiments, it is not
27 * build or shipped as part of the GNUnet system. 27 * build or shipped as part of the GNUnet system.
28 */ 28 */
29#include "platform.h"
29#include <stdlib.h> 30#include <stdlib.h>
30#include <stdio.h> 31#include <stdio.h>
31#include <string.h> 32#include <string.h>
diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c
index 37cf524d0..a6c897a79 100644
--- a/src/statistics/gnunet-service-statistics.c
+++ b/src/statistics/gnunet-service-statistics.c
@@ -24,14 +24,9 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_bio_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_container_lib.h"
29#include "gnunet_disk_lib.h"
30#include "gnunet_getopt_lib.h"
31#include "gnunet_protocols.h" 28#include "gnunet_protocols.h"
32#include "gnunet_service_lib.h"
33#include "gnunet_statistics_service.h" 29#include "gnunet_statistics_service.h"
34#include "gnunet_strings_lib.h"
35#include "gnunet_time_lib.h" 30#include "gnunet_time_lib.h"
36#include "statistics.h" 31#include "statistics.h"
37 32
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c
index b2f04d5d8..1e6e02294 100644
--- a/src/testbed/gnunet-service-testbed.c
+++ b/src/testbed/gnunet-service-testbed.c
@@ -24,6 +24,7 @@
24 * @author Sree Harsha Totakura 24 * @author Sree Harsha Totakura
25 */ 25 */
26 26
27#include "platform.h"
27#include "gnunet-service-testbed.h" 28#include "gnunet-service-testbed.h"
28#include "gnunet-service-testbed_barriers.h" 29#include "gnunet-service-testbed_barriers.h"
29#include "gnunet-service-testbed_connectionpool.h" 30#include "gnunet-service-testbed_connectionpool.h"
diff --git a/src/testbed/gnunet-service-testbed_barriers.c b/src/testbed/gnunet-service-testbed_barriers.c
index bc6148087..a7eba3201 100644
--- a/src/testbed/gnunet-service-testbed_barriers.c
+++ b/src/testbed/gnunet-service-testbed_barriers.c
@@ -24,6 +24,7 @@
24 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 24 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
25 */ 25 */
26 26
27#include "platform.h"
27#include "gnunet-service-testbed.h" 28#include "gnunet-service-testbed.h"
28#include "gnunet-service-testbed_barriers.h" 29#include "gnunet-service-testbed_barriers.h"
29#include "testbed_api.h" 30#include "testbed_api.h"
@@ -803,6 +804,7 @@ handle_barrier_cancel (void *cls,
803 &hash)) 804 &hash))
804 { 805 {
805 GNUNET_break_op (0); 806 GNUNET_break_op (0);
807 GNUNET_free (name);
806 GNUNET_SERVICE_client_drop (client); 808 GNUNET_SERVICE_client_drop (client);
807 return; 809 return;
808 } 810 }
@@ -811,6 +813,7 @@ handle_barrier_cancel (void *cls,
811 GNUNET_assert (NULL != barrier); 813 GNUNET_assert (NULL != barrier);
812 cancel_wrappers (barrier); 814 cancel_wrappers (barrier);
813 remove_barrier (barrier); 815 remove_barrier (barrier);
816 GNUNET_free (name);
814 GNUNET_SERVICE_client_continue (client); 817 GNUNET_SERVICE_client_continue (client);
815} 818}
816 819
diff --git a/src/testbed/gnunet-service-testbed_cache.c b/src/testbed/gnunet-service-testbed_cache.c
index 5e74b865a..5d5c2e297 100644
--- a/src/testbed/gnunet-service-testbed_cache.c
+++ b/src/testbed/gnunet-service-testbed_cache.c
@@ -23,6 +23,7 @@
23 * @brief testbed cache implementation 23 * @brief testbed cache implementation
24 * @author Sree Harsha Totakura 24 * @author Sree Harsha Totakura
25 */ 25 */
26#include "platform.h"
26#include "gnunet-service-testbed.h" 27#include "gnunet-service-testbed.h"
27 28
28/** 29/**
diff --git a/src/testbed/gnunet-service-testbed_connectionpool.c b/src/testbed/gnunet-service-testbed_connectionpool.c
index 59780e6c1..64b6706a4 100644
--- a/src/testbed/gnunet-service-testbed_connectionpool.c
+++ b/src/testbed/gnunet-service-testbed_connectionpool.c
@@ -24,6 +24,7 @@
24 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 24 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
25 */ 25 */
26 26
27#include "platform.h"
27#include "gnunet-service-testbed.h" 28#include "gnunet-service-testbed.h"
28#include "gnunet-service-testbed_connectionpool.h" 29#include "gnunet-service-testbed_connectionpool.h"
29#include "testbed_api_operations.h" 30#include "testbed_api_operations.h"
diff --git a/src/testbed/gnunet-service-testbed_links.c b/src/testbed/gnunet-service-testbed_links.c
index fe87d64ea..f4c27ffa2 100644
--- a/src/testbed/gnunet-service-testbed_links.c
+++ b/src/testbed/gnunet-service-testbed_links.c
@@ -25,6 +25,7 @@
25 * @author Sree Harsha Totakura 25 * @author Sree Harsha Totakura
26 */ 26 */
27 27
28#include "platform.h"
28#include "gnunet-service-testbed.h" 29#include "gnunet-service-testbed.h"
29 30
30/** 31/**
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c
index b13a3b7e0..54a566e89 100644
--- a/src/testbed/gnunet-service-testbed_oc.c
+++ b/src/testbed/gnunet-service-testbed_oc.c
@@ -24,6 +24,7 @@
24 * @author Sree Harsha Totakura 24 * @author Sree Harsha Totakura
25 */ 25 */
26 26
27#include "platform.h"
27#include "gnunet-service-testbed.h" 28#include "gnunet-service-testbed.h"
28#include "gnunet-service-testbed_connectionpool.h" 29#include "gnunet-service-testbed_connectionpool.h"
29#include "gnunet_transport_hello_service.h" 30#include "gnunet_transport_hello_service.h"
diff --git a/src/testbed/gnunet-service-testbed_peers.c b/src/testbed/gnunet-service-testbed_peers.c
index 154a6d4ec..05410c26a 100644
--- a/src/testbed/gnunet-service-testbed_peers.c
+++ b/src/testbed/gnunet-service-testbed_peers.c
@@ -25,6 +25,7 @@
25 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 25 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
26 */ 26 */
27 27
28#include "platform.h"
28#include "gnunet-service-testbed.h" 29#include "gnunet-service-testbed.h"
29#include "gnunet_arm_service.h" 30#include "gnunet_arm_service.h"
30#include <zlib.h> 31#include <zlib.h>
diff --git a/src/testbed/testbed_api_operations.h b/src/testbed/testbed_api_operations.h
index 2dba9c14d..7d6659837 100644
--- a/src/testbed/testbed_api_operations.h
+++ b/src/testbed/testbed_api_operations.h
@@ -27,7 +27,7 @@
27#define NEW_TESTING_API_OPERATIONS_H 27#define NEW_TESTING_API_OPERATIONS_H
28 28
29#include "gnunet_testbed_service.h" 29#include "gnunet_testbed_service.h"
30#include "gnunet_helper_lib.h" 30#include "gnunet_util_lib.h"
31 31
32 32
33/** 33/**
diff --git a/src/testbed/testbed_api_peers.h b/src/testbed/testbed_api_peers.h
index db8ec9881..10129d961 100644
--- a/src/testbed/testbed_api_peers.h
+++ b/src/testbed/testbed_api_peers.h
@@ -29,7 +29,7 @@
29#define NEW_TESTING_API_PEERS_H 29#define NEW_TESTING_API_PEERS_H
30 30
31#include "gnunet_testbed_service.h" 31#include "gnunet_testbed_service.h"
32#include "gnunet_helper_lib.h" 32#include "gnunet_util_lib.h"
33 33
34 34
35/** 35/**
diff --git a/src/testbed/testbed_api_underlay.c b/src/testbed/testbed_api_underlay.c
index 7e509fdfe..8c01e4503 100644
--- a/src/testbed/testbed_api_underlay.c
+++ b/src/testbed/testbed_api_underlay.c
@@ -24,6 +24,7 @@
24 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 24 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
25 */ 25 */
26 26
27#include "platform.h"
27#include "testbed_api_peers.h" 28#include "testbed_api_peers.h"
28 29
29 30
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c
index 477c8c60f..624aa58eb 100644
--- a/src/testing/gnunet-cmds-helper.c
+++ b/src/testing/gnunet-cmds-helper.c
@@ -59,9 +59,9 @@
59 59
60#define NODE_BASE_IP "192.168.15." 60#define NODE_BASE_IP "192.168.15."
61 61
62#define KNOWN_BASE_IP "92.68.151." 62#define KNOWN_BASE_IP "172.168.151."
63 63
64#define ROUTER_BASE_IP "92.68.150." 64#define ROUTER_BASE_IP "172.16.150."
65 65
66struct GNUNET_SCHEDULER_Task *finished_task; 66struct GNUNET_SCHEDULER_Task *finished_task;
67 67
diff --git a/src/testing/testing.c b/src/testing/testing.c
index de6bc45f5..56dc4e92d 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -40,9 +40,9 @@
40 40
41#define CONNECT_ADDRESS_TEMPLATE "%s-192.168.15.%u" 41#define CONNECT_ADDRESS_TEMPLATE "%s-192.168.15.%u"
42 42
43#define ROUTER_CONNECT_ADDRESS_TEMPLATE "%s-92.68.150.%u" 43#define ROUTER_CONNECT_ADDRESS_TEMPLATE "%s-172.16.150.%u"
44 44
45#define KNOWN_CONNECT_ADDRESS_TEMPLATE "%s-92.68.151.%u" 45#define KNOWN_CONNECT_ADDRESS_TEMPLATE "%s-172.16.151.%u"
46 46
47#define PREFIX_TCP "tcp" 47#define PREFIX_TCP "tcp"
48 48
@@ -128,7 +128,7 @@ struct GNUNET_TESTING_System
128 */ 128 */
129 struct GNUNET_DISK_MapHandle *map; 129 struct GNUNET_DISK_MapHandle *map;
130 130
131 struct SharedService **shared_services; 131 struct SharedService *shared_services;
132 132
133 unsigned int n_shared_services; 133 unsigned int n_shared_services;
134 134
@@ -380,7 +380,7 @@ GNUNET_TESTING_system_create_with_portrange (
380{ 380{
381 struct GNUNET_TESTING_System *system; 381 struct GNUNET_TESTING_System *system;
382 struct GNUNET_TESTING_SharedService tss; 382 struct GNUNET_TESTING_SharedService tss;
383 struct SharedService *ss; 383 struct SharedService ss;
384 unsigned int cnt; 384 unsigned int cnt;
385 385
386 GNUNET_assert (NULL != testdir); 386 GNUNET_assert (NULL != testdir);
@@ -410,22 +410,22 @@ GNUNET_TESTING_system_create_with_portrange (
410 for (cnt = 0; NULL != shared_services[cnt].service; cnt++) 410 for (cnt = 0; NULL != shared_services[cnt].service; cnt++)
411 { 411 {
412 tss = shared_services[cnt]; 412 tss = shared_services[cnt];
413 ss = GNUNET_new (struct SharedService); 413 memset (&ss, 0, sizeof (ss));
414 ss->sname = GNUNET_strdup (tss.service); 414 ss.sname = GNUNET_strdup (tss.service);
415 ss->cfg = GNUNET_CONFIGURATION_create (); 415 ss.cfg = GNUNET_CONFIGURATION_create ();
416 GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, 416 GNUNET_CONFIGURATION_iterate_section_values (tss.cfg,
417 ss->sname, 417 ss.sname,
418 &cfg_copy_iterator, 418 &cfg_copy_iterator,
419 ss->cfg); 419 ss.cfg);
420 GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, 420 GNUNET_CONFIGURATION_iterate_section_values (tss.cfg,
421 "TESTING", 421 "TESTING",
422 &cfg_copy_iterator, 422 &cfg_copy_iterator,
423 ss->cfg); 423 ss.cfg);
424 GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, 424 GNUNET_CONFIGURATION_iterate_section_values (tss.cfg,
425 "PATHS", 425 "PATHS",
426 &cfg_copy_iterator, 426 &cfg_copy_iterator,
427 ss->cfg); 427 ss.cfg);
428 ss->share = tss.share; 428 ss.share = tss.share;
429 GNUNET_array_append (system->shared_services, 429 GNUNET_array_append (system->shared_services,
430 system->n_shared_services, 430 system->n_shared_services,
431 ss); 431 ss);
@@ -547,7 +547,7 @@ GNUNET_TESTING_system_destroy (struct GNUNET_TESTING_System *system,
547 hostkeys_unload (system); 547 hostkeys_unload (system);
548 for (ss_cnt = 0; ss_cnt < system->n_shared_services; ss_cnt++) 548 for (ss_cnt = 0; ss_cnt < system->n_shared_services; ss_cnt++)
549 { 549 {
550 ss = system->shared_services[ss_cnt]; 550 ss = &system->shared_services[ss_cnt];
551 for (i_cnt = 0; i_cnt < ss->n_instances; i_cnt++) 551 for (i_cnt = 0; i_cnt < ss->n_instances; i_cnt++)
552 { 552 {
553 i = ss->instances[i_cnt]; 553 i = ss->instances[i_cnt];
@@ -558,7 +558,6 @@ GNUNET_TESTING_system_destroy (struct GNUNET_TESTING_System *system,
558 GNUNET_free (ss->instances); 558 GNUNET_free (ss->instances);
559 GNUNET_CONFIGURATION_destroy (ss->cfg); 559 GNUNET_CONFIGURATION_destroy (ss->cfg);
560 GNUNET_free (ss->sname); 560 GNUNET_free (ss->sname);
561 GNUNET_free (ss);
562 } 561 }
563 GNUNET_free (system->shared_services); 562 GNUNET_free (system->shared_services);
564 if (GNUNET_YES == remove_paths) 563 if (GNUNET_YES == remove_paths)
@@ -1221,7 +1220,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1221 /* Remove sections for shared services */ 1220 /* Remove sections for shared services */
1222 for (cnt = 0; cnt < system->n_shared_services; cnt++) 1221 for (cnt = 0; cnt < system->n_shared_services; cnt++)
1223 { 1222 {
1224 ss = system->shared_services[cnt]; 1223 ss = &system->shared_services[cnt];
1225 GNUNET_CONFIGURATION_remove_section (cfg, ss->sname); 1224 GNUNET_CONFIGURATION_remove_section (cfg, ss->sname);
1226 } 1225 }
1227 if (GNUNET_OK != 1226 if (GNUNET_OK !=
@@ -1269,7 +1268,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1269 * system->n_shared_services); 1268 * system->n_shared_services);
1270 for (cnt = 0; cnt < system->n_shared_services; cnt++) 1269 for (cnt = 0; cnt < system->n_shared_services; cnt++)
1271 { 1270 {
1272 ss = system->shared_services[cnt]; 1271 ss = &system->shared_services[cnt];
1273 ss_instances[cnt] = associate_shared_service (system, ss, cfg); 1272 ss_instances[cnt] = associate_shared_service (system, ss, cfg);
1274 if (NULL == ss_instances[cnt]) 1273 if (NULL == ss_instances[cnt])
1275 { 1274 {
@@ -1736,8 +1735,12 @@ GNUNET_TESTING_get_testname_from_underscore (const char *argv0)
1736} 1735}
1737 1736
1738 1737
1738/**
1739 * FIXME: I'm just janitoring around here. I have no idea what this function
1740 * is supposed todo. Needs documentation.
1741 */
1739static unsigned int 1742static unsigned int
1740get_first_value (char *line) 1743get_first_value (const char *line)
1741{ 1744{
1742 char *copy; 1745 char *copy;
1743 size_t slen; 1746 size_t slen;
@@ -1756,8 +1759,12 @@ get_first_value (char *line)
1756} 1759}
1757 1760
1758 1761
1762/**
1763 * FIXME: I'm just janitoring around here. I have no idea what this function
1764 * is supposed todo. Needs documentation.
1765 */
1759static char * 1766static char *
1760get_key (char *line) 1767get_key (const char *line)
1761{ 1768{
1762 char *copy; 1769 char *copy;
1763 size_t slen; 1770 size_t slen;
@@ -1778,8 +1785,12 @@ get_key (char *line)
1778} 1785}
1779 1786
1780 1787
1788/**
1789 * FIXME: I'm just janitoring around here. I have no idea what this function
1790 * is supposed todo. Needs documentation.
1791 */
1781static char * 1792static char *
1782get_first_string_value (char *line) 1793get_first_string_value (const char *line)
1783{ 1794{
1784 char *copy; 1795 char *copy;
1785 size_t slen, slen_token; 1796 size_t slen, slen_token;
@@ -1803,61 +1814,71 @@ get_first_string_value (char *line)
1803} 1814}
1804 1815
1805 1816
1817/**
1818 * FIXME: I'm just janitoring around here. I have no idea what this function
1819 * is supposed todo. Needs documentation.
1820 */
1806static unsigned int 1821static unsigned int
1807get_second_value (char *line) 1822get_second_value (const char *line)
1808{ 1823{
1809 char *copy; 1824 char *copy;
1810 size_t slen;
1811 char *token; 1825 char *token;
1812 unsigned int ret; 1826 unsigned int ret;
1813 char *rest = NULL; 1827 char *rest = NULL;
1814 1828
1815 slen = strlen (line) + 1; 1829 copy = GNUNET_strdup (line);
1816 copy = malloc (slen);
1817 memcpy (copy, line, slen);
1818 token = strtok_r (copy, ":", &rest); 1830 token = strtok_r (copy, ":", &rest);
1819 token = strtok_r (NULL, ":", &rest); 1831 token = strtok_r (NULL, ":", &rest);
1820 token = strtok_r (NULL, ":", &rest); 1832 token = strtok_r (NULL, ":", &rest);
1833 /* FIXME: ASSERT??? Are we not parsing "user" input here? */
1821 GNUNET_assert (1 == sscanf (token, "%u", &ret)); 1834 GNUNET_assert (1 == sscanf (token, "%u", &ret));
1822 GNUNET_free (copy); 1835 GNUNET_free (copy);
1823 return ret; 1836 return ret;
1824} 1837}
1825 1838
1826 1839
1840/**
1841 * FIXME: I'm just janitoring around here. I have no idea what this function
1842 * is supposed todo. Needs documentation.
1843 */
1827static char * 1844static char *
1828get_value (char *key, char *line) 1845get_value (const char *key, const char *line)
1829{ 1846{
1830 char *copy; 1847 char copy[strlen (line) + 1];
1831 size_t slen, slen_token; 1848 size_t slen;
1832 char *token; 1849 char *token;
1833 char *token2; 1850 char *token2;
1834 char *temp; 1851 char *temp;
1835 char *rest = NULL; 1852 char *rest = NULL;
1836 char *ret;
1837 1853
1838 slen = strlen (line) + 1; 1854 slen = strlen (line) + 1;
1839 copy = malloc (slen);
1840 memcpy (copy, line, slen); 1855 memcpy (copy, line, slen);
1841 temp = strstr (copy, key); 1856 temp = strstr (copy, key);
1842 if (NULL == temp) 1857 if (NULL == temp)
1843 return NULL; 1858 return NULL;
1844 token = strtok_r (temp, ":", &rest); 1859 token = strtok_r (temp, ":", &rest);
1860 if (NULL == token)
1861 return NULL;
1845 token = strtok_r (NULL, ":", &rest); 1862 token = strtok_r (NULL, ":", &rest);
1863 if (NULL == token)
1864 return NULL;
1846 token2 = strtok_r (token, "}", &rest); 1865 token2 = strtok_r (token, "}", &rest);
1847 slen_token = strlen (token2); 1866 if (NULL == token2)
1848 ret = malloc (slen_token + 1); 1867 return NULL;
1849 memcpy (ret, token2, slen_token + 1); 1868 return GNUNET_strdup (token2);
1850 GNUNET_free (copy);
1851 return ret;
1852} 1869}
1853 1870
1854 1871
1872/**
1873 * FIXME: I'm just janitoring around here. I have no idea what this function
1874 * is supposed todo. Needs documentation.
1875 */
1855static struct GNUNET_TESTING_NodeConnection * 1876static struct GNUNET_TESTING_NodeConnection *
1856get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node) 1877get_connect_value (const char *line,
1878 struct GNUNET_TESTING_NetjailNode *node)
1857{ 1879{
1858 struct GNUNET_TESTING_NodeConnection *node_connection; 1880 struct GNUNET_TESTING_NodeConnection *node_connection;
1859 char *copy; 1881 char *copy;
1860 size_t slen;
1861 char *token; 1882 char *token;
1862 char *token2; 1883 char *token2;
1863 unsigned int node_n; 1884 unsigned int node_n;
@@ -1870,9 +1891,7 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node)
1870 node_connection = GNUNET_new (struct GNUNET_TESTING_NodeConnection); 1891 node_connection = GNUNET_new (struct GNUNET_TESTING_NodeConnection);
1871 node_connection->node = node; 1892 node_connection->node = node;
1872 1893
1873 slen = strlen (line) + 1; 1894 copy = GNUNET_strdup (line);
1874 copy = malloc (slen);
1875 memcpy (copy, line, slen);
1876 token = strtok_r (copy, ":", &rest); 1895 token = strtok_r (copy, ":", &rest);
1877 if (0 == strcmp ("{K", token)) 1896 if (0 == strcmp ("{K", token))
1878 { 1897 {
@@ -1915,7 +1934,10 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node)
1915 } 1934 }
1916 else 1935 else
1917 { 1936 {
1937 GNUNET_break (0);
1918 GNUNET_free (node_connection); 1938 GNUNET_free (node_connection);
1939 GNUNET_free (copy);
1940 return NULL;
1919 } 1941 }
1920 1942
1921 while (NULL != (token = strtok_r (NULL, ":", &rest))) 1943 while (NULL != (token = strtok_r (NULL, ":", &rest)))
@@ -1923,17 +1945,9 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node)
1923 prefix = GNUNET_new (struct GNUNET_TESTING_AddressPrefix); 1945 prefix = GNUNET_new (struct GNUNET_TESTING_AddressPrefix);
1924 token2 = strtok_r (token, "}", &rest2); 1946 token2 = strtok_r (token, "}", &rest2);
1925 if (NULL != token2) 1947 if (NULL != token2)
1926 { 1948 prefix->address_prefix = GNUNET_strdup (token2);
1927 slen = strlen (token2) + 1;
1928 prefix->address_prefix = malloc (slen);
1929 memcpy (prefix->address_prefix, token2, slen);
1930 }
1931 else 1949 else
1932 { 1950 prefix->address_prefix = GNUNET_strdup (token);
1933 slen = strlen (token) + 1;
1934 prefix->address_prefix = malloc (slen);
1935 memcpy (prefix->address_prefix, token, slen);
1936 }
1937 1951
1938 LOG (GNUNET_ERROR_TYPE_DEBUG, 1952 LOG (GNUNET_ERROR_TYPE_DEBUG,
1939 "address_prefix %s\n", 1953 "address_prefix %s\n",
@@ -1952,13 +1966,16 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node)
1952} 1966}
1953 1967
1954 1968
1969/**
1970 * FIXME: I'm just janitoring around here. I have no idea what this function
1971 * is supposed todo. Needs documentation.
1972 */
1955static void 1973static void
1956node_connections (char *line, struct GNUNET_TESTING_NetjailNode *node) 1974node_connections (const char *line, struct GNUNET_TESTING_NetjailNode *node)
1957{ 1975{
1958 char *value, *value2; 1976 char *value, *value2;
1959 char *temp; 1977 char *temp;
1960 char *copy; 1978 char *copy;
1961 size_t slen;
1962 char *rest = NULL; 1979 char *rest = NULL;
1963 char *rest2 = NULL; 1980 char *rest2 = NULL;
1964 struct GNUNET_TESTING_NodeConnection *node_connection; 1981 struct GNUNET_TESTING_NodeConnection *node_connection;
@@ -1967,9 +1984,7 @@ node_connections (char *line, struct GNUNET_TESTING_NetjailNode *node)
1967 temp = strstr (line, "connect"); 1984 temp = strstr (line, "connect");
1968 if (NULL != temp) 1985 if (NULL != temp)
1969 { 1986 {
1970 slen = strlen (temp) + 1; 1987 copy = GNUNET_strdup (temp);
1971 copy = GNUNET_malloc (slen);
1972 memcpy (copy, temp, slen);
1973 strtok_r (copy, ":", &rest); 1988 strtok_r (copy, ":", &rest);
1974 value = strtok_r (rest, "|", &rest2); 1989 value = strtok_r (rest, "|", &rest2);
1975 1990
@@ -1979,6 +1994,8 @@ node_connections (char *line, struct GNUNET_TESTING_NetjailNode *node)
1979 "node_connections value %s\n", 1994 "node_connections value %s\n",
1980 value); 1995 value);
1981 node_connection = get_connect_value (value, node); 1996 node_connection = get_connect_value (value, node);
1997 if (NULL == node_connection)
1998 break; /* FIXME: continue? */
1982 GNUNET_CONTAINER_DLL_insert (node->node_connections_head, 1999 GNUNET_CONTAINER_DLL_insert (node->node_connections_head,
1983 node->node_connections_tail, 2000 node->node_connections_tail,
1984 node_connection); 2001 node_connection);
@@ -1993,6 +2010,10 @@ node_connections (char *line, struct GNUNET_TESTING_NetjailNode *node)
1993} 2010}
1994 2011
1995 2012
2013/**
2014 * FIXME: I'm just janitoring around here. I have no idea what this function
2015 * is supposed todo. Needs documentation.
2016 */
1996static int 2017static int
1997log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) 2018log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
1998{ 2019{
@@ -2041,7 +2062,7 @@ log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
2041 2062
2042 2063
2043static int 2064static int
2044log_topo (struct GNUNET_TESTING_NetjailTopology *topology) 2065log_topo (const struct GNUNET_TESTING_NetjailTopology *topology)
2045{ 2066{
2046 LOG (GNUNET_ERROR_TYPE_DEBUG, 2067 LOG (GNUNET_ERROR_TYPE_DEBUG,
2047 "plugin: %s spaces: %u nodes: %u known: %u\n", 2068 "plugin: %s spaces: %u nodes: %u known: %u\n",
@@ -2057,15 +2078,18 @@ log_topo (struct GNUNET_TESTING_NetjailTopology *topology)
2057 return GNUNET_YES; 2078 return GNUNET_YES;
2058} 2079}
2059 2080
2060void 2081/**
2082 * FIXME: I'm just janitoring around here. I have no idea what this function
2083 * is supposed todo. Needs documentation.
2084 */
2085static void
2061get_node_info (unsigned int num, 2086get_node_info (unsigned int num,
2062 struct GNUNET_TESTING_NetjailTopology *topology, 2087 const struct GNUNET_TESTING_NetjailTopology *topology,
2063 struct GNUNET_TESTING_NetjailNode **node_ex, 2088 struct GNUNET_TESTING_NetjailNode **node_ex,
2064 struct GNUNET_TESTING_NetjailNamespace **namespace_ex, 2089 struct GNUNET_TESTING_NetjailNamespace **namespace_ex,
2065 struct GNUNET_TESTING_NodeConnection **node_connections_ex) 2090 struct GNUNET_TESTING_NodeConnection **node_connections_ex)
2066{ 2091{
2067 struct GNUNET_ShortHashCode *hkey; 2092 struct GNUNET_ShortHashCode hkey;
2068 struct GNUNET_ShortHashCode *hkey_node;
2069 struct GNUNET_HashCode hc; 2093 struct GNUNET_HashCode hc;
2070 unsigned int namespace_n; 2094 unsigned int namespace_n;
2071 unsigned int node_m; 2095 unsigned int node_m;
@@ -2074,7 +2098,6 @@ get_node_info (unsigned int num,
2074 struct GNUNET_TESTING_NodeConnection *node_connections = NULL; 2098 struct GNUNET_TESTING_NodeConnection *node_connections = NULL;
2075 2099
2076 log_topo (topology); 2100 log_topo (topology);
2077 hkey = GNUNET_new (struct GNUNET_ShortHashCode);
2078 LOG (GNUNET_ERROR_TYPE_DEBUG, 2101 LOG (GNUNET_ERROR_TYPE_DEBUG,
2079 "num: %u \n", 2102 "num: %u \n",
2080 num); 2103 num);
@@ -2082,11 +2105,11 @@ get_node_info (unsigned int num,
2082 { 2105 {
2083 2106
2084 GNUNET_CRYPTO_hash (&num, sizeof(num), &hc); 2107 GNUNET_CRYPTO_hash (&num, sizeof(num), &hc);
2085 memcpy (hkey, 2108 memcpy (&hkey,
2086 &hc, 2109 &hc,
2087 sizeof (*hkey)); 2110 sizeof (hkey));
2088 node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals, 2111 node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals,
2089 hkey); 2112 &hkey);
2090 if (NULL != node) 2113 if (NULL != node)
2091 { 2114 {
2092 *node_ex = node; 2115 *node_ex = node;
@@ -2104,21 +2127,20 @@ get_node_info (unsigned int num,
2104 topology->nodes_m, 2127 topology->nodes_m,
2105 namespace_n); 2128 namespace_n);
2106 GNUNET_CRYPTO_hash (&namespace_n, sizeof(namespace_n), &hc); 2129 GNUNET_CRYPTO_hash (&namespace_n, sizeof(namespace_n), &hc);
2107 memcpy (hkey, 2130 memcpy (&hkey,
2108 &hc, 2131 &hc,
2109 sizeof (*hkey)); 2132 sizeof (hkey));
2110 namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces, 2133 namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces,
2111 hkey); 2134 &hkey);
2112 if (NULL != namespace) 2135 if (NULL != namespace)
2113 { 2136 {
2114 node_m = num - topology->nodes_x - topology->nodes_m * (namespace_n - 1); 2137 node_m = num - topology->nodes_x - topology->nodes_m * (namespace_n - 1);
2115 hkey_node = GNUNET_new (struct GNUNET_ShortHashCode);
2116 GNUNET_CRYPTO_hash (&node_m, sizeof(node_m), &hc); 2138 GNUNET_CRYPTO_hash (&node_m, sizeof(node_m), &hc);
2117 memcpy (hkey, 2139 memcpy (&hkey,
2118 &hc, 2140 &hc,
2119 sizeof (*hkey)); 2141 sizeof (hkey));
2120 node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes, 2142 node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes,
2121 hkey); 2143 &hkey);
2122 if (NULL != node) 2144 if (NULL != node)
2123 { 2145 {
2124 LOG (GNUNET_ERROR_TYPE_DEBUG, 2146 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2130,10 +2152,8 @@ get_node_info (unsigned int num,
2130 *node_ex = node; 2152 *node_ex = node;
2131 *namespace_ex = namespace; 2153 *namespace_ex = namespace;
2132 *node_connections_ex = node_connections; 2154 *node_connections_ex = node_connections;
2133 GNUNET_free (hkey_node);
2134 } 2155 }
2135 } 2156 }
2136 GNUNET_free (hkey);
2137} 2157}
2138 2158
2139/** 2159/**
@@ -2167,7 +2187,7 @@ GNUNET_TESTING_get_node (unsigned int num,
2167 */ 2187 */
2168struct GNUNET_TESTING_NodeConnection * 2188struct GNUNET_TESTING_NodeConnection *
2169GNUNET_TESTING_get_connections (unsigned int num, 2189GNUNET_TESTING_get_connections (unsigned int num,
2170 struct GNUNET_TESTING_NetjailTopology *topology) 2190 const struct GNUNET_TESTING_NetjailTopology *topology)
2171{ 2191{
2172 struct GNUNET_TESTING_NetjailNode *node; 2192 struct GNUNET_TESTING_NetjailNode *node;
2173 struct GNUNET_TESTING_NetjailNamespace *namespace; 2193 struct GNUNET_TESTING_NetjailNamespace *namespace;
@@ -2182,13 +2202,14 @@ GNUNET_TESTING_get_connections (unsigned int num,
2182} 2202}
2183 2203
2184 2204
2205/**
2206 * FIXME: Function named incorrectly IMO
2207 */
2185struct GNUNET_PeerIdentity * 2208struct GNUNET_PeerIdentity *
2186GNUNET_TESTING_get_pub_key (unsigned int num, 2209GNUNET_TESTING_get_pub_key (unsigned int num,
2187 const struct GNUNET_TESTING_System *tl_system) 2210 const struct GNUNET_TESTING_System *tl_system)
2188{ 2211{
2189 struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity); 2212 struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity);
2190 struct GNUNET_CRYPTO_EddsaPublicKey *pub_key = GNUNET_new (struct
2191 GNUNET_CRYPTO_EddsaPublicKey);
2192 struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key; 2213 struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key;
2193 2214
2194 priv_key = GNUNET_TESTING_hostkey_get (tl_system, 2215 priv_key = GNUNET_TESTING_hostkey_get (tl_system,
@@ -2196,10 +2217,8 @@ GNUNET_TESTING_get_pub_key (unsigned int num,
2196 peer); 2217 peer);
2197 2218
2198 GNUNET_CRYPTO_eddsa_key_get_public (priv_key, 2219 GNUNET_CRYPTO_eddsa_key_get_public (priv_key,
2199 pub_key); 2220 &peer->public_key);
2200 peer->public_key = *pub_key;
2201 GNUNET_free (priv_key); 2221 GNUNET_free (priv_key);
2202 GNUNET_free (pub_key);
2203 return peer; 2222 return peer;
2204} 2223}
2205 2224
@@ -2299,7 +2318,7 @@ GNUNET_TESTING_calculate_num (
2299 */ 2318 */
2300char * 2319char *
2301GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection, 2320GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection,
2302 char *prefix) 2321 const char *prefix)
2303{ 2322{
2304 struct GNUNET_TESTING_NetjailNode *node; 2323 struct GNUNET_TESTING_NetjailNode *node;
2305 char *addr; 2324 char *addr;
@@ -2374,6 +2393,12 @@ GNUNET_TESTING_get_additional_connects (unsigned int num,
2374 2393
2375 get_node_info (num, topology, &node, &namespace, &node_connections); 2394 get_node_info (num, topology, &node, &namespace, &node_connections);
2376 2395
2396 if (NULL == node)
2397 {
2398 LOG (GNUNET_ERROR_TYPE_WARNING,
2399 "No info found for node %d\n", num);
2400 return 0;
2401 }
2377 LOG (GNUNET_ERROR_TYPE_DEBUG, 2402 LOG (GNUNET_ERROR_TYPE_DEBUG,
2378 "node additional_connects for node %p\n", 2403 "node additional_connects for node %p\n",
2379 node); 2404 node);
@@ -2401,7 +2426,7 @@ GNUNET_TESTING_send_local_test_finished_msg ()
2401 2426
2402 2427
2403static void 2428static void
2404parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, char *token) 2429parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, const char *token)
2405{ 2430{
2406 char *ac_value; 2431 char *ac_value;
2407 int ret; 2432 int ret;
@@ -2438,7 +2463,7 @@ parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, char *token)
2438 * @return The GNUNET_TESTING_NetjailTopology 2463 * @return The GNUNET_TESTING_NetjailTopology
2439 */ 2464 */
2440struct GNUNET_TESTING_NetjailTopology * 2465struct GNUNET_TESTING_NetjailTopology *
2441GNUNET_TESTING_get_topo_from_string (char *data) 2466GNUNET_TESTING_get_topo_from_string (const char *input)
2442{ 2467{
2443 char *token; 2468 char *token;
2444 char *key = NULL; 2469 char *key = NULL;
@@ -2446,12 +2471,14 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2446 char *rest = NULL; 2471 char *rest = NULL;
2447 char *value = NULL; 2472 char *value = NULL;
2448 char *value2; 2473 char *value2;
2474 char *data;
2449 int ret; 2475 int ret;
2450 struct GNUNET_TESTING_NetjailTopology *topo; 2476 struct GNUNET_TESTING_NetjailTopology *topo;
2451 struct GNUNET_TESTING_NetjailRouter *router; 2477 struct GNUNET_TESTING_NetjailRouter *router;
2452 struct GNUNET_TESTING_NetjailNamespace *namespace; 2478 struct GNUNET_TESTING_NetjailNamespace *namespace;
2453 struct GNUNET_HashCode hc; 2479 struct GNUNET_HashCode hc;
2454 2480
2481 data = GNUNET_strdup (input);
2455 token = strtok_r (data, "\n", &rest); 2482 token = strtok_r (data, "\n", &rest);
2456 topo = GNUNET_new (struct GNUNET_TESTING_NetjailTopology); 2483 topo = GNUNET_new (struct GNUNET_TESTING_NetjailTopology);
2457 topo->map_namespaces = 2484 topo->map_namespaces =
@@ -2462,7 +2489,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2462 while (NULL != token) 2489 while (NULL != token)
2463 { 2490 {
2464 if (NULL != key) 2491 if (NULL != key)
2465 free (key); 2492 GNUNET_free (key);
2466 key = get_key (token); 2493 key = get_key (token);
2467 LOG (GNUNET_ERROR_TYPE_DEBUG, 2494 LOG (GNUNET_ERROR_TYPE_DEBUG,
2468 "In the loop with token: %s beginning with %s\n", 2495 "In the loop with token: %s beginning with %s\n",
@@ -2677,10 +2704,8 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2677 LOG (GNUNET_ERROR_TYPE_DEBUG, 2704 LOG (GNUNET_ERROR_TYPE_DEBUG,
2678 "plugin: %s\n", 2705 "plugin: %s\n",
2679 value); 2706 value);
2680 p_node->plugin = GNUNET_malloc (sizeof(*value)); 2707 p_node->plugin = value;
2681 memcpy (p_node->plugin, value, sizeof (*value));
2682 } 2708 }
2683 GNUNET_free (value);
2684 p_node->node_n = out; 2709 p_node->node_n = out;
2685 p_node->namespace_n = namespace->namespace_n; 2710 p_node->namespace_n = namespace->namespace_n;
2686 } 2711 }
@@ -2697,7 +2722,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2697 } 2722 }
2698 if (NULL != key) 2723 if (NULL != key)
2699 GNUNET_free (key); 2724 GNUNET_free (key);
2700 2725 GNUNET_free (data);
2701 return topo; 2726 return topo;
2702} 2727}
2703 2728
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index f56ae1753..0059861c2 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -1515,6 +1515,7 @@ test_transport_simple_send.sh \
1515test_transport_simple_send_broadcast.sh \ 1515test_transport_simple_send_broadcast.sh \
1516test_transport_udp_backchannel.sh \ 1516test_transport_udp_backchannel.sh \
1517test_transport_simple_send_dv_circle.sh \ 1517test_transport_simple_send_dv_circle.sh \
1518test_transport_simple_send_dv_inverse.sh \
1518gnunet-transport-certificate-creation.in \ 1519gnunet-transport-certificate-creation.in \
1519communicator-unix.conf \ 1520communicator-unix.conf \
1520test_plugin_hostkey \ 1521test_plugin_hostkey \
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index a8dbed604..84aa45b9a 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -1448,7 +1448,7 @@ handshake_ack_monotime_cb (void *cls,
1448 * @param queue The queue context. 1448 * @param queue The queue context.
1449 */ 1449 */
1450static void 1450static void
1451send_challenge (struct GNUNET_CRYPTO_ChallengeNonceP challenge, 1451send_challenge (struct GNUNET_CRYPTO_ChallengeNonceP challenge,
1452 struct Queue *queue) 1452 struct Queue *queue)
1453{ 1453{
1454 struct TCPConfirmationAck tca; 1454 struct TCPConfirmationAck tca;
@@ -1914,10 +1914,10 @@ queue_read (void *cls)
1914 &queue->cread_buf[queue->cread_off], 1914 &queue->cread_buf[queue->cread_off],
1915 BUF_SIZE - queue->cread_off); 1915 BUF_SIZE - queue->cread_off);
1916 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1916 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1917 "Received %lu bytes from TCP queue\n", rcvd); 1917 "Received %zd bytes from TCP queue\n", rcvd);
1918 GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG, 1918 GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
1919 "transport", 1919 "transport",
1920 "Received %lu bytes from TCP queue\n", rcvd); 1920 "Received %zd bytes from TCP queue\n", rcvd);
1921 if (-1 == rcvd) 1921 if (-1 == rcvd)
1922 { 1922 {
1923 if ((EAGAIN != errno) && (EINTR != errno)) 1923 if ((EAGAIN != errno) && (EINTR != errno))
diff --git a/src/transport/gnunet-helper-transport-bluetooth.c b/src/transport/gnunet-helper-transport-bluetooth.c
index 019f3914f..64f3b6160 100644
--- a/src/transport/gnunet-helper-transport-bluetooth.c
+++ b/src/transport/gnunet-helper-transport-bluetooth.c
@@ -19,7 +19,8 @@
19 19
20 SPDX-License-Identifier: AGPL3.0-or-later 20 SPDX-License-Identifier: AGPL3.0-or-later
21 */ 21 */
22#include "gnunet_config.h" 22#include "platform.h"
23#include "gnunet_private_config.h"
23 24
24#include <bluetooth/bluetooth.h> 25#include <bluetooth/bluetooth.h>
25#include <bluetooth/hci.h> 26#include <bluetooth/hci.h>
diff --git a/src/transport/gnunet-helper-transport-wlan.c b/src/transport/gnunet-helper-transport-wlan.c
index 72dd8b594..c1a230bef 100644
--- a/src/transport/gnunet-helper-transport-wlan.c
+++ b/src/transport/gnunet-helper-transport-wlan.c
@@ -109,30 +109,11 @@
109/* 109/*
110 * parts taken from aircrack-ng, parts changend. 110 * parts taken from aircrack-ng, parts changend.
111 */ 111 */
112#include "gnunet_config.h" 112#include "platform.h"
113#include <sys/socket.h> 113#include "gnunet_private_config.h"
114#include <sys/ioctl.h>
115#include <sys/types.h>
116#include <unistd.h>
117#include <sys/wait.h>
118#include <sys/time.h>
119#include <sys/stat.h>
120#include <netpacket/packet.h> 114#include <netpacket/packet.h>
121#include <linux/if_ether.h> 115#include <linux/if_ether.h>
122#include <linux/if.h>
123#include <linux/wireless.h> 116#include <linux/wireless.h>
124#include <netinet/in.h>
125#include <linux/if_tun.h>
126#include <stdio.h>
127#include <stdlib.h>
128#include <string.h>
129#include <stdarg.h>
130#include <fcntl.h>
131#include <errno.h>
132#include <dirent.h>
133#include <sys/param.h>
134#include <unistd.h>
135#include <stdint.h>
136 117
137#include "gnunet_protocols.h" 118#include "gnunet_protocols.h"
138#include "plugin_transport_wlan.h" 119#include "plugin_transport_wlan.h"
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 512b77a9d..5a28efb66 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -4685,8 +4685,9 @@ dv_setup_key_state_from_km (const struct GNUNET_HashCode *km,
4685 * @param target the target peer to encrypt to 4685 * @param target the target peer to encrypt to
4686 * @param iv unique IV to use 4686 * @param iv unique IV to use
4687 * @param[out] key set to the key material 4687 * @param[out] key set to the key material
4688 * @return GNUNET_OK on success
4688 */ 4689 */
4689static void 4690static enum GNUNET_GenericReturnValue
4690dh_key_derive_eph_pid ( 4691dh_key_derive_eph_pid (
4691 const struct GNUNET_CRYPTO_EcdhePrivateKey *priv_ephemeral, 4692 const struct GNUNET_CRYPTO_EcdhePrivateKey *priv_ephemeral,
4692 const struct GNUNET_PeerIdentity *target, 4693 const struct GNUNET_PeerIdentity *target,
@@ -4695,10 +4696,14 @@ dh_key_derive_eph_pid (
4695{ 4696{
4696 struct GNUNET_HashCode km; 4697 struct GNUNET_HashCode km;
4697 4698
4698 GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_ecdh_eddsa (priv_ephemeral, 4699 if (GNUNET_YES != GNUNET_CRYPTO_ecdh_eddsa (priv_ephemeral,
4699 &target->public_key, 4700 &target->public_key,
4700 &km)); 4701 &km))
4702 return GNUNET_SYSERR;
4703 // FIXME: Possibly also add return values here. We are processing
4704 // Input from other peers...
4701 dv_setup_key_state_from_km (&km, iv, key); 4705 dv_setup_key_state_from_km (&km, iv, key);
4706 return GNUNET_OK;
4702} 4707}
4703 4708
4704 4709
@@ -4710,18 +4715,21 @@ dh_key_derive_eph_pid (
4710 * @param target the target peer to encrypt to 4715 * @param target the target peer to encrypt to
4711 * @param iv unique IV to use 4716 * @param iv unique IV to use
4712 * @param[out] key set to the key material 4717 * @param[out] key set to the key material
4718 * @return GNUNET_OK on success
4713 */ 4719 */
4714static void 4720static enum GNUNET_GenericReturnValue
4715dh_key_derive_eph_pub (const struct GNUNET_CRYPTO_EcdhePublicKey *pub_ephemeral, 4721dh_key_derive_eph_pub (const struct GNUNET_CRYPTO_EcdhePublicKey *pub_ephemeral,
4716 const struct GNUNET_ShortHashCode *iv, 4722 const struct GNUNET_ShortHashCode *iv,
4717 struct DVKeyState *key) 4723 struct DVKeyState *key)
4718{ 4724{
4719 struct GNUNET_HashCode km; 4725 struct GNUNET_HashCode km;
4720 4726
4721 GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_eddsa_ecdh (GST_my_private_key, 4727 if (GNUNET_YES != GNUNET_CRYPTO_eddsa_ecdh (GST_my_private_key,
4722 pub_ephemeral, 4728 pub_ephemeral,
4723 &km)); 4729 &km))
4730 return GNUNET_SYSERR;
4724 dv_setup_key_state_from_km (&km, iv, key); 4731 dv_setup_key_state_from_km (&km, iv, key);
4732 return GNUNET_OK;
4725} 4733}
4726 4734
4727 4735
@@ -4769,15 +4777,18 @@ dv_encrypt (struct DVKeyState *key, const void *in, void *dst, size_t in_size)
4769 * @param ciph cipher text to decrypt 4777 * @param ciph cipher text to decrypt
4770 * @param[out] out output data to generate (plaintext) 4778 * @param[out] out output data to generate (plaintext)
4771 * @param out_size number of bytes of input in @a ciph and available in @a out 4779 * @param out_size number of bytes of input in @a ciph and available in @a out
4780 * @return GNUNET_OK on success
4772 */ 4781 */
4773static void 4782static enum GNUNET_GenericReturnValue
4774dv_decrypt (struct DVKeyState *key, 4783dv_decrypt (struct DVKeyState *key,
4775 void *out, 4784 void *out,
4776 const void *ciph, 4785 const void *ciph,
4777 size_t out_size) 4786 size_t out_size)
4778{ 4787{
4779 GNUNET_assert ( 4788 return (0 ==
4780 0 == gcry_cipher_decrypt (key->cipher, out, out_size, ciph, out_size)); 4789 gcry_cipher_decrypt (key->cipher,
4790 out, out_size,
4791 ciph, out_size)) ? GNUNET_OK : GNUNET_SYSERR;
4781} 4792}
4782 4793
4783 4794
@@ -4837,8 +4848,6 @@ encapsulate_for_dv (struct DistanceVector *dv,
4837 struct TransportDVBoxPayloadP payload_hdr; 4848 struct TransportDVBoxPayloadP payload_hdr;
4838 uint16_t enc_body_size = ntohs (hdr->size); 4849 uint16_t enc_body_size = ntohs (hdr->size);
4839 char enc[sizeof(struct TransportDVBoxPayloadP) + enc_body_size] GNUNET_ALIGN; 4850 char enc[sizeof(struct TransportDVBoxPayloadP) + enc_body_size] GNUNET_ALIGN;
4840 struct TransportDVBoxPayloadP *enc_payload_hdr =
4841 (struct TransportDVBoxPayloadP *) enc;
4842 struct DVKeyState *key; 4851 struct DVKeyState *key;
4843 struct GNUNET_TIME_Relative rtt; 4852 struct GNUNET_TIME_Relative rtt;
4844 4853
@@ -4854,10 +4863,14 @@ encapsulate_for_dv (struct DistanceVector *dv,
4854 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, 4863 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
4855 &box_hdr.iv, 4864 &box_hdr.iv,
4856 sizeof(box_hdr.iv)); 4865 sizeof(box_hdr.iv));
4857 dh_key_derive_eph_pid (&dv->private_key, &dv->target, &box_hdr.iv, key); 4866 // We are creating this key, so this must work.
4867 GNUNET_assert (GNUNET_OK ==
4868 dh_key_derive_eph_pid (&dv->private_key,
4869 &dv->target,
4870 &box_hdr.iv, key));
4858 payload_hdr.sender = GST_my_identity; 4871 payload_hdr.sender = GST_my_identity;
4859 payload_hdr.monotonic_time = GNUNET_TIME_absolute_hton (dv->monotime); 4872 payload_hdr.monotonic_time = GNUNET_TIME_absolute_hton (dv->monotime);
4860 dv_encrypt (key, &payload_hdr, enc_payload_hdr, sizeof(payload_hdr)); 4873 dv_encrypt (key, &payload_hdr, enc, sizeof(payload_hdr));
4861 dv_encrypt (key, 4874 dv_encrypt (key,
4862 hdr, 4875 hdr,
4863 &enc[sizeof(struct TransportDVBoxPayloadP)], 4876 &enc[sizeof(struct TransportDVBoxPayloadP)],
@@ -8153,13 +8166,11 @@ handle_dv_box (void *cls, const struct TransportDVBoxMessage *dvb)
8153 const char *enc_payload = (const char *) &hops[num_hops]; 8166 const char *enc_payload = (const char *) &hops[num_hops];
8154 uint16_t enc_payload_size = 8167 uint16_t enc_payload_size =
8155 size - (num_hops * sizeof(struct GNUNET_PeerIdentity)); 8168 size - (num_hops * sizeof(struct GNUNET_PeerIdentity));
8156 struct DVKeyState *key; 8169 struct DVKeyState key;
8157 struct GNUNET_HashCode hmac; 8170 struct GNUNET_HashCode hmac;
8158 const char *hdr; 8171 const char *hdr;
8159 size_t hdr_len; 8172 size_t hdr_len;
8160 8173
8161 key = GNUNET_new (struct DVKeyState);
8162
8163 if (GNUNET_EXTRA_LOGGING > 0) 8174 if (GNUNET_EXTRA_LOGGING > 0)
8164 { 8175 {
8165 char *path; 8176 char *path;
@@ -8234,13 +8245,20 @@ handle_dv_box (void *cls, const struct TransportDVBoxMessage *dvb)
8234 GNUNET_NO); 8245 GNUNET_NO);
8235 cmc->total_hops = ntohs (dvb->total_hops); 8246 cmc->total_hops = ntohs (dvb->total_hops);
8236 8247
8237 dh_key_derive_eph_pub (&dvb->ephemeral_key, &dvb->iv, key); 8248 // DH key derivation with received DV, could be garbage.
8249 if (GNUNET_OK !=
8250 dh_key_derive_eph_pub (&dvb->ephemeral_key, &dvb->iv, &key))
8251 {
8252 GNUNET_break_op (0);
8253 finish_cmc_handling (cmc);
8254 return;
8255 }
8238 hdr = (const char *) &dvb[1]; 8256 hdr = (const char *) &dvb[1];
8239 hdr_len = ntohs (dvb->orig_size) - sizeof(*dvb) - sizeof(struct 8257 hdr_len = ntohs (dvb->orig_size) - sizeof(*dvb) - sizeof(struct
8240 GNUNET_PeerIdentity) 8258 GNUNET_PeerIdentity)
8241 * ntohs (dvb->total_hops); 8259 * ntohs (dvb->total_hops);
8242 8260
8243 dv_hmac (key, &hmac, hdr, hdr_len); 8261 dv_hmac (&key, &hmac, hdr, hdr_len);
8244 if (0 != GNUNET_memcmp (&hmac, &dvb->hmac)) 8262 if (0 != GNUNET_memcmp (&hmac, &dvb->hmac))
8245 { 8263 {
8246 /* HMAC mismatch, discard! */ 8264 /* HMAC mismatch, discard! */
@@ -8254,14 +8272,29 @@ handle_dv_box (void *cls, const struct TransportDVBoxMessage *dvb)
8254 struct GNUNET_TIME_Absolute monotime; 8272 struct GNUNET_TIME_Absolute monotime;
8255 struct TransportDVBoxPayloadP ppay; 8273 struct TransportDVBoxPayloadP ppay;
8256 char body[hdr_len - sizeof(ppay)] GNUNET_ALIGN; 8274 char body[hdr_len - sizeof(ppay)] GNUNET_ALIGN;
8257 const struct GNUNET_MessageHeader *mh = 8275 const struct GNUNET_MessageHeader *mh;
8258 (const struct GNUNET_MessageHeader *) body;
8259 8276
8260 GNUNET_assert (hdr_len >= 8277 GNUNET_assert (hdr_len >=
8261 sizeof(ppay) + sizeof(struct GNUNET_MessageHeader)); 8278 sizeof(ppay) + sizeof(struct GNUNET_MessageHeader));
8262 dv_decrypt (key, &ppay, hdr, sizeof(ppay)); 8279 if (GNUNET_OK != dv_decrypt (&key, &ppay, hdr, sizeof(ppay)))
8263 dv_decrypt (key, &body, &hdr[sizeof(ppay)], hdr_len - sizeof(ppay)); 8280 {
8264 dv_key_clean (key); 8281 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
8282 "Error decrypting DV payload header\n");
8283 GNUNET_break_op (0);
8284 finish_cmc_handling (cmc);
8285 return;
8286 }
8287 if (GNUNET_OK != dv_decrypt (&key, body,
8288 &hdr[sizeof(ppay)], hdr_len - sizeof(ppay)))
8289 {
8290 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
8291 "Error decrypting DV payload\n");
8292 GNUNET_break_op (0);
8293 finish_cmc_handling (cmc);
8294 return;
8295 }
8296 mh = (const struct GNUNET_MessageHeader *) body;
8297 dv_key_clean (&key);
8265 if (ntohs (mh->size) != sizeof(body)) 8298 if (ntohs (mh->size) != sizeof(body))
8266 { 8299 {
8267 GNUNET_break_op (0); 8300 GNUNET_break_op (0);
diff --git a/src/transport/plugin_transport_wlan.h b/src/transport/plugin_transport_wlan.h
index d175f9377..6cb11f648 100644
--- a/src/transport/plugin_transport_wlan.h
+++ b/src/transport/plugin_transport_wlan.h
@@ -26,7 +26,7 @@
26#ifndef PLUGIN_TRANSPORT_WLAN 26#ifndef PLUGIN_TRANSPORT_WLAN
27#define PLUGIN_TRANSPORT_WLAN 27#define PLUGIN_TRANSPORT_WLAN
28 28
29#include "gnunet_crypto_lib.h" 29#include "gnunet_util_lib.h"
30#include "gnunet_common.h" 30#include "gnunet_common.h"
31 31
32/** 32/**
diff --git a/src/transport/test_transport_simple_send_dv_inverse.sh b/src/transport/test_transport_simple_send_dv_inverse.sh
index eac437cba..6a89f7397 100755
--- a/src/transport/test_transport_simple_send_dv_inverse.sh
+++ b/src/transport/test_transport_simple_send_dv_inverse.sh
@@ -2,10 +2,11 @@
2if ! [ -d "/run/netns" ]; then 2if ! [ -d "/run/netns" ]; then
3 echo You have to create the directory /run/netns. 3 echo You have to create the directory /run/netns.
4fi 4fi
5if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" == 1 ]; then 5if [ -f /proc/sys/kernel/unprivileged_userns_clone ]; then
6 # exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes --trace-children=yes --trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip/sed/bash ./test_transport_start_with_config test_transport_distance_vector_inverse_topo.conf" 6 if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" == 1 ]; then
7 exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_distance_vector_inverse_topo.conf"
8else
9 echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n" 7 echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n"
10 exit 78 8 exit 78
9 fi
11fi 10fi
11# exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes --trace-children=yes --trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip/sed/bash ./test_transport_start_with_config test_transport_distance_vector_inverse_topo.conf"
12exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_distance_vector_inverse_topo.conf"
diff --git a/src/transport/transport-testing-filenames.c b/src/transport/transport-testing-filenames.c
index 70c1ee55a..ee7b0aacf 100644
--- a/src/transport/transport-testing-filenames.c
+++ b/src/transport/transport-testing-filenames.c
@@ -23,6 +23,7 @@
23 * @author Matthias Wachs 23 * @author Matthias Wachs
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "platform.h"
26#include "transport-testing.h" 27#include "transport-testing.h"
27 28
28 29
diff --git a/src/transport/transport-testing-filenames2.c b/src/transport/transport-testing-filenames2.c
index 7d6fd529d..59fa1ebd5 100644
--- a/src/transport/transport-testing-filenames2.c
+++ b/src/transport/transport-testing-filenames2.c
@@ -23,6 +23,7 @@
23 * @author Matthias Wachs 23 * @author Matthias Wachs
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "platform.h"
26#include "transport-testing2.h" 27#include "transport-testing2.h"
27 28
28 29
diff --git a/src/transport/transport-testing-loggers.c b/src/transport/transport-testing-loggers.c
index 330a392c6..21ed0592a 100644
--- a/src/transport/transport-testing-loggers.c
+++ b/src/transport/transport-testing-loggers.c
@@ -22,6 +22,7 @@
22 * @brief convenience functions for logging common events in tests 22 * @brief convenience functions for logging common events in tests
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25#include "platform.h"
25#include "transport-testing.h" 26#include "transport-testing.h"
26 27
27 28
diff --git a/src/transport/transport-testing-loggers2.c b/src/transport/transport-testing-loggers2.c
index ead4fa365..e6c79b78a 100644
--- a/src/transport/transport-testing-loggers2.c
+++ b/src/transport/transport-testing-loggers2.c
@@ -22,6 +22,7 @@
22 * @brief convenience functions for logging common events in tests 22 * @brief convenience functions for logging common events in tests
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25#include "platform.h"
25#include "transport-testing2.h" 26#include "transport-testing2.h"
26 27
27 28
diff --git a/src/transport/transport-testing-main.c b/src/transport/transport-testing-main.c
index 8d1727d77..63b91713c 100644
--- a/src/transport/transport-testing-main.c
+++ b/src/transport/transport-testing-main.c
@@ -22,6 +22,7 @@
22 * @brief convenience main function for tests 22 * @brief convenience main function for tests
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25#include "platform.h"
25#include "transport-testing.h" 26#include "transport-testing.h"
26 27
27 28
diff --git a/src/transport/transport-testing-main2.c b/src/transport/transport-testing-main2.c
index de0b7f4cd..0a1710922 100644
--- a/src/transport/transport-testing-main2.c
+++ b/src/transport/transport-testing-main2.c
@@ -22,6 +22,7 @@
22 * @brief convenience main function for tests 22 * @brief convenience main function for tests
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25#include "platform.h"
25#include "transport-testing2.h" 26#include "transport-testing2.h"
26 27
27 28
diff --git a/src/transport/transport-testing-send.c b/src/transport/transport-testing-send.c
index 38018c172..9b017c563 100644
--- a/src/transport/transport-testing-send.c
+++ b/src/transport/transport-testing-send.c
@@ -22,6 +22,7 @@
22 * @brief convenience transmission function for tests 22 * @brief convenience transmission function for tests
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25#include "platform.h"
25#include "transport-testing.h" 26#include "transport-testing.h"
26 27
27/** 28/**
diff --git a/src/transport/transport-testing-send2.c b/src/transport/transport-testing-send2.c
index bd2afb9b0..c48dc3a4a 100644
--- a/src/transport/transport-testing-send2.c
+++ b/src/transport/transport-testing-send2.c
@@ -22,6 +22,7 @@
22 * @brief convenience transmission function for tests 22 * @brief convenience transmission function for tests
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25#include "platform.h"
25#include "transport-testing2.h" 26#include "transport-testing2.h"
26 27
27/** 28/**
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index 00c4a08dd..baced62e3 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -23,6 +23,7 @@
23 * @author Matthias Wachs 23 * @author Matthias Wachs
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "platform.h"
26#include "transport-testing.h" 27#include "transport-testing.h"
27 28
28 29
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index f0dee7388..566e0db71 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -23,6 +23,7 @@
23 * @author Matthias Wachs 23 * @author Matthias Wachs
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "platform.h"
26#include "transport-testing2.h" 27#include "transport-testing2.h"
27 28
28 29
diff --git a/src/transport/transport.h b/src/transport/transport.h
index c06c2abb3..e060f81ba 100644
--- a/src/transport/transport.h
+++ b/src/transport/transport.h
@@ -26,7 +26,7 @@
26#ifndef TRANSPORT_H 26#ifndef TRANSPORT_H
27#define TRANSPORT_H 27#define TRANSPORT_H
28 28
29#include "gnunet_crypto_lib.h" 29#include "gnunet_util_lib.h"
30#include "gnunet_time_lib.h" 30#include "gnunet_time_lib.h"
31#include "gnunet_constants.h" 31#include "gnunet_constants.h"
32 32
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 90f111cad..89228ed0b 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -48,12 +48,12 @@ libgnunetutil_la_SOURCES = \
48 common_allocation.c \ 48 common_allocation.c \
49 common_endian.c \ 49 common_endian.c \
50 common_logging.c \ 50 common_logging.c \
51 compress.c \
51 configuration.c \ 52 configuration.c \
52 configuration_helper.c \ 53 configuration_helper.c \
53 consttime_memcmp.c \ 54 consttime_memcmp.c \
54 container_bloomfilter.c \ 55 container_bloomfilter.c \
55 container_heap.c \ 56 container_heap.c \
56 container_meta_data.c \
57 container_multihashmap.c \ 57 container_multihashmap.c \
58 container_multishortmap.c \ 58 container_multishortmap.c \
59 container_multiuuidmap.c \ 59 container_multiuuidmap.c \
@@ -289,7 +289,6 @@ check_PROGRAMS = \
289 test_configuration \ 289 test_configuration \
290 test_container_bloomfilter \ 290 test_container_bloomfilter \
291 test_container_dll \ 291 test_container_dll \
292 test_container_meta_data \
293 test_container_multihashmap \ 292 test_container_multihashmap \
294 test_container_multihashmap32 \ 293 test_container_multihashmap32 \
295 test_container_multipeermap \ 294 test_container_multipeermap \
@@ -423,11 +422,6 @@ test_container_dll_SOURCES = \
423test_container_dll_LDADD = \ 422test_container_dll_LDADD = \
424 libgnunetutil.la 423 libgnunetutil.la
425 424
426test_container_meta_data_SOURCES = \
427 test_container_meta_data.c
428test_container_meta_data_LDADD = \
429 libgnunetutil.la
430
431test_container_multihashmap_SOURCES = \ 425test_container_multihashmap_SOURCES = \
432 test_container_multihashmap.c 426 test_container_multihashmap.c
433test_container_multihashmap_LDADD = \ 427test_container_multihashmap_LDADD = \
diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c
index 44caec2fa..8411c12ee 100644
--- a/src/util/bandwidth.c
+++ b/src/util/bandwidth.c
@@ -23,6 +23,7 @@
23 * @brief functions related to bandwidth (unit) 23 * @brief functions related to bandwidth (unit)
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/benchmark.c b/src/util/benchmark.c
index 12efde706..c9fc8842e 100644
--- a/src/util/benchmark.c
+++ b/src/util/benchmark.c
@@ -24,6 +24,7 @@
24 * @author Florian Dold <flo@dold.me> 24 * @author Florian Dold <flo@dold.me>
25 */ 25 */
26 26
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29#include "benchmark.h" 30#include "benchmark.h"
diff --git a/src/util/bio.c b/src/util/bio.c
index a09115048..70620aea7 100644
--- a/src/util/bio.c
+++ b/src/util/bio.c
@@ -22,6 +22,7 @@
22 * @brief functions for buffering IO 22 * @brief functions for buffering IO
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25
25#include "platform.h" 26#include "platform.h"
26#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
27 28
@@ -40,12 +41,6 @@
40 */ 41 */
41#define BIO_BUFFER_SIZE 65536 42#define BIO_BUFFER_SIZE 65536
42 43
43/**
44 * Maximum size allowed for meta data written/read from disk.
45 * File-sharing limits to 64k, so this should be rather generous.
46 */
47#define MAX_META_DATA (1024 * 1024)
48
49 44
50/** 45/**
51 * Enum used internally to know how buffering is handled. 46 * Enum used internally to know how buffering is handled.
@@ -159,7 +154,7 @@ GNUNET_BIO_read_open_buffer (void *buffer, size_t size)
159 * 154 *
160 * @param h file handle 155 * @param h file handle
161 * @param emsg set to the (allocated) error message 156 * @param emsg set to the (allocated) error message
162 * if the handle has an error message, the return 157 * if the handle has an error message, the return
163 * value is #GNUNET_SYSERR 158 * value is #GNUNET_SYSERR
164 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise 159 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
165 */ 160 */
@@ -187,6 +182,13 @@ GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg)
187 return err; 182 return err;
188} 183}
189 184
185void
186GNUNET_BIO_read_set_error (struct GNUNET_BIO_ReadHandle *h, const char* emsg)
187{
188 GNUNET_assert (NULL == h->emsg);
189 h->emsg = GNUNET_strdup (emsg);
190}
191
190 192
191/** 193/**
192 * Function used internally to read the contents of a file into a buffer. 194 * Function used internally to read the contents of a file into a buffer.
@@ -378,60 +380,6 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
378} 380}
379 381
380 382
381/**
382 * Read a metadata container.
383 *
384 * @param h handle to an open file
385 * @param what describes what is being read (for error message creation)
386 * @param result the buffer to store a pointer to the (allocated) metadata
387 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
388 */
389int
390GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
391 const char *what,
392 struct GNUNET_CONTAINER_MetaData **result)
393{
394 uint32_t size;
395 char *buf;
396 struct GNUNET_CONTAINER_MetaData *meta;
397
398 if (GNUNET_OK != GNUNET_BIO_read_int32 (h,
399 _ ("metadata length"),
400 (int32_t *) &size))
401 return GNUNET_SYSERR;
402 if (0 == size)
403 {
404 *result = NULL;
405 return GNUNET_OK;
406 }
407 if (MAX_META_DATA < size)
408 {
409 GNUNET_asprintf (
410 &h->emsg,
411 _ ("Serialized metadata `%s' larger than allowed (%u > %u)"),
412 what,
413 size,
414 MAX_META_DATA);
415 return GNUNET_SYSERR;
416 }
417 buf = GNUNET_malloc (size);
418 if (GNUNET_OK != GNUNET_BIO_read (h, what, buf, size))
419 {
420 GNUNET_free (buf);
421 return GNUNET_SYSERR;
422 }
423 meta = GNUNET_CONTAINER_meta_data_deserialize (buf, size);
424 if (NULL == meta)
425 {
426 GNUNET_free (buf);
427 GNUNET_asprintf (&h->emsg, _ ("Failed to deserialize metadata `%s'"), what);
428 return GNUNET_SYSERR;
429 }
430 GNUNET_free (buf);
431 *result = meta;
432 return GNUNET_OK;
433}
434
435 383
436/** 384/**
437 * Read a float. 385 * Read a float.
@@ -845,51 +793,6 @@ GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h,
845} 793}
846 794
847 795
848/**
849 * Write a metadata container.
850 *
851 * @param h the IO handle to write to
852 * @param what what is being written (for error message creation)
853 * @param m metadata to write
854 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
855 */
856int
857GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
858 const char *what,
859 const struct GNUNET_CONTAINER_MetaData *m)
860{
861 ssize_t size;
862 char *buf;
863
864 if (m == NULL)
865 return GNUNET_BIO_write_int32 (h, _ ("metadata length"), 0);
866 buf = NULL;
867 size = GNUNET_CONTAINER_meta_data_serialize (
868 m,
869 &buf,
870 MAX_META_DATA,
871 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
872 if (-1 == size)
873 {
874 GNUNET_free (buf);
875 GNUNET_free (h->emsg);
876 GNUNET_asprintf (&h->emsg,
877 _ ("Failed to serialize metadata `%s'"),
878 what);
879 return GNUNET_SYSERR;
880 }
881 if ((GNUNET_OK != GNUNET_BIO_write_int32 (h,
882 _ ("metadata length"),
883 (uint32_t) size))
884 || (GNUNET_OK != GNUNET_BIO_write (h, what, buf, size)))
885 {
886 GNUNET_free (buf);
887 return GNUNET_SYSERR;
888 }
889 GNUNET_free (buf);
890 return GNUNET_OK;
891}
892
893 796
894/** 797/**
895 * Write a float. 798 * Write a float.
@@ -1059,51 +962,6 @@ GNUNET_BIO_read_spec_string (const char *what,
1059 962
1060 963
1061/** 964/**
1062 * Function used internally to read a metadata container from within a read
1063 * spec.
1064 *
1065 * @param cls ignored, always NULL
1066 * @param h the IO handle to read from
1067 * @param what what is being read (for error message creation)
1068 * @param target where to store the data
1069 * @param target_size ignored
1070 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
1071 */
1072static int
1073read_spec_handler_meta_data (void *cls,
1074 struct GNUNET_BIO_ReadHandle *h,
1075 const char *what,
1076 void *target,
1077 size_t target_size)
1078{
1079 struct GNUNET_CONTAINER_MetaData **result = target;
1080 return GNUNET_BIO_read_meta_data (h, what, result);
1081}
1082
1083
1084/**
1085 * Create the specification to read a metadata container.
1086 *
1087 * @param what describes what is being read (for error message creation)
1088 * @param result the buffer to store a pointer to the (allocated) metadata
1089 * @return the read spec
1090 */
1091struct GNUNET_BIO_ReadSpec
1092GNUNET_BIO_read_spec_meta_data (const char *what,
1093 struct GNUNET_CONTAINER_MetaData **result)
1094{
1095 struct GNUNET_BIO_ReadSpec rs = {
1096 .rh = &read_spec_handler_meta_data,
1097 .cls = NULL,
1098 .target = result,
1099 .size = 0,
1100 };
1101
1102 return rs;
1103}
1104
1105
1106/**
1107 * Function used internally to read an (u)int32_t from within a read spec. 965 * Function used internally to read an (u)int32_t from within a read spec.
1108 * 966 *
1109 * @param cls ignored, always NULL 967 * @param cls ignored, always NULL
@@ -1349,52 +1207,6 @@ GNUNET_BIO_write_spec_string (const char *what,
1349 1207
1350 1208
1351/** 1209/**
1352 * Function used internally to write a metadata container from within a write
1353 * spec.
1354 *
1355 * @param cls ignored, always NULL
1356 * @param h the IO handle to write to
1357 * @param what what is being written (for error message creation)
1358 * @param source the data to write
1359 * @param source_size ignored
1360 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
1361 */
1362static int
1363write_spec_handler_meta_data (void *cls,
1364 struct GNUNET_BIO_WriteHandle *h,
1365 const char *what,
1366 void *source,
1367 size_t source_size)
1368{
1369 const struct GNUNET_CONTAINER_MetaData *m = source;
1370 return GNUNET_BIO_write_meta_data (h, what, m);
1371}
1372
1373
1374/**
1375 * Create the specification to write a metadata container.
1376 *
1377 * @param what what is being written (for error message creation)
1378 * @param m metadata to write
1379 * @return the write spec
1380 */
1381struct GNUNET_BIO_WriteSpec
1382GNUNET_BIO_write_spec_meta_data (const char *what,
1383 const struct GNUNET_CONTAINER_MetaData *m)
1384{
1385 struct GNUNET_BIO_WriteSpec ws = {
1386 .wh = &write_spec_handler_meta_data,
1387 .cls = NULL,
1388 .what = what,
1389 .source = (void *) m,
1390 .source_size = 0,
1391 };
1392
1393 return ws;
1394}
1395
1396
1397/**
1398 * Function used internally to write an (u)int32_t from within a write spec. 1210 * Function used internally to write an (u)int32_t from within a write spec.
1399 * 1211 *
1400 * @param cls ignored, always NULL 1212 * @param cls ignored, always NULL
diff --git a/src/util/buffer.c b/src/util/buffer.c
index 662e4d0f2..f88c56849 100644
--- a/src/util/buffer.c
+++ b/src/util/buffer.c
@@ -18,9 +18,9 @@
18 * @brief Common buffer management functions. 18 * @brief Common buffer management functions.
19 * @author Florian Dold 19 * @author Florian Dold
20 */ 20 */
21
21#include "platform.h" 22#include "platform.h"
22#include "gnunet_util_lib.h" 23#include "gnunet_util_lib.h"
23#include "gnunet_buffer_lib.h"
24 24
25/** 25/**
26 * Initialize a buffer with the given capacity. 26 * Initialize a buffer with the given capacity.
diff --git a/src/util/child_management.c b/src/util/child_management.c
index 8c413a8b5..680dbcabe 100644
--- a/src/util/child_management.c
+++ b/src/util/child_management.c
@@ -25,9 +25,9 @@
25 * @author Dominik Meister (ANASTASIS) 25 * @author Dominik Meister (ANASTASIS)
26 * @author t3sserakt 26 * @author t3sserakt
27 */ 27 */
28
28#include "platform.h" 29#include "platform.h"
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
30#include "gnunet_child_management_lib.h"
31 31
32/** 32/**
33 * Generic logging shortcut 33 * Generic logging shortcut
diff --git a/src/util/client.c b/src/util/client.c
index 91e0c1a85..fb2120ee8 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -26,6 +26,7 @@
26 * Generic TCP code for reliable, record-oriented TCP 26 * Generic TCP code for reliable, record-oriented TCP
27 * connections between clients and service providers. 27 * connections between clients and service providers.
28 */ 28 */
29
29#include "platform.h" 30#include "platform.h"
30#include "gnunet_protocols.h" 31#include "gnunet_protocols.h"
31#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c
index a43ac3865..36d49eddb 100644
--- a/src/util/common_allocation.c
+++ b/src/util/common_allocation.c
@@ -23,8 +23,9 @@
23 * @brief wrapper around malloc/free 23 * @brief wrapper around malloc/free
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_crypto_lib.h" 28#include "gnunet_util_lib.h"
28#if HAVE_MALLOC_H 29#if HAVE_MALLOC_H
29#include <malloc.h> 30#include <malloc.h>
30#endif 31#endif
diff --git a/src/util/common_endian.c b/src/util/common_endian.c
index ce70f91da..59c15326d 100644
--- a/src/util/common_endian.c
+++ b/src/util/common_endian.c
@@ -25,8 +25,9 @@
25 * @author Gabor X Toth 25 * @author Gabor X Toth
26 */ 26 */
27 27
28
28#include "platform.h" 29#include "platform.h"
29#include "gnunet_crypto_lib.h" 30#include "gnunet_util_lib.h"
30 31
31#define LOG(kind, ...) GNUNET_log_from (kind, "util-common-endian", __VA_ARGS__) 32#define LOG(kind, ...) GNUNET_log_from (kind, "util-common-endian", __VA_ARGS__)
32 33
diff --git a/src/util/common_logging.c b/src/util/common_logging.c
index 9fa848224..d27f70e83 100644
--- a/src/util/common_logging.c
+++ b/src/util/common_logging.c
@@ -23,10 +23,9 @@
23 * @brief error handling API 23 * @brief error handling API
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_crypto_lib.h" 28#include "gnunet_util_lib.h"
28#include "gnunet_disk_lib.h"
29#include "gnunet_strings_lib.h"
30#include <regex.h> 29#include <regex.h>
31 30
32 31
diff --git a/src/util/compress.c b/src/util/compress.c
new file mode 100644
index 000000000..73fa25bd9
--- /dev/null
+++ b/src/util/compress.c
@@ -0,0 +1,91 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2022 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file util/compress.c
23 * @brief Simple (de)compression logic
24 * @author Philipp Toelke
25 * @author Martin Schanzenbach
26 */
27
28#include "platform.h"
29#include "gnunet_util_lib.h"
30#include <zlib.h>
31
32int
33GNUNET_try_compression (const char *data,
34 size_t old_size,
35 char **result,
36 size_t *new_size)
37{
38 char *tmp;
39 uLongf dlen;
40
41 *result = NULL;
42 *new_size = 0;
43#ifdef compressBound
44 dlen = compressBound (old_size);
45#else
46 dlen = old_size + (old_size / 100) + 20;
47 /* documentation says 100.1% oldSize + 12 bytes, but we
48 * should be able to overshoot by more to be safe */
49#endif
50 tmp = GNUNET_malloc (dlen);
51 if (Z_OK ==
52 compress2 ((Bytef *) tmp,
53 &dlen,
54 (const Bytef *) data,
55 old_size, 9))
56 {
57 if (dlen < old_size)
58 {
59 *result = tmp;
60 *new_size = dlen;
61 return GNUNET_YES;
62 }
63 }
64 GNUNET_free (tmp);
65 return GNUNET_NO;
66}
67
68
69char *
70GNUNET_decompress (const char *input,
71 size_t input_size,
72 size_t output_size)
73{
74 char *output;
75 uLongf olen;
76
77 olen = output_size;
78 output = GNUNET_malloc (olen);
79 if (Z_OK ==
80 uncompress ((Bytef *) output,
81 &olen,
82 (const Bytef *) input,
83 input_size))
84 return output;
85 GNUNET_free (output);
86 return NULL;
87}
88
89
90
91/* end of compress.c */
diff --git a/src/util/configuration.c b/src/util/configuration.c
index 5c415aff7..1a66458db 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -22,14 +22,10 @@
22 * @brief configuration management 22 * @brief configuration management
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25
25#include "platform.h" 26#include "platform.h"
26#include "gnunet_crypto_lib.h" 27#include "gnunet_util_lib.h"
27#include "gnunet_strings_lib.h"
28#include "gnunet_os_lib.h"
29#include "gnunet_configuration_lib.h" 28#include "gnunet_configuration_lib.h"
30#include "gnunet_disk_lib.h"
31#include "gnunet_buffer_lib.h"
32#include "gnunet_container_lib.h"
33 29
34#define LOG(kind, ...) GNUNET_log_from (kind, "util", __VA_ARGS__) 30#define LOG(kind, ...) GNUNET_log_from (kind, "util", __VA_ARGS__)
35 31
diff --git a/src/util/configuration_helper.c b/src/util/configuration_helper.c
index 8f995ec03..d4d5fc732 100644
--- a/src/util/configuration_helper.c
+++ b/src/util/configuration_helper.c
@@ -22,6 +22,7 @@
22 * @brief helper logic for gnunet-config 22 * @brief helper logic for gnunet-config
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25
25#include "platform.h" 26#include "platform.h"
26#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
27 28
diff --git a/src/util/consttime_memcmp.c b/src/util/consttime_memcmp.c
index 5dfcb0757..d4fa45a5b 100644
--- a/src/util/consttime_memcmp.c
+++ b/src/util/consttime_memcmp.c
@@ -29,6 +29,7 @@ SOFTWARE.
29/* Rest of the file is 'original' */ 29/* Rest of the file is 'original' */
30 30
31 31
32#include "platform.h"
32#include <stddef.h> 33#include <stddef.h>
33#include <inttypes.h> 34#include <inttypes.h>
34 35
diff --git a/src/util/container_bloomfilter.c b/src/util/container_bloomfilter.c
index 4bfb82d14..7e4faaf3f 100644
--- a/src/util/container_bloomfilter.c
+++ b/src/util/container_bloomfilter.c
@@ -39,6 +39,7 @@
39 * @author Christian Grothoff 39 * @author Christian Grothoff
40 */ 40 */
41 41
42
42#include "platform.h" 43#include "platform.h"
43#include "gnunet_util_lib.h" 44#include "gnunet_util_lib.h"
44 45
diff --git a/src/util/container_heap.c b/src/util/container_heap.c
index 24f753adb..77b828d31 100644
--- a/src/util/container_heap.c
+++ b/src/util/container_heap.c
@@ -25,8 +25,9 @@
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 */ 26 */
27 27
28
28#include "platform.h" 29#include "platform.h"
29#include "gnunet_container_lib.h" 30#include "gnunet_util_lib.h"
30 31
31#define LOG(kind, ...) GNUNET_log_from (kind, "util-container-heap", \ 32#define LOG(kind, ...) GNUNET_log_from (kind, "util-container-heap", \
32 __VA_ARGS__) 33 __VA_ARGS__)
diff --git a/src/util/container_multihashmap.c b/src/util/container_multihashmap.c
index 8b1deac12..ab909484a 100644
--- a/src/util/container_multihashmap.c
+++ b/src/util/container_multihashmap.c
@@ -23,8 +23,9 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25 25
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_container_lib.h" 28#include "gnunet_util_lib.h"
28 29
29#define LOG(kind, ...) \ 30#define LOG(kind, ...) \
30 GNUNET_log_from (kind, "util-container-multihashmap", __VA_ARGS__) 31 GNUNET_log_from (kind, "util-container-multihashmap", __VA_ARGS__)
diff --git a/src/util/container_multihashmap32.c b/src/util/container_multihashmap32.c
index 2416c40f2..4ff4e1678 100644
--- a/src/util/container_multihashmap32.c
+++ b/src/util/container_multihashmap32.c
@@ -25,8 +25,9 @@
25 * @author Sree Harsha Totakura 25 * @author Sree Harsha Totakura
26 */ 26 */
27 27
28
28#include "platform.h" 29#include "platform.h"
29#include "gnunet_container_lib.h" 30#include "gnunet_util_lib.h"
30 31
31#define LOG(kind, ...) \ 32#define LOG(kind, ...) \
32 GNUNET_log_from (kind, "util-container-multihashmap32", __VA_ARGS__) 33 GNUNET_log_from (kind, "util-container-multihashmap32", __VA_ARGS__)
diff --git a/src/util/container_multipeermap.c b/src/util/container_multipeermap.c
index 976f172e1..82a240fff 100644
--- a/src/util/container_multipeermap.c
+++ b/src/util/container_multipeermap.c
@@ -23,6 +23,7 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25 25
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/container_multishortmap.c b/src/util/container_multishortmap.c
index a02d55770..3c0adc196 100644
--- a/src/util/container_multishortmap.c
+++ b/src/util/container_multishortmap.c
@@ -23,6 +23,7 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25 25
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/container_multiuuidmap.c b/src/util/container_multiuuidmap.c
index fbc4c8c39..96398e4f5 100644
--- a/src/util/container_multiuuidmap.c
+++ b/src/util/container_multiuuidmap.c
@@ -23,6 +23,7 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25 25
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/crypto_crc.c b/src/util/crypto_crc.c
index a2ffdb543..9328f2b84 100644
--- a/src/util/crypto_crc.c
+++ b/src/util/crypto_crc.c
@@ -27,8 +27,9 @@
27 * @brief implementation of CRC16 and CRC32 27 * @brief implementation of CRC16 and CRC32
28 * @author Christian Grothoff 28 * @author Christian Grothoff
29 */ 29 */
30
30#include "platform.h" 31#include "platform.h"
31#include "gnunet_crypto_lib.h" 32#include "gnunet_util_lib.h"
32 33
33#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-crc", __VA_ARGS__) 34#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-crc", __VA_ARGS__)
34 35
@@ -56,18 +57,17 @@ static void
56crc_init () 57crc_init ()
57{ 58{
58 static int once; 59 static int once;
59 unsigned int i, j;
60 GNUNET_uLong h = 1; 60 GNUNET_uLong h = 1;
61 61
62 if (once) 62 if (once)
63 return; 63 return;
64 once = 1; 64 once = 1;
65 crc_table[0] = 0; 65 crc_table[0] = 0;
66 for (i = 128; i; i >>= 1) 66 for (unsigned int i = 128; i; i >>= 1)
67 { 67 {
68 h = (h >> 1) ^ ((h & 1) ? POLYNOMIAL : 0); 68 h = (h >> 1) ^ ((h & 1) ? POLYNOMIAL : 0);
69 /* h is now crc_table[i] */ 69 /* h is now crc_table[i] */
70 for (j = 0; j < 256; j += 2 * i) 70 for (unsigned int j = 0; j < 256; j += 2 * i)
71 crc_table[i + j] = crc_table[j] ^ h; 71 crc_table[i + j] = crc_table[j] ^ h;
72 } 72 }
73} 73}
@@ -84,7 +84,7 @@ crc_init ()
84 * property of detecting all burst errors of length 32 bits or less. 84 * property of detecting all burst errors of length 32 bits or less.
85 */ 85 */
86static GNUNET_uLong 86static GNUNET_uLong
87crc32 (GNUNET_uLong crc, const char *buf, size_t len) 87gn_crc32 (GNUNET_uLong crc, const char *buf, size_t len)
88{ 88{
89 crc_init (); 89 crc_init ();
90 GNUNET_assert (crc_table[255] != 0); 90 GNUNET_assert (crc_table[255] != 0);
@@ -100,8 +100,8 @@ GNUNET_CRYPTO_crc32_n (const void *buf, size_t len)
100{ 100{
101 GNUNET_uLong crc; 101 GNUNET_uLong crc;
102 102
103 crc = crc32 (0L, Z_NULL, 0); 103 crc = gn_crc32 (0L, Z_NULL, 0);
104 crc = crc32 (crc, (char *) buf, len); 104 crc = gn_crc32 (crc, (char *) buf, len);
105 return crc; 105 return crc;
106} 106}
107 107
diff --git a/src/util/crypto_cs.c b/src/util/crypto_cs.c
index 4c6648229..8506c7fa6 100644
--- a/src/util/crypto_cs.c
+++ b/src/util/crypto_cs.c
@@ -24,8 +24,9 @@
24 * @author Lucien Heuzeveldt <lucienclaude.heuzeveldt@students.bfh.ch> 24 * @author Lucien Heuzeveldt <lucienclaude.heuzeveldt@students.bfh.ch>
25 * @author Gian Demarmels <gian@demarmels.org> 25 * @author Gian Demarmels <gian@demarmels.org>
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_crypto_lib.h" 29#include "gnunet_util_lib.h"
29#include <sodium.h> 30#include <sodium.h>
30#include <gcrypt.h> 31#include <gcrypt.h>
31 32
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c
index c4f0e64bd..7f9e3c070 100644
--- a/src/util/crypto_ecc.c
+++ b/src/util/crypto_ecc.c
@@ -24,11 +24,11 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * @author Florian Dold 25 * @author Florian Dold
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
28#include <gcrypt.h> 29#include <gcrypt.h>
29#include <sodium.h> 30#include <sodium.h>
30#include "gnunet_crypto_lib.h" 31#include "gnunet_util_lib.h"
31#include "gnunet_strings_lib.h"
32#include "benchmark.h" 32#include "benchmark.h"
33 33
34#define EXTRA_CHECKS 0 34#define EXTRA_CHECKS 0
diff --git a/src/util/crypto_ecc_dlog.c b/src/util/crypto_ecc_dlog.c
index 916acd9dd..6e333686f 100644
--- a/src/util/crypto_ecc_dlog.c
+++ b/src/util/crypto_ecc_dlog.c
@@ -25,10 +25,10 @@
25 * result is relativey small. 25 * result is relativey small.
26 * @author Christian Grothoff 26 * @author Christian Grothoff
27 */ 27 */
28
28#include "platform.h" 29#include "platform.h"
29#include <gcrypt.h> 30#include <gcrypt.h>
30#include "gnunet_crypto_lib.h" 31#include "gnunet_util_lib.h"
31#include "gnunet_container_lib.h"
32 32
33 33
34/** 34/**
diff --git a/src/util/crypto_ecc_gnsrecord.c b/src/util/crypto_ecc_gnsrecord.c
index 0ee0570c0..b902e0e0a 100644
--- a/src/util/crypto_ecc_gnsrecord.c
+++ b/src/util/crypto_ecc_gnsrecord.c
@@ -25,11 +25,11 @@
25 * @author Florian Dold 25 * @author Florian Dold
26 * @author Martin Schanzenbach 26 * @author Martin Schanzenbach
27 */ 27 */
28
28#include "platform.h" 29#include "platform.h"
29#include <gcrypt.h> 30#include <gcrypt.h>
30#include <sodium.h> 31#include <sodium.h>
31#include "gnunet_crypto_lib.h" 32#include "gnunet_util_lib.h"
32#include "gnunet_strings_lib.h"
33 33
34#define CURVE "Ed25519" 34#define CURVE "Ed25519"
35 35
diff --git a/src/util/crypto_ecc_setup.c b/src/util/crypto_ecc_setup.c
index cee912e90..e07d1e448 100644
--- a/src/util/crypto_ecc_setup.c
+++ b/src/util/crypto_ecc_setup.c
@@ -23,6 +23,7 @@
23 * @brief helper function for easy EdDSA key setup 23 * @brief helper function for easy EdDSA key setup
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include <gcrypt.h> 28#include <gcrypt.h>
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
diff --git a/src/util/crypto_edx25519.c b/src/util/crypto_edx25519.c
index e43c1685b..2d9a76aa3 100644
--- a/src/util/crypto_edx25519.c
+++ b/src/util/crypto_edx25519.c
@@ -26,11 +26,11 @@
26 * @author Florian Dold 26 * @author Florian Dold
27 * @author Martin Schanzenbach 27 * @author Martin Schanzenbach
28 */ 28 */
29
29#include "platform.h" 30#include "platform.h"
30#include <gcrypt.h> 31#include <gcrypt.h>
31#include <sodium.h> 32#include <sodium.h>
32#include "gnunet_crypto_lib.h" 33#include "gnunet_util_lib.h"
33#include "gnunet_strings_lib.h"
34 34
35#define CURVE "Ed25519" 35#define CURVE "Ed25519"
36 36
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c
index c910eb81c..e45cb42e0 100644
--- a/src/util/crypto_hash.c
+++ b/src/util/crypto_hash.c
@@ -23,9 +23,9 @@
23 * @brief SHA-512 #GNUNET_CRYPTO_hash() related functions 23 * @brief SHA-512 #GNUNET_CRYPTO_hash() related functions
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_crypto_lib.h" 28#include "gnunet_util_lib.h"
28#include "gnunet_strings_lib.h"
29#include "benchmark.h" 29#include "benchmark.h"
30#include <gcrypt.h> 30#include <gcrypt.h>
31 31
diff --git a/src/util/crypto_hash_file.c b/src/util/crypto_hash_file.c
index 42056fb38..7300bab29 100644
--- a/src/util/crypto_hash_file.c
+++ b/src/util/crypto_hash_file.c
@@ -23,6 +23,7 @@
23 * @brief incremental hashing of files 23 * @brief incremental hashing of files
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include <gcrypt.h> 29#include <gcrypt.h>
diff --git a/src/util/crypto_hkdf.c b/src/util/crypto_hkdf.c
index 838e37d8d..e724bc9ba 100644
--- a/src/util/crypto_hkdf.c
+++ b/src/util/crypto_hkdf.c
@@ -50,8 +50,9 @@
50 50
51 51
52#if GNUNET_BUILD 52#if GNUNET_BUILD
53
53#include "platform.h" 54#include "platform.h"
54#include "gnunet_crypto_lib.h" 55#include "gnunet_util_lib.h"
55#include "benchmark.h" 56#include "benchmark.h"
56#else 57#else
57#define GNUNET_NO 0 58#define GNUNET_NO 0
@@ -126,7 +127,7 @@ getPRK (gcry_md_hd_t mac,
126 if (0 == xts_len) 127 if (0 == xts_len)
127 { 128 {
128 char zero_salt[dlen]; 129 char zero_salt[dlen];
129 130
130 memset (zero_salt, 0, dlen); 131 memset (zero_salt, 0, dlen);
131 ret = doHMAC (mac, zero_salt, dlen, skm, skm_len); 132 ret = doHMAC (mac, zero_salt, dlen, skm, skm_len);
132 } 133 }
diff --git a/src/util/crypto_kdf.c b/src/util/crypto_kdf.c
index f577e0f7a..7cfd8fea4 100644
--- a/src/util/crypto_kdf.c
+++ b/src/util/crypto_kdf.c
@@ -25,10 +25,11 @@
25 * @author Jeffrey Burdges <burdges@gnunet.org> 25 * @author Jeffrey Burdges <burdges@gnunet.org>
26 */ 26 */
27 27
28#include "platform.h"
28#include <gcrypt.h> 29#include <gcrypt.h>
29 30
30#include "platform.h" 31
31#include "gnunet_crypto_lib.h" 32#include "gnunet_util_lib.h"
32 33
33#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-kdf", __VA_ARGS__) 34#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-kdf", __VA_ARGS__)
34 35
diff --git a/src/util/crypto_mpi.c b/src/util/crypto_mpi.c
index 6df47c7e1..06f2fd786 100644
--- a/src/util/crypto_mpi.c
+++ b/src/util/crypto_mpi.c
@@ -24,9 +24,10 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * @author Florian Dold 25 * @author Florian Dold
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
28#include <gcrypt.h> 29#include <gcrypt.h>
29#include "gnunet_crypto_lib.h" 30#include "gnunet_util_lib.h"
30 31
31 32
32#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-mpi", __VA_ARGS__) 33#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-mpi", __VA_ARGS__)
diff --git a/src/util/crypto_paillier.c b/src/util/crypto_paillier.c
index 5d762eba4..169d1e49e 100644
--- a/src/util/crypto_paillier.c
+++ b/src/util/crypto_paillier.c
@@ -24,6 +24,7 @@
24 * @author Florian Dold 24 * @author Florian Dold
25 * @author Christian Fuchs 25 * @author Christian Fuchs
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
28#include <gcrypt.h> 29#include <gcrypt.h>
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
diff --git a/src/util/crypto_pow.c b/src/util/crypto_pow.c
index 051a0c209..bfaaf555d 100644
--- a/src/util/crypto_pow.c
+++ b/src/util/crypto_pow.c
@@ -23,8 +23,9 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 * @author Bart Polot 24 * @author Bart Polot
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_crypto_lib.h" 28#include "gnunet_util_lib.h"
28#include <sodium.h> 29#include <sodium.h>
29 30
30/** 31/**
diff --git a/src/util/crypto_random.c b/src/util/crypto_random.c
index b2dcde124..72474d04b 100644
--- a/src/util/crypto_random.c
+++ b/src/util/crypto_random.c
@@ -24,9 +24,9 @@
24 * @brief functions to gather random numbers 24 * @brief functions to gather random numbers
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_crypto_lib.h" 29#include "gnunet_util_lib.h"
29#include "gnunet_time_lib.h"
30#include <gcrypt.h> 30#include <gcrypt.h>
31 31
32#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-random", __VA_ARGS__) 32#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-random", __VA_ARGS__)
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c
index 325a1fe86..2c446d21a 100644
--- a/src/util/crypto_rsa.c
+++ b/src/util/crypto_rsa.c
@@ -25,9 +25,10 @@
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 * @author Jeffrey Burdges <burdges@gnunet.org> 26 * @author Jeffrey Burdges <burdges@gnunet.org>
27 */ 27 */
28
28#include "platform.h" 29#include "platform.h"
29#include <gcrypt.h> 30#include <gcrypt.h>
30#include "gnunet_crypto_lib.h" 31#include "gnunet_util_lib.h"
31#include "benchmark.h" 32#include "benchmark.h"
32 33
33#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-rsa", __VA_ARGS__) 34#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-rsa", __VA_ARGS__)
diff --git a/src/util/crypto_symmetric.c b/src/util/crypto_symmetric.c
index ad54aa8b3..a9217febd 100644
--- a/src/util/crypto_symmetric.c
+++ b/src/util/crypto_symmetric.c
@@ -25,8 +25,9 @@
25 * @author Ioana Patrascu 25 * @author Ioana Patrascu
26 */ 26 */
27 27
28
28#include "platform.h" 29#include "platform.h"
29#include "gnunet_crypto_lib.h" 30#include "gnunet_util_lib.h"
30#include <gcrypt.h> 31#include <gcrypt.h>
31 32
32#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-symmetric", \ 33#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-symmetric", \
diff --git a/src/util/disk.c b/src/util/disk.c
index 2efb52d46..1d0e14b98 100644
--- a/src/util/disk.c
+++ b/src/util/disk.c
@@ -23,10 +23,9 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 * @author Nils Durner 24 * @author Nils Durner
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "disk.h" 28#include "gnunet_util_lib.h"
28#include "gnunet_strings_lib.h"
29#include "gnunet_disk_lib.h"
30 29
31#define LOG(kind, ...) GNUNET_log_from (kind, "util-disk", __VA_ARGS__) 30#define LOG(kind, ...) GNUNET_log_from (kind, "util-disk", __VA_ARGS__)
32 31
diff --git a/src/util/disk.h b/src/util/disk.h
index 89ff76687..bca398e26 100644
--- a/src/util/disk.h
+++ b/src/util/disk.h
@@ -26,8 +26,7 @@
26#ifndef GNUNET_DISK_H_ 26#ifndef GNUNET_DISK_H_
27#define GNUNET_DISK_H_ 27#define GNUNET_DISK_H_
28 28
29#include "gnunet_crypto_lib.h" 29#include "gnunet_util_lib.h"
30#include "gnunet_disk_lib.h"
31 30
32/** 31/**
33 * Retrieve OS file handle 32 * Retrieve OS file handle
diff --git a/src/util/dnsparser.c b/src/util/dnsparser.c
index d8b4a9bed..dab38def7 100644
--- a/src/util/dnsparser.c
+++ b/src/util/dnsparser.c
@@ -24,7 +24,9 @@
24 * @author Philipp Toelke 24 * @author Philipp Toelke
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
29#include "gnunet_util_lib.h"
28#if HAVE_LIBIDN2 30#if HAVE_LIBIDN2
29#if HAVE_IDN2_H 31#if HAVE_IDN2_H
30#include <idn2.h> 32#include <idn2.h>
@@ -38,8 +40,6 @@
38#include <idn/idna.h> 40#include <idn/idna.h>
39#endif 41#endif
40#endif 42#endif
41#include "gnunet_util_lib.h"
42
43 43
44/** 44/**
45 * Check if a label in UTF-8 format can be coded into valid IDNA. 45 * Check if a label in UTF-8 format can be coded into valid IDNA.
diff --git a/src/util/dnsstub.c b/src/util/dnsstub.c
index 9763f6501..c259b51dd 100644
--- a/src/util/dnsstub.c
+++ b/src/util/dnsstub.c
@@ -22,6 +22,7 @@
22 * @brief DNS stub resolver which sends DNS requests to an actual resolver 22 * @brief DNS stub resolver which sends DNS requests to an actual resolver
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25
25#include "platform.h" 26#include "platform.h"
26#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
27 28
diff --git a/src/util/getopt.c b/src/util/getopt.c
index 6dfad96da..b1737bbc7 100644
--- a/src/util/getopt.c
+++ b/src/util/getopt.c
@@ -37,6 +37,7 @@
37 * replace main GNU getopt parser with one that 37 * replace main GNU getopt parser with one that
38 * actually fits our API. 38 * actually fits our API.
39 */ 39 */
40
40#include "platform.h" 41#include "platform.h"
41#include "gnunet_util_lib.h" 42#include "gnunet_util_lib.h"
42 43
diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c
index 96aee40e3..31020f185 100644
--- a/src/util/getopt_helpers.c
+++ b/src/util/getopt_helpers.c
@@ -23,6 +23,7 @@
23 * @brief implements command line that sets option 23 * @brief implements command line that sets option
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/gnunet-base32.c b/src/util/gnunet-base32.c
index 217185ed0..209741740 100644
--- a/src/util/gnunet-base32.c
+++ b/src/util/gnunet-base32.c
@@ -23,6 +23,7 @@
23 * @brief tool to encode/decode from/to the Crockford Base32 encoding GNUnet uses 23 * @brief tool to encode/decode from/to the Crockford Base32 encoding GNUnet uses
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/gnunet-config-diff.c b/src/util/gnunet-config-diff.c
index 207b9518a..e1e3ffd5d 100644
--- a/src/util/gnunet-config-diff.c
+++ b/src/util/gnunet-config-diff.c
@@ -1,3 +1,4 @@
1
1#include "platform.h" 2#include "platform.h"
2#include <gnunet_util_lib.h> 3#include <gnunet_util_lib.h>
3 4
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c
index 7fda209da..714c683dd 100644
--- a/src/util/gnunet-config.c
+++ b/src/util/gnunet-config.c
@@ -23,6 +23,7 @@
23 * @brief tool to access and manipulate GNUnet configuration files 23 * @brief tool to access and manipulate GNUnet configuration files
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/gnunet-crypto-tvg.c b/src/util/gnunet-crypto-tvg.c
index 6ec9229e3..4655407f0 100644
--- a/src/util/gnunet-crypto-tvg.c
+++ b/src/util/gnunet-crypto-tvg.c
@@ -47,6 +47,7 @@
47 * 47 *
48 * 48 *
49 */ 49 */
50
50#include "platform.h" 51#include "platform.h"
51#include "gnunet_util_lib.h" 52#include "gnunet_util_lib.h"
52#include "gnunet_signatures.h" 53#include "gnunet_signatures.h"
diff --git a/src/util/gnunet-ecc.c b/src/util/gnunet-ecc.c
index 8e30ac416..812745085 100644
--- a/src/util/gnunet-ecc.c
+++ b/src/util/gnunet-ecc.c
@@ -23,6 +23,7 @@
23 * @brief tool to manipulate EDDSA key files 23 * @brief tool to manipulate EDDSA key files
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include "gnunet_testing_lib.h" 29#include "gnunet_testing_lib.h"
diff --git a/src/util/gnunet-qr.c b/src/util/gnunet-qr.c
index 5bccd3916..d9b873c05 100644
--- a/src/util/gnunet-qr.c
+++ b/src/util/gnunet-qr.c
@@ -23,12 +23,13 @@
23 * @author Martin Schanzenbach (integrate gnunet-uri) 23 * @author Martin Schanzenbach (integrate gnunet-uri)
24 * @author Christian Grothoff (error handling) 24 * @author Christian Grothoff (error handling)
25 */ 25 */
26#include "platform.h"
26#include <stdio.h> 27#include <stdio.h>
27#include <stdbool.h> 28#include <stdbool.h>
28#include <signal.h> 29#include <signal.h>
29#include <zbar.h> 30#include <zbar.h>
30 31
31#include "platform.h" 32
32#include "gnunet_util_lib.h" 33#include "gnunet_util_lib.h"
33 34
34#if HAVE_PNG 35#if HAVE_PNG
diff --git a/src/util/gnunet-resolver.c b/src/util/gnunet-resolver.c
index d8e6a1f0d..a23aeb4aa 100644
--- a/src/util/gnunet-resolver.c
+++ b/src/util/gnunet-resolver.c
@@ -23,6 +23,7 @@
23 * @brief tool to test resolver 23 * @brief tool to test resolver
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include "gnunet_resolver_service.h" 29#include "gnunet_resolver_service.h"
diff --git a/src/util/gnunet-scrypt.c b/src/util/gnunet-scrypt.c
index 3c219ef4f..3d1b9c017 100644
--- a/src/util/gnunet-scrypt.c
+++ b/src/util/gnunet-scrypt.c
@@ -22,6 +22,7 @@
22 * @brief tool to manipulate SCRYPT proofs of work. 22 * @brief tool to manipulate SCRYPT proofs of work.
23 * @author Bart Polot 23 * @author Bart Polot
24 */ 24 */
25
25#include "platform.h" 26#include "platform.h"
26#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
27#include <gcrypt.h> 28#include <gcrypt.h>
diff --git a/src/util/gnunet-service-resolver.c b/src/util/gnunet-service-resolver.c
index bb70ac3bd..77b57c72b 100644
--- a/src/util/gnunet-service-resolver.c
+++ b/src/util/gnunet-service-resolver.c
@@ -23,6 +23,7 @@
23 * @brief code to do DNS resolution 23 * @brief code to do DNS resolution
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include "gnunet_protocols.h" 29#include "gnunet_protocols.h"
diff --git a/src/util/gnunet-timeout.c b/src/util/gnunet-timeout.c
index 4c3c9125d..1d3002c08 100644
--- a/src/util/gnunet-timeout.c
+++ b/src/util/gnunet-timeout.c
@@ -24,6 +24,7 @@
24 * @author Matthias Wachs 24 * @author Matthias Wachs
25 */ 25 */
26 26
27#include "platform.h"
27#include <sys/types.h> 28#include <sys/types.h>
28#include <sys/wait.h> 29#include <sys/wait.h>
29#include <signal.h> 30#include <signal.h>
diff --git a/src/util/gnunet-uri.c b/src/util/gnunet-uri.c
index de0ff1f92..128167cc5 100644
--- a/src/util/gnunet-uri.c
+++ b/src/util/gnunet-uri.c
@@ -23,6 +23,7 @@
23 * @brief tool to dispatch URIs to the appropriate GNUnet helper process 23 * @brief tool to dispatch URIs to the appropriate GNUnet helper process
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/helper.c b/src/util/helper.c
index 09d3fffab..fe8643d31 100644
--- a/src/util/helper.c
+++ b/src/util/helper.c
@@ -25,10 +25,9 @@
25 * @author Philipp Toelke 25 * @author Philipp Toelke
26 * @author Christian Grothoff 26 * @author Christian Grothoff
27 */ 27 */
28
28#include "platform.h" 29#include "platform.h"
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
30#include "gnunet_mst_lib.h"
31
32 31
33/** 32/**
34 * Entry in the queue of messages we need to transmit to the helper. 33 * Entry in the queue of messages we need to transmit to the helper.
diff --git a/src/util/load.c b/src/util/load.c
index 64f0b19c1..a64171bd4 100644
--- a/src/util/load.c
+++ b/src/util/load.c
@@ -23,6 +23,7 @@
23 * @brief functions related to load calculations 23 * @brief functions related to load calculations
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/mq.c b/src/util/mq.c
index 585389ce8..788b9b636 100644
--- a/src/util/mq.c
+++ b/src/util/mq.c
@@ -23,6 +23,7 @@
23 * @file util/mq.c 23 * @file util/mq.c
24 * @brief general purpose request queue 24 * @brief general purpose request queue
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/mst.c b/src/util/mst.c
index 18f144906..d8509b7ec 100644
--- a/src/util/mst.c
+++ b/src/util/mst.c
@@ -24,6 +24,7 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26 26
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29 30
diff --git a/src/util/nc.c b/src/util/nc.c
index 49c95c14e..2a612917c 100644
--- a/src/util/nc.c
+++ b/src/util/nc.c
@@ -25,6 +25,7 @@
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 */ 26 */
27 27
28
28#include "platform.h" 29#include "platform.h"
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
30 31
diff --git a/src/util/network.c b/src/util/network.c
index 7588033c4..ac3de89bf 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -24,8 +24,8 @@
24 * @author Nils Durner 24 * @author Nils Durner
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h"
29#include "disk.h" 29#include "disk.h"
30 30
31#define LOG(kind, ...) GNUNET_log_from (kind, "util-network", __VA_ARGS__) 31#define LOG(kind, ...) GNUNET_log_from (kind, "util-network", __VA_ARGS__)
diff --git a/src/util/op.c b/src/util/op.c
index 647fedb53..a8fc3de4a 100644
--- a/src/util/op.c
+++ b/src/util/op.c
@@ -25,9 +25,10 @@
25 * @author Gabor X Toth 25 * @author Gabor X Toth
26 */ 26 */
27 27
28#include "platform.h"
28#include <inttypes.h> 29#include <inttypes.h>
29 30
30#include "platform.h" 31
31#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
32 33
33#define LOG(kind, ...) GNUNET_log_from (kind, "util-op", __VA_ARGS__) 34#define LOG(kind, ...) GNUNET_log_from (kind, "util-op", __VA_ARGS__)
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index 7a348b42e..ff04a8a7f 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -28,13 +28,14 @@
28 * @author Heikki Lindholm 28 * @author Heikki Lindholm
29 * @author LRN 29 * @author LRN
30 */ 30 */
31#include "platform.h"
31#include <sys/stat.h> 32#include <sys/stat.h>
32#include <stdlib.h> 33#include <stdlib.h>
33#include <string.h> 34#include <string.h>
34#include <unistd.h> 35#include <unistd.h>
35#include <unistr.h> /* for u16_to_u8 */ 36#include <unistr.h> /* for u16_to_u8 */
36 37
37#include "platform.h" 38
38#include "gnunet_util_lib.h" 39#include "gnunet_util_lib.h"
39#if DARWIN 40#if DARWIN
40#include <mach-o/ldsyms.h> 41#include <mach-o/ldsyms.h>
diff --git a/src/util/os_network.c b/src/util/os_network.c
index 9ee26f0a9..30cc8a7ce 100644
--- a/src/util/os_network.c
+++ b/src/util/os_network.c
@@ -27,6 +27,7 @@
27 * @author LRN 27 * @author LRN
28 * @author Christian Grothoff 28 * @author Christian Grothoff
29 */ 29 */
30
30#include "platform.h" 31#include "platform.h"
31#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
32 33
diff --git a/src/util/os_priority.c b/src/util/os_priority.c
index e60273814..6f1c596c8 100644
--- a/src/util/os_priority.c
+++ b/src/util/os_priority.c
@@ -24,6 +24,7 @@
24 * @author Nils Durner 24 * @author Nils Durner
25 */ 25 */
26 26
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29#include "disk.h" 30#include "disk.h"
diff --git a/src/util/peer.c b/src/util/peer.c
index 809efdcd5..e5c15b098 100644
--- a/src/util/peer.c
+++ b/src/util/peer.c
@@ -23,8 +23,9 @@
23 * @brief peer-ID table that assigns integer IDs to peer-IDs to save memory 23 * @brief peer-ID table that assigns integer IDs to peer-IDs to save memory
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_peer_lib.h" 28#include "gnunet_util_lib.h"
28 29
29#define LOG(kind, ...) GNUNET_log_from (kind, "util-peer", __VA_ARGS__) 30#define LOG(kind, ...) GNUNET_log_from (kind, "util-peer", __VA_ARGS__)
30 31
diff --git a/src/util/perf_crypto_asymmetric.c b/src/util/perf_crypto_asymmetric.c
index 8533351e1..c033a02ca 100644
--- a/src/util/perf_crypto_asymmetric.c
+++ b/src/util/perf_crypto_asymmetric.c
@@ -23,6 +23,7 @@
23 * @file util/perf_crypto_asymmetric.c 23 * @file util/perf_crypto_asymmetric.c
24 * @brief measure performance of public key functions 24 * @brief measure performance of public key functions
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include <gauger.h> 29#include <gauger.h>
diff --git a/src/util/perf_crypto_cs.c b/src/util/perf_crypto_cs.c
index 54c9c8e0e..43f32aae0 100644
--- a/src/util/perf_crypto_cs.c
+++ b/src/util/perf_crypto_cs.c
@@ -25,6 +25,7 @@
25 * @brief measure performance of Clause Blind Schnorr Signatures 25 * @brief measure performance of Clause Blind Schnorr Signatures
26 */ 26 */
27 27
28
28#include "platform.h" 29#include "platform.h"
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
30#include <gauger.h> 31#include <gauger.h>
diff --git a/src/util/perf_crypto_ecc_dlog.c b/src/util/perf_crypto_ecc_dlog.c
index f32ffbd67..698a3aafa 100644
--- a/src/util/perf_crypto_ecc_dlog.c
+++ b/src/util/perf_crypto_ecc_dlog.c
@@ -23,6 +23,7 @@
23 * @brief benchmark for ECC DLOG calculation 23 * @brief benchmark for ECC DLOG calculation
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include <gcrypt.h> 29#include <gcrypt.h>
diff --git a/src/util/perf_crypto_hash.c b/src/util/perf_crypto_hash.c
index 3bd483639..4e37ef758 100644
--- a/src/util/perf_crypto_hash.c
+++ b/src/util/perf_crypto_hash.c
@@ -23,6 +23,7 @@
23 * @file util/perf_crypto_hash.c 23 * @file util/perf_crypto_hash.c
24 * @brief measure performance of hash function 24 * @brief measure performance of hash function
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include <gauger.h> 29#include <gauger.h>
diff --git a/src/util/perf_crypto_paillier.c b/src/util/perf_crypto_paillier.c
index 35e6cce16..53c717a66 100644
--- a/src/util/perf_crypto_paillier.c
+++ b/src/util/perf_crypto_paillier.c
@@ -23,6 +23,7 @@
23 * @file util/perf_crypto_paillier.c 23 * @file util/perf_crypto_paillier.c
24 * @brief measure performance of Paillier encryption 24 * @brief measure performance of Paillier encryption
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include <gauger.h> 29#include <gauger.h>
diff --git a/src/util/perf_crypto_rsa.c b/src/util/perf_crypto_rsa.c
index 3806fe43d..ab9f362cf 100644
--- a/src/util/perf_crypto_rsa.c
+++ b/src/util/perf_crypto_rsa.c
@@ -23,6 +23,7 @@
23 * @file util/perf_crypto_rsa.c 23 * @file util/perf_crypto_rsa.c
24 * @brief measure performance of RSA signing 24 * @brief measure performance of RSA signing
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include <gauger.h> 29#include <gauger.h>
diff --git a/src/util/perf_crypto_symmetric.c b/src/util/perf_crypto_symmetric.c
index 8176361ba..9be452015 100644
--- a/src/util/perf_crypto_symmetric.c
+++ b/src/util/perf_crypto_symmetric.c
@@ -23,6 +23,7 @@
23 * @file util/perf_crypto_symmetric.c 23 * @file util/perf_crypto_symmetric.c
24 * @brief measure performance of encryption function 24 * @brief measure performance of encryption function
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include <gauger.h> 29#include <gauger.h>
diff --git a/src/util/perf_malloc.c b/src/util/perf_malloc.c
index ea25148ec..48a4a2ae7 100644
--- a/src/util/perf_malloc.c
+++ b/src/util/perf_malloc.c
@@ -23,6 +23,7 @@
23 * @file util/perf_malloc.c 23 * @file util/perf_malloc.c
24 * @brief measure performance of allocation functions 24 * @brief measure performance of allocation functions
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include <gauger.h> 29#include <gauger.h>
diff --git a/src/util/perf_mq.c b/src/util/perf_mq.c
index f6e3d78e2..5c956e4e9 100644
--- a/src/util/perf_mq.c
+++ b/src/util/perf_mq.c
@@ -24,6 +24,7 @@
24 * @author Florian Dold 24 * @author Florian Dold
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29#include <gauger.h> 30#include <gauger.h>
diff --git a/src/util/perf_scheduler.c b/src/util/perf_scheduler.c
index 4d4d0a228..af084e04a 100644
--- a/src/util/perf_scheduler.c
+++ b/src/util/perf_scheduler.c
@@ -22,6 +22,7 @@
22 * @file util/perf_scheduler.c 22 * @file util/perf_scheduler.c
23 * @brief measure performance of scheduler functions 23 * @brief measure performance of scheduler functions
24 */ 24 */
25
25#include "platform.h" 26#include "platform.h"
26#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
27#include <gauger.h> 28#include <gauger.h>
diff --git a/src/util/plugin.c b/src/util/plugin.c
index ffbae06ff..62c2a1df0 100644
--- a/src/util/plugin.c
+++ b/src/util/plugin.c
@@ -24,6 +24,7 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26 26
27
27#include "platform.h" 28#include "platform.h"
28#include <ltdl.h> 29#include <ltdl.h>
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
diff --git a/src/util/proc_compat.c b/src/util/proc_compat.c
index 6e852cb35..0423a0d5c 100644
--- a/src/util/proc_compat.c
+++ b/src/util/proc_compat.c
@@ -17,7 +17,7 @@
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
20#include "platform.h" 20
21 21
22/** 22/**
23 * @author Martin Schanzenbach 23 * @author Martin Schanzenbach
@@ -26,6 +26,7 @@
26 * Definitions for macOS and Win32 26 * Definitions for macOS and Win32
27 */ 27 */
28 28
29#include "platform.h"
29 30
30/** 31/**
31 * memrchr as defined in glibc 32 * memrchr as defined in glibc
diff --git a/src/util/program.c b/src/util/program.c
index fb7929b98..21b616ee2 100644
--- a/src/util/program.c
+++ b/src/util/program.c
@@ -24,6 +24,7 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26 26
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29#include "gnunet_resolver_service.h" 30#include "gnunet_resolver_service.h"
diff --git a/src/util/regex.c b/src/util/regex.c
index c2040a4b8..282d3aa99 100644
--- a/src/util/regex.c
+++ b/src/util/regex.c
@@ -23,9 +23,9 @@
23 * @author Maximilian Szengel 23 * @author Maximilian Szengel
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include "gnunet_tun_lib.h"
29 29
30/** 30/**
31 * 'wildcard', matches all possible values (for HEX encoding). 31 * 'wildcard', matches all possible values (for HEX encoding).
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c
index d38c700e4..130363c77 100644
--- a/src/util/resolver_api.c
+++ b/src/util/resolver_api.c
@@ -23,6 +23,7 @@
23 * @brief resolver for writing a tool 23 * @brief resolver for writing a tool
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include "gnunet_protocols.h" 29#include "gnunet_protocols.h"
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index acae4d7e2..f3b220c4a 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -22,6 +22,7 @@
22 * @brief schedule computations using continuation passing style 22 * @brief schedule computations using continuation passing style
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25
25#include "platform.h" 26#include "platform.h"
26#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
27#include "disk.h" 28#include "disk.h"
diff --git a/src/util/service.c b/src/util/service.c
index 27183981e..2c280f5a1 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -24,6 +24,7 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * @author Florian Dold 25 * @author Florian Dold
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29#include "gnunet_protocols.h" 30#include "gnunet_protocols.h"
diff --git a/src/util/signal.c b/src/util/signal.c
index 8b9a9a291..67849a7d6 100644
--- a/src/util/signal.c
+++ b/src/util/signal.c
@@ -24,6 +24,7 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26 26
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29 30
diff --git a/src/util/socks.c b/src/util/socks.c
index a1990ec8b..ffde8a667 100644
--- a/src/util/socks.c
+++ b/src/util/socks.c
@@ -25,6 +25,7 @@
25 * 25 *
26 * These routines should be called only on newly active connections. 26 * These routines should be called only on newly active connections.
27 */ 27 */
28
28#include "platform.h" 29#include "platform.h"
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
30 31
diff --git a/src/util/speedup.c b/src/util/speedup.c
index 82a8746a9..02719e56e 100644
--- a/src/util/speedup.c
+++ b/src/util/speedup.c
@@ -23,6 +23,7 @@
23 * @author Matthias Wachs 23 * @author Matthias Wachs
24 * @brief functions to speedup peer execution by manipulation system time 24 * @brief functions to speedup peer execution by manipulation system time
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include "speedup.h" 29#include "speedup.h"
diff --git a/src/util/strings.c b/src/util/strings.c
index 7e218cc59..479c0fcd6 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -24,13 +24,12 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26 26
27
27#include "platform.h" 28#include "platform.h"
28#if HAVE_ICONV 29#if HAVE_ICONV
29#include <iconv.h> 30#include <iconv.h>
30#endif 31#endif
31#include "gnunet_crypto_lib.h" 32#include "gnunet_util_lib.h"
32#include "gnunet_buffer_lib.h"
33#include "gnunet_strings_lib.h"
34#include <unicase.h> 33#include <unicase.h>
35#include <unistr.h> 34#include <unistr.h>
36#include <uniconv.h> 35#include <uniconv.h>
diff --git a/src/util/test_bio.c b/src/util/test_bio.c
index f18014719..90f0121d4 100644
--- a/src/util/test_bio.c
+++ b/src/util/test_bio.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27 27
28
28#include "platform.h" 29#include "platform.h"
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
30#define TESTSTRING "testString" 31#define TESTSTRING "testString"
@@ -39,25 +40,18 @@ test_normal_rw (void)
39 void *buffer; 40 void *buffer;
40 size_t buffer_size = 0; 41 size_t buffer_size = 0;
41 char *filename = GNUNET_DISK_mktemp ("gnunet-bio"); 42 char *filename = GNUNET_DISK_mktemp ("gnunet-bio");
42 struct GNUNET_CONTAINER_MetaData *mdW;
43 struct GNUNET_CONTAINER_MetaData *mdR = NULL;
44 char *rString = NULL; 43 char *rString = NULL;
45 int64_t wNum = TESTNUMBER64; 44 int64_t wNum = TESTNUMBER64;
46 int64_t rNum = 0; 45 int64_t rNum = 0;
47 46
48 mdW = GNUNET_CONTAINER_meta_data_create ();
49 GNUNET_CONTAINER_meta_data_add_publication_date (mdW);
50
51 struct GNUNET_BIO_WriteSpec ws[] = { 47 struct GNUNET_BIO_WriteSpec ws[] = {
52 GNUNET_BIO_write_spec_string ("test-normal-rw-string", TESTSTRING), 48 GNUNET_BIO_write_spec_string ("test-normal-rw-string", TESTSTRING),
53 GNUNET_BIO_write_spec_meta_data ("test-normal-rw-metadata", mdW),
54 GNUNET_BIO_write_spec_int64 ("test-normal-rw-int64", &wNum), 49 GNUNET_BIO_write_spec_int64 ("test-normal-rw-int64", &wNum),
55 GNUNET_BIO_write_spec_end (), 50 GNUNET_BIO_write_spec_end (),
56 }; 51 };
57 52
58 struct GNUNET_BIO_ReadSpec rs[] = { 53 struct GNUNET_BIO_ReadSpec rs[] = {
59 GNUNET_BIO_read_spec_string ("test-normal-rw-string", &rString, 200), 54 GNUNET_BIO_read_spec_string ("test-normal-rw-string", &rString, 200),
60 GNUNET_BIO_read_spec_meta_data ("test-normal-rw-metadata", &mdR),
61 GNUNET_BIO_read_spec_int64 ("test-normal-rw-int64", &rNum), 55 GNUNET_BIO_read_spec_int64 ("test-normal-rw-int64", &rNum),
62 GNUNET_BIO_read_spec_end (), 56 GNUNET_BIO_read_spec_end (),
63 }; 57 };
@@ -73,11 +67,8 @@ test_normal_rw (void)
73 GNUNET_assert (GNUNET_OK == GNUNET_BIO_read_spec_commit (rh, rs)); 67 GNUNET_assert (GNUNET_OK == GNUNET_BIO_read_spec_commit (rh, rs));
74 GNUNET_assert (GNUNET_OK == GNUNET_BIO_read_close (rh, NULL)); 68 GNUNET_assert (GNUNET_OK == GNUNET_BIO_read_close (rh, NULL));
75 GNUNET_assert (0 == strcmp (TESTSTRING, rString)); 69 GNUNET_assert (0 == strcmp (TESTSTRING, rString));
76 GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_meta_data_test_equal (mdR,
77 mdW));
78 GNUNET_assert (wNum == rNum); 70 GNUNET_assert (wNum == rNum);
79 71
80 GNUNET_CONTAINER_meta_data_destroy (mdR);
81 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (filename)); 72 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (filename));
82 GNUNET_free (filename); 73 GNUNET_free (filename);
83 74
@@ -97,14 +88,10 @@ test_normal_rw (void)
97 GNUNET_assert (GNUNET_OK == GNUNET_BIO_read_spec_commit (rh, rs)); 88 GNUNET_assert (GNUNET_OK == GNUNET_BIO_read_spec_commit (rh, rs));
98 GNUNET_assert (GNUNET_OK == GNUNET_BIO_read_close (rh, NULL)); 89 GNUNET_assert (GNUNET_OK == GNUNET_BIO_read_close (rh, NULL));
99 GNUNET_assert (0 == strcmp (TESTSTRING, rString)); 90 GNUNET_assert (0 == strcmp (TESTSTRING, rString));
100 GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_meta_data_test_equal (mdR,
101 mdW));
102 GNUNET_assert (wNum == rNum); 91 GNUNET_assert (wNum == rNum);
103 92
104 GNUNET_free (buffer); 93 GNUNET_free (buffer);
105 94
106 GNUNET_CONTAINER_meta_data_destroy (mdW);
107 GNUNET_CONTAINER_meta_data_destroy (mdR);
108 return 0; 95 return 0;
109} 96}
110 97
@@ -200,45 +187,6 @@ test_bigstring_rw (void)
200 187
201 188
202static int 189static int
203test_bigmeta_rw (void)
204{
205 static char meta[1024 * 1024 * 10];
206 struct GNUNET_BIO_WriteHandle *wh;
207 struct GNUNET_BIO_ReadHandle *rh;
208 char *filename = GNUNET_DISK_mktemp ("gnunet_bio");
209 struct GNUNET_CONTAINER_MetaData *mdR = NULL;
210
211 memset (meta, 'b', sizeof (meta));
212 meta[sizeof (meta) - 1] = '\0';
213
214 wh = GNUNET_BIO_write_open_file (filename);
215 GNUNET_assert (NULL != wh);
216 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_int32 (wh,
217 "test-bigmeta-rw-int32",
218 sizeof (meta)));
219 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write (wh,
220 "test-bigmeta-rw-bytes",
221 meta,
222 sizeof (meta)));
223 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_close (wh, NULL));
224
225 rh = GNUNET_BIO_read_open_file (filename);
226 GNUNET_assert (NULL != rh);
227 GNUNET_assert (GNUNET_SYSERR ==
228 GNUNET_BIO_read_meta_data (rh,
229 "test-bigmeta-rw-metadata",
230 &mdR));
231 GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read_close (rh, NULL));
232
233 GNUNET_assert (NULL == mdR);
234
235 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (filename));
236 GNUNET_free (filename);
237 return 0;
238}
239
240
241static int
242test_directory_r (void) 190test_directory_r (void)
243{ 191{
244#ifdef LINUX 192#ifdef LINUX
@@ -267,12 +215,12 @@ test_nullfile_rw (void)
267 memset (filename, 'a', sizeof (filename)); 215 memset (filename, 'a', sizeof (filename));
268 filename[sizeof (filename) - 1] = '\0'; 216 filename[sizeof (filename) - 1] = '\0';
269 217
270 GNUNET_log_skip (2, GNUNET_NO); 218 GNUNET_log_skip (1, GNUNET_NO);
271 wh = GNUNET_BIO_write_open_file (filename); 219 wh = GNUNET_BIO_write_open_file (filename);
272 GNUNET_log_skip (0, GNUNET_YES); 220 GNUNET_log_skip (0, GNUNET_YES);
273 GNUNET_assert (NULL == wh); 221 GNUNET_assert (NULL == wh);
274 222
275 GNUNET_log_skip (2, GNUNET_NO); 223 GNUNET_log_skip (1, GNUNET_NO);
276 rh = GNUNET_BIO_read_open_file (filename); 224 rh = GNUNET_BIO_read_open_file (filename);
277 GNUNET_log_skip (0, GNUNET_YES); 225 GNUNET_log_skip (0, GNUNET_YES);
278 GNUNET_assert (NULL == rh); 226 GNUNET_assert (NULL == rh);
@@ -290,11 +238,6 @@ test_fullfile_rw (void)
290 struct GNUNET_BIO_ReadHandle *rh; 238 struct GNUNET_BIO_ReadHandle *rh;
291 char *rString = NULL; 239 char *rString = NULL;
292 char rResult[200]; 240 char rResult[200];
293 struct GNUNET_CONTAINER_MetaData *mdW;
294 struct GNUNET_CONTAINER_MetaData *mdR = NULL;
295
296 mdW = GNUNET_CONTAINER_meta_data_create ();
297 GNUNET_CONTAINER_meta_data_add_publication_date (mdW);
298 241
299 struct GNUNET_BIO_WriteSpec ws[] = { 242 struct GNUNET_BIO_WriteSpec ws[] = {
300 GNUNET_BIO_write_spec_object ("test-fullfile-rw-bytes", 243 GNUNET_BIO_write_spec_object ("test-fullfile-rw-bytes",
@@ -302,8 +245,6 @@ test_fullfile_rw (void)
302 strlen (TESTSTRING)), 245 strlen (TESTSTRING)),
303 GNUNET_BIO_write_spec_string ("test-fullfile-rw-string", 246 GNUNET_BIO_write_spec_string ("test-fullfile-rw-string",
304 TESTSTRING), 247 TESTSTRING),
305 GNUNET_BIO_write_spec_meta_data ("test-fullfile-rw-metadata",
306 mdW),
307 GNUNET_BIO_write_spec_end (), 248 GNUNET_BIO_write_spec_end (),
308 }; 249 };
309 250
@@ -314,8 +255,6 @@ test_fullfile_rw (void)
314 GNUNET_BIO_read_spec_string ("test-fullfile-rw-string", 255 GNUNET_BIO_read_spec_string ("test-fullfile-rw-string",
315 &rString, 256 &rString,
316 200), 257 200),
317 GNUNET_BIO_read_spec_meta_data ("test-fullfile-rw-metadata",
318 &mdR),
319 GNUNET_BIO_read_spec_end (), 258 GNUNET_BIO_read_spec_end (),
320 }; 259 };
321 260
@@ -330,7 +269,6 @@ test_fullfile_rw (void)
330 GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read_close (rh, NULL)); 269 GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read_close (rh, NULL));
331 270
332 GNUNET_assert (NULL == rString); 271 GNUNET_assert (NULL == rString);
333 GNUNET_assert (NULL == mdR);
334#endif 272#endif
335 return 0; 273 return 0;
336} 274}
@@ -368,69 +306,6 @@ test_fakestring_rw (void)
368 306
369 307
370static int 308static int
371test_fakemeta_rw (void)
372{
373 struct GNUNET_BIO_WriteHandle *wh;
374 struct GNUNET_BIO_ReadHandle *rh;
375 char *filename = GNUNET_DISK_mktemp ("gnunet_bio");
376 struct GNUNET_CONTAINER_MetaData *mdR = NULL;
377
378 wh = GNUNET_BIO_write_open_file (filename);
379 GNUNET_assert (NULL != wh);
380 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_int32 (wh,
381 "test-fakestring-rw-int32",
382 2));
383 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_close (wh, NULL));
384
385 rh = GNUNET_BIO_read_open_file (filename);
386 GNUNET_assert (NULL != rh);
387 GNUNET_assert (GNUNET_SYSERR ==
388 GNUNET_BIO_read_meta_data (rh,
389 "test-fakestring-rw-metadata",
390 &mdR));
391 GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read_close (rh, NULL));
392
393 GNUNET_assert (NULL == mdR);
394
395 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (filename));
396 GNUNET_free (filename);
397 return 0;
398}
399
400
401static int
402test_fakebigmeta_rw (void)
403{
404 struct GNUNET_BIO_WriteHandle *wh;
405 struct GNUNET_BIO_ReadHandle *rh;
406 char *filename = GNUNET_DISK_mktemp ("gnunet_bio");
407 struct GNUNET_CONTAINER_MetaData *mdR = NULL;
408 int32_t wNum = 1024 * 1024 * 10;
409
410 wh = GNUNET_BIO_write_open_file (filename);
411 GNUNET_assert (NULL != wh);
412 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_int32 (wh,
413 "test-fakebigmeta-rw-int32",
414 wNum));
415 GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_close (wh, NULL));
416
417 rh = GNUNET_BIO_read_open_file (filename);
418 GNUNET_assert (NULL != rh);
419 GNUNET_assert (GNUNET_SYSERR ==
420 GNUNET_BIO_read_meta_data (rh,
421 "test-fakebigmeta-rw-metadata",
422 &mdR));
423 GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read_close (rh, NULL));
424
425 GNUNET_assert (NULL == mdR);
426
427 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (filename));
428 GNUNET_free (filename);
429 return 0;
430}
431
432
433static int
434check_string_rw (void) 309check_string_rw (void)
435{ 310{
436 GNUNET_assert (0 == test_nullstring_rw ()); 311 GNUNET_assert (0 == test_nullstring_rw ());
@@ -442,16 +317,6 @@ check_string_rw (void)
442 317
443 318
444static int 319static int
445check_metadata_rw (void)
446{
447 GNUNET_assert (0 == test_fakebigmeta_rw ());
448 GNUNET_assert (0 == test_fakemeta_rw ());
449 GNUNET_assert (0 == test_bigmeta_rw ());
450 return 0;
451}
452
453
454static int
455check_file_rw (void) 320check_file_rw (void)
456{ 321{
457 GNUNET_assert (0 == test_normal_rw ()); 322 GNUNET_assert (0 == test_normal_rw ());
@@ -467,7 +332,6 @@ main (int argc, char *argv[])
467{ 332{
468 GNUNET_log_setup ("test-bio", "WARNING", NULL); 333 GNUNET_log_setup ("test-bio", "WARNING", NULL);
469 GNUNET_assert (0 == check_file_rw ()); 334 GNUNET_assert (0 == check_file_rw ());
470 GNUNET_assert (0 == check_metadata_rw ());
471 GNUNET_assert (0 == check_string_rw ()); 335 GNUNET_assert (0 == check_string_rw ());
472 return 0; 336 return 0;
473} 337}
diff --git a/src/util/test_child_management.c b/src/util/test_child_management.c
index 62c143420..90cc74c72 100644
--- a/src/util/test_child_management.c
+++ b/src/util/test_child_management.c
@@ -23,6 +23,7 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 * @author Dominik Meister 24 * @author Dominik Meister
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/test_client.c b/src/util/test_client.c
index ef5765fff..64c32f646 100644
--- a/src/util/test_client.c
+++ b/src/util/test_client.c
@@ -22,6 +22,7 @@
22 * @brief tests for client.c 22 * @brief tests for client.c
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25
25#include "platform.h" 26#include "platform.h"
26#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
27 28
diff --git a/src/util/test_common_allocation.c b/src/util/test_common_allocation.c
index 50f259257..e262b696e 100644
--- a/src/util/test_common_allocation.c
+++ b/src/util/test_common_allocation.c
@@ -22,6 +22,7 @@
22 * @file util/test_common_allocation.c 22 * @file util/test_common_allocation.c
23 * @brief testcase for common_allocation.c 23 * @brief testcase for common_allocation.c
24 */ 24 */
25
25#include "platform.h" 26#include "platform.h"
26#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
27 28
diff --git a/src/util/test_common_endian.c b/src/util/test_common_endian.c
index 10a85a1bb..2c11c594e 100644
--- a/src/util/test_common_endian.c
+++ b/src/util/test_common_endian.c
@@ -21,6 +21,7 @@
21 * @file util/test_common_endian.c 21 * @file util/test_common_endian.c
22 * @brief testcase for common_endian.c 22 * @brief testcase for common_endian.c
23 */ 23 */
24
24#include "platform.h" 25#include "platform.h"
25#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
26 27
diff --git a/src/util/test_common_logging.c b/src/util/test_common_logging.c
index 7d7656ed8..a2e49f20a 100644
--- a/src/util/test_common_logging.c
+++ b/src/util/test_common_logging.c
@@ -23,6 +23,7 @@
23 * @brief testcase for the logging module 23 * @brief testcase for the logging module
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/test_common_logging_dummy.c b/src/util/test_common_logging_dummy.c
index c6c6411da..7e362c683 100644
--- a/src/util/test_common_logging_dummy.c
+++ b/src/util/test_common_logging_dummy.c
@@ -24,12 +24,13 @@
24 * log level adjustment) 24 * log level adjustment)
25 * @author LRN 25 * @author LRN
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
29#include "gnunet_util_lib.h"
30
28#undef GNUNET_EXTRA_LOGGING 31#undef GNUNET_EXTRA_LOGGING
29#define GNUNET_EXTRA_LOGGING GNUNET_YES 32#define GNUNET_EXTRA_LOGGING GNUNET_YES
30 33
31#include "gnunet_util_lib.h"
32
33/** 34/**
34 * Artificial delay attached to each log call that is not skipped out. 35 * Artificial delay attached to each log call that is not skipped out.
35 * This must be long enough for us to not to mistake skipped log call 36 * This must be long enough for us to not to mistake skipped log call
diff --git a/src/util/test_common_logging_runtime_loglevels.c b/src/util/test_common_logging_runtime_loglevels.c
index 79cf9d53a..f3f2fd64f 100644
--- a/src/util/test_common_logging_runtime_loglevels.c
+++ b/src/util/test_common_logging_runtime_loglevels.c
@@ -23,6 +23,7 @@
23 * @brief testcase for the logging module (runtime log level adjustment) 23 * @brief testcase for the logging module (runtime log level adjustment)
24 * @author LRN 24 * @author LRN
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/test_configuration.c b/src/util/test_configuration.c
index 823bf273d..75610fc74 100644
--- a/src/util/test_configuration.c
+++ b/src/util/test_configuration.c
@@ -23,6 +23,7 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25 25
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/test_container_bloomfilter.c b/src/util/test_container_bloomfilter.c
index 06a3fb500..244733dd9 100644
--- a/src/util/test_container_bloomfilter.c
+++ b/src/util/test_container_bloomfilter.c
@@ -24,6 +24,7 @@
24 * @author Igor Wronsky 24 * @author Igor Wronsky
25 */ 25 */
26 26
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29 30
diff --git a/src/util/test_container_dll.c b/src/util/test_container_dll.c
index 33671d00b..fcbef4e8b 100644
--- a/src/util/test_container_dll.c
+++ b/src/util/test_container_dll.c
@@ -24,6 +24,7 @@
24 * @brief Test of DLL operations 24 * @brief Test of DLL operations
25 */ 25 */
26 26
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29 30
diff --git a/src/util/test_container_heap.c b/src/util/test_container_heap.c
index c83c7810f..f11070ed5 100644
--- a/src/util/test_container_heap.c
+++ b/src/util/test_container_heap.c
@@ -24,6 +24,7 @@
24 * @brief Test of heap operations 24 * @brief Test of heap operations
25 */ 25 */
26 26
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29 30
diff --git a/src/util/test_container_meta_data.c b/src/util/test_container_meta_data.c
deleted file mode 100644
index db413f313..000000000
--- a/src/util/test_container_meta_data.c
+++ /dev/null
@@ -1,375 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2003, 2004, 2006, 2009, 2010 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file util/test_container_meta_data.c
23 * @brief Test for container_meta_data.c
24 * @author Christian Grothoff
25 */
26
27#include "platform.h"
28#include "gnunet_util_lib.h"
29
30#define ABORT(m) { fprintf (stderr, "Error at %s:%d\n", __FILE__, __LINE__); \
31 if (m != NULL) GNUNET_CONTAINER_meta_data_destroy (m); \
32 return 1; }
33
34
35static int
36testMeta (int i)
37{
38 struct GNUNET_CONTAINER_MetaData *m;
39 char val[256];
40 char *sval;
41 int j;
42 unsigned int size;
43
44 m = GNUNET_CONTAINER_meta_data_create ();
45 if (GNUNET_OK !=
46 GNUNET_CONTAINER_meta_data_insert (m, "<test>", EXTRACTOR_METATYPE_TITLE,
47 EXTRACTOR_METAFORMAT_UTF8,
48 "text/plain", "TestTitle",
49 strlen ("TestTitle") + 1))
50 ABORT (m);
51 if (GNUNET_OK !=
52 GNUNET_CONTAINER_meta_data_insert (m, "<test>",
53 EXTRACTOR_METATYPE_AUTHOR_NAME,
54 EXTRACTOR_METAFORMAT_UTF8,
55 "text/plain", "TestTitle",
56 strlen ("TestTitle") + 1))
57 ABORT (m);
58 if (GNUNET_OK == GNUNET_CONTAINER_meta_data_insert (m, "<test>",
59 EXTRACTOR_METATYPE_TITLE,
60 EXTRACTOR_METAFORMAT_UTF8,
61 "text/plain",
62 "TestTitle", strlen (
63 "TestTitle") + 1)) /* dup! */
64 ABORT (m);
65 if (GNUNET_OK == GNUNET_CONTAINER_meta_data_insert (m, "<test>",
66 EXTRACTOR_METATYPE_AUTHOR_NAME,
67 EXTRACTOR_METAFORMAT_UTF8,
68 "text/plain",
69 "TestTitle", strlen (
70 "TestTitle") + 1)) /* dup! */
71 ABORT (m);
72 if (2 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL))
73 ABORT (m);
74 if (GNUNET_OK !=
75 GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_AUTHOR_NAME,
76 "TestTitle", strlen ("TestTitle") + 1))
77 ABORT (m);
78 if (GNUNET_OK == GNUNET_CONTAINER_meta_data_delete (m,
79 EXTRACTOR_METATYPE_AUTHOR_NAME,
80 "TestTitle", strlen (
81 "TestTitle") + 1)) /* already gone */
82 ABORT (m);
83 if (1 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL))
84 ABORT (m);
85 if (GNUNET_OK !=
86 GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_TITLE,
87 "TestTitle", strlen ("TestTitle") + 1))
88 ABORT (m);
89 if (GNUNET_OK == GNUNET_CONTAINER_meta_data_delete (m,
90 EXTRACTOR_METATYPE_TITLE,
91 "TestTitle", strlen (
92 "TestTitle") + 1)) /* already gone */
93 ABORT (m);
94 if (0 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL))
95 ABORT (m);
96 for (j = 0; j < i; j++)
97 {
98 GNUNET_snprintf (val, sizeof(val), "%s.%d",
99 "A teststring that should compress well.", j);
100 if (GNUNET_OK !=
101 GNUNET_CONTAINER_meta_data_insert (m, "<test>",
102 EXTRACTOR_METATYPE_UNKNOWN,
103 EXTRACTOR_METAFORMAT_UTF8,
104 "text/plain", val, strlen (val) + 1))
105 ABORT (m);
106 }
107 if (i != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL))
108 ABORT (m);
109
110 size = GNUNET_CONTAINER_meta_data_get_serialized_size (m);
111 sval = NULL;
112 if (size !=
113 GNUNET_CONTAINER_meta_data_serialize (m, &sval, size,
114 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL))
115 {
116 GNUNET_free (sval);
117 ABORT (m);
118 }
119 GNUNET_CONTAINER_meta_data_destroy (m);
120 m = GNUNET_CONTAINER_meta_data_deserialize (sval, size);
121 GNUNET_free (sval);
122 if (m == NULL)
123 ABORT (m);
124 for (j = 0; j < i; j++)
125 {
126 GNUNET_snprintf (val,
127 sizeof(val),
128 "%s.%d",
129 "A teststring that should compress well.",
130 j);
131 if (GNUNET_OK !=
132 GNUNET_CONTAINER_meta_data_delete (m,
133 EXTRACTOR_METATYPE_UNKNOWN,
134 val,
135 strlen (val) + 1))
136 {
137 ABORT (m);
138 }
139 }
140 if (0 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL))
141 ABORT (m);
142 GNUNET_CONTAINER_meta_data_destroy (m);
143 return 0;
144}
145
146
147static int
148testMetaMore (int i)
149{
150 struct GNUNET_CONTAINER_MetaData *meta;
151 int q;
152 char txt[128];
153 char *data;
154 unsigned long long size;
155
156 meta = GNUNET_CONTAINER_meta_data_create ();
157 for (q = 0; q <= i; q++)
158 {
159 GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q);
160 GNUNET_CONTAINER_meta_data_insert (meta, "<test>",
161 q
162 % 42 /* EXTRACTOR_metatype_get_max () */,
163 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
164 txt, strlen (txt) + 1);
165 }
166 size = GNUNET_CONTAINER_meta_data_get_serialized_size (meta);
167 data = GNUNET_malloc (size * 4);
168 if (size !=
169 GNUNET_CONTAINER_meta_data_serialize (meta, &data, size * 4,
170 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL))
171 {
172 GNUNET_free (data);
173 ABORT (meta);
174 }
175 GNUNET_CONTAINER_meta_data_destroy (meta);
176 GNUNET_free (data);
177 return 0;
178}
179
180
181static int
182testMetaLink ()
183{
184 struct GNUNET_CONTAINER_MetaData *m;
185 char *val;
186 unsigned int size;
187
188 m = GNUNET_CONTAINER_meta_data_create ();
189 if (GNUNET_OK !=
190 GNUNET_CONTAINER_meta_data_insert (m, "<test>",
191 EXTRACTOR_METATYPE_UNKNOWN,
192 EXTRACTOR_METAFORMAT_UTF8,
193 "text/plain", "link",
194 strlen ("link") + 1))
195 ABORT (m);
196 if (GNUNET_OK !=
197 GNUNET_CONTAINER_meta_data_insert (m, "<test>",
198 EXTRACTOR_METATYPE_FILENAME,
199 EXTRACTOR_METAFORMAT_UTF8,
200 "text/plain", "lib-link.m4",
201 strlen ("lib-link.m4") + 1))
202 ABORT (m);
203 val = NULL;
204 size =
205 GNUNET_CONTAINER_meta_data_serialize (m, &val, (size_t) -1,
206 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL);
207 GNUNET_CONTAINER_meta_data_destroy (m);
208 m = GNUNET_CONTAINER_meta_data_deserialize (val, size);
209 GNUNET_free (val);
210 if (m == NULL)
211 ABORT (m);
212 GNUNET_CONTAINER_meta_data_destroy (m);
213 return 0;
214}
215
216
217static int
218check ()
219{
220 struct GNUNET_CONTAINER_MetaData *meta;
221 struct GNUNET_CONTAINER_MetaData *meta2;
222 int q;
223 int i = 100;
224 char txt[128];
225 char *str;
226 unsigned char *thumb;
227
228 meta = GNUNET_CONTAINER_meta_data_create ();
229 meta2 = GNUNET_CONTAINER_meta_data_create ();
230 for (q = 0; q <= i; q++)
231 {
232 GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q);
233 GNUNET_CONTAINER_meta_data_insert (meta, "<test>",
234 EXTRACTOR_METATYPE_UNKNOWN,
235 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
236 "TestTitle", strlen ("TestTitle") + 1);
237 GNUNET_CONTAINER_meta_data_insert (meta2, "<test>",
238 EXTRACTOR_METATYPE_UNKNOWN,
239 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
240 "TestTitle", strlen ("TestTitle") + 1);
241 }
242
243 // check meta_data_test_equal
244 if (GNUNET_YES != GNUNET_CONTAINER_meta_data_test_equal (meta, meta2))
245 {
246 GNUNET_CONTAINER_meta_data_destroy (meta2);
247 ABORT (meta);
248 }
249
250 // check meta_data_clear
251 GNUNET_CONTAINER_meta_data_clear (meta2);
252 if (0 != GNUNET_CONTAINER_meta_data_iterate (meta2, NULL, NULL))
253 {
254 GNUNET_CONTAINER_meta_data_destroy (meta2);
255 ABORT (meta);
256 }
257 // check equal branch in meta_data_test_equal
258 if (GNUNET_YES != GNUNET_CONTAINER_meta_data_test_equal (meta, meta))
259 {
260 GNUNET_CONTAINER_meta_data_destroy (meta2);
261 ABORT (meta);
262 }
263 // check "count" branch in meta_data_test_equal
264 if (GNUNET_NO != GNUNET_CONTAINER_meta_data_test_equal (meta, meta2))
265 {
266 GNUNET_CONTAINER_meta_data_destroy (meta2);
267 ABORT (meta);
268 }
269
270 // check meta_data_add_publication_date
271 GNUNET_CONTAINER_meta_data_add_publication_date (meta2);
272
273 // check meta_data_merge
274 GNUNET_CONTAINER_meta_data_clear (meta2);
275 GNUNET_CONTAINER_meta_data_merge (meta2, meta);
276 if (100 == GNUNET_CONTAINER_meta_data_iterate (meta2, NULL, NULL))
277 {
278 GNUNET_CONTAINER_meta_data_destroy (meta2);
279 ABORT (meta);
280 }
281
282 // check meta_data_get_by_type
283 GNUNET_CONTAINER_meta_data_clear (meta2);
284 if (NULL !=
285 (str =
286 GNUNET_CONTAINER_meta_data_get_by_type (meta2,
287 EXTRACTOR_METATYPE_UNKNOWN)))
288 {
289 GNUNET_CONTAINER_meta_data_destroy (meta2);
290 GNUNET_free (str);
291 ABORT (meta);
292 }
293
294 str =
295 GNUNET_CONTAINER_meta_data_get_by_type (meta, EXTRACTOR_METATYPE_UNKNOWN);
296 GNUNET_assert (NULL != str);
297 if (str[0] != 'T')
298 {
299 GNUNET_CONTAINER_meta_data_destroy (meta2);
300 GNUNET_free (str);
301 ABORT (meta);
302 }
303 GNUNET_free (str);
304
305 // check branch
306 if (NULL !=
307 (str =
308 GNUNET_CONTAINER_meta_data_get_by_type (meta,
309 EXTRACTOR_METATYPE_PUBLICATION_DATE)))
310 {
311 GNUNET_free (str);
312 GNUNET_CONTAINER_meta_data_destroy (meta2);
313 ABORT (meta);
314 }
315
316 // check meta_data_get_first_by_types
317 str =
318 GNUNET_CONTAINER_meta_data_get_first_by_types (meta,
319 EXTRACTOR_METATYPE_UNKNOWN,
320 -1);
321 GNUNET_assert (NULL != str);
322 if (str[0] != 'T')
323 {
324 GNUNET_CONTAINER_meta_data_destroy (meta2);
325 GNUNET_free (str);
326 ABORT (meta);
327 }
328 GNUNET_free (str);
329
330 // check meta_data_get_thumbnail
331 if (GNUNET_CONTAINER_meta_data_get_thumbnail (meta, &thumb) != 0)
332 {
333 GNUNET_free (thumb);
334 GNUNET_CONTAINER_meta_data_destroy (meta2);
335 ABORT (meta);
336 }
337 GNUNET_CONTAINER_meta_data_destroy (meta2);
338 // check meta_data_duplicate
339 meta2 = GNUNET_CONTAINER_meta_data_duplicate (meta);
340 if (200 == GNUNET_CONTAINER_meta_data_iterate (meta2, NULL, NULL))
341 {
342 GNUNET_CONTAINER_meta_data_destroy (meta2);
343 ABORT (meta);
344 }
345 GNUNET_CONTAINER_meta_data_destroy (meta2);
346 GNUNET_CONTAINER_meta_data_destroy (meta);
347 return 0;
348}
349
350
351int
352main (int argc, char *argv[])
353{
354 int failureCount = 0;
355 int i;
356
357 GNUNET_log_setup ("test-container-meta-data", "WARNING", NULL);
358 for (i = 0; i < 255; i++)
359 failureCount += testMeta (i);
360 for (i = 1; i < 255; i++)
361 failureCount += testMetaMore (i);
362 failureCount += testMetaLink ();
363
364 int ret = check ();
365
366 if (ret == 1)
367 return 1;
368
369 if (failureCount != 0)
370 return 1;
371 return 0;
372}
373
374
375/* end of test_container_meta_data.c */
diff --git a/src/util/test_container_multihashmap.c b/src/util/test_container_multihashmap.c
index f46b9f56e..233369257 100644
--- a/src/util/test_container_multihashmap.c
+++ b/src/util/test_container_multihashmap.c
@@ -24,6 +24,7 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26 26
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29 30
diff --git a/src/util/test_container_multihashmap32.c b/src/util/test_container_multihashmap32.c
index 92aac6eeb..eab5ad795 100644
--- a/src/util/test_container_multihashmap32.c
+++ b/src/util/test_container_multihashmap32.c
@@ -25,6 +25,7 @@
25 * @author Sree Harsha Totakura 25 * @author Sree Harsha Totakura
26 */ 26 */
27 27
28
28#include "platform.h" 29#include "platform.h"
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
30 31
diff --git a/src/util/test_container_multipeermap.c b/src/util/test_container_multipeermap.c
index cb6fc30d2..6639b05ea 100644
--- a/src/util/test_container_multipeermap.c
+++ b/src/util/test_container_multipeermap.c
@@ -24,6 +24,7 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26 26
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29 30
diff --git a/src/util/test_crypto_crc.c b/src/util/test_crypto_crc.c
index 4507deadd..d95eaf260 100644
--- a/src/util/test_crypto_crc.c
+++ b/src/util/test_crypto_crc.c
@@ -26,6 +26,7 @@
26 * @file util/test_crypto_crc.c 26 * @file util/test_crypto_crc.c
27 * @brief testcase for crypto_crc.c 27 * @brief testcase for crypto_crc.c
28 */ 28 */
29
29#include "platform.h" 30#include "platform.h"
30#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
31 32
diff --git a/src/util/test_crypto_cs.c b/src/util/test_crypto_cs.c
index a56ff7421..6fd2361fb 100644
--- a/src/util/test_crypto_cs.c
+++ b/src/util/test_crypto_cs.c
@@ -24,6 +24,7 @@
24 * @author Lucien Heuzeveldt <lucienclaude.heuzeveldt@students.bfh.ch> 24 * @author Lucien Heuzeveldt <lucienclaude.heuzeveldt@students.bfh.ch>
25 * @author Gian Demarmels <gian@demarmels.org> 25 * @author Gian Demarmels <gian@demarmels.org>
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29#include <sodium.h> 30#include <sodium.h>
diff --git a/src/util/test_crypto_ecc_dlog.c b/src/util/test_crypto_ecc_dlog.c
index 51f290d51..c3382a4fa 100644
--- a/src/util/test_crypto_ecc_dlog.c
+++ b/src/util/test_crypto_ecc_dlog.c
@@ -23,6 +23,7 @@
23 * @brief testcase for ECC DLOG calculation 23 * @brief testcase for ECC DLOG calculation
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include <gcrypt.h> 29#include <gcrypt.h>
diff --git a/src/util/test_crypto_ecdh_ecdsa.c b/src/util/test_crypto_ecdh_ecdsa.c
index 3cc12de9b..609f05282 100644
--- a/src/util/test_crypto_ecdh_ecdsa.c
+++ b/src/util/test_crypto_ecdh_ecdsa.c
@@ -24,6 +24,7 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * @author Bart Polot 25 * @author Bart Polot
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29#include <gcrypt.h> 30#include <gcrypt.h>
diff --git a/src/util/test_crypto_ecdh_eddsa.c b/src/util/test_crypto_ecdh_eddsa.c
index 6efd4d2fe..875f479c2 100644
--- a/src/util/test_crypto_ecdh_eddsa.c
+++ b/src/util/test_crypto_ecdh_eddsa.c
@@ -24,6 +24,7 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * @author Bart Polot 25 * @author Bart Polot
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29#include <gcrypt.h> 30#include <gcrypt.h>
diff --git a/src/util/test_crypto_ecdhe.c b/src/util/test_crypto_ecdhe.c
index 1144f1fe5..cf59cfa64 100644
--- a/src/util/test_crypto_ecdhe.c
+++ b/src/util/test_crypto_ecdhe.c
@@ -23,6 +23,7 @@
23 * @brief testcase for ECC ECDHE public key crypto 23 * @brief testcase for ECC ECDHE public key crypto
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include <gcrypt.h> 29#include <gcrypt.h>
diff --git a/src/util/test_crypto_ecdsa.c b/src/util/test_crypto_ecdsa.c
index 7908590a8..9dc1f863d 100644
--- a/src/util/test_crypto_ecdsa.c
+++ b/src/util/test_crypto_ecdsa.c
@@ -23,6 +23,7 @@
23 * @brief testcase for ECC ECDSA public key crypto 23 * @brief testcase for ECC ECDSA public key crypto
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include "gnunet_signatures.h" 29#include "gnunet_signatures.h"
diff --git a/src/util/test_crypto_eddsa.c b/src/util/test_crypto_eddsa.c
index e9573a307..820230fd2 100644
--- a/src/util/test_crypto_eddsa.c
+++ b/src/util/test_crypto_eddsa.c
@@ -23,6 +23,7 @@
23 * @brief testcase for ECC public key crypto 23 * @brief testcase for ECC public key crypto
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include "gnunet_signatures.h" 29#include "gnunet_signatures.h"
diff --git a/src/util/test_crypto_edx25519.c b/src/util/test_crypto_edx25519.c
index ead6f0bb9..85e235546 100644
--- a/src/util/test_crypto_edx25519.c
+++ b/src/util/test_crypto_edx25519.c
@@ -23,6 +23,7 @@
23 * @brief testcase for ECC public key crypto for edx25519 23 * @brief testcase for ECC public key crypto for edx25519
24 * @author Özgür Kesim 24 * @author Özgür Kesim
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include "gnunet_signatures.h" 29#include "gnunet_signatures.h"
diff --git a/src/util/test_crypto_hash.c b/src/util/test_crypto_hash.c
index 8241676da..337694a89 100644
--- a/src/util/test_crypto_hash.c
+++ b/src/util/test_crypto_hash.c
@@ -23,6 +23,7 @@
23 * @file util/test_crypto_hash.c 23 * @file util/test_crypto_hash.c
24 * @brief Test for crypto_hash.c 24 * @brief Test for crypto_hash.c
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/test_crypto_hash_context.c b/src/util/test_crypto_hash_context.c
index 8c652595f..08b63800f 100644
--- a/src/util/test_crypto_hash_context.c
+++ b/src/util/test_crypto_hash_context.c
@@ -22,6 +22,7 @@
22 * @brief test case for incremental hashing 22 * @brief test case for incremental hashing
23 * @author Florian Dold 23 * @author Florian Dold
24 */ 24 */
25
25#include "platform.h" 26#include "platform.h"
26#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
27 28
diff --git a/src/util/test_crypto_hkdf.c b/src/util/test_crypto_hkdf.c
index 85be5bb80..a9a4db7a0 100644
--- a/src/util/test_crypto_hkdf.c
+++ b/src/util/test_crypto_hkdf.c
@@ -27,10 +27,11 @@
27 * @author Nils Durner 27 * @author Nils Durner
28 */ 28 */
29 29
30#include "platform.h"
30#include <gcrypt.h> 31#include <gcrypt.h>
31 32
32#include "platform.h" 33
33#include "gnunet_crypto_lib.h" 34#include "gnunet_util_lib.h"
34 35
35void 36void
36tc1 () 37tc1 ()
diff --git a/src/util/test_crypto_kdf.c b/src/util/test_crypto_kdf.c
index 7c33e0ba8..81e4b4451 100644
--- a/src/util/test_crypto_kdf.c
+++ b/src/util/test_crypto_kdf.c
@@ -26,10 +26,11 @@
26 * @author Jeffrey Burdges <burdges@gnunet.org> 26 * @author Jeffrey Burdges <burdges@gnunet.org>
27 */ 27 */
28 28
29#include "platform.h"
29#include <gcrypt.h> 30#include <gcrypt.h>
30 31
31#include "platform.h" 32
32#include "gnunet_crypto_lib.h" 33#include "gnunet_util_lib.h"
33 34
34 35
35int 36int
diff --git a/src/util/test_crypto_paillier.c b/src/util/test_crypto_paillier.c
index 64c9569cb..412ce5c23 100644
--- a/src/util/test_crypto_paillier.c
+++ b/src/util/test_crypto_paillier.c
@@ -24,6 +24,7 @@
24 * @author Christian Fuchs 24 * @author Christian Fuchs
25 * @author Florian Dold 25 * @author Florian Dold
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29#include <gcrypt.h> 30#include <gcrypt.h>
diff --git a/src/util/test_crypto_random.c b/src/util/test_crypto_random.c
index b9cbbdf76..b776aef18 100644
--- a/src/util/test_crypto_random.c
+++ b/src/util/test_crypto_random.c
@@ -23,6 +23,7 @@
23 * @file util/test_crypto_random.c 23 * @file util/test_crypto_random.c
24 * @brief testcase for crypto_random.c 24 * @brief testcase for crypto_random.c
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/test_crypto_rsa.c b/src/util/test_crypto_rsa.c
index 2a676c711..9f2ddb66e 100644
--- a/src/util/test_crypto_rsa.c
+++ b/src/util/test_crypto_rsa.c
@@ -24,6 +24,7 @@
24 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 24 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
25 * @author Jeffrey Burdges <burdges@gnunet.org> 25 * @author Jeffrey Burdges <burdges@gnunet.org>
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
28#include <gcrypt.h> 29#include <gcrypt.h>
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
diff --git a/src/util/test_crypto_symmetric.c b/src/util/test_crypto_symmetric.c
index 5012c7f5b..4c8c2f0c2 100644
--- a/src/util/test_crypto_symmetric.c
+++ b/src/util/test_crypto_symmetric.c
@@ -23,6 +23,7 @@
23 * @file util/test_crypto_symmetric.c 23 * @file util/test_crypto_symmetric.c
24 * @brief test for AES ciphers 24 * @brief test for AES ciphers
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/test_disk.c b/src/util/test_disk.c
index 12bde8107..35b4bd14a 100644
--- a/src/util/test_disk.c
+++ b/src/util/test_disk.c
@@ -23,6 +23,7 @@
23 * @brief testcase for the storage module 23 * @brief testcase for the storage module
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/test_getopt.c b/src/util/test_getopt.c
index 7252530e2..cad10504d 100644
--- a/src/util/test_getopt.c
+++ b/src/util/test_getopt.c
@@ -21,6 +21,7 @@
21 * @file util/test_getopt.c 21 * @file util/test_getopt.c
22 * @brief testcase for util/getopt.c 22 * @brief testcase for util/getopt.c
23 */ 23 */
24
24#include "platform.h" 25#include "platform.h"
25#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
26 27
diff --git a/src/util/test_hexcoder.c b/src/util/test_hexcoder.c
index 923652a00..e04631188 100644
--- a/src/util/test_hexcoder.c
+++ b/src/util/test_hexcoder.c
@@ -24,9 +24,9 @@
24 * @brief test for #GNUNET_DNSPARSER_hex_to_bin() and 24 * @brief test for #GNUNET_DNSPARSER_hex_to_bin() and
25 * #GNUNET_DNSPARSER_bin_to_hex() 25 * #GNUNET_DNSPARSER_bin_to_hex()
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29#include "gnunet_dnsparser_lib.h"
30 30
31#define TESTSTRING "Hello World!" 31#define TESTSTRING "Hello World!"
32 32
diff --git a/src/util/test_mq.c b/src/util/test_mq.c
index dc34f2da4..522589daf 100644
--- a/src/util/test_mq.c
+++ b/src/util/test_mq.c
@@ -24,6 +24,7 @@
24 * @author Florian Dold 24 * @author Florian Dold
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29 30
diff --git a/src/util/test_os_network.c b/src/util/test_os_network.c
index cca29df0f..74e98663b 100644
--- a/src/util/test_os_network.c
+++ b/src/util/test_os_network.c
@@ -21,6 +21,7 @@
21 * @file util/test_os_network.c 21 * @file util/test_os_network.c
22 * @brief testcase for util/os_network.c 22 * @brief testcase for util/os_network.c
23 */ 23 */
24
24#include "platform.h" 25#include "platform.h"
25#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
26 27
diff --git a/src/util/test_os_start_process.c b/src/util/test_os_start_process.c
index 435b70e1a..cdb1acf03 100644
--- a/src/util/test_os_start_process.c
+++ b/src/util/test_os_start_process.c
@@ -25,6 +25,7 @@
25 * giving a file descriptor to write stdout to. If the 25 * giving a file descriptor to write stdout to. If the
26 * correct data "HELLO" is read then all is well. 26 * correct data "HELLO" is read then all is well.
27 */ 27 */
28
28#include "platform.h" 29#include "platform.h"
29#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
30#include "disk.h" 31#include "disk.h"
diff --git a/src/util/test_peer.c b/src/util/test_peer.c
index bb0bc48dc..ad4e6aac9 100644
--- a/src/util/test_peer.c
+++ b/src/util/test_peer.c
@@ -23,6 +23,7 @@
23 * @author Safey Mohammed 23 * @author Safey Mohammed
24 */ 24 */
25 25
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#include <gcrypt.h> 29#include <gcrypt.h>
diff --git a/src/util/test_plugin.c b/src/util/test_plugin.c
index e739d17c9..0831f3068 100644
--- a/src/util/test_plugin.c
+++ b/src/util/test_plugin.c
@@ -21,6 +21,7 @@
21 * @file util/test_plugin.c 21 * @file util/test_plugin.c
22 * @brief testcase for plugin.c 22 * @brief testcase for plugin.c
23 */ 23 */
24
24#include "platform.h" 25#include "platform.h"
25#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
26 27
diff --git a/src/util/test_plugin_plug.c b/src/util/test_plugin_plug.c
index bfaad52e8..ed582517b 100644
--- a/src/util/test_plugin_plug.c
+++ b/src/util/test_plugin_plug.c
@@ -21,6 +21,7 @@
21 * @file util/test_plugin_plug.c 21 * @file util/test_plugin_plug.c
22 * @brief plugin for testing 22 * @brief plugin for testing
23 */ 23 */
24
24#include "platform.h" 25#include "platform.h"
25 26
26 27
diff --git a/src/util/test_program.c b/src/util/test_program.c
index 912a581a5..3d63b0336 100644
--- a/src/util/test_program.c
+++ b/src/util/test_program.c
@@ -21,6 +21,7 @@
21 * @file util/test_program.c 21 * @file util/test_program.c
22 * @brief tests for program.c 22 * @brief tests for program.c
23 */ 23 */
24
24#include "platform.h" 25#include "platform.h"
25#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
26 27
diff --git a/src/util/test_regex.c b/src/util/test_regex.c
index b026ab955..968828755 100644
--- a/src/util/test_regex.c
+++ b/src/util/test_regex.c
@@ -22,6 +22,7 @@
22 * @brief simple test for regex.c iptoregex functions 22 * @brief simple test for regex.c iptoregex functions
23 * @author Maximilian Szengel 23 * @author Maximilian Szengel
24 */ 24 */
25
25#include "platform.h" 26#include "platform.h"
26#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
27 28
diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c
index eefb20890..5ad0c6bf3 100644
--- a/src/util/test_resolver_api.c
+++ b/src/util/test_resolver_api.c
@@ -21,6 +21,7 @@
21 * @file resolver/test_resolver_api.c 21 * @file resolver/test_resolver_api.c
22 * @brief testcase for resolver_api.c 22 * @brief testcase for resolver_api.c
23 */ 23 */
24
24#include "platform.h" 25#include "platform.h"
25#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
26#include "gnunet_resolver_service.h" 27#include "gnunet_resolver_service.h"
diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c
index 0e2e7f760..4573518fd 100644
--- a/src/util/test_scheduler.c
+++ b/src/util/test_scheduler.c
@@ -21,6 +21,7 @@
21 * @file util/test_scheduler.c 21 * @file util/test_scheduler.c
22 * @brief tests for the scheduler 22 * @brief tests for the scheduler
23 */ 23 */
24
24#include "platform.h" 25#include "platform.h"
25#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
26 27
diff --git a/src/util/test_scheduler_delay.c b/src/util/test_scheduler_delay.c
index 003fac196..41990272a 100644
--- a/src/util/test_scheduler_delay.c
+++ b/src/util/test_scheduler_delay.c
@@ -23,6 +23,7 @@
23 * precise the timers are. Expect values between 0.2 and 2 ms on 23 * precise the timers are. Expect values between 0.2 and 2 ms on
24 * modern machines. 24 * modern machines.
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/test_service.c b/src/util/test_service.c
index 61afc0cc5..198ae68ec 100644
--- a/src/util/test_service.c
+++ b/src/util/test_service.c
@@ -22,6 +22,7 @@
22 * @brief tests for service.c 22 * @brief tests for service.c
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25
25#include "platform.h" 26#include "platform.h"
26#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
27 28
diff --git a/src/util/test_socks.c b/src/util/test_socks.c
index c5a703db4..680ecada5 100644
--- a/src/util/test_socks.c
+++ b/src/util/test_socks.c
@@ -21,6 +21,7 @@
21 * @file util/test_socks.c 21 * @file util/test_socks.c
22 * @brief tests for socks.c 22 * @brief tests for socks.c
23 */ 23 */
24
24#include "platform.h" 25#include "platform.h"
25#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
26 27
diff --git a/src/util/test_speedup.c b/src/util/test_speedup.c
index bca6886aa..58d78641b 100644
--- a/src/util/test_speedup.c
+++ b/src/util/test_speedup.c
@@ -21,6 +21,7 @@
21 * @file util/test_speedup.c 21 * @file util/test_speedup.c
22 * @brief testcase for speedup.c 22 * @brief testcase for speedup.c
23 */ 23 */
24
24#include "platform.h" 25#include "platform.h"
25#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
26 27
diff --git a/src/util/test_strings.c b/src/util/test_strings.c
index cccffcaf5..0e39b9958 100644
--- a/src/util/test_strings.c
+++ b/src/util/test_strings.c
@@ -21,6 +21,7 @@
21 * @file util/test_strings.c 21 * @file util/test_strings.c
22 * @brief testcase for strings.c 22 * @brief testcase for strings.c
23 */ 23 */
24
24#include "platform.h" 25#include "platform.h"
25#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
26 27
diff --git a/src/util/test_strings_to_data.c b/src/util/test_strings_to_data.c
index 71861b128..75cbd135d 100644
--- a/src/util/test_strings_to_data.c
+++ b/src/util/test_strings_to_data.c
@@ -21,6 +21,7 @@
21 * @file util/test_strings_to_data.c 21 * @file util/test_strings_to_data.c
22 * @brief testcase for strings.c 22 * @brief testcase for strings.c
23 */ 23 */
24
24#include "platform.h" 25#include "platform.h"
25#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
26 27
diff --git a/src/util/test_time.c b/src/util/test_time.c
index 59917793c..35f270a44 100644
--- a/src/util/test_time.c
+++ b/src/util/test_time.c
@@ -21,6 +21,7 @@
21 * @file util/test_time.c 21 * @file util/test_time.c
22 * @brief testcase for time.c 22 * @brief testcase for time.c
23 */ 23 */
24
24#include "platform.h" 25#include "platform.h"
25#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
26 27
diff --git a/src/util/test_tun.c b/src/util/test_tun.c
index ad4a5c19e..1086ef3ca 100644
--- a/src/util/test_tun.c
+++ b/src/util/test_tun.c
@@ -23,6 +23,7 @@
23 * @brief test for tun.c 23 * @brief test for tun.c
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28 29
diff --git a/src/util/test_uri.c b/src/util/test_uri.c
index 7c8156648..d8fa38e96 100644
--- a/src/util/test_uri.c
+++ b/src/util/test_uri.c
@@ -1,3 +1,4 @@
1#include "platform.h"
1#include <stdlib.h> 2#include <stdlib.h>
2#include <stdio.h> 3#include <stdio.h>
3#include <string.h> 4#include <string.h>
diff --git a/src/util/time.c b/src/util/time.c
index cf072aebf..84957c6a8 100644
--- a/src/util/time.c
+++ b/src/util/time.c
@@ -23,6 +23,7 @@
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 * @brief functions for handling time and time arithmetic 24 * @brief functions for handling time and time arithmetic
25 */ 25 */
26
26#include "platform.h" 27#include "platform.h"
27#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
28#if __STDC_NO_ATOMICS__ 29#if __STDC_NO_ATOMICS__
diff --git a/src/util/tun.c b/src/util/tun.c
index e22cf0be8..c4ac6ff88 100644
--- a/src/util/tun.c
+++ b/src/util/tun.c
@@ -24,6 +24,7 @@
24 * @author Philipp Toelke 24 * @author Philipp Toelke
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 */ 26 */
27
27#include "platform.h" 28#include "platform.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29 30
diff --git a/src/util/uri.c b/src/util/uri.c
index fa383110d..b09968581 100644
--- a/src/util/uri.c
+++ b/src/util/uri.c
@@ -19,6 +19,7 @@
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE. 20 * SOFTWARE.
21 */ 21 */
22#include "platform.h"
22#include <stdlib.h> 23#include <stdlib.h>
23#include <stdio.h> 24#include <stdio.h>
24#include <string.h> 25#include <string.h>
diff --git a/src/vpn/gnunet-helper-vpn.c b/src/vpn/gnunet-helper-vpn.c
index 7686d51d5..30901da45 100644
--- a/src/vpn/gnunet-helper-vpn.c
+++ b/src/vpn/gnunet-helper-vpn.c
@@ -40,7 +40,7 @@
40/** 40/**
41 * Need 'struct GNUNET_MessageHeader'. 41 * Need 'struct GNUNET_MessageHeader'.
42 */ 42 */
43#include "gnunet_crypto_lib.h" 43#include "gnunet_util_lib.h"
44#include "gnunet_common.h" 44#include "gnunet_common.h"
45 45
46/** 46/**
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c
index a2a16e380..aa3f6ffe3 100644
--- a/src/vpn/gnunet-service-vpn.c
+++ b/src/vpn/gnunet-service-vpn.c
@@ -38,7 +38,6 @@
38#include "gnunet_cadet_service.h" 38#include "gnunet_cadet_service.h"
39#include "gnunet_statistics_service.h" 39#include "gnunet_statistics_service.h"
40#include "gnunet_constants.h" 40#include "gnunet_constants.h"
41#include "gnunet_tun_lib.h"
42#include "gnunet_regex_service.h" 41#include "gnunet_regex_service.h"
43#include "vpn.h" 42#include "vpn.h"
44#include "exit.h" 43#include "exit.h"
diff --git a/src/vpn/gnunet-vpn.c b/src/vpn/gnunet-vpn.c
index 60d631d5e..a67e17016 100644
--- a/src/vpn/gnunet-vpn.c
+++ b/src/vpn/gnunet-vpn.c
@@ -26,7 +26,6 @@
26 26
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
29#include "gnunet_tun_lib.h"
30#include "gnunet_vpn_service.h" 29#include "gnunet_vpn_service.h"
31 30
32 31
diff --git a/src/zonemaster/gnunet-service-zonemaster.c b/src/zonemaster/gnunet-service-zonemaster.c
index 8e5d157fd..1893ccc03 100644
--- a/src/zonemaster/gnunet-service-zonemaster.c
+++ b/src/zonemaster/gnunet-service-zonemaster.c
@@ -26,7 +26,6 @@
26#include "platform.h" 26#include "platform.h"
27#include <pthread.h> 27#include <pthread.h>
28#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
29#include "gnunet_dnsparser_lib.h"
30#include "gnunet_dht_service.h" 29#include "gnunet_dht_service.h"
31#include "gnunet_namestore_service.h" 30#include "gnunet_namestore_service.h"
32#include "gnunet_namecache_service.h" 31#include "gnunet_namecache_service.h"
@@ -117,11 +116,6 @@ static pthread_cond_t sign_jobs_cond;
117static int in_shutdown = GNUNET_NO; 116static int in_shutdown = GNUNET_NO;
118 117
119/** 118/**
120 * Iterator halted?
121 */
122static int iterator_halted = GNUNET_NO;
123
124/**
125 * Monitor halted? 119 * Monitor halted?
126 */ 120 */
127static int monitor_halted = GNUNET_NO; 121static int monitor_halted = GNUNET_NO;
@@ -451,7 +445,7 @@ shutdown_task (void *cls)
451 GNUNET_DHT_put_cancel (job->ph); 445 GNUNET_DHT_put_cancel (job->ph);
452 free_job (job); 446 free_job (job);
453 } 447 }
454if (NULL != statistics) 448 if (NULL != statistics)
455 { 449 {
456 GNUNET_STATISTICS_destroy (statistics, 450 GNUNET_STATISTICS_destroy (statistics,
457 GNUNET_NO); 451 GNUNET_NO);
@@ -740,6 +734,14 @@ check_zone_namestore_next ()
740 734
741 if (0 != ns_iteration_left) 735 if (0 != ns_iteration_left)
742 return; /* current NAMESTORE iteration not yet done */ 736 return; /* current NAMESTORE iteration not yet done */
737 if (job_queue_length >= JOB_QUEUE_LIMIT)
738 {
739 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
740 "Job queue length exceeded (%u/%u). Pausing namestore iteration.\n",
741 job_queue_length,
742 JOB_QUEUE_LIMIT);
743 return;
744 }
743 update_velocity (put_cnt); 745 update_velocity (put_cnt);
744 put_cnt = 0; 746 put_cnt = 0;
745 delay = GNUNET_TIME_relative_subtract (target_iteration_velocity_per_record, 747 delay = GNUNET_TIME_relative_subtract (target_iteration_velocity_per_record,
@@ -775,17 +777,14 @@ dht_put_continuation (void *cls)
775 struct RecordPublicationJob *job = cls; 777 struct RecordPublicationJob *job = cls;
776 778
777 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 779 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
778 "PUT complete\n"); 780 "PUT complete; Pending jobs: %u\n", job_queue_length - 1);
779 /* When we just fall under the limit, trigger monitor/iterator again 781 /* When we just fall under the limit, trigger monitor/iterator again
780 * if halted. We can only safely trigger one, prefer iterator. */ 782 * if halted. We can only safely trigger one, prefer iterator. */
783 if (NULL == zone_publish_task)
784 check_zone_namestore_next ();
781 if (job_queue_length <= JOB_QUEUE_LIMIT) 785 if (job_queue_length <= JOB_QUEUE_LIMIT)
782 { 786 {
783 if (GNUNET_YES == iterator_halted) 787 if (GNUNET_YES == monitor_halted)
784 {
785 GNUNET_NAMESTORE_zone_iterator_next (namestore_iter, 1);
786 iterator_halted = GNUNET_NO;
787 }
788 else if (GNUNET_YES == monitor_halted)
789 { 788 {
790 GNUNET_NAMESTORE_zone_monitor_next (zmon, 1); 789 GNUNET_NAMESTORE_zone_monitor_next (zmon, 1);
791 monitor_halted = GNUNET_NO; 790 monitor_halted = GNUNET_NO;
@@ -1077,14 +1076,6 @@ handle_record (void *cls,
1077 rd_count, 1076 rd_count,
1078 expire); 1077 expire);
1079 job_queue_length++; 1078 job_queue_length++;
1080 if (job_queue_length >= JOB_QUEUE_LIMIT)
1081 {
1082 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1083 "Job queue length exceeded (%u). Halting namestore iteration.\n",
1084 JOB_QUEUE_LIMIT);
1085 iterator_halted = GNUNET_YES;
1086 return;
1087 }
1088 check_zone_namestore_next (); 1079 check_zone_namestore_next ();
1089} 1080}
1090 1081
@@ -1240,7 +1231,8 @@ handle_monitor_event (void *cls,
1240 if (job_queue_length >= JOB_QUEUE_LIMIT) 1231 if (job_queue_length >= JOB_QUEUE_LIMIT)
1241 { 1232 {
1242 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1233 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1243 "Job queue length exceeded (%u). Halting monitor.\n", 1234 "Job queue length exceeded (%u/%u). Halting monitor.\n",
1235 job_queue_length,
1244 JOB_QUEUE_LIMIT); 1236 JOB_QUEUE_LIMIT);
1245 monitor_halted = GNUNET_YES; 1237 monitor_halted = GNUNET_YES;
1246 return; 1238 return;