summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am10
-rw-r--r--src/abd/Makefile.am4
-rw-r--r--src/abd/abd.h61
-rw-r--r--src/abd/abd_api.c8
-rw-r--r--src/abd/abd_serialization.c12
-rw-r--r--src/abd/delegate_misc.c34
-rw-r--r--src/abd/gnunet-abd.c58
-rw-r--r--src/abd/gnunet-service-abd.c58
-rw-r--r--src/abd/plugin_gnsrecord_abd.c7
-rwxr-xr-xsrc/abd/test_abd_bi_and.sh8
-rw-r--r--src/arm/arm_api.c1
-rw-r--r--src/ats/Makefile.am2
-rw-r--r--src/cadet/Makefile.am4
-rw-r--r--src/consensus/Makefile.am2
-rw-r--r--src/core/Makefile.am6
-rw-r--r--src/curl/curl.c118
-rw-r--r--src/datacache/Makefile.am2
-rw-r--r--src/datastore/Makefile.am6
-rw-r--r--src/dht/Makefile.am6
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c56
-rw-r--r--src/dhtu/Makefile.am50
-rw-r--r--src/dhtu/plugin_dhtu_gnunet.c571
-rw-r--r--src/dhtu/plugin_dhtu_ip.c4
-rw-r--r--src/dhtu/test_dhtu_ip.c (renamed from src/testing/test_testing_hello_world.c)50
-rw-r--r--src/dhtu/testing_dhtu_cmd_send.c119
-rw-r--r--src/fs/Makefile.am6
-rw-r--r--src/gns/Makefile.am4
-rw-r--r--src/gns/gnunet-bcd.c884
-rw-r--r--src/identity/Makefile.am2
-rw-r--r--src/identity/identity_api.c6
-rw-r--r--src/include/Makefile.am1
-rw-r--r--src/include/gnu_name_system_record_types.h10
-rw-r--r--src/include/gnunet_abd_service.h28
-rw-r--r--src/include/gnunet_common.h8
-rw-r--r--src/include/gnunet_crypto_lib.h29
-rw-r--r--src/include/gnunet_dht_service.h17
-rw-r--r--src/include/gnunet_dhtu_plugin.h54
-rw-r--r--src/include/gnunet_hello_lib.h7
-rw-r--r--src/include/gnunet_json_lib.h4
-rw-r--r--src/include/gnunet_messenger_service.h68
-rw-r--r--src/include/gnunet_mq_lib.h39
-rw-r--r--src/include/gnunet_network_lib.h16
-rw-r--r--src/include/gnunet_os_lib.h4
-rw-r--r--src/include/gnunet_pq_lib.h143
-rw-r--r--src/include/gnunet_protocols.h11
-rw-r--r--src/include/gnunet_testbed_service.h18
-rw-r--r--src/include/gnunet_testing_netjail_lib.h492
-rw-r--r--src/include/gnunet_testing_ng_lib.h1013
-rw-r--r--src/include/gnunet_testing_plugin.h12
-rw-r--r--src/include/gnunet_transport_service.h25
-rw-r--r--src/json/json.c2
-rw-r--r--src/json/json_helper.c5
-rw-r--r--src/messenger/Makefile.am13
-rw-r--r--src/messenger/gnunet-messenger.c21
-rw-r--r--src/messenger/gnunet-service-messenger.c63
-rw-r--r--src/messenger/gnunet-service-messenger_basement.c8
-rw-r--r--src/messenger/gnunet-service-messenger_basement.h8
-rw-r--r--src/messenger/gnunet-service-messenger_ego_store.c37
-rw-r--r--src/messenger/gnunet-service-messenger_ego_store.h21
-rw-r--r--src/messenger/gnunet-service-messenger_handle.c99
-rw-r--r--src/messenger/gnunet-service-messenger_handle.h42
-rw-r--r--src/messenger/gnunet-service-messenger_list_handles.c9
-rw-r--r--src/messenger/gnunet-service-messenger_list_handles.h9
-rw-r--r--src/messenger/gnunet-service-messenger_list_messages.c15
-rw-r--r--src/messenger/gnunet-service-messenger_list_messages.h15
-rw-r--r--src/messenger/gnunet-service-messenger_member.c65
-rw-r--r--src/messenger/gnunet-service-messenger_member.h28
-rw-r--r--src/messenger/gnunet-service-messenger_member_session.c32
-rw-r--r--src/messenger/gnunet-service-messenger_member_session.h12
-rw-r--r--src/messenger/gnunet-service-messenger_member_store.c44
-rw-r--r--src/messenger/gnunet-service-messenger_member_store.h21
-rw-r--r--src/messenger/gnunet-service-messenger_message_handle.c51
-rw-r--r--src/messenger/gnunet-service-messenger_message_handle.h48
-rw-r--r--src/messenger/gnunet-service-messenger_message_kind.c6
-rw-r--r--src/messenger/gnunet-service-messenger_message_kind.h6
-rw-r--r--src/messenger/gnunet-service-messenger_message_recv.c32
-rw-r--r--src/messenger/gnunet-service-messenger_message_recv.h18
-rw-r--r--src/messenger/gnunet-service-messenger_message_send.c24
-rw-r--r--src/messenger/gnunet-service-messenger_message_send.h24
-rw-r--r--src/messenger/gnunet-service-messenger_message_state.c12
-rw-r--r--src/messenger/gnunet-service-messenger_message_state.h12
-rw-r--r--src/messenger/gnunet-service-messenger_message_store.c123
-rw-r--r--src/messenger/gnunet-service-messenger_message_store.h21
-rw-r--r--src/messenger/gnunet-service-messenger_operation.c10
-rw-r--r--src/messenger/gnunet-service-messenger_operation.h6
-rw-r--r--src/messenger/gnunet-service-messenger_operation_store.c54
-rw-r--r--src/messenger/gnunet-service-messenger_operation_store.h3
-rw-r--r--src/messenger/gnunet-service-messenger_room.c165
-rw-r--r--src/messenger/gnunet-service-messenger_room.h55
-rw-r--r--src/messenger/gnunet-service-messenger_service.c39
-rw-r--r--src/messenger/gnunet-service-messenger_service.h33
-rw-r--r--src/messenger/gnunet-service-messenger_tunnel.c59
-rw-r--r--src/messenger/gnunet-service-messenger_tunnel.h22
-rw-r--r--src/messenger/messenger.conf.in1
-rw-r--r--src/messenger/messenger_api.c101
-rw-r--r--src/messenger/messenger_api_contact.c6
-rw-r--r--src/messenger/messenger_api_contact.h6
-rw-r--r--src/messenger/messenger_api_contact_store.c22
-rw-r--r--src/messenger/messenger_api_contact_store.h15
-rw-r--r--src/messenger/messenger_api_handle.c31
-rw-r--r--src/messenger/messenger_api_handle.h25
-rw-r--r--src/messenger/messenger_api_list_tunnels.c22
-rw-r--r--src/messenger/messenger_api_list_tunnels.h19
-rw-r--r--src/messenger/messenger_api_message.c139
-rw-r--r--src/messenger/messenger_api_message.h58
-rw-r--r--src/messenger/messenger_api_room.c75
-rw-r--r--src/messenger/messenger_api_room.h21
-rw-r--r--src/messenger/messenger_api_util.c6
-rw-r--r--src/messenger/messenger_api_util.h6
-rw-r--r--src/messenger/plugin_gnsrecord_messenger.c243
-rw-r--r--src/messenger/test_messenger.c10
-rw-r--r--src/messenger/test_messenger_adapt.c3
-rw-r--r--src/messenger/test_messenger_anonymous.c10
-rw-r--r--src/messenger/test_messenger_async_client.c3
-rw-r--r--src/messenger/test_messenger_async_p2p.c3
-rw-r--r--src/messenger/test_messenger_growth.c3
-rw-r--r--src/messenger/test_messenger_ring.c3
-rw-r--r--src/messenger/test_messenger_server.c3
-rw-r--r--src/messenger/test_messenger_sync_client.c3
-rw-r--r--src/messenger/test_messenger_sync_p2p.c3
-rw-r--r--src/messenger/test_messenger_worst_client.c3
-rw-r--r--src/messenger/test_messenger_worst_p2p.c3
-rw-r--r--src/messenger/testing_messenger_barrier.c6
-rw-r--r--src/messenger/testing_messenger_setup.c41
-rw-r--r--src/messenger/testing_messenger_setup.h3
-rw-r--r--src/namecache/Makefile.am8
-rw-r--r--src/namestore/Makefile.am6
-rw-r--r--src/namestore/gnunet-namestore-fcfsd.c11
-rw-r--r--src/namestore/gnunet-namestore.c6
-rw-r--r--src/nat/nat_api.c43
-rw-r--r--src/nse/Makefile.am4
-rw-r--r--src/nse/gnunet-service-nse.c2
-rw-r--r--src/peerinfo/Makefile.am2
-rw-r--r--src/peerstore/Makefile.am2
-rw-r--r--src/pq/pq.c8
-rw-r--r--src/pq/pq.h5
-rw-r--r--src/pq/pq_connect.c158
-rw-r--r--src/pq/pq_event.c40
-rw-r--r--src/pq/pq_exec.c7
-rw-r--r--src/pq/pq_prepare.c16
-rw-r--r--src/pq/pq_query_helper.c47
-rw-r--r--src/pq/pq_result_helper.c182
-rw-r--r--src/pt/Makefile.am4
-rw-r--r--src/reclaim/gnunet-reclaim.c5
-rw-r--r--src/regex/Makefile.am2
-rw-r--r--src/rps/Makefile.am4
-rw-r--r--src/secretsharing/Makefile.am2
-rw-r--r--src/set/Makefile.am4
-rw-r--r--src/seti/Makefile.am4
-rw-r--r--src/setu/Makefile.am4
-rw-r--r--src/statistics/statistics_api.c6
-rw-r--r--src/testbed/gnunet-testbed-profiler.c4
-rw-r--r--src/testbed/gnunet_testbed_mpi_spawn.c327
-rw-r--r--src/testbed/testbed_api_hosts.c35
-rw-r--r--src/testbed/testbed_api_testbed.c11
-rw-r--r--src/testing/Makefile.am52
-rw-r--r--src/testing/gnunet-cmds-helper.c80
-rwxr-xr-xsrc/testing/netjail_core.sh190
-rwxr-xr-xsrc/testing/netjail_core_v2.sh260
-rwxr-xr-xsrc/testing/netjail_exec.sh6
-rwxr-xr-xsrc/testing/netjail_exec_v2.sh14
-rwxr-xr-xsrc/testing/netjail_start.sh70
-rwxr-xr-xsrc/testing/netjail_start_v2.sh61
-rwxr-xr-xsrc/testing/netjail_stop.sh49
-rwxr-xr-xsrc/testing/netjail_stop_v2.sh59
-rw-r--r--src/testing/test_testing_api_cmd_netjail.c87
-rw-r--r--src/testing/test_testing_plugin_testcmd.c116
-rw-r--r--src/testing/testing.c669
-rw-r--r--src/testing/testing.h94
-rw-r--r--src/testing/testing_api_cmd_batch.c86
-rw-r--r--src/testing/testing_api_cmd_block_until_all_peers_started.c139
-rw-r--r--src/testing/testing_api_cmd_block_until_external_trigger.c114
-rw-r--r--src/testing/testing_api_cmd_end.c39
-rw-r--r--src/testing/testing_api_cmd_finish.c200
-rw-r--r--src/testing/testing_api_cmd_hello_world.c121
-rw-r--r--src/testing/testing_api_cmd_hello_world_birth.c159
-rw-r--r--src/testing/testing_api_cmd_local_test_finished.c69
-rw-r--r--src/testing/testing_api_cmd_local_test_prepared.c123
-rw-r--r--src/testing/testing_api_cmd_netjail_start.c181
-rw-r--r--src/testing/testing_api_cmd_netjail_start_testsystem.c656
-rw-r--r--src/testing/testing_api_cmd_netjail_start_testsystem_v2.c718
-rw-r--r--src/testing/testing_api_cmd_netjail_start_v2.c229
-rw-r--r--src/testing/testing_api_cmd_netjail_stop.c174
-rw-r--r--src/testing/testing_api_cmd_netjail_stop_testsystem.c91
-rw-r--r--src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c143
-rw-r--r--src/testing/testing_api_cmd_netjail_stop_v2.c225
-rw-r--r--src/testing/testing_api_cmd_send_peer_ready.c31
-rw-r--r--src/testing/testing_api_cmd_system_create.c29
-rw-r--r--src/testing/testing_api_cmd_system_destroy.c36
-rw-r--r--src/testing/testing_api_loop.c699
-rw-r--r--src/testing/testing_api_trait_cmd.c79
-rw-r--r--src/testing/testing_api_trait_process.c81
-rw-r--r--src/testing/testing_api_traits.c9
-rw-r--r--src/testing/testing_cmds.h19
-rwxr-xr-xsrc/testing/topo.sh8
-rw-r--r--src/topology/Makefile.am2
-rw-r--r--src/transport/Makefile.am82
-rw-r--r--src/transport/gnunet-communicator-tcp.c136
-rw-r--r--src/transport/gnunet-communicator-udp.c149
-rw-r--r--src/transport/gnunet-service-tng.c358
-rw-r--r--src/transport/tcp_service_legacy.c14
-rw-r--r--src/transport/test_transport_api2_tcp_node1.conf10
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send.c274
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send_broadcast.c398
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send_dv.c375
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send_v2.c234
-rw-r--r--src/transport/test_transport_plugin_cmd_udp_backchannel.c356
-rw-r--r--src/transport/test_transport_plugin_cmd_udp_backchannel_recv.c262
-rw-r--r--src/transport/test_transport_plugin_cmd_udp_backchannel_send.c262
-rw-r--r--src/transport/test_transport_port_forward.c85
-rw-r--r--src/transport/test_transport_simple_send.c86
-rwxr-xr-xsrc/transport/test_transport_simple_send.sh10
-rwxr-xr-xsrc/transport/test_transport_simple_send_broadcast.sh11
-rw-r--r--src/transport/test_transport_simple_send_broadcast_topo.conf4
-rwxr-xr-xsrc/transport/test_transport_simple_send_dv.sh11
-rwxr-xr-xsrc/transport/test_transport_simple_send_string.sh19
-rw-r--r--src/transport/test_transport_simple_send_topo.conf6
-rw-r--r--src/transport/test_transport_simple_send_v2.c83
-rwxr-xr-xsrc/transport/test_transport_simple_send_v2.sh2
-rw-r--r--src/transport/test_transport_start_with_config.c121
-rwxr-xr-xsrc/transport/test_transport_udp_backchannel.sh12
-rw-r--r--src/transport/test_transport_udp_backchannel_topo.conf7
-rw-r--r--src/transport/transport-testing-cmds.h312
-rw-r--r--src/transport/transport_api2_communication.c9
-rw-r--r--src/transport/transport_api2_core.c5
-rw-r--r--src/transport/transport_api_cmd_backchannel_check.c602
-rw-r--r--src/transport/transport_api_cmd_connecting_peers.c294
-rw-r--r--src/transport/transport_api_cmd_connecting_peers_v2.c242
-rw-r--r--src/transport/transport_api_cmd_send_simple.c164
-rw-r--r--src/transport/transport_api_cmd_send_simple_v2.c156
-rw-r--r--src/transport/transport_api_cmd_start_peer.c300
-rw-r--r--src/transport/transport_api_cmd_start_peer_v2.c607
-rw-r--r--src/transport/transport_api_cmd_stop_peer.c37
-rw-r--r--src/transport/transport_api_traits.c32
-rw-r--r--src/util/Makefile.am9
-rw-r--r--src/util/child_management.c66
-rw-r--r--src/util/common_allocation.c40
-rw-r--r--src/util/configuration.c15
-rw-r--r--src/util/container_bloomfilter.c26
-rw-r--r--src/util/crypto_hkdf.c23
-rw-r--r--src/util/crypto_rsa.c47
-rw-r--r--src/util/gnunet-qr.c597
-rw-r--r--src/util/helper.c4
-rw-r--r--src/util/mq.c6
-rw-r--r--src/util/network.c61
-rw-r--r--src/util/os_installation.c20
-rw-r--r--src/util/perf_malloc.c2
-rw-r--r--src/util/program.c63
-rw-r--r--src/util/scheduler.c3
-rw-r--r--src/util/service.c8
250 files changed, 10945 insertions, 9844 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index ef8c5b110..4c665c3b3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,14 +1,12 @@
# This Makefile.am is in the public domain
-if HAVE_TESTING
- TESTING = testing
- TESTBED = testbed-logger testbed
-endif
+TESTING = testing
+TESTBED = testbed-logger testbed
if HAVE_EXPERIMENTAL
EXP_DIR = \
- rps
- #abd FTBFS
+ rps \
+ abd
if HAVE_ABE
EXP_DIR += \
abe
diff --git a/src/abd/Makefile.am b/src/abd/Makefile.am
index 34a0438f5..304469e22 100644
--- a/src/abd/Makefile.am
+++ b/src/abd/Makefile.am
@@ -75,7 +75,9 @@ libgnunetabd_la_SOURCES = \
delegate_misc.c \
delegate_misc.h
libgnunetabd_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIB)
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/identity/libgnunetidentity.la \
+ $(XLIB)
libgnunetabd_la_LDFLAGS = \
$(GN_LIB_LDFLAGS)
diff --git a/src/abd/abd.h b/src/abd/abd.h
index 0af0d43ca..61210b3f7 100644
--- a/src/abd/abd.h
+++ b/src/abd/abd.h
@@ -42,12 +42,12 @@ struct CollectMessage
/**
* Subject public key
*/
- struct GNUNET_CRYPTO_EcdsaPrivateKey subject_key;
+ struct GNUNET_IDENTITY_PrivateKey subject_key;
/**
* Trust anchor
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
+ struct GNUNET_IDENTITY_PublicKey issuer_key;
/**
* Length of the issuer attribute
@@ -81,12 +81,12 @@ struct VerifyMessage
/**
* Subject public key
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
+ struct GNUNET_IDENTITY_PublicKey subject_key;
/**
* Trust anchor
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
+ struct GNUNET_IDENTITY_PublicKey issuer_key;
/**
* Number of delegates
@@ -170,7 +170,7 @@ struct DelegationRecordData
/**
* Subject key
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
+ struct GNUNET_IDENTITY_PublicKey subject_key;
/**
* Subject attributes
@@ -184,12 +184,12 @@ struct ChainEntry
/**
* Issuer key
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
+ struct GNUNET_IDENTITY_PublicKey issuer_key;
/**
* Subject key
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
+ struct GNUNET_IDENTITY_PublicKey subject_key;
/**
* Issuer attributes
@@ -203,46 +203,12 @@ struct ChainEntry
};
-struct CredentialEntry
+struct DelegateEntry
{
-
/**
* The signature for this credential by the issuer
*/
- struct GNUNET_CRYPTO_EcdsaSignature signature;
-
- /**
- * Signature meta
- */
- struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
-
- /**
- * Public key of the issuer
- */
- struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
-
- /**
- * Public key of the subject this credential was issued to
- */
- struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
-
- /**
- * Expiration time of this credential
- */
- uint64_t expiration GNUNET_PACKED;
-
- /**
- * Issuer attribute length
- */
- uint32_t issuer_attribute_len;
-
- /**
- * Followed by the attribute string
- */
-};
-
-struct DelegateEntry
-{
+ struct GNUNET_IDENTITY_Signature signature;
/**
* Signature meta
@@ -250,19 +216,14 @@ struct DelegateEntry
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
/**
- * The signature for this credential by the issuer
- */
- struct GNUNET_CRYPTO_EcdsaSignature signature;
-
- /**
* Public key of the issuer
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
+ struct GNUNET_IDENTITY_PublicKey issuer_key;
/**
* Public key of the subject this credential was issued to
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
+ struct GNUNET_IDENTITY_PublicKey subject_key;
/**
* Expiration time of this credential
diff --git a/src/abd/abd_api.c b/src/abd/abd_api.c
index cc25d06da..57f831e85 100644
--- a/src/abd/abd_api.c
+++ b/src/abd/abd_api.c
@@ -423,9 +423,9 @@ GNUNET_ABD_request_cancel (struct GNUNET_ABD_Request *lr)
struct GNUNET_ABD_Request *
GNUNET_ABD_collect (
struct GNUNET_ABD_Handle *handle,
- const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key,
+ const struct GNUNET_IDENTITY_PublicKey *issuer_key,
const char *issuer_attribute,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *subject_key,
+ const struct GNUNET_IDENTITY_PrivateKey *subject_key,
enum GNUNET_ABD_AlgoDirectionFlags direction,
GNUNET_ABD_CredentialResultProcessor proc,
void *proc_cls,
@@ -497,9 +497,9 @@ GNUNET_ABD_collect (
struct GNUNET_ABD_Request *
GNUNET_ABD_verify (
struct GNUNET_ABD_Handle *handle,
- const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key,
+ const struct GNUNET_IDENTITY_PublicKey *issuer_key,
const char *issuer_attribute,
- const struct GNUNET_CRYPTO_EcdsaPublicKey *subject_key,
+ const struct GNUNET_IDENTITY_PublicKey *subject_key,
uint32_t delegate_count,
const struct GNUNET_ABD_Delegate *delegates,
enum GNUNET_ABD_AlgoDirectionFlags direction,
diff --git a/src/abd/abd_serialization.c b/src/abd/abd_serialization.c
index c03fab7dc..4c219d791 100644
--- a/src/abd/abd_serialization.c
+++ b/src/abd/abd_serialization.c
@@ -199,7 +199,7 @@ GNUNET_ABD_delegates_serialize (
c_rec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DELEGATE);
c_rec.purpose.size =
htonl ((sizeof (struct DelegateEntry) + cd[i].issuer_attribute_len)
- - sizeof (struct GNUNET_CRYPTO_EcdsaSignature));
+ - sizeof (struct GNUNET_IDENTITY_Signature));
c_rec.expiration = GNUNET_htonll (cd[i].expiration.abs_value_us);
if (off + sizeof (c_rec) > dest_size)
return -1;
@@ -445,13 +445,13 @@ GNUNET_ABD_delegate_serialize (struct GNUNET_ABD_Delegate *dele,
}
cdata->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DELEGATE);
cdata->purpose.size =
- htonl (size - sizeof (struct GNUNET_CRYPTO_EcdsaSignature));
+ htonl (size - sizeof (struct GNUNET_IDENTITY_Signature));
GNUNET_memcpy (&cdata[1], tmp_str, attr_len);
if (GNUNET_OK !=
- GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_DELEGATE,
- cdata,
+ GNUNET_IDENTITY_signature_verify_ (GNUNET_SIGNATURE_PURPOSE_DELEGATE,
+ &cdata->purpose,
&cdata->signature,
&cdata->issuer_key))
{
@@ -473,8 +473,8 @@ GNUNET_ABD_delegate_deserialize (const char *data, size_t data_size)
return NULL;
cdata = (struct DelegateEntry *) data;
if (GNUNET_OK !=
- GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_DELEGATE,
- cdata,
+ GNUNET_IDENTITY_signature_verify_ (GNUNET_SIGNATURE_PURPOSE_DELEGATE,
+ &cdata->purpose,
&cdata->signature,
&cdata->issuer_key))
{
diff --git a/src/abd/delegate_misc.c b/src/abd/delegate_misc.c
index 4740a3e30..d67b40088 100644
--- a/src/abd/delegate_misc.c
+++ b/src/abd/delegate_misc.c
@@ -42,10 +42,10 @@ GNUNET_ABD_delegate_to_string (
char *issuer_pkey;
char *signature;
- subject_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred->subject_key);
- issuer_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred->issuer_key);
+ subject_pkey = GNUNET_IDENTITY_public_key_to_string (&cred->subject_key);
+ issuer_pkey = GNUNET_IDENTITY_public_key_to_string (&cred->issuer_key);
GNUNET_STRINGS_base64_encode ((char *) &cred->signature,
- sizeof (struct GNUNET_CRYPTO_EcdsaSignature),
+ sizeof (struct GNUNET_IDENTITY_Signature),
&signature);
if (0 == cred->subject_attribute_len)
{
@@ -80,7 +80,7 @@ struct GNUNET_ABD_Delegate *
GNUNET_ABD_delegate_from_string (const char *s)
{
struct GNUNET_ABD_Delegate *dele;
- size_t enclen = (sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)) * 8;
+ size_t enclen = (sizeof (struct GNUNET_IDENTITY_PublicKey)) * 8;
if (enclen % 5 > 0)
enclen += 5 - enclen % 5;
enclen /= 5; /* 260/5 = 52 */
@@ -91,12 +91,12 @@ GNUNET_ABD_delegate_from_string (const char *s)
char sub_attr[253 + 1] = "";
char signature[256]; // TODO max payload size
- struct GNUNET_CRYPTO_EcdsaSignature *sig;
+ struct GNUNET_IDENTITY_Signature *sig;
struct GNUNET_TIME_Absolute etime_abs;
// If it's A.a <- B.b...
if (6 != sscanf (s,
- "%52s.%253s -> %52s.%253s | %s | %" SCNu64,
+ "%58s.%253s -> %58s.%253s | %s | %" SCNu64,
issuer_pkey,
iss_attr,
subject_pkey,
@@ -106,7 +106,7 @@ GNUNET_ABD_delegate_from_string (const char *s)
{
// Try if it's A.a <- B
if (5 != sscanf (s,
- "%52s.%253s -> %52s | %s | %" SCNu64,
+ "%58s.%253s -> %58s | %s | %" SCNu64,
issuer_pkey,
iss_attr,
subject_pkey,
@@ -143,13 +143,11 @@ GNUNET_ABD_delegate_from_string (const char *s)
}
tmp_str[attr_len - 1] = '\0';
- GNUNET_CRYPTO_ecdsa_public_key_from_string (subject_pkey,
- strlen (subject_pkey),
+ GNUNET_IDENTITY_public_key_from_string (subject_pkey,
&dele->subject_key);
- GNUNET_CRYPTO_ecdsa_public_key_from_string (issuer_pkey,
- strlen (issuer_pkey),
+ GNUNET_IDENTITY_public_key_from_string (issuer_pkey,
&dele->issuer_key);
- GNUNET_assert (sizeof (struct GNUNET_CRYPTO_EcdsaSignature) ==
+ GNUNET_assert (sizeof (struct GNUNET_IDENTITY_Signature) ==
GNUNET_STRINGS_base64_decode (signature,
strlen (signature),
(void **) &sig));
@@ -187,8 +185,8 @@ GNUNET_ABD_delegate_from_string (const char *s)
struct GNUNET_ABD_Delegate *
GNUNET_ABD_delegate_issue (
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
- struct GNUNET_CRYPTO_EcdsaPublicKey *subject,
+ const struct GNUNET_IDENTITY_PrivateKey *issuer,
+ struct GNUNET_IDENTITY_PublicKey *subject,
const char *iss_attr,
const char *sub_attr,
struct GNUNET_TIME_Absolute *expiration)
@@ -223,9 +221,9 @@ GNUNET_ABD_delegate_issue (
del = GNUNET_malloc (size);
del->purpose.size =
- htonl (size - sizeof (struct GNUNET_CRYPTO_EcdsaSignature));
+ htonl (size - sizeof (struct GNUNET_IDENTITY_Signature));
del->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DELEGATE);
- GNUNET_CRYPTO_ecdsa_key_get_public (issuer, &del->issuer_key);
+ GNUNET_IDENTITY_key_get_public (issuer, &del->issuer_key);
del->subject_key = *subject;
del->expiration = GNUNET_htonll (expiration->abs_value_us);
del->issuer_attribute_len = htonl (strlen (iss_attr) + 1);
@@ -240,12 +238,12 @@ GNUNET_ABD_delegate_issue (
GNUNET_memcpy (&del[1], tmp_str, attr_len);
- GNUNET_CRYPTO_ecdsa_sign (issuer, del, &del->signature);
+ GNUNET_IDENTITY_sign_ (issuer, &del->purpose, &del->signature);
dele = GNUNET_malloc (sizeof (struct GNUNET_ABD_Delegate) + attr_len);
dele->signature = del->signature;
dele->expiration = *expiration;
- GNUNET_CRYPTO_ecdsa_key_get_public (issuer, &dele->issuer_key);
+ GNUNET_IDENTITY_key_get_public (issuer, &dele->issuer_key);
dele->subject_key = *subject;
diff --git a/src/abd/gnunet-abd.c b/src/abd/gnunet-abd.c
index b1fb767e3..17671273c 100644
--- a/src/abd/gnunet-abd.c
+++ b/src/abd/gnunet-abd.c
@@ -43,7 +43,7 @@ static struct GNUNET_NAMESTORE_Handle *ns;
/**
* Private key for the our zone.
*/
-static struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey;
+static struct GNUNET_IDENTITY_PrivateKey zone_pkey;
/**
* EgoLookup
@@ -98,12 +98,12 @@ static char *expiration;
/**
* Subject key
*/
-struct GNUNET_CRYPTO_EcdsaPublicKey subject_pkey;
+struct GNUNET_IDENTITY_PublicKey subject_pkey;
/**
* Issuer key
*/
-struct GNUNET_CRYPTO_EcdsaPublicKey issuer_pkey;
+struct GNUNET_IDENTITY_PublicKey issuer_pkey;
/**
@@ -206,11 +206,6 @@ static uint64_t etime;
static int etime_is_rel = GNUNET_SYSERR;
/**
- * Fixed size of the public/private keys
- */
-static const int key_length = 52;
-
-/**
* Record label for storing delegations
*/
static char *record_label;
@@ -282,9 +277,9 @@ handle_intermediate_result (void *cls,
printf ("%s Intermediate result: %s.%s <- %s.%s\n",
prefix,
- GNUNET_CRYPTO_ecdsa_public_key_to_string (&dd->issuer_key),
+ GNUNET_IDENTITY_public_key_to_string (&dd->issuer_key),
dd->issuer_attribute,
- GNUNET_CRYPTO_ecdsa_public_key_to_string (&dd->subject_key),
+ GNUNET_IDENTITY_public_key_to_string (&dd->subject_key),
dd->subject_attribute);
}
@@ -337,8 +332,8 @@ handle_verify_result (void *cls,
printf ("Delegation Chain:\n");
for (i = 0; i < d_count; i++)
{
- iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].issuer_key);
- sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dc[i].subject_key);
+ iss_key = GNUNET_IDENTITY_public_key_to_string (&dc[i].issuer_key);
+ sub_key = GNUNET_IDENTITY_public_key_to_string (&dc[i].subject_key);
if (0 != dc[i].subject_attribute_len)
{
@@ -363,8 +358,8 @@ handle_verify_result (void *cls,
printf ("\nDelegate(s):\n");
for (i = 0; i < c_count; i++)
{
- iss_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dele[i].issuer_key);
- sub_key = GNUNET_CRYPTO_ecdsa_public_key_to_string (&dele[i].subject_key);
+ iss_key = GNUNET_IDENTITY_public_key_to_string (&dele[i].issuer_key);
+ sub_key = GNUNET_IDENTITY_public_key_to_string (&dele[i].subject_key);
printf ("%s.%s <- %s\n", iss_key, dele[i].issuer_attribute, sub_key);
GNUNET_free (iss_key);
GNUNET_free (sub_key);
@@ -386,7 +381,7 @@ handle_verify_result (void *cls,
static void
identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
{
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
+ const struct GNUNET_IDENTITY_PrivateKey *privkey;
el = NULL;
if (NULL == ego)
@@ -405,8 +400,7 @@ identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
{
if (GNUNET_OK !=
- GNUNET_CRYPTO_ecdsa_public_key_from_string (issuer_key,
- strlen (issuer_key),
+ GNUNET_IDENTITY_public_key_from_string (issuer_key,
&issuer_pkey))
{
fprintf (stderr,
@@ -507,7 +501,7 @@ add_continuation (void *cls, int32_t success, const char *emsg)
static void
get_existing_record (void *cls,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
+ const struct GNUNET_IDENTITY_PrivateKey *zone_key,
const char *rec_name,
unsigned int rd_count,
const struct GNUNET_GNSRECORD_Data *rd)
@@ -573,13 +567,13 @@ store_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
// Get import subject public key string
char *subject_pubkey_str =
- GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred->subject_key);
+ GNUNET_IDENTITY_public_key_to_string (&cred->subject_key);
// Get zone public key string
- struct GNUNET_CRYPTO_EcdsaPublicKey zone_pubkey;
+ struct GNUNET_IDENTITY_PublicKey zone_pubkey;
GNUNET_IDENTITY_ego_get_public_key (ego, &zone_pubkey);
char *zone_pubkey_str =
- GNUNET_CRYPTO_ecdsa_public_key_to_string (&zone_pubkey);
+ GNUNET_IDENTITY_public_key_to_string (&zone_pubkey);
// Check if the subject key in the signed import matches the zone's key it is issued to
if (strcmp (zone_pubkey_str, subject_pubkey_str) != 0)
@@ -655,7 +649,7 @@ store_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
static void
sign_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
{
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
+ const struct GNUNET_IDENTITY_PrivateKey *privkey;
struct GNUNET_ABD_Delegate *dele;
struct GNUNET_TIME_Absolute etime_abs;
char *res;
@@ -686,16 +680,7 @@ sign_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
// Subject Public Key
token = strtok (subject, " ");
- if (key_length == strlen (token))
- {
- subject_pubkey_str = token;
- }
- else
- {
- fprintf (stderr, "Key error, wrong length: %ld!\n", strlen (token));
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
+ subject_pubkey_str = token;
// Subject Attribute(s)
token = strtok (NULL, " ");
if (NULL != token)
@@ -707,8 +692,7 @@ sign_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
privkey = GNUNET_IDENTITY_ego_get_private_key (ego);
if (GNUNET_OK !=
- GNUNET_CRYPTO_ecdsa_public_key_from_string (subject_pubkey_str,
- strlen (subject_pubkey_str),
+ GNUNET_IDENTITY_public_key_from_string (subject_pubkey_str,
&subject_pkey))
{
fprintf (stderr,
@@ -873,8 +857,7 @@ run (void *cls,
GNUNET_SCHEDULER_shutdown ();
return;
}
- if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_public_key_from_string (subject,
- strlen (subject),
+ if (GNUNET_OK != GNUNET_IDENTITY_public_key_from_string (subject,
&subject_pkey))
{
fprintf (stderr,
@@ -893,8 +876,7 @@ run (void *cls,
return;
}
if (GNUNET_OK !=
- GNUNET_CRYPTO_ecdsa_public_key_from_string (issuer_key,
- strlen (issuer_key),
+ GNUNET_IDENTITY_public_key_from_string (issuer_key,
&issuer_pkey))
{
fprintf (stderr,
diff --git a/src/abd/gnunet-service-abd.c b/src/abd/gnunet-service-abd.c
index 93368da45..3f9f2f924 100644
--- a/src/abd/gnunet-service-abd.c
+++ b/src/abd/gnunet-service-abd.c
@@ -61,12 +61,12 @@ struct DelegationChainEntry
/**
* The issuer
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
+ struct GNUNET_IDENTITY_PublicKey issuer_key;
/**
* The subject
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
+ struct GNUNET_IDENTITY_PublicKey subject_key;
/**
* The issued attribute
@@ -166,7 +166,7 @@ struct DelegationSetQueueEntry
/**
* Issuer key
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key;
+ struct GNUNET_IDENTITY_PublicKey *issuer_key;
/**
* Queue entries of this set
@@ -267,7 +267,7 @@ struct VerifyRequestHandle
/**
* Issuer public key
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
+ struct GNUNET_IDENTITY_PublicKey issuer_key;
/**
* Issuer attribute
@@ -277,7 +277,7 @@ struct VerifyRequestHandle
/**
* Subject public key
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
+ struct GNUNET_IDENTITY_PublicKey subject_key;
/**
* Delegate DLL
@@ -352,10 +352,10 @@ print_deleset (struct DelegationSetQueueEntry *dsentry, char *text)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%s %s.%s <- %s.%s\n",
text,
- GNUNET_CRYPTO_ecdsa_public_key_to_string (
+ GNUNET_IDENTITY_public_key_to_string (
&dsentry->delegation_chain_entry->issuer_key),
dsentry->delegation_chain_entry->issuer_attribute,
- GNUNET_CRYPTO_ecdsa_public_key_to_string (
+ GNUNET_IDENTITY_public_key_to_string (
&dsentry->delegation_chain_entry->subject_key),
dsentry->delegation_chain_entry->subject_attribute);
}
@@ -697,7 +697,7 @@ handle_bidirectional_match (struct DelegationSetQueueEntry *actual_entry,
{
if (0 != memcmp (&last_entry->delegation_chain_entry->subject_key,
&del_entry->delegate->issuer_key,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
+ sizeof (struct GNUNET_IDENTITY_PublicKey)))
continue;
if (0 != strcmp (last_entry->delegation_chain_entry->subject_attribute,
del_entry->delegate->issuer_attribute))
@@ -828,10 +828,10 @@ forward_resolution (void *cls,
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Entry not relevant, discarding: %s.%s <- %s.%s\n",
- GNUNET_CRYPTO_ecdsa_public_key_to_string (
+ GNUNET_IDENTITY_public_key_to_string (
&del->issuer_key),
del->issuer_attribute,
- GNUNET_CRYPTO_ecdsa_public_key_to_string (
+ GNUNET_IDENTITY_public_key_to_string (
&del->subject_key),
del->subject_attribute);
continue;
@@ -844,10 +844,10 @@ forward_resolution (void *cls,
// Start: Credential Chain Entry
// issuer key is subject key, who needs to be contacted to resolve this (forward, therefore subject)
- ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
+ ds_entry->issuer_key = GNUNET_new (struct GNUNET_IDENTITY_PublicKey);
GNUNET_memcpy (ds_entry->issuer_key,
&del->subject_key,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
+ sizeof (struct GNUNET_IDENTITY_PublicKey));
ds_entry->delegation_chain_entry = GNUNET_new (struct DelegationChainEntry);
ds_entry->delegation_chain_entry->subject_key = del->subject_key;
@@ -868,7 +868,7 @@ forward_resolution (void *cls,
// if: issuer key we looking for
if (0 == memcmp (&del->issuer_key,
&vrh->issuer_key,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
+ sizeof (struct GNUNET_IDENTITY_PublicKey)))
{
// if: issuer attr we looking for
if (0 == strcmp (del->issuer_attribute, vrh->issuer_attribute))
@@ -899,7 +899,7 @@ forward_resolution (void *cls,
{
if (0 == memcmp (&del_entry->delegate->issuer_key,
&vrh->delegation_chain_head->subject_key,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
+ sizeof (struct GNUNET_IDENTITY_PublicKey)))
{
if (0 == strcmp (del_entry->delegate->issuer_attribute,
vrh->delegation_chain_head->subject_attribute))
@@ -926,7 +926,7 @@ forward_resolution (void *cls,
// key of list entry matches actual key
if (0 == memcmp (&del_entry->delegation_chain_entry->subject_key,
&ds_entry->delegation_chain_entry->issuer_key,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
+ sizeof (struct GNUNET_IDENTITY_PublicKey)))
{
// compare entry subject attributes to this trailer (iss attr + old trailer)
if (0 == strcmp (del_entry->unresolved_attribute_delegation,
@@ -955,7 +955,7 @@ forward_resolution (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting to look up trailer %s in zone %s\n",
ds_entry->attr_trailer,
- GNUNET_CRYPTO_ecdsa_public_key_to_string (&del->issuer_key));
+ GNUNET_IDENTITY_public_key_to_string (&del->issuer_key));
ds_entry->lookup_request =
GNUNET_GNS_lookup (gns,
@@ -1064,10 +1064,10 @@ backward_resolution (void *cls,
ds_entry->delegation_chain_entry =
GNUNET_new (struct DelegationChainEntry);
ds_entry->delegation_chain_entry->subject_key = set[j].subject_key;
- ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
+ ds_entry->issuer_key = GNUNET_new (struct GNUNET_IDENTITY_PublicKey);
GNUNET_memcpy (ds_entry->issuer_key,
&set[j].subject_key,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
+ sizeof (struct GNUNET_IDENTITY_PublicKey));
if (0 < set[j].subject_attribute_len)
ds_entry->delegation_chain_entry->subject_attribute =
GNUNET_strdup (set[j].subject_attribute);
@@ -1091,7 +1091,7 @@ backward_resolution (void *cls,
// If key and attribute match credential: continue and backtrack
if (0 != memcmp (&set[j].subject_key,
&del_pointer->delegate->issuer_key,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
+ sizeof (struct GNUNET_IDENTITY_PublicKey)))
continue;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Checking if %s matches %s\n",
@@ -1173,7 +1173,7 @@ backward_resolution (void *cls,
// key of list entry matches actual key
if (0 == memcmp (&del_entry->delegation_chain_entry->issuer_key,
&ds_entry->delegation_chain_entry->subject_key,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
+ sizeof (struct GNUNET_IDENTITY_PublicKey)))
{
// compare entry subject attributes to this trailer (iss attr + old trailer)
if (0 == strcmp (del_entry->attr_trailer,
@@ -1262,7 +1262,7 @@ delegation_chain_bw_resolution_start (void *cls)
{
if (0 != memcmp (&del_entry->delegate->issuer_key,
&vrh->issuer_key,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
+ sizeof (struct GNUNET_IDENTITY_PublicKey)))
continue;
if (0 !=
strcmp (del_entry->delegate->issuer_attribute, vrh->issuer_attribute))
@@ -1284,10 +1284,10 @@ delegation_chain_bw_resolution_start (void *cls)
ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
ds_entry->from_bw = true;
- ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
+ ds_entry->issuer_key = GNUNET_new (struct GNUNET_IDENTITY_PublicKey);
GNUNET_memcpy (ds_entry->issuer_key,
&vrh->issuer_key,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
+ sizeof (struct GNUNET_IDENTITY_PublicKey));
ds_entry->issuer_attribute = GNUNET_strdup (vrh->issuer_attribute);
ds_entry->delegation_chain_entry = GNUNET_new (struct DelegationChainEntry);
@@ -1344,7 +1344,7 @@ delegation_chain_fw_resolution_start (void *cls)
{
if (0 != memcmp (&del_entry->delegate->issuer_key,
&vrh->issuer_key,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)))
+ sizeof (struct GNUNET_IDENTITY_PublicKey)))
continue;
if (0 !=
strcmp (del_entry->delegate->issuer_attribute, vrh->issuer_attribute))
@@ -1366,17 +1366,17 @@ delegation_chain_fw_resolution_start (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Looking for %s.%s\n",
- GNUNET_CRYPTO_ecdsa_public_key_to_string (
+ GNUNET_IDENTITY_public_key_to_string (
&del_entry->delegate->issuer_key),
del_entry->delegate->issuer_attribute);
ds_entry = GNUNET_new (struct DelegationSetQueueEntry);
GNUNET_CONTAINER_DLL_insert (vrh->dsq_head, vrh->dsq_tail, ds_entry);
ds_entry->from_bw = false;
- ds_entry->issuer_key = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey);
+ ds_entry->issuer_key = GNUNET_new (struct GNUNET_IDENTITY_PublicKey);
GNUNET_memcpy (ds_entry->issuer_key,
&del_entry->delegate->subject_key,
- sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
+ sizeof (struct GNUNET_IDENTITY_PublicKey));
ds_entry->delegation_chain_entry = GNUNET_new (struct DelegationChainEntry);
ds_entry->delegation_chain_entry->subject_key =
@@ -1580,7 +1580,7 @@ delegate_collection_finished (void *cls)
static void
handle_delegate_collection_cb (void *cls,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
+ const struct GNUNET_IDENTITY_PrivateKey *key,
const char *label,
unsigned int rd_count,
const struct GNUNET_GNSRECORD_Data *rd)
@@ -1643,7 +1643,7 @@ handle_collect (void *cls, const struct CollectMessage *c_msg)
vrh->client = client;
vrh->request_id = c_msg->id;
vrh->issuer_key = c_msg->issuer_key;
- GNUNET_CRYPTO_ecdsa_key_get_public (&c_msg->subject_key, &vrh->subject_key);
+ GNUNET_IDENTITY_key_get_public (&c_msg->subject_key, &vrh->subject_key);
vrh->issuer_attribute = GNUNET_strdup (issuer_attribute);
vrh->resolution_algo = ntohs (c_msg->resolution_algo);
diff --git a/src/abd/plugin_gnsrecord_abd.c b/src/abd/plugin_gnsrecord_abd.c
index 25dc20152..24cf6a3aa 100644
--- a/src/abd/plugin_gnsrecord_abd.c
+++ b/src/abd/plugin_gnsrecord_abd.c
@@ -77,7 +77,7 @@ abd_value_to_string (void *cls,
for (i = 0; i < ntohl (sets.set_count); i++)
{
subject_pkey =
- GNUNET_CRYPTO_ecdsa_public_key_to_string (&set[i].subject_key);
+ GNUNET_IDENTITY_public_key_to_string (&set[i].subject_key);
if (0 == set[i].subject_attribute_len)
{
@@ -158,7 +158,7 @@ abd_string_to_value (void *cls,
{
struct GNUNET_ABD_DelegationRecord *sets;
char attr_str[253 + 1];
- char subject_pkey[52 + 1];
+ char subject_pkey[58 + 1];
char *token;
char *tmp_str;
int matches = 0;
@@ -207,8 +207,7 @@ abd_string_to_value (void *cls,
matches = sscanf (token, "%s %s", subject_pkey, attr_str);
// sets the public key for the set entry
- GNUNET_CRYPTO_ecdsa_public_key_from_string (subject_pkey,
- strlen (subject_pkey),
+ GNUNET_IDENTITY_public_key_from_string (subject_pkey,
&set[i].subject_key);
// If not just key, also set subject attribute (Not A.a <- B but A.a <- B.b)
diff --git a/src/abd/test_abd_bi_and.sh b/src/abd/test_abd_bi_and.sh
index b32313636..99c89a344 100755
--- a/src/abd/test_abd_bi_and.sh
+++ b/src/abd/test_abd_bi_and.sh
@@ -55,16 +55,16 @@ gnunet-namestore -D -z b
gnunet-abd --createIssuerSide --ego=g --attribute="g" --subject="$HKEY h" --ttl=5m -c test_abd_lookup.conf
gnunet-namestore -D -z b
-SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"`
+SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2049-12-12 10:00:00"`
gnunet-abd --createSubjectSide --ego=d --import="$SIGNED"
gnunet-namestore -D -z d
-SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"`
+SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2049-12-12 10:00:00"`
gnunet-abd --createSubjectSide --ego=e --import="$SIGNED"
gnunet-namestore -D -z e
-SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="e" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
+SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="e" --subject="$FKEY" --ttl="2049-12-12 10:00:00"`
gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
gnunet-namestore -D -z f
-SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=h --attribute="h" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
+SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=h --attribute="h" --subject="$FKEY" --ttl="2049-12-12 10:00:00"`
gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
gnunet-namestore -D -z h
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c
index 5fcbfb0a9..1360ecf14 100644
--- a/src/arm/arm_api.c
+++ b/src/arm/arm_api.c
@@ -907,6 +907,7 @@ notify_starting (void *cls)
op->result_cont (op->cont_cls,
GNUNET_ARM_REQUEST_SENT_OK,
op->starting_ret);
+ GNUNET_DISK_file_close(op->rfd);
GNUNET_free (op);
}
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am
index 0b8e7309a..85a2bb555 100644
--- a/src/ats/Makefile.am
+++ b/src/ats/Makefile.am
@@ -65,11 +65,9 @@ gnunet_service_ats_LDADD = \
libgnunetats.la \
$(GN_LIBINTL)
-if HAVE_TESTING
TESTING_TESTS = \
test_ats_api_proportional \
test_ats_reservation_api_proportional
-endif
check_PROGRAMS = \
$(TESTING_TESTS)
diff --git a/src/cadet/Makefile.am b/src/cadet/Makefile.am
index 2289a2d96..d942c6495 100644
--- a/src/cadet/Makefile.am
+++ b/src/cadet/Makefile.am
@@ -78,12 +78,9 @@ if LINUX
endif
-if HAVE_TESTING
noinst_LTLIBRARIES = libgnunetcadettest.la $(noinst_LIB_EXP)
# noinst_PROGRAMS = gnunet-cadet-profiler
-endif
-if HAVE_TESTING
check_PROGRAMS = \
test_cadet_local_mq \
test_cadet_2_forward \
@@ -106,7 +103,6 @@ check_PROGRAMS = \
test_cadet_5_speed_reliable_backwards \
test_cadet_5_speed_backwards \
test_cadet_5_reopen
-endif
#gnunet_cadet_profiler_SOURCES = \
diff --git a/src/consensus/Makefile.am b/src/consensus/Makefile.am
index cf1d32e74..d7b23e7c6 100644
--- a/src/consensus/Makefile.am
+++ b/src/consensus/Makefile.am
@@ -89,7 +89,6 @@ libgnunet_plugin_block_consensus_la_LDFLAGS = \
-if HAVE_TESTING
bin_PROGRAMS = \
gnunet-consensus-profiler
@@ -100,7 +99,6 @@ if ENABLE_TEST_RUN
AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
TESTS = $(check_PROGRAMS)
endif
-endif
test_consensus_api_SOURCES = \
test_consensus_api.c
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index d2d3a2d7f..e51247e18 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -54,10 +54,8 @@ gnunet_core_LDADD = \
gnunet_core_LDFLAGS = \
$(GN_LIBINTL)
-if HAVE_TESTING
- TESTING_TESTS = \
- test_core_api_send_to_self
-endif
+TESTING_TESTS = \
+ test_core_api_send_to_self
check_PROGRAMS = \
test_core_api_start_only \
diff --git a/src/curl/curl.c b/src/curl/curl.c
index 71672c780..30c2f8c01 100644
--- a/src/curl/curl.c
+++ b/src/curl/curl.c
@@ -368,7 +368,8 @@ download_cb (char *bufptr,
db->eno = ENOMEM;
return 0; /* signals an error to curl */
}
- db->buf = GNUNET_realloc (db->buf, db->buf_size + msize);
+ db->buf = GNUNET_realloc (db->buf,
+ db->buf_size + msize);
buf = db->buf + db->buf_size;
GNUNET_memcpy (buf, bufptr, msize);
db->buf_size += msize;
@@ -421,7 +422,8 @@ setup_job_headers (struct GNUNET_CURL_Context *ctx,
&scope.scope_id,
sizeof(struct GNUNET_AsyncScopeId));
GNUNET_assert (NULL != aid_header);
- GNUNET_assert (NULL != curl_slist_append (all_headers, aid_header));
+ GNUNET_assert (NULL != curl_slist_append (all_headers,
+ aid_header));
GNUNET_free (aid_header);
}
}
@@ -455,12 +457,25 @@ setup_job (CURL *eh,
job = GNUNET_new (struct GNUNET_CURL_Job);
job->job_headers = all_headers;
- if ((CURLE_OK != curl_easy_setopt (eh, CURLOPT_PRIVATE, job)) ||
- (CURLE_OK !=
- curl_easy_setopt (eh, CURLOPT_WRITEFUNCTION, &download_cb)) ||
- (CURLE_OK != curl_easy_setopt (eh, CURLOPT_WRITEDATA, &job->db)) ||
- (CURLE_OK != curl_easy_setopt (eh, CURLOPT_SHARE, ctx->share)) ||
- (CURLM_OK != curl_multi_add_handle (ctx->multi, eh)))
+ if ( (CURLE_OK !=
+ curl_easy_setopt (eh,
+ CURLOPT_PRIVATE,
+ job)) ||
+ (CURLE_OK !=
+ curl_easy_setopt (eh,
+ CURLOPT_WRITEFUNCTION,
+ &download_cb)) ||
+ (CURLE_OK !=
+ curl_easy_setopt (eh,
+ CURLOPT_WRITEDATA,
+ &job->db)) ||
+ (CURLE_OK !=
+ curl_easy_setopt (eh,
+ CURLOPT_SHARE,
+ ctx->share)) ||
+ (CURLM_OK !=
+ curl_multi_add_handle (ctx->multi,
+ eh)) )
{
GNUNET_break (0);
GNUNET_free (job);
@@ -683,9 +698,12 @@ GNUNET_CURL_job_cancel (struct GNUNET_CURL_Job *job)
{
struct GNUNET_CURL_Context *ctx = job->ctx;
- GNUNET_CONTAINER_DLL_remove (ctx->jobs_head, ctx->jobs_tail, job);
+ GNUNET_CONTAINER_DLL_remove (ctx->jobs_head,
+ ctx->jobs_tail,
+ job);
GNUNET_break (CURLM_OK ==
- curl_multi_remove_handle (ctx->multi, job->easy_handle));
+ curl_multi_remove_handle (ctx->multi,
+ job->easy_handle));
curl_easy_cleanup (job->easy_handle);
GNUNET_free (job->db.buf);
curl_slist_free_all (job->job_headers);
@@ -831,7 +849,8 @@ enum GNUNET_GenericReturnValue
GNUNET_CURL_append_header (struct GNUNET_CURL_Context *ctx,
const char *header)
{
- ctx->common_headers = curl_slist_append (ctx->common_headers, header);
+ ctx->common_headers = curl_slist_append (ctx->common_headers,
+ header);
if (NULL == ctx->common_headers)
return GNUNET_SYSERR;
@@ -854,40 +873,46 @@ do_benchmark (CURLMsg *cmsg)
uint64_t bytes_sent = 0;
uint64_t bytes_received = 0;
- GNUNET_break (CURLE_OK == curl_easy_getinfo (cmsg->easy_handle,
- CURLINFO_TOTAL_TIME,
- &total_as_double));
+ GNUNET_break (CURLE_OK ==
+ curl_easy_getinfo (cmsg->easy_handle,
+ CURLINFO_TOTAL_TIME,
+ &total_as_double));
total.rel_value_us = total_as_double * 1000 * 1000;
- GNUNET_break (CURLE_OK == curl_easy_getinfo (cmsg->easy_handle,
- CURLINFO_EFFECTIVE_URL,
- &url));
+ GNUNET_break (CURLE_OK ==
+ curl_easy_getinfo (cmsg->easy_handle,
+ CURLINFO_EFFECTIVE_URL,
+ &url));
/* HEADER_SIZE + SIZE_DOWNLOAD_T is hopefully the total
number of bytes received, not clear from curl docs. */
- GNUNET_break (CURLE_OK == curl_easy_getinfo (cmsg->easy_handle,
- CURLINFO_HEADER_SIZE,
- &size_long));
+ GNUNET_break (CURLE_OK ==
+ curl_easy_getinfo (cmsg->easy_handle,
+ CURLINFO_HEADER_SIZE,
+ &size_long));
bytes_received += size_long;
- GNUNET_break (CURLE_OK == curl_easy_getinfo (cmsg->easy_handle,
- CURLINFO_SIZE_DOWNLOAD_T,
- &size_curl));
+ GNUNET_break (CURLE_OK ==
+ curl_easy_getinfo (cmsg->easy_handle,
+ CURLINFO_SIZE_DOWNLOAD_T,
+ &size_curl));
bytes_received += size_curl;
/* REQUEST_SIZE + SIZE_UPLOAD_T is hopefully the total number of bytes
sent, again docs are not completely clear. */
- GNUNET_break (CURLE_OK == curl_easy_getinfo (cmsg->easy_handle,
- CURLINFO_REQUEST_SIZE,
- &size_long));
+ GNUNET_break (CURLE_OK ==
+ curl_easy_getinfo (cmsg->easy_handle,
+ CURLINFO_REQUEST_SIZE,
+ &size_long));
bytes_sent += size_long;
/* We obtain this value to check an invariant, but never use it otherwise. */
- GNUNET_break (CURLE_OK == curl_easy_getinfo (cmsg->easy_handle,
- CURLINFO_SIZE_UPLOAD_T,
- &size_curl));
+ GNUNET_break (CURLE_OK ==
+ curl_easy_getinfo (cmsg->easy_handle,
+ CURLINFO_SIZE_UPLOAD_T,
+ &size_curl));
/* CURLINFO_SIZE_UPLOAD_T <= CURLINFO_REQUEST_SIZE should
be an invariant.
@@ -900,8 +925,10 @@ do_benchmark (CURLMsg *cmsg)
urd = get_url_benchmark_data (url, (unsigned int) response_code);
urd->count++;
- urd->time = GNUNET_TIME_relative_add (urd->time, total);
- urd->time_max = GNUNET_TIME_relative_max (total, urd->time_max);
+ urd->time = GNUNET_TIME_relative_add (urd->time,
+ total);
+ urd->time_max = GNUNET_TIME_relative_max (total,
+ urd->time_max);
urd->bytes_sent += bytes_sent;
urd->bytes_received += bytes_received;
}
@@ -929,7 +956,8 @@ GNUNET_CURL_perform2 (struct GNUNET_CURL_Context *ctx,
(void) curl_multi_perform (ctx->multi,
&n_running);
- while (NULL != (cmsg = curl_multi_info_read (ctx->multi, &n_completed)))
+ while (NULL != (cmsg = curl_multi_info_read (ctx->multi,
+ &n_completed)))
{
struct GNUNET_CURL_Job *job;
long response_code;
@@ -937,9 +965,10 @@ GNUNET_CURL_perform2 (struct GNUNET_CURL_Context *ctx,
/* Only documented return value is CURLMSG_DONE */
GNUNET_break (CURLMSG_DONE == cmsg->msg);
- GNUNET_assert (CURLE_OK == curl_easy_getinfo (cmsg->easy_handle,
- CURLINFO_PRIVATE,
- (char **) &job));
+ GNUNET_assert (CURLE_OK ==
+ curl_easy_getinfo (cmsg->easy_handle,
+ CURLINFO_PRIVATE,
+ (char **) &job));
GNUNET_assert (job->ctx == ctx);
response_code = 0;
if (NULL != job->jcc_raw)
@@ -1027,14 +1056,17 @@ GNUNET_CURL_get_select_info (struct GNUNET_CURL_Context *ctx,
int m;
m = -1;
- GNUNET_assert (CURLM_OK == curl_multi_fdset (ctx->multi,
- read_fd_set,
- write_fd_set,
- except_fd_set,
- &m));
+ GNUNET_assert (CURLM_OK ==
+ curl_multi_fdset (ctx->multi,
+ read_fd_set,
+ write_fd_set,
+ except_fd_set,
+ &m));
to = *timeout;
*max_fd = GNUNET_MAX (m, *max_fd);
- GNUNET_assert (CURLM_OK == curl_multi_timeout (ctx->multi, &to));
+ GNUNET_assert (CURLM_OK ==
+ curl_multi_timeout (ctx->multi,
+ &to));
/* Only if what we got back from curl is smaller than what we
already had (-1 == infinity!), then update timeout */
@@ -1079,7 +1111,9 @@ GNUNET_CURL_constructor__ (void)
if (CURLE_OK != (ret = curl_global_init (CURL_GLOBAL_DEFAULT)))
{
- CURL_STRERROR (GNUNET_ERROR_TYPE_ERROR, "curl_global_init", ret);
+ CURL_STRERROR (GNUNET_ERROR_TYPE_ERROR,
+ "curl_global_init",
+ ret);
curl_fail = 1;
}
}
diff --git a/src/datacache/Makefile.am b/src/datacache/Makefile.am
index ecb02d1c3..4789706ff 100644
--- a/src/datacache/Makefile.am
+++ b/src/datacache/Makefile.am
@@ -85,7 +85,6 @@ libgnunet_plugin_datacache_template_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS)
-if HAVE_TESTING
if HAVE_SQLITE
if HAVE_BENCHMARKS
SQLITE_BENCHMARKS = \
@@ -95,7 +94,6 @@ SQLITE_TESTS = \
test_datacache_sqlite \
test_datacache_quota_sqlite \
$(SQLITE_BENCHMARKS)
-endif
if HAVE_BENCHMARKS
HEAP_BENCHMARKS = \
diff --git a/src/datastore/Makefile.am b/src/datastore/Makefile.am
index cd1df4e5e..07ae004b3 100644
--- a/src/datastore/Makefile.am
+++ b/src/datastore/Makefile.am
@@ -52,7 +52,6 @@ gnunet_datastore_LDADD = \
if HAVE_MYSQL
MYSQL_PLUGIN = libgnunet_plugin_datastore_mysql.la
-if HAVE_TESTING
if HAVE_BENCHMARKS
MYSQL_BENCHMARKS = \
perf_datastore_api_mysql \
@@ -64,10 +63,8 @@ endif
test_plugin_datastore_mysql \
$(MYSQL_BENCHMARKS)
endif
-endif
if HAVE_SQLITE
SQLITE_PLUGIN = libgnunet_plugin_datastore_sqlite.la
-if HAVE_TESTING
if HAVE_BENCHMARKS
SQLITE_BENCHMARKS = \
perf_datastore_api_sqlite \
@@ -79,10 +76,8 @@ endif
test_plugin_datastore_sqlite \
$(SQLITE_BENCHMARKS)
endif
-endif
if HAVE_POSTGRESQL
POSTGRES_PLUGIN = libgnunet_plugin_datastore_postgres.la
-if HAVE_TESTING
if HAVE_BENCHMARKS
POSTGRES_BENCHMARKS = \
perf_datastore_api_postgres \
@@ -94,7 +89,6 @@ endif
test_plugin_datastore_postgres \
$(POSTGRES_BENCHMARKS)
endif
-endif
plugin_LTLIBRARIES = \
$(SQLITE_PLUGIN) \
diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am
index 919eca438..69e34000c 100644
--- a/src/dht/Makefile.am
+++ b/src/dht/Makefile.am
@@ -52,10 +52,8 @@ bin_PROGRAMS = \
gnunet-dht-get \
gnunet-dht-put
-if HAVE_TESTING
noinst_PROGRAMS = \
gnunet-dht-profiler
-endif
gnunet_service_dht_SOURCES = \
gnunet-service-dht.c gnunet-service-dht.h \
@@ -117,9 +115,7 @@ gnunet_dht_profiler_LDADD = \
gnunet_dht_profiler_LDFLAGS = \
$(GN_LIBINTL)
-if HAVE_TESTING
noinst_LIBRARIES = libgnunetdhttest.a
-endif
libgnunetdhttest_a_SOURCES = \
dht_test_lib.c dht_test_lib.h
@@ -128,7 +124,6 @@ libgnunetdhttest_a_LIBADD = \
$(top_builddir)/src/testbed/libgnunettestbed.la \
libgnunetdht.la
-if HAVE_TESTING
check_PROGRAMS = \
test_dht_api \
test_dht_twopeer \
@@ -136,7 +131,6 @@ check_PROGRAMS = \
test_dht_line \
test_dht_2dtorus \
test_dht_monitor
-endif
if HAVE_EXPERIMENTAL
# These tests still do not work as testbed does
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index ca255310c..02dab849b 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -115,29 +115,29 @@ struct PeerPutMessage
struct GNUNET_MessageHeader header;
/**
- * Processing options
+ * Content type.
*/
- uint32_t options GNUNET_PACKED;
+ uint32_t type GNUNET_PACKED;
/**
- * Content type.
+ * Processing options
*/
- uint32_t type GNUNET_PACKED;
+ uint16_t options GNUNET_PACKED;
/**
* Hop count
*/
- uint32_t hop_count GNUNET_PACKED;
+ uint16_t hop_count GNUNET_PACKED;
/**
* Replication level for this message
*/
- uint32_t desired_replication_level GNUNET_PACKED;
+ uint16_t desired_replication_level GNUNET_PACKED;
/**
* Length of the PUT path that follows (if tracked).
*/
- uint32_t put_path_length GNUNET_PACKED;
+ uint16_t put_path_length GNUNET_PACKED;
/**
* When does the content expire?
@@ -176,14 +176,19 @@ struct PeerResultMessage
uint32_t type GNUNET_PACKED;
/**
+ * Reserved.
+ */
+ uint32_t reserved GNUNET_PACKED;
+
+ /**
* Length of the PUT path that follows (if tracked).
*/
- uint32_t put_path_length GNUNET_PACKED;
+ uint16_t put_path_length GNUNET_PACKED;
/**
* Length of the GET path that follows (if tracked).
*/
- uint32_t get_path_length GNUNET_PACKED;
+ uint16_t get_path_length GNUNET_PACKED;
/**
* When does the content expire?
@@ -214,34 +219,29 @@ struct PeerGetMessage
struct GNUNET_MessageHeader header;
/**
- * Processing options
+ * Desired content type.
*/
- uint32_t options GNUNET_PACKED;
+ uint32_t type GNUNET_PACKED;
/**
- * Desired content type.
+ * Processing options
*/
- uint32_t type GNUNET_PACKED;
+ uint16_t options GNUNET_PACKED;
/**
* Hop count
*/
- uint32_t hop_count GNUNET_PACKED;
+ uint16_t hop_count GNUNET_PACKED;
/**
* Desired replication level for this request.
*/
- uint32_t desired_replication_level GNUNET_PACKED;
+ uint16_t desired_replication_level GNUNET_PACKED;
/**
* Size of the extended query.
*/
- uint32_t xquery_size;
-
- /**
- * Bloomfilter mutator.
- */
- uint32_t bf_mutator;
+ uint16_t xquery_size;
/**
* Bloomfilter (for peer identities) to stop circular routes
@@ -253,6 +253,11 @@ struct PeerGetMessage
*/
struct GNUNET_HashCode key;
+ /**
+ * Bloomfilter mutator.
+ */
+ uint32_t bf_mutator;
+
/* xquery */
/* result bloomfilter */
@@ -844,6 +849,10 @@ get_forward_count (uint32_t hop_count,
uint32_t forward_count;
float target_value;
+ if (0 == target_replication)
+ target_replication = 1; /* 0 is verboten */
+ if (target_replication > MAXIMUM_REPLICATION_LEVEL)
+ target_replication = MAXIMUM_REPLICATION_LEVEL;
if (hop_count > GDS_NSE_get () * 4.0)
{
/* forcefully terminate */
@@ -864,6 +873,8 @@ get_forward_count (uint32_t hop_count,
1 + (target_replication - 1.0) / (GDS_NSE_get ()
+ ((float) (target_replication - 1.0)
* hop_count));
+
+
/* Set forward count to floor of target_value */
forward_count = (uint32_t) target_value;
/* Subtract forward_count (floor) from target_value (yields value between 0 and 1) */
@@ -872,7 +883,8 @@ get_forward_count (uint32_t hop_count,
GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
if (random_value < (target_value * UINT32_MAX))
forward_count++;
- return forward_count;
+ return GNUNET_MIN (forward_count,
+ MAXIMUM_REPLICATION_LEVEL);
}
diff --git a/src/dhtu/Makefile.am b/src/dhtu/Makefile.am
index 72b422812..0e10721cd 100644
--- a/src/dhtu/Makefile.am
+++ b/src/dhtu/Makefile.am
@@ -11,6 +11,7 @@ if USE_COVERAGE
endif
plugin_LTLIBRARIES = \
+ libgnunet_plugin_dhtu_gnunet.la \
libgnunet_plugin_dhtu_ip.la
libgnunet_plugin_dhtu_ip_la_SOURCES = \
@@ -22,3 +23,52 @@ libgnunet_plugin_dhtu_ip_la_LIBADD = \
libgnunet_plugin_dhtu_ip_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS)
+
+
+libgnunet_plugin_dhtu_gnunet_la_SOURCES = \
+ plugin_dhtu_gnunet.c
+libgnunet_plugin_dhtu_gnunet_la_LIBADD = \
+ $(top_builddir)/src/ats/libgnunetats.la \
+ $(top_builddir)/src/core/libgnunetcore.la \
+ $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
+ $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/hello/libgnunethello.la \
+ $(top_builddir)/src/nse/libgnunetnse.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(XLIBS) \
+ $(LTLIBINTL)
+libgnunet_plugin_dhtu_gnunet_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+
+
+lib_LTLIBRARIES = \
+ libgnunettestingdhtu.la
+
+libgnunettestingdhtu_la_SOURCES = \
+ testing_dhtu_cmd_send.c
+libgnunettestingdhtu_la_LIBADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/arm/libgnunetarm.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(LTLIBINTL)
+libgnunettestingdhtu_la_LDFLAGS = \
+ $(GN_LIB_LDFLAGS) \
+ -version-info 0:0:0
+
+
+
+test_dhtu_ip_SOURCES = \
+ test_dhtu_ip.c
+test_dhtu_ip_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/arm/libgnunetarm.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+check_PROGRAMS = \
+ test_dhtu_ip
+
+if ENABLE_TEST_RUN
+AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
+TESTS = \
+ $(check_PROGRAMS)
+endif
diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c
index d6cd75242..ee78858c8 100644
--- a/src/dhtu/plugin_dhtu_gnunet.c
+++ b/src/dhtu/plugin_dhtu_gnunet.c
@@ -21,11 +21,82 @@
/**
* @author Christian Grothoff
*
- * @file plugin_dhtu_ip.c
+ * @file plugin_dhtu_gnunet.c
* @brief plain IP based DHT network underlay
*/
#include "platform.h"
-#incluce "gnunet_dhtu_plugin.h"
+#include "gnunet_dhtu_plugin.h"
+#include "gnunet_ats_service.h"
+#include "gnunet_core_service.h"
+#include "gnunet_transport_service.h"
+#include "gnunet_hello_lib.h"
+#include "gnunet_peerinfo_service.h"
+#include "gnunet_nse_service.h"
+
+
+/**
+ * Handle for a private key used by this underlay.
+ */
+struct GNUNET_DHTU_PrivateKey
+{
+ /**
+ * GNUnet uses eddsa for peers.
+ */
+ struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
+
+};
+
+GNUNET_NETWORK_STRUCT_BEGIN
+
+/**
+ * Handle for a public key used by this underlay.
+ */
+struct PublicKey
+{
+
+ /**
+ * Header.
+ */
+ struct GNUNET_DHTU_PublicKey header;
+
+ /**
+ * GNUnet uses eddsa for peers.
+ */
+ struct GNUNET_PeerIdentity peer_pub;
+
+};
+
+
+GNUNET_NETWORK_STRUCT_END
+
+
+/**
+ * Handle for a HELLO we're offering the transport.
+ */
+struct HelloHandle
+{
+ /**
+ * Kept in a DLL.
+ */
+ struct HelloHandle *next;
+
+ /**
+ * Kept in a DLL.
+ */
+ struct HelloHandle *prev;
+
+ /**
+ * Our plugin.
+ */
+ struct Plugin *plugin;
+
+ /**
+ * Offer handle.
+ */
+ struct GNUNET_TRANSPORT_OfferHelloHandle *ohh;
+
+};
+
/**
* Opaque handle that the underlay offers for our address to be used when
@@ -38,6 +109,17 @@ struct GNUNET_DHTU_Source
* Application context for this source.
*/
void *app_ctx;
+
+ /**
+ * Hash position of this peer in the DHT.
+ */
+ struct GNUNET_DHTU_Hash my_id;
+
+ /**
+ * Private key of this peer.
+ */
+ struct GNUNET_DHTU_PrivateKey pk;
+
};
@@ -47,13 +129,34 @@ struct GNUNET_DHTU_Source
*/
struct GNUNET_DHTU_Target
{
-
+
/**
* Application context for this target.
*/
void *app_ctx;
/**
+ * Our plugin with its environment.
+ */
+ struct Plugin *plugin;
+
+ /**
+ * CORE MQ to send messages to this peer.
+ */
+ struct GNUNET_MQ_Handle *mq;
+
+ /**
+ * Public key of the peer.
+ */
+ struct PublicKey pk;
+
+ /**
+ * Hash of the @a pk to identify position of the peer
+ * in the DHT.
+ */
+ struct GNUNET_DHTU_Hash peer_id;
+
+ /**
* Head of preferences expressed for this target.
*/
struct GNUNET_DHTU_PreferenceHandle *ph_head;
@@ -64,12 +167,18 @@ struct GNUNET_DHTU_Target
struct GNUNET_DHTU_PreferenceHandle *ph_tail;
/**
+ * ATS preference handle for this peer, or NULL.
+ */
+ struct GNUNET_ATS_ConnectivitySuggestHandle *csh;
+
+ /**
* Preference counter, length of the @a ph_head DLL.
*/
unsigned int ph_count;
};
+
/**
* Opaque handle expressing a preference of the DHT to
* keep a particular target connected.
@@ -94,23 +203,56 @@ struct GNUNET_DHTU_PreferenceHandle
/**
- * Opaque handle for a private key used by this underlay.
- */
-struct GNUNET_DHTU_PrivateKey
-{
- /* we are IP, we do not do crypto */
-};
-
-
-/**
* Closure for all plugin functions.
*/
struct Plugin
{
- /**
+
+ /**
+ * Our "source" address. Traditional CORE API does not tell us which source
+ * it is, so they are all identical.
+ */
+ struct GNUNET_DHTU_Source src;
+
+ /**
+ * My identity.
+ */
+ struct GNUNET_PeerIdentity my_identity;
+
+ /**
* Callbacks into the DHT.
*/
struct GNUNET_DHTU_PluginEnvironment *env;
+
+ /**
+ * Handle to the CORE service.
+ */
+ struct GNUNET_CORE_Handle *core;
+
+ /**
+ * Handle to ATS service.
+ */
+ struct GNUNET_ATS_ConnectivityHandle *ats;
+
+ /**
+ * Handle to the NSE service.
+ */
+ struct GNUNET_NSE_Handle *nse;
+
+ /**
+ * Watching for our address to change.
+ */
+ struct GNUNET_PEERINFO_NotifyContext *nc;
+
+ /**
+ * Hellos we are offering to transport.
+ */
+ struct HelloHandle *hh_head;
+
+ /**
+ * Hellos we are offering to transport.
+ */
+ struct HelloHandle *hh_tail;
};
@@ -126,10 +268,17 @@ struct Plugin
static ssize_t
ip_sign (void *cls,
const struct GNUNET_DHTU_PrivateKey *pk,
- const struct GNUNET_DHTU_SignaturePurpose *purpose,
+ const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
void **sig)
{
- return 0;
+ struct GNUNET_CRYPTO_EddsaSignature *es;
+
+ es = GNUNET_new (struct GNUNET_CRYPTO_EddsaSignature);
+ GNUNET_CRYPTO_eddsa_sign_ (&pk->eddsa_priv,
+ purpose,
+ es);
+ *sig = es;
+ return sizeof (*es);
}
@@ -148,14 +297,55 @@ ip_sign (void *cls,
static enum GNUNET_GenericReturnValue
ip_verify (void *cls,
const struct GNUNET_DHTU_PublicKey *pk,
- const struct GNUNET_DHTU_SignaturePurpose *purpose,
+ const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
const void *sig,
size_t sig_size)
{
- return GNUNET_NO;
+ const struct GNUNET_CRYPTO_EddsaSignature *es = sig;
+ const struct PublicKey *pub;
+
+ GNUNET_assert (sizeof (struct PublicKey) ==
+ ntohs (pk->size));
+ pub = (const struct PublicKey *) pk;
+ if (sizeof (*es) != sig_size)
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+ if (GNUNET_OK !=
+ GNUNET_CRYPTO_eddsa_verify_ (ntohl (purpose->purpose),
+ purpose,
+ es,
+ &pub->peer_pub.public_key))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+
+/**
+ * Function called once a hello offer is completed.
+ *
+ * @param cls a `struct HelloHandle`
+ */
+static void
+hello_offered_cb (void *cls)
+{
+ struct HelloHandle *hh = cls;
+ struct Plugin *plugin = hh->plugin;
+
+ GNUNET_CONTAINER_DLL_remove (plugin->hh_head,
+ plugin->hh_tail,
+ hh);
+ GNUNET_free (hh);
}
+#include "../peerinfo-tool/gnunet-peerinfo_plugins.c"
+
+
/**
* Request creation of a session with a peer at the given @a address.
*
@@ -166,7 +356,31 @@ static void
ip_try_connect (void *cls,
const char *address)
{
- GNUNET_break (0);
+ struct Plugin *plugin = cls;
+ struct GNUNET_HELLO_Message *hello = NULL;
+ struct HelloHandle *hh;
+ struct GNUNET_CRYPTO_EddsaPublicKey pubkey;
+
+ if (GNUNET_OK !=
+ GNUNET_HELLO_parse_uri (address,
+ &pubkey,
+ &hello,
+ &GPI_plugins_find))
+ {
+ GNUNET_break (0);
+ return;
+ }
+
+ hh = GNUNET_new (struct HelloHandle);
+ hh->plugin = plugin;
+ GNUNET_CONTAINER_DLL_insert (plugin->hh_head,
+ plugin->hh_tail,
+ hh);
+ hh->ohh = GNUNET_TRANSPORT_offer_hello (plugin->env->cfg,
+ &hello->header,
+ &hello_offered_cb,
+ hh);
+ GNUNET_free (hello);
}
@@ -174,7 +388,7 @@ ip_try_connect (void *cls,
* Request underlay to keep the connection to @a target alive if possible.
* Hold may be called multiple times to express a strong preference to
* keep a connection, say because a @a target is in multiple tables.
- *
+ *
* @param cls closure
* @param target connection to keep alive
*/
@@ -182,6 +396,7 @@ static struct GNUNET_DHTU_PreferenceHandle *
ip_hold (void *cls,
struct GNUNET_DHTU_Target *target)
{
+ struct Plugin *plugin = cls;
struct GNUNET_DHTU_PreferenceHandle *ph;
ph = GNUNET_new (struct GNUNET_DHTU_PreferenceHandle);
@@ -190,13 +405,19 @@ ip_hold (void *cls,
target->ph_tail,
ph);
target->ph_count++;
+ if (NULL != target->csh)
+ GNUNET_ATS_connectivity_suggest_cancel (target->csh);
+ target->csh
+ = GNUNET_ATS_connectivity_suggest (plugin->ats,
+ &target->pk.peer_pub,
+ target->ph_count);
return ph;
}
/**
* Do no long request underlay to keep the connection alive.
- *
+ *
* @param cls closure
* @param target connection to keep alive
*/
@@ -204,12 +425,22 @@ static void
ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph)
{
struct GNUNET_DHTU_Target *target = ph->target;
-
+ struct Plugin *plugin = target->plugin;
+
GNUNET_CONTAINER_DLL_remove (target->ph_head,
target->ph_tail,
ph);
target->ph_count--;
GNUNET_free (ph);
+ if (NULL != target->csh)
+ GNUNET_ATS_connectivity_suggest_cancel (target->csh);
+ if (0 == target->ph_count)
+ target->csh = NULL;
+ else
+ target->csh
+ = GNUNET_ATS_connectivity_suggest (plugin->ats,
+ &target->pk.peer_pub,
+ target->ph_count);
}
@@ -225,7 +456,7 @@ ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph)
* @param msg_size number of bytes in @a msg
* @param finished_cb function called once transmission is done
* (not called if @a target disconnects, then only the
- * disconnect_cb is called).
+ * disconnect_cb is called).
* @param finished_cb_cls closure for @a finished_cb
*/
static void
@@ -236,7 +467,246 @@ ip_send (void *cls,
GNUNET_SCHEDULER_TaskCallback finished_cb,
void *finished_cb_cls)
{
- GNUNET_break (0);
+ struct GNUNET_MQ_Envelope *env;
+ struct GNUNET_MessageHeader *cmsg;
+
+ env = GNUNET_MQ_msg_extra (cmsg,
+ msg_size,
+ GNUNET_MESSAGE_TYPE_DHT_CORE);
+ GNUNET_MQ_notify_sent (env,
+ finished_cb,
+ finished_cb_cls);
+ memcpy (&cmsg[1],
+ msg,
+ msg_size);
+ GNUNET_MQ_send (target->mq,
+ env);
+}
+
+
+/**
+ * Method called whenever a given peer connects.
+ *
+ * @param cls closure
+ * @param peer peer identity this notification is about
+ * @return closure associated with @a peer. given to mq callbacks and
+ * #GNUNET_CORE_DisconnectEventHandler
+ */
+static void *
+core_connect_cb (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ struct GNUNET_MQ_Handle *mq)
+{
+ struct Plugin *plugin = cls;
+ struct GNUNET_DHTU_Target *target;
+
+ target = GNUNET_new (struct GNUNET_DHTU_Target);
+ target->plugin = plugin;
+ target->mq = mq;
+ target->pk.header.size = htons (sizeof (struct PublicKey));
+ target->pk.peer_pub = *peer;
+ GNUNET_CRYPTO_hash (peer,
+ sizeof (struct GNUNET_PeerIdentity),
+ &target->peer_id.hc);
+ plugin->env->connect_cb (plugin->env->cls,
+ &target->pk.header,
+ &target->peer_id,
+ target,
+ &target->app_ctx);
+ return target;
+}
+
+
+/**
+ * Method called whenever a peer disconnects.
+ *
+ * @param cls closure
+ * @param peer peer identity this notification is about
+ * @param peer_cls closure associated with peer. given in
+ * #GNUNET_CORE_ConnectEventHandler
+ */
+static void
+core_disconnect_cb (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ void *peer_cls)
+{
+ struct Plugin *plugin = cls;
+ struct GNUNET_DHTU_Target *target = peer_cls;
+
+ plugin->env->disconnect_cb (target->app_ctx);
+ if (NULL != target->csh)
+ GNUNET_ATS_connectivity_suggest_cancel (target->csh);
+ GNUNET_free (target);
+}
+
+
+/**
+ * Find the @a hello for our identity and then pass
+ * it to the DHT as a URL. Note that we only
+ * add addresses, never remove them, due to limitations
+ * of the current peerinfo/core/transport APIs.
+ * This will change with TNG.
+ *
+ * @param cls a `struct Plugin`
+ * @param peer id of the peer, NULL for last call
+ * @param hello hello message for the peer (can be NULL)
+ * @param error message
+ */
+static void
+peerinfo_cb (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_HELLO_Message *hello,
+ const char *err_msg)
+{
+ struct Plugin *plugin = cls;
+ char *addr;
+
+ if (NULL == hello)
+ return;
+ if (NULL == peer)
+ return;
+ if (0 !=
+ GNUNET_memcmp (peer,
+ &plugin->my_identity))
+ return;
+ addr = GNUNET_HELLO_compose_uri (hello,
+ &GPI_plugins_find);
+ if (NULL == addr)
+ return;
+ GNUNET_CRYPTO_hash (&plugin->my_identity,
+ sizeof (struct GNUNET_PeerIdentity),
+ &plugin->src.my_id.hc);
+ plugin->env->address_add_cb (plugin->env->cls,
+ &plugin->src.my_id,
+ &plugin->src.pk,
+ addr,
+ &plugin->src,
+ &plugin->src.app_ctx);
+ GNUNET_free (addr);
+}
+
+
+/**
+ * Function called after #GNUNET_CORE_connect has succeeded (or failed
+ * for good). Note that the private key of the peer is intentionally
+ * not exposed here; if you need it, your process should try to read
+ * the private key file directly (which should work if you are
+ * authorized...). Implementations of this function must not call
+ * #GNUNET_CORE_disconnect (other than by scheduling a new task to
+ * do this later).
+ *
+ * @param cls closure
+ * @param my_identity ID of this peer, NULL if we failed
+ */
+static void
+core_init_cb (void *cls,
+ const struct GNUNET_PeerIdentity *my_identity)
+{
+ struct Plugin *plugin = cls;
+
+ plugin->my_identity = *my_identity;
+ plugin->nc = GNUNET_PEERINFO_notify (plugin->env->cfg,
+ GNUNET_NO,
+ &peerinfo_cb,
+ plugin);
+}
+
+
+/**
+ * Anything goes, always return #GNUNET_OK.
+ *
+ * @param cls unused
+ * @param msg message to check
+ * @return #GNUNET_OK if all is fine
+ */
+static int
+check_core_message (void *cls,
+ const struct GNUNET_MessageHeader *msg)
+{
+ (void) cls;
+ (void) msg;
+ return GNUNET_OK;
+}
+
+
+/**
+ * Handle message from CORE for the DHT. Passes it to the
+ * DHT logic.
+ *
+ * @param cls a `struct GNUNET_DHTU_Target` of the sender
+ * @param msg the message we received
+ */
+static void
+handle_core_message (void *cls,
+ const struct GNUNET_MessageHeader *msg)
+{
+ struct GNUNET_DHTU_Target *origin = cls;
+ struct Plugin *plugin = origin->plugin;
+
+ plugin->env->receive_cb (plugin->env->cls,
+ &origin->app_ctx,
+ &plugin->src.app_ctx,
+ &msg[1],
+ ntohs (msg->size) - sizeof (*msg));
+}
+
+
+/**
+ * Callback to call when network size estimate is updated.
+ *
+ * @param cls closure
+ * @param timestamp time when the estimate was received from the server (or created by the server)
+ * @param logestimate the log(Base 2) value of the current network size estimate
+ * @param std_dev standard deviation for the estimate
+ */
+static void
+nse_cb (void *cls,
+ struct GNUNET_TIME_Absolute timestamp,
+ double logestimate,
+ double std_dev)
+{
+ struct Plugin *plugin = cls;
+
+ plugin->env->network_size_cb (plugin->env->cls,
+ timestamp,
+ logestimate,
+ std_dev);
+}
+
+
+/**
+ * Exit point from the plugin.
+ *
+ * @param cls closure (our `struct Plugin`)
+ * @return NULL
+ */
+void *
+libgnunet_plugin_dhtu_gnunet_done (void *cls)
+{
+ struct GNUNET_DHTU_PluginFunctions *api = cls;
+ struct Plugin *plugin = api->cls;
+ struct HelloHandle *hh;
+
+ while (NULL != (hh = plugin->hh_head))
+ {
+ GNUNET_CONTAINER_DLL_remove (plugin->hh_head,
+ plugin->hh_tail,
+ hh);
+ GNUNET_TRANSPORT_offer_hello_cancel (hh->ohh);
+ GNUNET_free (hh);
+ }
+ if (NULL != plugin->nse)
+ GNUNET_NSE_disconnect (plugin->nse);
+ if (NULL != plugin->core)
+ GNUNET_CORE_disconnect (plugin->core);
+ if (NULL != plugin->ats)
+ GNUNET_ATS_connectivity_done (plugin->ats);
+ if (NULL != plugin->nc)
+ GNUNET_PEERINFO_notify_cancel (plugin->nc);
+ GPI_plugins_unload ();
+ GNUNET_free (plugin);
+ GNUNET_free (api);
+ return NULL;
}
@@ -252,9 +722,25 @@ libgnunet_plugin_dhtu_ip_init (void *cls)
struct GNUNET_DHTU_PluginEnvironment *env = cls;
struct GNUNET_DHTU_PluginFunctions *api;
struct Plugin *plugin;
-
+ struct GNUNET_MQ_MessageHandler handlers[] = {
+ GNUNET_MQ_hd_var_size (core_message,
+ GNUNET_MESSAGE_TYPE_DHT_CORE,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_handler_end ()
+ };
+ struct GNUNET_CRYPTO_EddsaPrivateKey *pk;
+
+ pk = GNUNET_CRYPTO_eddsa_key_create_from_configuration (env->cfg);
+ if (NULL == pk)
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
plugin = GNUNET_new (struct Plugin);
plugin->env = env;
+ plugin->src.pk.eddsa_priv = *pk;
+ GNUNET_free (pk);
api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions);
api->cls = plugin;
api->sign = &ip_sign;
@@ -263,23 +749,24 @@ libgnunet_plugin_dhtu_ip_init (void *cls)
api->hold = &ip_hold;
api->drop = &ip_drop;
api->send = &ip_send;
+ plugin->ats = GNUNET_ATS_connectivity_init (env->cfg);
+ plugin->core = GNUNET_CORE_connect (env->cfg,
+ plugin,
+ &core_init_cb,
+ &core_connect_cb,
+ &core_disconnect_cb,
+ handlers);
+ plugin->nse = GNUNET_NSE_connect (env->cfg,
+ &nse_cb,
+ plugin);
+ if ( (NULL == plugin->ats) ||
+ (NULL == plugin->core) ||
+ (NULL == plugin->nse) )
+ {
+ GNUNET_break (0);
+ libgnunet_plugin_dhtu_gnunet_done (plugin);
+ return NULL;
+ }
+ GPI_plugins_load (env->cfg);
return api;
}
-
-
-/**
- * Exit point from the plugin.
- *
- * @param cls closure (our `struct Plugin`)
- * @return NULL
- */
-void *
-libgnunet_plugin_dhtu_gnunet_done (void *cls)
-{
- struct GNUNET_DHTU_PluginFunctions *api = cls;
- struct Plugin *plugin = api->cls;
-
- GNUNET_free (plugin);
- GNUNET_free (api);
- return NULL;
-}
diff --git a/src/dhtu/plugin_dhtu_ip.c b/src/dhtu/plugin_dhtu_ip.c
index 8593a69ef..ae35adb37 100644
--- a/src/dhtu/plugin_dhtu_ip.c
+++ b/src/dhtu/plugin_dhtu_ip.c
@@ -240,7 +240,7 @@ struct Plugin
static ssize_t
ip_sign (void *cls,
const struct GNUNET_DHTU_PrivateKey *pk,
- const struct GNUNET_DHTU_SignaturePurpose *purpose,
+ const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
void **sig)
{
return 0;
@@ -262,7 +262,7 @@ ip_sign (void *cls,
static enum GNUNET_GenericReturnValue
ip_verify (void *cls,
const struct GNUNET_DHTU_PublicKey *pk,
- const struct GNUNET_DHTU_SignaturePurpose *purpose,
+ const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
const void *sig,
size_t sig_size)
{
diff --git a/src/testing/test_testing_hello_world.c b/src/dhtu/test_dhtu_ip.c
index 6300e26a4..7913cfc35 100644
--- a/src/testing/test_testing_hello_world.c
+++ b/src/dhtu/test_dhtu_ip.c
@@ -19,50 +19,32 @@
*/
/**
- * @file testing/test_testing_hello_world.c
- * @brief hello world test case
- * @author t3sserakt
+ * @file dhtu/test_dhtu_ip.c
+ * @brief Test case for the DHTU implementation for IP
+ * @author Christian Grothoff
*/
#include "platform.h"
-#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_netjail_lib.h"
#include "gnunet_util_lib.h"
-/**
- * Main function to run the test cases.
- *
- * @param cls not used.
- *
- */
-static void
-run (void *cls)
-{
- (void *) cls;
- struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
- struct GNUNET_TESTING_Command commands[] = {
- GNUNET_TESTING_cmd_hello_world_birth ("hello-world-birth-0",
- &now),
- GNUNET_TESTING_cmd_hello_world ("hello-world-0","hello-world-birth-0",""),
- GNUNET_TESTING_cmd_end ()
- };
+#define CONFIG_FILE "test_dhtu_ip.conf"
- GNUNET_TESTING_run (NULL,
- commands,
- GNUNET_TIME_UNIT_FOREVER_REL);
-}
int
main (int argc,
char *const *argv)
{
- int rv = 0;
-
- GNUNET_log_setup ("test-hello-world",
- "DEBUG",
- NULL);
-
- GNUNET_SCHEDULER_run (&run,
- NULL);
+ struct GNUNET_TESTING_Command commands[] = {
+ GNUNET_TESTING_cmd_netjail_start ("netjail-start",
+ CONFIG_FILE),
+ GNUNET_TESTING_cmd_netjail_stop ("netjail-stop",
+ CONFIG_FILE),
+ GNUNET_TESTING_cmd_end ()
+ };
- return rv;
+ return GNUNET_TESTING_main (NULL,
+ commands,
+ TIMEOUT);
}
diff --git a/src/dhtu/testing_dhtu_cmd_send.c b/src/dhtu/testing_dhtu_cmd_send.c
new file mode 100644
index 000000000..fe8e1c18a
--- /dev/null
+++ b/src/dhtu/testing_dhtu_cmd_send.c
@@ -0,0 +1,119 @@
+/*
+ This file is part of GNUnet
+ Copyright (C) 2021 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file testing/testing_dhtu_cmd_send.c
+ * @brief use DHTU to send a message
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_netjail_lib.h"
+
+
+/**
+ * State for the 'send' command.
+ */
+struct SendState
+{
+
+ /**
+ * Mandatory context for async commands.
+ */
+ struct GNUNET_TESTING_AsyncContext ac;
+
+};
+
+
+/**
+ *
+ *
+ * @param cls a `struct SendState`
+ */
+static void
+send_cleanup (void *cls)
+{
+ struct SendState *ss = cls;
+
+ GNUNET_free (ss);
+}
+
+
+/**
+ * Return trains of the ``send`` command.
+ *
+ * @param cls closure.
+ * @param[out] ret result
+ * @param trait name of the trait.
+ * @param index index number of the object to offer.
+ * @return #GNUNET_OK on success.
+ * #GNUNET_NO if no trait was found
+ */
+static enum GNUNET_GenericReturnValue
+send_traits (void *cls,
+ const void **ret,
+ const char *trait,
+ unsigned int index)
+{
+ return GNUNET_NO;
+}
+
+
+/**
+ * Run the 'send' command.
+ *
+ * @param cls closure.
+ * @param is interpreter state.
+ */
+static void
+send_run (void *cls,
+ struct GNUNET_TESTING_Interpreter *is)
+{
+ struct SendState *ss = cls;
+
+#if 0
+ other_cmd = GNUNET_TESTING_interpreter_lookup_command (ss->other_label);
+ GNUNET_TESTING_get_trait_XXX (other_cmd,
+ &data);
+#endif
+ GNUNET_TESTING_async_finish (&ss->ac);
+}
+
+
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_DHTU_cmd_send (const char *label)
+{
+ struct SendState *ss;
+
+ ss = GNUNET_new (struct SendState);
+
+ {
+ struct GNUNET_TESTING_Command cmd = {
+ .cls = ss,
+ .label = label,
+ .run = &send_run,
+ .ac = &ss->ac,
+ .cleanup = &send_cleanup,
+ .traits = &send_traits
+ };
+
+ return cmd;
+ }
+}
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am
index 5b6ba2376..3d8ec2bac 100644
--- a/src/fs/Makefile.am
+++ b/src/fs/Makefile.am
@@ -21,9 +21,7 @@ lib_LTLIBRARIES = libgnunetfs.la
plugin_LTLIBRARIES = \
libgnunet_plugin_block_fs.la
-if HAVE_TESTING
noinst_LIBRARIES = libgnunetfstest.a
-endif
libgnunetfs_la_SOURCES = \
fs_api.c fs_api.h fs.h \
@@ -71,11 +69,9 @@ libexec_PROGRAMS = \
gnunet-helper-fs-publish \
gnunet-service-fs
-if HAVE_TESTING
noinst_PROGRAMS = \
gnunet-fs-profiler \
gnunet-daemon-fsprofiler
-endif
bin_PROGRAMS = \
gnunet-auto-share \
@@ -230,7 +226,6 @@ if HAVE_BENCHMARKS
perf_gnunet_service_fs_p2p_respect
endif
-if HAVE_TESTING
check_PROGRAMS = \
test_plugin_block_fs \
test_fs_directory \
@@ -258,7 +253,6 @@ check_PROGRAMS = \
test_gnunet_service_fs_p2p \
test_gnunet_service_fs_p2p_cadet \
$(FS_BENCHMARKS)
-endif
test_plugin_block_fs_SOURCES = \
test_plugin_block_fs.c
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am
index 3aaa734f2..1380cba10 100644
--- a/src/gns/Makefile.am
+++ b/src/gns/Makefile.am
@@ -80,7 +80,9 @@ bin_PROGRAMS = \
noinst_PROGRAMS = \
gnunet-gns-benchmark
+if HAVE_PDFLATEX
bin_PROGRAMS += gnunet-bcd
+endif
REST_PLUGIN = libgnunet_plugin_rest_gns.la
@@ -169,7 +171,7 @@ gnunet_dns2gns_LDADD = \
$(GN_LIBINTL)
if HAVE_SUDO
-SUDO_OR_DOAS_BINARY= $(SUDO_BINARY)
+SUDO_OR_DOAS_BINARY= $(SUDO_BINARY) -n
else
if HAVE_DOAS_BINARY
SUDO_OR_DOAS_BINARY= $(DOAS_BINARY)
diff --git a/src/gns/gnunet-bcd.c b/src/gns/gnunet-bcd.c
index a2e94089c..83efcfba5 100644
--- a/src/gns/gnunet-bcd.c
+++ b/src/gns/gnunet-bcd.c
@@ -30,394 +30,522 @@
#include "gnunet_identity_service.h"
#include "gnunet_mhd_compat.h"
+struct StaticResource
+{
+ /**
+ * Handle to file on disk.
+ */
+ struct GNUNET_DISK_FileHandle *handle;
+
+ /**
+ * Size in bytes of the file.
+ */
+ uint64_t size;
+
+ /**
+ * Cached response object to send to clients.
+ */
+ struct MHD_Response *response;
+};
+
+struct ParameterMap
+{
+ /**
+ * Name of the parameter from the request.
+ */
+ char *name;
+
+ /**
+ * Name of the definition in the TeX output.
+ */
+ char *definition;
+};
+
/**
- * Error page to display if submitted GNS key is invalid.
+ * Handle to the HTTP server as provided by libmicrohttpd
*/
-#define INVALID_GNSKEY \
- "<html><head><title>Error</title><body>Invalid GNS public key given.</body></html>"
+static struct MHD_Daemon *httpd = NULL;
/**
- * Error page to display on 404.
+ * Our primary task for the HTTPD.
*/
-#define NOT_FOUND \
- "<html><head><title>Error</title><body>404 not found</body></html>"
+static struct GNUNET_SCHEDULER_Task *httpd_task = NULL;
/**
- * Handle to the HTTP server as provided by libmicrohttpd
+ * Index file resource (simple result).
*/
-static struct MHD_Daemon *daemon_handle;
+static struct StaticResource *index_simple = NULL;
/**
- * Our configuration.
+ * Index file resource (full result).
*/
-static const struct GNUNET_CONFIGURATION_Handle *cfg;
+static struct StaticResource *index_full = NULL;
/**
- * Our primary task for the HTTPD.
+ * Error: invalid gns key.
*/
-static struct GNUNET_SCHEDULER_Task *http_task;
+static struct StaticResource *key_error = NULL;
/**
- * Our main website.
+ * Error: 404
*/
-static struct MHD_Response *main_response;
+static struct StaticResource *notfound_error = NULL;
/**
- * Error: invalid gns key.
+ * Errors after receiving the form data.
*/
-static struct MHD_Response *invalid_gnskey_response;
+static struct StaticResource *internal_error = NULL;
/**
- * Error: 404
+ * Other errors.
*/
-static struct MHD_Response *not_found_response;
+static struct StaticResource *forbidden_error = NULL;
/**
- * Absolute name of the 'gns-bcd.tex' file.
+ * Full path to the TeX template file (simple result)
*/
-static char *resfile;
+static char *tex_file_simple = NULL;
/**
- * Port number.
+ * Full path to the TeX template file (full result)
*/
-static uint16_t port = 8888;
+static char *tex_file_full = NULL;
+/**
+ * Full path to the TeX template file (PNG result)
+ */
+static char *tex_file_png = NULL;
-struct Entry
-{
- const char *formname;
- const char *texname;
+/**
+ * Used as a sort of singleton to send exactly one 100 CONTINUE per request.
+ */
+static int continue_100 = 100;
+
+/**
+ * Map of names with TeX definitions, used during PDF generation.
+ */
+static const struct ParameterMap pmap[] = {
+ {"prefix", "prefix"},
+ {"name", "name"},
+ {"suffix", "suffix"},
+ {"street", "street"},
+ {"city", "city"},
+ {"phone", "phone"},
+ {"fax", "fax"},
+ {"email", "email"},
+ {"homepage", "homepage"},
+ {"org", "organization"},
+ {"department", "department"},
+ {"subdepartment", "subdepartment"},
+ {"jobtitle", "jobtitle"},
+ {NULL, NULL},
};
+/**
+ * Port number.
+ */
+static uint16_t port = 8888;
/**
- * Main request handler.
+ * Task ran at shutdown to clean up everything.
+ *
+ * @param cls unused
*/
-static MHD_RESULT
-access_handler_callback (void *cls,
- struct MHD_Connection *connection,
- const char *url,
- const char *method,
- const char *version,
- const char *upload_data,
- size_t *upload_data_size,
- void **con_cls)
+static void
+do_shutdown (void *cls)
{
- static int dummy;
- static const struct Entry map[] = { { "prefix", "prefix" },
- { "name", "name" },
- { "suffix", "suffix" },
- { "street", "street" },
- { "city", "city" },
- { "phone", "phone" },
- { "fax", "fax" },
- { "email", "email" },
- { "homepage", "homepage" },
- { "orga", "orga" },
- { "departmenti18n", "departmentde" },
- { "departmenten", "departmenten" },
- { "subdepartmenti18n",
- "subdepartmentde" },
- { "subdepartmenten", "subdepartmenten" },
- { "jobtitlei18n", "jobtitlegerman" },
- { "jobtitleen", "jobtitleenglish" },
- { "subdepartmenten", "subdepartmenten" },
- { NULL, NULL } };
-
- (void) cls;
- (void) version;
- (void) upload_data;
- (void) upload_data_size;
- if (0 != strcmp (method, MHD_HTTP_METHOD_GET))
+ /* We cheat a bit here: the file descriptor is implicitly closed by MHD, so
+ calling `GNUNET_DISK_file_close' would generate a spurious warning message
+ in the log. Since that function does nothing but close the descriptor and
+ free the allocated memory, After destroying the response all that's left to
+ do is call `GNUNET_free'. */
+ if (NULL != index_simple)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _ ("Refusing `%s' request to HTTP server\n"),
- method);
- return MHD_NO;
+ MHD_destroy_response (index_simple->response);
+ GNUNET_free (index_simple->handle);
+ GNUNET_free (index_simple);
}
- if (NULL == *con_cls)
+ if (NULL != index_full)
{
- (*con_cls) = &dummy;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending 100 CONTINUE reply\n");
- return MHD_YES; /* send 100 continue */
+ MHD_destroy_response (index_full->response);
+ GNUNET_free (index_full->handle);
+ GNUNET_free (index_full);
}
- if (0 == strcasecmp (url, "/"))
- return MHD_queue_response (connection, MHD_HTTP_OK, main_response);
- if (0 == strcasecmp (url, "/submit.pdf"))
+ if (NULL != key_error)
{
- unsigned int i;
- char *p;
- char *tmp;
- char *deffile;
- struct GNUNET_IDENTITY_PublicKey pub;
- size_t slen;
- FILE *f;
- struct stat st;
- struct MHD_Response *response;
- int fd;
- MHD_RESULT ret;
-
- const char *gpg_fp = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "gpgfingerprint");
- const char *gns_nick = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "gnsnick");
- const char *gnskey =
- MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "gnskey");
- if ((NULL == gnskey) ||
- (GNUNET_OK !=
- GNUNET_IDENTITY_public_key_from_string (gnskey,
- &pub)))
- {
- return MHD_queue_response (connection,
- MHD_HTTP_OK,
- invalid_gnskey_response);
- }
- tmp = GNUNET_DISK_mkdtemp (gnskey);
- if (NULL == tmp)
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "mktemp", gnskey);
- return MHD_NO;
- }
- GNUNET_asprintf (&deffile, "%s%s%s", tmp, DIR_SEPARATOR_STR, "def.tex");
- f = fopen (deffile, "w");
- if (NULL == f)
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", deffile);
- GNUNET_free (deffile);
- GNUNET_DISK_directory_remove (tmp);
- GNUNET_free (tmp);
- return MHD_NO;
- }
- for (i = 0; NULL != map[i].formname; i++)
- {
- const char *val = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- map[i].formname);
- if (NULL != val)
- fprintf (f, "\\def\\%s{%s}\n", map[i].texname, val);
- else
- fprintf (f, "\\def\\%s{}\n", map[i].texname);
- }
- if (NULL != gpg_fp)
- {
- char *gpg1;
- char *gpg2;
-
- slen = strlen (gpg_fp);
- gpg1 = GNUNET_strndup (gpg_fp, slen / 2);
- gpg2 = GNUNET_strdup (&gpg_fp[slen / 2]);
- fprintf (f, "\\def\\gpglineone{%s}\n\\def\\gpglinetwo{%s}\n", gpg1, gpg2);
- GNUNET_free (gpg2);
- GNUNET_free (gpg1);
- }
- fprintf (f,
- "\\def\\gns{%s/%s}\n",
- gnskey,
- (NULL == gns_nick) ? "" : gns_nick);
- fclose (f);
- GNUNET_asprintf (
- &p,
- "cd %s; cp %s gns-bcd.tex | pdflatex --enable-write18 gns-bcd.tex > /dev/null 2> /dev/null",
- tmp,
- resfile);
- GNUNET_free (deffile);
- ret = system (p);
- if (WIFSIGNALED (ret) || (0 != WEXITSTATUS (ret)))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "system", p);
- GNUNET_asprintf (&deffile, "%s%s%s", tmp, DIR_SEPARATOR_STR, "gns-bcd.pdf");
- fd = open (deffile, O_RDONLY);
- if (-1 == fd)
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", deffile);
- GNUNET_free (deffile);
- GNUNET_free (p);
- GNUNET_DISK_directory_remove (tmp);
- GNUNET_free (tmp);
- return MHD_NO;
- }
- GNUNET_break (0 == stat (deffile, &st));
- if (NULL ==
- (response = MHD_create_response_from_fd ((size_t) st.st_size, fd)))
- {
- GNUNET_break (0);
- GNUNET_break (0 == close (fd));
- GNUNET_free (deffile);
- GNUNET_free (p);
- GNUNET_DISK_directory_remove (tmp);
- GNUNET_free (tmp);
- return MHD_NO;
- }
- (void) MHD_add_response_header (response,
- MHD_HTTP_HEADER_CONTENT_TYPE,
- "application/pdf");
- ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
- MHD_destroy_response (response);
- GNUNET_free (deffile);
- GNUNET_free (p);
- GNUNET_DISK_directory_remove (tmp);
- GNUNET_free (tmp);
- return ret;
+ MHD_destroy_response (key_error->response);
+ GNUNET_free (key_error->handle);
+ GNUNET_free (key_error);
+ }
+ if (NULL != notfound_error)
+ {
+ MHD_destroy_response (notfound_error->response);
+ GNUNET_free (notfound_error->handle);
+ GNUNET_free (notfound_error);
+ }
+ if (NULL != internal_error)
+ {
+ MHD_destroy_response (internal_error->response);
+ GNUNET_free (internal_error->handle);
+ GNUNET_free (internal_error);
+ }
+ if (NULL != forbidden_error)
+ {
+ MHD_destroy_response (forbidden_error->response);
+ GNUNET_free (forbidden_error->handle);
+ GNUNET_free (forbidden_error);
}
- return MHD_queue_response (connection,
- MHD_HTTP_NOT_FOUND,
- not_found_response);
-}
-
-
-/**
- * Function that queries MHD's select sets and
- * starts the task waiting for them.
- */
-static struct GNUNET_SCHEDULER_Task *
-prepare_daemon (struct MHD_Daemon *daemon_handle);
+ if (NULL != httpd_task)
+ {
+ GNUNET_SCHEDULER_cancel (httpd_task);
+ }
+ if (NULL != httpd)
+ {
+ MHD_stop_daemon (httpd);
+ }
+}
/**
- * Call MHD to process pending requests and then go back
- * and schedule the next run.
+ * Called when the HTTP server has some pending operations.
+ *
+ * @param cls unused
*/
static void
-run_daemon (void *cls)
-{
- struct MHD_Daemon *daemon_handle = cls;
-
- http_task = NULL;
- GNUNET_assert (MHD_YES == MHD_run (daemon_handle));
- http_task = prepare_daemon (daemon_handle);
-}
-
+do_httpd (void *cls);
/**
- * Function that queries MHD's select sets and
- * starts the task waiting for them.
+ * Schedule a task to run MHD.
*/
-static struct GNUNET_SCHEDULER_Task *
-prepare_daemon (struct MHD_Daemon *daemon_handle)
+static void
+run_httpd (void)
{
- struct GNUNET_SCHEDULER_Task *ret;
fd_set rs;
fd_set ws;
fd_set es;
- struct GNUNET_NETWORK_FDSet *wrs;
- struct GNUNET_NETWORK_FDSet *wws;
- int max;
- MHD_UNSIGNED_LONG_LONG timeout;
- int haveto;
- struct GNUNET_TIME_Relative tv;
+
+ struct GNUNET_NETWORK_FDSet *grs = GNUNET_NETWORK_fdset_create ();
+ struct GNUNET_NETWORK_FDSet *gws = GNUNET_NETWORK_fdset_create ();
+ struct GNUNET_NETWORK_FDSet *ges = GNUNET_NETWORK_fdset_create ();
FD_ZERO (&rs);
FD_ZERO (&ws);
FD_ZERO (&es);
- wrs = GNUNET_NETWORK_fdset_create ();
- wws = GNUNET_NETWORK_fdset_create ();
- max = -1;
- GNUNET_assert (MHD_YES == MHD_get_fdset (daemon_handle, &rs, &ws, &es, &max));
- haveto = MHD_get_timeout (daemon_handle, &timeout);
- if (haveto == MHD_YES)
- tv.rel_value_us = (uint64_t) timeout * 1000LL;
- else
- tv = GNUNET_TIME_UNIT_FOREVER_REL;
- GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1);
- GNUNET_NETWORK_fdset_copy_native (wws, &ws, max + 1);
- ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH,
- tv,
- wrs,
- wws,
- &run_daemon,
- daemon_handle);
- GNUNET_NETWORK_fdset_destroy (wrs);
- GNUNET_NETWORK_fdset_destroy (wws);
- return ret;
+
+ int max = -1;
+ GNUNET_assert (MHD_YES == MHD_get_fdset (httpd, &rs, &ws, &es, &max));
+
+ unsigned MHD_LONG_LONG timeout = 0;
+ struct GNUNET_TIME_Relative gtime = GNUNET_TIME_UNIT_FOREVER_REL;
+ if (MHD_YES == MHD_get_timeout (httpd, &timeout))
+ {
+ gtime = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
+ timeout);
+ }
+
+ GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1);
+ GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1);
+ GNUNET_NETWORK_fdset_copy_native (ges, &es, max + 1);
+
+ httpd_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH,
+ gtime,
+ grs,
+ gws,
+ &do_httpd,
+ NULL);
+ GNUNET_NETWORK_fdset_destroy (grs);
+ GNUNET_NETWORK_fdset_destroy (gws);
+ GNUNET_NETWORK_fdset_destroy (ges);
}
+/**
+ * Called when the HTTP server has some pending operations.
+ *
+ * @param cls unused
+ */
+static void
+do_httpd (void *cls)
+{
+ httpd_task = NULL;
+ MHD_run (httpd);
+ run_httpd ();
+}
/**
- * Start server offering our hostlist.
+ * Send a response back to a connected client.
*
- * @return #GNUNET_OK on success
+ * @param cls unused
+ * @param connection the connection with the client
+ * @param url the requested address
+ * @param method the HTTP method used
+ * @param version the protocol version (including the "HTTP/" part)
+ * @param upload_data data sent with a POST request
+ * @param upload_data_size length in bytes of the POST data
+ * @param ptr used to pass data between request handling phases
+ * @return MHD_NO on error
*/
-static int
-server_start ()
+static MHD_RESULT
+create_response (void *cls,
+ struct MHD_Connection *connection,
+ const char *url,
+ const char *method,
+ const char *version,
+ const char *upload_data,
+ size_t *upload_data_size,
+ void **ptr)
{
- if (0 == port)
+ (void) cls;
+ (void) version;
+ (void) upload_data;
+ (void) upload_data_size;
+
+ bool isget = (0 == strcmp (method, MHD_HTTP_METHOD_GET));
+ bool ishead = (0 == strcmp (method, MHD_HTTP_METHOD_HEAD));
+
+ if (!isget && !ishead)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Invalid port number %u. Exiting.\n"),
- port);
- return GNUNET_SYSERR;
+ return MHD_queue_response (connection,
+ MHD_HTTP_NOT_IMPLEMENTED,
+ forbidden_error->response);
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _ ("Businesscard HTTP server starts on %u\n"),
- port);
- daemon_handle = MHD_start_daemon (MHD_USE_DUAL_STACK | MHD_USE_DEBUG,
- port,
- NULL /* accept_policy_callback */,
- NULL,
- &access_handler_callback,
- NULL,
- MHD_OPTION_CONNECTION_LIMIT,
- (unsigned int) 512,
- MHD_OPTION_PER_IP_CONNECTION_LIMIT,
- (unsigned int) 2,
- MHD_OPTION_CONNECTION_TIMEOUT,
- (unsigned int) 60,
- MHD_OPTION_CONNECTION_MEMORY_LIMIT,
- (size_t) (16 * 1024),
- MHD_OPTION_END);
- if (NULL == daemon_handle)
+
+ if (ishead)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Could not start businesscard HTTP server on port %u\n"),
- (unsigned int) port);
- return GNUNET_SYSERR;
+ /* Dedicated branch in case we want to provide a different result for some
+ reason (e.g. a non-web browser application using the web UI) */
+ return MHD_queue_response (connection,
+ MHD_HTTP_OK,
+ index_simple->response);
}
- http_task = prepare_daemon (daemon_handle);
- return GNUNET_OK;
-}
+ /* Send a 100 CONTINUE response to tell clients that the result of the
+ request might take some time */
+ if (NULL == *ptr)
+ {
+ *ptr = &continue_100;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending 100 CONTINUE\n");
+ return MHD_YES;
+ }
-/**
- * Stop HTTP server.
- */
-static void
-server_stop (void *cls)
-{
- (void) cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "HTTP server shutdown\n");
- if (NULL != http_task)
+ if (0 == strcmp ("/", url))
+ {
+ return MHD_queue_response (connection,
+ MHD_HTTP_OK,
+ index_simple->response);
+ }
+
+ if (0 == strcmp ("/full", url))
+ {
+ return MHD_queue_response (connection,
+ MHD_HTTP_OK,
+ index_full->response);
+ }
+
+ bool isfull = (0 == strcmp ("/submit/full", url));
+ bool issimple = (0 == strcmp ("/submit/simple", url));
+
+ if (!isfull && !issimple)
+ {
+ return MHD_queue_response (connection,
+ MHD_HTTP_NOT_FOUND,
+ notfound_error->response);
+ }
+
+ const char *gpgfp = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "gpgfingerprint");
+ const char *gnsnick = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "gnsnick");
+ const char *gnskey = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "gnskey");
+ const char *qrpng = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "gnspng");
+
+ struct GNUNET_IDENTITY_PublicKey pk;
+ if (NULL == gnskey
+ || GNUNET_OK != GNUNET_IDENTITY_public_key_from_string (gnskey, &pk))
+ {
+ return MHD_queue_response (connection,
+ MHD_HTTP_BAD_REQUEST,
+ key_error->response);
+ }
+
+ char *tmpd = GNUNET_DISK_mkdtemp (gnskey);
+ if (NULL == tmpd)
+ {
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "mktemp", gnskey);
+ return MHD_queue_response (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ internal_error->response);
+ }
+
+ char *defpath = NULL;
+ GNUNET_asprintf (&defpath, "%s%s%s", tmpd, DIR_SEPARATOR_STR, "def.tex");
+
+ FILE *deffile = fopen (defpath, "w");
+ if (NULL == deffile)
{
- GNUNET_SCHEDULER_cancel (http_task);
- http_task = NULL;
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", defpath);
+ GNUNET_free (defpath);
+ GNUNET_DISK_directory_remove (tmpd);
+ GNUNET_free (tmpd);
+ return MHD_queue_response (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ internal_error->response);
}
- if (NULL != daemon_handle)
+
+ GNUNET_free (defpath);
+
+ for (size_t i=0; NULL!=pmap[i].name; ++i)
{
- MHD_stop_daemon (daemon_handle);
- daemon_handle = NULL;
+ const char *value = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ pmap[i].name);
+ fprintf (deffile,
+ "\\def\\%s{%s}\n",
+ pmap[i].definition,
+ (NULL == value) ? "" : value);
}
- if (NULL != main_response)
+
+ if (NULL != gpgfp)
{
- MHD_destroy_response (main_response);
- main_response = NULL;
+ size_t len = strlen (gpgfp);
+ char *line1 = GNUNET_strndup (gpgfp, len/2);
+ char *line2 = GNUNET_strdup (&gpgfp[len/2]);
+ fprintf (deffile,
+ "\\def\\gpglineone{%s}\n\\def\\gpglinetwo{%s}\n",
+ line1,
+ line2);
}
- if (NULL != invalid_gnskey_response)
+
+ fprintf (deffile,
+ "\\def\\gns{%s/%s}\n",
+ gnskey,
+ (NULL == gnsnick) ? "" : gnsnick);
+
+ fclose (deffile);
+
+ char *command = NULL;
+ GNUNET_asprintf (&command,
+ "cd %s; cp %s gns-bcd.tex; "
+ "pdflatex %s gns-bcd.tex >/dev/null 2>&1",
+ tmpd,
+ (isfull) ? tex_file_full :
+ ((NULL == qrpng) ? tex_file_simple : tex_file_png),
+ (NULL == qrpng) ? "" : "-shell-escape");
+
+ int ret = system (command);
+
+ GNUNET_free (command);
+
+ if (WIFSIGNALED (ret) || 0 != WEXITSTATUS (ret))
{
- MHD_destroy_response (invalid_gnskey_response);
- invalid_gnskey_response = NULL;
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "system", command);
}
- if (NULL != not_found_response)
+
+ GNUNET_asprintf (&defpath,
+ "%s%s%s",
+ tmpd,
+ DIR_SEPARATOR_STR,
+ (NULL == qrpng) ? "gns-bcd.pdf" : "gns-bcd.png");
+
+ int pdf = open (defpath, O_RDONLY);
+ if (-1 == pdf)
{
- MHD_destroy_response (not_found_response);
- not_found_response = NULL;
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", defpath);
+ GNUNET_free (defpath);
+ GNUNET_DISK_directory_remove (tmpd);
+ GNUNET_free (tmpd);
+ return MHD_queue_response (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ internal_error->response);
}
- if (NULL != resfile)
+
+ struct stat statret;
+ GNUNET_break (0 == stat (defpath, &statret));
+
+ GNUNET_free (defpath);
+
+ struct MHD_Response *pdfrs =
+ MHD_create_response_from_fd ((size_t) statret.st_size, pdf);
+ if (NULL == pdfrs)
{
- GNUNET_free (resfile);
- resfile = NULL;
+ GNUNET_break (0);
+ GNUNET_break (0 == close (pdf));
+ GNUNET_DISK_directory_remove (tmpd);
+ GNUNET_free (tmpd);
+ return MHD_queue_response (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ internal_error->response);
}
+
+ MHD_add_response_header (pdfrs,
+ MHD_HTTP_HEADER_CONTENT_TYPE,
+ (NULL == qrpng) ? "application/pdf" : "image/png");
+ MHD_add_response_header (pdfrs,
+ MHD_HTTP_HEADER_CONTENT_DISPOSITION,
+ (NULL == qrpng) ?
+ "attachment; filename=\"gns-business-card.pdf\"" :
+ "attachment; filename=\"gns-qr-code.png\"");
+ MHD_RESULT r = MHD_queue_response (connection, MHD_HTTP_OK, pdfrs);
+
+ MHD_destroy_response (pdfrs);
+ GNUNET_DISK_directory_remove (tmpd);
+ GNUNET_free (tmpd);
+
+ return r;
}
+/**
+ * Open a file on disk and generate a response for it.
+ *
+ * @param name name of the file to open
+ * @param basedir directory where the file is located
+ * @return NULL on error
+ */
+static struct StaticResource *
+open_static_resource (const char *name, const char *basedir)
+{
+ char *fullname = NULL;
+ GNUNET_asprintf (&fullname, "%s%s%s", basedir, DIR_SEPARATOR_STR, name);
+
+ struct GNUNET_DISK_FileHandle *f =
+ GNUNET_DISK_file_open (fullname,
+ GNUNET_DISK_OPEN_READ,
+ GNUNET_DISK_PERM_NONE);
+
+ GNUNET_free (fullname);
+
+ if (NULL == f)
+ {
+ return NULL;
+ }
+
+ off_t size = 0;
+ if (GNUNET_SYSERR == GNUNET_DISK_file_handle_size (f, &size))
+ {
+ GNUNET_DISK_file_close (f);
+ return NULL;
+ }
+
+ struct MHD_Response *response = MHD_create_response_from_fd64 (size, f->fd);
+
+ if (NULL == response)
+ {
+ GNUNET_DISK_file_close (f);
+ return NULL;
+ }
+
+ struct StaticResource *res = GNUNET_new (struct StaticResource);
+ res->handle = f;
+ res->size = (uint64_t) size;
+ res->response = response;
+
+ return res;
+}
/**
* Main function that will be run.
@@ -433,63 +561,84 @@ run (void *cls,
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *c)
{
- struct stat st;
- char *dir;
- char *fn;
- int fd;
-
(void) cls;
(void) args;
(void) cfgfile;
- cfg = c;
- dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
- GNUNET_assert (NULL != dir);
- GNUNET_asprintf (&fn, "%s%s%s", dir, DIR_SEPARATOR_STR, "gns-bcd.html");
- GNUNET_asprintf (&resfile, "%s%s%s", dir, DIR_SEPARATOR_STR, "gns-bcd.tex");
- GNUNET_free (dir);
- fd = open (fn, O_RDONLY);
- if (-1 == fd)
+
+ if (0 == port)
{
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", fn);
- GNUNET_free (fn);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Invalid port number %u\n"),
+ port);
+ GNUNET_SCHEDULER_shutdown ();
return;
}
- if (0 != stat (fn, &st))
+
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
+
+ char *datadir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
+ GNUNET_assert (NULL != datadir);
+
+ GNUNET_asprintf (&tex_file_full,
+ "%s%s%s",
+ datadir,
+ DIR_SEPARATOR_STR,
+ "gns-bcd.tex");
+ GNUNET_asprintf (&tex_file_simple,
+ "%s%s%s",
+ datadir,
+ DIR_SEPARATOR_STR,
+ "gns-bcd-simple.tex");
+ GNUNET_asprintf(&tex_file_png,
+ "%s%s%s",
+ datadir,
+ DIR_SEPARATOR_STR,
+ "gns-bcd-png.tex");
+
+ index_simple = open_static_resource ("gns-bcd-simple.html", datadir);
+ index_full = open_static_resource ("gns-bcd.html", datadir);
+ key_error = open_static_resource ("gns-bcd-invalid-key.html", datadir);
+ notfound_error = open_static_resource ("gns-bcd-not-found.html", datadir);
+ internal_error = open_static_resource ("gns-bcd-internal-error.html", datadir);
+ forbidden_error = open_static_resource ("gns-bcd-forbidden.html", datadir);
+
+ GNUNET_free (datadir);
+
+ if ((NULL == index_simple) || (NULL == index_full)
+ || (NULL == key_error) || (NULL == notfound_error)
+ || (NULL == internal_error) || (NULL == forbidden_error))
{
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", fn);
- GNUNET_free (fn);
- GNUNET_break (0 == close (fd));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Unable to set up the daemon\n"));
+ GNUNET_SCHEDULER_shutdown ();
return;
}
- GNUNET_free (fn);
- if (NULL ==
- (main_response = MHD_create_response_from_fd ((size_t) st.st_size, fd)))
+
+ int flags = MHD_USE_DUAL_STACK | MHD_USE_DEBUG | MHD_ALLOW_SUSPEND_RESUME;
+ do
{
- GNUNET_break (0);
- GNUNET_break (0 == close (fd));
+ httpd = MHD_start_daemon (flags,
+ port,
+ NULL, NULL,
+ &create_response, NULL,
+ MHD_OPTION_CONNECTION_LIMIT, 512,
+ MHD_OPTION_PER_IP_CONNECTION_LIMIT, 2,
+ MHD_OPTION_CONNECTION_TIMEOUT, 60,
+ MHD_OPTION_CONNECTION_MEMORY_LIMIT, 16 * 1024,
+ MHD_OPTION_END);
+ flags = MHD_USE_DEBUG;
+ } while (NULL == httpd && flags != MHD_USE_DEBUG);
+
+ if (NULL == httpd)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Failed to start HTTP server\n"));
+ GNUNET_SCHEDULER_shutdown ();
return;
}
- (void) MHD_add_response_header (main_response,
- MHD_HTTP_HEADER_CONTENT_TYPE,
- "text/html");
- invalid_gnskey_response =
- MHD_create_response_from_buffer (strlen (INVALID_GNSKEY),
- INVALID_GNSKEY,
- MHD_RESPMEM_PERSISTENT);
- (void) MHD_add_response_header (invalid_gnskey_response,
- MHD_HTTP_HEADER_CONTENT_TYPE,
- "text/html");
- not_found_response = MHD_create_response_from_buffer (strlen (NOT_FOUND),
- NOT_FOUND,
- MHD_RESPMEM_PERSISTENT);
- (void) MHD_add_response_header (not_found_response,
- MHD_HTTP_HEADER_CONTENT_TYPE,
- "text/html");
- if (GNUNET_OK != server_start ())
- return;
- GNUNET_SCHEDULER_add_shutdown (&server_stop, NULL);
-}
+ run_httpd ();
+}
/**
* The main function for gnunet-gns.
@@ -502,32 +651,25 @@ int
main (int argc, char *const *argv)
{
struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_option_uint16 ('p',
- "port",
- "PORT",
- gettext_noop (
- "Run HTTP serve on port PORT (default is 8888)"),
- &port),
- GNUNET_GETOPT_OPTION_END
+ GNUNET_GETOPT_option_uint16 (
+ 'p',
+ "port",
+ "PORT",
+ gettext_noop ("Run HTTP server on port PORT (default is 8888)"),
+ &port),
+ GNUNET_GETOPT_OPTION_END,
};
- int ret;
-
- if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
- return 2;
- GNUNET_log_setup ("gnunet-bcd", "WARNING", NULL);
- ret = (GNUNET_OK ==
- GNUNET_PROGRAM_run (argc,
- argv,
- "gnunet-bcd",
- _ ("GNUnet HTTP server to create business cards"),
- options,
- &run,
- NULL))
- ? 0
- : 1;
- GNUNET_free_nz ((void *) argv);
- return ret;
-}
+ return ((GNUNET_OK ==
+ GNUNET_PROGRAM_run (argc,
+ argv,
+ "gnunet-bcd",
+ _ ("GNUnet HTTP server to create business cards"),
+ options,
+ &run,
+ NULL))
+ ? 0
+ : 1);
+}
/* end of gnunet-bcd.c */
diff --git a/src/identity/Makefile.am b/src/identity/Makefile.am
index e806f0059..59ace6c41 100644
--- a/src/identity/Makefile.am
+++ b/src/identity/Makefile.am
@@ -67,11 +67,9 @@ gnunet_identity_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
$(GN_LIBINTL)
-if HAVE_TESTING
check_PROGRAMS = \
test_identity \
test_identity_defaults
-endif
if ENABLE_TEST_RUN
AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c
index 22371f91a..08a975e65 100644
--- a/src/identity/identity_api.c
+++ b/src/identity/identity_api.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2013, 2016 GNUnet e.V.
+ Copyright (C) 2013, 2016, 2021 GNUnet e.V.
GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
@@ -1020,7 +1020,9 @@ GNUNET_IDENTITY_write_key_to_buffer (const struct
return -1;
if (length < 0)
return -2;
- GNUNET_memcpy (buffer, key, length);
+ GNUNET_memcpy (buffer, &(key->type), sizeof (key->type));
+ GNUNET_memcpy (buffer + sizeof (key->type), &(key->ecdsa_key), length
+ - sizeof (key->type));
return length;
}
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index 9c22b5977..e4b02b8ee 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -118,6 +118,7 @@ gnunetinclude_HEADERS = \
gnunet_testing_lib.h \
gnunet_testing_plugin.h \
gnunet_testing_ng_lib.h \
+ gnunet_testing_netjail_lib.h \
gnunet_time_lib.h \
gnunet_transport_service.h \
gnunet_transport_application_service.h \
diff --git a/src/include/gnu_name_system_record_types.h b/src/include/gnu_name_system_record_types.h
index b2cf45dc8..22b2c472e 100644
--- a/src/include/gnu_name_system_record_types.h
+++ b/src/include/gnu_name_system_record_types.h
@@ -127,6 +127,16 @@ extern "C" {
*/
#define GNUNET_GNSRECORD_TYPE_EDKEY 65556
+/**
+ * Encoding for Robust Immutable Storage (ERIS) binary read capability
+ */
+#define GNUNET_GNSRECORD_TYPE_ERIS_READ_CAPABILITY 65557
+
+/**
+ * Record type to share an entry of a messenger room
+ */
+#define GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY 65558
+
#if 0 /* keep Emacsens' auto-indent happy */
{
diff --git a/src/include/gnunet_abd_service.h b/src/include/gnunet_abd_service.h
index afec880f1..21f668a8d 100644
--- a/src/include/gnunet_abd_service.h
+++ b/src/include/gnunet_abd_service.h
@@ -103,7 +103,7 @@ struct GNUNET_ABD_DelegationRecordSet
/**
* Public key of the subject this attribute was delegated to
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
+ struct GNUNET_IDENTITY_PublicKey subject_key;
/**
* Length of attribute, may be 0
@@ -123,7 +123,7 @@ struct GNUNET_ABD_DelegationSet
/**
* Public key of the subject this attribute was delegated to
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
+ struct GNUNET_IDENTITY_PublicKey subject_key;
uint32_t subject_attribute_len;
@@ -143,12 +143,12 @@ struct GNUNET_ABD_Delegation
/**
* The issuer of the delegation
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
+ struct GNUNET_IDENTITY_PublicKey issuer_key;
/**
* Public key of the subject this attribute was delegated to
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
+ struct GNUNET_IDENTITY_PublicKey subject_key;
/**
* Length of the attribute
@@ -181,17 +181,17 @@ struct GNUNET_ABD_Delegate
/**
* The issuer of the credential
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
+ struct GNUNET_IDENTITY_PublicKey issuer_key;
/**
* Public key of the subject this credential was issued to
*/
- struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
+ struct GNUNET_IDENTITY_PublicKey subject_key;
/**
* Signature of this credential
*/
- struct GNUNET_CRYPTO_EcdsaSignature signature;
+ struct GNUNET_IDENTITY_Signature signature;
/**
* Expiration of this credential
@@ -318,9 +318,9 @@ typedef void (*GNUNET_ABD_RemoveDelegateResultProcessor) (void *cls,
*/
struct GNUNET_ABD_Request*
GNUNET_ABD_verify (struct GNUNET_ABD_Handle *handle,
- const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key,
+ const struct GNUNET_IDENTITY_PublicKey *issuer_key,
const char *issuer_attribute,
- const struct GNUNET_CRYPTO_EcdsaPublicKey *subject_key,
+ const struct GNUNET_IDENTITY_PublicKey *subject_key,
uint32_t delegate_count,
const struct GNUNET_ABD_Delegate *delegates,
enum GNUNET_ABD_AlgoDirectionFlags direction,
@@ -331,9 +331,9 @@ struct GNUNET_ABD_Request*
struct GNUNET_ABD_Request*
GNUNET_ABD_collect (struct GNUNET_ABD_Handle *handle,
- const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key,
+ const struct GNUNET_IDENTITY_PublicKey *issuer_key,
const char *issuer_attribute,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *subject_key,
+ const struct GNUNET_IDENTITY_PrivateKey *subject_key,
enum GNUNET_ABD_AlgoDirectionFlags direction,
GNUNET_ABD_CredentialResultProcessor proc,
void *proc_cls,
@@ -356,7 +356,7 @@ struct GNUNET_ABD_Request *
GNUNET_ABD_add_delegation (struct GNUNET_ABD_Handle *handle,
struct GNUNET_IDENTITY_Ego *issuer,
const char *attribute,
- struct GNUNET_CRYPTO_EcdsaPublicKey *subject,
+ struct GNUNET_IDENTITY_PublicKey *subject,
const char *delegated_attribute,
GNUNET_ABD_DelegateResultProcessor proc,
void *proc_cls);
@@ -389,8 +389,8 @@ GNUNET_ABD_remove_delegation (struct GNUNET_ABD_Handle *handle,
* @return handle to the queued request
*/
struct GNUNET_ABD_Delegate*
-GNUNET_ABD_delegate_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
- struct GNUNET_CRYPTO_EcdsaPublicKey *subject,
+GNUNET_ABD_delegate_issue (const struct GNUNET_IDENTITY_PrivateKey *issuer,
+ struct GNUNET_IDENTITY_PublicKey *subject,
const char *iss_attr,
const char *sub_attr,
struct GNUNET_TIME_Absolute *expiration);
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index ca3ddceaa..4472d3ee8 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -151,10 +151,10 @@ enum GNUNET_GenericReturnValue
*/
#if __BYTE_ORDER == __LITTLE_ENDIAN
-#if defined(__linux__)
-#define BYTE_SWAP_16(x) __bswap_16 (x)
-#define BYTE_SWAP_32(x) __bswap_32 (x)
-#define BYTE_SWAP_64(x) __bswap_64 (x)
+#ifdef HAVE_BYTESWAP_H
+#define BYTE_SWAP_16(x) bswap_16 (x)
+#define BYTE_SWAP_32(x) bswap_32 (x)
+#define BYTE_SWAP_64(x) bswap_64 (x)
#else
#define BYTE_SWAP_16(x) ((((x) & 0x00ff) << 8) | (((x) & 0xff00) >> 8))
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index ae73c9d40..edb4bb230 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -821,7 +821,8 @@ GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key,
* @param cls closure
* @param res resulting hash, NULL on error
*/
-typedef void (*GNUNET_CRYPTO_HashCompletedCallback) (
+typedef void
+(*GNUNET_CRYPTO_HashCompletedCallback) (
void *cls,
const struct GNUNET_HashCode *res);
@@ -1259,7 +1260,7 @@ GNUNET_CRYPTO_ecdsa_public_key_from_string (
* @param priv where to store the private key
* @return #GNUNET_OK on success
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_CRYPTO_eddsa_private_key_from_string (
const char *enc,
size_t enclen,
@@ -1317,7 +1318,7 @@ GNUNET_CRYPTO_ecdsa_key_from_file (const char *filename,
* @return #GNUNET_OK on success, #GNUNET_NO if @a do_create was set but
* we found an existing file, #GNUNET_SYSERR on failure
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_CRYPTO_eddsa_key_from_file (const char *filename,
int do_create,
struct GNUNET_CRYPTO_EddsaPrivateKey *pkey);
@@ -1793,7 +1794,7 @@ GNUNET_CRYPTO_ecdsa_sign_ (
* @param pub public key of the signer
* @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_CRYPTO_eddsa_verify_ (
uint32_t purpose,
const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
@@ -1846,7 +1847,7 @@ GNUNET_CRYPTO_eddsa_verify_ (
* @param pub public key of the signer
* @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_CRYPTO_ecdsa_verify_ (
uint32_t purpose,
const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
@@ -2215,6 +2216,15 @@ GNUNET_CRYPTO_rsa_public_key_hash (const struct GNUNET_CRYPTO_RsaPublicKey *key,
/**
+ * Check if @a key is well-formed.
+ *
+ * @return true if @a key is well-formed.
+ */
+bool
+GNUNET_CRYPTO_rsa_public_key_check (
+ const struct GNUNET_CRYPTO_RsaPublicKey *key);
+
+/**
* Obtain the length of the RSA key in bits.
*
* @param key the public key to introspect
@@ -2256,7 +2266,8 @@ GNUNET_CRYPTO_rsa_public_key_encode (
* @return NULL on error
*/
struct GNUNET_CRYPTO_RsaPublicKey *
-GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, size_t len);
+GNUNET_CRYPTO_rsa_public_key_decode (const char *buf,
+ size_t len);
/**
@@ -2288,9 +2299,9 @@ GNUNET_CRYPTO_rsa_signature_cmp (const struct GNUNET_CRYPTO_RsaSignature *s1,
* @return 0 if the two are equal
*/
int
-GNUNET_CRYPTO_rsa_private_key_cmp (const struct GNUNET_CRYPTO_RsaPrivateKey *p1,
- const struct
- GNUNET_CRYPTO_RsaPrivateKey *p2);
+GNUNET_CRYPTO_rsa_private_key_cmp (
+ const struct GNUNET_CRYPTO_RsaPrivateKey *p1,
+ const struct GNUNET_CRYPTO_RsaPrivateKey *p2);
/**
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h
index 95d30ae6f..d4a4ed7d2 100644
--- a/src/include/gnunet_dht_service.h
+++ b/src/include/gnunet_dht_service.h
@@ -82,8 +82,9 @@ enum GNUNET_DHT_RouteOption
GNUNET_DHT_RO_NONE = 0,
/**
- * Each peer along the way should look at 'enc' (otherwise
- * only the k-peers closest to the key should look at it).
+ * Each peer along the way should process the request (otherwise
+ * only peers locally closest to the key when the random walk
+ * is over should look at it).
*/
GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE = 1,
@@ -99,14 +100,10 @@ enum GNUNET_DHT_RouteOption
GNUNET_DHT_RO_FIND_PEER = 4,
/**
- * Possible message option for query key randomization.
- */
- GNUNET_DHT_RO_BART = 8,
-
- /**
- * Flag given to monitors if this was the last hop for a GET/PUT.
- */
- GNUNET_DHT_RO_LAST_HOP = 16
+ * Flag given to monitors if this was the last hop for a GET/PUT.
+ * This is only used for internal processing.
+ */
+ GNUNET_DHT_RO_LAST_HOP = 65535
};
diff --git a/src/include/gnunet_dhtu_plugin.h b/src/include/gnunet_dhtu_plugin.h
index df9729a23..e65318fb5 100644
--- a/src/include/gnunet_dhtu_plugin.h
+++ b/src/include/gnunet_dhtu_plugin.h
@@ -75,42 +75,18 @@ struct GNUNET_DHTU_PublicKey
/* followed by size-2 bytes of the actual public key */
};
-
+
/**
* Hash used by the DHT for keys and peers.
*/
struct GNUNET_DHTU_Hash
{
-
- /**
- * For now, use a 512 bit hash. (To be discussed).
- */
- struct GNUNET_HashCode hc;
-};
-
-/**
- * @brief header of what an DHTU signature signs
- * this must be followed by "size - 8" bytes of
- * the actual signed data
- */
-struct GNUNET_DHTU_SignaturePurpose
-{
/**
- * How many bytes does this signature sign?
- * (including this purpose header); in network
- * byte order (!).
- */
- uint32_t size GNUNET_PACKED;
-
- /**
- * What does this signature vouch for? This
- * must contain a GNUNET_SIGNATURE_PURPOSE_XXX
- * constant (from gnunet_signatures.h). In
- * network byte order!
+ * For now, use a 512 bit hash. (To be discussed).
*/
- uint32_t purpose GNUNET_PACKED;
+ struct GNUNET_HashCode hc;
};
@@ -131,7 +107,7 @@ struct GNUNET_DHTU_PluginEnvironment
*/
void *cls;
- /**
+ /**
* Function to call with new addresses of this peer.
*
* @param cls the closure
@@ -151,7 +127,7 @@ struct GNUNET_DHTU_PluginEnvironment
struct GNUNET_DHTU_Source *source,
void **ctx);
- /**
+ /**
* Function to call with expired addresses of this peer.
*
* @param[in] ctx storage space used by the DHT in association with this address
@@ -160,7 +136,7 @@ struct GNUNET_DHTU_PluginEnvironment
(*address_del_cb)(void *ctx);
/**
- * We have a new estimate on the size of the underlay.
+ * We have a new estimate on the size of the underlay.
*
* @param cls closure
* @param timestamp time when the estimate was received from the server (or created by the server)
@@ -172,7 +148,7 @@ struct GNUNET_DHTU_PluginEnvironment
struct GNUNET_TIME_Absolute timestamp,
double logestimate,
double std_dev);
-
+
/**
* Function to call when we connect to a peer and can henceforth transmit to
* that peer.
@@ -208,7 +184,7 @@ struct GNUNET_DHTU_PluginEnvironment
* @param cls the closure
* @param origin where the message originated from
* @param[in,out] tctx ctx of target address where we received the message from
- * @param[in,out] sctx ctx of our own source address at which we received the message
+ * @param[in,out] sctx ctx of our own source address at which we received the message
* @param message the message we received @param message_size number of
* bytes in @a message
*/
@@ -244,7 +220,7 @@ struct GNUNET_DHTU_PluginFunctions
ssize_t
(*sign)(void *cls,
const struct GNUNET_DHTU_PrivateKey *pk,
- const struct GNUNET_DHTU_SignaturePurpose *purpose,
+ const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
void **sig);
/**
@@ -262,7 +238,7 @@ struct GNUNET_DHTU_PluginFunctions
enum GNUNET_GenericReturnValue
(*verify)(void *cls,
const struct GNUNET_DHTU_PublicKey *pk,
- const struct GNUNET_DHTU_SignaturePurpose *purpose,
+ const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
const void *sig,
size_t sig_size);
@@ -281,7 +257,7 @@ struct GNUNET_DHTU_PluginFunctions
* Request underlay to keep the connection to @a target alive if possible.
* Hold may be called multiple times to express a strong preference to
* keep a connection, say because a @a target is in multiple tables.
- *
+ *
* @param cls closure
* @param target connection to keep alive
*/
@@ -291,13 +267,13 @@ struct GNUNET_DHTU_PluginFunctions
/**
* Do no long request underlay to keep the connection alive.
- *
+ *
* @param cls closure
* @param target connection to keep alive
*/
void
(*drop)(struct GNUNET_DHTU_PreferenceHandle *ph);
-
+
/**
* Send message to some other participant over the network. Note that
* sending is not guaranteeing that the other peer actually received the
@@ -310,7 +286,7 @@ struct GNUNET_DHTU_PluginFunctions
* @param msg_size number of bytes in @a msg
* @param finished_cb function called once transmission is done
* (not called if @a target disconnects, then only the
- * disconnect_cb is called).
+ * disconnect_cb is called).
* @param finished_cb_cls closure for @a finished_cb
*/
void
@@ -320,7 +296,7 @@ struct GNUNET_DHTU_PluginFunctions
size_t msg_size,
GNUNET_SCHEDULER_TaskCallback finished_cb,
void *finished_cb_cls);
-
+
};
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h
index fff0045aa..74eca999d 100644
--- a/src/include/gnunet_hello_lib.h
+++ b/src/include/gnunet_hello_lib.h
@@ -268,9 +268,10 @@ GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address,
* @return number of bytes written or 0, #GNUNET_SYSERR to signal the
* end of the iteration.
*/
-typedef ssize_t (*GNUNET_HELLO_GenerateAddressListCallback) (void *cls,
- size_t max,
- void *buf);
+typedef ssize_t
+(*GNUNET_HELLO_GenerateAddressListCallback) (void *cls,
+ size_t max,
+ void *buf);
/**
diff --git a/src/include/gnunet_json_lib.h b/src/include/gnunet_json_lib.h
index 92f696e08..5ef4592e5 100644
--- a/src/include/gnunet_json_lib.h
+++ b/src/include/gnunet_json_lib.h
@@ -107,9 +107,9 @@ struct GNUNET_JSON_Specification
size_t *size_ptr;
/**
- * Set to #GNUNET_YES if this component is optional.
+ * Set to true if this component is optional.
*/
- int is_optional;
+ bool is_optional;
};
diff --git a/src/include/gnunet_messenger_service.h b/src/include/gnunet_messenger_service.h
index 5d7155a3d..96d48b411 100644
--- a/src/include/gnunet_messenger_service.h
+++ b/src/include/gnunet_messenger_service.h
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2020 GNUnet e.V.
+ Copyright (C) 2020--2021 GNUnet e.V.
GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
@@ -75,6 +75,27 @@ struct GNUNET_MESSENGER_Room;
*/
struct GNUNET_MESSENGER_Contact;
+GNUNET_NETWORK_STRUCT_BEGIN
+
+/**
+ * A room entry record specifies which peer is hosting a given room and
+ * may also specify the key to enter it.
+ */
+struct GNUNET_MESSENGER_RoomEntryRecord
+{
+ /**
+ * The peer identity of an open door to a room.
+ */
+ struct GNUNET_PeerIdentity door;
+
+ /**
+ * The hash identifying the port of the room.
+ */
+ struct GNUNET_HashCode key;
+};
+
+GNUNET_NETWORK_STRUCT_END
+
/**
* Enum for the different supported kinds of messages
*/
@@ -527,7 +548,8 @@ enum GNUNET_MESSENGER_MessageFlags
* @param[in/out] handle Messenger handle
*/
typedef void
-(*GNUNET_MESSENGER_IdentityCallback) (void *cls, struct GNUNET_MESSENGER_Handle *handle);
+(*GNUNET_MESSENGER_IdentityCallback) (void *cls,
+ struct GNUNET_MESSENGER_Handle *handle);
/**
* Method called whenever a message is sent or received from a <i>room</i>.
@@ -543,7 +565,8 @@ typedef void
* @param[in] flags Flags of the message
*/
typedef void
-(*GNUNET_MESSENGER_MessageCallback) (void *cls, struct GNUNET_MESSENGER_Room *room,
+(*GNUNET_MESSENGER_MessageCallback) (void *cls,
+ struct GNUNET_MESSENGER_Room *room,
const struct GNUNET_MESSENGER_Contact *sender,
const struct GNUNET_MESSENGER_Message *message,
const struct GNUNET_HashCode *hash,
@@ -558,7 +581,8 @@ typedef void
* @param[in] contact Contact handle
*/
typedef int
-(*GNUNET_MESSENGER_MemberCallback) (void* cls, struct GNUNET_MESSENGER_Room *room,
+(*GNUNET_MESSENGER_MemberCallback) (void* cls,
+ struct GNUNET_MESSENGER_Room *room,
const struct GNUNET_MESSENGER_Contact *contact);
/**
@@ -574,9 +598,12 @@ typedef int
* @return Messenger handle to use, NULL on error
*/
struct GNUNET_MESSENGER_Handle*
-GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name,
- GNUNET_MESSENGER_IdentityCallback identity_callback, void *identity_cls,
- GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls);
+GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *name,
+ GNUNET_MESSENGER_IdentityCallback identity_callback,
+ void *identity_cls,
+ GNUNET_MESSENGER_MessageCallback msg_callback,
+ void *msg_cls);
/**
* Update a handle of the messenger to use a different ego key and replace the old one with a newly generated one. All
@@ -619,7 +646,8 @@ GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle);
* @return #GNUNET_YES on success, #GNUNET_NO on failure and #GNUNET_SYSERR if <i>handle</i> is NULL
*/
int
-GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, const char *name);
+GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle,
+ const char *name);
/**
* Get the public key used by the messenger or NULL if the anonymous key was used.
@@ -647,7 +675,8 @@ GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle);
* @return Room handle, NULL on error
*/
struct GNUNET_MESSENGER_Room*
-GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key);
+GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_HashCode *key);
/**
* Enter a room to send and receive messages through a <b>door</b> opened using #GNUNET_MESSENGER_open_room.
@@ -668,7 +697,8 @@ GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, const struct
* @return Room handle, NULL on error
*/
struct GNUNET_MESSENGER_Room*
-GNUNET_MESSENGER_enter_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door,
+GNUNET_MESSENGER_enter_room (struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_PeerIdentity *door,
const struct GNUNET_HashCode *key);
/**
@@ -695,8 +725,10 @@ GNUNET_MESSENGER_close_room (struct GNUNET_MESSENGER_Room *room);
* @return Amount of rooms iterated
*/
int
-GNUNET_MESSENGER_find_rooms (const struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_MESSENGER_Contact *contact,
- GNUNET_MESSENGER_MemberCallback callback, void *cls);
+GNUNET_MESSENGER_find_rooms (const struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_MESSENGER_Contact *contact,
+ GNUNET_MESSENGER_MemberCallback callback,
+ void *cls);
/**
* Get the key of a given <i>room</i>.
@@ -717,7 +749,8 @@ GNUNET_MESSENGER_room_get_key (const struct GNUNET_MESSENGER_Room *room);
* @return Contact handle, NULL otherwise
*/
const struct GNUNET_MESSENGER_Contact*
-GNUNET_MESSENGER_get_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash);
+GNUNET_MESSENGER_get_sender (const struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_HashCode *hash);
/**
* Get the name used by the <i>contact</i>.
@@ -756,7 +789,8 @@ GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact
* @param[in] contact Contact or NULL
*/
void
-GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message,
+GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_MESSENGER_Message *message,
const struct GNUNET_MESSENGER_Contact* contact);
/**
@@ -767,7 +801,8 @@ GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, const struct
* @return Message struct or NULL if no message with that hash is known
*/
const struct GNUNET_MESSENGER_Message*
-GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash);
+GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_HashCode *hash);
/**
* Iterates through all members of a given <i>room</i> and calls a selected <i>callback</i>
@@ -780,7 +815,8 @@ GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room, const st
* @return Amount of members iterated
*/
int
-GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback,
+GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room,
+ GNUNET_MESSENGER_MemberCallback callback,
void* cls);
#if 0 /* keep Emacsens' auto-indent happy */
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h
index 37bba8c1b..a1c5c4957 100644
--- a/src/include/gnunet_mq_lib.h
+++ b/src/include/gnunet_mq_lib.h
@@ -305,7 +305,8 @@ enum GNUNET_MQ_PriorityPreferences
* @param cls closure
* @param msg the received message
*/
-typedef void (*GNUNET_MQ_MessageCallback) (
+typedef void
+(*GNUNET_MQ_MessageCallback) (
void *cls,
const struct GNUNET_MessageHeader *msg);
@@ -318,7 +319,8 @@ typedef void (*GNUNET_MQ_MessageCallback) (
* @return #GNUNET_OK if the message is well-formed,
* #GNUNET_SYSERR if not
*/
-typedef int (*GNUNET_MQ_MessageValidationCallback) (
+typedef int
+(*GNUNET_MQ_MessageValidationCallback) (
void *cls,
const struct GNUNET_MessageHeader *msg);
@@ -331,9 +333,10 @@ typedef int (*GNUNET_MQ_MessageValidationCallback) (
* @param msg the message to send
* @param impl_state state of the implementation
*/
-typedef void (*GNUNET_MQ_SendImpl) (struct GNUNET_MQ_Handle *mq,
- const struct GNUNET_MessageHeader *msg,
- void *impl_state);
+typedef void
+(*GNUNET_MQ_SendImpl) (struct GNUNET_MQ_Handle *mq,
+ const struct GNUNET_MessageHeader *msg,
+ void *impl_state);
/**
@@ -345,8 +348,9 @@ typedef void (*GNUNET_MQ_SendImpl) (struct GNUNET_MQ_Handle *mq,
* @param mq the message queue to destroy
* @param impl_state state of the implementation
*/
-typedef void (*GNUNET_MQ_DestroyImpl) (struct GNUNET_MQ_Handle *mq,
- void *impl_state);
+typedef void
+(*GNUNET_MQ_DestroyImpl) (struct GNUNET_MQ_Handle *mq,
+ void *impl_state);
/**
@@ -355,8 +359,9 @@ typedef void (*GNUNET_MQ_DestroyImpl) (struct GNUNET_MQ_Handle *mq,
* @param mq message queue
* @param impl_state state specific to the implementation
*/
-typedef void (*GNUNET_MQ_CancelImpl) (struct GNUNET_MQ_Handle *mq,
- void *impl_state);
+typedef void
+(*GNUNET_MQ_CancelImpl) (struct GNUNET_MQ_Handle *mq,
+ void *impl_state);
/**
@@ -368,7 +373,9 @@ typedef void (*GNUNET_MQ_CancelImpl) (struct GNUNET_MQ_Handle *mq,
* @param cls closure
* @param error error code
*/
-typedef void (*GNUNET_MQ_ErrorHandler) (void *cls, enum GNUNET_MQ_Error error);
+typedef void
+(*GNUNET_MQ_ErrorHandler) (void *cls,
+ enum GNUNET_MQ_Error error);
/**
@@ -821,7 +828,8 @@ GNUNET_MQ_get_length (struct GNUNET_MQ_Handle *mq);
* @param ev the envelope with the message to send.
*/
void
-GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev);
+GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq,
+ struct GNUNET_MQ_Envelope *ev);
/**
@@ -854,7 +862,8 @@ GNUNET_MQ_send_cancel (struct GNUNET_MQ_Envelope *ev);
* @param assoc_data to associate
*/
uint32_t
-GNUNET_MQ_assoc_add (struct GNUNET_MQ_Handle *mq, void *assoc_data);
+GNUNET_MQ_assoc_add (struct GNUNET_MQ_Handle *mq,
+ void *assoc_data);
/**
@@ -865,7 +874,8 @@ GNUNET_MQ_assoc_add (struct GNUNET_MQ_Handle *mq, void *assoc_data);
* @return the associated data
*/
void *
-GNUNET_MQ_assoc_get (struct GNUNET_MQ_Handle *mq, uint32_t request_id);
+GNUNET_MQ_assoc_get (struct GNUNET_MQ_Handle *mq,
+ uint32_t request_id);
/**
@@ -876,7 +886,8 @@ GNUNET_MQ_assoc_get (struct GNUNET_MQ_Handle *mq, uint32_t request_id);
* @return the associated data
*/
void *
-GNUNET_MQ_assoc_remove (struct GNUNET_MQ_Handle *mq, uint32_t request_id);
+GNUNET_MQ_assoc_remove (struct GNUNET_MQ_Handle *mq,
+ uint32_t request_id);
/**
diff --git a/src/include/gnunet_network_lib.h b/src/include/gnunet_network_lib.h
index 97ab64add..ff1e853f5 100644
--- a/src/include/gnunet_network_lib.h
+++ b/src/include/gnunet_network_lib.h
@@ -78,7 +78,7 @@ struct GNUNET_NETWORK_FDSet
* @param pf protocol family to test (PF_INET, PF_INET6, PF_UNIX)
* @return #GNUNET_OK if the PF is supported
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_NETWORK_test_pf (int pf);
@@ -154,7 +154,7 @@ GNUNET_NETWORK_socket_set_blocking (struct GNUNET_NETWORK_Handle *fd,
* @param address_len length of @a address
* @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc,
const struct sockaddr *address,
socklen_t address_len);
@@ -165,7 +165,7 @@ GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc,
* @param desc socket to close
* @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc);
@@ -186,7 +186,7 @@ GNUNET_NETWORK_socket_free_memory_only_ (struct GNUNET_NETWORK_Handle *desc);
* @param address_len of @a address
* @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc,
const struct sockaddr *address,
socklen_t address_len);
@@ -202,7 +202,7 @@ GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc,
* @param optlen length of optval
* @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_NETWORK_socket_getsockopt (const struct GNUNET_NETWORK_Handle *desc,
int level,
int optname,
@@ -217,7 +217,7 @@ GNUNET_NETWORK_socket_getsockopt (const struct GNUNET_NETWORK_Handle *desc,
* @param backlog length of the listen queue
* @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_NETWORK_socket_listen (const struct GNUNET_NETWORK_Handle *desc,
int backlog);
@@ -339,7 +339,7 @@ GNUNET_NETWORK_socket_setsockopt (struct GNUNET_NETWORK_Handle *fd,
* @param how type of shutdown
* @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc,
int how);
@@ -353,7 +353,7 @@ GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc,
* @param desc socket
* @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_NETWORK_socket_disable_corking (struct GNUNET_NETWORK_Handle *desc);
diff --git a/src/include/gnunet_os_lib.h b/src/include/gnunet_os_lib.h
index 749f766d2..eddf97dab 100644
--- a/src/include/gnunet_os_lib.h
+++ b/src/include/gnunet_os_lib.h
@@ -672,9 +672,9 @@ GNUNET_OS_install_parent_control_handler (void *cls);
* #GNUNET_NO if not SUID (but binary exists),
* #GNUNET_SYSERR on error (no such binary or not executable)
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_OS_check_helper_binary (const char *binary,
- int check_suid,
+ bool check_suid,
const char *params);
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h
index fe3fabbea..05d373f88 100644
--- a/src/include/gnunet_pq_lib.h
+++ b/src/include/gnunet_pq_lib.h
@@ -133,6 +133,16 @@ GNUNET_PQ_query_param_string (const char *ptr);
/**
+ * Pass a boolean into a query.
+ *
+ * @param b boolean bit to pass
+ * @return query parameter to use
+ */
+struct GNUNET_PQ_QueryParam
+GNUNET_PQ_query_param_bool (bool b);
+
+
+/**
* Generate fixed-size query parameter with size determined
* by variable type.
*
@@ -335,7 +345,15 @@ struct GNUNET_PQ_ResultSpec
*/
#define GNUNET_PQ_result_spec_end \
{ \
- NULL, NULL, NULL, NULL, 0, NULL, NULL \
+ .conv = NULL, \
+ .cleaner = NULL, \
+ .cls = NULL, \
+ .dst = NULL, \
+ .dst_size = 0, \
+ .fname = NULL, \
+ .result_size = NULL, \
+ .is_nullable = false, \
+ .is_null = NULL \
}
@@ -377,7 +395,9 @@ GNUNET_PQ_result_spec_variable_size (const char *name,
* @return array entry for the result specification to use
*/
struct GNUNET_PQ_ResultSpec
-GNUNET_PQ_result_spec_fixed_size (const char *name, void *dst, size_t dst_size);
+GNUNET_PQ_result_spec_fixed_size (const char *name,
+ void *dst,
+ size_t dst_size);
/**
@@ -399,7 +419,20 @@ GNUNET_PQ_result_spec_fixed_size (const char *name, void *dst, size_t dst_size);
* @return array entry for the result specification to use
*/
struct GNUNET_PQ_ResultSpec
-GNUNET_PQ_result_spec_string (const char *name, char **dst);
+GNUNET_PQ_result_spec_string (const char *name,
+ char **dst);
+
+
+/**
+ * boolean expected.
+ *
+ * @param name name of the field in the table
+ * @param[out] dst where to store the result
+ * @return array entry for the result specification to use
+ */
+struct GNUNET_PQ_ResultSpec
+GNUNET_PQ_result_spec_bool (const char *name,
+ bool *dst);
/**
@@ -470,7 +503,8 @@ GNUNET_PQ_result_spec_absolute_time_nbo (const char *name,
* @return array entry for the result specification to use
*/
struct GNUNET_PQ_ResultSpec
-GNUNET_PQ_result_spec_uint16 (const char *name, uint16_t *u16);
+GNUNET_PQ_result_spec_uint16 (const char *name,
+ uint16_t *u16);
/**
@@ -481,7 +515,8 @@ GNUNET_PQ_result_spec_uint16 (const char *name, uint16_t *u16);
* @return array entry for the result specification to use
*/
struct GNUNET_PQ_ResultSpec
-GNUNET_PQ_result_spec_uint32 (const char *name, uint32_t *u32);
+GNUNET_PQ_result_spec_uint32 (const char *name,
+ uint32_t *u32);
/**
@@ -492,7 +527,8 @@ GNUNET_PQ_result_spec_uint32 (const char *name, uint32_t *u32);
* @return array entry for the result specification to use
*/
struct GNUNET_PQ_ResultSpec
-GNUNET_PQ_result_spec_uint64 (const char *name, uint64_t *u64);
+GNUNET_PQ_result_spec_uint64 (const char *name,
+ uint64_t *u64);
/* ************************* pq.c functions ************************ */
@@ -641,11 +677,11 @@ GNUNET_PQ_eval_prepared_multi_select (struct GNUNET_PQ_Context *db,
* codes to `enum GNUNET_DB_QueryStatus`.
*/
enum GNUNET_DB_QueryStatus
-GNUNET_PQ_eval_prepared_singleton_select (struct GNUNET_PQ_Context *db,
- const char *statement_name,
- const struct
- GNUNET_PQ_QueryParam *params,
- struct GNUNET_PQ_ResultSpec *rs);
+GNUNET_PQ_eval_prepared_singleton_select (
+ struct GNUNET_PQ_Context *db,
+ const char *statement_name,
+ const struct GNUNET_PQ_QueryParam *params,
+ struct GNUNET_PQ_ResultSpec *rs);
/* ******************** pq_prepare.c functions ************** */
@@ -707,7 +743,7 @@ GNUNET_PQ_make_prepare (const char *name,
* @return #GNUNET_OK on success,
* #GNUNET_SYSERR on error
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_PQ_prepare_statements (struct GNUNET_PQ_Context *db,
const struct GNUNET_PQ_PreparedStatement *ps);
@@ -772,7 +808,7 @@ GNUNET_PQ_make_try_execute (const char *sql);
* @return #GNUNET_OK on success (modulo statements where errors can be ignored)
* #GNUNET_SYSERR on error
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_PQ_exec_statements (struct GNUNET_PQ_Context *db,
const struct GNUNET_PQ_ExecuteStatement *es);
@@ -781,6 +817,29 @@ GNUNET_PQ_exec_statements (struct GNUNET_PQ_Context *db,
/**
+ * Flags to control PQ operation.
+ */
+enum GNUNET_PQ_Options
+{
+ /**
+ * Traditional default. Do nothing special.
+ */
+ GNUNET_PQ_FLAG_NONE = 0,
+
+ /**
+ * Dropping database. Do not attempt to initialize
+ * versioning schema if not present.
+ */
+ GNUNET_PQ_FLAG_DROP = 1,
+
+ /**
+ * Check database version is current. Fail to connect if it is not.
+ */
+ GNUNET_PQ_FLAG_CHECK_CURRENT = 2
+};
+
+
+/**
* Create a connection to the Postgres database using @a config_str for the
* configuration. Initialize logging via GNUnet's log routines and disable
* Postgres's logger. Also ensures that the statements in @a load_path and @a
@@ -810,6 +869,37 @@ GNUNET_PQ_connect (const char *config_str,
/**
+ * Create a connection to the Postgres database using @a config_str for the
+ * configuration. Initialize logging via GNUnet's log routines and disable
+ * Postgres's logger. Also ensures that the statements in @a load_path and @a
+ * es are executed whenever we (re)connect to the database, and that the
+ * prepared statements in @a ps are "ready". If statements in @es fail that
+ * were created with #GNUNET_PQ_make_execute(), then the entire operation
+ * fails.
+ *
+ * In @a load_path, a list of "$XXXX.sql" files is expected where $XXXX
+ * must be a sequence of contiguous integer values starting at 0000.
+ * These files are then loaded in sequence using "psql $config_str" before
+ * running statements from @e es. The directory is inspected again on
+ * reconnect.
+ *
+ * @param config_str configuration to use
+ * @param load_path path to directory with SQL transactions to run, can be NULL
+ * @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated
+ * array of statements to execute upon EACH connection, can be NULL
+ * @param ps array of prepared statements to prepare, can be NULL
+ * @param flags connection flags
+ * @return NULL on error
+ */
+struct GNUNET_PQ_Context *
+GNUNET_PQ_connect2 (const char *config_str,
+ const char *load_path,
+ const struct GNUNET_PQ_ExecuteStatement *es,
+ const struct GNUNET_PQ_PreparedStatement *ps,
+ enum GNUNET_PQ_Options flags);
+
+
+/**
* Connect to a postgres database using the configuration
* option "CONFIG" in @a section. Also ensures that the
* statements in @a es are executed whenever we (re)connect to the
@@ -835,6 +925,33 @@ GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
/**
+ * Connect to a postgres database using the configuration
+ * option "CONFIG" in @a section. Also ensures that the
+ * statements in @a es are executed whenever we (re)connect to the
+ * database, and that the prepared statements in @a ps are "ready".
+ *
+ * The caller does not have to ensure that @a es and @a ps remain allocated
+ * and initialized in memory until #GNUNET_PQ_disconnect() is called, as a copy will be made.
+ *
+ * @param cfg configuration
+ * @param section configuration section to use to get Postgres configuration options
+ * @param load_path_suffix suffix to append to the SQL_DIR in the configuration
+ * @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated
+ * array of statements to execute upon EACH connection, can be NULL
+ * @param ps array of prepared statements to prepare, can be NULL
+ * @param flags connection flags
+ * @return the postgres handle, NULL on error
+ */
+struct GNUNET_PQ_Context *
+GNUNET_PQ_connect_with_cfg2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *section,
+ const char *load_path_suffix,
+ const struct GNUNET_PQ_ExecuteStatement *es,
+ const struct GNUNET_PQ_PreparedStatement *ps,
+ enum GNUNET_PQ_Options flags);
+
+
+/**
* Reinitialize the database @a db if the connection is down.
*
* @param db database connection to reinitialize
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 6b61dfc72..9e278eb92 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -660,6 +660,11 @@ extern "C" {
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN 156
/**
+ * DHT wants to use CORE to transmit data.
+ */
+#define GNUNET_MESSAGE_TYPE_DHT_CORE 143
+
+/**
* Further X-VINE DHT messages continued from 880
*/
@@ -3574,7 +3579,11 @@ extern "C" {
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED 1703
-#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED 1704
+#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED 1704
+
+#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED 1705
+
+#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED 1706
/*********************************************************************************/
diff --git a/src/include/gnunet_testbed_service.h b/src/include/gnunet_testbed_service.h
index acb444de4..888c6e391 100644
--- a/src/include/gnunet_testbed_service.h
+++ b/src/include/gnunet_testbed_service.h
@@ -139,24 +139,6 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
/**
- * Loads the set of host allocated by the LoadLeveler Job Scheduler. This
- * function is only available when compiled with support for LoadLeveler and is
- * used for running on the SuperMUC
- *
- * @param cfg the configuration to use as a template while starting a controller
- * on any of the loaded hosts. Operation queue sizes specific to a host
- * are also read from this configuration handle
- * @param hosts set to the hosts found in the file; caller must free this if
- * number of hosts returned is greater than 0
- * @return number of hosts returned in 'hosts', 0 on error
- */
-unsigned int
-GNUNET_TESTBED_hosts_load_from_loadleveler (const struct
- GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTBED_Host
- ***hosts);
-
-/**
* Destroy a host handle. Must only be called once everything
* running on that host has been stopped.
*
diff --git a/src/include/gnunet_testing_netjail_lib.h b/src/include/gnunet_testing_netjail_lib.h
new file mode 100644
index 000000000..011db00f8
--- /dev/null
+++ b/src/include/gnunet_testing_netjail_lib.h
@@ -0,0 +1,492 @@
+/*
+ This file is part of GNUnet
+ Copyright (C) 2021 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @brief API for writing an interpreter to test GNUnet components
+ * @author Christian Grothoff <christian@grothoff.org>
+ * @author Marcello Stanisci
+ * @author t3sserakt
+ */
+#ifndef GNUNET_TESTING_NETJAIL_LIB_H
+#define GNUNET_TESTING_NETJAIL_LIB_H
+
+#include "gnunet_util_lib.h"
+#include "gnunet_testing_plugin.h"
+#include "gnunet_testing_ng_lib.h"
+
+
+/**
+ * Router of a netjail subnet.
+ */
+struct GNUNET_TESTING_NetjailRouter
+{
+ /**
+ * Will tcp be forwarded?
+ */
+ unsigned int tcp_port;
+
+ /**
+ * Will udp be forwarded?
+ */
+ unsigned int udp_port;
+};
+
+
+/**
+ * Enum for the different types of nodes.
+ */
+enum GNUNET_TESTING_NODE_TYPE
+{
+ /**
+ * Node in a subnet.
+ */
+ GNUNET_TESTING_SUBNET_NODE,
+
+ /**
+ * Global known node.
+ */
+ GNUNET_TESTING_GLOBAL_NODE
+};
+
+/**
+ * Protocol address prefix für a connection between nodes.
+ */
+struct GNUNET_TESTING_AddressPrefix
+{
+ /**
+ * Pointer to the previous prefix in the DLL.
+ */
+ struct GNUNET_TESTING_AddressPrefix *prev;
+
+ /**
+ * Pointer to the next prefix in the DLL.
+ */
+ struct GNUNET_TESTING_AddressPrefix *next;
+
+ /**
+ * The address prefix.
+ */
+ char *address_prefix;
+};
+
+
+/**
+ * Node in a netjail topology.
+ */
+struct GNUNET_TESTING_NetjailNode;
+
+/**
+ * Connection to another node.
+ */
+struct GNUNET_TESTING_NodeConnection
+{
+ /**
+ * Pointer to the previous connection in the DLL.
+ */
+ struct GNUNET_TESTING_NodeConnection *prev;
+
+ /**
+ * Pointer to the next connection in the DLL.
+ */
+ struct GNUNET_TESTING_NodeConnection *next;
+
+ /**
+ * The number of the subnet of the node this connection points to. This is 0,
+ * if the node is a global known node.
+ */
+ unsigned int namespace_n;
+
+ /**
+ * The number of the node this connection points to.
+ */
+ unsigned int node_n;
+
+ /**
+ * The type of the node this connection points to.
+ */
+ enum GNUNET_TESTING_NODE_TYPE node_type;
+
+ /**
+ * The node which establish the connection
+ */
+ struct GNUNET_TESTING_NetjailNode *node;
+
+ /**
+ * Head of the DLL with the address prefixes for the protocolls this node is reachable.
+ */
+ struct GNUNET_TESTING_AddressPrefix *address_prefixes_head;
+
+ /**
+ * Tail of the DLL with the address prefixes for the protocolls this node is reachable.
+ */
+ struct GNUNET_TESTING_AddressPrefix *address_prefixes_tail;
+};
+
+/**
+ * Node in the netjail topology.
+ */
+struct GNUNET_TESTING_NetjailNode
+{
+ /**
+ * Plugin for the test case to be run on this node.
+ */
+ char *plugin;
+
+ /**
+ * Flag indicating if this node is a global known node.
+ */
+ unsigned int is_global;
+
+ /**
+ * The number of the subnet this node is running in.
+ */
+ unsigned int namespace_n;
+
+ /**
+ * The number of this node in the subnet.
+ */
+ unsigned int node_n;
+
+ /**
+ * Head of the DLL with the connections which shall be established to other nodes.
+ */
+ struct GNUNET_TESTING_NodeConnection *node_connections_head;
+
+ /**
+ * Tail of the DLL with the connections which shall be established to other nodes.
+ */
+ struct GNUNET_TESTING_NodeConnection *node_connections_tail;
+};
+
+
+/**
+ * Subnet in a topology.
+ */
+struct GNUNET_TESTING_NetjailNamespace
+{
+ /**
+ * The number of the subnet.
+ */
+ unsigned int namespace_n;
+
+ /**
+ * Router of the subnet.
+ */
+ struct GNUNET_TESTING_NetjailRouter *router;
+
+ /**
+ * Hash map containing the nodes in this subnet.
+ */
+ struct GNUNET_CONTAINER_MultiShortmap *nodes;
+};
+
+/**
+ * Toplogy of our netjail setup.
+ */
+struct GNUNET_TESTING_NetjailTopology
+{
+
+ /**
+ * Default plugin for the test case to be run on nodes.
+ */
+ char *plugin;
+
+ /**
+ * Number of subnets.
+ */
+ unsigned int namespaces_n;
+
+ /**
+ * Number of nodes per subnet.
+ */
+ unsigned int nodes_m;
+
+ /**
+ * Number of global known nodes.
+ */
+ unsigned int nodes_x;
+
+ /**
+ * Hash map containing the subnets (for natted nodes) of the topology.
+ */
+ struct GNUNET_CONTAINER_MultiShortmap *map_namespaces;
+
+ /**
+ * Hash map containing the global known nodes which are not natted.
+ */
+ struct GNUNET_CONTAINER_MultiShortmap *map_globals;
+};
+
+/**
+ * Getting the topology from file.
+ *
+ * @param filename The name of the topology file.
+ * @return The GNUNET_TESTING_NetjailTopology
+ */
+struct GNUNET_TESTING_NetjailTopology *
+GNUNET_TESTING_get_topo_from_file (const char *filename);
+
+
+/**
+ * Parse the topology data.
+ *
+ * @param data The topology data.
+ * @return The GNUNET_TESTING_NetjailTopology
+ */
+struct GNUNET_TESTING_NetjailTopology *
+GNUNET_TESTING_get_topo_from_string (char *data);
+
+
+/**
+ * Get the connections to other nodes for a specific node.
+ *
+ * @param num The specific node we want the connections for.
+ * @param topology The topology we get the connections from.
+ * @return The connections of the node.
+ */
+struct GNUNET_TESTING_NodeConnection *
+GNUNET_TESTING_get_connections (unsigned int num, struct
+ GNUNET_TESTING_NetjailTopology *topology);
+
+
+/**
+ * Get the address for a specific communicator from a connection.
+ *
+ * @param connection The connection we like to have the address from.
+ * @param prefix The communicator protocol prefix.
+ * @return The address of the communicator.
+ */
+char *
+GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection,
+ char *prefix);
+
+
+/**
+ * Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
+ *
+ * @param topology The GNUNET_TESTING_NetjailTopology to be deallocated.
+ */
+void
+GNUNET_TESTING_free_topology (struct GNUNET_TESTING_NetjailTopology *topology);
+
+
+/**
+ * Calculate the unique id identifying a node from a given connction.
+ *
+ * @param node_connection The connection we calculate the id from.
+ * @param topology The topology we get all needed information from.
+ * @return The unique id of the node from the connection.
+ */
+unsigned int
+GNUNET_TESTING_calculate_num (struct
+ GNUNET_TESTING_NodeConnection *node_connection,
+ struct GNUNET_TESTING_NetjailTopology *topology);
+
+
+/**
+ * Struct with information for callbacks.
+ *
+ */
+struct BlockState
+{
+ /**
+ * Context for our asynchronous completion.
+ */
+ struct GNUNET_TESTING_AsyncContext ac;
+
+ /**
+ * The label of this command.
+ */
+ const char *label;
+
+ /**
+ * If this command will block.
+ */
+ unsigned int asynchronous_finish;
+};
+
+/**
+ * Struct to hold information for callbacks.
+ *
+ */
+struct LocalPreparedState
+{
+ /**
+ * Context for our asynchronous completion.
+ */
+ struct GNUNET_TESTING_AsyncContext ac;
+
+ /**
+ * Callback to write messages to the master loop.
+ *
+ */
+ TESTING_CMD_HELPER_write_cb write_message;
+};
+
+
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_system_destroy (const char *label,
+ const char *create_label);
+
+
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_system_create (const char *label,
+ const char *testdir);
+
+
+/**
+ * Create command.
+ *
+ * @param label name for command.
+ * @param topology_config Configuration file for the test topology.
+ * @param read_file Flag indicating if the the name of the topology file is send to the helper, or a string with the topology data.
+ * @return command.
+ */
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_netjail_start (const char *label,
+ char *topology_config,
+ unsigned int *read_file);
+
+
+/**
+ * Create command.
+ *
+ * @param label name for command.
+ * @param topology_config Configuration file for the test topology.
+ * @param read_file Flag indicating if the the name of the topology file is send to the helper, or a string with the topology data.
+ * @return command.
+ */
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_netjail_stop (const char *label,
+ char *topology_config,
+ unsigned int *read_file);
+
+
+/**
+ * Create command.
+ *
+ * @param label Name for the command.
+ * @param topology The complete topology information.
+ * @param read_file Flag indicating if the the name of the topology file is send to the helper, or a string with the topology data.
+ * @param topology_data If read_file is GNUNET_NO, topology_data holds the string with the topology.
+ * @return command.
+ */
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_netjail_start_testing_system (
+ const char *label,
+ struct GNUNET_TESTING_NetjailTopology *topology,
+ unsigned int *read_file,
+ char *topology_data);
+
+
+/**
+ * Create command.
+ *
+ * @param label name for command.
+ * @param helper_start_label label of the cmd to start the test system.
+ * @param topology The complete topology information.
+ * @return command.
+ */
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_stop_testing_system (
+ const char *label,
+ const char *helper_start_label,
+ struct GNUNET_TESTING_NetjailTopology *topology);
+
+
+/**
+ * Create a GNUNET_CMDS_LOCAL_FINISHED message.
+ *
+ * @param rv The result of the local test as GNUNET_GenericReturnValue.
+ * @return The GNUNET_CMDS_LOCAL_FINISHED message.
+*/
+struct GNUNET_MessageHeader *
+GNUNET_TESTING_send_local_test_finished_msg (enum GNUNET_GenericReturnValue rv);
+
+
+
+
+
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_block_until_all_peers_started (
+ const char *label,
+ unsigned int *all_peers_started);
+
+
+/**
+ * Create command.
+ *
+ * @param label name for command.
+ * @param all_peers_started Flag which will be set from outside.
+ * @param asynchronous_finish If GNUNET_YES this command will not block.
+ * @return command.
+ */
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_block_until_external_trigger (
+ const char *label);
+
+
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_send_peer_ready (const char *label,
+ TESTING_CMD_HELPER_write_cb write_message);
+
+
+/**
+ * Create command.
+ *
+ * @param label name for command.
+ * @param write_message Callback to write messages to the master loop.
+ * @return command.
+ */
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_local_test_finished (
+ const char *label,
+ TESTING_CMD_HELPER_write_cb write_message);
+
+/**
+ * Create command.
+ *
+ * @param label name for command.
+ * @param write_message Callback to write messages to the master loop.
+ * @param all_local_tests_prepared Flag which will be set from outside.
+ * @return command.
+ */
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_local_test_prepared (const char *label,
+ TESTING_CMD_HELPER_write_cb
+ write_message);
+
+
+/* ***** Netjail trait support ***** */
+
+
+/**
+ * Call #op on all simple traits.
+ */
+#define GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS(op) \
+ op (test_system, const struct GNUNET_TESTING_System) \
+ op (async_context, const struct GNUNET_TESTING_AsyncContext) \
+ op (helper_handles, const struct GNUNET_HELPER_Handle *) \
+ op (local_prepared_state, const struct LocalPreparedState) \
+ op (block_state, const struct BlockState)
+
+GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT)
+
+#endif
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h
index 9ef42a3aa..c0e534594 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -31,6 +31,14 @@
#include "gnunet_testing_plugin.h"
#include "gnunet_testing_lib.h"
+/**
+ * Stringify operator.
+ *
+ * @param a some expression to stringify. Must NOT be a macro.
+ * @return same expression as a constant string.
+ */
+#define GNUNET_S(a) #a
+
/* ********************* Helper functions ********************* */
@@ -47,117 +55,44 @@
} while (0)
-/**
- * Router of a network namespace.
- */
-struct GNUNET_TESTING_NetjailRouter
-{
- /**
- * Will tcp be forwarded?
- */
- unsigned int tcp_port;
-
- /**
- * Will udp be forwarded?
- */
- unsigned int udp_port;
-};
-
-
-/**
- * Node in the netjail topology.
- */
-struct GNUNET_TESTING_NetjailNode
-{
- /**
- * Plugin for the test case to be run on this node.
- */
- char *plugin;
-
- /**
- * Flag indicating if this node is a global known node.
- */
- unsigned int is_global;
-
- /**
- * The number of the namespace this node is running in.
- */
- unsigned int namespace_n;
-
- /**
- * The number of this node in the namespace.
- */
- unsigned int node_n;
-};
-
+/* ******************* Generic interpreter logic ************ */
/**
- * Namespace in a topology.
+ * Global state of the interpreter, used by a command
+ * to access information about other commands.
*/
-struct GNUNET_TESTING_NetjailNamespace
-{
- /**
- * The number of the namespace.
- */
- unsigned int namespace_n;
-
- /**
- * Router of the namespace.
- */
- struct GNUNET_TESTING_NetjailRouter *router;
-
- /**
- * Hash map containing the nodes in this namespace.
- */
- struct GNUNET_CONTAINER_MultiShortmap *nodes;
-};
+struct GNUNET_TESTING_Interpreter;
/**
- * Toplogy of our netjail setup.
+ * State each asynchronous command must have in its closure.
*/
-struct GNUNET_TESTING_NetjailTopology
+struct GNUNET_TESTING_AsyncContext
{
/**
- * Default plugin for the test case to be run on nodes.
- */
- char *plugin;
-
- /**
- * Number of namespaces.
- */
- unsigned int namespaces_n;
-
- /**
- * Number of nodes per namespace.
+ * Interpreter we are part of.
*/
- unsigned int nodes_m;
+ struct GNUNET_TESTING_Interpreter *is;
/**
- * Number of global known nodes per namespace.
+ * Function to call when done.
*/
- unsigned int nodes_x;
+ GNUNET_SCHEDULER_TaskCallback cont;
/**
- * Hash map containing the namespaces (for natted nodes) of the topology.
+ * Closure for @e cont.
*/
- struct GNUNET_CONTAINER_MultiShortmap *map_namespaces;
+ void *cont_cls;
/**
- * Hash map containing the global known nodes which are not natted.
+ * Indication if the command finished (#GNUNET_OK).
+ * #GNUNET_NO if it did not finish,
+ * #GNUNET_SYSERR if it failed.
*/
- struct GNUNET_CONTAINER_MultiShortmap *map_globals;
+ enum GNUNET_GenericReturnValue finished;
};
-/* ******************* Generic interpreter logic ************ */
-
-/**
- * Global state of the interpreter, used by a command
- * to access information about other commands.
- */
-struct GNUNET_TESTING_Interpreter;
-
/**
* A command to be run by the interpreter.
*/
@@ -187,57 +122,43 @@ struct GNUNET_TESTING_Command
* the asynchronous activity to terminate.
*
* @param cls closure
- * @param cmd command being run
- * @param i interpreter state
+ * @param is interpreter state
*/
void
(*run)(void *cls,
- const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTING_Interpreter *i);
+ struct GNUNET_TESTING_Interpreter *is);
/**
- * Wait for any asynchronous execution of @e run to conclude,
- * then call finish_cont. Finish may only be called once per command.
- *
- * This member may be NULL if this command is a synchronous command,
- * and also should be set to NULL once the command has finished.
+ * Pointer to the asynchronous context in the command's
+ * closure. Used by the
+ * #GNUNET_TESTING_async_finish() and
+ * #GNUNET_TESTING_async_fail() functions.
*
- * @param cls closure
- * @param cont function to call upon completion, can be NULL
- * @param cont_cls closure for @a cont
- */
- int
- (*finish)(void *cls,
- GNUNET_SCHEDULER_TaskCallback cont,
- void *cont_cls);
-
- /**
- * Task for running the finish function.
+ * Must be NULL if a command is synchronous.
*/
- struct GNUNET_SCHEDULER_Task *finish_task;
+ struct GNUNET_TESTING_AsyncContext *ac;
/**
* Clean up after the command. Run during forced termination
* (CTRL-C) or test failure or test success.
*
* @param cls closure
- * @param cmd command being cleaned up
*/
void
- (*cleanup)(void *cls,
- const struct GNUNET_TESTING_Command *cmd);
+ (*cleanup)(void *cls);
/**
* Extract information from a command that is useful for other
- * commands.
+ * commands. Can be NULL if a command has no traits.
*
* @param cls closure
* @param[out] ret result (could be anything)
* @param trait name of the trait
* @param index index number of the object to extract.
- * @return #GNUNET_OK on success
+ * @return #GNUNET_OK on success,
+ * #GNUNET_NO if no trait was found
*/
- int
+ enum GNUNET_GenericReturnValue
(*traits)(void *cls,
const void **ret,
const char *trait,
@@ -265,13 +186,6 @@ struct GNUNET_TESTING_Command
struct GNUNET_TIME_Absolute last_req_time;
/**
- * How often did we try to execute this command? (In case it is a request
- * that is repated.) Note that a command must have some built-in retry
- * mechanism for this value to be useful.
- */
- unsigned int num_tries;
-
- /**
* In case @e asynchronous_finish is true, how long should we wait for this
* command to complete? If @e finish did not complete after this amount of
* time, the interpreter will fail. Should be set generously to ensure
@@ -280,9 +194,16 @@ struct GNUNET_TESTING_Command
struct GNUNET_TIME_Relative default_timeout;
/**
+ * How often did we try to execute this command? (In case it is a request
+ * that is repated.) Note that a command must have some built-in retry
+ * mechanism for this value to be useful.
+ */
+ unsigned int num_tries;
+
+ /**
* If "true", the interpreter should not immediately call
* @e finish, even if @e finish is non-NULL. Otherwise,
- * #TALER_TESTING_cmd_finish() must be used
+ * #GNUNET_TESTING_cmd_finish() must be used
* to ensure that a command actually completed.
*/
bool asynchronous_finish;
@@ -291,40 +212,43 @@ struct GNUNET_TESTING_Command
/**
- * Struct to use for command-specific context information closure of a command waiting
- * for another command.
+ * Lookup command by label.
+ * Only future commands are looked up.
+ *
+ * @param is interpreter to lookup command in
+ * @param label label of the command to lookup.
+ * @return the command, if it is found, or NULL.
*/
-struct SyncState
-{
- /**
- * Closure for all commands with command-specific context information.
- */
- void *cls;
+const struct GNUNET_TESTING_Command *
+GNUNET_TESTING_interpreter_lookup_future_command (
+ struct GNUNET_TESTING_Interpreter *is,
+ const char *label);
- /**
- * The asynchronous command the synchronous command of this closure waits for.
- */
- const struct GNUNET_TESTING_Command *async_cmd;
- /**
- * Task for running the finish method of the asynchronous task the command is waiting for.
- */
- struct GNUNET_SCHEDULER_Task *finish_task;
+/**
+ * Lookup command by label.
+ *
+ * @param is interpreter to lookup command in
+ * @param label label of the command to lookup.
+ * @return the command, if it is found, or NULL.
+ */
+const struct GNUNET_TESTING_Command *
+GNUNET_TESTING_interpreter_lookup_command (
+ struct GNUNET_TESTING_Interpreter *is,
+ const char *label);
- /**
- * When did the execution of this commands finish function start?
- */
- struct GNUNET_TIME_Absolute start_finish_time;
-};
/**
* Lookup command by label.
+ * All commands, first into the past, then into the furture are looked up.
*
+ * @param is interpreter to lookup command in
* @param label label of the command to lookup.
* @return the command, if it is found, or NULL.
*/
const struct GNUNET_TESTING_Command *
-GNUNET_TESTING_interpreter_lookup_command (
+GNUNET_TESTING_interpreter_lookup_command_all (
+ struct GNUNET_TESTING_Interpreter *is,
const char *label);
@@ -345,7 +269,25 @@ GNUNET_TESTING_interpreter_get_current_label (
* @param is interpreter state.
*/
void
-GNUNET_TESTING_interpreter_fail ();
+GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is);
+
+
+/**
+ * The asynchronous command of @a ac has failed.
+ *
+ * @param ac command-specific context
+ */
+void
+GNUNET_TESTING_async_fail (struct GNUNET_TESTING_AsyncContext *ac);
+
+
+/**
+ * The asynchronous command of @a ac has finished.
+ *
+ * @param ac command-specific context
+ */
+void
+GNUNET_TESTING_async_finish (struct GNUNET_TESTING_AsyncContext *ac);
/**
@@ -363,8 +305,8 @@ GNUNET_TESTING_cmd_end (void);
* @param cmd command to make synchronous.
* @return a finish-command.
*/
-const struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_make_unblocking (const struct GNUNET_TESTING_Command cmd);
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_make_unblocking (struct GNUNET_TESTING_Command cmd);
/**
@@ -400,31 +342,46 @@ GNUNET_TESTING_cmd_rewind_ip (const char *label,
/**
- * Wait until we receive SIGCHLD signal. Then obtain the process trait of the
- * current command, wait on the the zombie and continue with the next command.
+ * Function called with the final result of the test.
*
- * @param is interpreter state.
+ * @param cls closure
+ * @param rv #GNUNET_OK if the test passed
*/
-// void
-// GNUNET_TESTING_wait_for_sigchld (struct GNUNET_TESTING_Interpreter *is);
-// => replace with child_management.c
+typedef void
+(*GNUNET_TESTING_ResultCallback)(void *cls,
+ enum GNUNET_GenericReturnValue rv);
/**
- * Start scheduling loop with signal handlers and run the
- * test suite with the @a commands.
+ * Run the testsuite. Note, CMDs are copied into
+ * the interpreter state because they are _usually_
+ * defined into the "run" method that returns after
+ * having scheduled the test interpreter.
*
- * @param cfg_name name of configuration file to use
* @param commands the list of command to execute
* @param timeout how long to wait for each command to execute
- * @return #GNUNET_OK if all is okay, != #GNUNET_OK otherwise.
- * non-GNUNET_OK codes are #GNUNET_SYSERR most of the
- * times.
+ * @param rc function to call with the final result
+ * @param rc_cls closure for @a rc
+ */
+void
+GNUNET_TESTING_run (struct GNUNET_TESTING_Command *commands,
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_TESTING_ResultCallback rc,
+ void *rc_cls);
+
+
+/**
+ * Start a GNUnet scheduler event loop and
+ * run the testsuite. Return 0 upon success.
+ * Expected to be called directly from main().
+ *
+ * @param commands the list of command to execute
+ * @param timeout how long to wait for each command to execute
+ * @return EXIT_SUCCESS on success, EXIT_FAILURE on failure
*/
int
-GNUNET_TESTING_run (const char *cfg_filename,
- struct GNUNET_TESTING_Command *commands,
- struct GNUNET_TIME_Relative timeout);
+GNUNET_TESTING_main (struct GNUNET_TESTING_Command *commands,
+ struct GNUNET_TIME_Relative timeout);
/**
@@ -432,6 +389,8 @@ GNUNET_TESTING_run (const char *cfg_filename,
*
* @param prog program's name to look into
* @param marker chunk to find in @a prog
+ * // FIXME: this does not belong here! => libgnunetutil, maybe?
+ * // FIXME: return bool? document return value!
*/
int
GNUNET_TESTING_has_in_name (const char *prog,
@@ -440,12 +399,45 @@ GNUNET_TESTING_has_in_name (const char *prog,
/* ************** Specific interpreter commands ************ */
+
+/**
+ * Returns the actual running command.
+ *
+ * @param is Global state of the interpreter, used by a command
+ * to access information about other commands.
+ * @return The actual running command.
+ */
+struct GNUNET_TESTING_Command *
+GNUNET_TESTING_interpreter_get_current_command (
+ struct GNUNET_TESTING_Interpreter *is);
+
+
+/**
+ * Check if the command is running.
+ *
+ * @param cmd The command to check.
+ * @return GNUNET_NO if the command is not running, GNUNET_YES if it is running.
+ */
+enum GNUNET_GenericReturnValue
+GNUNET_TESTING_running (const struct GNUNET_TESTING_Command *command);
+
+
+/**
+ * Check if a command is finished.
+ *
+ * @param cmd The command to check.
+ * @return GNUNET_NO if the command is not finished, GNUNET_YES if it is finished.
+ */
+enum GNUNET_GenericReturnValue
+GNUNET_TESTING_finished (struct GNUNET_TESTING_Command *command);
+
+
/**
* Create a "signal" CMD.
*
* @param label command label.
* @param process_label label of a command that has a process trait
- * @param process_index index of the process trait at @a process_label
+ * @param process_index index of the process trait at @a process_label // FIXME: enum? needed?
* @param signal signal to send to @a process.
* @return the command.
*/
@@ -484,49 +476,8 @@ GNUNET_TESTING_cmd_batch (const char *label,
/**
- * Test if this command is a batch command.
- *
- * @return false if not, true if it is a batch command
- */
-// TODO: figure out if this needs to be exposed in the public API.
-int
-GNUNET_TESTING_cmd_is_batch (const struct GNUNET_TESTING_Command *cmd);
-
-
-/**
- * Advance internal pointer to next command.
- *
- * @param is interpreter state.
- */
-// TODO: figure out if this needs to be exposed in the public API.
-void
-GNUNET_TESTING_cmd_batch_next (struct GNUNET_TESTING_Interpreter *is);
-
-
-/**
- * Obtain what command the batch is at.
- *
- * @return cmd current batch command
- */
-// TODO: figure out if this needs to be exposed in the public API.
-struct GNUNET_TESTING_Command *
-GNUNET_TESTING_cmd_batch_get_current (const struct GNUNET_TESTING_Command *cmd);
-
-
-/**
- * Set what command the batch should be at.
- *
- * @param cmd current batch command
- * @param new_ip where to move the IP
- */
-// TODO: figure out if this needs to be exposed in the public API.
-void
-GNUNET_TESTING_cmd_batch_set_current (const struct GNUNET_TESTING_Command *cmd,
- unsigned int new_ip);
-
-
-/**
* Performance counter.
+ * // FIXME: this might not belong here!
*/
struct GNUNET_TESTING_Timer
{
@@ -569,6 +520,74 @@ GNUNET_TESTING_get_topo_from_file (const char *filename);
/**
+ * Parse the topology data.
+ *
+ * @param data The topology data.
+ * @return The GNUNET_TESTING_NetjailTopology
+ */
+struct GNUNET_TESTING_NetjailTopology *
+GNUNET_TESTING_get_topo_from_string (char *data);
+
+
+/**
+ * Get the connections to other nodes for a specific node.
+ *
+ * @param num The specific node we want the connections for.
+ * @param topology The topology we get the connections from.
+ * @return The connections of the node.
+ */
+struct GNUNET_TESTING_NodeConnection *
+GNUNET_TESTING_get_connections (unsigned int num, struct
+ GNUNET_TESTING_NetjailTopology *topology);
+
+
+/**
+ * Get the address for a specific communicator from a connection.
+ *
+ * @param connection The connection we like to have the address from.
+ * @param prefix The communicator protocol prefix.
+ * @return The address of the communicator.
+ */
+char *
+GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection,
+ char *prefix);
+
+
+/**
+ * Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
+ *
+ * @param topology The GNUNET_TESTING_NetjailTopology to be deallocated.
+ */
+void
+GNUNET_TESTING_free_topology (struct GNUNET_TESTING_NetjailTopology *topology);
+
+
+/**
+ * Calculate the unique id identifying a node from a given connction.
+ *
+ * @param node_connection The connection we calculate the id from.
+ * @param topology The topology we get all needed information from.
+ * @return The unique id of the node from the connection.
+ */
+unsigned int
+GNUNET_TESTING_calculate_num (struct
+ GNUNET_TESTING_NodeConnection *node_connection,
+ struct GNUNET_TESTING_NetjailTopology *topology);
+
+
+/**
+ * Retrieve the public key from the test system with the unique node id.
+ *
+ * @param num The unique node id.
+ * @param tl_system The test system.
+ * @return The peer identity wrapping the public key.
+ */
+struct GNUNET_PeerIdentity *
+GNUNET_TESTING_get_pub_key (unsigned int num,
+ const struct GNUNET_TESTING_System *tl_system);
+
+
+/**
* Obtain performance data from the interpreter.
*
* @param timers what commands (by label) to obtain runtimes for
@@ -622,7 +641,7 @@ GNUNET_TESTING_trait_end (void);
* @param index index number of the trait to extract.
* @return #GNUNET_OK when the trait is found.
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits,
const void **ret,
const char *trait,
@@ -631,472 +650,120 @@ GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits,
/* ****** Specific traits supported by this component ******* */
-/**
- * Obtain location where a command stores a pointer to a process.
- *
- * @param cmd command to extract trait from.
- * @param index which process to pick if @a cmd
- * has multiple on offer.
- * @param[out] processp set to the address of the pointer to the
- * process.
- * @return #GNUNET_OK on success.
- */
-int
-GNUNET_TESTING_get_trait_process (const struct GNUNET_TESTING_Command *cmd,
- unsigned int index,
- struct GNUNET_OS_Process ***processp);
-
-
-/**
- * Offer location where a command stores a pointer to a process.
- *
- * @param index offered location index number, in case there are
- * multiple on offer.
- * @param processp process location to offer.
- * @return the trait.
- */
-struct GNUNET_TESTING_Trait
-GNUNET_TESTING_make_trait_process (unsigned int index,
- struct GNUNET_OS_Process **processp);
-
-
-/**
- * Offer number trait, 32-bit version.
- *
- * @param index the number's index number.
- * @param n number to offer.
- */
-struct GNUNET_TESTING_Trait
-GNUNET_TESTING_make_trait_uint32 (unsigned int index,
- const uint32_t *n);
-
-
-/**
- * Obtain a "number" value from @a cmd, 32-bit version.
- *
- * @param cmd command to extract the number from.
- * @param index the number's index number.
- * @param[out] n set to the number coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-GNUNET_TESTING_get_trait_uint32 (const struct GNUNET_TESTING_Command *cmd,
- unsigned int index,
- const uint32_t **n);
-
-
-/**
- * Offer number trait, 64-bit version.
- *
- * @param index the number's index number.
- * @param n number to offer.
- */
-struct GNUNET_TESTING_Trait
-GNUNET_TESTING_make_trait_uint64 (unsigned int index,
- const uint64_t *n);
-
-
-/**
- * Obtain a "number" value from @a cmd, 64-bit version.
- *
- * @param cmd command to extract the number from.
- * @param index the number's index number.
- * @param[out] n set to the number coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-GNUNET_TESTING_get_trait_uint64 (const struct GNUNET_TESTING_Command *cmd,
- unsigned int index,
- const uint64_t **n);
-
-
-/**
- * Offer number trait, 64-bit signed version.
- *
- * @param index the number's index number.
- * @param n number to offer.
- */
-struct GNUNET_TESTING_Trait
-GNUNET_TESTING_make_trait_int64 (unsigned int index,
- const int64_t *n);
-
-
-/**
- * Obtain a "number" value from @a cmd, 64-bit signed version.
- *
- * @param cmd command to extract the number from.
- * @param index the number's index number.
- * @param[out] n set to the number coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-GNUNET_TESTING_get_trait_int64 (const struct GNUNET_TESTING_Command *cmd,
- unsigned int index,
- const int64_t **n);
-
-
-/**
- * Offer a number.
- *
- * @param index the number's index number.
- * @param n the number to offer.
- * @return #GNUNET_OK on success.
- */
-struct GNUNET_TESTING_Trait
-GNUNET_TESTING_make_trait_uint (unsigned int index,
- const unsigned int *i);
-
-
-/**
- * Obtain a number from @a cmd.
- *
- * @param cmd command to extract the number from.
- * @param index the number's index number.
- * @param[out] n set to the number coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-GNUNET_TESTING_get_trait_uint (const struct GNUNET_TESTING_Command *cmd,
- unsigned int index,
- const unsigned int **n);
-
-/**
- * Obtain a string from @a cmd.
- *
- * @param cmd command to extract the subject from.
- * @param index index number associated with the transfer
- * subject to offer.
- * @param[out] s where to write the offered
- * string.
- * @return #GNUNET_OK on success.
- */
-int
-GNUNET_TESTING_get_trait_string (
- const struct GNUNET_TESTING_Command *cmd,
- unsigned int index,
- const char **s);
-
-
-/**
- * Offer string subject.
- *
- * @param index index number associated with the transfer
- * subject being offered.
- * @param s string to offer.
- * @return the trait.
- */
-struct GNUNET_TESTING_Trait
-GNUNET_TESTING_make_trait_string (unsigned int index,
- const char *s);
-
-/**
- * Offer a command in a trait.
- *
- * @param index always zero. Commands offering this
- * kind of traits do not need this index. For
- * example, a "meta" CMD returns always the
- * CMD currently being executed.
- * @param cmd wire details to offer.
- *
- * @return the trait.
- */
-struct GNUNET_TESTING_Trait
-GNUNET_TESTING_make_trait_cmd (unsigned int index,
- const struct GNUNET_TESTING_Command *cmd);
-
-
-/**
- * Obtain a command from @a cmd.
- *
- * @param cmd command to extract the command from.
- * @param index always zero. Commands offering this
- * kind of traits do not need this index. For
- * example, a "meta" CMD returns always the
- * CMD currently being executed.
- * @param[out] _cmd where to write the wire details.
- * @return #GNUNET_OK on success.
- */
-int
-GNUNET_TESTING_get_trait_cmd (const struct GNUNET_TESTING_Command *cmd,
- unsigned int index,
- struct GNUNET_TESTING_Command **_cmd);
-
-
-/**
- * Obtain a uuid from @a cmd.
- *
- * @param cmd command to extract the uuid from.
- * @param index which amount to pick if @a cmd has multiple
- * on offer
- * @param[out] uuid where to write the uuid.
- * @return #GNUNET_OK on success.
- */
-int
-GNUNET_TESTING_get_trait_uuid (const struct GNUNET_TESTING_Command *cmd,
- unsigned int index,
- struct GNUNET_Uuid **uuid);
-
-
-/**
- * Offer a uuid in a trait.
- *
- * @param index which uuid to offer, in case there are
- * multiple available.
- * @param uuid the uuid to offer.
- *
- * @return the trait.
- */
-struct GNUNET_TESTING_Trait
-GNUNET_TESTING_make_trait_uuid (unsigned int index,
- const struct GNUNET_Uuid *uuid);
-
-
-/**
- * Obtain a absolute time from @a cmd.
- *
- * @param cmd command to extract trait from
- * @param index which time stamp to pick if
- * @a cmd has multiple on offer.
- * @param[out] time set to the wanted WTID.
- * @return #GNUNET_OK on success
- */
-int
-GNUNET_TESTING_get_trait_absolute_time (
- const struct GNUNET_TESTING_Command *cmd,
- unsigned int index,
- const struct GNUNET_TIME_Absolute **time);
-
-
-/**
- * Offer a absolute time.
- *
- * @param index associate the object with this index
- * @param time which object should be returned
- * @return the trait.
- */
-struct GNUNET_TESTING_Trait
-GNUNET_TESTING_make_trait_absolute_time (
- unsigned int index,
- const struct GNUNET_TIME_Absolute *time);
-
-
-/**
- * Obtain a relative time from @a cmd.
- *
- * @param cmd command to extract trait from
- * @param index which time to pick if
- * @a cmd has multiple on offer.
- * @param[out] time set to the wanted WTID.
- * @return #GNUNET_OK on success
- */
-int
-GNUNET_TESTING_get_trait_relative_time (
- const struct GNUNET_TESTING_Command *cmd,
- unsigned int index,
- const struct GNUNET_TIME_Relative **time);
-
-
-/**
- * Offer a relative time.
- *
- * @param index associate the object with this index
- * @param time which object should be returned
- * @return the trait.
- */
-struct GNUNET_TESTING_Trait
-GNUNET_TESTING_make_trait_relative_time (
- unsigned int index,
- const struct GNUNET_TIME_Relative *time);
-
-
-/**
- * Create command.
- *
- * @param label name for command.
- * @param now when the command was started.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_hello_world_birth (const char *label,
- struct GNUNET_TIME_Absolute *now);
-
-/**
- * Create command.
- *
- * @param label name for command.
- * @param message initial message.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_hello_world (const char *label,
- const char *birthLabel,
- char *message);
-
-/**
- * Offer data from trait
- *
- * @param cmd command to extract the url from.
- * @param pt which url is to be picked, in case
- * multiple are offered.
- * @param[out] url where to write the url.
- * @return #GNUNET_OK on success.
- */
-int
-GNUNET_TESTING_get_trait_what_am_i (const struct GNUNET_TESTING_Command *cmd,
- char **what_am_i);
-
-
-int
-GNUNET_TESTING_get_trait_test_system (const struct
- GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTING_System **test_system);
-
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_system_create (const char *label,
- const char *testdir);
-
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_system_destroy (const char *label,
- const char *create_label);
-
-
-/**
- * Create command.
- *
- * @param label name for command.
- * @param local_m Number of local nodes in each namespace.
- * @param global_n The number of namespaces.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_netjail_start (const char *label,
- char *local_m,
- char *global_n);
-
-/**
- * Create command.
- *
- * @param label name for command.
- * @param topology_config Configuration file for the test topology.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_netjail_start_v2 (const char *label,
- char *topology_config);
-
-
-/**
- * Create command.
- *
- * @param label name for command.
- * @param binaryname to exec.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label,
- char *local_m,
- char *global_n,
- char *plugin_name,
- unsigned int *rv);
-
-
-/**
- * Create command.
- *
- * @param label Name for the command.
- * @param topology_config Configuration file for the test topology.
- * @param rv Pointer to the return value of the test.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_netjail_start_testing_system_v2 (const char *label,
- const char *topology_config,
- unsigned int *rv);
-
/**
- * Create command.
- *
- * @param label name for command.
- * @param binaryname to stop.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_netjail_stop (const char *label,
- char *local_m,
- char *global_n);
-
-
-/**
- * Create command.
- *
- * @param label name for command.
- * @param topology_config Configuration file for the test topology.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_netjail_stop_v2 (const char *label,
- char *topology_config);
-
+ * Create headers for a trait with name @a name for
+ * statically allocated data of type @a type.
+ */
+#define GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT(name,type) \
+ enum GNUNET_GenericReturnValue \
+ GNUNET_TESTING_get_trait_ ## name ( \
+ const struct GNUNET_TESTING_Command *cmd, \
+ type **ret); \
+ struct GNUNET_TESTING_Trait \
+ GNUNET_TESTING_make_trait_ ## name ( \
+ type * value);
+
+
+/**
+ * Create C implementation for a trait with name @a name for statically
+ * allocated data of type @a type.
+ */
+#define GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT(name,type) \
+ enum GNUNET_GenericReturnValue \
+ GNUNET_TESTING_get_trait_ ## name ( \
+ const struct GNUNET_TESTING_Command *cmd, \
+ type **ret) \
+ { \
+ if (NULL == cmd->traits) return GNUNET_SYSERR; \
+ return cmd->traits (cmd->cls, \
+ (const void **) ret, \
+ GNUNET_S (name), \
+ 0); \
+ } \
+ struct GNUNET_TESTING_Trait \
+ GNUNET_TESTING_make_trait_ ## name ( \
+ type * value) \
+ { \
+ struct GNUNET_TESTING_Trait ret = { \
+ .trait_name = GNUNET_S (name), \
+ .ptr = (const void *) value \
+ }; \
+ return ret; \
+ }
+
+
+/**
+ * Create headers for a trait with name @a name for
+ * statically allocated data of type @a type.
+ */
+#define GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT(name,type) \
+ enum GNUNET_GenericReturnValue \
+ GNUNET_TESTING_get_trait_ ## name ( \
+ const struct GNUNET_TESTING_Command *cmd, \
+ unsigned int index, \
+ type **ret); \
+ struct GNUNET_TESTING_Trait \
+ GNUNET_TESTING_make_trait_ ## name ( \
+ unsigned int index, \
+ type * value);
+
+
+/**
+ * Create C implementation for a trait with name @a name for statically
+ * allocated data of type @a type.
+ */
+#define GNUNET_TESTING_MAKE_IMPL_INDEXED_TRAIT(name,type) \
+ enum GNUNET_GenericReturnValue \
+ GNUNET_TESTING_get_trait_ ## name ( \
+ const struct GNUNET_TESTING_Command *cmd, \
+ unsigned int index, \
+ type **ret) \
+ { \
+ if (NULL == cmd->traits) return GNUNET_SYSERR; \
+ return cmd->traits (cmd->cls, \
+ (const void **) ret, \
+ GNUNET_S (name), \
+ index); \
+ } \
+ struct GNUNET_TESTING_Trait \
+ GNUNET_TESTING_make_trait_ ## name ( \
+ unsigned int index, \
+ type * value) \
+ { \
+ struct GNUNET_TESTING_Trait ret = { \
+ .index = index, \
+ .trait_name = GNUNET_S (name), \
+ .ptr = (const void *) value \
+ }; \
+ return ret; \
+ }
+
+
+/**
+ * Call #op on all simple traits.
+ */
+#define GNUNET_TESTING_SIMPLE_TRAITS(op) \
+ op (process, struct GNUNET_OS_Process *)
+
+
+/**
+ * Call #op on all indexed traits.
+ */
+#define GNUNET_TESTING_INDEXED_TRAITS(op) \
+ op (uint32, const uint32_t) \
+ op (uint64, const uint64_t) \
+ op (int64, const int64_t) \
+ op (uint, const unsigned int) \
+ op (string, const char) \
+ op (cmd, const struct GNUNET_TESTING_Command) \
+ op (uuid, const struct GNUNET_Uuid) \
+ op (time, const struct GNUNET_TIME_Absolute) \
+ op (absolute_time, const struct GNUNET_TIME_Absolute) \
+ op (relative_time, const struct GNUNET_TIME_Relative)
+
+GNUNET_TESTING_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT)
+
+GNUNET_TESTING_INDEXED_TRAITS (GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT)
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_stop_testing_system (const char *label,
- const char *helper_start_label,
- char *local_m,
- char *global_n);
-
-/**
- * Create command.
- *
- * @param label name for command.
- * @param topology_config Configuration file for the test topology.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_stop_testing_system_v2 (const char *label,
- const char *helper_start_label,
- const char *topology_config);
-
-
-int
-GNUNET_TESTING_get_trait_helper_handles (const struct
- GNUNET_TESTING_Command *cmd,
- struct GNUNET_HELPER_Handle ***helper);
-
-
-/**
- * Offer handles to testing cmd helper from trait
- *
- * @param cmd command to extract the message from.
- * @param pt pointer to message.
- * @return #GNUNET_OK on success.
- */
-int
-GNUNET_TESTING_get_trait_helper_handles_v2 (const struct
- GNUNET_TESTING_Command *cmd,
- struct GNUNET_HELPER_Handle ***
- helper);
-
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_block_until_all_peers_started (const char *label,
- unsigned int *
- all_peers_started);
-
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_block_until_external_trigger (const char *label,
- unsigned int *
- stop_blocking);
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_send_peer_ready (const char *label,
- TESTING_CMD_HELPER_write_cb write_message);
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_local_test_finished (const char *label,
- TESTING_CMD_HELPER_write_cb
- write_message);
#endif
diff --git a/src/include/gnunet_testing_plugin.h b/src/include/gnunet_testing_plugin.h
index 151827d4b..b59d2cea1 100644
--- a/src/include/gnunet_testing_plugin.h
+++ b/src/include/gnunet_testing_plugin.h
@@ -46,11 +46,19 @@ typedef void
char *node_ip,
char *n,
char *m,
- char *local_m);
+ char *local_m,
+ char *topology_data,
+ unsigned int *read_file);
+
typedef void
(*GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED) ();
+
+typedef void
+(*GNUNET_TESTING_PLUGIN_ALL_LOCAL_TESTS_PREPARED) ();
+
+
struct GNUNET_TESTING_PluginFunctions
{
/**
@@ -61,6 +69,8 @@ struct GNUNET_TESTING_PluginFunctions
GNUNET_TESTING_PLUGIN_StartTestCase start_testcase;
GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED all_peers_started;
+
+ GNUNET_TESTING_PLUGIN_ALL_LOCAL_TESTS_PREPARED all_local_tests_prepared;
};
#if 0 /* keep Emacsens' auto-indent happy */
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h
index d190eff92..459efc506 100644
--- a/src/include/gnunet_transport_service.h
+++ b/src/include/gnunet_transport_service.h
@@ -115,9 +115,10 @@ struct GNUNET_TRANSPORT_AddressToStringContext;
* if #GNUNET_NO: address was invalid (or not supported)
* if #GNUNET_SYSERR: communication error (IPC error)
*/
-typedef void (*GNUNET_TRANSPORT_AddressToStringCallback) (void *cls,
- const char *address,
- int res);
+typedef void
+(*GNUNET_TRANSPORT_AddressToStringCallback) (void *cls,
+ const char *address,
+ int res);
/**
@@ -326,7 +327,8 @@ struct GNUNET_TRANSPORT_PeerMonitoringContext;
* @param state current state this peer is in
* @param state_timeout timeout for the current state of the peer
*/
-typedef void (*GNUNET_TRANSPORT_PeerIterateCallback) (
+typedef void
+(*GNUNET_TRANSPORT_PeerIterateCallback) (
void *cls,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Address *address,
@@ -394,7 +396,8 @@ struct GNUNET_TRANSPORT_Blacklist;
* @param pid peer to approve or disapproave
* @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not
*/
-typedef int (*GNUNET_TRANSPORT_BlacklistCallback) (
+typedef int
+(*GNUNET_TRANSPORT_BlacklistCallback) (
void *cls,
const struct GNUNET_PeerIdentity *pid);
@@ -541,7 +544,8 @@ struct GNUNET_TRANSPORT_SessionInfo
* NULL with @a session being non-NULL if the monitor
* was being cancelled while sessions were active
*/
-typedef void (*GNUNET_TRANSPORT_SessionMonitorCallback) (
+typedef void
+(*GNUNET_TRANSPORT_SessionMonitorCallback) (
void *cls,
struct GNUNET_TRANSPORT_PluginSession *session,
void **session_ctx,
@@ -593,7 +597,8 @@ struct GNUNET_TRANSPORT_CoreHandle;
* @param mq message queue to use to transmit to @a peer
* @return closure to use in MQ handlers
*/
-typedef void *(*GNUNET_TRANSPORT_NotifyConnect) (
+typedef void *
+(*GNUNET_TRANSPORT_NotifyConnect) (
void *cls,
const struct GNUNET_PeerIdentity *peer,
struct GNUNET_MQ_Handle *mq);
@@ -610,7 +615,8 @@ typedef void *(*GNUNET_TRANSPORT_NotifyConnect) (
* @param handlers_cls closure of the handlers, was returned from the
* connect notification callback
*/
-typedef void (*GNUNET_TRANSPORT_NotifyDisconnect) (
+typedef void
+(*GNUNET_TRANSPORT_NotifyDisconnect) (
void *cls,
const struct GNUNET_PeerIdentity *peer,
void *handler_cls);
@@ -632,7 +638,8 @@ typedef void (*GNUNET_TRANSPORT_NotifyDisconnect) (
* @param handlers_cls closure of the handlers, was returned from the
* connect notification callback
*/
-typedef void (*GNUNET_TRANSPORT_NotifyExcessBandwidth) (
+typedef void
+(*GNUNET_TRANSPORT_NotifyExcessBandwidth) (
void *cls,
const struct GNUNET_PeerIdentity *neighbour,
void *handlers_cls);
diff --git a/src/json/json.c b/src/json/json.c
index 51d5c0c72..6d11b4fdd 100644
--- a/src/json/json.c
+++ b/src/json/json.c
@@ -77,7 +77,7 @@ GNUNET_JSON_spec_mark_optional (struct GNUNET_JSON_Specification spec)
{
struct GNUNET_JSON_Specification ret = spec;
- ret.is_optional = GNUNET_YES;
+ ret.is_optional = true;
return ret;
}
diff --git a/src/json/json_helper.c b/src/json/json_helper.c
index 55435ea19..3a11f205c 100644
--- a/src/json/json_helper.c
+++ b/src/json/json_helper.c
@@ -847,11 +847,8 @@ GNUNET_JSON_spec_rsa_public_key (const char *name,
struct GNUNET_JSON_Specification ret = {
.parser = &parse_rsa_public_key,
.cleaner = &clean_rsa_public_key,
- .cls = NULL,
.field = name,
- .ptr = pk,
- .ptr_size = 0,
- .size_ptr = NULL
+ .ptr = pk
};
*pk = NULL;
diff --git a/src/messenger/Makefile.am b/src/messenger/Makefile.am
index 3fc532e7e..4be11f3aa 100644
--- a/src/messenger/Makefile.am
+++ b/src/messenger/Makefile.am
@@ -10,6 +10,19 @@ pkgcfgdir= $(pkgdatadir)/config.d/
libexecdir= $(pkglibdir)/libexec/
+plugin_LTLIBRARIES = \
+ libgnunet_plugin_gnsrecord_messenger.la
+
+
+libgnunet_plugin_gnsrecord_messenger_la_SOURCES = \
+ plugin_gnsrecord_messenger.c
+libgnunet_plugin_gnsrecord_messenger_la_LIBADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(LTLIBINTL)
+libgnunet_plugin_gnsrecord_messenger_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+
+
pkgcfg_DATA = \
messenger.conf
diff --git a/src/messenger/gnunet-messenger.c b/src/messenger/gnunet-messenger.c
index 28fa4b147..e2d106be8 100644
--- a/src/messenger/gnunet-messenger.c
+++ b/src/messenger/gnunet-messenger.c
@@ -42,8 +42,11 @@ struct GNUNET_MESSENGER_Handle *messenger;
* @param[in] flags Flags of message
*/
void
-on_message (void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *sender,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash,
+on_message (void *cls,
+ struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_MESSENGER_Contact *sender,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash,
enum GNUNET_MESSENGER_MessageFlags flags)
{
const char *sender_name = GNUNET_MESSENGER_contact_get_name (sender);
@@ -124,7 +127,8 @@ listen_stdio (void *cls);
#define MAX_BUFFER_SIZE 60000
static int
-iterate_send_private_message (void *cls, struct GNUNET_MESSENGER_Room *room,
+iterate_send_private_message (void *cls,
+ struct GNUNET_MESSENGER_Room *room,
const struct GNUNET_MESSENGER_Contact *contact)
{
struct GNUNET_MESSENGER_Message *message = cls;
@@ -226,7 +230,8 @@ struct GNUNET_SCHEDULER_Task *shutdown_task;
* @param[in/out] handle Handle of messenger service
*/
static void
-on_identity (void *cls, struct GNUNET_MESSENGER_Handle *handle)
+on_identity (void *cls,
+ struct GNUNET_MESSENGER_Handle *handle)
{
struct GNUNET_HashCode key;
memset (&key, 0, sizeof(key));
@@ -292,7 +297,10 @@ on_identity (void *cls, struct GNUNET_MESSENGER_Handle *handle)
* @param[in] cfg configuration
*/
static void
-run (void *cls, char *const*args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
+run (void *cls,
+ char *const*args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
{
messenger = GNUNET_MESSENGER_connect (cfg, ego_name, &on_identity, NULL, &on_message, NULL);
@@ -307,7 +315,8 @@ run (void *cls, char *const*args, const char *cfgfile, const struct GNUNET_CONFI
* @return #EXIT_SUCCESS ok, #EXIT_FAILURE on error
*/
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
const char *description = "Open and connect to rooms using the MESSENGER to chat.";
diff --git a/src/messenger/gnunet-service-messenger.c b/src/messenger/gnunet-service-messenger.c
index 7edd76d32..546f4c0d2 100644
--- a/src/messenger/gnunet-service-messenger.c
+++ b/src/messenger/gnunet-service-messenger.c
@@ -39,14 +39,16 @@ struct GNUNET_MESSENGER_Client
struct GNUNET_MESSENGER_Service *messenger;
static int
-check_create (void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg)
+check_create (void *cls,
+ const struct GNUNET_MESSENGER_CreateMessage *msg)
{
GNUNET_MQ_check_zero_termination(msg);
return GNUNET_OK;
}
static void
-handle_create (void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg)
+handle_create (void *cls,
+ const struct GNUNET_MESSENGER_CreateMessage *msg)
{
struct GNUNET_MESSENGER_Client *msg_client = cls;
@@ -60,7 +62,8 @@ handle_create (void *cls, const struct GNUNET_MESSENGER_CreateMessage *msg)
}
static void
-handle_update (void *cls, const struct GNUNET_MESSENGER_UpdateMessage *msg)
+handle_update (void *cls,
+ const struct GNUNET_MESSENGER_UpdateMessage *msg)
{
struct GNUNET_MESSENGER_Client *msg_client = cls;
@@ -70,7 +73,8 @@ handle_update (void *cls, const struct GNUNET_MESSENGER_UpdateMessage *msg)
}
static void
-handle_destroy (void *cls, const struct GNUNET_MESSENGER_DestroyMessage *msg)
+handle_destroy (void *cls,
+ const struct GNUNET_MESSENGER_DestroyMessage *msg)
{
struct GNUNET_MESSENGER_Client *msg_client = cls;
@@ -78,14 +82,16 @@ handle_destroy (void *cls, const struct GNUNET_MESSENGER_DestroyMessage *msg)
}
static int
-check_set_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
+check_set_name (void *cls,
+ const struct GNUNET_MESSENGER_NameMessage *msg)
{
GNUNET_MQ_check_zero_termination(msg);
return GNUNET_OK;
}
static void
-handle_set_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
+handle_set_name (void *cls,
+ const struct GNUNET_MESSENGER_NameMessage *msg)
{
struct GNUNET_MESSENGER_Client *msg_client = cls;
@@ -99,7 +105,8 @@ handle_set_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
}
static void
-handle_room_open (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
+handle_room_open (void *cls,
+ const struct GNUNET_MESSENGER_RoomMessage *msg)
{
struct GNUNET_MESSENGER_Client *msg_client = cls;
@@ -125,7 +132,8 @@ handle_room_open (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
}
static void
-handle_room_entry (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
+handle_room_entry (void *cls,
+ const struct GNUNET_MESSENGER_RoomMessage *msg)
{
struct GNUNET_MESSENGER_Client *msg_client = cls;
@@ -153,7 +161,8 @@ handle_room_entry (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
}
static void
-handle_room_close (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
+handle_room_close (void *cls,
+ const struct GNUNET_MESSENGER_RoomMessage *msg)
{
struct GNUNET_MESSENGER_Client *msg_client = cls;
@@ -179,7 +188,8 @@ handle_room_close (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
}
static int
-check_send_message (void *cls, const struct GNUNET_MESSENGER_SendMessage *msg)
+check_send_message (void *cls,
+ const struct GNUNET_MESSENGER_SendMessage *msg)
{
const uint16_t full_length = ntohs (msg->header.size);
@@ -211,20 +221,21 @@ check_for_message:
struct GNUNET_MESSENGER_Message message;
- if (length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN))
+ if (length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_NO))
return GNUNET_NO;
if (GNUNET_YES != decode_message (&message, msg_length, msg_buffer, GNUNET_NO, NULL))
return GNUNET_NO;
- if (GNUNET_YES != filter_message_sending(&message))
- return GNUNET_NO;
+ const int allowed = filter_message_sending(&message);
- return GNUNET_OK;
+ cleanup_message(&message);
+ return GNUNET_YES == allowed? GNUNET_OK : GNUNET_NO;
}
static void
-handle_send_message (void *cls, const struct GNUNET_MESSENGER_SendMessage *msg)
+handle_send_message (void *cls,
+ const struct GNUNET_MESSENGER_SendMessage *msg)
{
struct GNUNET_MESSENGER_Client *msg_client = cls;
@@ -267,11 +278,14 @@ handle_send_message (void *cls, const struct GNUNET_MESSENGER_SendMessage *msg)
GNUNET_MESSENGER_name_of_kind (message.header.kind), GNUNET_h2s (key));
end_handling:
+ cleanup_message(&message);
+
GNUNET_SERVICE_client_continue (msg_client->client);
}
static void
-callback_found_message (void *cls, struct GNUNET_MESSENGER_SrvRoom *room,
+callback_found_message (void *cls,
+ struct GNUNET_MESSENGER_SrvRoom *room,
const struct GNUNET_MESSENGER_Message *message,
const struct GNUNET_HashCode *hash)
{
@@ -296,11 +310,12 @@ callback_found_message (void *cls, struct GNUNET_MESSENGER_SrvRoom *room,
struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of(member, message, hash);
if (session)
- notify_handle_message (msg_client->handle, get_room_key(room), session, message, hash);
+ notify_handle_message (msg_client->handle, room, session, message, hash);
}
static void
-handle_get_message (void *cls, const struct GNUNET_MESSENGER_GetMessage *msg)
+handle_get_message (void *cls,
+ const struct GNUNET_MESSENGER_GetMessage *msg)
{
struct GNUNET_MESSENGER_Client *msg_client = cls;
@@ -341,7 +356,9 @@ end_handling:
}
static void*
-callback_client_connect (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
+callback_client_connect (void *cls,
+ struct GNUNET_SERVICE_Client *client,
+ struct GNUNET_MQ_Handle *mq)
{
struct GNUNET_MESSENGER_Client *msg_client = GNUNET_new(struct GNUNET_MESSENGER_Client);
@@ -352,7 +369,9 @@ callback_client_connect (void *cls, struct GNUNET_SERVICE_Client *client, struct
}
static void
-callback_client_disconnect (void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls)
+callback_client_disconnect (void *cls,
+ struct GNUNET_SERVICE_Client *client,
+ void *internal_cls)
{
struct GNUNET_MESSENGER_Client *msg_client = internal_cls;
@@ -369,7 +388,9 @@ callback_client_disconnect (void *cls, struct GNUNET_SERVICE_Client *client, voi
* @param[in/out] service the initialized service
*/
static void
-run (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_SERVICE_Handle *service)
+run (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *config,
+ struct GNUNET_SERVICE_Handle *service)
{
messenger = create_service (config, service);
diff --git a/src/messenger/gnunet-service-messenger_basement.c b/src/messenger/gnunet-service-messenger_basement.c
index f302c8d66..89aa103ee 100644
--- a/src/messenger/gnunet-service-messenger_basement.c
+++ b/src/messenger/gnunet-service-messenger_basement.c
@@ -40,7 +40,9 @@ count_of_tunnels (const struct GNUNET_MESSENGER_ListTunnels *tunnels)
}
int
-should_connect_tunnel_to (size_t count, size_t src, size_t dst)
+should_connect_tunnel_to (size_t count,
+ size_t src,
+ size_t dst)
{
if ((src + 1) % count == dst % count)
return GNUNET_YES;
@@ -49,7 +51,9 @@ should_connect_tunnel_to (size_t count, size_t src, size_t dst)
}
int
-required_connection_between (size_t count, size_t src, size_t dst)
+required_connection_between (size_t count,
+ size_t src,
+ size_t dst)
{
if (GNUNET_YES == should_connect_tunnel_to (count, src, dst))
return GNUNET_YES;
diff --git a/src/messenger/gnunet-service-messenger_basement.h b/src/messenger/gnunet-service-messenger_basement.h
index b19aec405..a097b482f 100644
--- a/src/messenger/gnunet-service-messenger_basement.h
+++ b/src/messenger/gnunet-service-messenger_basement.h
@@ -48,7 +48,9 @@ count_of_tunnels (const struct GNUNET_MESSENGER_ListTunnels *tunnels);
* @return #GNUNET_YES or #GNUNET_NO based on topologic requirement
*/
int
-should_connect_tunnel_to (size_t count, size_t src, size_t dst);
+should_connect_tunnel_to (size_t count,
+ size_t src,
+ size_t dst);
/**
* Returns #GNUNET_YES or #GNUNET_NO to determine if the peers of index <i>src</i> and
@@ -61,6 +63,8 @@ should_connect_tunnel_to (size_t count, size_t src, size_t dst);
* @return #GNUNET_YES or #GNUNET_NO based on topologic requirement
*/
int
-required_connection_between (size_t count, size_t src, size_t dst);
+required_connection_between (size_t count,
+ size_t src,
+ size_t dst);
#endif //GNUNET_SERVICE_MESSENGER_BASEMENT_H
diff --git a/src/messenger/gnunet-service-messenger_ego_store.c b/src/messenger/gnunet-service-messenger_ego_store.c
index 3b069fcf5..c460ac1c7 100644
--- a/src/messenger/gnunet-service-messenger_ego_store.c
+++ b/src/messenger/gnunet-service-messenger_ego_store.c
@@ -28,7 +28,10 @@
#include "gnunet-service-messenger_handle.h"
static void
-callback_update_ego (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *identifier)
+callback_update_ego (void *cls,
+ struct GNUNET_IDENTITY_Ego *ego,
+ void **ctx,
+ const char *identifier)
{
if ((!ego) || (!identifier))
return;
@@ -41,7 +44,8 @@ callback_update_ego (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, con
}
void
-init_ego_store(struct GNUNET_MESSENGER_EgoStore *store, const struct GNUNET_CONFIGURATION_Handle *config)
+init_ego_store(struct GNUNET_MESSENGER_EgoStore *store,
+ const struct GNUNET_CONFIGURATION_Handle *config)
{
GNUNET_assert ((store) && (config));
@@ -58,7 +62,9 @@ init_ego_store(struct GNUNET_MESSENGER_EgoStore *store, const struct GNUNET_CONF
static int
-iterate_destroy_egos (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_destroy_egos (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_Ego *ego = value;
GNUNET_free(ego);
@@ -112,7 +118,9 @@ clear_ego_store(struct GNUNET_MESSENGER_EgoStore *store)
}
static void
-callback_ego_create (void *cls, const struct GNUNET_IDENTITY_PrivateKey *key, const char *emsg)
+callback_ego_create (void *cls,
+ const struct GNUNET_IDENTITY_PrivateKey *key,
+ const char *emsg)
{
struct GNUNET_MESSENGER_EgoOperation *element = cls;
struct GNUNET_MESSENGER_EgoStore *store = element->store;
@@ -139,7 +147,8 @@ callback_ego_create (void *cls, const struct GNUNET_IDENTITY_PrivateKey *key, co
}
void
-create_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifier,
+create_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
+ const char *identifier,
void *handle)
{
GNUNET_assert ((store) && (identifier));
@@ -158,7 +167,8 @@ create_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifie
}
static void
-callback_ego_lookup (void *cls, struct GNUNET_IDENTITY_Ego *ego)
+callback_ego_lookup (void *cls,
+ struct GNUNET_IDENTITY_Ego *ego)
{
struct GNUNET_MESSENGER_EgoLookup *element = cls;
struct GNUNET_MESSENGER_EgoStore *store = element->store;
@@ -183,8 +193,10 @@ callback_ego_lookup (void *cls, struct GNUNET_IDENTITY_Ego *ego)
}
void
-lookup_store_ego(struct GNUNET_MESSENGER_EgoStore *store, const char *identifier,
- GNUNET_MESSENGER_EgoLookupCallback lookup, void *cls)
+lookup_store_ego(struct GNUNET_MESSENGER_EgoStore *store,
+ const char *identifier,
+ GNUNET_MESSENGER_EgoLookupCallback lookup,
+ void *cls)
{
GNUNET_assert (store);
@@ -219,7 +231,8 @@ lookup_store_ego(struct GNUNET_MESSENGER_EgoStore *store, const char *identifier
}
struct GNUNET_MESSENGER_Ego*
-update_store_ego(struct GNUNET_MESSENGER_EgoStore *store, const char *identifier,
+update_store_ego(struct GNUNET_MESSENGER_EgoStore *store,
+ const char *identifier,
const struct GNUNET_IDENTITY_PrivateKey *key)
{
GNUNET_assert ((store) && (identifier) && (key));
@@ -244,7 +257,8 @@ update_store_ego(struct GNUNET_MESSENGER_EgoStore *store, const char *identifier
}
static void
-callback_ego_rename (void *cls, const char *emsg)
+callback_ego_rename (void *cls,
+ const char *emsg)
{
struct GNUNET_MESSENGER_EgoOperation *element = cls;
struct GNUNET_MESSENGER_EgoStore *store = element->store;
@@ -277,7 +291,8 @@ callback_ego_rename (void *cls, const char *emsg)
}
void
-rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *old_identifier,
+rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
+ const char *old_identifier,
const char *new_identifier)
{
GNUNET_assert ((store) && (old_identifier) && (new_identifier));
diff --git a/src/messenger/gnunet-service-messenger_ego_store.h b/src/messenger/gnunet-service-messenger_ego_store.h
index 41f14fff2..4222a4e91 100644
--- a/src/messenger/gnunet-service-messenger_ego_store.h
+++ b/src/messenger/gnunet-service-messenger_ego_store.h
@@ -35,7 +35,8 @@ struct GNUNET_MESSENGER_Ego;
struct GNUNET_MESSENGER_EgoStore;
typedef void
-(*GNUNET_MESSENGER_EgoLookupCallback) (void *cls, const char *identifier,
+(*GNUNET_MESSENGER_EgoLookupCallback) (void *cls,
+ const char *identifier,
const struct GNUNET_MESSENGER_Ego *ego);
struct GNUNET_MESSENGER_EgoLookup
@@ -87,7 +88,8 @@ struct GNUNET_MESSENGER_EgoStore
* @param[in] config Configuration handle
*/
void
-init_ego_store (struct GNUNET_MESSENGER_EgoStore *store, const struct GNUNET_CONFIGURATION_Handle *config);
+init_ego_store (struct GNUNET_MESSENGER_EgoStore *store,
+ const struct GNUNET_CONFIGURATION_Handle *config);
/**
* Clears an EGO-store, wipes its content and deallocates its memory.
@@ -107,7 +109,8 @@ clear_ego_store (struct GNUNET_MESSENGER_EgoStore *store);
* @param[in/out] handle Handle or NULL
*/
void
-create_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifier,
+create_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
+ const char *identifier,
void *handle);
/**
@@ -120,8 +123,10 @@ create_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifie
* @param[in] cls Closure
*/
void
-lookup_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifier,
- GNUNET_MESSENGER_EgoLookupCallback lookup, void *cls);
+lookup_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
+ const char *identifier,
+ GNUNET_MESSENGER_EgoLookupCallback lookup,
+ void *cls);
/**
* Updates the registration of an EGO to a <i>store</i> under
@@ -133,7 +138,8 @@ lookup_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifie
* @return Updated EGO
*/
struct GNUNET_MESSENGER_Ego*
-update_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifier,
+update_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
+ const char *identifier,
const struct GNUNET_IDENTITY_PrivateKey *key);
/**
@@ -146,7 +152,8 @@ update_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *identifie
* @param[in] new_identifier New identifier string
*/
void
-rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store, const char *old_identifier,
+rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
+ const char *old_identifier,
const char *new_identifier);
#endif //GNUNET_SERVICE_MESSENGER_EGO_STORE_H
diff --git a/src/messenger/gnunet-service-messenger_handle.c b/src/messenger/gnunet-service-messenger_handle.c
index d7007dbf6..341bb7251 100644
--- a/src/messenger/gnunet-service-messenger_handle.c
+++ b/src/messenger/gnunet-service-messenger_handle.c
@@ -31,7 +31,8 @@
#include "messenger_api_util.h"
struct GNUNET_MESSENGER_SrvHandle*
-create_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq)
+create_handle (struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_MQ_Handle *mq)
{
GNUNET_assert((service) && (mq));
@@ -49,7 +50,9 @@ create_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle
}
int
-iterate_free_member_ids (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_free_member_ids (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
GNUNET_free(value);
@@ -74,7 +77,9 @@ destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle)
}
void
-get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, const char *name, char **dir)
+get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle,
+ const char *name,
+ char **dir)
{
GNUNET_assert((handle) && (dir));
@@ -87,7 +92,8 @@ get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, const c
}
static int
-create_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
+create_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((handle) && (key));
@@ -112,7 +118,8 @@ create_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const
}
const struct GNUNET_ShortHashCode*
-get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
+get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((handle) && (key));
@@ -120,7 +127,8 @@ get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const str
}
int
-change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key,
+change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key,
const struct GNUNET_ShortHashCode *unique_id)
{
GNUNET_assert((handle) && (key) && (unique_id));
@@ -165,7 +173,8 @@ send_message_to_client:
}
static void
-change_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name)
+change_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const char *name)
{
GNUNET_assert(handle);
@@ -192,7 +201,8 @@ change_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name)
}
static void
-change_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Ego *ego)
+change_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_MESSENGER_Ego *ego)
{
GNUNET_assert(handle);
@@ -222,7 +232,9 @@ struct GNUNET_MESSENGER_MessageHandle
};
static int
-iterate_send_message (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_send_message (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_MessageHandle *msg_handle = cls;
@@ -232,7 +244,8 @@ iterate_send_message (void *cls, const struct GNUNET_HashCode *key, void *value)
}
void
-set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Ego *ego)
+set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_MESSENGER_Ego *ego)
{
GNUNET_assert((handle) && (ego));
@@ -271,7 +284,9 @@ get_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle)
}
static void
-callback_setup_handle_name (void *cls, const char *name, const struct GNUNET_MESSENGER_Ego *ego)
+callback_setup_handle_name (void *cls,
+ const char *name,
+ const struct GNUNET_MESSENGER_Ego *ego)
{
struct GNUNET_MESSENGER_SrvHandle *handle = cls;
@@ -285,7 +300,8 @@ callback_setup_handle_name (void *cls, const char *name, const struct GNUNET_MES
}
void
-setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name)
+setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const char *name)
{
GNUNET_assert(handle);
@@ -295,7 +311,9 @@ setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name)
}
static void
-callback_update_handle (void *cls, const char *name, const struct GNUNET_MESSENGER_Ego *ego)
+callback_update_handle (void *cls,
+ const char *name,
+ const struct GNUNET_MESSENGER_Ego *ego)
{
struct GNUNET_MESSENGER_SrvHandle *handle = cls;
@@ -326,7 +344,9 @@ update_handle (struct GNUNET_MESSENGER_SrvHandle *handle)
}
static void
-callback_set_handle_name (void *cls, const char *name, const struct GNUNET_MESSENGER_Ego *ego)
+callback_set_handle_name (void *cls,
+ const char *name,
+ const struct GNUNET_MESSENGER_Ego *ego)
{
struct GNUNET_MESSENGER_SrvHandle *handle = cls;
@@ -383,7 +403,8 @@ callback_set_handle_name (void *cls, const char *name, const struct GNUNET_MESSE
}
void
-set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name)
+set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const char *name)
{
GNUNET_assert(handle);
@@ -403,7 +424,8 @@ set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name)
}
int
-open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
+open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((handle) && (key));
@@ -414,7 +436,8 @@ open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET
}
int
-entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door,
+entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_PeerIdentity *door,
const struct GNUNET_HashCode *key)
{
GNUNET_assert((handle) && (door) && (key));
@@ -426,7 +449,8 @@ entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNE
}
int
-close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
+close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((handle) && (key));
@@ -437,7 +461,8 @@ close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNE
}
int
-send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key,
+send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key,
const struct GNUNET_MESSENGER_Message *message)
{
GNUNET_assert((handle) && (key) && (message));
@@ -475,14 +500,15 @@ get_next_member_session_contect(const struct GNUNET_MESSENGER_MemberSession *ses
}
static const struct GNUNET_MESSENGER_MemberSession*
-get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
+get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle,
+ struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_HashCode *key)
{
- GNUNET_assert((handle) && (key) && (handle->service));
+ GNUNET_assert((handle) && (room) && (key) && (handle->service));
const struct GNUNET_ShortHashCode *id = get_handle_member_id(handle, key);
- struct GNUNET_MESSENGER_SrvRoom *room = get_service_room(handle->service, key);
- if ((!id) || (!room))
+ if (!id)
return NULL;
struct GNUNET_MESSENGER_MemberStore *store = get_room_member_store(room);
@@ -497,11 +523,15 @@ get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle, const stru
}
void
-notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key,
+notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
+ struct GNUNET_MESSENGER_SrvRoom *room,
const struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
- GNUNET_assert((handle) && (key) && (session) && (message) && (hash));
+ GNUNET_assert((handle) && (room) && (session) && (message) && (hash));
+
+ const struct GNUNET_HashCode *key = get_room_key(room);
if ((!handle->mq) || (!get_handle_member_id (handle, key)))
{
@@ -547,7 +577,7 @@ notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct G
msg->flags = (uint32_t) GNUNET_MESSENGER_FLAG_NONE;
- if (get_handle_member_session(handle, key) == session)
+ if (get_handle_member_session(handle, room, key) == session)
msg->flags |= (uint32_t) GNUNET_MESSENGER_FLAG_SENT;
if (private_message)
@@ -563,10 +593,16 @@ notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct G
}
static int
-callback_scan_for_rooms (void *cls, const char *filename)
+callback_scan_for_rooms (void *cls,
+ const char *filename)
{
struct GNUNET_MESSENGER_SrvHandle *handle = cls;
+ if ((strlen(filename) <= 4) || (0 != strcmp(filename + strlen(filename) - 4, ".cfg")))
+ return GNUNET_OK;
+
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Load room configuration of handle: %s\n", filename);
+
struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create ();
if ((GNUNET_YES == GNUNET_DISK_file_test (filename)) && (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, filename)))
@@ -606,7 +642,9 @@ load_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle)
}
static int
-iterate_save_rooms (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_save_rooms (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_SrvHandle *handle = cls;
struct GNUNET_ShortHashCode *member_id = value;
@@ -616,9 +654,10 @@ iterate_save_rooms (void *cls, const struct GNUNET_HashCode *key, void *value)
char *filename;
GNUNET_asprintf (&filename, "%s%s%c%s.cfg", id_dir, "rooms", DIR_SEPARATOR, GNUNET_h2s (key));
-
GNUNET_free(id_dir);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Save room configuration of handle: %s\n", filename);
+
struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create ();
char *key_data = GNUNET_STRINGS_data_to_string_alloc (key, sizeof(*key));
diff --git a/src/messenger/gnunet-service-messenger_handle.h b/src/messenger/gnunet-service-messenger_handle.h
index d8ff3aaa8..4438570b9 100644
--- a/src/messenger/gnunet-service-messenger_handle.h
+++ b/src/messenger/gnunet-service-messenger_handle.h
@@ -60,7 +60,8 @@ struct GNUNET_MESSENGER_SrvHandle
* @return New handle
*/
struct GNUNET_MESSENGER_SrvHandle*
-create_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq);
+create_handle (struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_MQ_Handle *mq);
/**
* Destroys a handle and frees its memory fully.
@@ -79,7 +80,9 @@ destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle);
* @param[out] dir Path to store data
*/
void
-get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, const char *name, char **dir);
+get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle,
+ const char *name,
+ char **dir);
/**
* Returns the member id of a given <i>handle</i> in a specific <i>room</i>.
@@ -91,7 +94,8 @@ get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, const c
* @return Member id or NULL
*/
const struct GNUNET_ShortHashCode*
-get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key);
+get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key);
/**
* Changes the member id of a given <i>handle</i> in a specific <i>room</i> to match a <i>unique_id</i>
@@ -105,7 +109,8 @@ get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const str
* @return GNUNET_OK on success, otherwise GNUNET_SYSERR
*/
int
-change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key,
+change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key,
const struct GNUNET_ShortHashCode *unique_id);
/**
@@ -115,7 +120,8 @@ change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, const struct
* @param[in] ego EGO key pair
*/
void
-set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Ego *ego);
+set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_MESSENGER_Ego *ego);
/**
* Returns the EGO used by a given <i>handle</i>.
@@ -133,7 +139,8 @@ get_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle);
* @param[in] name Name (optionally: valid EGO name)
*/
void
-setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name);
+setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const char *name);
/**
* Tries to change the key pair of an EGO of a <i>handle</i> under the same name and informs all rooms
@@ -154,7 +161,8 @@ update_handle (struct GNUNET_MESSENGER_SrvHandle *handle);
* @param[in] name New name
*/
void
-set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name);
+set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const char *name);
/**
* Makes a given <i>handle</i> a member of the room using a specific <i>key</i> and opens the
@@ -165,7 +173,8 @@ set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name);
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
int
-open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key);
+open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key);
/**
* Makes a given <i>handle</i> a member of the room using a specific <i>key</i> and enters the room
@@ -177,7 +186,8 @@ open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
int
-entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door,
+entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_PeerIdentity *door,
const struct GNUNET_HashCode *key);
/**
@@ -189,7 +199,8 @@ entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNE
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
int
-close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key);
+close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key);
/**
* Sends a <i>message</i> from a given <i>handle</i> to the room using a specific <i>key</i>.
@@ -200,22 +211,25 @@ close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNE
* @return #GNUNET_YES on success, #GNUNET_NO or #GNUNET_SYSERR otherwise.
*/
int
-send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key,
+send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key,
const struct GNUNET_MESSENGER_Message *message);
/**
* Notifies the handle that a new message was received or sent.
*
* @param[in/out] handle Handle
- * @param[in] key Key of room
+ * @param[in] room Room of the message
* @param[in] session Member session
* @param[in] message Message
* @param[in] hash Hash of message
*/
void
-notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key,
+notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
+ struct GNUNET_MESSENGER_SrvRoom *room,
const struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Loads member ids and other potential configuration from a given <i>handle</i> which
diff --git a/src/messenger/gnunet-service-messenger_list_handles.c b/src/messenger/gnunet-service-messenger_list_handles.c
index adcbf6a42..c0ae18716 100644
--- a/src/messenger/gnunet-service-messenger_list_handles.c
+++ b/src/messenger/gnunet-service-messenger_list_handles.c
@@ -55,7 +55,8 @@ clear_list_handles (struct GNUNET_MESSENGER_ListHandles *handles)
}
void
-add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MESSENGER_SrvHandle *handle)
+add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles,
+ struct GNUNET_MESSENGER_SrvHandle *handle)
{
GNUNET_assert((handles) && (handle));
@@ -67,7 +68,8 @@ add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MES
}
int
-remove_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MESSENGER_SrvHandle *handle)
+remove_list_handle (struct GNUNET_MESSENGER_ListHandles *handles,
+ struct GNUNET_MESSENGER_SrvHandle *handle)
{
GNUNET_assert((handles) && (handle));
@@ -87,7 +89,8 @@ remove_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_
}
struct GNUNET_MESSENGER_SrvHandle*
-find_list_handle_by_member (const struct GNUNET_MESSENGER_ListHandles *handles, const struct GNUNET_HashCode *key)
+find_list_handle_by_member (const struct GNUNET_MESSENGER_ListHandles *handles,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((handles) && (key));
diff --git a/src/messenger/gnunet-service-messenger_list_handles.h b/src/messenger/gnunet-service-messenger_list_handles.h
index 9f7ca725f..f4d7ca5c0 100644
--- a/src/messenger/gnunet-service-messenger_list_handles.h
+++ b/src/messenger/gnunet-service-messenger_list_handles.h
@@ -69,7 +69,8 @@ clear_list_handles (struct GNUNET_MESSENGER_ListHandles *handles);
* @param[in/out] handle Handle
*/
void
-add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MESSENGER_SrvHandle *handle);
+add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles,
+ struct GNUNET_MESSENGER_SrvHandle *handle);
/**
* Removes the first entry matching with a specific <i>handle</i> from the list of
@@ -80,7 +81,8 @@ add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MES
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
int
-remove_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MESSENGER_SrvHandle *handle);
+remove_list_handle (struct GNUNET_MESSENGER_ListHandles *handles,
+ struct GNUNET_MESSENGER_SrvHandle *handle);
/**
* Searches linearly through the list of <i>handles</i> for members of a specific room
@@ -93,6 +95,7 @@ remove_list_handle (struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_
* @return First handle which is a current member
*/
struct GNUNET_MESSENGER_SrvHandle*
-find_list_handle_by_member (const struct GNUNET_MESSENGER_ListHandles *handles, const struct GNUNET_HashCode *key);
+find_list_handle_by_member (const struct GNUNET_MESSENGER_ListHandles *handles,
+ const struct GNUNET_HashCode *key);
#endif //GNUNET_SERVICE_MESSENGER_LIST_HANDLES_H
diff --git a/src/messenger/gnunet-service-messenger_list_messages.c b/src/messenger/gnunet-service-messenger_list_messages.c
index 2666ccdab..7092dc76f 100644
--- a/src/messenger/gnunet-service-messenger_list_messages.c
+++ b/src/messenger/gnunet-service-messenger_list_messages.c
@@ -52,7 +52,8 @@ clear_list_messages (struct GNUNET_MESSENGER_ListMessages *messages)
}
void
-add_to_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash)
+add_to_list_messages (struct GNUNET_MESSENGER_ListMessages *messages,
+ const struct GNUNET_HashCode *hash)
{
GNUNET_assert((messages) && (hash));
@@ -64,7 +65,8 @@ add_to_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const stru
}
void
-copy_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_MESSENGER_ListMessages *origin)
+copy_list_messages (struct GNUNET_MESSENGER_ListMessages *messages,
+ const struct GNUNET_MESSENGER_ListMessages *origin)
{
GNUNET_assert((messages) && (origin));
@@ -75,7 +77,8 @@ copy_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct
}
void
-remove_from_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash)
+remove_from_list_messages (struct GNUNET_MESSENGER_ListMessages *messages,
+ const struct GNUNET_HashCode *hash)
{
GNUNET_assert((messages) && (hash));
@@ -91,7 +94,8 @@ remove_from_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const
}
void
-load_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const char *path)
+load_list_messages (struct GNUNET_MESSENGER_ListMessages *messages,
+ const char *path)
{
GNUNET_assert((messages) && (path));
@@ -125,7 +129,8 @@ load_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const char *
}
void
-save_list_messages (const struct GNUNET_MESSENGER_ListMessages *messages, const char *path)
+save_list_messages (const struct GNUNET_MESSENGER_ListMessages *messages,
+ const char *path)
{
GNUNET_assert((messages) && (path));
diff --git a/src/messenger/gnunet-service-messenger_list_messages.h b/src/messenger/gnunet-service-messenger_list_messages.h
index 93ec203ea..7abc8c00f 100644
--- a/src/messenger/gnunet-service-messenger_list_messages.h
+++ b/src/messenger/gnunet-service-messenger_list_messages.h
@@ -68,7 +68,8 @@ clear_list_messages (struct GNUNET_MESSENGER_ListMessages *messages);
* @param[in] hash Hash of message
*/
void
-add_to_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash);
+add_to_list_messages (struct GNUNET_MESSENGER_ListMessages *messages,
+ const struct GNUNET_HashCode *hash);
/**
* Copies all message hashes from an <i>origin</i> to another list.
@@ -77,7 +78,8 @@ add_to_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const stru
* @param[in] origin Source list of hashes
*/
void
-copy_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_MESSENGER_ListMessages *origin);
+copy_list_messages (struct GNUNET_MESSENGER_ListMessages *messages,
+ const struct GNUNET_MESSENGER_ListMessages *origin);
/**
* Removes the first entry with a matching <i>hash</i> from the list.
@@ -86,7 +88,8 @@ copy_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct
* @param[in] hash Hash of message
*/
void
-remove_from_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash);
+remove_from_list_messages (struct GNUNET_MESSENGER_ListMessages *messages,
+ const struct GNUNET_HashCode *hash);
/**
* Loads the list of message hashes from a file under a given <i>path</i>.
@@ -95,7 +98,8 @@ remove_from_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const
* @param[in] path Path of file
*/
void
-load_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const char *path);
+load_list_messages (struct GNUNET_MESSENGER_ListMessages *messages,
+ const char *path);
/**
* Saves the list of message hashes to a file under a given <i>path</i>.
@@ -104,6 +108,7 @@ load_list_messages (struct GNUNET_MESSENGER_ListMessages *messages, const char *
* @param[in] path Path of file
*/
void
-save_list_messages (const struct GNUNET_MESSENGER_ListMessages *messages, const char *path);
+save_list_messages (const struct GNUNET_MESSENGER_ListMessages *messages,
+ const char *path);
#endif //GNUNET_SERVICE_MESSENGER_LIST_MESSAGES_H
diff --git a/src/messenger/gnunet-service-messenger_member.c b/src/messenger/gnunet-service-messenger_member.c
index b0a735dbe..976b68fe6 100644
--- a/src/messenger/gnunet-service-messenger_member.c
+++ b/src/messenger/gnunet-service-messenger_member.c
@@ -28,7 +28,8 @@
#include "gnunet-service-messenger_member_session.h"
struct GNUNET_MESSENGER_Member*
-create_member (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id)
+create_member (struct GNUNET_MESSENGER_MemberStore *store,
+ const struct GNUNET_ShortHashCode *id)
{
GNUNET_assert (store);
@@ -50,7 +51,9 @@ create_member (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_S
}
static int
-iterate_destroy_session (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_destroy_session (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_MemberSession *session = value;
destroy_member_session(session);
@@ -77,7 +80,8 @@ get_member_id (const struct GNUNET_MESSENGER_Member *member)
}
static int
-callback_scan_for_sessions (void *cls, const char *filename)
+callback_scan_for_sessions (void *cls,
+ const char *filename)
{
struct GNUNET_MESSENGER_Member *member = cls;
@@ -95,7 +99,8 @@ callback_scan_for_sessions (void *cls, const char *filename)
}
void
-load_member (struct GNUNET_MESSENGER_MemberStore *store, const char *directory)
+load_member (struct GNUNET_MESSENGER_MemberStore *store,
+ const char *directory)
{
GNUNET_assert ((store) && (directory));
@@ -107,6 +112,8 @@ load_member (struct GNUNET_MESSENGER_MemberStore *store, const char *directory)
if (GNUNET_YES != GNUNET_DISK_file_test (config_file))
goto free_config;
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Load member configuration: %s\n", config_file);
+
struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, config_file))
@@ -139,7 +146,9 @@ free_config:
}
static int
-iterate_load_next_session (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_load_next_session (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
const char* sessions_directory = cls;
@@ -156,7 +165,8 @@ iterate_load_next_session (void *cls, const struct GNUNET_HashCode *key, void *v
}
void
-load_member_next_sessions (const struct GNUNET_MESSENGER_Member *member, const char *directory)
+load_member_next_sessions (const struct GNUNET_MESSENGER_Member *member,
+ const char *directory)
{
GNUNET_assert ((member) && (directory));
@@ -169,7 +179,9 @@ load_member_next_sessions (const struct GNUNET_MESSENGER_Member *member, const c
}
static int
-iterate_save_session (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_save_session (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
const char* sessions_directory = cls;
@@ -187,13 +199,16 @@ iterate_save_session (void *cls, const struct GNUNET_HashCode *key, void *value)
}
void
-save_member (struct GNUNET_MESSENGER_Member *member, const char *directory)
+save_member (struct GNUNET_MESSENGER_Member *member,
+ const char *directory)
{
GNUNET_assert ((member) && (directory));
char *config_file;
GNUNET_asprintf (&config_file, "%s%s", directory, "member.cfg");
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Save member configuration: %s\n", config_file);
+
struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create ();
char *id_data = GNUNET_STRINGS_data_to_string_alloc (&(member->id), sizeof(member->id));
@@ -221,7 +236,8 @@ save_member (struct GNUNET_MESSENGER_Member *member, const char *directory)
}
static void
-sync_session_contact_from_next (struct GNUNET_MESSENGER_MemberSession *session, struct GNUNET_MESSENGER_MemberSession *next)
+sync_session_contact_from_next (struct GNUNET_MESSENGER_MemberSession *session,
+ struct GNUNET_MESSENGER_MemberSession *next)
{
GNUNET_assert((session) && (next));
@@ -235,7 +251,9 @@ sync_session_contact_from_next (struct GNUNET_MESSENGER_MemberSession *session,
}
static int
-iterate_sync_session_contact (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_sync_session_contact (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_MemberSession *session = value;
@@ -254,7 +272,8 @@ sync_member_contacts (struct GNUNET_MESSENGER_Member *member)
}
struct GNUNET_MESSENGER_MemberSession*
-get_member_session (const struct GNUNET_MESSENGER_Member *member, const struct GNUNET_IDENTITY_PublicKey *public_key)
+get_member_session (const struct GNUNET_MESSENGER_Member *member,
+ const struct GNUNET_IDENTITY_PublicKey *public_key)
{
GNUNET_assert ((member) && (public_key));
@@ -272,7 +291,9 @@ struct GNUNET_MESSENGER_ClosureSearchSession {
};
static int
-iterate_search_session (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_search_session (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_ClosureSearchSession* search = cls;
struct GNUNET_MESSENGER_MemberSession *session = value;
@@ -285,7 +306,8 @@ iterate_search_session (void *cls, const struct GNUNET_HashCode *key, void *valu
}
static struct GNUNET_MESSENGER_MemberSession*
-try_member_session (struct GNUNET_MESSENGER_Member *member, const struct GNUNET_IDENTITY_PublicKey *public_key)
+try_member_session (struct GNUNET_MESSENGER_Member *member,
+ const struct GNUNET_IDENTITY_PublicKey *public_key)
{
struct GNUNET_MESSENGER_MemberSession* session = get_member_session(member, public_key);
@@ -301,7 +323,8 @@ try_member_session (struct GNUNET_MESSENGER_Member *member, const struct GNUNET_
}
struct GNUNET_MESSENGER_MemberSession*
-get_member_session_of (struct GNUNET_MESSENGER_Member *member, const struct GNUNET_MESSENGER_Message *message,
+get_member_session_of (struct GNUNET_MESSENGER_Member *member,
+ const struct GNUNET_MESSENGER_Message *message,
const struct GNUNET_HashCode *hash)
{
GNUNET_assert ((member) && (message) && (hash) &&
@@ -324,7 +347,8 @@ get_member_session_of (struct GNUNET_MESSENGER_Member *member, const struct GNUN
}
void
-add_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session)
+add_member_session (struct GNUNET_MESSENGER_Member *member,
+ struct GNUNET_MESSENGER_MemberSession *session)
{
if (!session)
return;
@@ -344,7 +368,8 @@ add_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSEN
}
void
-remove_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session)
+remove_member_session (struct GNUNET_MESSENGER_Member *member,
+ struct GNUNET_MESSENGER_MemberSession *session)
{
GNUNET_assert ((member) && (session) && (session->member == member));
@@ -364,7 +389,9 @@ struct GNUNET_MESSENGER_ClosureIterateSessions {
};
static int
-iterate_member_sessions_it (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_member_sessions_it (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_ClosureIterateSessions *iterate = cls;
struct GNUNET_MESSENGER_MemberSession *session = value;
@@ -373,7 +400,9 @@ iterate_member_sessions_it (void *cls, const struct GNUNET_HashCode *key, void *
}
int
-iterate_member_sessions (struct GNUNET_MESSENGER_Member *member, GNUNET_MESSENGER_MemberIteratorCallback it, void *cls)
+iterate_member_sessions (struct GNUNET_MESSENGER_Member *member,
+ GNUNET_MESSENGER_MemberIteratorCallback it,
+ void *cls)
{
GNUNET_assert ((member) && (member->sessions) && (it));
diff --git a/src/messenger/gnunet-service-messenger_member.h b/src/messenger/gnunet-service-messenger_member.h
index fb2e57cfb..46269315a 100644
--- a/src/messenger/gnunet-service-messenger_member.h
+++ b/src/messenger/gnunet-service-messenger_member.h
@@ -52,7 +52,8 @@ struct GNUNET_MESSENGER_Member
* @return New member or NULL
*/
struct GNUNET_MESSENGER_Member*
-create_member (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id);
+create_member (struct GNUNET_MESSENGER_MemberStore *store,
+ const struct GNUNET_ShortHashCode *id);
/**
* Destroys a member and frees its memory fully.
@@ -80,7 +81,8 @@ get_member_id (const struct GNUNET_MESSENGER_Member *member);
* @param[in] directory Path to a directory
*/
void
-load_member (struct GNUNET_MESSENGER_MemberStore *store, const char *directory);
+load_member (struct GNUNET_MESSENGER_MemberStore *store,
+ const char *directory);
/**
* Loads data about next sessions from a <i>directory</i> into an empty loaded
@@ -90,7 +92,8 @@ load_member (struct GNUNET_MESSENGER_MemberStore *store, const char *directory);
* @param[in] directory Path to a directory
*/
void
-load_member_next_sessions (const struct GNUNET_MESSENGER_Member *member, const char *directory);
+load_member_next_sessions (const struct GNUNET_MESSENGER_Member *member,
+ const char *directory);
/**
* Saves data from a <i>member</i> into a directory which
@@ -100,7 +103,8 @@ load_member_next_sessions (const struct GNUNET_MESSENGER_Member *member, const c
* @param[in] directory Path to a directory
*/
void
-save_member (struct GNUNET_MESSENGER_Member *member, const char *directory);
+save_member (struct GNUNET_MESSENGER_Member *member,
+ const char *directory);
/**
* Synchronizes contacts between all sessions from a given <i>member</i>
@@ -120,7 +124,8 @@ sync_member_contacts (struct GNUNET_MESSENGER_Member *member);
* @return Member session
*/
struct GNUNET_MESSENGER_MemberSession*
-get_member_session (const struct GNUNET_MESSENGER_Member *member, const struct GNUNET_IDENTITY_PublicKey *public_key);
+get_member_session (const struct GNUNET_MESSENGER_Member *member,
+ const struct GNUNET_IDENTITY_PublicKey *public_key);
/**
* Returns the member session of a <i>member</i> using a public key which can verify
@@ -133,7 +138,8 @@ get_member_session (const struct GNUNET_MESSENGER_Member *member, const struct G
* @return Member session
*/
struct GNUNET_MESSENGER_MemberSession*
-get_member_session_of (struct GNUNET_MESSENGER_Member *member, const struct GNUNET_MESSENGER_Message *message,
+get_member_session_of (struct GNUNET_MESSENGER_Member *member,
+ const struct GNUNET_MESSENGER_Message *message,
const struct GNUNET_HashCode *hash);
/**
@@ -143,7 +149,8 @@ get_member_session_of (struct GNUNET_MESSENGER_Member *member, const struct GNUN
* @param[in/out] session Member session
*/
void
-add_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session);
+add_member_session (struct GNUNET_MESSENGER_Member *member,
+ struct GNUNET_MESSENGER_MemberSession *session);
/**
* Removes a given member <i>session</i> from its <i>member</i>.
@@ -152,7 +159,8 @@ add_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSEN
* @param[in/out] session Member session
*/
void
-remove_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session);
+remove_member_session (struct GNUNET_MESSENGER_Member *member,
+ struct GNUNET_MESSENGER_MemberSession *session);
/**
* Iterate through all member sessions currently connected to a given <i>member</i>
@@ -165,6 +173,8 @@ remove_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MES
* @return Amount of sessions iterated through
*/
int
-iterate_member_sessions (struct GNUNET_MESSENGER_Member *member, GNUNET_MESSENGER_MemberIteratorCallback it, void* cls);
+iterate_member_sessions (struct GNUNET_MESSENGER_Member *member,
+ GNUNET_MESSENGER_MemberIteratorCallback it,
+ void* cls);
#endif //GNUNET_SERVICE_MESSENGER_MEMBER_H
diff --git a/src/messenger/gnunet-service-messenger_member_session.c b/src/messenger/gnunet-service-messenger_member_session.c
index 690c703b2..846dbbe2b 100644
--- a/src/messenger/gnunet-service-messenger_member_session.c
+++ b/src/messenger/gnunet-service-messenger_member_session.c
@@ -158,7 +158,9 @@ completion:
}
static int
-iterate_copy_history (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_copy_history (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_MemberSession *next = cls;
@@ -460,7 +462,8 @@ struct GNUNET_MESSENGER_MemberSessionHistoryEntry
};
static void
-load_member_session_history (struct GNUNET_MESSENGER_MemberSession *session, const char *path)
+load_member_session_history (struct GNUNET_MESSENGER_MemberSession *session,
+ const char *path)
{
GNUNET_assert((session) && (path));
@@ -502,7 +505,8 @@ load_member_session_history (struct GNUNET_MESSENGER_MemberSession *session, con
}
void
-load_member_session (struct GNUNET_MESSENGER_Member *member, const char *directory)
+load_member_session (struct GNUNET_MESSENGER_Member *member,
+ const char *directory)
{
GNUNET_assert ((member) && (directory));
@@ -514,6 +518,8 @@ load_member_session (struct GNUNET_MESSENGER_Member *member, const char *directo
if (GNUNET_YES != GNUNET_DISK_file_test (config_file))
goto free_config;
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Load session configuration of member: %s\n", config_file);
+
struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, config_file))
@@ -571,7 +577,8 @@ free_config:
}
static struct GNUNET_MESSENGER_MemberSession*
-get_cycle_safe_next_session (struct GNUNET_MESSENGER_MemberSession *session, struct GNUNET_MESSENGER_MemberSession *next)
+get_cycle_safe_next_session (struct GNUNET_MESSENGER_MemberSession *session,
+ struct GNUNET_MESSENGER_MemberSession *next)
{
if (!next)
return NULL;
@@ -589,7 +596,8 @@ get_cycle_safe_next_session (struct GNUNET_MESSENGER_MemberSession *session, str
}
void
-load_member_session_next (struct GNUNET_MESSENGER_MemberSession *session, const char *directory)
+load_member_session_next (struct GNUNET_MESSENGER_MemberSession *session,
+ const char *directory)
{
GNUNET_assert ((session) && (directory));
@@ -599,6 +607,8 @@ load_member_session_next (struct GNUNET_MESSENGER_MemberSession *session, const
if (GNUNET_YES != GNUNET_DISK_file_test (config_file))
goto free_config;
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Load next session configuration of member: %s\n", config_file);
+
struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, config_file))
@@ -640,7 +650,9 @@ free_config:
}
static int
-iterate_save_member_session_history_hentries (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_save_member_session_history_hentries (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_DISK_FileHandle *handle = cls;
unsigned char ownership = value? GNUNET_YES : GNUNET_NO;
@@ -652,7 +664,8 @@ iterate_save_member_session_history_hentries (void *cls, const struct GNUNET_Has
}
static void
-save_member_session_history (struct GNUNET_MESSENGER_MemberSession *session, const char *path)
+save_member_session_history (struct GNUNET_MESSENGER_MemberSession *session,
+ const char *path)
{
GNUNET_assert((session) && (path));
@@ -678,13 +691,16 @@ save_member_session_history (struct GNUNET_MESSENGER_MemberSession *session, con
}
void
-save_member_session (struct GNUNET_MESSENGER_MemberSession *session, const char *directory)
+save_member_session (struct GNUNET_MESSENGER_MemberSession *session,
+ const char *directory)
{
GNUNET_assert ((session) && (directory));
char *config_file;
GNUNET_asprintf (&config_file, "%s%s", directory, "session.cfg");
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Save session configuration of member: %s\n", config_file);
+
struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create ();
char *key_data = GNUNET_IDENTITY_public_key_to_string(get_member_session_public_key(session));
diff --git a/src/messenger/gnunet-service-messenger_member_session.h b/src/messenger/gnunet-service-messenger_member_session.h
index bf4d10f67..9ba801776 100644
--- a/src/messenger/gnunet-service-messenger_member_session.h
+++ b/src/messenger/gnunet-service-messenger_member_session.h
@@ -225,7 +225,8 @@ verify_member_session_as_sender (const struct GNUNET_MESSENGER_MemberSession *se
*/
int
check_member_session_history (const struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_HashCode *hash, int ownership);
+ const struct GNUNET_HashCode *hash,
+ int ownership);
/**
* Adds a given <i>message</i> to the history of a <i>session</i> using the messages
@@ -262,7 +263,8 @@ clear_member_session_history (struct GNUNET_MESSENGER_MemberSession *session,
* @param[in] directory Path to a directory
*/
void
-load_member_session (struct GNUNET_MESSENGER_Member *member, const char *directory);
+load_member_session (struct GNUNET_MESSENGER_Member *member,
+ const char *directory);
/**
* Loads the connection from one <i>session</i> to another through the
@@ -273,7 +275,8 @@ load_member_session (struct GNUNET_MESSENGER_Member *member, const char *directo
* @param[in] directory Path to a directory
*/
void
-load_member_session_next (struct GNUNET_MESSENGER_MemberSession *session, const char *directory);
+load_member_session_next (struct GNUNET_MESSENGER_MemberSession *session,
+ const char *directory);
/**
* Saves data from a member <i>session</i> into a <i>directory</i> which can be
@@ -283,6 +286,7 @@ load_member_session_next (struct GNUNET_MESSENGER_MemberSession *session, const
* @param[in] directory Path to a directory
*/
void
-save_member_session (struct GNUNET_MESSENGER_MemberSession *session, const char *directory);
+save_member_session (struct GNUNET_MESSENGER_MemberSession *session,
+ const char *directory);
#endif //GNUNET_SERVICE_MESSENGER_MEMBER_SESSION_H
diff --git a/src/messenger/gnunet-service-messenger_member_store.c b/src/messenger/gnunet-service-messenger_member_store.c
index 2925965d4..e96ee3883 100644
--- a/src/messenger/gnunet-service-messenger_member_store.c
+++ b/src/messenger/gnunet-service-messenger_member_store.c
@@ -30,7 +30,8 @@
#include "gnunet-service-messenger_room.h"
void
-init_member_store (struct GNUNET_MESSENGER_MemberStore *store, struct GNUNET_MESSENGER_SrvRoom *room)
+init_member_store (struct GNUNET_MESSENGER_MemberStore *store,
+ struct GNUNET_MESSENGER_SrvRoom *room)
{
GNUNET_assert ((store) && (room));
@@ -39,7 +40,9 @@ init_member_store (struct GNUNET_MESSENGER_MemberStore *store, struct GNUNET_MES
}
static int
-iterate_destroy_members (void *cls, const struct GNUNET_ShortHashCode *key, void *value)
+iterate_destroy_members (void *cls,
+ const struct GNUNET_ShortHashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_Member *member = value;
destroy_member(member);
@@ -75,7 +78,8 @@ get_member_store_key (const struct GNUNET_MESSENGER_MemberStore *store)
}
static int
-callback_scan_for_members (void *cls, const char *filename)
+callback_scan_for_members (void *cls,
+ const char *filename)
{
struct GNUNET_MESSENGER_MemberStore *store = cls;
@@ -94,7 +98,9 @@ callback_scan_for_members (void *cls, const char *filename)
}
static int
-iterate_load_next_member_sessions (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
+iterate_load_next_member_sessions (void *cls,
+ const struct GNUNET_ShortHashCode *id,
+ void *value)
{
const char *sync_dir = cls;
@@ -114,7 +120,9 @@ iterate_load_next_member_sessions (void *cls, const struct GNUNET_ShortHashCode
}
static int
-iterate_sync_member_contacts (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
+iterate_sync_member_contacts (void *cls,
+ const struct GNUNET_ShortHashCode *id,
+ void *value)
{
struct GNUNET_MESSENGER_Member *member = value;
@@ -126,7 +134,8 @@ iterate_sync_member_contacts (void *cls, const struct GNUNET_ShortHashCode *id,
}
void
-load_member_store (struct GNUNET_MESSENGER_MemberStore *store, const char *directory)
+load_member_store (struct GNUNET_MESSENGER_MemberStore *store,
+ const char *directory)
{
GNUNET_assert ((store) && (directory));
@@ -143,7 +152,9 @@ load_member_store (struct GNUNET_MESSENGER_MemberStore *store, const char *direc
}
static int
-iterate_save_members (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
+iterate_save_members (void *cls,
+ const struct GNUNET_ShortHashCode *id,
+ void *value)
{
const char *save_dir = cls;
@@ -164,7 +175,8 @@ iterate_save_members (void *cls, const struct GNUNET_ShortHashCode *id, void *va
}
void
-save_member_store (struct GNUNET_MESSENGER_MemberStore *store, const char *directory)
+save_member_store (struct GNUNET_MESSENGER_MemberStore *store,
+ const char *directory)
{
GNUNET_assert ((store) && (directory));
@@ -179,7 +191,8 @@ save_member_store (struct GNUNET_MESSENGER_MemberStore *store, const char *direc
}
struct GNUNET_MESSENGER_Member*
-get_store_member (const struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id)
+get_store_member (const struct GNUNET_MESSENGER_MemberStore *store,
+ const struct GNUNET_ShortHashCode *id)
{
GNUNET_assert ((store) && (store->members) && (id));
@@ -187,7 +200,8 @@ get_store_member (const struct GNUNET_MESSENGER_MemberStore *store, const struct
}
struct GNUNET_MESSENGER_Member*
-get_store_member_of (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_MESSENGER_Message *message)
+get_store_member_of (struct GNUNET_MESSENGER_MemberStore *store,
+ const struct GNUNET_MESSENGER_Message *message)
{
if ((GNUNET_MESSENGER_KIND_INFO == message->header.kind) ||
(GNUNET_MESSENGER_KIND_JOIN == message->header.kind))
@@ -197,7 +211,8 @@ get_store_member_of (struct GNUNET_MESSENGER_MemberStore *store, const struct GN
}
struct GNUNET_MESSENGER_Member*
-add_store_member (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id)
+add_store_member (struct GNUNET_MESSENGER_MemberStore *store,
+ const struct GNUNET_ShortHashCode *id)
{
GNUNET_assert ((store) && (store->members));
@@ -227,7 +242,9 @@ struct GNUNET_MESSENGER_ClosureIterateMembers {
};
static int
-iterate_store_members_it (void *cls, const struct GNUNET_ShortHashCode *key, void *value)
+iterate_store_members_it (void *cls,
+ const struct GNUNET_ShortHashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_ClosureIterateMembers *iterate = cls;
struct GNUNET_MESSENGER_Member *member = value;
@@ -236,7 +253,8 @@ iterate_store_members_it (void *cls, const struct GNUNET_ShortHashCode *key, voi
}
int
-iterate_store_members (struct GNUNET_MESSENGER_MemberStore *store, GNUNET_MESSENGER_MemberIteratorCallback it,
+iterate_store_members (struct GNUNET_MESSENGER_MemberStore *store,
+ GNUNET_MESSENGER_MemberIteratorCallback it,
void* cls)
{
GNUNET_assert ((store) && (store->members) && (it));
diff --git a/src/messenger/gnunet-service-messenger_member_store.h b/src/messenger/gnunet-service-messenger_member_store.h
index 859e4683d..af50f0d36 100644
--- a/src/messenger/gnunet-service-messenger_member_store.h
+++ b/src/messenger/gnunet-service-messenger_member_store.h
@@ -56,7 +56,8 @@ typedef int (*GNUNET_MESSENGER_MemberIteratorCallback) (
* @param room Room
*/
void
-init_member_store (struct GNUNET_MESSENGER_MemberStore *store, struct GNUNET_MESSENGER_SrvRoom *room);
+init_member_store (struct GNUNET_MESSENGER_MemberStore *store,
+ struct GNUNET_MESSENGER_SrvRoom *room);
/**
* Clears a member <i>store</i>, wipes its content and deallocates its memory.
@@ -91,7 +92,8 @@ get_member_store_key (const struct GNUNET_MESSENGER_MemberStore *store);
* @param[in] directory Path to a directory
*/
void
-load_member_store (struct GNUNET_MESSENGER_MemberStore *store, const char *directory);
+load_member_store (struct GNUNET_MESSENGER_MemberStore *store,
+ const char *directory);
/**
* Saves members from a member <i>store</i> into a directory.
@@ -100,7 +102,8 @@ load_member_store (struct GNUNET_MESSENGER_MemberStore *store, const char *direc
* @param[in] directory Path to a directory
*/
void
-save_member_store (struct GNUNET_MESSENGER_MemberStore *store, const char *directory);
+save_member_store (struct GNUNET_MESSENGER_MemberStore *store,
+ const char *directory);
/**
* Returns the member in a <i>store</i> identified by a given <i>id</i>. If the <i>store</i>
@@ -111,7 +114,8 @@ save_member_store (struct GNUNET_MESSENGER_MemberStore *store, const char *direc
* @return Member or NULL
*/
struct GNUNET_MESSENGER_Member*
-get_store_member (const struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id);
+get_store_member (const struct GNUNET_MESSENGER_MemberStore *store,
+ const struct GNUNET_ShortHashCode *id);
/**
* Returns the member of a <i>store</i> using a sender id of a given <i>message</i>.
@@ -122,7 +126,8 @@ get_store_member (const struct GNUNET_MESSENGER_MemberStore *store, const struct
* @return Member or NULL
*/
struct GNUNET_MESSENGER_Member*
-get_store_member_of (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_MESSENGER_Message *message);
+get_store_member_of (struct GNUNET_MESSENGER_MemberStore *store,
+ const struct GNUNET_MESSENGER_Message *message);
/**
* Adds a member to a <i>store</i> under a specific <i>id</i> and returns it on success.
@@ -132,7 +137,8 @@ get_store_member_of (struct GNUNET_MESSENGER_MemberStore *store, const struct GN
* @return Member or NULL
*/
struct GNUNET_MESSENGER_Member*
-add_store_member (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id);
+add_store_member (struct GNUNET_MESSENGER_MemberStore *store,
+ const struct GNUNET_ShortHashCode *id);
/**
* Iterate through all member sessions currently connected to the members of the given
@@ -145,7 +151,8 @@ add_store_member (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNE
* @return Amount of members iterated through
*/
int
-iterate_store_members (struct GNUNET_MESSENGER_MemberStore *store, GNUNET_MESSENGER_MemberIteratorCallback it,
+iterate_store_members (struct GNUNET_MESSENGER_MemberStore *store,
+ GNUNET_MESSENGER_MemberIteratorCallback it,
void* cls);
#endif //GNUNET_SERVICE_MESSENGER_MEMBER_STORE_H
diff --git a/src/messenger/gnunet-service-messenger_message_handle.c b/src/messenger/gnunet-service-messenger_message_handle.c
index 86f2b901a..701d78c89 100644
--- a/src/messenger/gnunet-service-messenger_message_handle.c
+++ b/src/messenger/gnunet-service-messenger_message_handle.c
@@ -27,7 +27,8 @@
static void
handle_session_switch (struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
struct GNUNET_MESSENGER_MemberSession *next = switch_member_session(session, message, hash);
@@ -36,8 +37,10 @@ handle_session_switch (struct GNUNET_MESSENGER_MemberSession *session,
}
void
-handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Member (%s) joins room (%s).\n",
GNUNET_sh2s (&(message->header.sender_id)), GNUNET_h2s(get_room_key(room)));
@@ -54,8 +57,10 @@ handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSEN
}
void
-handle_message_leave (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+handle_message_leave (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Member (%s) leaves room (%s).\n",
GNUNET_sh2s (&(message->header.sender_id)), GNUNET_h2s(get_room_key(room)));
@@ -64,8 +69,10 @@ handle_message_leave (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSE
}
void
-handle_message_name (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+handle_message_name (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
struct GNUNET_MESSENGER_Contact *contact = get_member_session_contact(session);
@@ -76,15 +83,19 @@ handle_message_name (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSEN
}
void
-handle_message_key (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+handle_message_key (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
handle_session_switch (session, message, hash);
}
void
-handle_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+handle_message_peer (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
if (GNUNET_NO == contains_list_tunnels (&(room->basement), &(message->body.peer.peer)))
add_to_list_tunnels (&(room->basement), &(message->body.peer.peer));
@@ -94,8 +105,10 @@ handle_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSEN
}
void
-handle_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+handle_message_id (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
handle_session_switch (session, message, hash);
@@ -108,8 +121,10 @@ handle_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE
}
void
-handle_message_miss (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+handle_message_miss (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
struct GNUNET_MESSENGER_ListTunnel *element = find_list_tunnels (&(room->basement), &(message->body.peer.peer), NULL);
@@ -123,8 +138,10 @@ handle_message_miss (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSEN
}
void
-handle_message_delete (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+handle_message_delete (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
struct GNUNET_TIME_Relative delay = GNUNET_TIME_relative_ntoh (message->body.deletion.delay);
struct GNUNET_TIME_Absolute action = GNUNET_TIME_absolute_ntoh (message->header.timestamp);
diff --git a/src/messenger/gnunet-service-messenger_message_handle.h b/src/messenger/gnunet-service-messenger_message_handle.h
index 844142b77..0e5be3408 100644
--- a/src/messenger/gnunet-service-messenger_message_handle.h
+++ b/src/messenger/gnunet-service-messenger_message_handle.h
@@ -45,8 +45,10 @@
* @param[in] hash Hash of the message
*/
void
-handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Handles a received or sent leave message to make changes of current member information.
@@ -58,8 +60,10 @@ handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSEN
* @param[in] hash Hash of the message
*/
void
-handle_message_leave (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+handle_message_leave (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Handles a received or sent name message to rename a current member.
@@ -71,8 +75,10 @@ handle_message_leave (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSE
* @param[in] hash Hash of the message
*/
void
-handle_message_name (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+handle_message_name (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Handles a received or sent key message to change the key of a member and rearrange the contacts accordingly.
@@ -84,8 +90,10 @@ handle_message_name (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSEN
* @param[in] hash Hash of the message
*/
void
-handle_message_key (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+handle_message_key (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Handles a received or sent peer message to make changes of the basement in the room.
@@ -97,8 +105,10 @@ handle_message_key (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENG
* @param[in] hash Hash of the message
*/
void
-handle_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+handle_message_peer (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Handles a received or sent id message to change a members id.
@@ -110,8 +120,10 @@ handle_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSEN
* @param[in] hash Hash of the message
*/
void
-handle_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+handle_message_id (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Handles a received or sent miss message to drop a peer from the basement in the room.
@@ -123,8 +135,10 @@ handle_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE
* @param[in] hash Hash of the message
*/
void
-handle_message_miss (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+handle_message_miss (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Handles a received or sent delete message to delete a specific message from the store.
@@ -136,7 +150,9 @@ handle_message_miss (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSEN
* @param[in] hash Hash of the message
*/
void
-handle_message_delete (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+handle_message_delete (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
#endif //GNUNET_SERVICE_MESSENGER_MESSAGE_HANDLE_H
diff --git a/src/messenger/gnunet-service-messenger_message_kind.c b/src/messenger/gnunet-service-messenger_message_kind.c
index 3edcade91..2449b9230 100644
--- a/src/messenger/gnunet-service-messenger_message_kind.c
+++ b/src/messenger/gnunet-service-messenger_message_kind.c
@@ -190,7 +190,8 @@ create_message_request (const struct GNUNET_HashCode *hash)
}
struct GNUNET_MESSENGER_Message*
-create_message_invite (const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key)
+create_message_invite (const struct GNUNET_PeerIdentity *door,
+ const struct GNUNET_HashCode *key)
{
if ((!door) || (!key))
return NULL;
@@ -222,7 +223,8 @@ create_message_text (const char *text)
}
struct GNUNET_MESSENGER_Message*
-create_message_delete (const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
+create_message_delete (const struct GNUNET_HashCode *hash,
+ const struct GNUNET_TIME_Relative delay)
{
if (!hash)
return NULL;
diff --git a/src/messenger/gnunet-service-messenger_message_kind.h b/src/messenger/gnunet-service-messenger_message_kind.h
index c098868c0..508f19074 100644
--- a/src/messenger/gnunet-service-messenger_message_kind.h
+++ b/src/messenger/gnunet-service-messenger_message_kind.h
@@ -146,7 +146,8 @@ create_message_request (const struct GNUNET_HashCode *hash);
* @return New message
*/
struct GNUNET_MESSENGER_Message*
-create_message_invite (const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key);
+create_message_invite (const struct GNUNET_PeerIdentity *door,
+ const struct GNUNET_HashCode *key);
/**
* Creates and allocates a new <i>text message containing a string representing text.
@@ -167,6 +168,7 @@ create_message_text (const char *text);
* @return New message
*/
struct GNUNET_MESSENGER_Message*
-create_message_delete (const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay);
+create_message_delete (const struct GNUNET_HashCode *hash,
+ const struct GNUNET_TIME_Relative delay);
#endif //GNUNET_SERVICE_MESSENGER_MESSAGE_KIND_H
diff --git a/src/messenger/gnunet-service-messenger_message_recv.c b/src/messenger/gnunet-service-messenger_message_recv.c
index b2a5052d2..bb6ee6f17 100644
--- a/src/messenger/gnunet-service-messenger_message_recv.c
+++ b/src/messenger/gnunet-service-messenger_message_recv.c
@@ -28,8 +28,10 @@
#include "gnunet-service-messenger_operation.h"
static void
-forward_about_members (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel,
- struct GNUNET_MESSENGER_MemberSession *session, struct GNUNET_CONTAINER_MultiHashMap *map)
+forward_about_members (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ struct GNUNET_CONTAINER_MultiHashMap *map)
{
if (session->prev)
forward_about_members (room, tunnel, session->prev, map);
@@ -54,8 +56,9 @@ forward_about_members (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESS
}
static int
-iterate_forward_members (void *cls, const struct GNUNET_IDENTITY_PublicKey *public_key,
- struct GNUNET_MESSENGER_MemberSession *session)
+iterate_forward_members (void *cls,
+ const struct GNUNET_IDENTITY_PublicKey *public_key,
+ struct GNUNET_MESSENGER_MemberSession *session)
{
struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
@@ -71,8 +74,10 @@ iterate_forward_members (void *cls, const struct GNUNET_IDENTITY_PublicKey *publ
}
int
-recv_message_info (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+recv_message_info (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
const uint32_t version = get_tunnel_messenger_version(tunnel);
@@ -108,8 +113,10 @@ recv_message_info (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE
}
int
-recv_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+recv_message_peer (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
struct GNUNET_PeerIdentity peer;
GNUNET_PEER_resolve (tunnel->peer, &peer);
@@ -126,7 +133,8 @@ recv_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE
}
static void
-callback_found_message (void *cls, struct GNUNET_MESSENGER_SrvRoom *room,
+callback_found_message (void *cls,
+ struct GNUNET_MESSENGER_SrvRoom *room,
const struct GNUNET_MESSENGER_Message *message,
const struct GNUNET_HashCode *hash)
{
@@ -152,8 +160,10 @@ callback_found_message (void *cls, struct GNUNET_MESSENGER_SrvRoom *room,
* It will only be forwarded if it can't be answered!
*/
int
-recv_message_request (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+recv_message_request (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
struct GNUNET_MESSENGER_Member *member = get_store_member_of(member_store, message);
diff --git a/src/messenger/gnunet-service-messenger_message_recv.h b/src/messenger/gnunet-service-messenger_message_recv.h
index 9cb36c466..400c10245 100644
--- a/src/messenger/gnunet-service-messenger_message_recv.h
+++ b/src/messenger/gnunet-service-messenger_message_recv.h
@@ -46,8 +46,10 @@
* @return #GNUNET_NO to not forward the message
*/
int
-recv_message_info (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+recv_message_info (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Handles a received peer message to link it to its origin tunnel if the peer identity matches.
@@ -60,8 +62,10 @@ recv_message_info (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE
* @return #GNUNET_YES to forward the message
*/
int
-recv_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+recv_message_peer (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Handles a received request message by checking for the requested message and forwarding it back
@@ -75,7 +79,9 @@ recv_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE
* @return #GNUNET_YES or #GNUNET_NO depending on required forwarding
*/
int
-recv_message_request (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+recv_message_request (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
#endif //GNUNET_SERVICE_MESSENGER_MESSAGE_RECV_H
diff --git a/src/messenger/gnunet-service-messenger_message_send.c b/src/messenger/gnunet-service-messenger_message_send.c
index a59a178cc..8cc2466d7 100644
--- a/src/messenger/gnunet-service-messenger_message_send.c
+++ b/src/messenger/gnunet-service-messenger_message_send.c
@@ -30,15 +30,19 @@
#include "gnunet-service-messenger_operation.h"
void
-send_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+send_message_join (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
check_room_peer_status(room, NULL);
}
void
-send_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+send_message_peer (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
if (!room->peer_message)
room->peer_message = GNUNET_new(struct GNUNET_HashCode);
@@ -47,15 +51,19 @@ send_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE
}
void
-send_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+send_message_id (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
change_handle_member_id (handle, get_room_key(room), &(message->body.id.id));
}
void
-send_message_request (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+send_message_request (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
struct GNUNET_MESSENGER_OperationStore *operation_store = get_room_operation_store(room);
diff --git a/src/messenger/gnunet-service-messenger_message_send.h b/src/messenger/gnunet-service-messenger_message_send.h
index 63320ab17..232355c41 100644
--- a/src/messenger/gnunet-service-messenger_message_send.h
+++ b/src/messenger/gnunet-service-messenger_message_send.h
@@ -44,8 +44,10 @@
* @param[in] hash Hash of the message
*/
void
-send_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+send_message_join (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Handles a sent peer message to update the rooms peer message of this service.
@@ -57,8 +59,10 @@ send_message_join (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE
* @param[in] hash Hash of the message
*/
void
-send_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+send_message_peer (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Handles a sent id message to update the handles member id in the room.
@@ -70,8 +74,10 @@ send_message_peer (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE
* @param[in] hash Hash of the message
*/
void
-send_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+send_message_id (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Handles a sent request message to trigger the request operation for this service.
@@ -83,7 +89,9 @@ send_message_id (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_
* @param[in] hash Hash of the message
*/
void
-send_message_request (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+send_message_request (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
#endif //GNUNET_SERVICE_MESSENGER_MESSAGE_SEND_H
diff --git a/src/messenger/gnunet-service-messenger_message_state.c b/src/messenger/gnunet-service-messenger_message_state.c
index cdd2d9712..344962d11 100644
--- a/src/messenger/gnunet-service-messenger_message_state.c
+++ b/src/messenger/gnunet-service-messenger_message_state.c
@@ -65,8 +65,10 @@ get_message_state_merge_hash (const struct GNUNET_MESSENGER_MessageState *state)
}
void
-update_message_state (struct GNUNET_MESSENGER_MessageState *state, int requested,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+update_message_state (struct GNUNET_MESSENGER_MessageState *state,
+ int requested,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
GNUNET_assert((state) && (message) && (hash));
@@ -83,7 +85,8 @@ update_message_state (struct GNUNET_MESSENGER_MessageState *state, int requested
}
void
-load_message_state (struct GNUNET_MESSENGER_MessageState *state, const char *path)
+load_message_state (struct GNUNET_MESSENGER_MessageState *state,
+ const char *path)
{
GNUNET_assert((state) && (path));
@@ -95,7 +98,8 @@ load_message_state (struct GNUNET_MESSENGER_MessageState *state, const char *pat
}
void
-save_message_state (const struct GNUNET_MESSENGER_MessageState *state, const char *path)
+save_message_state (const struct GNUNET_MESSENGER_MessageState *state,
+ const char *path)
{
GNUNET_assert((state) && (path));
diff --git a/src/messenger/gnunet-service-messenger_message_state.h b/src/messenger/gnunet-service-messenger_message_state.h
index dc8671df4..af52b26b6 100644
--- a/src/messenger/gnunet-service-messenger_message_state.h
+++ b/src/messenger/gnunet-service-messenger_message_state.h
@@ -51,13 +51,17 @@ const struct GNUNET_HashCode*
get_message_state_merge_hash (const struct GNUNET_MESSENGER_MessageState *state);
void
-update_message_state (struct GNUNET_MESSENGER_MessageState *state, int requested,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+update_message_state (struct GNUNET_MESSENGER_MessageState *state,
+ int requested,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
void
-load_message_state (struct GNUNET_MESSENGER_MessageState *state, const char *path);
+load_message_state (struct GNUNET_MESSENGER_MessageState *state,
+ const char *path);
void
-save_message_state (const struct GNUNET_MESSENGER_MessageState *state, const char *path);
+save_message_state (const struct GNUNET_MESSENGER_MessageState *state,
+ const char *path);
#endif //GNUNET_SERVICE_MESSENGER_MESSAGE_STATE_H
diff --git a/src/messenger/gnunet-service-messenger_message_store.c b/src/messenger/gnunet-service-messenger_message_store.c
index 1984eba21..ddad266ad 100644
--- a/src/messenger/gnunet-service-messenger_message_store.c
+++ b/src/messenger/gnunet-service-messenger_message_store.c
@@ -42,7 +42,9 @@ init_message_store (struct GNUNET_MESSENGER_MessageStore *store)
}
static int
-iterate_destroy_entries (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_destroy_entries (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_MessageEntry *entry = value;
@@ -52,7 +54,9 @@ iterate_destroy_entries (void *cls, const struct GNUNET_HashCode *key, void *val
}
static int
-iterate_destroy_messages (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_destroy_messages (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_Message *message = value;
@@ -62,7 +66,9 @@ iterate_destroy_messages (void *cls, const struct GNUNET_HashCode *key, void *va
}
static int
-iterate_destroy_links (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_destroy_links (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_HashCode *previous = value;
@@ -98,8 +104,15 @@ struct GNUNET_MESSENGER_MessageEntryStorage
struct GNUNET_MESSENGER_MessageEntry entry;
};
+#define load_message_store_attribute_failed(file, attribute) \
+ sizeof(attribute) != GNUNET_DISK_file_read(file, &(attribute), sizeof(attribute))
+
+#define save_message_store_attribute_failed(file, attribute) \
+ sizeof(attribute) != GNUNET_DISK_file_write(file, &(attribute), sizeof(attribute))
+
static void
-load_message_store_entries (struct GNUNET_MESSENGER_MessageStore *store, const char *filename)
+load_message_store_entries (struct GNUNET_MESSENGER_MessageStore *store,
+ const char *filename)
{
enum GNUNET_DISK_AccessPermissions permission = (GNUNET_DISK_PERM_USER_READ);
@@ -111,31 +124,34 @@ load_message_store_entries (struct GNUNET_MESSENGER_MessageStore *store, const c
struct GNUNET_MESSENGER_MessageEntryStorage storage;
struct GNUNET_MESSENGER_MessageEntry *entry;
+ memset(&storage, 0, sizeof(storage));
+
do
{
+ entry = NULL;
+
+ if ((load_message_store_attribute_failed(entries, storage.hash)) ||
+ (load_message_store_attribute_failed(entries, storage.entry.offset)) ||
+ (load_message_store_attribute_failed(entries, storage.entry.length)))
+ break;
+
entry = GNUNET_new(struct GNUNET_MESSENGER_MessageEntry);
- if (GNUNET_DISK_file_read (entries, &storage, sizeof(storage)) == sizeof(storage))
- {
- GNUNET_memcpy(entry, &(storage.entry), sizeof(*entry));
-
- if ((GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (store->entries, &(storage.hash))) ||
- (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (store->entries, &(storage.hash), entry,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)))
- {
- store->rewrite_entries = GNUNET_YES;
- GNUNET_free(entry);
- }
- }
- else
- {
- GNUNET_free(entry);
+ GNUNET_memcpy(entry, &(storage.entry), sizeof(*entry));
- entry = NULL;
+ if ((GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (store->entries, &(storage.hash))) ||
+ (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (store->entries, &(storage.hash), entry,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)))
+ {
+ store->rewrite_entries = GNUNET_YES;
+ break;
}
}
while (entry);
+ if (entry)
+ GNUNET_free(entry);
+
GNUNET_DISK_file_close (entries);
}
@@ -146,7 +162,8 @@ struct GNUNET_MESSENGER_MessageLinkStorage
};
static void
-load_message_store_links (struct GNUNET_MESSENGER_MessageStore *store, const char *filename)
+load_message_store_links (struct GNUNET_MESSENGER_MessageStore *store,
+ const char *filename)
{
enum GNUNET_DISK_AccessPermissions permission = (GNUNET_DISK_PERM_USER_READ);
@@ -156,17 +173,19 @@ load_message_store_links (struct GNUNET_MESSENGER_MessageStore *store, const cha
return;
struct GNUNET_MESSENGER_MessageLinkStorage storage;
- struct GNUNET_MESSENGER_MessageLink *link = NULL;
+ struct GNUNET_MESSENGER_MessageLink *link;
memset(&storage, 0, sizeof(storage));
do
{
- if ((sizeof(storage.hash) != GNUNET_DISK_file_read (entries, &(storage.hash), sizeof(storage.hash))) ||
- (sizeof(storage.link.multiple) != GNUNET_DISK_file_read (entries, &(storage.link.multiple), sizeof(storage.link.multiple))) ||
- (sizeof(storage.link.first) != GNUNET_DISK_file_read (entries, &(storage.link.first), sizeof(storage.link.first))) ||
+ link = NULL;
+
+ if ((load_message_store_attribute_failed(entries, storage.hash)) ||
+ (load_message_store_attribute_failed(entries, storage.link.multiple)) ||
+ (load_message_store_attribute_failed(entries, storage.link.first)) ||
((GNUNET_YES == storage.link.multiple) &&
- (sizeof(storage.link.second) != GNUNET_DISK_file_read (entries, &(storage.link.second), sizeof(storage.link.second)))))
+ (load_message_store_attribute_failed(entries, storage.link.second))))
break;
link = GNUNET_new(struct GNUNET_MESSENGER_MessageLink);
@@ -187,7 +206,8 @@ load_message_store_links (struct GNUNET_MESSENGER_MessageStore *store, const cha
}
void
-load_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory)
+load_message_store (struct GNUNET_MESSENGER_MessageStore *store,
+ const char *directory)
{
GNUNET_assert((store) && (directory));
@@ -232,23 +252,26 @@ struct GNUNET_MESSENGER_ClosureMessageSave
};
static int
-iterate_save_entries (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_save_entries (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_ClosureMessageSave *save = cls;
struct GNUNET_MESSENGER_MessageEntry *entry = value;
struct GNUNET_MESSENGER_MessageEntryStorage storage;
- GNUNET_memcpy(&(storage.hash), key, sizeof(storage.hash));
- GNUNET_memcpy(&(storage.entry), entry, sizeof(*entry));
-
- GNUNET_DISK_file_write (save->storage, &storage, sizeof(storage));
+ GNUNET_DISK_file_write (save->storage, key, sizeof(*key));
+ GNUNET_DISK_file_write (save->storage, &(entry->offset), sizeof(entry->offset));
+ GNUNET_DISK_file_write (save->storage, &(entry->length), sizeof(entry->length));
return GNUNET_YES;
}
static int
-iterate_save_messages (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_save_messages (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_ClosureMessageSave *save = cls;
@@ -263,8 +286,10 @@ iterate_save_messages (void *cls, const struct GNUNET_HashCode *key, void *value
storage.entry.length = get_message_size (message, GNUNET_YES);
storage.entry.offset = GNUNET_DISK_file_seek (save->store->storage_messages, 0, GNUNET_DISK_SEEK_END);
- if ((GNUNET_SYSERR == storage.entry.offset) || (sizeof(storage)
- != GNUNET_DISK_file_write (save->storage, &storage, sizeof(storage))))
+ if ((GNUNET_SYSERR == storage.entry.offset) ||
+ (save_message_store_attribute_failed(save->storage, storage.hash)) ||
+ (save_message_store_attribute_failed(save->storage, storage.entry.offset)) ||
+ (save_message_store_attribute_failed(save->storage, storage.entry.length)))
return GNUNET_YES;
char *buffer = GNUNET_malloc(storage.entry.length);
@@ -274,12 +299,13 @@ iterate_save_messages (void *cls, const struct GNUNET_HashCode *key, void *value
GNUNET_DISK_file_write (save->store->storage_messages, buffer, storage.entry.length);
GNUNET_free(buffer);
-
return GNUNET_YES;
}
static int
-iterate_save_links (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_save_links (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_ClosureMessageSave *save = cls;
struct GNUNET_MESSENGER_MessageLink *link = value;
@@ -295,7 +321,8 @@ iterate_save_links (void *cls, const struct GNUNET_HashCode *key, void *value)
}
void
-save_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory)
+save_message_store (struct GNUNET_MESSENGER_MessageStore *store,
+ const char *directory)
{
GNUNET_assert((store) && (directory));
@@ -372,7 +399,8 @@ close_entries:
}
int
-contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
+contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store,
+ const struct GNUNET_HashCode *hash)
{
GNUNET_assert((store) && (hash));
@@ -383,7 +411,8 @@ contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, const
}
const struct GNUNET_MESSENGER_Message*
-get_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
+get_store_message (struct GNUNET_MESSENGER_MessageStore *store,
+ const struct GNUNET_HashCode *hash)
{
GNUNET_assert((store) && (hash));
@@ -409,7 +438,7 @@ get_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNU
return NULL;
if ((GNUNET_DISK_file_read (store->storage_messages, buffer, entry->length) != entry->length) ||
- (entry->length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN)))
+ (entry->length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_YES)))
goto free_buffer;
message = create_message (GNUNET_MESSENGER_KIND_UNKNOWN);
@@ -444,7 +473,8 @@ free_buffer:
}
const struct GNUNET_MESSENGER_MessageLink*
-get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash,
+get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store,
+ const struct GNUNET_HashCode *hash,
int deleted_only)
{
if (deleted_only)
@@ -473,7 +503,8 @@ get_link:
}
int
-put_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash,
+put_store_message (struct GNUNET_MESSENGER_MessageStore *store,
+ const struct GNUNET_HashCode *hash,
struct GNUNET_MESSENGER_Message *message)
{
GNUNET_assert((store) && (hash) && (message));
@@ -483,7 +514,8 @@ put_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNU
}
static void
-add_link (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash,
+add_link (struct GNUNET_MESSENGER_MessageStore *store,
+ const struct GNUNET_HashCode *hash,
const struct GNUNET_MESSENGER_Message *message)
{
struct GNUNET_MESSENGER_MessageLink *link = GNUNET_new(struct GNUNET_MESSENGER_MessageLink);
@@ -503,7 +535,8 @@ add_link (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashC
}
int
-delete_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
+delete_store_message (struct GNUNET_MESSENGER_MessageStore *store,
+ const struct GNUNET_HashCode *hash)
{
GNUNET_assert((store) && (hash));
diff --git a/src/messenger/gnunet-service-messenger_message_store.h b/src/messenger/gnunet-service-messenger_message_store.h
index 87305826a..476d98dd5 100644
--- a/src/messenger/gnunet-service-messenger_message_store.h
+++ b/src/messenger/gnunet-service-messenger_message_store.h
@@ -81,7 +81,8 @@ clear_message_store (struct GNUNET_MESSENGER_MessageStore *store);
* @param[in] directory Path to a directory
*/
void
-load_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory);
+load_message_store (struct GNUNET_MESSENGER_MessageStore *store,
+ const char *directory);
/**
* Saves messages from a message <i>store</i> into a <i>directory</i>.
@@ -90,7 +91,8 @@ load_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *dir
* @param[in] directory Path to a directory
*/
void
-save_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory);
+save_message_store (struct GNUNET_MESSENGER_MessageStore *store,
+ const char *directory);
/**
* Checks if a message matching a given <i>hash</i> is stored in a message <i>store</i>.
@@ -103,7 +105,8 @@ save_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *dir
* @return #GNUNET_YES on match, otherwise #GNUNET_NO
*/
int
-contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash);
+contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store,
+ const struct GNUNET_HashCode *hash);
/**
* Returns the message from a message <i>store</i> matching a given <i>hash</i>. If no matching
@@ -117,7 +120,8 @@ contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, const
* @return Message or NULL
*/
const struct GNUNET_MESSENGER_Message*
-get_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash);
+get_store_message (struct GNUNET_MESSENGER_MessageStore *store,
+ const struct GNUNET_HashCode *hash);
/**
* Returns the message link from a message <i>store</i> matching a given <i>hash</i>. If the
@@ -133,7 +137,8 @@ get_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNU
* @return Message link or NULL
*/
const struct GNUNET_MESSENGER_MessageLink*
-get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash,
+get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store,
+ const struct GNUNET_HashCode *hash,
int deleted_only);
/**
@@ -145,7 +150,8 @@ get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store, const struc
* @return #GNUNET_OK on success, otherwise #GNUNET_NO
*/
int
-put_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash,
+put_store_message (struct GNUNET_MESSENGER_MessageStore *store,
+ const struct GNUNET_HashCode *hash,
struct GNUNET_MESSENGER_Message *message);
/**
@@ -157,6 +163,7 @@ put_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNU
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/
int
-delete_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash);
+delete_store_message (struct GNUNET_MESSENGER_MessageStore *store,
+ const struct GNUNET_HashCode *hash);
#endif //GNUNET_SERVICE_MESSENGER_MESSAGE_STORE_H
diff --git a/src/messenger/gnunet-service-messenger_operation.c b/src/messenger/gnunet-service-messenger_operation.c
index d0c378699..2b92d0c1d 100644
--- a/src/messenger/gnunet-service-messenger_operation.c
+++ b/src/messenger/gnunet-service-messenger_operation.c
@@ -58,10 +58,13 @@ static void
callback_operation (void *cls);
struct GNUNET_MESSENGER_Operation*
-load_operation (struct GNUNET_MESSENGER_OperationStore *store, const char *path)
+load_operation (struct GNUNET_MESSENGER_OperationStore *store,
+ const char *path)
{
GNUNET_assert((store) && (path));
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Load operation configuration: %s\n", path);
+
struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create ();
struct GNUNET_MESSENGER_Operation* op = NULL;
@@ -118,10 +121,13 @@ destroy_config:
}
void
-save_operation (const struct GNUNET_MESSENGER_Operation *op, const char *path)
+save_operation (const struct GNUNET_MESSENGER_Operation *op,
+ const char *path)
{
GNUNET_assert((path) && (op));
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Save operation configuration: %s\n", path);
+
struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create ();
char *hash_data;
diff --git a/src/messenger/gnunet-service-messenger_operation.h b/src/messenger/gnunet-service-messenger_operation.h
index f1e06f4a7..485668548 100644
--- a/src/messenger/gnunet-service-messenger_operation.h
+++ b/src/messenger/gnunet-service-messenger_operation.h
@@ -86,7 +86,8 @@ destroy_operation (struct GNUNET_MESSENGER_Operation *op);
* @param[in] path Path of a configuration file
*/
struct GNUNET_MESSENGER_Operation*
-load_operation (struct GNUNET_MESSENGER_OperationStore *store, const char *path);
+load_operation (struct GNUNET_MESSENGER_OperationStore *store,
+ const char *path);
/**
* Saves data from an <i>operation</i> into a configuration file at a
@@ -97,7 +98,8 @@ load_operation (struct GNUNET_MESSENGER_OperationStore *store, const char *path)
* @param[in] path Path of a configuration file
*/
void
-save_operation (const struct GNUNET_MESSENGER_Operation *op, const char *path);
+save_operation (const struct GNUNET_MESSENGER_Operation *op,
+ const char *path);
/**
* Starts an inactive operation with a given <i>delay</i> in a
diff --git a/src/messenger/gnunet-service-messenger_operation_store.c b/src/messenger/gnunet-service-messenger_operation_store.c
index a32fbad2c..276f0b92b 100644
--- a/src/messenger/gnunet-service-messenger_operation_store.c
+++ b/src/messenger/gnunet-service-messenger_operation_store.c
@@ -29,7 +29,8 @@
#include "gnunet-service-messenger_room.h"
void
-init_operation_store (struct GNUNET_MESSENGER_OperationStore *store, struct GNUNET_MESSENGER_SrvRoom *room)
+init_operation_store (struct GNUNET_MESSENGER_OperationStore *store,
+ struct GNUNET_MESSENGER_SrvRoom *room)
{
GNUNET_assert((store) && (room));
@@ -38,7 +39,9 @@ init_operation_store (struct GNUNET_MESSENGER_OperationStore *store, struct GNUN
}
static int
-iterate_destroy_operations (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_destroy_operations (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_Operation *op = value;
@@ -57,27 +60,25 @@ clear_operation_store (struct GNUNET_MESSENGER_OperationStore *store)
}
static int
-callback_scan_for_operations (void *cls, const char *filename)
+callback_scan_for_operations (void *cls,
+ const char *filename)
{
struct GNUNET_MESSENGER_OperationStore *store = cls;
- if (GNUNET_YES == GNUNET_DISK_file_test (filename))
- {
- char *path;
-
- GNUNET_asprintf (&path, "%s%c", filename, DIR_SEPARATOR);
+ if (GNUNET_YES != GNUNET_DISK_file_test (filename))
+ return GNUNET_OK;
- struct GNUNET_MESSENGER_Operation *op = load_operation(store, path);
+ if ((strlen(filename) <= 4) || (0 != strcmp(filename + strlen(filename) - 4, ".cfg")))
+ return GNUNET_OK;
- if ((op) && (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put(
- store->operations,
- &(op->hash), op,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)))
- {
- destroy_operation(op);
- }
+ struct GNUNET_MESSENGER_Operation *op = load_operation(store, filename);
- GNUNET_free(path);
+ if ((op) && (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put(
+ store->operations,
+ &(op->hash), op,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)))
+ {
+ destroy_operation(op);
}
return GNUNET_OK;
@@ -89,12 +90,19 @@ load_operation_store (struct GNUNET_MESSENGER_OperationStore *store,
{
GNUNET_assert ((store) && (directory));
- if (GNUNET_OK == GNUNET_DISK_directory_test (directory, GNUNET_YES))
- GNUNET_DISK_directory_scan (directory, callback_scan_for_operations, store);
+ char* load_dir;
+ GNUNET_asprintf (&load_dir, "%s%s%c", directory, "operations", DIR_SEPARATOR);
+
+ if (GNUNET_OK == GNUNET_DISK_directory_test (load_dir, GNUNET_YES))
+ GNUNET_DISK_directory_scan (load_dir, callback_scan_for_operations, store);
+
+ GNUNET_free(load_dir);
}
static int
-iterate_save_operations (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_save_operations (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
const char *save_dir = cls;
@@ -192,10 +200,12 @@ cancel_store_operation (struct GNUNET_MESSENGER_OperationStore *store,
}
extern void
-callback_room_deletion (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash);
+callback_room_deletion (struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_HashCode *hash);
extern void
-callback_room_merge (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash);
+callback_room_merge (struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_HashCode *hash);
void
callback_store_operation (struct GNUNET_MESSENGER_OperationStore *store,
diff --git a/src/messenger/gnunet-service-messenger_operation_store.h b/src/messenger/gnunet-service-messenger_operation_store.h
index 4c613437c..18eb7f8a1 100644
--- a/src/messenger/gnunet-service-messenger_operation_store.h
+++ b/src/messenger/gnunet-service-messenger_operation_store.h
@@ -48,7 +48,8 @@ struct GNUNET_MESSENGER_OperationStore
* @param[in/out] room Room
*/
void
-init_operation_store (struct GNUNET_MESSENGER_OperationStore *store, struct GNUNET_MESSENGER_SrvRoom *room);
+init_operation_store (struct GNUNET_MESSENGER_OperationStore *store,
+ struct GNUNET_MESSENGER_SrvRoom *room);
/**
* Clears an operation <i>store</i>, stops all operations and deallocates its memory.
diff --git a/src/messenger/gnunet-service-messenger_room.c b/src/messenger/gnunet-service-messenger_room.c
index 73e94908f..7f2fd0ca6 100644
--- a/src/messenger/gnunet-service-messenger_room.c
+++ b/src/messenger/gnunet-service-messenger_room.c
@@ -43,7 +43,8 @@ static void
idle_request_room_messages (void *cls);
struct GNUNET_MESSENGER_SrvRoom*
-create_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
+create_room (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((handle) && (key));
@@ -78,7 +79,9 @@ create_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_Hash
}
static int
-iterate_destroy_tunnels (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
+iterate_destroy_tunnels (void *cls,
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
{
struct GNUNET_MESSENGER_SrvTunnel *tunnel = value;
destroy_tunnel (tunnel);
@@ -150,7 +153,8 @@ get_room_operation_store (struct GNUNET_MESSENGER_SrvRoom *room)
}
static int
-send_room_info (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
+send_room_info (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
struct GNUNET_MESSENGER_SrvTunnel *tunnel)
{
if ((!handle) || (!is_tunnel_connected (tunnel)))
@@ -160,7 +164,9 @@ send_room_info (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_S
}
static void*
-callback_room_connect (void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *source)
+callback_room_connect (void *cls,
+ struct GNUNET_CADET_Channel *channel,
+ const struct GNUNET_PeerIdentity *source)
{
struct GNUNET_MESSENGER_SrvRoom *room = cls;
@@ -197,7 +203,8 @@ callback_room_connect (void *cls, struct GNUNET_CADET_Channel *channel, const st
}
static int
-join_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
+join_room (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
struct GNUNET_MESSENGER_Member *member)
{
GNUNET_assert((room) && (handle) && (member));
@@ -205,7 +212,9 @@ join_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHan
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Joining room: %s (%s)\n", GNUNET_h2s (get_room_key (room)),
GNUNET_sh2s (get_member_id(member)));
- if (GNUNET_OK != change_handle_member_id (handle, get_room_key(room), get_member_id(member)))
+ const struct GNUNET_ShortHashCode *member_id = get_member_id(member);
+
+ if (GNUNET_OK != change_handle_member_id (handle, get_room_key(room), member_id))
return GNUNET_NO;
struct GNUNET_MESSENGER_Message *message = create_message_join (get_handle_ego (handle));
@@ -217,6 +226,7 @@ join_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHan
return GNUNET_NO;
}
+ GNUNET_memcpy(&(message->header.sender_id), member_id, sizeof(*member_id));
return send_room_message (room, handle, message);
}
@@ -228,8 +238,10 @@ struct GNUNET_MESSENGER_MemberNotify
};
static void
-notify_about_members (struct GNUNET_MESSENGER_MemberNotify *notify, struct GNUNET_MESSENGER_MemberSession *session,
- struct GNUNET_CONTAINER_MultiHashMap *map, int check_permission)
+notify_about_members (struct GNUNET_MESSENGER_MemberNotify *notify,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ struct GNUNET_CONTAINER_MultiHashMap *map,
+ int check_permission)
{
if (session->prev)
notify_about_members (notify, session->prev, map, GNUNET_YES);
@@ -253,12 +265,13 @@ notify_about_members (struct GNUNET_MESSENGER_MemberNotify *notify, struct GNUNE
const struct GNUNET_MESSENGER_Message *message = get_store_message(message_store, &(element->hash));
if (message)
- notify_handle_message (notify->handle, get_room_key(notify->room), session, message, &(element->hash));
+ notify_handle_message (notify->handle, notify->room, session, message, &(element->hash));
}
}
static int
-iterate_notify_about_members (void *cls, const struct GNUNET_IDENTITY_PublicKey *public_key,
+iterate_notify_about_members (void *cls,
+ const struct GNUNET_IDENTITY_PublicKey *public_key,
struct GNUNET_MESSENGER_MemberSession *session)
{
struct GNUNET_MESSENGER_MemberNotify *notify = cls;
@@ -275,7 +288,8 @@ iterate_notify_about_members (void *cls, const struct GNUNET_IDENTITY_PublicKey
}
static int
-join_room_locally (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
+join_room_locally (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle)
{
const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (handle, get_room_key(room));
@@ -306,16 +320,20 @@ join_room_locally (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE
}
extern int
-check_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header);
+check_tunnel_message (void *cls,
+ const struct GNUNET_MessageHeader *header);
extern void
-handle_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header);
+handle_tunnel_message (void *cls,
+ const struct GNUNET_MessageHeader *header);
extern void
-callback_tunnel_disconnect (void *cls, const struct GNUNET_CADET_Channel *channel);
+callback_tunnel_disconnect (void *cls,
+ const struct GNUNET_CADET_Channel *channel);
int
-open_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
+open_room (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle)
{
GNUNET_assert((room) && (handle));
@@ -344,12 +362,7 @@ open_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHan
const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (handle, get_room_key(room));
struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
- struct GNUNET_MESSENGER_Member *member = get_store_member(member_store, member_id);
-
- if (member)
- goto exit_open_room;
-
- member = add_store_member(member_store, member_id);
+ struct GNUNET_MESSENGER_Member *member = add_store_member(member_store, member_id);
if ((GNUNET_NO == join_room (room, handle, member)) && (room->port))
{
@@ -361,12 +374,14 @@ open_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHan
return GNUNET_NO;
}
-exit_open_room:
- return (room->port ? send_room_message (room, handle, create_message_peer (room->service)) : GNUNET_NO);
+ struct GNUNET_MESSENGER_Message *peer_msg = create_message_peer (room->service);
+ GNUNET_memcpy(&(peer_msg->header.sender_id), member_id, sizeof(*member_id));
+ return (room->port ? send_room_message (room, handle, peer_msg) : GNUNET_NO);
}
int
-enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
+enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
const struct GNUNET_PeerIdentity *door)
{
GNUNET_assert((room) && (handle) && (door));
@@ -404,8 +419,11 @@ enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Sr
}
struct GNUNET_MQ_Envelope*
-pack_room_message (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SrvHandle *handle,
- struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, int mode)
+pack_room_message (const struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_MESSENGER_SrvHandle *handle,
+ struct GNUNET_MESSENGER_Message *message,
+ struct GNUNET_HashCode *hash,
+ int mode)
{
GNUNET_assert((room) && (handle) && (message) && (hash));
@@ -432,7 +450,9 @@ struct GNUNET_MESSENGER_ClosureSendRoom
};
static int
-iterate_send_room_message (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
+iterate_send_room_message (void *cls,
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
{
struct GNUNET_MESSENGER_SrvTunnel *tunnel = value;
@@ -466,14 +486,18 @@ iterate_send_room_message (void *cls, const struct GNUNET_PeerIdentity *key, voi
int
update_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+ struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
void
-callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
int
-send_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
+send_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
struct GNUNET_MESSENGER_Message *message)
{
GNUNET_assert((room) && (handle));
@@ -530,8 +554,10 @@ send_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE
}
void
-forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel,
- struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
GNUNET_assert((room) && (tunnel));
@@ -554,7 +580,8 @@ forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSE
}
void
-check_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel)
+check_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvTunnel *tunnel)
{
if (!room->peer_message)
return;
@@ -592,7 +619,8 @@ resend_peer_message:
}
void
-merge_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
+merge_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle)
{
GNUNET_assert(room);
@@ -612,7 +640,8 @@ merge_next:
}
void
-callback_room_deletion (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash)
+callback_room_deletion (struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_HashCode *hash)
{
if (GNUNET_OK != delete_store_message (get_room_message_store(room), hash))
{
@@ -622,7 +651,8 @@ callback_room_deletion (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUN
}
void
-callback_room_merge (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash)
+callback_room_merge (struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_HashCode *hash)
{
if (!room->host)
return;
@@ -631,8 +661,10 @@ callback_room_merge (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_
}
int
-delete_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
+delete_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_HashCode *hash,
+ const struct GNUNET_TIME_Relative delay)
{
GNUNET_assert((room) && (session) && (hash));
@@ -687,7 +719,8 @@ get_room_key (const struct GNUNET_MESSENGER_SrvRoom *room)
}
const struct GNUNET_MESSENGER_SrvTunnel*
-get_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_PeerIdentity *peer)
+get_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_PeerIdentity *peer)
{
GNUNET_assert((room) && (peer));
@@ -695,9 +728,11 @@ get_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNE
}
static int
-request_room_message_step (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash,
+request_room_message_step (struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_HashCode *hash,
const struct GNUNET_MESSENGER_MemberSession *session,
- GNUNET_MESSENGER_MessageRequestCallback callback, void* cls)
+ GNUNET_MESSENGER_MessageRequestCallback callback,
+ void* cls)
{
struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(room);
@@ -732,9 +767,11 @@ forward:
}
int
-request_room_message (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash,
+request_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_HashCode *hash,
const struct GNUNET_MESSENGER_MemberSession *session,
- GNUNET_MESSENGER_MessageRequestCallback callback, void* cls)
+ GNUNET_MESSENGER_MessageRequestCallback callback,
+ void* cls)
{
GNUNET_assert((room) && (hash));
@@ -747,7 +784,8 @@ request_room_message (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET
}
void
-callback_room_disconnect (struct GNUNET_MESSENGER_SrvRoom *room, void *cls)
+callback_room_disconnect (struct GNUNET_MESSENGER_SrvRoom *room,
+ void *cls)
{
struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
@@ -766,8 +804,10 @@ callback_room_disconnect (struct GNUNET_MESSENGER_SrvRoom *room, void *cls)
}
int
-callback_verify_room_message (struct GNUNET_MESSENGER_SrvRoom *room, void *cls,
- struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash)
+callback_verify_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ void *cls,
+ struct GNUNET_MESSENGER_Message *message,
+ struct GNUNET_HashCode *hash)
{
if (GNUNET_MESSENGER_KIND_UNKNOWN == message->header.kind)
{
@@ -826,8 +866,10 @@ idle_request_room_messages (void *cls)
}
void
-solve_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_IDENTITY_PublicKey *public_key,
- const struct GNUNET_ShortHashCode *member_id, struct GNUNET_TIME_Absolute timestamp)
+solve_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_IDENTITY_PublicKey *public_key,
+ const struct GNUNET_ShortHashCode *member_id,
+ struct GNUNET_TIME_Absolute timestamp)
{
GNUNET_assert ((room) && (public_key) && (member_id));
@@ -945,7 +987,8 @@ finish_handling:
int
update_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+ struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
GNUNET_assert((room) && (message) && (hash));
@@ -1008,7 +1051,8 @@ struct GNUNET_MESSENGER_MemberUpdate
};
static int
-iterate_update_member_sessions (void *cls, const struct GNUNET_IDENTITY_PublicKey *public_key,
+iterate_update_member_sessions (void *cls,
+ const struct GNUNET_IDENTITY_PublicKey *public_key,
struct GNUNET_MESSENGER_MemberSession *session)
{
struct GNUNET_MESSENGER_MemberUpdate *update = cls;
@@ -1030,11 +1074,14 @@ iterate_update_member_sessions (void *cls, const struct GNUNET_IDENTITY_PublicKe
}
static void
-remove_room_member_session (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session);
+remove_room_member_session (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session);
void
-callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
struct GNUNET_MESSENGER_Member *member = get_store_member_of(member_store, message);
@@ -1113,7 +1160,8 @@ callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUN
}
static void
-get_room_data_subdir (struct GNUNET_MESSENGER_SrvRoom *room, char **dir)
+get_room_data_subdir (struct GNUNET_MESSENGER_SrvRoom *room,
+ char **dir)
{
GNUNET_assert((room) && (dir));
@@ -1140,11 +1188,7 @@ load_room (struct GNUNET_MESSENGER_SrvRoom *room)
load_list_tunnels(&(room->basement), basement_file);
GNUNET_free(basement_file);
- char *last_messages_file;
- GNUNET_asprintf (&last_messages_file, "%s%s", room_dir, "last_messages.list");
-
load_message_state(&(room->state), room_dir);
- GNUNET_free (last_messages_file);
}
GNUNET_free(room_dir);
@@ -1178,7 +1222,8 @@ save_room (struct GNUNET_MESSENGER_SrvRoom *room)
}
static void
-remove_room_member_session (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session)
+remove_room_member_session (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session)
{
GNUNET_assert ((room) && (session));
diff --git a/src/messenger/gnunet-service-messenger_room.h b/src/messenger/gnunet-service-messenger_room.h
index 31ec877af..4b3811104 100644
--- a/src/messenger/gnunet-service-messenger_room.h
+++ b/src/messenger/gnunet-service-messenger_room.h
@@ -89,7 +89,8 @@ struct GNUNET_MESSENGER_SrvRoom
* @return New room
*/
struct GNUNET_MESSENGER_SrvRoom*
-create_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key);
+create_room (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key);
/**
* Destroys a room and frees its memory fully.
@@ -139,7 +140,8 @@ get_room_operation_store (struct GNUNET_MESSENGER_SrvRoom *room);
* @return #GNUNET_YES on success, #GNUNET_NO on failure.
*/
int
-open_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle);
+open_room (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle);
/**
* Connects a tunnel to a hosting peer of a <i>room</i> through a so called <i>door</i> which is represented by
@@ -152,7 +154,8 @@ open_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHan
* @return #GNUNET_YES on success, #GNUNET_NO on failure.
*/
int
-enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
+enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
const struct GNUNET_PeerIdentity *door);
/**
@@ -173,8 +176,11 @@ enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Sr
* @return New envelope or NULL
*/
struct GNUNET_MQ_Envelope*
-pack_room_message (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SrvHandle *handle,
- struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, int mode);
+pack_room_message (const struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_MESSENGER_SrvHandle *handle,
+ struct GNUNET_MESSENGER_Message *message,
+ struct GNUNET_HashCode *hash,
+ int mode);
/**
* Sends a <i>message</i> from a given <i>handle</i> into a <i>room</i>. The <i>hash</i> parameter will be
@@ -192,7 +198,8 @@ pack_room_message (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNU
* @return #GNUNET_YES on success, #GNUNET_NO or #GNUNET_SYSERR otherwise.
*/
int
-send_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
+send_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
struct GNUNET_MESSENGER_Message *message);
/**
@@ -204,8 +211,10 @@ send_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE
* @param[in] hash Hash of message
*/
void
-forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel,
- struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Checks the current state of opening a given <i>room</i> from this peer and re-publishes it
@@ -216,7 +225,8 @@ forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSE
* @param[in/out] tunnel Tunnel
*/
void
-check_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel);
+check_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvTunnel *tunnel);
/**
* Reduces all current forks inside of the message history of a <i>room</i> to one remaining last message
@@ -226,7 +236,8 @@ check_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MES
* @param[in/out] handle Handle
*/
void
-merge_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle);
+merge_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle);
/**
* Deletes a message from the <i>room</i> with a given <i>hash</i> in a specific <i>delay</i> if
@@ -239,8 +250,10 @@ merge_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_M
* @return #GNUNET_YES on success, #GNUNET_NO if permission gets denied, #GNUNET_SYSERR on operation failure
*/
int
-delete_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay);
+delete_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_HashCode *hash,
+ const struct GNUNET_TIME_Relative delay);
/**
* Returns the CADET handle from a rooms service.
@@ -269,7 +282,8 @@ get_room_key (const struct GNUNET_MESSENGER_SrvRoom *room);
* @return Tunnel or NULL
*/
const struct GNUNET_MESSENGER_SrvTunnel*
-get_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_PeerIdentity *peer);
+get_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_PeerIdentity *peer);
/**
* Method called whenever a <i>message</i> is found during a request in a <i>room</i>.
@@ -280,7 +294,8 @@ get_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNE
* @param[in] hash Hash of message
*/
typedef void (GNUNET_MESSENGER_MessageRequestCallback) (
- void *cls, struct GNUNET_MESSENGER_SrvRoom *room,
+ void *cls,
+ struct GNUNET_MESSENGER_SrvRoom *room,
const struct GNUNET_MESSENGER_Message *message,
const struct GNUNET_HashCode *hash
);
@@ -301,9 +316,11 @@ typedef void (GNUNET_MESSENGER_MessageRequestCallback) (
* @return #GNUNET_YES if the request could be processed, otherwise #GNUNET_NO
*/
int
-request_room_message (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash,
+request_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_HashCode *hash,
const struct GNUNET_MESSENGER_MemberSession *session,
- GNUNET_MESSENGER_MessageRequestCallback callback, void* cls);
+ GNUNET_MESSENGER_MessageRequestCallback callback,
+ void* cls);
/**
* Checks for potential collisions with member ids and solves them changing active handles ids if they
@@ -315,8 +332,10 @@ request_room_message (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET
* @param[in] timestamp Timestamp
*/
void
-solve_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_IDENTITY_PublicKey *public_key,
- const struct GNUNET_ShortHashCode *member_id, struct GNUNET_TIME_Absolute timestamp);
+solve_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_IDENTITY_PublicKey *public_key,
+ const struct GNUNET_ShortHashCode *member_id,
+ struct GNUNET_TIME_Absolute timestamp);
/**
* Rebuilds the decentralized structure for a <i>room</i> by ensuring all required connections are made
diff --git a/src/messenger/gnunet-service-messenger_service.c b/src/messenger/gnunet-service-messenger_service.c
index 8c63e9bf4..b53b72af8 100644
--- a/src/messenger/gnunet-service-messenger_service.c
+++ b/src/messenger/gnunet-service-messenger_service.c
@@ -41,7 +41,8 @@ callback_shutdown_service (void *cls)
}
struct GNUNET_MESSENGER_Service*
-create_service (const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_SERVICE_Handle *service_handle)
+create_service (const struct GNUNET_CONFIGURATION_Handle *config,
+ struct GNUNET_SERVICE_Handle *service_handle)
{
GNUNET_assert((config) && (service_handle));
@@ -88,7 +89,9 @@ create_service (const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_
}
static int
-iterate_destroy_rooms (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_destroy_rooms (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_SrvRoom *room = value;
destroy_room (room);
@@ -151,7 +154,8 @@ get_service_contact_store (struct GNUNET_MESSENGER_Service *service)
}
struct GNUNET_MESSENGER_SrvHandle*
-add_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq)
+add_service_handle (struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_MQ_Handle *mq)
{
GNUNET_assert((service) && (mq));
@@ -166,7 +170,8 @@ add_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_H
}
void
-remove_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle)
+remove_service_handle (struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_MESSENGER_SrvHandle *handle)
{
GNUNET_assert((service) && (handle));
@@ -178,7 +183,8 @@ remove_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_M
}
int
-get_service_peer_identity (const struct GNUNET_MESSENGER_Service *service, struct GNUNET_PeerIdentity *peer)
+get_service_peer_identity (const struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_PeerIdentity *peer)
{
GNUNET_assert((service) && (peer));
@@ -186,7 +192,8 @@ get_service_peer_identity (const struct GNUNET_MESSENGER_Service *service, struc
}
struct GNUNET_MESSENGER_SrvRoom*
-get_service_room (const struct GNUNET_MESSENGER_Service *service, const struct GNUNET_HashCode *key)
+get_service_room (const struct GNUNET_MESSENGER_Service *service,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((service) && (key));
@@ -194,7 +201,8 @@ get_service_room (const struct GNUNET_MESSENGER_Service *service, const struct G
}
int
-open_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle,
+open_service_room (struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
const struct GNUNET_HashCode *key)
{
GNUNET_assert((service) && (handle) && (key));
@@ -217,8 +225,10 @@ open_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSE
}
int
-entry_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key)
+entry_service_room (struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_PeerIdentity *door,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((service) && (handle) && (door) && (key));
@@ -250,7 +260,8 @@ entry_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESS
}
int
-close_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle,
+close_service_room (struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
const struct GNUNET_HashCode *key)
{
GNUNET_assert((service) && (handle) && (key));
@@ -290,9 +301,11 @@ close_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESS
}
void
-handle_service_message (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvRoom *room,
+handle_service_message (struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_MESSENGER_SrvRoom *room,
const struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
GNUNET_assert((service) && (room) && (session) && (message) && (hash));
@@ -300,7 +313,7 @@ handle_service_message (struct GNUNET_MESSENGER_Service *service, struct GNUNET_
while (element)
{
- notify_handle_message (element->handle, get_room_key(room), session, message, hash);
+ notify_handle_message (element->handle, room, session, message, hash);
element = element->next;
}
}
diff --git a/src/messenger/gnunet-service-messenger_service.h b/src/messenger/gnunet-service-messenger_service.h
index aa43fa457..d364a93c0 100644
--- a/src/messenger/gnunet-service-messenger_service.h
+++ b/src/messenger/gnunet-service-messenger_service.h
@@ -68,7 +68,8 @@ struct GNUNET_MESSENGER_Service
* @return New service
*/
struct GNUNET_MESSENGER_Service*
-create_service (const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_SERVICE_Handle *service_handle);
+create_service (const struct GNUNET_CONFIGURATION_Handle *config,
+ struct GNUNET_SERVICE_Handle *service_handle);
/**
* Destroys a <i>service</i> and frees its memory fully.
@@ -104,7 +105,8 @@ get_service_contact_store (struct GNUNET_MESSENGER_Service *service);
* @return New handle
*/
struct GNUNET_MESSENGER_SrvHandle*
-add_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq);
+add_service_handle (struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_MQ_Handle *mq);
/**
* Removes a <i>handle</i> from a <i>service</i> and destroys it.
@@ -113,7 +115,8 @@ add_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_H
* @param[in/out] handle Handle
*/
void
-remove_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle);
+remove_service_handle (struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_MESSENGER_SrvHandle *handle);
/**
* Tries to write the peer identity of the peer running a <i>service</i> on to the <i>peer</i>
@@ -124,7 +127,8 @@ remove_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_M
* @return #GNUNET_OK on success, otherwise #GNUNET_SYSERR
*/
int
-get_service_peer_identity (const struct GNUNET_MESSENGER_Service *service, struct GNUNET_PeerIdentity *peer);
+get_service_peer_identity (const struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_PeerIdentity *peer);
/**
* Returns the room identified by a given <i>key</i> for a <i>service</i>. If the service doesn't know any room
@@ -135,7 +139,8 @@ get_service_peer_identity (const struct GNUNET_MESSENGER_Service *service, struc
* @return Room or NULL
*/
struct GNUNET_MESSENGER_SrvRoom*
-get_service_room (const struct GNUNET_MESSENGER_Service *service, const struct GNUNET_HashCode *key);
+get_service_room (const struct GNUNET_MESSENGER_Service *service,
+ const struct GNUNET_HashCode *key);
/**
* Tries to open a room using a given <i>key</i> for a <i>service</i> by a specific <i>handle</i>. The room will be
@@ -147,7 +152,8 @@ get_service_room (const struct GNUNET_MESSENGER_Service *service, const struct G
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
int
-open_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle,
+open_service_room (struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
const struct GNUNET_HashCode *key);
/**
@@ -164,8 +170,10 @@ open_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSE
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
int
-entry_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key);
+entry_service_room (struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_PeerIdentity *door,
+ const struct GNUNET_HashCode *key);
/**
* Tries to close a room using a given <i>key</i> for a <i>service</i> by a specific <i>handle</i>. The room will
@@ -180,7 +188,8 @@ entry_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESS
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
int
-close_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle,
+close_service_room (struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
const struct GNUNET_HashCode *key);
/**
@@ -194,8 +203,10 @@ close_service_room (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESS
* @param[in] hash Hash of message
*/
void
-handle_service_message (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvRoom *room,
+handle_service_message (struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_MESSENGER_SrvRoom *room,
const struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
#endif //GNUNET_SERVICE_MESSENGER_SERVICE_H
diff --git a/src/messenger/gnunet-service-messenger_tunnel.c b/src/messenger/gnunet-service-messenger_tunnel.c
index b9d063813..45c10c1af 100644
--- a/src/messenger/gnunet-service-messenger_tunnel.c
+++ b/src/messenger/gnunet-service-messenger_tunnel.c
@@ -33,7 +33,8 @@
#include "messenger_api_util.h"
struct GNUNET_MESSENGER_SrvTunnel*
-create_tunnel (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_PeerIdentity *door)
+create_tunnel (struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_PeerIdentity *door)
{
GNUNET_assert((room) && (door));
@@ -72,7 +73,8 @@ destroy_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel)
}
void
-bind_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_CADET_Channel *channel)
+bind_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ struct GNUNET_CADET_Channel *channel)
{
GNUNET_assert(tunnel);
@@ -83,10 +85,12 @@ bind_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_CADET_Chan
}
extern void
-callback_room_disconnect (struct GNUNET_MESSENGER_SrvRoom *room, void *cls);
+callback_room_disconnect (struct GNUNET_MESSENGER_SrvRoom *room,
+ void *cls);
void
-callback_tunnel_disconnect (void *cls, const struct GNUNET_CADET_Channel *channel)
+callback_tunnel_disconnect (void *cls,
+ const struct GNUNET_CADET_Channel *channel)
{
struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
@@ -99,11 +103,14 @@ callback_tunnel_disconnect (void *cls, const struct GNUNET_CADET_Channel *channe
}
extern int
-callback_verify_room_message (struct GNUNET_MESSENGER_SrvRoom *room, void *cls,
- struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash);
+callback_verify_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ void *cls,
+ struct GNUNET_MESSENGER_Message *message,
+ struct GNUNET_HashCode *hash);
int
-check_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header)
+check_tunnel_message (void *cls,
+ const struct GNUNET_MessageHeader *header)
{
struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
@@ -115,7 +122,7 @@ check_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header)
struct GNUNET_MESSENGER_Message message;
- if (length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN))
+ if (length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_YES))
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Tunnel error: Message too short! (%d)\n", length);
return GNUNET_SYSERR;
@@ -137,14 +144,18 @@ check_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header)
extern int
update_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+ struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
extern void
-callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
static void
-update_tunnel_last_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_HashCode *hash)
+update_tunnel_last_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ const struct GNUNET_HashCode *hash)
{
struct GNUNET_MESSENGER_OperationStore *operation_store = get_room_operation_store(tunnel->room);
@@ -165,6 +176,9 @@ handle_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header)
{
struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
+ if (!tunnel)
+ return;
+
const uint16_t length = ntohs (header->size) - sizeof(*header);
const char *buffer = (const char*) &header[1];
@@ -179,9 +193,6 @@ handle_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header)
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Got message of kind: %s!\n",
GNUNET_MESSENGER_name_of_kind(message.header.kind));
- if (!tunnel)
- return;
-
const int new_message = update_room_message (
tunnel->room, copy_message (&message), &hash
);
@@ -215,6 +226,8 @@ handle_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header)
}
receive_done:
+ cleanup_message(&message);
+
GNUNET_CADET_receive_done (tunnel->channel);
}
@@ -281,7 +294,8 @@ callback_tunnel_sent (void *cls)
}
void
-send_tunnel_envelope (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MQ_Envelope *env,
+send_tunnel_envelope (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ struct GNUNET_MQ_Envelope *env,
const struct GNUNET_HashCode *hash)
{
GNUNET_assert((tunnel) && (env) && (hash));
@@ -299,7 +313,9 @@ send_tunnel_envelope (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_M
}
int
-send_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, void *handle, struct GNUNET_MESSENGER_Message *message)
+send_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ void *handle,
+ struct GNUNET_MESSENGER_Message *message)
{
GNUNET_assert((tunnel) && (handle));
@@ -325,7 +341,8 @@ send_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, void *handle, st
}
void
-forward_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message,
+forward_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ const struct GNUNET_MESSENGER_Message *message,
const struct GNUNET_HashCode *hash)
{
GNUNET_assert((tunnel) && (message) && (hash));
@@ -353,7 +370,8 @@ get_tunnel_peer_message (const struct GNUNET_MESSENGER_SrvTunnel *tunnel)
}
void
-get_tunnel_peer_identity (const struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_PeerIdentity *peer)
+get_tunnel_peer_identity (const struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ struct GNUNET_PeerIdentity *peer)
{
GNUNET_assert(tunnel);
@@ -369,7 +387,8 @@ get_tunnel_messenger_version (const struct GNUNET_MESSENGER_SrvTunnel *tunnel)
}
int
-update_tunnel_messenger_version (struct GNUNET_MESSENGER_SrvTunnel *tunnel, uint32_t version)
+update_tunnel_messenger_version (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ uint32_t version)
{
GNUNET_assert(tunnel);
diff --git a/src/messenger/gnunet-service-messenger_tunnel.h b/src/messenger/gnunet-service-messenger_tunnel.h
index 96d98546d..7bd749281 100644
--- a/src/messenger/gnunet-service-messenger_tunnel.h
+++ b/src/messenger/gnunet-service-messenger_tunnel.h
@@ -55,7 +55,8 @@ struct GNUNET_MESSENGER_SrvTunnel
* @return New tunnel
*/
struct GNUNET_MESSENGER_SrvTunnel*
-create_tunnel (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_PeerIdentity *door);
+create_tunnel (struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_PeerIdentity *door);
/**
* Destroys a <i>tunnel</i> and frees its memory fully.
@@ -73,7 +74,8 @@ destroy_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel);
* @param[in/out] channel CADET channel
*/
void
-bind_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_CADET_Channel *channel);
+bind_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ struct GNUNET_CADET_Channel *channel);
/**
* Tries to connect a <i>tunnel</i> by creating a new CADET channel and binding it.
@@ -112,7 +114,8 @@ is_tunnel_connected (const struct GNUNET_MESSENGER_SrvTunnel *tunnel);
* @param[in] hash Hash of message
*/
void
-send_tunnel_envelope (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MQ_Envelope *env,
+send_tunnel_envelope (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ struct GNUNET_MQ_Envelope *env,
const struct GNUNET_HashCode *hash);
/**
@@ -126,7 +129,9 @@ send_tunnel_envelope (struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_M
* @return #GNUNET_YES on success, GNUNET_NO otherwise
*/
int
-send_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, void *handle, struct GNUNET_MESSENGER_Message *message);
+send_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ void *handle,
+ struct GNUNET_MESSENGER_Message *message);
/**
* Forwards a given <i>message</i> with a known <i>hash</i> through a <i>tunnel</i>.
@@ -136,7 +141,8 @@ send_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, void *handle, st
* @param[in] hash Hash of message
*/
void
-forward_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message,
+forward_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ const struct GNUNET_MESSENGER_Message *message,
const struct GNUNET_HashCode *hash);
/**
@@ -158,7 +164,8 @@ get_tunnel_peer_message (const struct GNUNET_MESSENGER_SrvTunnel *tunnel);
* @param[out] peer Peer identity
*/
void
-get_tunnel_peer_identity (const struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_PeerIdentity *peer);
+get_tunnel_peer_identity (const struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ struct GNUNET_PeerIdentity *peer);
/**
* Returns the current messenger version the peer connected via a given <i>tunnel</i>
@@ -181,6 +188,7 @@ get_tunnel_messenger_version (const struct GNUNET_MESSENGER_SrvTunnel *tunnel);
* @param[in] version Version of messenger
*/
int
-update_tunnel_messenger_version (struct GNUNET_MESSENGER_SrvTunnel *tunnel, uint32_t version);
+update_tunnel_messenger_version (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ uint32_t version);
#endif //GNUNET_SERVICE_MESSENGER_TUNNEL_H
diff --git a/src/messenger/messenger.conf.in b/src/messenger/messenger.conf.in
index 59e11b166..6b54550ea 100644
--- a/src/messenger/messenger.conf.in
+++ b/src/messenger/messenger.conf.in
@@ -1,5 +1,6 @@
[messenger]
START_ON_DEMAND = YES
+RUN_PER_USER = YES
PORT = 2097
HOSTNAME = localhost
BINARY = gnunet-service-messenger
diff --git a/src/messenger/messenger_api.c b/src/messenger/messenger_api.c
index f7c73f769..a37b1b10b 100644
--- a/src/messenger/messenger_api.c
+++ b/src/messenger/messenger_api.c
@@ -70,14 +70,16 @@ GNUNET_MESSENGER_name_of_kind (enum GNUNET_MESSENGER_MessageKind kind)
}
static int
-check_get_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
+check_get_name (void *cls,
+ const struct GNUNET_MESSENGER_NameMessage *msg)
{
GNUNET_MQ_check_zero_termination(msg);
return GNUNET_OK;
}
static void
-handle_get_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
+handle_get_name (void *cls,
+ const struct GNUNET_MESSENGER_NameMessage *msg)
{
struct GNUNET_MESSENGER_Handle *handle = cls;
@@ -89,7 +91,8 @@ handle_get_name (void *cls, const struct GNUNET_MESSENGER_NameMessage *msg)
}
static int
-check_get_key (void *cls, const struct GNUNET_MESSENGER_KeyMessage *msg)
+check_get_key (void *cls,
+ const struct GNUNET_MESSENGER_KeyMessage *msg)
{
const uint16_t full_length = ntohs (msg->header.size);
@@ -107,7 +110,8 @@ check_get_key (void *cls, const struct GNUNET_MESSENGER_KeyMessage *msg)
}
static void
-handle_get_key (void *cls, const struct GNUNET_MESSENGER_KeyMessage *msg)
+handle_get_key (void *cls,
+ const struct GNUNET_MESSENGER_KeyMessage *msg)
{
struct GNUNET_MESSENGER_Handle *handle = cls;
@@ -129,7 +133,8 @@ handle_get_key (void *cls, const struct GNUNET_MESSENGER_KeyMessage *msg)
}
static void
-handle_member_id (void *cls, const struct GNUNET_MESSENGER_MemberMessage *msg)
+handle_member_id (void *cls,
+ const struct GNUNET_MESSENGER_MemberMessage *msg)
{
struct GNUNET_MESSENGER_Handle *handle = cls;
@@ -150,7 +155,8 @@ handle_member_id (void *cls, const struct GNUNET_MESSENGER_MemberMessage *msg)
}
static void
-handle_room_open (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
+handle_room_open (void *cls,
+ const struct GNUNET_MESSENGER_RoomMessage *msg)
{
struct GNUNET_MESSENGER_Handle *handle = cls;
@@ -162,7 +168,8 @@ handle_room_open (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
}
static void
-handle_room_entry (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
+handle_room_entry (void *cls,
+ const struct GNUNET_MESSENGER_RoomMessage *msg)
{
struct GNUNET_MESSENGER_Handle *handle = cls;
@@ -175,7 +182,8 @@ handle_room_entry (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
}
static void
-handle_room_close (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
+handle_room_close (void *cls,
+ const struct GNUNET_MESSENGER_RoomMessage *msg)
{
struct GNUNET_MESSENGER_Handle *handle = cls;
@@ -187,7 +195,8 @@ handle_room_close (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
}
static int
-check_recv_message (void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg)
+check_recv_message (void *cls,
+ const struct GNUNET_MESSENGER_RecvMessage *msg)
{
const uint16_t full_length = ntohs (msg->header.size);
@@ -199,17 +208,19 @@ check_recv_message (void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg)
struct GNUNET_MESSENGER_Message message;
- if (length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN))
+ if (length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_YES))
return GNUNET_NO;
if (GNUNET_YES != decode_message (&message, length, buffer, GNUNET_YES, NULL))
return GNUNET_NO;
+ cleanup_message(&message);
return GNUNET_OK;
}
static void
-handle_recv_message (void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg)
+handle_recv_message (void *cls,
+ const struct GNUNET_MESSENGER_RecvMessage *msg)
{
struct GNUNET_MESSENGER_Handle *handle = cls;
@@ -244,18 +255,23 @@ handle_recv_message (void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg)
handle_room_message (room, contact, &message, hash);
+ const struct GNUNET_MESSENGER_Message *stored_message = get_room_message(room, hash);
+
if (handle->msg_callback)
- handle->msg_callback (handle->msg_cls, room, contact, &message, hash, flags);
+ handle->msg_callback (handle->msg_cls, room, contact, stored_message, hash, flags);
}
else
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Room not found\n");
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Unknown room for this client: %s\n", GNUNET_h2s (key));
+
+ cleanup_message(&message);
}
static void
reconnect (struct GNUNET_MESSENGER_Handle *handle);
static void
-send_open_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
+send_open_room (struct GNUNET_MESSENGER_Handle *handle,
+ struct GNUNET_MESSENGER_Room *room)
{
struct GNUNET_MESSENGER_RoomMessage *msg;
struct GNUNET_MQ_Envelope *env;
@@ -266,7 +282,8 @@ send_open_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_
}
static void
-send_enter_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room,
+send_enter_room (struct GNUNET_MESSENGER_Handle *handle,
+ struct GNUNET_MESSENGER_Room *room,
const struct GNUNET_PeerIdentity *door)
{
struct GNUNET_MESSENGER_RoomMessage *msg;
@@ -279,7 +296,8 @@ send_enter_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER
}
static void
-send_close_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
+send_close_room (struct GNUNET_MESSENGER_Handle *handle,
+ struct GNUNET_MESSENGER_Room *room)
{
struct GNUNET_MESSENGER_RoomMessage *msg;
struct GNUNET_MQ_Envelope *env;
@@ -290,7 +308,9 @@ send_close_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER
}
static int
-iterate_reset_room (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_reset_room (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_Handle *handle = cls;
struct GNUNET_MESSENGER_Room *room = value;
@@ -329,7 +349,9 @@ callback_reconnect (void *cls)
}
static int
-iterate_close_room (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_close_room (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_Handle *handle = cls;
struct GNUNET_MESSENGER_Room *room = value;
@@ -340,7 +362,8 @@ iterate_close_room (void *cls, const struct GNUNET_HashCode *key, void *value)
}
static void
-callback_mq_error (void *cls, enum GNUNET_MQ_Error error)
+callback_mq_error (void *cls,
+ enum GNUNET_MQ_Error error)
{
struct GNUNET_MESSENGER_Handle *handle = cls;
@@ -402,9 +425,12 @@ reconnect (struct GNUNET_MESSENGER_Handle *handle)
}
struct GNUNET_MESSENGER_Handle*
-GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name,
- GNUNET_MESSENGER_IdentityCallback identity_callback, void *identity_cls,
- GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls)
+GNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *name,
+ GNUNET_MESSENGER_IdentityCallback identity_callback,
+ void *identity_cls,
+ GNUNET_MESSENGER_MessageCallback msg_callback,
+ void *msg_cls)
{
struct GNUNET_MESSENGER_Handle *handle = create_handle (cfg, identity_callback, identity_cls, msg_callback, msg_cls);
@@ -475,7 +501,8 @@ GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle)
}
int
-GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, const char *name)
+GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle,
+ const char *name)
{
if (!handle)
return GNUNET_SYSERR;
@@ -517,7 +544,8 @@ GNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle)
}
struct GNUNET_MESSENGER_Room*
-GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
+GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_HashCode *key)
{
if ((!handle) || (!key))
return NULL;
@@ -541,7 +569,8 @@ GNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, const struct
}
struct GNUNET_MESSENGER_Room*
-GNUNET_MESSENGER_enter_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door,
+GNUNET_MESSENGER_enter_room (struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_PeerIdentity *door,
const struct GNUNET_HashCode *key)
{
if ((!handle) || (!door) || (!key))
@@ -583,7 +612,9 @@ struct GNUNET_MESSENGER_RoomFind
};
static int
-iterate_find_room (void* cls, const struct GNUNET_HashCode *key, void *value)
+iterate_find_room (void* cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_RoomFind *find = cls;
struct GNUNET_MESSENGER_Room *room = value;
@@ -602,8 +633,10 @@ iterate_find_room (void* cls, const struct GNUNET_HashCode *key, void *value)
}
int
-GNUNET_MESSENGER_find_rooms (const struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_MESSENGER_Contact *contact,
- GNUNET_MESSENGER_MemberCallback callback, void *cls)
+GNUNET_MESSENGER_find_rooms (const struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_MESSENGER_Contact *contact,
+ GNUNET_MESSENGER_MemberCallback callback,
+ void *cls)
{
if (!handle)
return GNUNET_SYSERR;
@@ -628,7 +661,8 @@ GNUNET_MESSENGER_room_get_key (const struct GNUNET_MESSENGER_Room *room)
}
const struct GNUNET_MESSENGER_Contact*
-GNUNET_MESSENGER_get_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
+GNUNET_MESSENGER_get_sender (const struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_HashCode *hash)
{
if ((!room) || (!hash))
return NULL;
@@ -655,7 +689,8 @@ GNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact
}
void
-GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message,
+GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_MESSENGER_Message *message,
const struct GNUNET_MESSENGER_Contact *contact)
{
if ((!room) || (!message))
@@ -723,7 +758,8 @@ GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, const struct
}
const struct GNUNET_MESSENGER_Message*
-GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
+GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_HashCode *hash)
{
if ((!room) || (!hash))
return NULL;
@@ -745,7 +781,8 @@ GNUNET_MESSENGER_get_message (const struct GNUNET_MESSENGER_Room *room, const st
}
int
-GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback,
+GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room,
+ GNUNET_MESSENGER_MemberCallback callback,
void *cls)
{
if (!room)
diff --git a/src/messenger/messenger_api_contact.c b/src/messenger/messenger_api_contact.c
index 04e1f60c1..cbca17640 100644
--- a/src/messenger/messenger_api_contact.c
+++ b/src/messenger/messenger_api_contact.c
@@ -60,7 +60,8 @@ get_contact_name (const struct GNUNET_MESSENGER_Contact *contact)
}
void
-set_contact_name (struct GNUNET_MESSENGER_Contact *contact, const char *name)
+set_contact_name (struct GNUNET_MESSENGER_Contact *contact,
+ const char *name)
{
GNUNET_assert(contact);
@@ -98,7 +99,8 @@ decrease_contact_rc (struct GNUNET_MESSENGER_Contact *contact)
}
void
-get_context_from_member (const struct GNUNET_HashCode *key, const struct GNUNET_ShortHashCode *id,
+get_context_from_member (const struct GNUNET_HashCode *key,
+ const struct GNUNET_ShortHashCode *id,
struct GNUNET_HashCode *context)
{
GNUNET_assert((key) && (id) && (context));
diff --git a/src/messenger/messenger_api_contact.h b/src/messenger/messenger_api_contact.h
index e94d1fcd0..b5410f998 100644
--- a/src/messenger/messenger_api_contact.h
+++ b/src/messenger/messenger_api_contact.h
@@ -71,7 +71,8 @@ get_contact_name (const struct GNUNET_MESSENGER_Contact *contact);
* @param[in] name Name
*/
void
-set_contact_name (struct GNUNET_MESSENGER_Contact *contact, const char *name);
+set_contact_name (struct GNUNET_MESSENGER_Contact *contact,
+ const char *name);
/**
* Returns the public key of a given <i>contact</i>.
@@ -108,7 +109,8 @@ decrease_contact_rc (struct GNUNET_MESSENGER_Contact *contact);
* @param[out] hash Member context
*/
void
-get_context_from_member (const struct GNUNET_HashCode *key, const struct GNUNET_ShortHashCode *id,
+get_context_from_member (const struct GNUNET_HashCode *key,
+ const struct GNUNET_ShortHashCode *id,
struct GNUNET_HashCode *context);
#endif //GNUNET_MESSENGER_API_CONTACT_H
diff --git a/src/messenger/messenger_api_contact_store.c b/src/messenger/messenger_api_contact_store.c
index 6a517c2e0..1c10a8fbf 100644
--- a/src/messenger/messenger_api_contact_store.c
+++ b/src/messenger/messenger_api_contact_store.c
@@ -38,7 +38,9 @@ init_contact_store (struct GNUNET_MESSENGER_ContactStore *store)
}
static int
-iterate_destroy_contacts (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_destroy_contacts (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_Contact *contact = value;
destroy_contact (contact);
@@ -58,7 +60,8 @@ clear_contact_store (struct GNUNET_MESSENGER_ContactStore *store)
}
static struct GNUNET_CONTAINER_MultiHashMap*
-select_store_contact_map (struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context,
+select_store_contact_map (struct GNUNET_MESSENGER_ContactStore *store,
+ const struct GNUNET_HashCode *context,
struct GNUNET_HashCode *hash)
{
const struct GNUNET_IDENTITY_PublicKey *anonymous = get_anonymous_public_key ();
@@ -76,7 +79,8 @@ select_store_contact_map (struct GNUNET_MESSENGER_ContactStore *store, const str
}
struct GNUNET_MESSENGER_Contact*
-get_store_contact_raw (struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context,
+get_store_contact_raw (struct GNUNET_MESSENGER_ContactStore *store,
+ const struct GNUNET_HashCode *context,
const struct GNUNET_HashCode *key_hash)
{
GNUNET_assert ((store) && (store->contacts) && (context) && (key_hash));
@@ -92,7 +96,8 @@ get_store_contact_raw (struct GNUNET_MESSENGER_ContactStore *store, const struct
}
struct GNUNET_MESSENGER_Contact*
-get_store_contact (struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context,
+get_store_contact (struct GNUNET_MESSENGER_ContactStore *store,
+ const struct GNUNET_HashCode *context,
const struct GNUNET_IDENTITY_PublicKey *pubkey)
{
GNUNET_assert ((store) && (store->contacts) && (context) && (pubkey));
@@ -130,8 +135,10 @@ get_store_contact (struct GNUNET_MESSENGER_ContactStore *store, const struct GNU
}
void
-update_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET_MESSENGER_Contact* contact,
- const struct GNUNET_HashCode *context, const struct GNUNET_HashCode *next_context,
+update_store_contact (struct GNUNET_MESSENGER_ContactStore *store,
+ struct GNUNET_MESSENGER_Contact* contact,
+ const struct GNUNET_HashCode *context,
+ const struct GNUNET_HashCode *next_context,
const struct GNUNET_IDENTITY_PublicKey *pubkey)
{
GNUNET_assert ((store) && (store->contacts) && (contact) && (pubkey));
@@ -163,7 +170,8 @@ update_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET
}
void
-remove_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET_MESSENGER_Contact* contact,
+remove_store_contact (struct GNUNET_MESSENGER_ContactStore *store,
+ struct GNUNET_MESSENGER_Contact* contact,
const struct GNUNET_HashCode *context)
{
GNUNET_assert ((store) && (store->contacts) && (contact));
diff --git a/src/messenger/messenger_api_contact_store.h b/src/messenger/messenger_api_contact_store.h
index f2dad9f84..bdab2ceeb 100644
--- a/src/messenger/messenger_api_contact_store.h
+++ b/src/messenger/messenger_api_contact_store.h
@@ -68,7 +68,8 @@ clear_contact_store (struct GNUNET_MESSENGER_ContactStore *store);
* @param[in] key_hash Hash of public key
*/
struct GNUNET_MESSENGER_Contact*
-get_store_contact_raw (struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context,
+get_store_contact_raw (struct GNUNET_MESSENGER_ContactStore *store,
+ const struct GNUNET_HashCode *context,
const struct GNUNET_HashCode *key_hash);
/**
@@ -87,7 +88,8 @@ get_store_contact_raw (struct GNUNET_MESSENGER_ContactStore *store, const struct
* @param[in] pubkey Public key of EGO
*/
struct GNUNET_MESSENGER_Contact*
-get_store_contact (struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context,
+get_store_contact (struct GNUNET_MESSENGER_ContactStore *store,
+ const struct GNUNET_HashCode *context,
const struct GNUNET_IDENTITY_PublicKey *pubkey);
/**
@@ -103,8 +105,10 @@ get_store_contact (struct GNUNET_MESSENGER_ContactStore *store, const struct GNU
* @param[in] pubkey Public key of EGO
*/
void
-update_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET_MESSENGER_Contact* contact,
- const struct GNUNET_HashCode *context, const struct GNUNET_HashCode *next_context,
+update_store_contact (struct GNUNET_MESSENGER_ContactStore *store,
+ struct GNUNET_MESSENGER_Contact* contact,
+ const struct GNUNET_HashCode *context,
+ const struct GNUNET_HashCode *next_context,
const struct GNUNET_IDENTITY_PublicKey *pubkey);
/**
@@ -116,7 +120,8 @@ update_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET
* @param[in] context Member context
*/
void
-remove_store_contact (struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET_MESSENGER_Contact* contact,
+remove_store_contact (struct GNUNET_MESSENGER_ContactStore *store,
+ struct GNUNET_MESSENGER_Contact* contact,
const struct GNUNET_HashCode *context);
#endif //GNUNET_MESSENGER_API_CONTACT_STORE_H
diff --git a/src/messenger/messenger_api_handle.c b/src/messenger/messenger_api_handle.c
index ab57f82cc..242389040 100644
--- a/src/messenger/messenger_api_handle.c
+++ b/src/messenger/messenger_api_handle.c
@@ -28,8 +28,11 @@
#include "messenger_api_util.h"
struct GNUNET_MESSENGER_Handle*
-create_handle (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_MESSENGER_IdentityCallback identity_callback,
- void *identity_cls, GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls)
+create_handle (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ GNUNET_MESSENGER_IdentityCallback identity_callback,
+ void *identity_cls,
+ GNUNET_MESSENGER_MessageCallback msg_callback,
+ void *msg_cls)
{
GNUNET_assert(cfg);
@@ -58,7 +61,9 @@ create_handle (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_MESSENGER_I
}
static int
-iterate_destroy_room (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_destroy_room (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_Room *room = value;
@@ -93,11 +98,12 @@ destroy_handle (struct GNUNET_MESSENGER_Handle *handle)
clear_contact_store(get_handle_contact_store(handle));
- GNUNET_free(handle->name);
+ GNUNET_free(handle);
}
void
-set_handle_name (struct GNUNET_MESSENGER_Handle *handle, const char *name)
+set_handle_name (struct GNUNET_MESSENGER_Handle *handle,
+ const char *name)
{
GNUNET_assert(handle);
@@ -116,7 +122,8 @@ get_handle_name (const struct GNUNET_MESSENGER_Handle *handle)
}
void
-set_handle_key (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_IDENTITY_PublicKey *pubkey)
+set_handle_key (struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_IDENTITY_PublicKey *pubkey)
{
GNUNET_assert(handle);
@@ -146,7 +153,8 @@ get_handle_contact_store (struct GNUNET_MESSENGER_Handle *handle)
}
struct GNUNET_MESSENGER_Contact*
-get_handle_contact (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
+get_handle_contact (struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((handle) && (key));
@@ -162,7 +170,8 @@ get_handle_contact (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_
}
void
-open_handle_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
+open_handle_room (struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((handle) && (key));
@@ -173,7 +182,8 @@ open_handle_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_Ha
}
void
-entry_handle_room_at (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door,
+entry_handle_room_at (struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_PeerIdentity *door,
const struct GNUNET_HashCode *key)
{
GNUNET_assert((handle) && (door) && (key));
@@ -185,7 +195,8 @@ entry_handle_room_at (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNE
}
void
-close_handle_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
+close_handle_room (struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((handle) && (key));
diff --git a/src/messenger/messenger_api_handle.h b/src/messenger/messenger_api_handle.h
index e6ca474f2..6a43f13a6 100644
--- a/src/messenger/messenger_api_handle.h
+++ b/src/messenger/messenger_api_handle.h
@@ -71,8 +71,11 @@ struct GNUNET_MESSENGER_Handle
* @return New handle
*/
struct GNUNET_MESSENGER_Handle*
-create_handle (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_MESSENGER_IdentityCallback identity_callback,
- void *identity_cls, GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls);
+create_handle (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ GNUNET_MESSENGER_IdentityCallback identity_callback,
+ void *identity_cls,
+ GNUNET_MESSENGER_MessageCallback msg_callback,
+ void *msg_cls);
/**
* Destroys a <i>handle</i> and frees its memory fully from the client API.
@@ -89,7 +92,8 @@ destroy_handle (struct GNUNET_MESSENGER_Handle *handle);
* @param[in] name New name
*/
void
-set_handle_name (struct GNUNET_MESSENGER_Handle *handle, const char *name);
+set_handle_name (struct GNUNET_MESSENGER_Handle *handle,
+ const char *name);
/**
* Returns the current name of a given <i>handle</i> or NULL if no valid name was assigned yet.
@@ -107,7 +111,8 @@ get_handle_name (const struct GNUNET_MESSENGER_Handle *handle);
* @param[in] pubkey Public key
*/
void
-set_handle_key (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_IDENTITY_PublicKey *pubkey);
+set_handle_key (struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_IDENTITY_PublicKey *pubkey);
/**
* Returns the public key of a given <i>handle</i>.
@@ -136,7 +141,8 @@ get_handle_contact_store (struct GNUNET_MESSENGER_Handle *handle);
* @return Contact
*/
struct GNUNET_MESSENGER_Contact*
-get_handle_contact (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key);
+get_handle_contact (struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_HashCode *key);
/**
* Marks a room known to a <i>handle</i> identified by a given <i>key</i> as open.
@@ -145,7 +151,8 @@ get_handle_contact (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_
* @param[in] key Key of room
*/
void
-open_handle_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key);
+open_handle_room (struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_HashCode *key);
/**
* Adds a tunnel for a room known to a <i>handle</i> identified by a given <i>key</i> to a
@@ -156,7 +163,8 @@ open_handle_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_Ha
* @param[in] key Key of room
*/
void
-entry_handle_room_at (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door,
+entry_handle_room_at (struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_PeerIdentity *door,
const struct GNUNET_HashCode *key);
/**
@@ -166,6 +174,7 @@ entry_handle_room_at (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNE
* @param[in] key Key of room
*/
void
-close_handle_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key);
+close_handle_room (struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_HashCode *key);
#endif //GNUNET_MESSENGER_API_HANDLE_H
diff --git a/src/messenger/messenger_api_list_tunnels.c b/src/messenger/messenger_api_list_tunnels.c
index 990e36878..7e77d8f2f 100644
--- a/src/messenger/messenger_api_list_tunnels.c
+++ b/src/messenger/messenger_api_list_tunnels.c
@@ -53,14 +53,16 @@ clear_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels)
}
static int
-compare_list_tunnels (void *cls, struct GNUNET_MESSENGER_ListTunnel *element0,
+compare_list_tunnels (void *cls,
+ struct GNUNET_MESSENGER_ListTunnel *element0,
struct GNUNET_MESSENGER_ListTunnel *element1)
{
return ((int) element0->peer) - ((int) element1->peer);
}
void
-add_to_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer)
+add_to_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
+ const struct GNUNET_PeerIdentity *peer)
{
GNUNET_assert((tunnels) && (peer));
@@ -73,7 +75,9 @@ add_to_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct
}
struct GNUNET_MESSENGER_ListTunnel*
-find_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer, size_t *index)
+find_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
+ const struct GNUNET_PeerIdentity *peer,
+ size_t *index)
{
GNUNET_assert((tunnels) && (peer));
@@ -98,7 +102,8 @@ find_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GN
}
int
-contains_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer)
+contains_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
+ const struct GNUNET_PeerIdentity *peer)
{
GNUNET_assert((tunnels) && (peer));
@@ -106,7 +111,8 @@ contains_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struc
}
struct GNUNET_MESSENGER_ListTunnel*
-remove_from_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, struct GNUNET_MESSENGER_ListTunnel *element)
+remove_from_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
+ struct GNUNET_MESSENGER_ListTunnel *element)
{
GNUNET_assert((tunnels) && (element));
@@ -120,7 +126,8 @@ remove_from_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, struct G
}
void
-load_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const char *path)
+load_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
+ const char *path)
{
GNUNET_assert((tunnels) && (path));
@@ -154,7 +161,8 @@ load_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const char *pat
}
void
-save_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const char *path)
+save_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
+ const char *path)
{
GNUNET_assert((tunnels) && (path));
diff --git a/src/messenger/messenger_api_list_tunnels.h b/src/messenger/messenger_api_list_tunnels.h
index c952da3c2..0e086ee5e 100644
--- a/src/messenger/messenger_api_list_tunnels.h
+++ b/src/messenger/messenger_api_list_tunnels.h
@@ -67,7 +67,8 @@ clear_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels);
* @param[in] peer Peer identity of tunnel
*/
void
-add_to_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer);
+add_to_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
+ const struct GNUNET_PeerIdentity *peer);
/**
* Searches linearly through the list of tunnels peer identities for matching a
@@ -85,7 +86,9 @@ add_to_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct
* @return Element in the list with matching peer identity
*/
struct GNUNET_MESSENGER_ListTunnel*
-find_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer, size_t *index);
+find_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
+ const struct GNUNET_PeerIdentity *peer,
+ size_t *index);
/**
* Tests linearly if the list of tunnels peer identities contains a specific
@@ -96,7 +99,8 @@ find_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GN
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
int
-contains_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer);
+contains_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
+ const struct GNUNET_PeerIdentity *peer);
/**
* Removes a specific <i>element</i> from the list of tunnels peer identities and returns
@@ -107,7 +111,8 @@ contains_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const struc
* @return Next element in the list
*/
struct GNUNET_MESSENGER_ListTunnel*
-remove_from_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, struct GNUNET_MESSENGER_ListTunnel *element);
+remove_from_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
+ struct GNUNET_MESSENGER_ListTunnel *element);
/**
* Loads the list of tunnels peer identities from a file under a given <i>path</i>.
@@ -116,7 +121,8 @@ remove_from_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, struct G
* @param[in] path Path of file
*/
void
-load_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const char *path);
+load_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
+ const char *path);
/**
* Saves the list of tunnels peer identities to a file under a given <i>path</i>.
@@ -125,6 +131,7 @@ load_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const char *pat
* @param[in] path Path of file
*/
void
-save_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels, const char *path);
+save_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
+ const char *path);
#endif //GNUNET_MESSENGER_API_LIST_TUNNELS_H
diff --git a/src/messenger/messenger_api_message.c b/src/messenger/messenger_api_message.c
index c7364d51c..496c98dbf 100644
--- a/src/messenger/messenger_api_message.c
+++ b/src/messenger/messenger_api_message.c
@@ -103,7 +103,8 @@ copy_message (const struct GNUNET_MESSENGER_Message *message)
}
static void
-destroy_message_body (enum GNUNET_MESSENGER_MessageKind kind, struct GNUNET_MESSENGER_MessageBody *body)
+destroy_message_body (enum GNUNET_MESSENGER_MessageKind kind,
+ struct GNUNET_MESSENGER_MessageBody *body)
{
switch (kind)
{
@@ -125,6 +126,14 @@ destroy_message_body (enum GNUNET_MESSENGER_MessageKind kind, struct GNUNET_MESS
}
void
+cleanup_message (struct GNUNET_MESSENGER_Message *message)
+{
+ GNUNET_assert(message);
+
+ destroy_message_body (message->header.kind, &(message->body));
+}
+
+void
destroy_message (struct GNUNET_MESSENGER_Message *message)
{
GNUNET_assert(message);
@@ -150,7 +159,8 @@ is_message_session_bound (const struct GNUNET_MESSENGER_Message *message)
}
static void
-fold_short_message (const struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_ShortMessage *shortened)
+fold_short_message (const struct GNUNET_MESSENGER_Message *message,
+ struct GNUNET_MESSENGER_ShortMessage *shortened)
{
shortened->kind = message->header.kind;
@@ -158,7 +168,8 @@ fold_short_message (const struct GNUNET_MESSENGER_Message *message, struct GNUNE
}
static void
-unfold_short_message (struct GNUNET_MESSENGER_ShortMessage *shortened, struct GNUNET_MESSENGER_Message *message)
+unfold_short_message (struct GNUNET_MESSENGER_ShortMessage *shortened,
+ struct GNUNET_MESSENGER_Message *message)
{
destroy_message_body (message->header.kind, &(message->body));
@@ -218,20 +229,26 @@ get_message_body_kind_size (enum GNUNET_MESSENGER_MessageKind kind)
typedef uint32_t kind_t;
uint16_t
-get_message_kind_size (enum GNUNET_MESSENGER_MessageKind kind)
+get_message_kind_size (enum GNUNET_MESSENGER_MessageKind kind,
+ int include_header)
{
uint16_t length = 0;
- length += member_size(struct GNUNET_MESSENGER_Message, header.timestamp);
- length += member_size(struct GNUNET_MESSENGER_Message, header.sender_id);
- length += member_size(struct GNUNET_MESSENGER_Message, header.previous);
+ if (GNUNET_YES == include_header)
+ {
+ length += member_size(struct GNUNET_MESSENGER_Message, header.timestamp);
+ length += member_size(struct GNUNET_MESSENGER_Message, header.sender_id);
+ length += member_size(struct GNUNET_MESSENGER_Message, header.previous);
+ }
+
length += sizeof(kind_t);
return length + get_message_body_kind_size (kind);
}
static uint16_t
-get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET_MESSENGER_MessageBody *body)
+get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind,
+ const struct GNUNET_MESSENGER_MessageBody *body)
{
uint16_t length = 0;
@@ -267,23 +284,24 @@ get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind, const struct GNUN
uint16_t
get_message_size (const struct GNUNET_MESSENGER_Message *message,
- int include_signature)
+ int include_header)
{
GNUNET_assert(message);
uint16_t length = 0;
- if (GNUNET_YES == include_signature)
+ if (GNUNET_YES == include_header)
length += GNUNET_IDENTITY_signature_get_length(&(message->header.signature));
- length += get_message_kind_size (message->header.kind);
+ length += get_message_kind_size (message->header.kind, include_header);
length += get_message_body_size (message->header.kind, &(message->body));
return length;
}
static uint16_t
-get_short_message_size (const struct GNUNET_MESSENGER_ShortMessage *message, int include_body)
+get_short_message_size (const struct GNUNET_MESSENGER_ShortMessage *message,
+ int include_body)
{
const uint16_t minimum_size = sizeof(struct GNUNET_HashCode) + sizeof(kind_t);
@@ -301,7 +319,7 @@ calc_usual_padding ()
uint16_t kind_size;
for (int i = 0; i <= GNUNET_MESSENGER_KIND_MAX; i++) {
- kind_size = get_message_kind_size ((enum GNUNET_MESSENGER_MessageKind) i);
+ kind_size = get_message_kind_size ((enum GNUNET_MESSENGER_MessageKind) i, GNUNET_YES);
if (kind_size > padding)
padding = kind_size;
@@ -370,8 +388,11 @@ calc_padded_length (uint16_t length)
} while (0)
static void
-encode_message_body (enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET_MESSENGER_MessageBody *body,
- uint16_t length, char *buffer, uint16_t offset)
+encode_message_body (enum GNUNET_MESSENGER_MessageKind kind,
+ const struct GNUNET_MESSENGER_MessageBody *body,
+ uint16_t length,
+ char *buffer,
+ uint16_t offset)
{
uint32_t version;
switch (kind)
@@ -445,28 +466,36 @@ encode_message_body (enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET
}
void
-encode_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer,
- int include_signature)
+encode_message (const struct GNUNET_MESSENGER_Message *message,
+ uint16_t length,
+ char *buffer,
+ int include_header)
{
GNUNET_assert((message) && (buffer));
uint16_t offset = 0;
- if (GNUNET_YES == include_signature)
+ if (GNUNET_YES == include_header)
encode_step_signature(buffer, offset, &(message->header.signature), length);
const kind_t kind = GNUNET_htobe32((kind_t) message->header.kind);
- encode_step(buffer, offset, &(message->header.timestamp));
- encode_step(buffer, offset, &(message->header.sender_id));
- encode_step(buffer, offset, &(message->header.previous));
+ if (GNUNET_YES == include_header)
+ {
+ encode_step(buffer, offset, &(message->header.timestamp));
+ encode_step(buffer, offset, &(message->header.sender_id));
+ encode_step(buffer, offset, &(message->header.previous));
+ }
+
encode_step(buffer, offset, &kind);
encode_message_body (message->header.kind, &(message->body), length, buffer, offset);
}
static void
-encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message, uint16_t length, char *buffer)
+encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message,
+ uint16_t length,
+ char *buffer)
{
struct GNUNET_HashCode hash;
uint16_t offset = sizeof(hash);
@@ -512,8 +541,11 @@ encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message, uint1
} while (0)
static uint16_t
-decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind, struct GNUNET_MESSENGER_MessageBody *body,
- uint16_t length, const char *buffer, uint16_t offset)
+decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind,
+ struct GNUNET_MESSENGER_MessageBody *body,
+ uint16_t length,
+ const char *buffer,
+ uint16_t offset)
{
uint16_t padding = 0;
@@ -593,14 +625,21 @@ decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind, struct GNUNET_MESS
}
int
-decode_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer,
- int include_signature, uint16_t *padding)
+decode_message (struct GNUNET_MESSENGER_Message *message,
+ uint16_t length,
+ const char *buffer,
+ int include_header,
+ uint16_t *padding)
{
- GNUNET_assert((message) && (buffer) && (length >= get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN)));
+ GNUNET_assert(
+ (message) &&
+ (buffer) &&
+ (length >= get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN, include_header))
+ );
uint16_t offset = 0;
- if (GNUNET_YES == include_signature)
+ if (GNUNET_YES == include_header)
{
ssize_t result = GNUNET_IDENTITY_read_signature_from_buffer(
&(message->header.signature), buffer, length - offset
@@ -614,19 +653,23 @@ decode_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, const
const uint16_t count = length - offset;
- if (count < get_message_kind_size (GNUNET_MESSENGER_KIND_UNKNOWN))
+ if (count < get_message_kind_size (GNUNET_MESSENGER_KIND_UNKNOWN, include_header))
return GNUNET_NO;
kind_t kind;
- decode_step(buffer, offset, &(message->header.timestamp));
- decode_step(buffer, offset, &(message->header.sender_id));
- decode_step(buffer, offset, &(message->header.previous));
+ if (GNUNET_YES == include_header)
+ {
+ decode_step(buffer, offset, &(message->header.timestamp));
+ decode_step(buffer, offset, &(message->header.sender_id));
+ decode_step(buffer, offset, &(message->header.previous));
+ }
+
decode_step(buffer, offset, &kind);
message->header.kind = (enum GNUNET_MESSENGER_MessageKind) GNUNET_be32toh(kind);
- if (count < get_message_kind_size (message->header.kind))
+ if (count < get_message_kind_size (message->header.kind, include_header))
return GNUNET_NO;
const uint16_t result = decode_message_body (&(message->header.kind), &(message->body), length, buffer, offset);
@@ -638,7 +681,9 @@ decode_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, const
}
static int
-decode_short_message (struct GNUNET_MESSENGER_ShortMessage *message, uint16_t length, const char *buffer)
+decode_short_message (struct GNUNET_MESSENGER_ShortMessage *message,
+ uint16_t length,
+ const char *buffer)
{
struct GNUNET_HashCode expected, hash;
uint16_t offset = sizeof(hash);
@@ -675,7 +720,9 @@ decode_short_message (struct GNUNET_MESSENGER_ShortMessage *message, uint16_t le
}
void
-hash_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer,
+hash_message (const struct GNUNET_MESSENGER_Message *message,
+ uint16_t length,
+ const char *buffer,
struct GNUNET_HashCode *hash)
{
GNUNET_assert((message) && (buffer) && (hash));
@@ -688,8 +735,11 @@ hash_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, c
}
void
-sign_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer,
- const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Ego *ego)
+sign_message (struct GNUNET_MESSENGER_Message *message,
+ uint16_t length,
+ char *buffer,
+ const struct GNUNET_HashCode *hash,
+ const struct GNUNET_MESSENGER_Ego *ego)
{
GNUNET_assert((message) && (buffer) && (hash) && (ego));
@@ -706,7 +756,8 @@ sign_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, char *b
}
int
-verify_message (const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash,
+verify_message (const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash,
const struct GNUNET_IDENTITY_PublicKey *key)
{
GNUNET_assert((message) && (hash) && (key));
@@ -726,7 +777,8 @@ verify_message (const struct GNUNET_MESSENGER_Message *message, const struct GNU
}
int
-encrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_IDENTITY_PublicKey *key)
+encrypt_message (struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_IDENTITY_PublicKey *key)
{
GNUNET_assert((message) && (key));
@@ -760,7 +812,8 @@ encrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_I
}
int
-decrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_IDENTITY_PrivateKey *key)
+decrypt_message (struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_IDENTITY_PrivateKey *key)
{
GNUNET_assert((message) && (key));
@@ -788,8 +841,10 @@ decrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_I
}
struct GNUNET_MQ_Envelope*
-pack_message (struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash,
- const struct GNUNET_MESSENGER_Ego *ego, int mode)
+pack_message (struct GNUNET_MESSENGER_Message *message,
+ struct GNUNET_HashCode *hash,
+ const struct GNUNET_MESSENGER_Ego *ego,
+ int mode)
{
GNUNET_assert(message);
diff --git a/src/messenger/messenger_api_message.h b/src/messenger/messenger_api_message.h
index 7ce30dc92..46c5cb024 100644
--- a/src/messenger/messenger_api_message.h
+++ b/src/messenger/messenger_api_message.h
@@ -62,6 +62,14 @@ struct GNUNET_MESSENGER_Message*
copy_message (const struct GNUNET_MESSENGER_Message *message);
/**
+ * Frees the messages body memory.
+ *
+ * @param[in/out] message Message
+ */
+void
+cleanup_message (struct GNUNET_MESSENGER_Message *message);
+
+/**
* Destroys a message and frees its memory fully.
*
* @param[in/out] message Message
@@ -82,21 +90,23 @@ is_message_session_bound (const struct GNUNET_MESSENGER_Message *message);
* Returns the minimal size in bytes to encode a message of a specific <i>kind</i>.
*
* @param[in] kind Kind of message
+ * @param[in] include_header Flag to include header
* @return Minimal size to encode
*/
uint16_t
-get_message_kind_size (enum GNUNET_MESSENGER_MessageKind kind);
+get_message_kind_size (enum GNUNET_MESSENGER_MessageKind kind,
+ int include_header);
/**
* Returns the exact size in bytes to encode a given <i>message</i>.
*
* @param[in] message Message
- * @param[in] encode_signature Flag to include signature
+ * @param[in] include_header Flag to include header
* @return Size to encode
*/
uint16_t
get_message_size (const struct GNUNET_MESSENGER_Message *message,
- int include_signature);
+ int include_header);
/**
* Encodes a given <i>message</i> into a <i>buffer</i> of a maximal <i>length</i> in bytes.
@@ -104,11 +114,13 @@ get_message_size (const struct GNUNET_MESSENGER_Message *message,
* @param[in] message Message
* @param[in] length Maximal length to encode
* @param[out] buffer Buffer
- * @param[in] encode_signature Flag to include signature
+ * @param[in] include_header Flag to include header
*/
void
-encode_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer,
- int include_signature);
+encode_message (const struct GNUNET_MESSENGER_Message *message,
+ uint16_t length,
+ char *buffer,
+ int include_header);
/**
* Decodes a <i>message</i> from a given <i>buffer</i> of a maximal <i>length</i> in bytes.
@@ -121,12 +133,16 @@ encode_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length,
* @param[out] message Message
* @param[in] length Maximal length to decode
* @param[in] buffer Buffer
+ * @param[in] include_header Flag to include header
* @param[out] padding Padding
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
int
-decode_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer,
- int include_signature, uint16_t *padding);
+decode_message (struct GNUNET_MESSENGER_Message *message,
+ uint16_t length,
+ const char *buffer,
+ int include_header,
+ uint16_t *padding);
/**
* Calculates a <i>hash</i> of a given <i>buffer</i> with a <i>length</i> in bytes
@@ -138,7 +154,9 @@ decode_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, const
* @param[out] hash Hash
*/
void
-hash_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer,
+hash_message (const struct GNUNET_MESSENGER_Message *message,
+ uint16_t length,
+ const char *buffer,
struct GNUNET_HashCode *hash);
/**
@@ -152,8 +170,11 @@ hash_message (const struct GNUNET_MESSENGER_Message *message, uint16_t length, c
* @param[in] ego EGO
*/
void
-sign_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer,
- const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Ego *ego);
+sign_message (struct GNUNET_MESSENGER_Message *message,
+ uint16_t length,
+ char *buffer,
+ const struct GNUNET_HashCode *hash,
+ const struct GNUNET_MESSENGER_Ego *ego);
/**
* Verifies the signature of a given <i>message</i> and its <i>hash</i> with a specific
@@ -166,7 +187,8 @@ sign_message (struct GNUNET_MESSENGER_Message *message, uint16_t length, char *b
* @return #GNUNET_OK on success, otherwise #GNUNET_SYSERR
*/
int
-verify_message (const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash,
+verify_message (const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash,
const struct GNUNET_IDENTITY_PublicKey *key);
/**
@@ -179,7 +201,8 @@ verify_message (const struct GNUNET_MESSENGER_Message *message, const struct GNU
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
int
-encrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_IDENTITY_PublicKey *key);
+encrypt_message (struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_IDENTITY_PublicKey *key);
/**
* Decrypts a private <i>message</i> using a given private <i>key</i> and replaces its body
@@ -191,7 +214,8 @@ encrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_I
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
int
-decrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_IDENTITY_PrivateKey *key);
+decrypt_message (struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_IDENTITY_PrivateKey *key);
#define GNUNET_MESSENGER_PACK_MODE_ENVELOPE 0x1
#define GNUNET_MESSENGER_PACK_MODE_UNKNOWN 0x0
@@ -209,8 +233,10 @@ decrypt_message (struct GNUNET_MESSENGER_Message *message, const struct GNUNET_I
* @return Envelope or NULL
*/
struct GNUNET_MQ_Envelope*
-pack_message (struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash,
- const struct GNUNET_MESSENGER_Ego *ego, int mode);
+pack_message (struct GNUNET_MESSENGER_Message *message,
+ struct GNUNET_HashCode *hash,
+ const struct GNUNET_MESSENGER_Ego *ego,
+ int mode);
/**
* Returns if a specific kind of message should be sent by a client. The function returns
diff --git a/src/messenger/messenger_api_room.c b/src/messenger/messenger_api_room.c
index 0d9237a2e..6e2d33f48 100644
--- a/src/messenger/messenger_api_room.c
+++ b/src/messenger/messenger_api_room.c
@@ -28,7 +28,8 @@
#include "messenger_api_handle.h"
struct GNUNET_MESSENGER_Room*
-create_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
+create_room (struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((handle) && (key));
@@ -49,7 +50,9 @@ create_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCod
}
static int
-iterate_destroy_message (void *cls, const struct GNUNET_HashCode *key, void *value)
+iterate_destroy_message (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_RoomMessageEntry *entry = value;
@@ -83,7 +86,8 @@ destroy_room (struct GNUNET_MESSENGER_Room *room)
}
const struct GNUNET_MESSENGER_Message*
-get_room_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
+get_room_message (const struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_HashCode *hash)
{
GNUNET_assert((room) && (hash));
@@ -95,7 +99,8 @@ get_room_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_
}
struct GNUNET_MESSENGER_Contact*
-get_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
+get_room_sender (const struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_HashCode *hash)
{
GNUNET_assert((room) && (hash));
@@ -107,8 +112,10 @@ get_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_H
}
static struct GNUNET_MESSENGER_Contact*
-handle_join_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+handle_join_message (struct GNUNET_MESSENGER_Room *room,
+ struct GNUNET_MESSENGER_Contact *sender,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
if (!sender)
{
@@ -129,8 +136,10 @@ handle_join_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER
}
static void
-handle_leave_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+handle_leave_message (struct GNUNET_MESSENGER_Room *room,
+ struct GNUNET_MESSENGER_Contact *sender,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
if ((!sender) ||
(GNUNET_YES != GNUNET_CONTAINER_multishortmap_remove(room->members, &(message->header.sender_id), sender)))
@@ -144,8 +153,10 @@ handle_leave_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGE
}
static void
-handle_name_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+handle_name_message (struct GNUNET_MESSENGER_Room *room,
+ struct GNUNET_MESSENGER_Contact *sender,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
if (!sender)
return;
@@ -154,8 +165,10 @@ handle_name_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER
}
static void
-handle_key_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+handle_key_message (struct GNUNET_MESSENGER_Room *room,
+ struct GNUNET_MESSENGER_Contact *sender,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
if (!sender)
return;
@@ -169,8 +182,10 @@ handle_key_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_
}
static void
-handle_id_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+handle_id_message (struct GNUNET_MESSENGER_Room *room,
+ struct GNUNET_MESSENGER_Contact *sender,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
if ((!sender) ||
(GNUNET_YES != GNUNET_CONTAINER_multishortmap_remove(room->members, &(message->header.sender_id), sender)) ||
@@ -188,8 +203,10 @@ handle_id_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_C
}
static void
-handle_miss_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+handle_miss_message (struct GNUNET_MESSENGER_Room *room,
+ struct GNUNET_MESSENGER_Contact *sender,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
if ((room->contact_id) && (0 == GNUNET_memcmp(&(message->header.sender_id), room->contact_id)))
{
@@ -201,8 +218,10 @@ handle_miss_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER
}
static void
-handle_delete_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+handle_delete_message (struct GNUNET_MESSENGER_Room *room,
+ struct GNUNET_MESSENGER_Contact *sender,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
struct GNUNET_MESSENGER_RoomMessageEntry *entry = GNUNET_CONTAINER_multihashmap_get (
room->messages, &(message->body.deletion.hash)
@@ -217,8 +236,10 @@ handle_delete_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENG
}
struct GNUNET_MESSENGER_Contact*
-handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
+handle_room_message (struct GNUNET_MESSENGER_Room *room,
+ struct GNUNET_MESSENGER_Contact *sender,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
if (GNUNET_NO != GNUNET_CONTAINER_multihashmap_contains (room->messages, hash))
return sender;
@@ -276,7 +297,9 @@ struct GNUNET_MESSENGER_MemberCall
};
static int
-iterate_local_members (void* cls, const struct GNUNET_ShortHashCode *key, void *value)
+iterate_local_members (void* cls,
+ const struct GNUNET_ShortHashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_MemberCall *call = cls;
struct GNUNET_MESSENGER_Contact *contact = value;
@@ -285,7 +308,8 @@ iterate_local_members (void* cls, const struct GNUNET_ShortHashCode *key, void *
}
int
-iterate_room_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback,
+iterate_room_members (struct GNUNET_MESSENGER_Room *room,
+ GNUNET_MESSENGER_MemberCallback callback,
void* cls)
{
GNUNET_assert(room);
@@ -311,7 +335,9 @@ struct GNUNET_MESSENGER_MemberFind
};
static int
-iterate_find_member (void* cls, const struct GNUNET_ShortHashCode *key, void *value)
+iterate_find_member (void* cls,
+ const struct GNUNET_ShortHashCode *key,
+ void *value)
{
struct GNUNET_MESSENGER_MemberFind *find = cls;
struct GNUNET_MESSENGER_Contact *contact = value;
@@ -326,7 +352,8 @@ iterate_find_member (void* cls, const struct GNUNET_ShortHashCode *key, void *va
}
int
-find_room_member (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
+find_room_member (const struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_MESSENGER_Contact *contact)
{
GNUNET_assert(room);
diff --git a/src/messenger/messenger_api_room.h b/src/messenger/messenger_api_room.h
index 634052272..320312f0c 100644
--- a/src/messenger/messenger_api_room.h
+++ b/src/messenger/messenger_api_room.h
@@ -64,7 +64,8 @@ struct GNUNET_MESSENGER_Room
* @return New room
*/
struct GNUNET_MESSENGER_Room*
-create_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key);
+create_room (struct GNUNET_MESSENGER_Handle *handle,
+ const struct GNUNET_HashCode *key);
/**
* Destroys a room and frees its memory fully from the client API.
@@ -83,7 +84,8 @@ destroy_room (struct GNUNET_MESSENGER_Room *room);
* @return Message or NULL
*/
const struct GNUNET_MESSENGER_Message*
-get_room_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash);
+get_room_message (const struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_HashCode *hash);
/**
* Returns a messages sender locally stored from a map for a given <i>hash</i> in a <i>room</i>. If no
@@ -94,7 +96,8 @@ get_room_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_
* @return Contact of sender or NULL
*/
struct GNUNET_MESSENGER_Contact*
-get_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash);
+get_room_sender (const struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_HashCode *hash);
/**
* Handles a <i>message</i> with a given <i>hash</i> in a <i>room</i> for the client API to update
@@ -110,8 +113,10 @@ get_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_H
* @return Contact of sender
*/
struct GNUNET_MESSENGER_Contact*
-handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
+handle_room_message (struct GNUNET_MESSENGER_Room *room,
+ struct GNUNET_MESSENGER_Contact *sender,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Iterates through all members of a given <i>room</i> to forward each of them to a selected
@@ -123,7 +128,8 @@ handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER
* @return Amount of members iterated
*/
int
-iterate_room_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback,
+iterate_room_members (struct GNUNET_MESSENGER_Room *room,
+ GNUNET_MESSENGER_MemberCallback callback,
void* cls);
/**
@@ -135,6 +141,7 @@ iterate_room_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_Membe
* @return #GNUNET_YES if found, otherwise #GNUNET_NO
*/
int
-find_room_member (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact);
+find_room_member (const struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_MESSENGER_Contact *contact);
#endif //GNUNET_MESSENGER_API_ROOM_H
diff --git a/src/messenger/messenger_api_util.c b/src/messenger/messenger_api_util.c
index 4ad00c45e..52b4e934a 100644
--- a/src/messenger/messenger_api_util.c
+++ b/src/messenger/messenger_api_util.c
@@ -45,7 +45,8 @@ delayed_disconnect_channel (struct GNUNET_CADET_Channel *channel)
}
int
-generate_free_member_id (struct GNUNET_ShortHashCode *id, const struct GNUNET_CONTAINER_MultiShortmap *members)
+generate_free_member_id (struct GNUNET_ShortHashCode *id,
+ const struct GNUNET_CONTAINER_MultiShortmap *members)
{
GNUNET_assert(id);
@@ -84,7 +85,8 @@ get_anonymous_public_key ()
}
void
-convert_messenger_key_to_port(const struct GNUNET_HashCode *key, struct GNUNET_HashCode *port)
+convert_messenger_key_to_port(const struct GNUNET_HashCode *key,
+ struct GNUNET_HashCode *port)
{
static uint32_t version_value = 0;
static struct GNUNET_HashCode version;
diff --git a/src/messenger/messenger_api_util.h b/src/messenger/messenger_api_util.h
index af562a1e8..af64790b6 100644
--- a/src/messenger/messenger_api_util.h
+++ b/src/messenger/messenger_api_util.h
@@ -51,7 +51,8 @@ delayed_disconnect_channel (struct GNUNET_CADET_Channel *channel);
* @return #GNUNET_YES on success, #GNUNET_NO on failure
*/
int
-generate_free_member_id (struct GNUNET_ShortHashCode *id, const struct GNUNET_CONTAINER_MultiShortmap *members);
+generate_free_member_id (struct GNUNET_ShortHashCode *id,
+ const struct GNUNET_CONTAINER_MultiShortmap *members);
/**
* Returns the public identity key of #GNUNET_IDENTITY_ego_get_anonymous() without
@@ -73,6 +74,7 @@ get_anonymous_public_key ();
* @param[out] port CADET service port
*/
void
-convert_messenger_key_to_port(const struct GNUNET_HashCode *key, struct GNUNET_HashCode *port);
+convert_messenger_key_to_port(const struct GNUNET_HashCode *key,
+ struct GNUNET_HashCode *port);
#endif //GNUNET_SERVICE_MESSENGER_UTIL_H
diff --git a/src/messenger/plugin_gnsrecord_messenger.c b/src/messenger/plugin_gnsrecord_messenger.c
new file mode 100644
index 000000000..2219f0bde
--- /dev/null
+++ b/src/messenger/plugin_gnsrecord_messenger.c
@@ -0,0 +1,243 @@
+/*
+ This file is part of GNUnet.
+ Copyright (C) 2021 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+/**
+ * @author Tobias Frisch
+ * @file src/messenger/plugin_gnsrecord_messenger.c
+ * @brief Plugin to provide the API for useful GNS records to improve
+ * the usability of the messenger service.
+ */
+
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_gnsrecord_lib.h"
+#include "gnunet_messenger_service.h"
+#include "gnunet_gnsrecord_plugin.h"
+
+
+/**
+ * Convert the 'value' of a record to a string.
+ *
+ * @param cls closure, unused
+ * @param type type of the record
+ * @param data value in binary encoding
+ * @param data_size number of bytes in @a data
+ * @return NULL on error, otherwise human-readable representation of the value
+ */
+static char *
+messenger_value_to_string (void *cls,
+ uint32_t type,
+ const void *data,
+ size_t data_size)
+{
+ (void) cls;
+ switch (type)
+ {
+ case GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY:
+ {
+ if (data_size != sizeof(struct GNUNET_MESSENGER_RoomEntryRecord))
+ {
+ GNUNET_break_op (0);
+ return NULL;
+ }
+
+ const struct GNUNET_MESSENGER_RoomEntryRecord *record = data;
+
+ char *door = GNUNET_CRYPTO_eddsa_public_key_to_string (&(record->door.public_key));
+ char *key = GNUNET_STRINGS_data_to_string_alloc (&(record->key), sizeof(struct GNUNET_HashCode));
+
+ char *ret;
+ GNUNET_asprintf (&ret, "%s-%s", door, key);
+ GNUNET_free (key);
+ GNUNET_free (door);
+ return ret;
+ }
+
+ default:
+ return NULL;
+ }
+}
+
+
+/**
+ * Convert human-readable version of a 'value' of a record to the binary
+ * representation.
+ *
+ * @param cls closure, unused
+ * @param type type of the record
+ * @param s human-readable string
+ * @param data set to value in binary encoding (will be allocated)
+ * @param data_size set to number of bytes in @a data
+ * @return #GNUNET_OK on success
+ */
+static int
+messenger_string_to_value (void *cls,
+ uint32_t type,
+ const char *s,
+ void **data,
+ size_t *data_size)
+{
+ (void) cls;
+ if (NULL == s)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+
+ switch (type)
+ {
+ case GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY:
+ {
+ char key [103];
+ const char *dash;
+ struct GNUNET_PeerIdentity door;
+
+ if ((NULL == (dash = strchr (s, '-'))) ||
+ (1 != sscanf (s, "%103s-", key)) ||
+ (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (dash + 1,
+ strlen (dash + 1),
+ &(door.public_key))))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Unable to parse MESSENGER_ROOM_ENTRY record `%s'\n"),
+ s);
+ return GNUNET_SYSERR;
+ }
+
+ struct GNUNET_MESSENGER_RoomEntryRecord *record = GNUNET_new (
+ struct GNUNET_MESSENGER_RoomEntryRecord
+ );
+
+ if (GNUNET_OK != GNUNET_STRINGS_string_to_data (key,
+ strlen (key),
+ &(record->key),
+ sizeof(struct GNUNET_HashCode)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Unable to parse MESSENGER_ROOM_ENTRY record `%s'\n"),
+ s);
+ GNUNET_free (record);
+ return GNUNET_SYSERR;
+ }
+
+ record->door = door;
+ *data = record;
+ *data_size = sizeof(struct GNUNET_MESSENGER_RoomEntryRecord);
+ return GNUNET_OK;
+ }
+
+ default:
+ return GNUNET_SYSERR;
+ }
+}
+
+
+/**
+ * Mapping of record type numbers to human-readable
+ * record type names.
+ */
+static struct
+{
+ const char *name;
+ uint32_t number;
+} name_map[] = {
+ { "MESSENGER_ROOM_ENTRY", GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY },
+ { NULL, UINT32_MAX }
+};
+
+
+/**
+ * Convert a type name (e.g. "AAAA") to the corresponding number.
+ *
+ * @param cls closure, unused
+ * @param gns_typename name to convert
+ * @return corresponding number, UINT32_MAX on error
+ */
+static uint32_t
+messenger_typename_to_number (void *cls,
+ const char *gns_typename)
+{
+ unsigned int i;
+
+ (void) cls;
+ i = 0;
+ while ((name_map[i].name != NULL) &&
+ (0 != strcasecmp (gns_typename, name_map[i].name)))
+ i++;
+ return name_map[i].number;
+}
+
+
+/**
+ * Convert a type number to the corresponding type string (e.g. 1 to "A")
+ *
+ * @param cls closure, unused
+ * @param type number of a type to convert
+ * @return corresponding typestring, NULL on error
+ */
+static const char *
+messenger_number_to_typename (void *cls,
+ uint32_t type)
+{
+ unsigned int i;
+
+ (void) cls;
+ i = 0;
+ while ((name_map[i].name != NULL) &&
+ (type != name_map[i].number))
+ i++;
+ return name_map[i].name;
+}
+
+
+/**
+ * Entry point for the plugin.
+ *
+ * @param cls NULL
+ * @return the exported block API
+ */
+void *
+libgnunet_plugin_gnsrecord_messenger_init (void *cls)
+{
+ struct GNUNET_GNSRECORD_PluginFunctions *api;
+
+ (void) cls;
+ api = GNUNET_new (struct GNUNET_GNSRECORD_PluginFunctions);
+ api->value_to_string = &messenger_value_to_string;
+ api->string_to_value = &messenger_string_to_value;
+ api->typename_to_number = &messenger_typename_to_number;
+ api->number_to_typename = &messenger_number_to_typename;
+ return api;
+}
+
+
+/**
+ * Exit point from the plugin.
+ *
+ * @param cls the return value from #libgnunet_plugin_block_test_init
+ * @return NULL
+ */
+void *
+libgnunet_plugin_gnsrecord_messenger_done (void *cls)
+{
+ struct GNUNET_GNSRECORD_PluginFunctions *api = cls;
+
+ GNUNET_free (api);
+ return NULL;
+}
diff --git a/src/messenger/test_messenger.c b/src/messenger/test_messenger.c
index fb3e3e1bc..5784dfd82 100644
--- a/src/messenger/test_messenger.c
+++ b/src/messenger/test_messenger.c
@@ -100,7 +100,8 @@ static int identity_counter = 0;
* @param handle Handle of messenger service
*/
static void
-on_identity (void *cls, struct GNUNET_MESSENGER_Handle *handle)
+on_identity (void *cls,
+ struct GNUNET_MESSENGER_Handle *handle)
{
if (op_task)
{
@@ -150,7 +151,9 @@ on_identity (void *cls, struct GNUNET_MESSENGER_Handle *handle)
* @param peer Peer for testing
*/
static void
-run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer)
+run (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTING_Peer *peer)
{
die_task = GNUNET_SCHEDULER_add_delayed (TOTAL_TIMEOUT, &end_badly, NULL);
@@ -168,7 +171,8 @@ run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TES
* @return 0 ok, 1 on error
*/
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
if (0 != GNUNET_TESTING_peer_run ("test-messenger", "test_messenger_api.conf", &run, NULL))
return 1;
diff --git a/src/messenger/test_messenger_adapt.c b/src/messenger/test_messenger_adapt.c
index 90e8ac28d..3230af6b7 100644
--- a/src/messenger/test_messenger_adapt.c
+++ b/src/messenger/test_messenger_adapt.c
@@ -33,7 +33,8 @@
* @return 0 ok, 1 on error
*/
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
unsigned int doors [] = { 5, 1, 2, 3, 6, 7, 8, 4 };
unsigned int stages [] = { 0x21, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x21 };
diff --git a/src/messenger/test_messenger_anonymous.c b/src/messenger/test_messenger_anonymous.c
index a70121a30..8cb339f0e 100644
--- a/src/messenger/test_messenger_anonymous.c
+++ b/src/messenger/test_messenger_anonymous.c
@@ -96,7 +96,8 @@ end_operation (void *cls)
* @param handle Handle of messenger service
*/
static void
-on_identity (void *cls, struct GNUNET_MESSENGER_Handle *handle)
+on_identity (void *cls,
+ struct GNUNET_MESSENGER_Handle *handle)
{
if (op_task)
{
@@ -144,7 +145,9 @@ on_identity (void *cls, struct GNUNET_MESSENGER_Handle *handle)
* @param peer Peer for testing
*/
static void
-run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer)
+run (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTING_Peer *peer)
{
die_task = GNUNET_SCHEDULER_add_delayed (TOTAL_TIMEOUT, &end_badly, NULL);
@@ -160,7 +163,8 @@ run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TES
* @return 0 ok, 1 on error
*/
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
if (0 != GNUNET_TESTING_peer_run ("test-messenger", "test_messenger_api.conf", &run, NULL))
return 1;
diff --git a/src/messenger/test_messenger_async_client.c b/src/messenger/test_messenger_async_client.c
index 1067b9a6d..8404195dc 100644
--- a/src/messenger/test_messenger_async_client.c
+++ b/src/messenger/test_messenger_async_client.c
@@ -33,7 +33,8 @@
* @return 0 ok, 1 on error
*/
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
unsigned int doors [] = { 0, 1 };
unsigned int stages [] = { 0x10, 0x20 };
diff --git a/src/messenger/test_messenger_async_p2p.c b/src/messenger/test_messenger_async_p2p.c
index d827aae16..25746f7ff 100644
--- a/src/messenger/test_messenger_async_p2p.c
+++ b/src/messenger/test_messenger_async_p2p.c
@@ -33,7 +33,8 @@
* @return 0 ok, 1 on error
*/
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
unsigned int doors [] = { 2, 1 };
unsigned int stages [] = { 0x30, 0x30 };
diff --git a/src/messenger/test_messenger_growth.c b/src/messenger/test_messenger_growth.c
index 3781f3ee5..c3f243cbf 100644
--- a/src/messenger/test_messenger_growth.c
+++ b/src/messenger/test_messenger_growth.c
@@ -33,7 +33,8 @@
* @return 0 ok, 1 on error
*/
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
unsigned int doors [] = { 0, 1, 1, 1, 1, 1, 1, 1 };
unsigned int stages [] = { 0x01, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21 };
diff --git a/src/messenger/test_messenger_ring.c b/src/messenger/test_messenger_ring.c
index 07cfd0c47..777d79eb8 100644
--- a/src/messenger/test_messenger_ring.c
+++ b/src/messenger/test_messenger_ring.c
@@ -33,7 +33,8 @@
* @return 0 ok, 1 on error
*/
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
unsigned int doors [] = { 8, 1, 2, 3, 4, 5, 6, 7 };
unsigned int stages [] = { 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21 };
diff --git a/src/messenger/test_messenger_server.c b/src/messenger/test_messenger_server.c
index 1cf2fcc27..61e96e879 100644
--- a/src/messenger/test_messenger_server.c
+++ b/src/messenger/test_messenger_server.c
@@ -33,7 +33,8 @@
* @return 0 ok, 1 on error
*/
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
unsigned int doors [] = { 0, 1, 1, 1, 1, 1, 1, 1 };
unsigned int stages [] = { 0x01, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
diff --git a/src/messenger/test_messenger_sync_client.c b/src/messenger/test_messenger_sync_client.c
index 99f26b018..02d90a61d 100644
--- a/src/messenger/test_messenger_sync_client.c
+++ b/src/messenger/test_messenger_sync_client.c
@@ -33,7 +33,8 @@
* @return 0 ok, 1 on error
*/
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
unsigned int doors [] = { 0, 1 };
unsigned int stages [] = { 0x01, 0x20 };
diff --git a/src/messenger/test_messenger_sync_p2p.c b/src/messenger/test_messenger_sync_p2p.c
index 77ce280a1..0a900a39e 100644
--- a/src/messenger/test_messenger_sync_p2p.c
+++ b/src/messenger/test_messenger_sync_p2p.c
@@ -33,7 +33,8 @@
* @return 0 ok, 1 on error
*/
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
unsigned int doors [] = { 2, 1 };
unsigned int stages [] = { 0x21, 0x21 };
diff --git a/src/messenger/test_messenger_worst_client.c b/src/messenger/test_messenger_worst_client.c
index 63826631c..a3d5aafec 100644
--- a/src/messenger/test_messenger_worst_client.c
+++ b/src/messenger/test_messenger_worst_client.c
@@ -33,7 +33,8 @@
* @return 0 ok, 1 on error
*/
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
unsigned int doors [] = { 0, 1 };
unsigned int stages [] = { 0x10, 0x02 };
diff --git a/src/messenger/test_messenger_worst_p2p.c b/src/messenger/test_messenger_worst_p2p.c
index c89288eea..89e54cfbd 100644
--- a/src/messenger/test_messenger_worst_p2p.c
+++ b/src/messenger/test_messenger_worst_p2p.c
@@ -33,7 +33,8 @@
* @return 0 ok, 1 on error
*/
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
unsigned int doors [] = { 2, 1 };
unsigned int stages [] = { 0x12, 0x12 };
diff --git a/src/messenger/testing_messenger_barrier.c b/src/messenger/testing_messenger_barrier.c
index 618d255b7..a95ea9ef1 100644
--- a/src/messenger/testing_messenger_barrier.c
+++ b/src/messenger/testing_messenger_barrier.c
@@ -61,7 +61,8 @@ GNUNET_init_barrier (unsigned int requirement,
}
static void
-exit_status (struct GNUNET_BarrierHandle *barrier, int status);
+exit_status (struct GNUNET_BarrierHandle *barrier,
+ int status);
static void
cancel_barrier (void *cls)
@@ -96,7 +97,8 @@ struct GNUNET_BarrierWaitHandle
};
static void
-exit_status (struct GNUNET_BarrierHandle *barrier, int status)
+exit_status (struct GNUNET_BarrierHandle *barrier,
+ int status)
{
struct GNUNET_BarrierWaitHandle *waiting = barrier->head;
while (waiting)
diff --git a/src/messenger/testing_messenger_setup.c b/src/messenger/testing_messenger_setup.c
index 98241fa08..3cde8c9bb 100644
--- a/src/messenger/testing_messenger_setup.c
+++ b/src/messenger/testing_messenger_setup.c
@@ -204,7 +204,9 @@ end_error_cb (void *cls)
}
static void
-barrier2_wait_cb (void *cls, struct GNUNET_BarrierWaitHandle *waiting, int status)
+barrier2_wait_cb (void *cls,
+ struct GNUNET_BarrierWaitHandle *waiting,
+ int status)
{
struct test_peer *peer = cls;
@@ -215,7 +217,9 @@ barrier2_wait_cb (void *cls, struct GNUNET_BarrierWaitHandle *waiting, int statu
}
static void
-barrier_wait_cb (void *cls, struct GNUNET_BarrierWaitHandle *waiting, int status)
+barrier_wait_cb (void *cls,
+ struct GNUNET_BarrierWaitHandle *waiting,
+ int status)
{
struct test_peer *peer = cls;
@@ -259,8 +263,11 @@ barrier_wait_cb (void *cls, struct GNUNET_BarrierWaitHandle *waiting, int status
* @param flags Flags of message
*/
static void
-on_message (void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *sender,
- const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash,
+on_message (void *cls,
+ struct GNUNET_MESSENGER_Room *room,
+ const struct GNUNET_MESSENGER_Contact *sender,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash,
enum GNUNET_MESSENGER_MessageFlags flags)
{
struct test_peer *peer = cls;
@@ -340,7 +347,9 @@ second_stage (void *cls)
}
static void
-on_peer (void *cb_cls, struct GNUNET_TESTBED_Operation *op, const struct GNUNET_TESTBED_PeerInformation *pinfo,
+on_peer (void *cb_cls,
+ struct GNUNET_TESTBED_Operation *op,
+ const struct GNUNET_TESTBED_PeerInformation *pinfo,
const char *emsg)
{
struct test_peer *peer = cb_cls;
@@ -396,7 +405,8 @@ on_peer (void *cb_cls, struct GNUNET_TESTBED_Operation *op, const struct GNUNET_
* @param event Information about the event
*/
static void
-run (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
+run (void *cls,
+ const struct GNUNET_TESTBED_EventInformation *event)
{
struct test_properties *properties = cls;
@@ -420,7 +430,9 @@ run (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
}
static void
-barrier2_cb (void *cls, struct GNUNET_BarrierHandle *barrier, int status)
+barrier2_cb (void *cls,
+ struct GNUNET_BarrierHandle *barrier,
+ int status)
{
struct test_properties *properties = cls;
@@ -449,7 +461,9 @@ barrier2_cb (void *cls, struct GNUNET_BarrierHandle *barrier, int status)
}
static void
-barrier_cb (void *cls, struct GNUNET_BarrierHandle *barrier, int status)
+barrier_cb (void *cls,
+ struct GNUNET_BarrierHandle *barrier,
+ int status)
{
struct test_properties *properties = cls;
@@ -485,8 +499,12 @@ barrier_cb (void *cls, struct GNUNET_BarrierHandle *barrier, int status)
}
static void
-init (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers,
- unsigned int links_succeeded, unsigned int links_failed)
+init (void *cls,
+ struct GNUNET_TESTBED_RunHandle *h,
+ unsigned int num_peers,
+ struct GNUNET_TESTBED_Peer **peers,
+ unsigned int links_succeeded,
+ unsigned int links_failed)
{
struct test_properties *properties = cls;
@@ -500,7 +518,8 @@ init (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, str
}
int
-GNUNET_run_messenger_setup (const char* test_name, const struct test_configuration *cfg)
+GNUNET_run_messenger_setup (const char* test_name,
+ const struct test_configuration *cfg)
{
struct test_properties properties;
memset(&properties, 0, sizeof(properties));
diff --git a/src/messenger/testing_messenger_setup.h b/src/messenger/testing_messenger_setup.h
index 5e6b5d461..e5ae0c151 100644
--- a/src/messenger/testing_messenger_setup.h
+++ b/src/messenger/testing_messenger_setup.h
@@ -34,6 +34,7 @@ struct test_configuration
};
int
-GNUNET_run_messenger_setup (const char* test_name, const struct test_configuration *cfg);
+GNUNET_run_messenger_setup (const char* test_name,
+ const struct test_configuration *cfg);
#endif /* GNUNET_TESTING_MESSENGER_SETUP_H_ */
diff --git a/src/namecache/Makefile.am b/src/namecache/Makefile.am
index 8ffa85ddb..272f16b77 100644
--- a/src/namecache/Makefile.am
+++ b/src/namecache/Makefile.am
@@ -17,30 +17,22 @@ endif
if HAVE_EXPERIMENTAL
FLAT_PLUGIN = libgnunet_plugin_namecache_flat.la
-if HAVE_TESTING
FLAT_TESTS = test_plugin_namecache_flat
endif
-endif
if HAVE_SQLITE
SQLITE_PLUGIN = libgnunet_plugin_namecache_sqlite.la
-if HAVE_TESTING
SQLITE_TESTS = test_plugin_namecache_sqlite
endif
-endif
if HAVE_POSTGRESQL
POSTGRES_PLUGIN = libgnunet_plugin_namecache_postgres.la
-if HAVE_TESTING
POSTGRES_TESTS = test_plugin_namecache_postgres
endif
-endif
# testcases do not even build yet; thus: experimental!
-if HAVE_TESTING
TESTING_TESTS = \
test_namecache_api_cache_block
-endif
if HAVE_SQLITE
check_PROGRAMS = \
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am
index 18e6a196b..51708dd67 100644
--- a/src/namestore/Makefile.am
+++ b/src/namestore/Makefile.am
@@ -16,7 +16,6 @@ if USE_COVERAGE
endif
HEAP_PLUGIN = libgnunet_plugin_namestore_flat.la
-if HAVE_TESTING
HEAP_TESTS = test_plugin_namestore_flat \
test_namestore_api_store_flat \
test_namestore_api_store_update_flat \
@@ -35,11 +34,9 @@ HEAP_TESTS = test_plugin_namestore_flat \
test_namestore_api_monitoring_existing_flat \
test_namestore_api_zone_to_name_flat \
perf_namestore_api_zone_iteration_flat
-endif
if HAVE_SQLITE
SQLITE_PLUGIN = libgnunet_plugin_namestore_sqlite.la
-if HAVE_TESTING
SQLITE_TESTS = test_plugin_namestore_sqlite \
test_namestore_api_store_sqlite \
test_namestore_api_store_update_sqlite \
@@ -59,11 +56,9 @@ SQLITE_TESTS = test_plugin_namestore_sqlite \
test_namestore_api_zone_to_name_sqlite \
perf_namestore_api_zone_iteration_sqlite
endif
-endif
if HAVE_POSTGRESQL
POSTGRES_PLUGIN = libgnunet_plugin_namestore_postgres.la
-if HAVE_TESTING
POSTGRES_TESTS = test_plugin_namestore_postgres \
test_namestore_api_store_postgres \
test_namestore_api_store_update_postgres \
@@ -83,7 +78,6 @@ POSTGRES_TESTS = test_plugin_namestore_postgres \
test_namestore_api_zone_to_name_postgres \
perf_namestore_api_zone_iteration_postgres
endif
-endif
if HAVE_SQLITE
check_PROGRAMS = \
diff --git a/src/namestore/gnunet-namestore-fcfsd.c b/src/namestore/gnunet-namestore-fcfsd.c
index 95d4c5878..7ec9db156 100644
--- a/src/namestore/gnunet-namestore-fcfsd.c
+++ b/src/namestore/gnunet-namestore-fcfsd.c
@@ -205,6 +205,15 @@ do_shutdown (void *cls)
{
GNUNET_IDENTITY_disconnect (identity);
}
+
+ if (NULL != httpd_task)
+ {
+ GNUNET_SCHEDULER_cancel (httpd_task);
+ }
+ if (NULL != httpd)
+ {
+ MHD_stop_daemon (httpd);
+ }
}
@@ -985,7 +994,7 @@ identity_cb (void *cls,
*
* @param name name of the file to open
* @param basedir directory where the file is located
- * @return #GNUNET_SYSERR on error
+ * @return NULL on error
*/
static struct StaticPage *
open_static_page (const char *name, const char *basedir)
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 92d2cf627..852d99608 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -1212,8 +1212,10 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
char sname[64];
struct GNUNET_IDENTITY_PublicKey pkey;
- GNUNET_STRINGS_utf8_tolower (uri, uri);
- if ((2 != (sscanf (uri, "gnunet://gns/%52s/%63s", sh, sname))) ||
+ memset(sh, 0, 105);
+ memset(sname, 0, 64);
+
+ if ((2 != (sscanf (uri, "gnunet://gns/%58s/%63s", sh, sname))) ||
(GNUNET_OK !=
GNUNET_IDENTITY_public_key_from_string (sh, &pkey)))
{
diff --git a/src/nat/nat_api.c b/src/nat/nat_api.c
index 4622b1428..20e7b6ec6 100644
--- a/src/nat/nat_api.c
+++ b/src/nat/nat_api.c
@@ -311,7 +311,8 @@ handle_address_change_notification (
* @param error details about the error
*/
static void
-mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
+mq_error_handler (void *cls,
+ enum GNUNET_MQ_Error error)
{
struct GNUNET_NAT_Handle *nh = cls;
@@ -328,29 +329,36 @@ static void
do_connect (void *cls)
{
struct GNUNET_NAT_Handle *nh = cls;
- struct GNUNET_MQ_MessageHandler handlers[] =
- { GNUNET_MQ_hd_var_size (connection_reversal_request,
- GNUNET_MESSAGE_TYPE_NAT_CONNECTION_REVERSAL_REQUESTED,
- struct
- GNUNET_NAT_ConnectionReversalRequestedMessage,
- nh),
- GNUNET_MQ_hd_var_size (address_change_notification,
- GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE,
- struct GNUNET_NAT_AddressChangeNotificationMessage,
- nh),
- GNUNET_MQ_handler_end () };
+ struct GNUNET_MQ_MessageHandler handlers[] = {
+ GNUNET_MQ_hd_var_size (
+ connection_reversal_request,
+ GNUNET_MESSAGE_TYPE_NAT_CONNECTION_REVERSAL_REQUESTED,
+ struct GNUNET_NAT_ConnectionReversalRequestedMessage,
+ nh),
+ GNUNET_MQ_hd_var_size (
+ address_change_notification,
+ GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE,
+ struct GNUNET_NAT_AddressChangeNotificationMessage,
+ nh),
+ GNUNET_MQ_handler_end ()
+ };
struct GNUNET_MQ_Envelope *env;
nh->reconnect_task = NULL;
nh->mq =
- GNUNET_CLIENT_connect (nh->cfg, "nat", handlers, &mq_error_handler, nh);
+ GNUNET_CLIENT_connect (nh->cfg,
+ "nat",
+ handlers,
+ &mq_error_handler,
+ nh);
if (NULL == nh->mq)
{
reconnect (nh);
return;
}
env = GNUNET_MQ_msg_copy (nh->reg);
- GNUNET_MQ_send (nh->mq, env);
+ GNUNET_MQ_send (nh->mq,
+ env);
}
@@ -396,8 +404,9 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
len += addrlens[i];
str_len = strlen (config_section) + 1;
len += str_len;
- if ((len > GNUNET_MAX_MESSAGE_SIZE - sizeof(*rm)) ||
- (num_addrs > UINT16_MAX))
+ if ( (len > GNUNET_MAX_MESSAGE_SIZE - sizeof(*rm)) ||
+ (num_addrs > UINT16_MAX) ||
+ (str_len > UINT16_MAX) )
{
GNUNET_break (0);
return NULL;
@@ -475,7 +484,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
* @return #GNUNET_YES if @a data is a STUN packet,
* #GNUNET_NO if the packet is invalid (not a stun packet)
*/
-static int
+static enum GNUNET_GenericReturnValue
test_stun_packet (const void *data, size_t len)
{
const struct stun_header *hdr;
diff --git a/src/nse/Makefile.am b/src/nse/Makefile.am
index 824aa10d4..0c6182e61 100644
--- a/src/nse/Makefile.am
+++ b/src/nse/Makefile.am
@@ -36,10 +36,8 @@ libgnunetnse_la_LDFLAGS = \
libexec_PROGRAMS = \
gnunet-service-nse
-if HAVE_TESTING
noinst_PROGRAMS = \
gnunet-nse-profiler
-endif
gnunet_nse_profiler_SOURCES = \
gnunet-nse-profiler.c
@@ -71,12 +69,10 @@ if HAVE_BENCHMARKS
MULTIPEER_TEST = test_nse_multipeer
endif
-if HAVE_TESTING
check_PROGRAMS = \
test_nse_api \
perf_kdf \
$(MULTIPEER_TEST)
-endif
if ENABLE_TEST_RUN
AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c
index 8e9cd0c9d..972b3a79d 100644
--- a/src/nse/gnunet-service-nse.c
+++ b/src/nse/gnunet-service-nse.c
@@ -390,7 +390,7 @@ setup_estimate_message (struct GNUNET_NSE_ClientMessage *em)
if (variance >= 0)
std_dev = sqrt (variance);
else
- std_dev = variance; /* must be infinity due to estimate_count == 0 */
+ std_dev = variance; /* return NaN (due to estimate_count == 0 causing 0.0/0.0) */
current_std_dev = std_dev;
current_size_estimate = mean;
diff --git a/src/peerinfo/Makefile.am b/src/peerinfo/Makefile.am
index e61e5a13d..cdab22a9d 100644
--- a/src/peerinfo/Makefile.am
+++ b/src/peerinfo/Makefile.am
@@ -48,14 +48,12 @@ if HAVE_BENCHMARKS
perf_peerinfo_api
endif
-if HAVE_TESTING
check_PROGRAMS = \
test_peerinfo_shipped_hellos \
test_peerinfo_api \
test_peerinfo_api_friend_only \
test_peerinfo_api_notify_friend_only \
$(PEERINFO_BENCHMARKS)
-endif
if ENABLE_TEST_RUN
diff --git a/src/peerstore/Makefile.am b/src/peerstore/Makefile.am
index babf40654..d9904e59d 100644
--- a/src/peerstore/Makefile.am
+++ b/src/peerstore/Makefile.am
@@ -63,9 +63,7 @@ endif
if HAVE_SQLITE
SQLITE_PLUGIN = libgnunet_plugin_peerstore_sqlite.la
-if HAVE_TESTING
SQLITE_TESTS = test_plugin_peerstore_sqlite
-endif
libgnunet_plugin_peerstore_sqlite_la_SOURCES = \
plugin_peerstore_sqlite.c
libgnunet_plugin_peerstore_sqlite_la_LIBADD = \
diff --git a/src/pq/pq.c b/src/pq/pq.c
index b260aa1db..130ff355f 100644
--- a/src/pq/pq.c
+++ b/src/pq/pq.c
@@ -95,6 +95,11 @@ GNUNET_PQ_exec_prepared (struct GNUNET_PQ_Context *db,
param_lengths,
param_formats,
1);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+ "pq",
+ "Execution of prepared SQL statement `%s' finished (%d)\n",
+ name,
+ PGRES_COMMAND_OK == PQresultStatus (res));
if ( (PGRES_COMMAND_OK != PQresultStatus (res)) &&
(CONNECTION_OK != (status = PQstatus (db->conn))) )
{
@@ -163,6 +168,9 @@ GNUNET_PQ_extract_result (PGresult *result,
spec->fname);
goto cleanup;
case GNUNET_SYSERR:
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to extract field `%s'\n",
+ spec->fname);
GNUNET_break (0);
goto cleanup;
}
diff --git a/src/pq/pq.h b/src/pq/pq.h
index d10931d99..354d85a9f 100644
--- a/src/pq/pq.h
+++ b/src/pq/pq.h
@@ -73,6 +73,11 @@ struct GNUNET_PQ_Context
* File descriptor wrapper for @e event_task.
*/
struct GNUNET_NETWORK_Handle *rfd;
+
+ /**
+ * Flags controlling the connection.
+ */
+ enum GNUNET_PQ_Options flags;
};
diff --git a/src/pq/pq_connect.c b/src/pq/pq_connect.c
index a2dce3fb0..a63d5f14e 100644
--- a/src/pq/pq_connect.c
+++ b/src/pq/pq_connect.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- Copyright (C) 2017, 2019, 2020 GNUnet e.V.
+ Copyright (C) 2017, 2019, 2020, 2021 GNUnet e.V.
GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
@@ -70,6 +70,21 @@ GNUNET_PQ_connect (const char *config_str,
const struct GNUNET_PQ_ExecuteStatement *es,
const struct GNUNET_PQ_PreparedStatement *ps)
{
+ return GNUNET_PQ_connect2 (config_str,
+ load_path,
+ es,
+ ps,
+ GNUNET_PQ_FLAG_NONE);
+}
+
+
+struct GNUNET_PQ_Context *
+GNUNET_PQ_connect2 (const char *config_str,
+ const char *load_path,
+ const struct GNUNET_PQ_ExecuteStatement *es,
+ const struct GNUNET_PQ_PreparedStatement *ps,
+ enum GNUNET_PQ_Options flags)
+{
struct GNUNET_PQ_Context *db;
unsigned int elen = 0;
unsigned int plen = 0;
@@ -82,6 +97,7 @@ GNUNET_PQ_connect (const char *config_str,
plen++;
db = GNUNET_new (struct GNUNET_PQ_Context);
+ db->flags = flags;
db->config_str = GNUNET_strdup (config_str);
if (NULL != load_path)
db->load_path = GNUNET_strdup (load_path);
@@ -200,68 +216,72 @@ GNUNET_PQ_run_sql (struct GNUNET_PQ_Context *db,
load_path);
for (unsigned int i = 1; i<10000; i++)
{
+ char patch_name[slen];
+ char buf[slen];
enum GNUNET_DB_QueryStatus qs;
- {
- char buf[slen];
-
- /* First, check patch actually exists */
- GNUNET_snprintf (buf,
- sizeof (buf),
- "%s%04u.sql",
- load_path,
- i);
- if (GNUNET_YES !=
- GNUNET_DISK_file_test (buf))
- return GNUNET_OK; /* We are done */
- }
+
+ /* First, check patch actually exists */
+ GNUNET_snprintf (buf,
+ sizeof (buf),
+ "%s%04u.sql",
+ load_path,
+ i);
+ if (GNUNET_YES !=
+ GNUNET_DISK_file_test (buf))
+ return GNUNET_OK; /* We are done */
/* Second, check with DB versioning schema if this patch was already applied,
if so, skip it. */
+ GNUNET_snprintf (patch_name,
+ sizeof (patch_name),
+ "%s%04u",
+ load_path_suffix,
+ i);
{
- char patch_name[slen];
-
- GNUNET_snprintf (patch_name,
- sizeof (patch_name),
- "%s%04u",
- load_path_suffix,
- i);
+ char *applied_by;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_string (patch_name),
+ GNUNET_PQ_query_param_end
+ };
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_string ("applied_by",
+ &applied_by),
+ GNUNET_PQ_result_spec_end
+ };
+
+ qs = GNUNET_PQ_eval_prepared_singleton_select (db,
+ "gnunet_pq_check_patch",
+ params,
+ rs);
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Database version %s already applied by %s, skipping\n",
+ patch_name,
+ applied_by);
+ GNUNET_PQ_cleanup_result (rs);
+ }
+ if (GNUNET_DB_STATUS_HARD_ERROR == qs)
{
- char *applied_by;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_string (patch_name),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_string ("applied_by",
- &applied_by),
- GNUNET_PQ_result_spec_end
- };
-
- qs = GNUNET_PQ_eval_prepared_singleton_select (db,
- "gnunet_pq_check_patch",
- params,
- rs);
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Database version %s already applied by %s, skipping\n",
- patch_name,
- applied_by);
- GNUNET_PQ_cleanup_result (rs);
- }
- if (GNUNET_DB_STATUS_HARD_ERROR == qs)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
}
}
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
continue; /* patch already applied, skip it */
- /* patch not yet applied, run it! */
+ if (0 != (GNUNET_PQ_FLAG_CHECK_CURRENT & db->flags))
{
- int ret;
+ /* We are only checking, found unapplied patch, bad! */
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Database outdated, patch %s missing. Aborting!\n",
+ patch_name);
+ return GNUNET_SYSERR;
+ }
+ else
+ {
+ /* patch not yet applied, run it! */
+ enum GNUNET_GenericReturnValue ret;
ret = apply_patch (db,
load_path,
@@ -334,9 +354,17 @@ GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db)
NULL);
if (PGRES_COMMAND_OK != PQresultStatus (res))
{
- int ret;
+ enum GNUNET_GenericReturnValue ret;
PQclear (res);
+ if (0 != (db->flags & GNUNET_PQ_FLAG_DROP))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Failed to prepare statement to check patch level. Likely versioning schema does not exist yet. Not attempting drop!\n");
+ PQfinish (db->conn);
+ db->conn = NULL;
+ return;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Failed to prepare statement to check patch level. Likely versioning schema does not exist yet, loading patch level 0000!\n");
ret = apply_patch (db,
@@ -424,6 +452,23 @@ GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
const struct GNUNET_PQ_ExecuteStatement *es,
const struct GNUNET_PQ_PreparedStatement *ps)
{
+ return GNUNET_PQ_connect_with_cfg2 (cfg,
+ section,
+ load_path_suffix,
+ es,
+ ps,
+ GNUNET_PQ_FLAG_NONE);
+}
+
+
+struct GNUNET_PQ_Context *
+GNUNET_PQ_connect_with_cfg2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *section,
+ const char *load_path_suffix,
+ const struct GNUNET_PQ_ExecuteStatement *es,
+ const struct GNUNET_PQ_PreparedStatement *ps,
+ enum GNUNET_PQ_Options flags)
+{
struct GNUNET_PQ_Context *db;
char *conninfo;
char *load_path;
@@ -447,10 +492,11 @@ GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
"%s%s",
sp,
load_path_suffix);
- db = GNUNET_PQ_connect (conninfo == NULL ? "" : conninfo,
- load_path,
- es,
- ps);
+ db = GNUNET_PQ_connect2 (conninfo == NULL ? "" : conninfo,
+ load_path,
+ es,
+ ps,
+ flags);
GNUNET_free (load_path);
GNUNET_free (sp);
GNUNET_free (conninfo);
diff --git a/src/pq/pq_event.c b/src/pq/pq_event.c
index 79a2e80c6..98a28c317 100644
--- a/src/pq/pq_event.c
+++ b/src/pq/pq_event.c
@@ -194,9 +194,15 @@ event_do_poll (struct GNUNET_PQ_Context *db)
"PG poll job active\n");
if (1 !=
PQconsumeInput (db->conn))
+ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to read from Postgres: %s\n",
PQerrorMessage (db->conn));
+ if (CONNECTION_BAD != PQstatus (db->conn))
+ return;
+ GNUNET_PQ_reconnect (db);
+ return;
+ }
while (NULL != (n = PQnotifies (db->conn)))
{
struct GNUNET_ShortHashCode sh;
@@ -263,10 +269,20 @@ do_scheduler_notify (void *cls)
struct GNUNET_PQ_Context *db = cls;
db->event_task = NULL;
- GNUNET_assert (NULL != db->rfd);
+ if (NULL == db->rfd)
+ GNUNET_PQ_reconnect (db);
event_do_poll (db);
+ if (NULL != db->event_task)
+ return;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Resubscribing\n");
+ if (NULL == db->rfd)
+ {
+ db->event_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &do_scheduler_notify,
+ db);
+ return;
+ }
db->event_task
= GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
db->rfd,
@@ -329,6 +345,8 @@ manage_subscribe (struct GNUNET_PQ_Context *db,
char *end;
PGresult *result;
+ if (NULL == db->conn)
+ return;
end = stpcpy (sql,
cmd);
end = sh_to_channel (&eh->sh,
@@ -420,6 +438,7 @@ GNUNET_PQ_event_listen (struct GNUNET_PQ_Context *db,
void *cb_cls)
{
struct GNUNET_DB_EventHandler *eh;
+ bool sub;
eh = GNUNET_new (struct GNUNET_DB_EventHandler);
eh->db = db;
@@ -427,6 +446,9 @@ GNUNET_PQ_event_listen (struct GNUNET_PQ_Context *db,
&eh->sh);
eh->cb = cb;
eh->cb_cls = cb_cls;
+ sub = (NULL ==
+ GNUNET_CONTAINER_multishortmap_get (db->channel_map,
+ &eh->sh));
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multishortmap_put (db->channel_map,
&eh->sh,
@@ -439,9 +461,10 @@ GNUNET_PQ_event_listen (struct GNUNET_PQ_Context *db,
scheduler_fd_cb (db,
PQsocket (db->conn));
}
- manage_subscribe (db,
- "LISTEN X",
- eh);
+ if (sub)
+ manage_subscribe (db,
+ "LISTEN X",
+ eh);
eh->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
&event_timeout,
eh);
@@ -458,9 +481,12 @@ GNUNET_PQ_event_listen_cancel (struct GNUNET_DB_EventHandler *eh)
GNUNET_CONTAINER_multishortmap_remove (db->channel_map,
&eh->sh,
eh));
- manage_subscribe (db,
- "UNLISTEN X",
- eh);
+ if (NULL ==
+ GNUNET_CONTAINER_multishortmap_get (db->channel_map,
+ &eh->sh))
+ manage_subscribe (db,
+ "UNLISTEN X",
+ eh);
if (0 == GNUNET_CONTAINER_multishortmap_size (db->channel_map))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
diff --git a/src/pq/pq_exec.c b/src/pq/pq_exec.c
index fd4feae53..dcde331b6 100644
--- a/src/pq/pq_exec.c
+++ b/src/pq/pq_exec.c
@@ -72,7 +72,7 @@ GNUNET_PQ_make_try_execute (const char *sql)
* @return #GNUNET_OK on success (modulo statements where errors can be ignored)
* #GNUNET_SYSERR on error
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_PQ_exec_statements (struct GNUNET_PQ_Context *db,
const struct GNUNET_PQ_ExecuteStatement *es)
{
@@ -86,6 +86,11 @@ GNUNET_PQ_exec_statements (struct GNUNET_PQ_Context *db,
db);
result = PQexec (db->conn,
es[i].sql);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Running statement `%s' on %p finished (%d)\n",
+ es[i].sql,
+ db,
+ PGRES_COMMAND_OK == PQresultStatus (result));
if ((GNUNET_NO == es[i].ignore_errors) &&
(PGRES_COMMAND_OK != PQresultStatus (result)))
{
diff --git a/src/pq/pq_prepare.c b/src/pq/pq_prepare.c
index 63087456f..fcf1cc793 100644
--- a/src/pq/pq_prepare.c
+++ b/src/pq/pq_prepare.c
@@ -58,7 +58,7 @@ GNUNET_PQ_make_prepare (const char *name,
* @return #GNUNET_OK on success,
* #GNUNET_SYSERR on error
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_PQ_prepare_statements (struct GNUNET_PQ_Context *db,
const struct GNUNET_PQ_PreparedStatement *ps)
{
@@ -106,12 +106,22 @@ GNUNET_PQ_prepare_statements (struct GNUNET_PQ_Context *db,
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"pq",
- _ ("PQprepare (`%s' as `%s') failed with error: %s\n"),
+ "PQprepare (`%s' as `%s') failed with error: %s\n",
ps[i].sql,
ps[i].name,
PQerrorMessage (db->conn));
PQclear (ret);
- return GNUNET_SYSERR;
+ ret = PQdescribePrepared (db->conn,
+ ps[i].name);
+ if (PGRES_COMMAND_OK != PQresultStatus (ret))
+ {
+ PQclear (ret);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+ "pq",
+ "Statement `%s' already known. Ignoring the issue in the hope that you are using connection pooling...\n",
+ ps[i].name);
}
PQclear (ret);
}
diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c
index cee84d203..78c324512 100644
--- a/src/pq/pq_query_helper.c
+++ b/src/pq/pq_query_helper.c
@@ -61,7 +61,7 @@ qconv_null (void *cls,
return -1;
param_values[0] = NULL;
param_lengths[0] = 0;
- param_formats[0] = 1;
+ param_formats[0] = 1;
return 0;
}
@@ -134,6 +134,17 @@ GNUNET_PQ_query_param_string (const char *ptr)
}
+struct GNUNET_PQ_QueryParam
+GNUNET_PQ_query_param_bool (bool b)
+{
+ static uint8_t bt = 1;
+ static uint8_t bf = 0;
+
+ return GNUNET_PQ_query_param_fixed_size (b ? &bt : &bf,
+ sizeof (uint8_t));
+}
+
+
/**
* Function called to convert input argument into SQL parameters.
*
@@ -180,8 +191,9 @@ qconv_uint16 (void *cls,
struct GNUNET_PQ_QueryParam
GNUNET_PQ_query_param_uint16 (const uint16_t *x)
{
- struct GNUNET_PQ_QueryParam res =
- { &qconv_uint16, NULL, x, sizeof(*x), 1 };
+ struct GNUNET_PQ_QueryParam res = {
+ &qconv_uint16, NULL, x, sizeof(*x), 1
+ };
return res;
}
@@ -233,8 +245,9 @@ qconv_uint32 (void *cls,
struct GNUNET_PQ_QueryParam
GNUNET_PQ_query_param_uint32 (const uint32_t *x)
{
- struct GNUNET_PQ_QueryParam res =
- { &qconv_uint32, NULL, x, sizeof(*x), 1 };
+ struct GNUNET_PQ_QueryParam res = {
+ &qconv_uint32, NULL, x, sizeof(*x), 1
+ };
return res;
}
@@ -286,8 +299,9 @@ qconv_uint64 (void *cls,
struct GNUNET_PQ_QueryParam
GNUNET_PQ_query_param_uint64 (const uint64_t *x)
{
- struct GNUNET_PQ_QueryParam res =
- { &qconv_uint64, NULL, x, sizeof(*x), 1 };
+ struct GNUNET_PQ_QueryParam res = {
+ &qconv_uint64, NULL, x, sizeof(*x), 1
+ };
return res;
}
@@ -339,8 +353,9 @@ struct GNUNET_PQ_QueryParam
GNUNET_PQ_query_param_rsa_public_key (const struct
GNUNET_CRYPTO_RsaPublicKey *x)
{
- struct GNUNET_PQ_QueryParam res =
- { &qconv_rsa_public_key, NULL, (x), 0, 1 };
+ struct GNUNET_PQ_QueryParam res = {
+ &qconv_rsa_public_key, NULL, (x), 0, 1
+ };
return res;
}
@@ -391,8 +406,9 @@ qconv_rsa_signature (void *cls,
struct GNUNET_PQ_QueryParam
GNUNET_PQ_query_param_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *x)
{
- struct GNUNET_PQ_QueryParam res =
- { &qconv_rsa_signature, NULL, (x), 0, 1 };
+ struct GNUNET_PQ_QueryParam res = {
+ &qconv_rsa_signature, NULL, (x), 0, 1
+ };
return res;
}
@@ -446,8 +462,9 @@ qconv_rel_time (void *cls,
struct GNUNET_PQ_QueryParam
GNUNET_PQ_query_param_relative_time (const struct GNUNET_TIME_Relative *x)
{
- struct GNUNET_PQ_QueryParam res =
- { &qconv_rel_time, NULL, x, sizeof(*x), 1 };
+ struct GNUNET_PQ_QueryParam res = {
+ &qconv_rel_time, NULL, x, sizeof(*x), 1
+ };
return res;
}
@@ -510,8 +527,8 @@ GNUNET_PQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x)
struct GNUNET_PQ_QueryParam
-GNUNET_PQ_query_param_absolute_time_nbo (const struct
- GNUNET_TIME_AbsoluteNBO *x)
+GNUNET_PQ_query_param_absolute_time_nbo (
+ const struct GNUNET_TIME_AbsoluteNBO *x)
{
return GNUNET_PQ_query_param_auto_from_type (&x->abs_value_us__);
}
diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c
index 23fb4f96e..4057772ec 100644
--- a/src/pq/pq_result_helper.c
+++ b/src/pq/pq_result_helper.c
@@ -127,10 +127,13 @@ GNUNET_PQ_result_spec_variable_size (const char *name,
void **dst,
size_t *sptr)
{
- struct GNUNET_PQ_ResultSpec res =
- { &extract_varsize_blob,
- &clean_varsize_blob, NULL,
- (void *) (dst), 0, name, sptr };
+ struct GNUNET_PQ_ResultSpec res = {
+ .conv = &extract_varsize_blob,
+ .cleaner = &clean_varsize_blob,
+ .dst = (void *) (dst),
+ .fname = name,
+ .result_size = sptr
+ };
return res;
}
@@ -207,10 +210,12 @@ GNUNET_PQ_result_spec_fixed_size (const char *name,
void *dst,
size_t dst_size)
{
- struct GNUNET_PQ_ResultSpec res =
- { &extract_fixed_blob,
- NULL, NULL,
- (dst), dst_size, name, NULL };
+ struct GNUNET_PQ_ResultSpec res = {
+ .conv = &extract_fixed_blob,
+ .dst = (dst),
+ .dst_size = dst_size,
+ .fname = name
+ };
return res;
}
@@ -301,11 +306,12 @@ struct GNUNET_PQ_ResultSpec
GNUNET_PQ_result_spec_rsa_public_key (const char *name,
struct GNUNET_CRYPTO_RsaPublicKey **rsa)
{
- struct GNUNET_PQ_ResultSpec res =
- { &extract_rsa_public_key,
- &clean_rsa_public_key,
- NULL,
- (void *) rsa, 0, name, NULL };
+ struct GNUNET_PQ_ResultSpec res = {
+ .conv = &extract_rsa_public_key,
+ .cleaner = &clean_rsa_public_key,
+ .dst = (void *) rsa,
+ .fname = name
+ };
return res;
}
@@ -395,11 +401,12 @@ struct GNUNET_PQ_ResultSpec
GNUNET_PQ_result_spec_rsa_signature (const char *name,
struct GNUNET_CRYPTO_RsaSignature **sig)
{
- struct GNUNET_PQ_ResultSpec res =
- { &extract_rsa_signature,
- &clean_rsa_signature,
- NULL,
- (void *) sig, 0, (name), NULL };
+ struct GNUNET_PQ_ResultSpec res = {
+ .conv = &extract_rsa_signature,
+ .cleaner = &clean_rsa_signature,
+ .dst = (void *) sig,
+ .fname = name
+ };
return res;
}
@@ -489,11 +496,82 @@ struct GNUNET_PQ_ResultSpec
GNUNET_PQ_result_spec_string (const char *name,
char **dst)
{
- struct GNUNET_PQ_ResultSpec res =
- { &extract_string,
- &clean_string,
- NULL,
- (void *) dst, 0, (name), NULL };
+ struct GNUNET_PQ_ResultSpec res = {
+ .conv = &extract_string,
+ .cleaner = &clean_string,
+ .dst = (void *) dst,
+ .fname = (name)
+ };
+
+ return res;
+}
+
+
+/**
+ * Extract data from a Postgres database @a result at row @a row.
+ *
+ * @param cls closure
+ * @param result where to extract data from
+ * @param int row to extract data from
+ * @param fname name (or prefix) of the fields to extract from
+ * @param[in,out] dst_size where to store size of result, may be NULL
+ * @param[out] dst where to store the result
+ * @return
+ * #GNUNET_YES if all results could be extracted
+ * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL)
+ */
+static enum GNUNET_GenericReturnValue
+extract_bool (void *cls,
+ PGresult *result,
+ int row,
+ const char *fname,
+ size_t *dst_size,
+ void *dst)
+{
+ bool *b = dst;
+ const uint8_t *res;
+ int fnum;
+ size_t len;
+
+ (void) cls;
+ fnum = PQfnumber (result,
+ fname);
+ if (fnum < 0)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ if (PQgetisnull (result,
+ row,
+ fnum))
+ return GNUNET_NO;
+ /* if a field is null, continue but
+ * remember that we now return a different result */
+ len = PQgetlength (result,
+ row,
+ fnum);
+ if (sizeof (uint8_t) != len)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ res = (const uint8_t *) PQgetvalue (result,
+ row,
+ fnum);
+ *b = (0 != *res);
+ return GNUNET_OK;
+}
+
+
+struct GNUNET_PQ_ResultSpec
+GNUNET_PQ_result_spec_bool (const char *name,
+ bool *dst)
+{
+ struct GNUNET_PQ_ResultSpec res = {
+ .conv = &extract_bool,
+ .dst = (void *) dst,
+ .fname = name
+ };
return res;
}
@@ -566,13 +644,10 @@ GNUNET_PQ_result_spec_relative_time (const char *name,
struct GNUNET_TIME_Relative *rt)
{
struct GNUNET_PQ_ResultSpec res = {
- &extract_rel_time,
- NULL,
- NULL,
- (void *) rt,
- sizeof(*rt),
- name,
- NULL
+ .conv = &extract_rel_time,
+ .dst = (void *) rt,
+ .dst_size = sizeof(*rt),
+ .fname = name
};
return res;
@@ -645,11 +720,12 @@ struct GNUNET_PQ_ResultSpec
GNUNET_PQ_result_spec_absolute_time (const char *name,
struct GNUNET_TIME_Absolute *at)
{
- struct GNUNET_PQ_ResultSpec res =
- { &extract_abs_time,
- NULL,
- NULL,
- (void *) at, sizeof(*at), (name), NULL };
+ struct GNUNET_PQ_ResultSpec res = {
+ .conv = &extract_abs_time,
+ .dst = (void *) at,
+ .dst_size = sizeof(*at),
+ .fname = name
+ };
return res;
}
@@ -660,7 +736,8 @@ GNUNET_PQ_result_spec_absolute_time_nbo (const char *name,
struct GNUNET_TIME_AbsoluteNBO *at)
{
struct GNUNET_PQ_ResultSpec res =
- GNUNET_PQ_result_spec_auto_from_type (name, &at->abs_value_us__);
+ GNUNET_PQ_result_spec_auto_from_type (name,
+ &at->abs_value_us__);
return res;
}
@@ -729,11 +806,12 @@ struct GNUNET_PQ_ResultSpec
GNUNET_PQ_result_spec_uint16 (const char *name,
uint16_t *u16)
{
- struct GNUNET_PQ_ResultSpec res =
- { &extract_uint16,
- NULL,
- NULL,
- (void *) u16, sizeof(*u16), (name), NULL };
+ struct GNUNET_PQ_ResultSpec res = {
+ .conv = &extract_uint16,
+ .dst = (void *) u16,
+ .dst_size = sizeof(*u16),
+ .fname = name
+ };
return res;
}
@@ -803,13 +881,10 @@ GNUNET_PQ_result_spec_uint32 (const char *name,
uint32_t *u32)
{
struct GNUNET_PQ_ResultSpec res = {
- &extract_uint32,
- NULL,
- NULL,
- (void *) u32,
- sizeof(*u32),
- (name),
- NULL
+ .conv = &extract_uint32,
+ .dst = (void *) u32,
+ .dst_size = sizeof(*u32),
+ .fname = name
};
return res;
@@ -884,13 +959,10 @@ GNUNET_PQ_result_spec_uint64 (const char *name,
uint64_t *u64)
{
struct GNUNET_PQ_ResultSpec res = {
- &extract_uint64,
- NULL,
- NULL,
- (void *) u64,
- sizeof(*u64),
- (name),
- NULL
+ .conv = &extract_uint64,
+ .dst = (void *) u64,
+ .dst_size = sizeof(*u64),
+ .fname = name
};
return res;
diff --git a/src/pt/Makefile.am b/src/pt/Makefile.am
index 10ae04931..fc2cb592c 100644
--- a/src/pt/Makefile.am
+++ b/src/pt/Makefile.am
@@ -28,8 +28,6 @@ gnunet_daemon_pt_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
$(GN_LIBINTL)
-if HAVE_TESTING
-
if HAVE_LIBGNURL
LIB_GNURL=@LIBGNURL@
CPP_GNURL=@LIBGNURL_CPPFLAGS@
@@ -56,8 +54,6 @@ endif
endif
endif
-endif
-
check_PROGRAMS = $(VPN_TEST)
if ENABLE_TEST_RUN
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c
index cefb66b8f..da5f90409 100644
--- a/src/reclaim/gnunet-reclaim.c
+++ b/src/reclaim/gnunet-reclaim.c
@@ -521,7 +521,7 @@ iter_cb (void *cls,
char *id;
const char *attr_type;
- if ((NULL != attr_name) && (NULL != claim))
+ if ((NULL != attr_name) && (NULL == claim))
{
if (0 == strcasecmp (attr_name, attr->name))
{
@@ -530,6 +530,7 @@ iter_cb (void *cls,
attr->type,
attr->data,
attr->data_size);
+ claim->id = attr->id;
}
}
else if (issue_attrs)
@@ -830,7 +831,7 @@ main (int argc, char *const argv[])
GNUNET_GETOPT_option_string ('a',
"add",
"NAME",
- gettext_noop ("Add an attribute NAME"),
+ gettext_noop ("Add or update an attribute NAME"),
&attr_name),
GNUNET_GETOPT_option_string ('d',
"delete",
diff --git a/src/regex/Makefile.am b/src/regex/Makefile.am
index 9a7466cb2..2dbf3a3f9 100644
--- a/src/regex/Makefile.am
+++ b/src/regex/Makefile.am
@@ -102,11 +102,9 @@ libgnunetregextest_a_LIBADD = \
$(top_builddir)/src/util/libgnunetutil.la \
libgnunetregex_internal.a
-if HAVE_TESTING
noinst_PROGRAMS = $(noinst_mysql_progs) \
perf-regex \
gnunet-regex-profiler
-endif
perf_regex_SOURCES = \
perf-regex.c
diff --git a/src/rps/Makefile.am b/src/rps/Makefile.am
index b9de6b5e3..b5e8c0617 100644
--- a/src/rps/Makefile.am
+++ b/src/rps/Makefile.am
@@ -45,10 +45,8 @@ libgnunetrps_la_CFLAGS = $(AM_CFLAGS)
libexec_PROGRAMS = \
gnunet-service-rps
-if HAVE_TESTING
noinst_PROGRAMS = \
gnunet-rps-profiler
-endif
gnunet_service_rps_SOURCES = \
@@ -74,7 +72,6 @@ gnunet_service_rps_LDADD = \
$(GN_LIBINTL)
-if HAVE_TESTING
check_PROGRAMS = \
test_service_rps_view \
test_service_rps_custommap \
@@ -91,7 +88,6 @@ check_PROGRAMS += \
test_rps_malicious_2 \
test_rps_malicious_3
endif
-endif
rps_test_src = \
test_rps.c \
diff --git a/src/secretsharing/Makefile.am b/src/secretsharing/Makefile.am
index 9ae6e7892..13dd0bd8d 100644
--- a/src/secretsharing/Makefile.am
+++ b/src/secretsharing/Makefile.am
@@ -51,7 +51,6 @@ libgnunetsecretsharing_la_LIBADD = \
libgnunetsecretsharing_la_LDFLAGS = \
$(GN_LIB_LDFLAGS)
-if HAVE_TESTING
bin_PROGRAMS = \
gnunet-secretsharing-profiler
@@ -62,7 +61,6 @@ if ENABLE_TEST_RUN
AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
TESTS = $(check_PROGRAMS)
endif
-endif
test_secretsharing_api_SOURCES = \
test_secretsharing_api.c
diff --git a/src/set/Makefile.am b/src/set/Makefile.am
index d6b10a1f8..837d42ff5 100644
--- a/src/set/Makefile.am
+++ b/src/set/Makefile.am
@@ -14,13 +14,11 @@ if USE_COVERAGE
AM_CFLAGS = -fprofile-arcs -ftest-coverage
endif
-if HAVE_TESTING
bin_PROGRAMS = \
gnunet-set-profiler
noinst_PROGRAMS = \
gnunet-set-ibf-profiler
-endif
libexec_PROGRAMS = \
gnunet-service-set
@@ -69,13 +67,11 @@ libgnunetset_la_LIBADD = \
libgnunetset_la_LDFLAGS = \
$(GN_LIB_LDFLAGS)
-if HAVE_TESTING
check_PROGRAMS = \
test_set_api \
test_set_union_result_symmetric \
test_set_intersection_result_full \
test_set_union_copy
-endif
if ENABLE_TEST_RUN
AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
diff --git a/src/seti/Makefile.am b/src/seti/Makefile.am
index 522f33ece..8441c5060 100644
--- a/src/seti/Makefile.am
+++ b/src/seti/Makefile.am
@@ -14,10 +14,8 @@ if USE_COVERAGE
AM_CFLAGS = -fprofile-arcs -ftest-coverage
endif
-if HAVE_TESTING
bin_PROGRAMS = \
gnunet-seti-profiler
-endif
libexec_PROGRAMS = \
gnunet-service-seti
@@ -55,10 +53,8 @@ libgnunetseti_la_LIBADD = \
libgnunetseti_la_LDFLAGS = \
$(GN_LIB_LDFLAGS)
-if HAVE_TESTING
check_PROGRAMS = \
test_seti_api
-endif
if ENABLE_TEST_RUN
AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
diff --git a/src/setu/Makefile.am b/src/setu/Makefile.am
index 77d048add..897bf3f86 100644
--- a/src/setu/Makefile.am
+++ b/src/setu/Makefile.am
@@ -14,13 +14,11 @@ if USE_COVERAGE
AM_CFLAGS = -fprofile-arcs -ftest-coverage
endif
-if HAVE_TESTING
bin_PROGRAMS = \
gnunet-setu-profiler
noinst_PROGRAMS = \
gnunet-setu-ibf-profiler
-endif
libexec_PROGRAMS = \
gnunet-service-setu
@@ -67,11 +65,9 @@ libgnunetsetu_la_LIBADD = \
libgnunetsetu_la_LDFLAGS = \
$(GN_LIB_LDFLAGS)
-if HAVE_TESTING
check_PROGRAMS = \
test_setu_api \
perf_setu_api
-endif
if ENABLE_TEST_RUN
AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c
index d6c2680b8..6e6acb3e5 100644
--- a/src/statistics/statistics_api.c
+++ b/src/statistics/statistics_api.c
@@ -270,11 +270,11 @@ update_memory_statistics (struct GNUNET_STATISTICS_Handle *h)
if (GNUNET_NO != h->do_destroy)
return;
-#if HAVE_MALLINFO
+#if HAVE_MALLINFO2
{
- struct mallinfo mi;
+ struct mallinfo2 mi;
- mi = mallinfo ();
+ mi = mallinfo2 ();
current_heap_size = mi.uordblks + mi.fordblks;
}
#endif
diff --git a/src/testbed/gnunet-testbed-profiler.c b/src/testbed/gnunet-testbed-profiler.c
index b07c725a3..49d975119 100644
--- a/src/testbed/gnunet-testbed-profiler.c
+++ b/src/testbed/gnunet-testbed-profiler.c
@@ -227,11 +227,9 @@ test_run (void *cls,
abort_task = NULL;
return;
}
-#if (! ENABLE_SUPERMUC)
fprintf (stdout, "Testbed running, waiting for keystroke to shut down\n");
fflush (stdout);
(void) getc (stdin);
-#endif
fprintf (stdout, "Shutting down. Please wait\n");
fflush (stdout);
GNUNET_SCHEDULER_shutdown ();
@@ -297,14 +295,12 @@ main (int argc, char *const *argv)
"keystroke but continues to run until a termination "
"signal is received"),
&noninteractive),
-#if ! ENABLE_SUPERMUC
GNUNET_GETOPT_option_string ('H',
"hosts",
"FILENAME",
gettext_noop (
"name of the file with the login information for the testbed"),
&hosts_file),
-#endif
GNUNET_GETOPT_OPTION_END
};
const char *binaryHelp = "gnunet-testbed-profiler [OPTIONS]";
diff --git a/src/testbed/gnunet_testbed_mpi_spawn.c b/src/testbed/gnunet_testbed_mpi_spawn.c
deleted file mode 100644
index 577ffbeba..000000000
--- a/src/testbed/gnunet_testbed_mpi_spawn.c
+++ /dev/null
@@ -1,327 +0,0 @@
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_testbed_service.h"
-
-
-/**
- * Generic logging shorthand
- */
-#define LOG(kind, ...) \
- GNUNET_log (kind, __VA_ARGS__)
-
-/**
- * Debug logging shorthand
- */
-#define LOG_DEBUG(...) \
- LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
-
-/**
- * Global result
- */
-static int ret;
-
-/**
- * The child process we spawn
- */
-static struct GNUNET_OS_Process *child;
-
-/**
- * The arguments including the binary to spawn
- */
-static char **argv2;
-
-/**
- * Pipe used to communicate shutdown via signal.
- */
-static struct GNUNET_DISK_PipeHandle *sigpipe;
-
-/**
- * Filename of the unique file
- */
-static char *fn;
-
-/**
- * Handle to the unique file
- */
-static int fh;
-
-/**
- * The return code of the binary
- */
-static unsigned long child_exit_code;
-
-/**
- * The process status of the child
- */
-static enum GNUNET_OS_ProcessStatusType child_status;
-
-/**
- * Task to kill the child
- */
-static struct GNUNET_SCHEDULER_Task *terminate_task_id;
-
-/**
- * Task to kill the child
- */
-static struct GNUNET_SCHEDULER_Task *child_death_task_id;
-
-/**
- * The shutdown task
- */
-static void
-shutdown_task (void *cls)
-{
- if (0 != child_exit_code)
- {
- LOG (GNUNET_ERROR_TYPE_WARNING, "Child exited with error code: %lu\n",
- child_exit_code);
- ret = 128 + (int) child_exit_code;
- }
- if (0 != fh)
- {
- close (fh);
- }
- if ((NULL != fn) && (0 != unlink (fn)))
- {
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "open");
- ret = GNUNET_SYSERR;
- }
-}
-
-
-static void
-terminate_task (void *cls)
-{
- static int hard_kill;
-
- GNUNET_assert (NULL != child);
- terminate_task_id =
- GNUNET_SCHEDULER_add_shutdown (&terminate_task, NULL);
- if (0 != hard_kill)
- {
- switch (hard_kill)
- {
- case 1:
- case 2:
- LOG (GNUNET_ERROR_TYPE_WARNING,
- "%d more interrupts needed to send SIGKILL to the child\n",
- 3 - hard_kill);
- hard_kill++;
- return;
-
- case 3:
- GNUNET_break (0 == GNUNET_OS_process_kill (child, SIGKILL));
- return;
- }
- }
- hard_kill++;
- GNUNET_break (0 == GNUNET_OS_process_kill (child, GNUNET_TERM_SIG));
- LOG (GNUNET_ERROR_TYPE_INFO, _ ("Waiting for child to exit.\n"));
-}
-
-
-/**
- * Task triggered whenever we receive a SIGCHLD (child
- * process died).
- *
- * @param cls closure, NULL if we need to self-restart
- */
-static void
-child_death_task (void *cls)
-{
- const struct GNUNET_DISK_FileHandle *pr;
- char c[16];
- const struct GNUNET_SCHEDULER_TaskContext *tc;
-
-
- pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ);
- child_death_task_id = NULL;
- tc = GNUNET_SCHEDULER_get_task_context ();
- if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY))
- {
- child_death_task_id =
- GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
- pr, &child_death_task, NULL);
- return;
- }
- /* consume the signal */
- GNUNET_break (0 < GNUNET_DISK_file_read (pr, &c, sizeof(c)));
- LOG_DEBUG ("Child died\n");
- GNUNET_SCHEDULER_cancel (terminate_task_id);
- terminate_task_id = NULL;
- GNUNET_assert (GNUNET_OK == GNUNET_OS_process_status (child, &child_status,
- &child_exit_code));
- GNUNET_OS_process_destroy (child);
- child = NULL;
- GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
-}
-
-
-static void
-destroy_hosts (struct GNUNET_TESTBED_Host **hosts, unsigned int nhosts)
-{
- unsigned int host;
-
- GNUNET_assert (NULL != hosts);
- for (host = 0; host < nhosts; host++)
- if (NULL != hosts[host])
- GNUNET_TESTBED_host_destroy (hosts[host]);
- GNUNET_free (hosts);
- hosts = NULL;
-}
-
-
-/**
- * The main scheduler run task
- *
- * @param cls NULL
- */
-static void
-run (void *cls)
-{
- struct GNUNET_TESTBED_Host **hosts;
- const struct GNUNET_CONFIGURATION_Handle *null_cfg;
- char *tmpdir;
- char *hostname;
- size_t hostname_len;
- unsigned int nhosts;
-
- null_cfg = GNUNET_CONFIGURATION_create ();
- nhosts = GNUNET_TESTBED_hosts_load_from_loadleveler (null_cfg, &hosts);
- if (0 == nhosts)
- {
- GNUNET_break (0);
- ret = GNUNET_SYSERR;
- return;
- }
- hostname_len = GNUNET_OS_get_hostname_max_length ();
- hostname = GNUNET_malloc (hostname_len);
- if (0 != gethostname (hostname, hostname_len))
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Cannot get hostname. Exiting\n");
- GNUNET_free (hostname);
- destroy_hosts (hosts, nhosts);
- ret = GNUNET_SYSERR;
- return;
- }
- if (NULL == strstr (GNUNET_TESTBED_host_get_hostname (hosts[0]), hostname))
- {
- LOG_DEBUG ("Exiting as `%s' is not the lowest host\n", hostname);
- GNUNET_free (hostname);
- ret = GNUNET_OK;
- return;
- }
- LOG_DEBUG ("Will be executing `%s' on host `%s'\n", argv2[0], hostname);
- GNUNET_free (hostname);
- destroy_hosts (hosts, nhosts);
- tmpdir = getenv ("TMPDIR");
- if (NULL == tmpdir)
- tmpdir = getenv ("TMP");
- if (NULL == tmpdir)
- tmpdir = getenv ("TEMP");
- if (NULL == tmpdir)
- tmpdir = "/tmp";
- (void) GNUNET_asprintf (&fn, "%s/gnunet-testbed-spawn.lock", tmpdir);
- /* Open the unique file; we can create it then we can spawn the child process
- else we exit */
- fh = open (fn, O_CREAT | O_EXCL | O_CLOEXEC,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
- if (-1 == fh)
- {
- if (EEXIST == errno)
- {
- LOG_DEBUG ("Lock file already created by other process. Exiting\n");
- ret = GNUNET_OK;
- return;
- }
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "open");
- ret = GNUNET_SYSERR;
- return;
- }
- /* Spawn the new process here */
- LOG (GNUNET_ERROR_TYPE_INFO, _ ("Spawning process `%s'\n"), argv2[0]);
- child = GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL,
- NULL,
- NULL, NULL,
- argv2[0], argv2);
- if (NULL == child)
- {
- GNUNET_break (0);
- ret = GNUNET_SYSERR;
- GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
- return;
- }
- ret = GNUNET_OK;
- terminate_task_id =
- GNUNET_SCHEDULER_add_shutdown (&terminate_task, NULL);
- child_death_task_id =
- GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_DISK_pipe_handle (sigpipe,
- GNUNET_DISK_PIPE_END_READ),
- &child_death_task, NULL);
-}
-
-
-/**
- * Signal handler called for SIGCHLD.
- */
-static void
-sighandler_child_death ()
-{
- static char c;
- int old_errno = errno; /* back-up errno */
-
- GNUNET_break (1 ==
- GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle
- (sigpipe, GNUNET_DISK_PIPE_END_WRITE),
- &c, sizeof(c)));
- errno = old_errno; /* restore errno */
-}
-
-
-/**
- * Execution start point
- */
-int
-main (int argc, char *argv[])
-{
- struct GNUNET_SIGNAL_Context *shc_chld;
- unsigned int cnt;
-
- ret = -1;
- if (argc < 2)
- {
- printf ("Need arguments: gnunet-testbed-mpi-spawn <cmd> <cmd_args>");
- return 1;
- }
- if (GNUNET_OK != GNUNET_log_setup ("gnunet-testbed-spawn", NULL, NULL))
- {
- GNUNET_break (0);
- return 1;
- }
- if (NULL == (sigpipe = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE)))
- {
- GNUNET_break (0);
- ret = GNUNET_SYSERR;
- return 1;
- }
- shc_chld =
- GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death);
- if (NULL == shc_chld)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Cannot install a signal handler\n");
- return 1;
- }
- argv2 = GNUNET_malloc (sizeof(char *) * argc);
- for (cnt = 1; cnt < argc; cnt++)
- argv2[cnt - 1] = argv[cnt];
- GNUNET_SCHEDULER_run (run, NULL);
- GNUNET_free (argv2);
- GNUNET_SIGNAL_handler_uninstall (shc_chld);
- shc_chld = NULL;
- GNUNET_DISK_pipe_close (sigpipe);
- GNUNET_free (fn);
- if (GNUNET_OK != ret)
- return ret;
- return 0;
-}
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c
index 1a8d9976d..8dd0a4893 100644
--- a/src/testbed/testbed_api_hosts.c
+++ b/src/testbed/testbed_api_hosts.c
@@ -568,41 +568,6 @@ simple_resolve (const char *host)
/**
- * Loads the set of host allocated by the LoadLeveler Job Scheduler. This
- * function is only available when compiled with support for LoadLeveler and is
- * used for running on the SuperMUC
- *
- * @param cfg the configuration to use as a template while starting a controller
- * on any of the loaded hosts. Operation queue sizes specific to a host
- * are also read from this configuration handle
- * @param hosts set to the hosts found in the file; caller must free this if
- * number of hosts returned is greater than 0
- * @return number of hosts returned in 'hosts', 0 on error
- */
-unsigned int
-GNUNET_TESTBED_hosts_load_from_loadleveler (
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTBED_Host ***hosts)
-{
-#if ! ENABLE_SUPERMUC
- LOG (GNUNET_ERROR_TYPE_ERROR,
- _ ("The function %s is only available when compiled with (--with-ll)\n"),
- __func__);
- GNUNET_assert (0);
-#else
- const char *hostfile;
-
- if (NULL == (hostfile = getenv ("MP_SAVEHOSTFILE")))
- {
- GNUNET_break (0);
- return 0;
- }
- return GNUNET_TESTBED_hosts_load_from_file (hostfile, cfg, hosts);
-#endif
-}
-
-
-/**
* Destroy a host handle. Must only be called once everything
* running on that host has been stopped.
*
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c
index e9b9979ce..e0b76ad78 100644
--- a/src/testbed/testbed_api_testbed.c
+++ b/src/testbed/testbed_api_testbed.c
@@ -1265,16 +1265,6 @@ GNUNET_TESTBED_run (const char *host_filename,
GNUNET_assert (num_peers > 0);
rc = GNUNET_new (struct GNUNET_TESTBED_RunHandle);
rc->cfg = GNUNET_CONFIGURATION_dup (cfg);
-#if ENABLE_SUPERMUC
- rc->num_hosts = GNUNET_TESTBED_hosts_load_from_loadleveler (rc->cfg,
- &rc->hosts);
- if (0 == rc->num_hosts)
- {
- LOG (GNUNET_ERROR_TYPE_WARNING,
- _ ("No hosts loaded from LoadLeveler. Need at least one host\n"));
- goto error_cleanup;
- }
-#else
if (NULL != host_filename)
{
rc->num_hosts =
@@ -1289,7 +1279,6 @@ GNUNET_TESTBED_run (const char *host_filename,
}
else
rc->h = GNUNET_TESTBED_host_create (NULL, NULL, rc->cfg, 0);
-#endif
rc->num_peers = num_peers;
rc->event_mask = event_mask;
rc->cc = cc;
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index a584ad761..bcb45da70 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -6,6 +6,8 @@ if USE_COVERAGE
XLIB = -lgcov
endif
+libexecdir= $(pkglibdir)/libexec/
+
pkgcfgdir= $(pkgdatadir)/config.d/
dist_pkgcfg_DATA = \
@@ -16,9 +18,6 @@ libexec_PROGRAMS = \
plugindir = $(libdir)/gnunet
-plugin_LTLIBRARIES = \
- libgnunet_test_testing_plugin_testcmd.la
-
lib_LTLIBRARIES = \
libgnunettesting.la
@@ -29,39 +28,22 @@ gnunet_cmds_helper_LDADD = $(XLIB) \
libgnunettesting.la \
$(LTLIBINTL) $(Z_LIBS)
-libgnunet_test_testing_plugin_testcmd_la_SOURCES = \
- test_testing_plugin_testcmd.c
-libgnunet_test_testing_plugin_testcmd_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/arm/libgnunetarm.la \
- libgnunettesting.la \
- $(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(LTLIBINTL)
-libgnunet_test_testing_plugin_testcmd_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-
libgnunettesting_la_SOURCES = \
+ testing_api_cmd_end.c \
+ testing_api_cmd_finish.c \
testing_api_cmd_local_test_finished.c \
+ testing_api_cmd_local_test_prepared.c \
testing_api_cmd_send_peer_ready.c \
- testing_api_cmd_block_until_all_peers_started.c \
testing_api_cmd_block_until_external_trigger.c \
testing_api_cmd_netjail_start.c \
- testing_api_cmd_netjail_start_v2.c \
testing_api_cmd_netjail_start_testsystem.c \
- testing_api_cmd_netjail_start_testsystem_v2.c \
testing_api_cmd_netjail_stop_testsystem.c \
- testing_api_cmd_netjail_stop_testsystem_v2.c \
testing_api_cmd_netjail_stop.c \
- testing_api_cmd_netjail_stop_v2.c \
testing.c testing.h \
testing_api_cmd_system_create.c \
testing_api_cmd_system_destroy.c \
testing_api_cmd_batch.c \
- testing_api_cmd_hello_world.c \
- testing_api_cmd_hello_world_birth.c \
testing_api_loop.c \
- testing_api_trait_cmd.c \
- testing_api_trait_process.c \
testing_api_traits.c
libgnunettesting_la_LIBADD = \
$(top_builddir)/src/arm/libgnunetarm.la \
@@ -92,9 +74,6 @@ list_keys_LDADD = \
check_PROGRAMS = \
- test_testing_topology \
- test_testing_api_cmd_netjail \
- test_testing_hello_world \
test_testing_portreservation \
test_testing_servicestartup \
test_testing_peerstartup \
@@ -104,33 +83,12 @@ check_PROGRAMS = \
if ENABLE_TEST_RUN
AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
TESTS = \
- test_testing_topology \
- test_testing_api_cmd_netjail \
- test_testing_hello_world \
test_testing_portreservation \
test_testing_peerstartup \
test_testing_peerstartup2 \
test_testing_servicestartup
endif
-test_testing_topology_SOURCES = \
- test_testing_topology.c
-test_testing_topology_LDADD = \
- libgnunettesting.la \
- $(top_builddir)/src/util/libgnunetutil.la
-
-test_testing_api_cmd_netjail_SOURCES = \
- test_testing_api_cmd_netjail.c
-test_testing_api_cmd_netjail_LDADD = \
- libgnunettesting.la \
- $(top_builddir)/src/util/libgnunetutil.la
-
-test_testing_hello_world_SOURCES = \
- test_testing_hello_world.c
-test_testing_hello_world_LDADD = \
- libgnunettesting.la \
- $(top_builddir)/src/util/libgnunetutil.la
-
test_testing_portreservation_SOURCES = \
test_testing_portreservation.c
test_testing_portreservation_LDADD = \
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c
index 8f9e77709..5ff7c04ea 100644
--- a/src/testing/gnunet-cmds-helper.c
+++ b/src/testing/gnunet-cmds-helper.c
@@ -57,6 +57,8 @@ testing_api_cmd_block_until_all_peers_started.c */
#define NODE_BASE_IP "192.168.15."
+#define KNOWN_BASE_IP "92.68.151."
+
#define ROUTER_BASE_IP "92.68.150."
/**
@@ -140,6 +142,16 @@ struct NodeIdentifier
*
*/
char *local_m;
+
+ /**
+ * Shall we read the topology from file, or from a string.
+ */
+ unsigned int *read_file;
+
+ /**
+ * String with topology data or name of topology file.
+ */
+ char *topology_data;
};
/**
@@ -343,6 +355,7 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message)
size_t msg_length;
char *router_ip;
char *node_ip;
+ unsigned int namespace_n;
msize = ntohs (message->size);
if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT == ntohs (message->type))
@@ -378,14 +391,29 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message)
strcpy (router_ip, ROUTER_BASE_IP);
strcat (router_ip, plugin->n);
- node_ip = GNUNET_malloc (strlen (NODE_BASE_IP) + strlen (plugin->m) + 1);
- strcat (node_ip, NODE_BASE_IP);
+ sscanf (plugin->n, "%u", &namespace_n);
+
+ if (0 == namespace_n)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "known node n: %s\n",
+ plugin->n);
+ node_ip = GNUNET_malloc (strlen (KNOWN_BASE_IP) + strlen (plugin->m) + 1);
+ strcat (node_ip, KNOWN_BASE_IP);
+ }
+ else
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "subnet node n: %s\n",
+ plugin->n);
+ node_ip = GNUNET_malloc (strlen (NODE_BASE_IP) + strlen (plugin->m) + 1);
+ strcat (node_ip, NODE_BASE_IP);
+ }
strcat (node_ip, plugin->m);
plugin->api->start_testcase (&write_message, router_ip, node_ip, plugin->m,
- plugin->n, plugin->local_m);
-
- GNUNET_free (binary);
+ plugin->n, plugin->local_m, ni->topology_data,
+ ni->read_file);
msg_length = sizeof(struct GNUNET_CMDS_HelperReply);
reply = GNUNET_new (struct GNUNET_CMDS_HelperReply);
@@ -394,14 +422,28 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message)
write_message ((struct GNUNET_MessageHeader *) reply, msg_length);
+ GNUNET_free (binary);
+ GNUNET_free (router_ip);
+ GNUNET_free (plugin_name);
+
return GNUNET_OK;
}
else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs (
message->type))
{
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "all peers started\n");
plugin->api->all_peers_started ();
return GNUNET_OK;
}
+ else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED == ntohs (
+ message->type))
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "all local tests prepared\n");
+ plugin->api->all_local_tests_prepared ();
+ return GNUNET_OK;
+ }
else
{
LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n");
@@ -530,6 +572,10 @@ main (int argc, char **argv)
struct GNUNET_GETOPT_CommandLineOption options[] =
{ GNUNET_GETOPT_OPTION_END };
int ret;
+ int i;
+ size_t topology_data_length = 0;
+ unsigned int read_file;
+ char cr[1] = "\n";
GNUNET_log_setup ("gnunet-cmds-helper",
"DEBUG",
@@ -540,6 +586,30 @@ main (int argc, char **argv)
ni->m = argv[3];
ni->n = argv[4];
+ sscanf (argv[5], "%u", &read_file);
+
+ if (1 == read_file)
+ ni->topology_data = argv[6];
+ else
+ {
+ for (i = 6; i<argc; i++)
+ topology_data_length += strlen (argv[i]) + 1;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "topo data length %lu\n",
+ topology_data_length);
+ ni->topology_data = GNUNET_malloc (topology_data_length);
+ for (i = 6; i<argc; i++)
+ {
+ strcat (ni->topology_data, argv[i]);
+ strcat (ni->topology_data, cr);
+ }
+ }
+ ni->read_file = &read_file;
+ ni->topology_data[topology_data_length - 1] = '\0';
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "topo data %s\n",
+ ni->topology_data);
+
status = GNUNET_OK;
if (NULL ==
(sigpipe = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE)))
diff --git a/src/testing/netjail_core.sh b/src/testing/netjail_core.sh
index cf350d3fa..ef0a54a5e 100755
--- a/src/testing/netjail_core.sh
+++ b/src/testing/netjail_core.sh
@@ -2,6 +2,7 @@
#
+PREFIX=${PPID:?must run from a parent process}
# running with `sudo` is required to be
# able running the actual commands as the
@@ -9,10 +10,61 @@
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
-netjail_check() {
- NODE_COUNT=$1
+export RESULT=
+export NAMESPACE_NUM=0
+export INTERFACE_NUM=0
+
+netjail_next_namespace() {
+ local NUM=$NAMESPACE_NUM
+ NAMESPACE_NUM=$(($NAMESPACE_NUM + 1))
+ RESULT=$NUM
+}
+
+netjail_next_interface() {
+ local NUM=$INTERFACE_NUM
+ INTERFACE_NUM=$(($INTERFACE_NUM + 1))
+ RESULT=$NUM
+}
+
+netjail_opt() {
+ local OPT=$1
+ shift 1
+
+ INDEX=1
+
+ while [ $# -gt 0 ]; do
+ if [ "$1" = "$OPT" ]; then
+ RESULT=$INDEX
+ return
+ fi
+
+ INDEX=$(($INDEX + 1))
+ shift 1
+ done
+
+ RESULT=0
+}
+
+netjail_opts() {
+ local OPT=$1
+ local DEF=$2
+ shift 2
+
+ while [ $# -gt 0 ]; do
+ if [ "$1" = "$OPT" ]; then
+ printf "$2"
+ return
+ fi
+
+ shift 1
+ done
+
+ RESULT="$DEF"
+}
- FD_COUNT=$(($(ls /proc/self/fd | wc -w) - 4))
+netjail_check() {
+ local NODE_COUNT=$1
+ local FD_COUNT=$(($(ls /proc/self/fd | wc -w) - 4))
# quit if `$FD_COUNT < ($LOCAL_M * $GLOBAL_N * 2)`:
# the script also requires `sudo -C ($FD_COUNT + 4)`
@@ -25,43 +77,81 @@ netjail_check() {
fi
}
-netjail_print_name() {
- printf "%s%02x%02x" $1 $2 ${3:-0}
+netjail_check_bin() {
+ local PROGRAM=$1
+ local MATCH=$(ls $(echo $PATH | tr ":" "\n") | grep "^$PROGRAM\$" | tr "\n" " " | awk '{ print $1 }')
+
+ # quit if the required binary $PROGRAM can not be
+ # found in the used $PATH.
+
+ if [ "$MATCH" != "$PROGRAM" ]; then
+ echo "Required binary not found: $PROGRAM" >&2
+ exit 1
+ fi
}
netjail_bridge() {
- BRIDGE=$1
+ netjail_next_interface
+ local NUM=$RESULT
+ local BRIDGE=$(printf "%06x-%08x" $PREFIX $NUM)
ip link add $BRIDGE type bridge
ip link set dev $BRIDGE up
+
+ RESULT=$BRIDGE
+}
+
+netjail_bridge_name() {
+ netjail_next_interface
+ local NUM=$RESULT
+ local BRIDGE=$(printf "%06x-%08x" $PREFIX $NUM)
+
+ RESULT=$BRIDGE
}
netjail_bridge_clear() {
- BRIDGE=$1
+ local BRIDGE=$1
ip link delete $BRIDGE
}
netjail_node() {
- NODE=$1
+ netjail_next_namespace
+ local NUM=$RESULT
+ local NODE=$(printf "%06x-%08x" $PREFIX $NUM)
ip netns add $NODE
+
+ RESULT=$NODE
+}
+
+netjail_node_name() {
+ netjail_next_namespace
+ local NUM=$RESULT
+ local NODE=$(printf "%06x-%08x" $PREFIX $NUM)
+
+ RESULT=$NODE
}
netjail_node_clear() {
- NODE=$1
+ local NODE=$1
ip netns delete $NODE
}
netjail_node_link_bridge() {
- NODE=$1
- BRIDGE=$2
- ADDRESS=$3
- MASK=$4
+ local NODE=$1
+ local BRIDGE=$2
+ local ADDRESS=$3
+ local MASK=$4
- LINK_IF="$NODE-$BRIDGE-0"
- LINK_BR="$NODE-$BRIDGE-1"
+ netjail_next_interface
+ local NUM_IF=$RESULT
+ netjail_next_interface
+ local NUM_BR=$RESULT
+
+ local LINK_IF=$(printf "%06x-%08x" $PREFIX $NUM_IF)
+ local LINK_BR=$(printf "%06x-%08x" $PREFIX $NUM_BR)
ip link add $LINK_IF type veth peer name $LINK_BR
ip link set $LINK_IF netns $NODE
@@ -72,28 +162,47 @@ netjail_node_link_bridge() {
ip -n $NODE link set up dev lo
ip link set $LINK_BR up
+
+ RESULT=$LINK_BR
+}
+
+netjail_node_link_bridge_name() {
+
+ netjail_next_interface
+ netjail_next_interface
+ local NUM_BR=$RESULT
+
+ local LINK_BR=$(printf "%06x-%08x" $PREFIX $NUM_BR)
+
+ RESULT=$LINK_BR
+}
+
+netjail_node_unlink_bridge() {
+ local LINK_BR=$1
+
+ ip link delete $LINK_BR
}
netjail_node_add_nat() {
- NODE=$1
- ADDRESS=$2
- MASK=$3
+ local NODE=$1
+ local ADDRESS=$2
+ local MASK=$3
ip netns exec $NODE iptables -t nat -A POSTROUTING -s "$ADDRESS/$MASK" -j MASQUERADE
}
netjail_node_add_default() {
- NODE=$1
- ADDRESS=$2
+ local NODE=$1
+ local ADDRESS=$2
ip -n $NODE route add default via $ADDRESS
}
netjail_node_exec() {
JAILOR=${SUDO_USER:?must run in sudo}
- NODE=$1
- FD_IN=$2
- FD_OUT=$3
+ local NODE=$1
+ local FD_IN=$2
+ local FD_OUT=$3
shift 3
ip netns exec $NODE sudo -u $JAILOR -- $@ 1>& $FD_OUT 0<& $FD_IN
@@ -114,3 +223,38 @@ netjail_node_exec_without_fds_and_sudo() {
ip netns exec $NODE $@
}
+netjail_kill() {
+ local PID=$1
+ local MATCH=$(ps --pid $PID | awk "{ if ( \$1 == $PID ) { print \$1 } }" | wc -l)
+
+ if [ $MATCH -gt 0 ]; then
+ kill -n 19 $PID
+
+ for CHILD in $(ps -o pid,ppid -ax | awk "{ if ( \$2 == $PID ) { print \$1 } }"); do
+ netjail_kill $CHILD
+ done
+
+ kill $PID
+ fi
+}
+
+netjail_killall() {
+ if [ $# -gt 0 ]; then
+ local PIDS=$1
+
+ for PID in $PIDS; do
+ netjail_kill $PID
+ done
+ fi
+}
+
+netjail_waitall() {
+ if [ $# -gt 0 ]; then
+ local PIDS=$1
+
+ for PID in $PIDS; do
+ wait $PID
+ done
+ fi
+}
+
diff --git a/src/testing/netjail_core_v2.sh b/src/testing/netjail_core_v2.sh
deleted file mode 100755
index ef0a54a5e..000000000
--- a/src/testing/netjail_core_v2.sh
+++ /dev/null
@@ -1,260 +0,0 @@
-#!/bin/sh
-#
-
-
-PREFIX=${PPID:?must run from a parent process}
-
-# running with `sudo` is required to be
-# able running the actual commands as the
-# original user.
-
-export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
-
-export RESULT=
-export NAMESPACE_NUM=0
-export INTERFACE_NUM=0
-
-netjail_next_namespace() {
- local NUM=$NAMESPACE_NUM
- NAMESPACE_NUM=$(($NAMESPACE_NUM + 1))
- RESULT=$NUM
-}
-
-netjail_next_interface() {
- local NUM=$INTERFACE_NUM
- INTERFACE_NUM=$(($INTERFACE_NUM + 1))
- RESULT=$NUM
-}
-
-netjail_opt() {
- local OPT=$1
- shift 1
-
- INDEX=1
-
- while [ $# -gt 0 ]; do
- if [ "$1" = "$OPT" ]; then
- RESULT=$INDEX
- return
- fi
-
- INDEX=$(($INDEX + 1))
- shift 1
- done
-
- RESULT=0
-}
-
-netjail_opts() {
- local OPT=$1
- local DEF=$2
- shift 2
-
- while [ $# -gt 0 ]; do
- if [ "$1" = "$OPT" ]; then
- printf "$2"
- return
- fi
-
- shift 1
- done
-
- RESULT="$DEF"
-}
-
-netjail_check() {
- local NODE_COUNT=$1
- local FD_COUNT=$(($(ls /proc/self/fd | wc -w) - 4))
-
- # quit if `$FD_COUNT < ($LOCAL_M * $GLOBAL_N * 2)`:
- # the script also requires `sudo -C ($FD_COUNT + 4)`
- # so you need 'Defaults closefrom_override' in the
- # sudoers file.
-
- if [ $FD_COUNT -lt $(($NODE_COUNT * 2)) ]; then
- echo "File descriptors do not match requirements!" >&2
- exit 1
- fi
-}
-
-netjail_check_bin() {
- local PROGRAM=$1
- local MATCH=$(ls $(echo $PATH | tr ":" "\n") | grep "^$PROGRAM\$" | tr "\n" " " | awk '{ print $1 }')
-
- # quit if the required binary $PROGRAM can not be
- # found in the used $PATH.
-
- if [ "$MATCH" != "$PROGRAM" ]; then
- echo "Required binary not found: $PROGRAM" >&2
- exit 1
- fi
-}
-
-netjail_bridge() {
- netjail_next_interface
- local NUM=$RESULT
- local BRIDGE=$(printf "%06x-%08x" $PREFIX $NUM)
-
- ip link add $BRIDGE type bridge
- ip link set dev $BRIDGE up
-
- RESULT=$BRIDGE
-}
-
-netjail_bridge_name() {
- netjail_next_interface
- local NUM=$RESULT
- local BRIDGE=$(printf "%06x-%08x" $PREFIX $NUM)
-
- RESULT=$BRIDGE
-}
-
-netjail_bridge_clear() {
- local BRIDGE=$1
-
- ip link delete $BRIDGE
-}
-
-netjail_node() {
- netjail_next_namespace
- local NUM=$RESULT
- local NODE=$(printf "%06x-%08x" $PREFIX $NUM)
-
- ip netns add $NODE
-
- RESULT=$NODE
-}
-
-netjail_node_name() {
- netjail_next_namespace
- local NUM=$RESULT
- local NODE=$(printf "%06x-%08x" $PREFIX $NUM)
-
- RESULT=$NODE
-}
-
-netjail_node_clear() {
- local NODE=$1
-
- ip netns delete $NODE
-}
-
-netjail_node_link_bridge() {
- local NODE=$1
- local BRIDGE=$2
- local ADDRESS=$3
- local MASK=$4
-
- netjail_next_interface
- local NUM_IF=$RESULT
- netjail_next_interface
- local NUM_BR=$RESULT
-
- local LINK_IF=$(printf "%06x-%08x" $PREFIX $NUM_IF)
- local LINK_BR=$(printf "%06x-%08x" $PREFIX $NUM_BR)
-
- ip link add $LINK_IF type veth peer name $LINK_BR
- ip link set $LINK_IF netns $NODE
- ip link set $LINK_BR master $BRIDGE
-
- ip -n $NODE addr add "$ADDRESS/$MASK" dev $LINK_IF
- ip -n $NODE link set $LINK_IF up
- ip -n $NODE link set up dev lo
-
- ip link set $LINK_BR up
-
- RESULT=$LINK_BR
-}
-
-netjail_node_link_bridge_name() {
-
- netjail_next_interface
- netjail_next_interface
- local NUM_BR=$RESULT
-
- local LINK_BR=$(printf "%06x-%08x" $PREFIX $NUM_BR)
-
- RESULT=$LINK_BR
-}
-
-netjail_node_unlink_bridge() {
- local LINK_BR=$1
-
- ip link delete $LINK_BR
-}
-
-netjail_node_add_nat() {
- local NODE=$1
- local ADDRESS=$2
- local MASK=$3
-
- ip netns exec $NODE iptables -t nat -A POSTROUTING -s "$ADDRESS/$MASK" -j MASQUERADE
-}
-
-netjail_node_add_default() {
- local NODE=$1
- local ADDRESS=$2
-
- ip -n $NODE route add default via $ADDRESS
-}
-
-netjail_node_exec() {
- JAILOR=${SUDO_USER:?must run in sudo}
- local NODE=$1
- local FD_IN=$2
- local FD_OUT=$3
- shift 3
-
- ip netns exec $NODE sudo -u $JAILOR -- $@ 1>& $FD_OUT 0<& $FD_IN
-}
-
-netjail_node_exec_without_fds() {
- JAILOR=${SUDO_USER:?must run in sudo}
- NODE=$1
- shift 1
-
- ip netns exec $NODE sudo -u $JAILOR -- $@
-}
-
-netjail_node_exec_without_fds_and_sudo() {
- NODE=$1
- shift 1
-
- ip netns exec $NODE $@
-}
-
-netjail_kill() {
- local PID=$1
- local MATCH=$(ps --pid $PID | awk "{ if ( \$1 == $PID ) { print \$1 } }" | wc -l)
-
- if [ $MATCH -gt 0 ]; then
- kill -n 19 $PID
-
- for CHILD in $(ps -o pid,ppid -ax | awk "{ if ( \$2 == $PID ) { print \$1 } }"); do
- netjail_kill $CHILD
- done
-
- kill $PID
- fi
-}
-
-netjail_killall() {
- if [ $# -gt 0 ]; then
- local PIDS=$1
-
- for PID in $PIDS; do
- netjail_kill $PID
- done
- fi
-}
-
-netjail_waitall() {
- if [ $# -gt 0 ]; then
- local PIDS=$1
-
- for PID in $PIDS; do
- wait $PID
- done
- fi
-}
-
diff --git a/src/testing/netjail_exec.sh b/src/testing/netjail_exec.sh
index 17a7caaac..cd993a39b 100755
--- a/src/testing/netjail_exec.sh
+++ b/src/testing/netjail_exec.sh
@@ -9,8 +9,6 @@ export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
M=$1
N=$2
-NODE=$(netjail_print_name "N" $N $M)
+NODE=$6
-
-
-netjail_node_exec_without_fds_and_sudo $NODE $3 $4 $5 $1 $2
+netjail_node_exec_without_fds_and_sudo $NODE $3 $4 $5 $1 $2
diff --git a/src/testing/netjail_exec_v2.sh b/src/testing/netjail_exec_v2.sh
deleted file mode 100755
index 597baad20..000000000
--- a/src/testing/netjail_exec_v2.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-. "./../testing/netjail_core_v2.sh"
-
-set -eu
-set -x
-
-export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
-
-M=$1
-N=$2
-
-NODE=$6
-
-netjail_node_exec_without_fds_and_sudo $NODE $3 $4 $5 $1 $2
diff --git a/src/testing/netjail_start.sh b/src/testing/netjail_start.sh
index 0984a3c42..1dfe1dfdf 100755
--- a/src/testing/netjail_start.sh
+++ b/src/testing/netjail_start.sh
@@ -1,52 +1,74 @@
-#!/bin/sh
+#!/bin/bash
. "./../testing/netjail_core.sh"
+. "./../testing/topo.sh"
set -eu
set -x
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
-LOCAL_M=$1
-GLOBAL_N=$2
+filename=$1
+PREFIX=$2
-# TODO: stunserver? ..and globally known peer?
+read_topology $filename
shift 2
LOCAL_GROUP="192.168.15"
GLOBAL_GROUP="92.68.150"
+KNOWN_GROUP="92.68.151"
-NETWORK_NET=$(netjail_print_name "n" $GLOBAL_N $LOCAL_M)
-netjail_bridge $NETWORK_NET
+echo "Start [local: $LOCAL_GROUP.0/24, global: $GLOBAL_GROUP.0/16]"
-for N in $(seq $GLOBAL_N); do
- ROUTER=$(netjail_print_name "R" $N)
+netjail_bridge
+NETWORK_NET=$RESULT
- netjail_node $ROUTER
- netjail_node_link_bridge $ROUTER $NETWORK_NET "$GLOBAL_GROUP.$N" 24
+for X in $(seq $KNOWN); do
+ netjail_node
+ KNOWN_NODES[$X]=$RESULT
+ netjail_node_link_bridge ${KNOWN_NODES[$X]} $NETWORK_NET "$KNOWN_GROUP.$X" 16
+ KNOWN_LINKS[$X]=$RESULT
+done
- ROUTER_NET=$(netjail_print_name "r" $N)
+declare -A NODES
+declare -A NODE_LINKS
- netjail_bridge $ROUTER_NET
+for N in $(seq $GLOBAL_N); do
+ netjail_node
+ ROUTERS[$N]=$RESULT
+ netjail_node_link_bridge ${ROUTERS[$N]} $NETWORK_NET "$GLOBAL_GROUP.$N" 16
+ NETWORK_LINKS[$N]=$RESULT
+ netjail_bridge
+ ROUTER_NETS[$N]=$RESULT
for M in $(seq $LOCAL_M); do
- NODE=$(netjail_print_name "N" $N $M)
-
- netjail_node $NODE
- netjail_node_link_bridge $NODE $ROUTER_NET "$LOCAL_GROUP.$M" 24
+ netjail_node
+ NODES[$N,$M]=$RESULT
+ netjail_node_link_bridge ${NODES[$N,$M]} ${ROUTER_NETS[$N]} "$LOCAL_GROUP.$M" 24
+ NODE_LINKS[$N,$M]=$RESULT
done
ROUTER_ADDR="$LOCAL_GROUP.$(($LOCAL_M+1))"
-
- netjail_node_link_bridge $ROUTER $ROUTER_NET $ROUTER_ADDR 24
- netjail_node_add_nat $ROUTER $ROUTER_ADDR 24
+ netjail_node_link_bridge ${ROUTERS[$N]} ${ROUTER_NETS[$N]} $ROUTER_ADDR 24
+ ROUTER_LINKS[$N]=$RESULT
+
+ netjail_node_add_nat ${ROUTERS[$N]} $ROUTER_ADDR 24
for M in $(seq $LOCAL_M); do
- NODE=$(netjail_print_name "N" $N $M)
-
- netjail_node_add_default $NODE $ROUTER_ADDR
+ netjail_node_add_default ${NODES[$N,$M]} $ROUTER_ADDR
done
-done
-
+ # TODO Topology configuration must be enhanced to configure forwarding to more than one subnet node via different ports.
+
+ if [ "1" == "${R_TCP[$N]}" ]
+ then
+ ip netns exec ${ROUTERS[$N]} iptables -t nat -A PREROUTING -p tcp -d $GLOBAL_GROUP.$N --dport 60002 -j DNAT --to $LOCAL_GROUP.1
+ ip netns exec ${ROUTERS[$N]} iptables -A FORWARD -d $LOCAL_GROUP.1 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
+ fi
+ if [ "1" == "${R_UDP[$N]}" ]
+ then
+ ip netns exec ${ROUTERS[$N]} iptables -t nat -A PREROUTING -p udp -d $GLOBAL_GROUP.$N --dport 60002 -j DNAT --to $LOCAL_GROUP.1
+ ip netns exec ${ROUTERS[$N]} iptables -A FORWARD -d $LOCAL_GROUP.1 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
+ fi
+done
diff --git a/src/testing/netjail_start_v2.sh b/src/testing/netjail_start_v2.sh
deleted file mode 100755
index cf1fe113a..000000000
--- a/src/testing/netjail_start_v2.sh
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/bash
-. "./../testing/netjail_core_v2.sh"
-. "./../testing/topo.sh"
-
-set -eu
-set -x
-
-export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
-
-filename=$1
-PREFIX=$2
-
-read_topology $filename
-
-shift 2
-
-LOCAL_GROUP="192.168.15"
-GLOBAL_GROUP="92.68.150"
-KNOWN_GROUP="92.68.151"
-
-
-echo "Start [local: $LOCAL_GROUP.0/24, global: $GLOBAL_GROUP.0/16]"
-
-netjail_bridge
-NETWORK_NET=$RESULT
-
-for X in $(seq $KNOWN); do
- netjail_node
- KNOWN_NODES[$X]=$RESULT
- netjail_node_link_bridge ${KNOWN_NODES[$X]} $NETWORK_NET "$KNOWN_GROUP.$X" 16
- KNOWN_LINKS[$X]=$RESULT
-done
-
-declare -A NODES
-declare -A NODE_LINKS
-
-for N in $(seq $GLOBAL_N); do
- netjail_node
- ROUTERS[$N]=$RESULT
- netjail_node_link_bridge ${ROUTERS[$N]} $NETWORK_NET "$GLOBAL_GROUP.$N" 16
- NETWORK_LINKS[$N]=$RESULT
- netjail_bridge
- ROUTER_NETS[$N]=$RESULT
-
- for M in $(seq $LOCAL_M); do
- netjail_node
- NODES[$N,$M]=$RESULT
- netjail_node_link_bridge ${NODES[$N,$M]} ${ROUTER_NETS[$N]} "$LOCAL_GROUP.$M" 24
- NODE_LINKS[$N,$M]=$RESULT
- done
-
- ROUTER_ADDR="$LOCAL_GROUP.$(($LOCAL_M+1))"
- netjail_node_link_bridge ${ROUTERS[$N]} ${ROUTER_NETS[$N]} $ROUTER_ADDR 24
- ROUTER_LINKS[$N]=$RESULT
-
- netjail_node_add_nat ${ROUTERS[$N]} $ROUTER_ADDR 24
-
- for M in $(seq $LOCAL_M); do
- netjail_node_add_default ${NODES[$N,$M]} $ROUTER_ADDR
- done
-done
diff --git a/src/testing/netjail_stop.sh b/src/testing/netjail_stop.sh
index 08f68cf7f..abfaf3acf 100755
--- a/src/testing/netjail_stop.sh
+++ b/src/testing/netjail_stop.sh
@@ -1,24 +1,57 @@
-#!/bin/sh
+#!/bin/bash
. "./../testing/netjail_core.sh"
+. "./../testing/topo.sh"
set -eu
set -x
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
-LOCAL_M=$1
-GLOBAL_N=$2
-NETWORK_NET=$(netjail_print_name "n" $GLOBAL_N $LOCAL_M)
+filename=$1
+PREFIX=$2
-shift 2
+read_topology $filename
+
+declare -A NODES
+declare -A NODE_LINKS
+
+netjail_bridge_name
+NETWORK_NET=$RESULT
+
+for X in $(seq $KNOWN); do
+ netjail_node_name
+ KNOWN_NODES[$X]=$RESULT
+ netjail_node_link_bridge_name
+ KNOWN_LINKS[$X]=$RESULT
+ netjail_node_unlink_bridge ${KNOWN_LINKS[$X]}
+ netjail_node_clear ${KNOWN_NODES[$X]}
+done
for N in $(seq $GLOBAL_N); do
+ netjail_node_name
+ ROUTERS[$N]=$RESULT
+ netjail_node_link_bridge_name
+ NETWORK_LINKS[$N]=$RESULT
+ netjail_bridge_name
+ ROUTER_NETS[$N]=$RESULT
+ netjail_node_link_bridge_name
+ ROUTER_LINKS[$N]=$RESULT
+
+ netjail_node_unlink_bridge ${ROUTER_LINKS[$N]}
+
for M in $(seq $LOCAL_M); do
- netjail_node_clear $(netjail_print_name "N" $N $M)
+ netjail_node_name
+ NODES[$N,$M]=$RESULT
+ netjail_node_link_bridge_name
+ NODE_LINKS[$N,$M]=$RESULT
+ netjail_node_unlink_bridge ${NODE_LINKS[$N,$M]}
+ netjail_node_clear ${NODES[$N,$M]}
done
+
- netjail_bridge_clear $(netjail_print_name "r" $N)
- netjail_node_clear $(netjail_print_name "R" $N)
+ netjail_bridge_clear ${ROUTER_NETS[$N]}
+ netjail_node_unlink_bridge ${NETWORK_LINKS[$N]}
+ netjail_node_clear ${ROUTERS[$N]}
done
netjail_bridge_clear $NETWORK_NET
diff --git a/src/testing/netjail_stop_v2.sh b/src/testing/netjail_stop_v2.sh
deleted file mode 100755
index 6e9fd1ccc..000000000
--- a/src/testing/netjail_stop_v2.sh
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash
-. "./../testing/netjail_core_v2.sh"
-. "./../testing/topo.sh"
-
-set -eu
-set -x
-
-export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
-
-filename=$1
-PREFIX=$2
-
-read_topology $filename
-
-declare -A NODES
-declare -A NODE_LINKS
-
-netjail_bridge_name
-NETWORK_NET=$RESULT
-
-for X in $(seq $KNOWN); do
- netjail_node_name
- KNOWN_NODES[$X]=$RESULT
- netjail_node_link_bridge_name
- KNOWN_LINKS[$X]=$RESULT
- netjail_node_unlink_bridge ${KNOWN_LINKS[$X]}
- netjail_node_clear ${KNOWN_NODES[$X]}
-done
-
-for N in $(seq $GLOBAL_N); do
- netjail_node_name
- ROUTERS[$N]=$RESULT
- netjail_node_link_bridge_name
- NETWORK_LINKS[$N]=$RESULT
- netjail_bridge_name
- ROUTER_NETS[$N]=$RESULT
- netjail_node_link_bridge_name
- ROUTER_LINKS[$N]=$RESULT
-
- netjail_node_unlink_bridge ${ROUTER_LINKS[$N]}
-
- for M in $(seq $LOCAL_M); do
- netjail_node_name
- NODES[$N,$M]=$RESULT
- netjail_node_link_bridge_name
- NODE_LINKS[$N,$M]=$RESULT
- netjail_node_unlink_bridge ${NODE_LINKS[$N,$M]}
- netjail_node_clear ${NODES[$N,$M]}
- done
-
-
- netjail_bridge_clear ${ROUTER_NETS[$N]}
- netjail_node_unlink_bridge ${NETWORK_LINKS[$N]}
- netjail_node_clear ${ROUTERS[$N]}
-done
-
-netjail_bridge_clear $NETWORK_NET
-
-echo "Done"
diff --git a/src/testing/test_testing_api_cmd_netjail.c b/src/testing/test_testing_api_cmd_netjail.c
deleted file mode 100644
index aeddfb7c9..000000000
--- a/src/testing/test_testing_api_cmd_netjail.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file testing/test_testbed_api_cmd_netjail.c
- * @brief Test case executing a script in a network name space.
- * @author t3sserakt
- */
-#include "platform.h"
-#include "gnunet_testing_ng_lib.h"
-#include "gnunet_util_lib.h"
-
-
-/**
- * Return value of the test.
- *
- */
-static unsigned int rv = 0;
-
-
-/**
- * Main function to run the test cases.
- *
- * @param cls not used.
- *
- */
-static void
-run (void *cls)
-{
- struct GNUNET_TESTING_Command commands[] = {
- GNUNET_TESTING_cmd_netjail_start ("netjail-start-1",
- "2",
- "2"),
- GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed-1",
- "2",
- "2",
- "libgnunet_plugin_testcmd",
- &rv),
- GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed",
- "netjail-start-testbed-1",
- "2",
- "2"),
- GNUNET_TESTING_cmd_netjail_stop ("netjail-stop-1",
- "2",
- "2"),
- GNUNET_TESTING_cmd_end ()
- };
-
- GNUNET_TESTING_run (NULL,
- commands,
- GNUNET_TIME_UNIT_FOREVER_REL);
-}
-
-
-int
-main (int argc,
- char *const *argv)
-{
- int rv = 0;
-
- GNUNET_log_setup ("test-netjail",
- "DEBUG",
- NULL);
- GNUNET_SCHEDULER_run (&run,
- NULL);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Test finished!\n");
- return rv;
-}
diff --git a/src/testing/test_testing_plugin_testcmd.c b/src/testing/test_testing_plugin_testcmd.c
deleted file mode 100644
index 444272fcd..000000000
--- a/src/testing/test_testing_plugin_testcmd.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file testbed/plugin_testcmd.c
- * @brief a plugin to provide the API for running test cases.
- * @author t3sserakt
- */
-#include "platform.h"
-#include "gnunet_testing_ng_lib.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_testing_ng_lib.h"
-
-/**
- * Generic logging shortcut
- */
-#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
-
-unsigned int are_all_peers_started;
-
-static void
-all_peers_started ()
-{
- are_all_peers_started = GNUNET_YES;
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "setting are_all_peers_started: %d\n",
- are_all_peers_started);
-}
-
-static void
-start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
- char *node_ip,
- char *n,
- char *m,
- char *local_m)
-{
- struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
-
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "We got here 6!\n");
-
- are_all_peers_started = GNUNET_NO;
-
- struct GNUNET_TESTING_Command commands[] = {
- GNUNET_TESTING_cmd_hello_world_birth ("hello-world-birth-0",
- &now),
- GNUNET_TESTING_cmd_hello_world ("hello-world-0","hello-world-birth-0",""),
- GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready-1",
- write_message),
- GNUNET_TESTING_cmd_block_until_all_peers_started ("block-1",
- &are_all_peers_started),
- GNUNET_TESTING_cmd_local_test_finished ("local-test-finished-1",
- write_message)
- };
-
- GNUNET_TESTING_run (NULL,
- commands,
- GNUNET_TIME_UNIT_FOREVER_REL);
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "We got here 7!\n");
-
-}
-
-
-/**
- * Entry point for the plugin.
- *
- * @param cls NULL
- * @return the exported block API
- */
-void *
-libgnunet_plugin_testcmd_init (void *cls)
-{
- struct GNUNET_TESTING_PluginFunctions *api;
-
- api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
- api->start_testcase = &start_testcase;
- api->all_peers_started = &all_peers_started;
- return api;
-}
-
-
-/**
- * Exit point from the plugin.
- *
- * @param cls the return value from #libgnunet_plugin_block_test_init
- * @return NULL
- */
-void *
-libgnunet_plugin_testcmd_done (void *cls)
-{
- struct GNUNET_TESTING_PluginFunctions *api = cls;
-
- GNUNET_free (api);
- return NULL;
-}
-
-
-/* end of plugin_testcmd.c */
diff --git a/src/testing/testing.c b/src/testing/testing.c
index fcde39901..fd0701d7d 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -33,10 +33,20 @@
#include "gnunet_util_lib.h"
#include "gnunet_arm_service.h"
#include "gnunet_testing_lib.h"
-#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_netjail_lib.h"
+#include "testing_cmds.h"
#define LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__)
+#define CONNECT_ADDRESS_TEMPLATE "%s-192.168.15.%u:60002"
+
+#define ROUTER_CONNECT_ADDRESS_TEMPLATE "%s-92.68.150.%u:60002"
+
+#define KNOWN_CONNECT_ADDRESS_TEMPLATE "%s-92.68.151.%u:60002"
+
+#define PREFIX_TCP "tcp"
+
+#define PREFIX_UDP "udp"
/**
* Lowest port used for GNUnet testing. Should be high enough to not
@@ -1788,8 +1798,8 @@ get_first_value (char *line)
memcpy (copy, line, slen);
token = strtok_r (copy, ":", &rest);
token = strtok_r (NULL, ":", &rest);
- sscanf (token, "%u", &ret);
- free (copy);
+ GNUNET_assert (1 == sscanf (token, "%u", &ret));
+ GNUNET_free (copy);
return ret;
}
@@ -1809,7 +1819,7 @@ get_key (char *line)
token = strtok_r (copy, ":", &rest);
ret = malloc (2);
memcpy (ret, token, 2);
- free (copy);
+ GNUNET_free (copy);
return ret;
}
@@ -1834,7 +1844,7 @@ get_first_string_value (char *line)
slen_token = strlen (token);
ret = malloc (slen_token + 1);
memcpy (ret, token, slen_token + 1);
- free (copy);
+ GNUNET_free (copy);
return ret;
}
@@ -1854,8 +1864,8 @@ get_second_value (char *line)
token = strtok_r (copy, ":", &rest);
token = strtok_r (NULL, ":", &rest);
token = strtok_r (NULL, ":", &rest);
- sscanf (token, "%u", &ret);
- free (copy);
+ GNUNET_assert (1 == sscanf (token, "%u", &ret));
+ GNUNET_free (copy);
return ret;
}
@@ -1883,73 +1893,517 @@ get_value (char *key, char *line)
slen_token = strlen (token2);
ret = malloc (slen_token + 1);
memcpy (ret, token2, slen_token + 1);
- free (copy);