summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-09-08 12:33:09 +0000
committerng0 <ng0@n0.is>2019-09-08 12:33:09 +0000
commitd41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch)
tree9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src
parenta0fce305c565c0937d917a92712f15e9c5736260 (diff)
uncrustify as demanded.
Diffstat (limited to 'src')
-rw-r--r--src/abe/abe.c327
-rw-r--r--src/abe/test_cpabe.c65
-rw-r--r--src/arm/arm.h18
-rw-r--r--src/arm/arm_api.c710
-rw-r--r--src/arm/arm_monitor_api.c150
-rw-r--r--src/arm/gnunet-arm.c840
-rw-r--r--src/arm/gnunet-service-arm.c2268
-rw-r--r--src/arm/mockup-service.c75
-rw-r--r--src/arm/test_arm_api.c241
-rw-r--r--src/arm/test_exponential_backoff.c386
-rw-r--r--src/arm/test_gnunet_service_arm.c252
-rw-r--r--src/ats-tests/ats-testing-experiment.c1023
-rw-r--r--src/ats-tests/ats-testing-log.c979
-rw-r--r--src/ats-tests/ats-testing-preferences.c196
-rw-r--r--src/ats-tests/ats-testing-traffic.c359
-rw-r--r--src/ats-tests/ats-testing.c1081
-rw-r--r--src/ats-tests/ats-testing.h128
-rw-r--r--src/ats-tests/gnunet-ats-sim.c427
-rw-r--r--src/ats-tests/gnunet-solver-eval.c1244
-rw-r--r--src/ats-tests/perf_ats.c571
-rw-r--r--src/ats-tests/perf_ats.h40
-rw-r--r--src/ats-tests/perf_ats_logging.c678
-rw-r--r--src/ats-tool/gnunet-ats.c943
-rw-r--r--src/ats/ats.h58
-rw-r--r--src/ats/ats2.h30
-rw-r--r--src/ats/ats_api2_application.c203
-rw-r--r--src/ats/ats_api2_transport.c435
-rw-r--r--src/ats/ats_api_connectivity.c221
-rw-r--r--src/ats/ats_api_performance.c776
-rw-r--r--src/ats/ats_api_scanner.c32
-rw-r--r--src/ats/ats_api_scheduling.c613
-rw-r--r--src/ats/gnunet-ats-solver-eval.c3826
-rw-r--r--src/ats/gnunet-ats-solver-eval.h78
-rw-r--r--src/ats/gnunet-service-ats-new.c658
-rw-r--r--src/ats/gnunet-service-ats.c466
-rw-r--r--src/ats/gnunet-service-ats.h6
-rw-r--r--src/ats/gnunet-service-ats_addresses.c627
-rw-r--r--src/ats/gnunet-service-ats_addresses.h73
-rw-r--r--src/ats/gnunet-service-ats_connectivity.c121
-rw-r--r--src/ats/gnunet-service-ats_connectivity.h22
-rw-r--r--src/ats/gnunet-service-ats_normalization.c217
-rw-r--r--src/ats/gnunet-service-ats_normalization.h10
-rw-r--r--src/ats/gnunet-service-ats_performance.c230
-rw-r--r--src/ats/gnunet-service-ats_performance.h30
-rw-r--r--src/ats/gnunet-service-ats_plugins.c574
-rw-r--r--src/ats/gnunet-service-ats_plugins.h58
-rw-r--r--src/ats/gnunet-service-ats_preferences.c496
-rw-r--r--src/ats/gnunet-service-ats_preferences.h38
-rw-r--r--src/ats/gnunet-service-ats_reservations.c158
-rw-r--r--src/ats/gnunet-service-ats_reservations.h18
-rw-r--r--src/ats/gnunet-service-ats_scheduling.c146
-rw-r--r--src/ats/gnunet-service-ats_scheduling.h22
-rw-r--r--src/ats/perf_ats_solver.c1373
-rw-r--r--src/ats/plugin_ats2_common.c114
-rw-r--r--src/ats/plugin_ats2_simple.c718
-rw-r--r--src/ats/plugin_ats_mlp.c2260
-rw-r--r--src/ats/plugin_ats_proportional.c1070
-rw-r--r--src/ats/plugin_ats_ril.c2134
-rw-r--r--src/ats/test_ats2_lib.c140
-rw-r--r--src/ats/test_ats2_lib.h12
-rw-r--r--src/ats/test_ats_api.c22
-rw-r--r--src/ats/test_ats_lib.c1123
-rw-r--r--src/ats/test_ats_lib.h80
-rw-r--r--src/ats/test_ats_reservation_api.c18
-rw-r--r--src/auction/auction.h7
-rw-r--r--src/auction/gnunet-auction-create.c292
-rw-r--r--src/auction/gnunet-auction-info.c33
-rw-r--r--src/auction/gnunet-auction-join.c33
-rw-r--r--src/auction/gnunet-service-auction.c72
-rw-r--r--src/auction/test_auction_api.c10
-rw-r--r--src/block/bg_bf.c120
-rw-r--r--src/block/block.c254
-rw-r--r--src/block/plugin_block_template.c104
-rw-r--r--src/block/plugin_block_test.c122
-rw-r--r--src/cadet/cadet.h67
-rw-r--r--src/cadet/cadet_api.c762
-rw-r--r--src/cadet/cadet_api_get_channel.c139
-rw-r--r--src/cadet/cadet_api_get_path.c155
-rw-r--r--src/cadet/cadet_api_helper.c16
-rw-r--r--src/cadet/cadet_api_list_peers.c126
-rw-r--r--src/cadet/cadet_api_list_tunnels.c134
-rw-r--r--src/cadet/cadet_protocol.h58
-rw-r--r--src/cadet/cadet_test_lib.c252
-rw-r--r--src/cadet/cadet_test_lib.h34
-rw-r--r--src/cadet/desirability_table.c40
-rw-r--r--src/cadet/gnunet-cadet-profiler.c837
-rw-r--r--src/cadet/gnunet-cadet.c712
-rw-r--r--src/cadet/gnunet-service-cadet.c1174
-rw-r--r--src/cadet/gnunet-service-cadet.h42
-rw-r--r--src/cadet/gnunet-service-cadet_channel.c1870
-rw-r--r--src/cadet/gnunet-service-cadet_channel.h90
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c760
-rw-r--r--src/cadet/gnunet-service-cadet_connection.h83
-rw-r--r--src/cadet/gnunet-service-cadet_core.c1164
-rw-r--r--src/cadet/gnunet-service-cadet_core.h8
-rw-r--r--src/cadet/gnunet-service-cadet_dht.c308
-rw-r--r--src/cadet/gnunet-service-cadet_dht.h14
-rw-r--r--src/cadet/gnunet-service-cadet_hello.c96
-rw-r--r--src/cadet/gnunet-service-cadet_hello.h10
-rw-r--r--src/cadet/gnunet-service-cadet_paths.c748
-rw-r--r--src/cadet/gnunet-service-cadet_paths.h50
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c1244
-rw-r--r--src/cadet/gnunet-service-cadet_peer.h116
-rw-r--r--src/cadet/gnunet-service-cadet_tunnels.c3467
-rw-r--r--src/cadet/gnunet-service-cadet_tunnels.h88
-rw-r--r--src/cadet/test_cadet.c1198
-rw-r--r--src/cadet/test_cadet_flow.c747
-rw-r--r--src/cadet/test_cadet_local_mq.c265
-rw-r--r--src/consensus/consensus.h11
-rw-r--r--src/consensus/consensus_api.c183
-rw-r--r--src/consensus/consensus_protocol.h16
-rw-r--r--src/consensus/gnunet-consensus-profiler.c536
-rw-r--r--src/consensus/gnunet-service-consensus.c2972
-rw-r--r--src/consensus/plugin_block_consensus.c60
-rw-r--r--src/consensus/test_consensus_api.c77
-rw-r--r--src/conversation/conversation.h77
-rw-r--r--src/conversation/conversation_api.c696
-rw-r--r--src/conversation/conversation_api_call.c713
-rw-r--r--src/conversation/gnunet-conversation-test.c191
-rw-r--r--src/conversation/gnunet-conversation.c1325
-rw-r--r--src/conversation/gnunet-helper-audio-playback-gst.c385
-rw-r--r--src/conversation/gnunet-helper-audio-playback.c1023
-rw-r--r--src/conversation/gnunet-helper-audio-record-gst.c375
-rw-r--r--src/conversation/gnunet-helper-audio-record.c688
-rw-r--r--src/conversation/gnunet-service-conversation.c1348
-rw-r--r--src/conversation/gnunet_gst.c1217
-rw-r--r--src/conversation/gnunet_gst.h58
-rw-r--r--src/conversation/gnunet_gst_def.h80
-rw-r--r--src/conversation/gnunet_gst_test.c127
-rw-r--r--src/conversation/microphone.c115
-rw-r--r--src/conversation/plugin_gnsrecord_conversation.c188
-rw-r--r--src/conversation/speaker.c120
-rw-r--r--src/conversation/test_conversation_api.c526
-rw-r--r--src/conversation/test_conversation_api_reject.c362
-rw-r--r--src/conversation/test_conversation_api_twocalls.c654
-rw-r--r--src/core/core.h31
-rw-r--r--src/core/core_api.c562
-rw-r--r--src/core/core_api_monitor_peers.c84
-rw-r--r--src/core/gnunet-core.c196
-rw-r--r--src/core/gnunet-service-core.c897
-rw-r--r--src/core/gnunet-service-core.h24
-rw-r--r--src/core/gnunet-service-core_kx.c2027
-rw-r--r--src/core/gnunet-service-core_kx.h20
-rw-r--r--src/core/gnunet-service-core_sessions.c819
-rw-r--r--src/core/gnunet-service-core_sessions.h42
-rw-r--r--src/core/gnunet-service-core_typemap.c231
-rw-r--r--src/core/gnunet-service-core_typemap.h42
-rw-r--r--src/core/test_core_api.c344
-rw-r--r--src/core/test_core_api_reliability.c584
-rw-r--r--src/core/test_core_api_send_to_self.c150
-rw-r--r--src/core/test_core_api_start_only.c228
-rw-r--r--src/core/test_core_quota_compliance.c901
-rw-r--r--src/credential/credential.h38
-rw-r--r--src/credential/credential_api.c354
-rw-r--r--src/credential/credential_misc.c159
-rw-r--r--src/credential/credential_misc.h6
-rw-r--r--src/credential/credential_serialization.c444
-rw-r--r--src/credential/credential_serialization.h166
-rw-r--r--src/credential/gnunet-credential.c655
-rw-r--r--src/credential/gnunet-service-credential.c1064
-rw-r--r--src/credential/plugin_gnsrecord_credential.c346
-rw-r--r--src/credential/plugin_rest_credential.c1368
-rw-r--r--src/curl/curl.c529
-rw-r--r--src/curl/curl_reschedule.c119
-rw-r--r--src/datacache/datacache.c338
-rw-r--r--src/datacache/perf_datacache.c138
-rw-r--r--src/datacache/plugin_datacache_heap.c360
-rw-r--r--src/datacache/plugin_datacache_postgres.c699
-rw-r--r--src/datacache/plugin_datacache_sqlite.c887
-rw-r--r--src/datacache/plugin_datacache_template.c81
-rw-r--r--src/datacache/test_datacache.c222
-rw-r--r--src/datacache/test_datacache_quota.c156
-rw-r--r--src/datastore/datastore.h31
-rw-r--r--src/datastore/datastore_api.c1315
-rw-r--r--src/datastore/gnunet-datastore.c442
-rw-r--r--src/datastore/gnunet-service-datastore.c1518
-rw-r--r--src/datastore/perf_datastore_api.c497
-rw-r--r--src/datastore/perf_plugin_datastore.c563
-rw-r--r--src/datastore/plugin_datastore_heap.c622
-rw-r--r--src/datastore/plugin_datastore_mysql.c1114
-rw-r--r--src/datastore/plugin_datastore_postgres.c942
-rw-r--r--src/datastore/plugin_datastore_sqlite.c1445
-rw-r--r--src/datastore/plugin_datastore_template.c119
-rw-r--r--src/datastore/test_datastore_api.c696
-rw-r--r--src/datastore/test_datastore_api_management.c377
-rw-r--r--src/datastore/test_plugin_datastore.c451
-rw-r--r--src/dht/dht.h39
-rw-r--r--src/dht/dht_api.c964
-rw-r--r--src/dht/dht_test_lib.c135
-rw-r--r--src/dht/dht_test_lib.h24
-rw-r--r--src/dht/gnunet-dht-get.c226
-rw-r--r--src/dht/gnunet-dht-monitor.c276
-rw-r--r--src/dht/gnunet-dht-put.c173
-rw-r--r--src/dht/gnunet-service-dht.c120
-rw-r--r--src/dht/gnunet-service-dht.h74
-rw-r--r--src/dht/gnunet-service-dht_clients.c1395
-rw-r--r--src/dht/gnunet-service-dht_datacache.c387
-rw-r--r--src/dht/gnunet-service-dht_datacache.h44
-rw-r--r--src/dht/gnunet-service-dht_hello.c86
-rw-r--r--src/dht/gnunet-service-dht_hello.h10
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c2652
-rw-r--r--src/dht/gnunet-service-dht_neighbours.h72
-rw-r--r--src/dht/gnunet-service-dht_nse.c58
-rw-r--r--src/dht/gnunet-service-dht_nse.h10
-rw-r--r--src/dht/gnunet-service-dht_routing.c396
-rw-r--r--src/dht/gnunet-service-dht_routing.h40
-rw-r--r--src/dht/gnunet_dht_profiler.c760
-rw-r--r--src/dht/plugin_block_dht.c196
-rw-r--r--src/dht/test_dht_api.c184
-rw-r--r--src/dht/test_dht_monitor.c324
-rw-r--r--src/dht/test_dht_topo.c495
-rw-r--r--src/dns/dns.h17
-rw-r--r--src/dns/dns_api.c225
-rw-r--r--src/dns/gnunet-dns-monitor.c380
-rw-r--r--src/dns/gnunet-dns-redirector.c234
-rw-r--r--src/dns/gnunet-helper-dns.c1336
-rw-r--r--src/dns/gnunet-service-dns.c1251
-rw-r--r--src/dns/gnunet-zonewalk.c593
-rw-r--r--src/dns/plugin_block_dns.c191
-rw-r--r--src/exit/exit.h31
-rw-r--r--src/exit/gnunet-daemon-exit.c4698
-rw-r--r--src/exit/gnunet-helper-exit-windows.c1160
-rw-r--r--src/exit/gnunet-helper-exit.c964
-rw-r--r--src/fragmentation/defragmentation.c400
-rw-r--r--src/fragmentation/fragmentation.c402
-rw-r--r--src/fragmentation/fragmentation.h14
-rw-r--r--src/fragmentation/test_fragmentation.c246
-rw-r--r--src/fragmentation/test_fragmentation_parallel.c190
-rw-r--r--src/fs/fs.h43
-rw-r--r--src/fs/fs_api.c3372
-rw-r--r--src/fs/fs_api.h231
-rw-r--r--src/fs/fs_directory.c612
-rw-r--r--src/fs/fs_dirmetascan.c473
-rw-r--r--src/fs/fs_download.c2574
-rw-r--r--src/fs/fs_file_information.c324
-rw-r--r--src/fs/fs_getopt.c239
-rw-r--r--src/fs/fs_list_indexed.c134
-rw-r--r--src/fs/fs_misc.c198
-rw-r--r--src/fs/fs_namespace.c663
-rw-r--r--src/fs/fs_publish.c1659
-rw-r--r--src/fs/fs_publish_ksk.c151
-rw-r--r--src/fs/fs_publish_ublock.c247
-rw-r--r--src/fs/fs_publish_ublock.h38
-rw-r--r--src/fs/fs_search.c1622
-rw-r--r--src/fs/fs_sharetree.c259
-rw-r--r--src/fs/fs_test_lib.c424
-rw-r--r--src/fs/fs_test_lib.h38
-rw-r--r--src/fs/fs_tree.c264
-rw-r--r--src/fs/fs_tree.h38
-rw-r--r--src/fs/fs_unindex.c862
-rw-r--r--src/fs/fs_uri.c1774
-rw-r--r--src/fs/gnunet-auto-share.c602
-rw-r--r--src/fs/gnunet-daemon-fsprofiler.c565
-rw-r--r--src/fs/gnunet-directory.c171
-rw-r--r--src/fs/gnunet-download.c446
-rw-r--r--src/fs/gnunet-fs-profiler.c150
-rw-r--r--src/fs/gnunet-fs.c108
-rw-r--r--src/fs/gnunet-helper-fs-publish.c404
-rw-r--r--src/fs/gnunet-publish.c1076
-rw-r--r--src/fs/gnunet-search.c376
-rw-r--r--src/fs/gnunet-service-fs.c1124
-rw-r--r--src/fs/gnunet-service-fs.h24
-rw-r--r--src/fs/gnunet-service-fs_cadet.h36
-rw-r--r--src/fs/gnunet-service-fs_cadet_client.c427
-rw-r--r--src/fs/gnunet-service-fs_cadet_server.c457
-rw-r--r--src/fs/gnunet-service-fs_cp.c1451
-rw-r--r--src/fs/gnunet-service-fs_cp.h85
-rw-r--r--src/fs/gnunet-service-fs_indexing.c480
-rw-r--r--src/fs/gnunet-service-fs_indexing.h40
-rw-r--r--src/fs/gnunet-service-fs_pe.c629
-rw-r--r--src/fs/gnunet-service-fs_pe.h22
-rw-r--r--src/fs/gnunet-service-fs_pr.c1845
-rw-r--r--src/fs/gnunet-service-fs_pr.h93
-rw-r--r--src/fs/gnunet-service-fs_push.c468
-rw-r--r--src/fs/gnunet-service-fs_push.h12
-rw-r--r--src/fs/gnunet-service-fs_put.c176
-rw-r--r--src/fs/gnunet-service-fs_put.h8
-rw-r--r--src/fs/gnunet-unindex.c161
-rw-r--r--src/fs/perf_gnunet_service_fs_p2p.c312
-rw-r--r--src/fs/perf_gnunet_service_fs_p2p_respect.c378
-rw-r--r--src/fs/plugin_block_fs.c287
-rw-r--r--src/fs/test_fs.c249
-rw-r--r--src/fs/test_fs_directory.c171
-rw-r--r--src/fs/test_fs_download.c419
-rw-r--r--src/fs/test_fs_download_persistence.c375
-rw-r--r--src/fs/test_fs_file_information.c124
-rw-r--r--src/fs/test_fs_getopt.c14
-rw-r--r--src/fs/test_fs_list_indexed.c276
-rw-r--r--src/fs/test_fs_namespace.c327
-rw-r--r--src/fs/test_fs_namespace_list_updateable.c115
-rw-r--r--src/fs/test_fs_publish.c262
-rw-r--r--src/fs/test_fs_publish_persistence.c324
-rw-r--r--src/fs/test_fs_search.c257
-rw-r--r--src/fs/test_fs_search_persistence.c317
-rw-r--r--src/fs/test_fs_search_probes.c264
-rw-r--r--src/fs/test_fs_search_with_and.c285
-rw-r--r--src/fs/test_fs_start_stop.c28
-rw-r--r--src/fs/test_fs_test_lib.c149
-rw-r--r--src/fs/test_fs_unindex.c248
-rw-r--r--src/fs/test_fs_unindex_persistence.c321
-rw-r--r--src/fs/test_fs_uri.c420
-rw-r--r--src/fs/test_gnunet_service_fs_migration.c213
-rw-r--r--src/fs/test_gnunet_service_fs_p2p.c142
-rw-r--r--src/fs/test_plugin_block_fs.c74
-rw-r--r--src/gns/gns.h11
-rw-r--r--src/gns/gns_api.c257
-rw-r--r--src/gns/gns_api.h9
-rw-r--r--src/gns/gns_tld_api.c236
-rw-r--r--src/gns/gnunet-bcd.c629
-rw-r--r--src/gns/gnunet-dns2gns.c791
-rw-r--r--src/gns/gnunet-gns-benchmark.c540
-rw-r--r--src/gns/gnunet-gns-helper-service-w32.c944
-rw-r--r--src/gns/gnunet-gns-import.c387
-rw-r--r--src/gns/gnunet-gns-proxy.c4108
-rw-r--r--src/gns/gnunet-gns.c250
-rw-r--r--src/gns/gnunet-service-gns.c491
-rw-r--r--src/gns/gnunet-service-gns.h10
-rw-r--r--src/gns/gnunet-service-gns_interceptor.c429
-rw-r--r--src/gns/gnunet-service-gns_interceptor.h8
-rw-r--r--src/gns/gnunet-service-gns_resolver.c3290
-rw-r--r--src/gns/gnunet-service-gns_resolver.h28
-rw-r--r--src/gns/gnunet_w32nsp_lib.h2
-rw-r--r--src/gns/nss/nss_gns.c192
-rw-r--r--src/gns/nss/nss_gns_query.c140
-rw-r--r--src/gns/nss/nss_gns_query.h11
-rw-r--r--src/gns/plugin_block_gns.c148
-rw-r--r--src/gns/plugin_gnsrecord_gns.c443
-rw-r--r--src/gns/plugin_rest_gns.c284
-rw-r--r--src/gns/test_gns_proxy.c548
-rw-r--r--src/gns/w32nsp-install.c152
-rw-r--r--src/gns/w32nsp-resolve.c636
-rw-r--r--src/gns/w32nsp-uninstall.c28
-rw-r--r--src/gns/w32nsp.c728
-rw-r--r--src/gns/w32resolver.h7
-rw-r--r--src/gnsrecord/gnsrecord.c139
-rw-r--r--src/gnsrecord/gnsrecord_crypto.c484
-rw-r--r--src/gnsrecord/gnsrecord_misc.c210
-rw-r--r--src/gnsrecord/gnsrecord_serialization.c253
-rw-r--r--src/gnsrecord/perf_gnsrecord_crypto.c106
-rw-r--r--src/gnsrecord/plugin_gnsrecord_dns.c1167
-rw-r--r--src/gnsrecord/test_gnsrecord_block_expiration.c31
-rw-r--r--src/gnsrecord/test_gnsrecord_crypto.c123
-rw-r--r--src/gnsrecord/test_gnsrecord_serialization.c159
-rw-r--r--src/hello/address.c74
-rw-r--r--src/hello/gnunet-hello.c186
-rw-r--r--src/hello/hello-ng.c145
-rw-r--r--src/hello/hello.c882
-rw-r--r--src/hello/test_friend_hello.c200
-rw-r--r--src/hello/test_hello.c288
-rw-r--r--src/hostlist/gnunet-daemon-hostlist.c282
-rw-r--r--src/hostlist/gnunet-daemon-hostlist.h4
-rw-r--r--src/hostlist/gnunet-daemon-hostlist_client.c1771
-rw-r--r--src/hostlist/gnunet-daemon-hostlist_client.h18
-rw-r--r--src/hostlist/gnunet-daemon-hostlist_server.c887
-rw-r--r--src/hostlist/gnunet-daemon-hostlist_server.h16
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist.c236
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist_learning.c659
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist_reconnect.c260
-rw-r--r--src/identity/gnunet-identity.c360
-rw-r--r--src/identity/gnunet-service-identity.c1059
-rw-r--r--src/identity/identity.h29
-rw-r--r--src/identity/identity_api.c605
-rw-r--r--src/identity/identity_api_lookup.c122
-rw-r--r--src/identity/identity_api_suffix_lookup.c122
-rw-r--r--src/identity/plugin_rest_identity.c1090
-rw-r--r--src/identity/test_identity.c225
-rw-r--r--src/identity/test_identity_defaults.c178
-rw-r--r--src/include/block_dns.h8
-rw-r--r--src/include/block_fs.h13
-rw-r--r--src/include/block_regex.h10
-rw-r--r--src/include/compat.h14
-rw-r--r--src/include/gauger.h152
-rw-r--r--src/include/gettext.h14
-rw-r--r--src/include/gnunet_abe_lib.h50
-rw-r--r--src/include/gnunet_applications.h4
-rw-r--r--src/include/gnunet_arm_service.h54
-rw-r--r--src/include/gnunet_ats_application_service.h38
-rw-r--r--src/include/gnunet_ats_plugin.h40
-rw-r--r--src/include/gnunet_ats_plugin_new.h76
-rw-r--r--src/include/gnunet_ats_service.h143
-rw-r--r--src/include/gnunet_ats_transport_service.h57
-rw-r--r--src/include/gnunet_bandwidth_lib.h50
-rw-r--r--src/include/gnunet_bio_lib.h66
-rw-r--r--src/include/gnunet_block_group_lib.h26
-rw-r--r--src/include/gnunet_block_lib.h84
-rw-r--r--src/include/gnunet_block_plugin.h33
-rw-r--r--src/include/gnunet_cadet_service.h112
-rw-r--r--src/include/gnunet_client_lib.h14
-rw-r--r--src/include/gnunet_common.h454
-rw-r--r--src/include/gnunet_configuration_lib.h208
-rw-r--r--src/include/gnunet_consensus_service.h34
-rw-r--r--src/include/gnunet_constants.h24
-rw-r--r--src/include/gnunet_container_lib.h655
-rw-r--r--src/include/gnunet_conversation_service.h111
-rw-r--r--src/include/gnunet_core_service.h40
-rw-r--r--src/include/gnunet_credential_service.h84
-rw-r--r--src/include/gnunet_crypto_lib.h530
-rw-r--r--src/include/gnunet_curl_lib.h97
-rw-r--r--src/include/gnunet_datacache_lib.h54
-rw-r--r--src/include/gnunet_datacache_plugin.h22
-rw-r--r--src/include/gnunet_datastore_plugin.h34
-rw-r--r--src/include/gnunet_datastore_service.h118
-rw-r--r--src/include/gnunet_db_lib.h36
-rw-r--r--src/include/gnunet_dht_service.h75
-rw-r--r--src/include/gnunet_disk_lib.h199
-rw-r--r--src/include/gnunet_dns_service.h27
-rw-r--r--src/include/gnunet_dnsparser_lib.h193
-rw-r--r--src/include/gnunet_dnsstub_lib.h30
-rw-r--r--src/include/gnunet_fragmentation_lib.h52
-rw-r--r--src/include/gnunet_friends_lib.h18
-rw-r--r--src/include/gnunet_fs_service.h1053
-rw-r--r--src/include/gnunet_getopt_lib.h148
-rw-r--r--src/include/gnunet_gns_service.h40
-rw-r--r--src/include/gnunet_gnsrecord_lib.h98
-rw-r--r--src/include/gnunet_gnsrecord_plugin.h27
-rw-r--r--src/include/gnunet_hello_lib.h112
-rw-r--r--src/include/gnunet_helper_lib.h38
-rw-r--r--src/include/gnunet_identity_service.h84
-rw-r--r--src/include/gnunet_json_lib.h136
-rw-r--r--src/include/gnunet_load_lib.h18
-rw-r--r--src/include/gnunet_microphone_lib.h51
-rw-r--r--src/include/gnunet_mq_lib.h258
-rw-r--r--src/include/gnunet_mst_lib.h32
-rw-r--r--src/include/gnunet_my_lib.h236
-rw-r--r--src/include/gnunet_mysql_lib.h22
-rw-r--r--src/include/gnunet_namecache_plugin.h18
-rw-r--r--src/include/gnunet_namecache_service.h26
-rw-r--r--src/include/gnunet_namestore_plugin.h52
-rw-r--r--src/include/gnunet_namestore_service.h108
-rw-r--r--src/include/gnunet_nat_auto_service.h32
-rw-r--r--src/include/gnunet_nat_service.h91
-rw-r--r--src/include/gnunet_nc_lib.h20
-rw-r--r--src/include/gnunet_network_lib.h188
-rw-r--r--src/include/gnunet_nse_service.h8
-rw-r--r--src/include/gnunet_nt_lib.h40
-rw-r--r--src/include/gnunet_op_lib.h44
-rw-r--r--src/include/gnunet_os_lib.h135
-rw-r--r--src/include/gnunet_peer_lib.h20
-rw-r--r--src/include/gnunet_peerinfo_service.h38
-rw-r--r--src/include/gnunet_peerstore_plugin.h9
-rw-r--r--src/include/gnunet_peerstore_service.h63
-rw-r--r--src/include/gnunet_plugin_lib.h22
-rw-r--r--src/include/gnunet_pq_lib.h158
-rw-r--r--src/include/gnunet_program_lib.h34
-rw-r--r--src/include/gnunet_protocols.h10
-rw-r--r--src/include/gnunet_reclaim_attribute_lib.h55
-rw-r--r--src/include/gnunet_reclaim_attribute_plugin.h6
-rw-r--r--src/include/gnunet_reclaim_service.h107
-rw-r--r--src/include/gnunet_regex_service.h24
-rw-r--r--src/include/gnunet_resolver_service.h42
-rw-r--r--src/include/gnunet_rest_lib.h28
-rw-r--r--src/include/gnunet_rest_plugin.h9
-rw-r--r--src/include/gnunet_revocation_service.h34
-rw-r--r--src/include/gnunet_rps_service.h76
-rw-r--r--src/include/gnunet_scalarproduct_service.h37
-rw-r--r--src/include/gnunet_scheduler_lib.h214
-rw-r--r--src/include/gnunet_secretsharing_service.h119
-rw-r--r--src/include/gnunet_service_lib.h87
-rw-r--r--src/include/gnunet_set_service.h106
-rw-r--r--src/include/gnunet_signal_lib.h12
-rw-r--r--src/include/gnunet_signatures.h2
-rw-r--r--src/include/gnunet_socks.h12
-rw-r--r--src/include/gnunet_speaker_lib.h47
-rw-r--r--src/include/gnunet_sq_lib.h139
-rw-r--r--src/include/gnunet_statistics_service.h60
-rw-r--r--src/include/gnunet_strings_lib.h174
-rw-r--r--src/include/gnunet_testbed_logger_service.h20
-rw-r--r--src/include/gnunet_testbed_service.h430
-rw-r--r--src/include/gnunet_testing_lib.h101
-rw-r--r--src/include/gnunet_time_lib.h140
-rw-r--r--src/include/gnunet_transport_application_service.h34
-rw-r--r--src/include/gnunet_transport_communication_service.h27
-rw-r--r--src/include/gnunet_transport_core_service.h24
-rw-r--r--src/include/gnunet_transport_hello_service.h23
-rw-r--r--src/include/gnunet_transport_manipulation_service.h18
-rw-r--r--src/include/gnunet_transport_monitor_service.h19
-rw-r--r--src/include/gnunet_transport_plugin.h26
-rw-r--r--src/include/gnunet_transport_service.h72
-rw-r--r--src/include/gnunet_tun_lib.h152
-rw-r--r--src/include/gnunet_util_lib.h2
-rw-r--r--src/include/gnunet_util_taler_wallet_lib.h2
-rw-r--r--src/include/gnunet_vpn_service.h42
-rw-r--r--src/include/platform.h12
-rw-r--r--src/include/tap-windows.h24
-rw-r--r--src/include/winproc.h331
-rw-r--r--src/json/json.c126
-rw-r--r--src/json/json_generator.c168
-rw-r--r--src/json/json_gnsrecord.c233
-rw-r--r--src/json/json_helper.c725
-rw-r--r--src/json/json_mhd.c356
-rw-r--r--src/json/test_json.c192
-rw-r--r--src/json/test_json_mhd.c240
-rw-r--r--src/my/my.c274
-rw-r--r--src/my/my_query_helper.c153
-rw-r--r--src/my/my_result_helper.c600
-rw-r--r--src/my/test_my.c366
-rw-r--r--src/mysql/mysql.c358
-rw-r--r--src/namecache/gnunet-namecache.c198
-rw-r--r--src/namecache/gnunet-service-namecache.c338
-rw-r--r--src/namecache/namecache.h20
-rw-r--r--src/namecache/namecache_api.c363
-rw-r--r--src/namecache/plugin_namecache_flat.c446
-rw-r--r--src/namecache/plugin_namecache_postgres.c329
-rw-r--r--src/namecache/plugin_namecache_sqlite.c656
-rw-r--r--src/namecache/test_namecache_api_cache_block.c231
-rw-r--r--src/namecache/test_plugin_namecache.c78
-rw-r--r--src/namestore/gnunet-namestore-fcfsd.c1097
-rw-r--r--src/namestore/gnunet-namestore.c1779
-rw-r--r--src/namestore/gnunet-service-namestore.c1934
-rw-r--r--src/namestore/gnunet-zoneimport.c1801
-rw-r--r--src/namestore/namestore.h48
-rw-r--r--src/namestore/namestore_api.c841
-rw-r--r--src/namestore/namestore_api_monitor.c189
-rw-r--r--src/namestore/perf_namestore_api_zone_iteration.c386
-rw-r--r--src/namestore/plugin_namestore_flat.c828
-rw-r--r--src/namestore/plugin_namestore_postgres.c674
-rw-r--r--src/namestore/plugin_namestore_sqlite.c849
-rw-r--r--src/namestore/plugin_rest_namestore.c632
-rw-r--r--src/namestore/test_common.c68
-rw-r--r--src/namestore/test_namestore_api_lookup_nick.c367
-rw-r--r--src/namestore/test_namestore_api_lookup_private.c230
-rw-r--r--src/namestore/test_namestore_api_lookup_public.c214
-rw-r--r--src/namestore/test_namestore_api_lookup_shadow.c276
-rw-r--r--src/namestore/test_namestore_api_lookup_shadow_filter.c375
-rw-r--r--src/namestore/test_namestore_api_monitoring.c390
-rw-r--r--src/namestore/test_namestore_api_monitoring_existing.c444
-rw-r--r--src/namestore/test_namestore_api_remove.c204
-rw-r--r--src/namestore/test_namestore_api_remove_not_existing_record.c144
-rw-r--r--src/namestore/test_namestore_api_store.c132
-rw-r--r--src/namestore/test_namestore_api_store_update.c326
-rw-r--r--src/namestore/test_namestore_api_zone_iteration.c584
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_nick.c463
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_specific_zone.c546
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_stop.c527
-rw-r--r--src/namestore/test_namestore_api_zone_to_name.c274
-rw-r--r--src/namestore/test_plugin_namestore.c176
-rw-r--r--src/nat-auto/gnunet-nat-auto.c288
-rw-r--r--src/nat-auto/gnunet-nat-auto_legacy.c476
-rw-r--r--src/nat-auto/gnunet-nat-server.c300
-rw-r--r--src/nat-auto/gnunet-service-nat-auto.c327
-rw-r--r--src/nat-auto/gnunet-service-nat-auto_legacy.c1008
-rw-r--r--src/nat-auto/nat-auto.h17
-rw-r--r--src/nat-auto/nat_auto_api.c264
-rw-r--r--src/nat-auto/nat_auto_api_test.c490
-rw-r--r--src/nat/gnunet-helper-nat-client-windows.c325
-rw-r--r--src/nat/gnunet-helper-nat-client.c341
-rw-r--r--src/nat/gnunet-helper-nat-server-windows.c433
-rw-r--r--src/nat/gnunet-helper-nat-server.c583
-rw-r--r--src/nat/gnunet-nat.c432
-rw-r--r--src/nat/gnunet-service-nat.c2190
-rw-r--r--src/nat/gnunet-service-nat.h26
-rw-r--r--src/nat/gnunet-service-nat_externalip.c181
-rw-r--r--src/nat/gnunet-service-nat_externalip.h18
-rw-r--r--src/nat/gnunet-service-nat_helper.c368
-rw-r--r--src/nat/gnunet-service-nat_helper.h28
-rw-r--r--src/nat/gnunet-service-nat_mini.c594
-rw-r--r--src/nat/gnunet-service-nat_mini.h20
-rw-r--r--src/nat/gnunet-service-nat_stun.c178
-rw-r--r--src/nat/gnunet-service-nat_stun.h10
-rw-r--r--src/nat/nat.h34
-rw-r--r--src/nat/nat_api.c548
-rw-r--r--src/nat/nat_api_stun.c155
-rw-r--r--src/nat/nat_stun.h67
-rw-r--r--src/nat/test_nat.c124
-rw-r--r--src/nat/test_nat_mini.c84
-rw-r--r--src/nat/test_nat_test.c107
-rw-r--r--src/nat/test_stun.c278
-rw-r--r--src/nse/gnunet-nse-profiler.c713
-rw-r--r--src/nse/gnunet-nse.c77
-rw-r--r--src/nse/gnunet-service-nse.c1300
-rw-r--r--src/nse/nse.h7
-rw-r--r--src/nse/nse_api.c95
-rw-r--r--src/nse/perf_kdf.c50
-rw-r--r--src/nse/test_nse_api.c54
-rw-r--r--src/nse/test_nse_multipeer.c115
-rw-r--r--src/nt/nt.c366
-rw-r--r--src/peerinfo-tool/gnunet-peerinfo.c677
-rw-r--r--src/peerinfo-tool/gnunet-peerinfo_plugins.c117
-rw-r--r--src/peerinfo-tool/gnunet-peerinfo_plugins.h10
-rw-r--r--src/peerinfo-tool/plugin_rest_peerinfo.c520
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c1301
-rw-r--r--src/peerinfo/peerinfo.h22
-rw-r--r--src/peerinfo/peerinfo_api.c427
-rw-r--r--src/peerinfo/peerinfo_api_notify.c170
-rw-r--r--src/peerinfo/perf_peerinfo_api.c150
-rw-r--r--src/peerinfo/test_peerinfo_api.c127
-rw-r--r--src/peerinfo/test_peerinfo_api_friend_only.c155
-rw-r--r--src/peerinfo/test_peerinfo_api_notify_friend_only.c226
-rw-r--r--src/peerinfo/test_peerinfo_shipped_hellos.c134
-rw-r--r--src/peerstore/gnunet-peerstore.c39
-rw-r--r--src/peerstore/gnunet-service-peerstore.c446
-rw-r--r--src/peerstore/peerstore.h12
-rw-r--r--src/peerstore/peerstore_api.c541
-rw-r--r--src/peerstore/peerstore_common.c154
-rw-r--r--src/peerstore/peerstore_common.h30
-rw-r--r--src/peerstore/perf_peerstore_store.c68
-rw-r--r--src/peerstore/plugin_peerstore_flat.c520
-rw-r--r--src/peerstore/plugin_peerstore_sqlite.c699
-rw-r--r--src/peerstore/test_peerstore_api_iterate.c194
-rw-r--r--src/peerstore/test_peerstore_api_store.c208
-rw-r--r--src/peerstore/test_peerstore_api_sync.c96
-rw-r--r--src/peerstore/test_peerstore_api_watch.c84
-rw-r--r--src/peerstore/test_plugin_peerstore.c205
-rw-r--r--src/pq/pq.c156
-rw-r--r--src/pq/pq_connect.c108
-rw-r--r--src/pq/pq_eval.c294
-rw-r--r--src/pq/pq_exec.c88
-rw-r--r--src/pq/pq_prepare.c88
-rw-r--r--src/pq/pq_query_helper.c282
-rw-r--r--src/pq/pq_result_helper.c838
-rw-r--r--src/pq/test_pq.c382
-rw-r--r--src/pt/gnunet-daemon-pt.c1115
-rw-r--r--src/pt/test_gns_vpn.c902
-rw-r--r--src/pt/test_gnunet_vpn.c521
-rw-r--r--src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c59
-rw-r--r--src/reclaim-attribute/reclaim_attribute.c340
-rw-r--r--src/reclaim-attribute/reclaim_attribute.h5
-rw-r--r--src/reclaim/gnunet-reclaim.c715
-rw-r--r--src/reclaim/gnunet-service-reclaim.c1273
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c1154
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.h45
-rw-r--r--src/reclaim/json_reclaim.c244
-rw-r--r--src/reclaim/json_reclaim.h6
-rw-r--r--src/reclaim/oidc_helper.h46
-rw-r--r--src/reclaim/plugin_gnsrecord_reclaim.c101
-rw-r--r--src/reclaim/plugin_rest_openid_connect.c2084
-rw-r--r--src/reclaim/plugin_rest_reclaim.c941
-rw-r--r--src/reclaim/reclaim.h50
-rw-r--r--src/reclaim/reclaim_api.c576
-rw-r--r--src/regex/gnunet-daemon-regexprofiler.c330
-rw-r--r--src/regex/gnunet-regex-profiler.c1308
-rw-r--r--src/regex/gnunet-regex-simulation-profiler.c634
-rw-r--r--src/regex/gnunet-service-regex.c303
-rw-r--r--src/regex/perf-regex.c102
-rw-r--r--src/regex/plugin_block_regex.c347
-rw-r--r--src/regex/regex_api_announce.c105
-rw-r--r--src/regex/regex_api_search.c167
-rw-r--r--src/regex/regex_block_lib.c380
-rw-r--r--src/regex/regex_block_lib.h51
-rw-r--r--src/regex/regex_internal.c3107
-rw-r--r--src/regex/regex_internal.h54
-rw-r--r--src/regex/regex_internal_dht.c662
-rw-r--r--src/regex/regex_internal_lib.h60
-rw-r--r--src/regex/regex_ipc.h16
-rw-r--r--src/regex/regex_test_graph.c289
-rw-r--r--src/regex/regex_test_lib.c484
-rw-r--r--src/regex/regex_test_lib.h21
-rw-r--r--src/regex/regex_test_random.c115
-rw-r--r--src/regex/test_regex_api.c72
-rw-r--r--src/regex/test_regex_eval_api.c436
-rw-r--r--src/regex/test_regex_graph_api.c161
-rw-r--r--src/regex/test_regex_integration.c186
-rw-r--r--src/regex/test_regex_iterate_api.c314
-rw-r--r--src/regex/test_regex_proofs.c92
-rw-r--r--src/rest/gnunet-rest-server.c1067
-rw-r--r--src/rest/plugin_rest_config.c339
-rw-r--r--src/rest/plugin_rest_copying.c112
-rw-r--r--src/rest/rest.c79
-rw-r--r--src/revocation/gnunet-revocation.c500
-rw-r--r--src/revocation/gnunet-service-revocation.c985
-rw-r--r--src/revocation/plugin_block_revocation.c179
-rw-r--r--src/revocation/revocation.h20
-rw-r--r--src/revocation/revocation_api.c298
-rw-r--r--src/revocation/test_revocation.c424
-rw-r--r--src/rps/gnunet-rps-profiler.c2967
-rw-r--r--src/rps/gnunet-rps.c229
-rw-r--r--src/rps/gnunet-service-rps.c4228
-rw-r--r--src/rps/gnunet-service-rps_custommap.c253
-rw-r--r--src/rps/gnunet-service-rps_custommap.h32
-rw-r--r--src/rps/gnunet-service-rps_sampler.c64
-rw-r--r--src/rps/gnunet-service-rps_sampler.h44
-rw-r--r--src/rps/gnunet-service-rps_sampler_elem.c98
-rw-r--r--src/rps/gnunet-service-rps_sampler_elem.h30
-rw-r--r--src/rps/gnunet-service-rps_view.c201
-rw-r--r--src/rps/gnunet-service-rps_view.h34
-rw-r--r--src/rps/rps-sampler_client.c175
-rw-r--r--src/rps/rps-sampler_client.h44
-rw-r--r--src/rps/rps-sampler_common.c493
-rw-r--r--src/rps/rps-sampler_common.h76
-rw-r--r--src/rps/rps-test_util.c585
-rw-r--r--src/rps/rps-test_util.h84
-rw-r--r--src/rps/rps.h46
-rw-r--r--src/rps/rps_api.c913
-rw-r--r--src/rps/test_rps.c2658
-rw-r--r--src/rps/test_rps_api.c59
-rw-r--r--src/rps/test_service_rps_custommap.c153
-rw-r--r--src/rps/test_service_rps_sampler_elem.c230
-rw-r--r--src/rps/test_service_rps_view.c184
-rw-r--r--src/scalarproduct/gnunet-scalarproduct.c441
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct-ecc.h13
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c973
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c930
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct.h15
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct_alice.c1141
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct_bob.c1140
-rw-r--r--src/scalarproduct/scalarproduct.h22
-rw-r--r--src/scalarproduct/scalarproduct_api.c406
-rw-r--r--src/scalarproduct/test_ecc_scalarproduct.c187
-rw-r--r--src/secretsharing/gnunet-secretsharing-profiler.c502
-rw-r--r--src/secretsharing/gnunet-service-secretsharing.c2096
-rw-r--r--src/secretsharing/secretsharing.h26
-rw-r--r--src/secretsharing/secretsharing_api.c337
-rw-r--r--src/secretsharing/secretsharing_common.c92
-rw-r--r--src/secretsharing/secretsharing_protocol.h16
-rw-r--r--src/secretsharing/test_secretsharing_api.c68
-rw-r--r--src/set/gnunet-service-set.c1843
-rw-r--r--src/set/gnunet-service-set.h54
-rw-r--r--src/set/gnunet-service-set_intersection.c1241
-rw-r--r--src/set/gnunet-service-set_intersection.h20
-rw-r--r--src/set/gnunet-service-set_protocol.h26
-rw-r--r--src/set/gnunet-service-set_union.c2299
-rw-r--r--src/set/gnunet-service-set_union.h76
-rw-r--r--src/set/gnunet-service-set_union_strata_estimator.c210
-rw-r--r--src/set/gnunet-service-set_union_strata_estimator.h41
-rw-r--r--src/set/gnunet-set-ibf-profiler.c362
-rw-r--r--src/set/gnunet-set-profiler.c505
-rw-r--r--src/set/ibf.c282
-rw-r--r--src/set/ibf.h60
-rw-r--r--src/set/ibf_sim.c119
-rw-r--r--src/set/plugin_block_set_test.c48
-rw-r--r--src/set/set.h45
-rw-r--r--src/set/set_api.c923
-rw-r--r--src/set/test_set_api.c411
-rw-r--r--src/set/test_set_intersection_result_full.c388
-rw-r--r--src/set/test_set_union_copy.c285
-rw-r--r--src/set/test_set_union_result_symmetric.c394
-rw-r--r--src/sq/sq.c134
-rw-r--r--src/sq/sq_exec.c94
-rw-r--r--src/sq/sq_prepare.c72
-rw-r--r--src/sq/sq_query_helper.c305
-rw-r--r--src/sq/sq_result_helper.c550
-rw-r--r--src/sq/test_sq.c364
-rw-r--r--src/statistics/gnunet-service-statistics.c853
-rw-r--r--src/statistics/gnunet-statistics.c815
-rw-r--r--src/statistics/statistics.h18
-rw-r--r--src/statistics/statistics_api.c1146
-rw-r--r--src/statistics/test_statistics_api.c297
-rw-r--r--src/statistics/test_statistics_api_loop.c101
-rw-r--r--src/statistics/test_statistics_api_watch.c139
-rw-r--r--src/statistics/test_statistics_api_watch_zero_value.c187
-rw-r--r--src/template/gnunet-service-template.c40
-rw-r--r--src/template/gnunet-template.c38
-rw-r--r--src/template/test_template_api.c8
-rw-r--r--src/testbed-logger/gnunet-service-testbed-logger.c196
-rw-r--r--src/testbed-logger/test_testbed_logger_api.c228
-rw-r--r--src/testbed-logger/testbed_logger_api.c183
-rw-r--r--src/testbed/generate-underlay-topology.c375
-rw-r--r--src/testbed/gnunet-daemon-latency-logger.c264
-rw-r--r--src/testbed/gnunet-daemon-testbed-blacklist.c170
-rw-r--r--src/testbed/gnunet-daemon-testbed-underlay.c366
-rw-r--r--src/testbed/gnunet-helper-testbed.c556
-rw-r--r--src/testbed/gnunet-service-test-barriers.c80
-rw-r--r--src/testbed/gnunet-service-testbed.c919
-rw-r--r--src/testbed/gnunet-service-testbed.h223
-rw-r--r--src/testbed/gnunet-service-testbed_barriers.c740
-rw-r--r--src/testbed/gnunet-service-testbed_barriers.h60
-rw-r--r--src/testbed/gnunet-service-testbed_cache.c147
-rw-r--r--src/testbed/gnunet-service-testbed_connectionpool.c676
-rw-r--r--src/testbed/gnunet-service-testbed_connectionpool.h37
-rw-r--r--src/testbed/gnunet-service-testbed_cpustatus.c363
-rw-r--r--src/testbed/gnunet-service-testbed_links.c1147
-rw-r--r--src/testbed/gnunet-service-testbed_links.h61
-rw-r--r--src/testbed/gnunet-service-testbed_meminfo.c185
-rw-r--r--src/testbed/gnunet-service-testbed_meminfo.h4
-rw-r--r--src/testbed/gnunet-service-testbed_oc.c1658
-rw-r--r--src/testbed/gnunet-service-testbed_peers.c1630
-rw-r--r--src/testbed/gnunet-testbed-profiler.c222
-rw-r--r--src/testbed/gnunet_mpi_test.c122
-rw-r--r--src/testbed/gnunet_testbed_mpi_spawn.c293
-rw-r--r--src/testbed/test_gnunet_helper_testbed.c112
-rw-r--r--src/testbed/test_testbed_api.c359
-rw-r--r--src/testbed/test_testbed_api_2peers_1controller.c396
-rw-r--r--src/testbed/test_testbed_api_3peers_3controllers.c968
-rw-r--r--src/testbed/test_testbed_api_barriers.c163
-rw-r--r--src/testbed/test_testbed_api_controllerlink.c770
-rw-r--r--src/testbed/test_testbed_api_hosts.c155
-rw-r--r--src/testbed/test_testbed_api_operations.c469
-rw-r--r--src/testbed/test_testbed_api_peer_reconfiguration.c108
-rw-r--r--src/testbed/test_testbed_api_peers_manage_services.c133
-rw-r--r--src/testbed/test_testbed_api_sd.c76
-rw-r--r--src/testbed/test_testbed_api_statistics.c108
-rw-r--r--src/testbed/test_testbed_api_test.c173
-rw-r--r--src/testbed/test_testbed_api_test_timeout.c82
-rw-r--r--src/testbed/test_testbed_api_testbed_run.c181
-rw-r--r--src/testbed/test_testbed_api_topology.c150
-rw-r--r--src/testbed/test_testbed_api_topology_clique.c142
-rw-r--r--src/testbed/test_testbed_underlay.c106
-rw-r--r--src/testbed/testbed.h134
-rw-r--r--src/testbed/testbed_api.c2063
-rw-r--r--src/testbed/testbed_api.h134
-rw-r--r--src/testbed/testbed_api_barriers.c236
-rw-r--r--src/testbed/testbed_api_hosts.c1081
-rw-r--r--src/testbed/testbed_api_hosts.h55
-rw-r--r--src/testbed/testbed_api_operations.c794
-rw-r--r--src/testbed/testbed_api_operations.h41
-rw-r--r--src/testbed/testbed_api_peers.c727
-rw-r--r--src/testbed/testbed_api_peers.h65
-rw-r--r--src/testbed/testbed_api_sd.c82
-rw-r--r--src/testbed/testbed_api_sd.h12
-rw-r--r--src/testbed/testbed_api_services.c129
-rw-r--r--src/testbed/testbed_api_statistics.c207
-rw-r--r--src/testbed/testbed_api_test.c51
-rw-r--r--src/testbed/testbed_api_testbed.c1179
-rw-r--r--src/testbed/testbed_api_topology.c1368
-rw-r--r--src/testbed/testbed_api_topology.h20
-rw-r--r--src/testbed/testbed_api_underlay.c105
-rw-r--r--src/testbed/testbed_helper.h8
-rw-r--r--src/testing/gnunet-testing.c470
-rw-r--r--src/testing/list-keys.c112
-rw-r--r--src/testing/test_testing_peerstartup.c73
-rw-r--r--src/testing/test_testing_peerstartup2.c140
-rw-r--r--src/testing/test_testing_portreservation.c68
-rw-r--r--src/testing/test_testing_servicestartup.c30
-rw-r--r--src/testing/test_testing_sharedservices.c104
-rw-r--r--src/testing/testing.c1474
-rw-r--r--src/topology/friends.c263
-rw-r--r--src/topology/gnunet-daemon-topology.c854
-rw-r--r--src/topology/test_gnunet_daemon_topology.c224
-rw-r--r--src/transport/communicator.h8
-rw-r--r--src/transport/gnunet-communicator-tcp.c1840
-rw-r--r--src/transport/gnunet-communicator-udp.c2292
-rw-r--r--src/transport/gnunet-communicator-unix.c958
-rw-r--r--src/transport/gnunet-helper-transport-bluetooth.c3205
-rw-r--r--src/transport/gnunet-helper-transport-wlan-dummy.c595
-rw-r--r--src/transport/gnunet-helper-transport-wlan.c1607
-rw-r--r--src/transport/gnunet-service-tng.c7781
-rw-r--r--src/transport/gnunet-service-transport.c2390
-rw-r--r--src/transport/gnunet-service-transport.h64
-rw-r--r--src/transport/gnunet-service-transport_ats.c772
-rw-r--r--src/transport/gnunet-service-transport_ats.h56
-rw-r--r--src/transport/gnunet-service-transport_hello.c209
-rw-r--r--src/transport/gnunet-service-transport_hello.h24
-rw-r--r--src/transport/gnunet-service-transport_manipulation.c508
-rw-r--r--src/transport/gnunet-service-transport_manipulation.h38
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c4336
-rw-r--r--src/transport/gnunet-service-transport_neighbours.h86
-rw-r--r--src/transport/gnunet-service-transport_plugins.c486
-rw-r--r--src/transport/gnunet-service-transport_plugins.h24
-rw-r--r--src/transport/gnunet-service-transport_validation.c1702
-rw-r--r--src/transport/gnunet-service-transport_validation.h32
-rw-r--r--src/transport/gnunet-transport-profiler.c560
-rw-r--r--src/transport/gnunet-transport-wlan-receiver.c144
-rw-r--r--src/transport/gnunet-transport-wlan-sender.c280
-rw-r--r--src/transport/gnunet-transport.c1266
-rw-r--r--src/transport/ieee80211_radiotap.h60
-rw-r--r--src/transport/plugin_transport_http.h88
-rw-r--r--src/transport/plugin_transport_http_client.c2426
-rw-r--r--src/transport/plugin_transport_http_common.c961
-rw-r--r--src/transport/plugin_transport_http_common.h91
-rw-r--r--src/transport/plugin_transport_http_server.c3571
-rw-r--r--src/transport/plugin_transport_smtp.c642
-rw-r--r--src/transport/plugin_transport_tcp.c3631
-rw-r--r--src/transport/plugin_transport_template.c188
-rw-r--r--src/transport/plugin_transport_udp.c3988
-rw-r--r--src/transport/plugin_transport_udp.h46
-rw-r--r--src/transport/plugin_transport_udp_broadcasting.c643
-rw-r--r--src/transport/plugin_transport_unix.c1603
-rw-r--r--src/transport/plugin_transport_wlan.c2091
-rw-r--r--src/transport/plugin_transport_wlan.h53
-rw-r--r--src/transport/tcp_connection_legacy.c1315
-rw-r--r--src/transport/tcp_server_legacy.c1283
-rw-r--r--src/transport/tcp_server_mst_legacy.c329
-rw-r--r--src/transport/tcp_service_legacy.c1761
-rw-r--r--src/transport/test_communicator_unix.c222
-rw-r--r--src/transport/test_http_common.c227
-rw-r--r--src/transport/test_plugin_transport.c836
-rw-r--r--src/transport/test_quota_compliance.c326
-rw-r--r--src/transport/test_transport_address_switch.c406
-rw-r--r--src/transport/test_transport_api.c78
-rw-r--r--src/transport/test_transport_api_blacklisting.c178
-rw-r--r--src/transport/test_transport_api_disconnect.c96
-rw-r--r--src/transport/test_transport_api_limited_sockets.c78
-rw-r--r--src/transport/test_transport_api_manipulation_cfg.c175
-rw-r--r--src/transport/test_transport_api_manipulation_recv_tcp.c180
-rw-r--r--src/transport/test_transport_api_manipulation_send_tcp.c178
-rw-r--r--src/transport/test_transport_api_monitor_peers.c206
-rw-r--r--src/transport/test_transport_api_reliability.c218
-rw-r--r--src/transport/test_transport_api_restart_reconnect.c182
-rw-r--r--src/transport/test_transport_api_timeout.c128
-rw-r--r--src/transport/test_transport_blacklisting.c705
-rw-r--r--src/transport/test_transport_testing_restart.c133
-rw-r--r--src/transport/test_transport_testing_startstop.c117
-rw-r--r--src/transport/transport-testing-filenames.c124
-rw-r--r--src/transport/transport-testing-loggers.c44
-rw-r--r--src/transport/transport-testing-main.c460
-rw-r--r--src/transport/transport-testing-send.c206
-rw-r--r--src/transport/transport-testing.c1019
-rw-r--r--src/transport/transport-testing.h81
-rw-r--r--src/transport/transport-testing2.c456
-rw-r--r--src/transport/transport-testing2.h62
-rw-r--r--src/transport/transport.h155
-rw-r--r--src/transport/transport_api2_application.c189
-rw-r--r--src/transport/transport_api2_communication.c465
-rw-r--r--src/transport/transport_api2_core.c490
-rw-r--r--src/transport/transport_api2_monitor.c127
-rw-r--r--src/transport/transport_api_address_to_string.c222
-rw-r--r--src/transport/transport_api_blacklist.c91
-rw-r--r--src/transport/transport_api_core.c603
-rw-r--r--src/transport/transport_api_hello_get.c142
-rw-r--r--src/transport/transport_api_manipulation.c130
-rw-r--r--src/transport/transport_api_monitor_peers.c377
-rw-r--r--src/transport/transport_api_monitor_plugins.c294
-rw-r--r--src/transport/transport_api_offer_hello.c81
-rw-r--r--src/util/bandwidth.c368
-rw-r--r--src/util/benchmark.c260
-rw-r--r--src/util/benchmark.h92
-rw-r--r--src/util/bio.c384
-rw-r--r--src/util/client.c891
-rw-r--r--src/util/common_allocation.c294
-rw-r--r--src/util/common_endian.c26
-rw-r--r--src/util/common_logging.c1083
-rw-r--r--src/util/configuration.c1351
-rw-r--r--src/util/configuration_loader.c66
-rw-r--r--src/util/container_bloomfilter.c552
-rw-r--r--src/util/container_heap.c329
-rw-r--r--src/util/container_meta_data.c975
-rw-r--r--src/util/container_multihashmap.c885
-rw-r--r--src/util/container_multihashmap32.c333
-rw-r--r--src/util/container_multipeermap.c831
-rw-r--r--src/util/container_multishortmap.c785
-rw-r--r--src/util/container_multiuuidmap.c795
-rw-r--r--src/util/crypto_abe.c335
-rw-r--r--src/util/crypto_crc.c63
-rw-r--r--src/util/crypto_ecc.c1416
-rw-r--r--src/util/crypto_ecc_dlog.c377
-rw-r--r--src/util/crypto_ecc_setup.c608
-rw-r--r--src/util/crypto_hash.c305
-rw-r--r--src/util/crypto_hash_file.c167
-rw-r--r--src/util/crypto_hkdf.c184
-rw-r--r--src/util/crypto_kdf.c136
-rw-r--r--src/util/crypto_mpi.c112
-rw-r--r--src/util/crypto_paillier.c423
-rw-r--r--src/util/crypto_random.c283
-rw-r--r--src/util/crypto_rsa.c1106
-rw-r--r--src/util/crypto_symmetric.c186
-rw-r--r--src/util/disk.c2507
-rw-r--r--src/util/disk.h8
-rw-r--r--src/util/dnsparser.c1292
-rw-r--r--src/util/dnsstub.c546
-rw-r--r--src/util/getopt.c1041
-rw-r--r--src/util/getopt_helpers.c766
-rw-r--r--src/util/gnunet-config-diff.c20
-rw-r--r--src/util/gnunet-config.c342
-rw-r--r--src/util/gnunet-ecc.c560
-rw-r--r--src/util/gnunet-helper-w32-console.c249
-rw-r--r--src/util/gnunet-helper-w32-console.h10
-rw-r--r--src/util/gnunet-qr.c258
-rw-r--r--src/util/gnunet-resolver.c146
-rw-r--r--src/util/gnunet-scrypt.c356
-rw-r--r--src/util/gnunet-service-resolver.c1241
-rw-r--r--src/util/gnunet-timeout-w32.c182
-rw-r--r--src/util/gnunet-timeout.c104
-rw-r--r--src/util/gnunet-uri.c149
-rw-r--r--src/util/helper.c562
-rw-r--r--src/util/load.c97
-rw-r--r--src/util/mq.c680
-rw-r--r--src/util/mst.c463
-rw-r--r--src/util/nc.c97
-rw-r--r--src/util/network.c1975
-rw-r--r--src/util/op.c157
-rw-r--r--src/util/os_installation.c1005
-rw-r--r--src/util/os_network.c560
-rw-r--r--src/util/os_priority.c2218
-rw-r--r--src/util/peer.c141
-rw-r--r--src/util/perf_crypto_asymmetric.c95
-rw-r--r--src/util/perf_crypto_ecc_dlog.c168
-rw-r--r--src/util/perf_crypto_hash.c84
-rw-r--r--src/util/perf_crypto_paillier.c90
-rw-r--r--src/util/perf_crypto_rsa.c266
-rw-r--r--src/util/perf_crypto_symmetric.c52
-rw-r--r--src/util/perf_malloc.c30
-rw-r--r--src/util/plugin.c246
-rw-r--r--src/util/proc_compat.c14
-rw-r--r--src/util/program.c354
-rw-r--r--src/util/regex.c970
-rw-r--r--src/util/resolver.h11
-rw-r--r--src/util/resolver_api.c1294
-rw-r--r--src/util/scheduler.c1923
-rw-r--r--src/util/service.c2247
-rw-r--r--src/util/signal.c64
-rw-r--r--src/util/socks.c549
-rw-r--r--src/util/speedup.c94
-rw-r--r--src/util/speedup.h10
-rw-r--r--src/util/strings.c2002
-rw-r--r--src/util/test_bio.c436
-rw-r--r--src/util/test_client.c154
-rw-r--r--src/util/test_common_allocation.c118
-rw-r--r--src/util/test_common_endian.c18
-rw-r--r--src/util/test_common_logging.c96
-rw-r--r--src/util/test_common_logging_dummy.c92
-rw-r--r--src/util/test_common_logging_runtime_loglevels.c493
-rw-r--r--src/util/test_configuration.c663
-rw-r--r--src/util/test_container_bloomfilter.c304
-rw-r--r--src/util/test_container_dll.c79
-rw-r--r--src/util/test_container_heap.c382
-rw-r--r--src/util/test_container_meta_data.c426
-rw-r--r--src/util/test_container_multihashmap.c126
-rw-r--r--src/util/test_container_multihashmap32.c92
-rw-r--r--src/util/test_container_multipeermap.c126
-rw-r--r--src/util/test_crypto_crc.c12
-rw-r--r--src/util/test_crypto_ecc_dlog.c174
-rw-r--r--src/util/test_crypto_ecdh_eddsa.c82
-rw-r--r--src/util/test_crypto_ecdhe.c58
-rw-r--r--src/util/test_crypto_ecdsa.c266
-rw-r--r--src/util/test_crypto_eddsa.c206
-rw-r--r--src/util/test_crypto_hash.c104
-rw-r--r--src/util/test_crypto_hash_context.c44
-rw-r--r--src/util/test_crypto_hkdf.c276
-rw-r--r--src/util/test_crypto_kdf.c47
-rw-r--r--src/util/test_crypto_paillier.c305
-rw-r--r--src/util/test_crypto_random.c37
-rw-r--r--src/util/test_crypto_rsa.c154
-rw-r--r--src/util/test_crypto_symmetric.c152
-rw-r--r--src/util/test_disk.c336
-rw-r--r--src/util/test_getopt.c167
-rw-r--r--src/util/test_hexcoder.c32
-rw-r--r--src/util/test_mq.c281
-rw-r--r--src/util/test_os_network.c68
-rw-r--r--src/util/test_os_start_process.c279
-rw-r--r--src/util/test_peer.c98
-rw-r--r--src/util/test_plugin.c40
-rw-r--r--src/util/test_plugin_plug.c14
-rw-r--r--src/util/test_program.c128
-rw-r--r--src/util/test_regex.c184
-rw-r--r--src/util/test_resolver_api.c421
-rw-r--r--src/util/test_scheduler.c182
-rw-r--r--src/util/test_scheduler_delay.c56
-rw-r--r--src/util/test_service.c196
-rw-r--r--src/util/test_socks.c255
-rw-r--r--src/util/test_speedup.c86
-rw-r--r--src/util/test_strings.c170
-rw-r--r--src/util/test_strings_to_data.c43
-rw-r--r--src/util/test_time.c260
-rw-r--r--src/util/test_tun.c66
-rw-r--r--src/util/time.c413
-rw-r--r--src/util/tun.c264
-rw-r--r--src/util/w32cat.c166
-rw-r--r--src/util/win.c1319
-rw-r--r--src/util/winproc.c369
-rw-r--r--src/vpn/gnunet-helper-vpn-windows.c1106
-rw-r--r--src/vpn/gnunet-helper-vpn.c897
-rw-r--r--src/vpn/gnunet-service-vpn.c3814
-rw-r--r--src/vpn/gnunet-vpn.c375
-rw-r--r--src/vpn/vpn.h17
-rw-r--r--src/vpn/vpn_api.c339
-rw-r--r--src/zonemaster/gnunet-service-zonemaster-monitor.c423
-rw-r--r--src/zonemaster/gnunet-service-zonemaster.c801
1047 files changed, 224184 insertions, 224529 deletions
diff --git a/src/abe/abe.c b/src/abe/abe.c
index 091ba0ced..31c6e04e0 100644
--- a/src/abe/abe.c
+++ b/src/abe/abe.c
@@ -11,13 +11,13 @@
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 abe/abe.c
@@ -33,55 +33,53 @@
#include "gnunet_crypto_lib.h"
#include "gnunet_abe_lib.h"
-struct GNUNET_ABE_AbeMasterKey
-{
+struct GNUNET_ABE_AbeMasterKey {
gabe_pub_t* pub;
gabe_msk_t* msk;
};
-struct GNUNET_ABE_AbeKey
-{
+struct GNUNET_ABE_AbeKey {
gabe_pub_t* pub;
gabe_prv_t* prv;
};
static int
-init_aes( element_t k, int enc,
- gcry_cipher_hd_t* handle,
- struct GNUNET_CRYPTO_SymmetricSessionKey *key,
- unsigned char* iv)
+init_aes(element_t k, int enc,
+ gcry_cipher_hd_t* handle,
+ struct GNUNET_CRYPTO_SymmetricSessionKey *key,
+ unsigned char* iv)
{
int rc;
int key_len;
unsigned char* key_buf;
key_len = element_length_in_bytes(k) < 33 ? 3 : element_length_in_bytes(k);
- key_buf = (unsigned char*) malloc(key_len);
+ key_buf = (unsigned char*)malloc(key_len);
element_to_bytes(key_buf, k);
- GNUNET_memcpy (key->aes_key, key_buf, GNUNET_CRYPTO_AES_KEY_LENGTH);
- GNUNET_assert (0 ==
- gcry_cipher_open (handle, GCRY_CIPHER_AES256,
- GCRY_CIPHER_MODE_CFB, 0));
- rc = gcry_cipher_setkey (*handle,
- key->aes_key,
- sizeof (key->aes_key));
- GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY));
- memset (iv, 0, 16); //TODO make reasonable
- rc = gcry_cipher_setiv (*handle,
- iv,
- 16);
- GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY));
+ GNUNET_memcpy(key->aes_key, key_buf, GNUNET_CRYPTO_AES_KEY_LENGTH);
+ GNUNET_assert(0 ==
+ gcry_cipher_open(handle, GCRY_CIPHER_AES256,
+ GCRY_CIPHER_MODE_CFB, 0));
+ rc = gcry_cipher_setkey(*handle,
+ key->aes_key,
+ sizeof(key->aes_key));
+ GNUNET_assert((0 == rc) || ((char)rc == GPG_ERR_WEAK_KEY));
+ memset(iv, 0, 16); //TODO make reasonable
+ rc = gcry_cipher_setiv(*handle,
+ iv,
+ 16);
+ GNUNET_assert((0 == rc) || ((char)rc == GPG_ERR_WEAK_KEY));
free(key_buf);
return rc;
}
static int
-aes_128_cbc_encrypt( char* pt,
- int size,
- element_t k,
- char **ct )
+aes_128_cbc_encrypt(char* pt,
+ int size,
+ element_t k,
+ char **ct)
{
gcry_cipher_hd_t handle;
struct GNUNET_CRYPTO_SymmetricSessionKey skey;
@@ -90,34 +88,35 @@ aes_128_cbc_encrypt( char* pt,
int padding;
int buf_size;
uint8_t len[4];
+
init_aes(k, 1, &handle, &skey, iv);
/* TODO make less crufty */
/* stuff in real length (big endian) before padding */
- len[0] = (size & 0xff000000)>>24;
- len[1] = (size & 0xff0000)>>16;
- len[2] = (size & 0xff00)>>8;
- len[3] = (size & 0xff)>>0;
- padding = 16 - ((4+size) % 16);
+ len[0] = (size & 0xff000000) >> 24;
+ len[1] = (size & 0xff0000) >> 16;
+ len[2] = (size & 0xff00) >> 8;
+ len[3] = (size & 0xff) >> 0;
+ padding = 16 - ((4 + size) % 16);
buf_size = 4 + size + padding;
- buf = GNUNET_malloc (buf_size);
- GNUNET_memcpy (buf, len, 4);
- GNUNET_memcpy (buf+4, pt, size);
- *ct = GNUNET_malloc (buf_size);
+ buf = GNUNET_malloc(buf_size);
+ GNUNET_memcpy(buf, len, 4);
+ GNUNET_memcpy(buf + 4, pt, size);
+ *ct = GNUNET_malloc(buf_size);
- GNUNET_assert (0 == gcry_cipher_encrypt (handle, *ct, buf_size, buf, buf_size));
- gcry_cipher_close (handle);
+ GNUNET_assert(0 == gcry_cipher_encrypt(handle, *ct, buf_size, buf, buf_size));
+ gcry_cipher_close(handle);
//AES_cbc_encrypt(pt->data, ct->data, pt->len, &key, iv, AES_ENCRYPT);
- GNUNET_free (buf);
+ GNUNET_free(buf);
return buf_size;
}
static int
-aes_128_cbc_decrypt( char* ct,
- int size,
- element_t k,
- char **pt )
+aes_128_cbc_decrypt(char* ct,
+ int size,
+ element_t k,
+ char **pt)
{
struct GNUNET_CRYPTO_SymmetricSessionKey skey;
gcry_cipher_hd_t handle;
@@ -127,22 +126,22 @@ aes_128_cbc_decrypt( char* ct,
init_aes(k, 1, &handle, &skey, iv);
- tmp = GNUNET_malloc (size);
+ tmp = GNUNET_malloc(size);
//AES_cbc_encrypt(ct->data, pt->data, ct->len, &key, iv, AES_DECRYPT);
- GNUNET_assert (0 == gcry_cipher_decrypt (handle, tmp, size, ct, size));
- gcry_cipher_close (handle);
+ GNUNET_assert(0 == gcry_cipher_decrypt(handle, tmp, size, ct, size));
+ gcry_cipher_close(handle);
/* TODO make less crufty */
/* get real length */
len = 0;
len = len
- | ((tmp[0])<<24) | ((tmp[1])<<16)
- | ((tmp[2])<<8) | ((tmp[3])<<0);
+ | ((tmp[0]) << 24) | ((tmp[1]) << 16)
+ | ((tmp[2]) << 8) | ((tmp[3]) << 0);
/* truncate any garbage from the padding */
- *pt = GNUNET_malloc (len);
- GNUNET_memcpy (*pt, tmp+4, len);
- GNUNET_free (tmp);
+ *pt = GNUNET_malloc(len);
+ GNUNET_memcpy(*pt, tmp + 4, len);
+ GNUNET_free(tmp);
return len;
}
@@ -153,13 +152,14 @@ aes_128_cbc_decrypt( char* ct,
* @return fresh private key; free using #GNUNET_ABE_cpabe_delete_master_key
*/
struct GNUNET_ABE_AbeMasterKey*
-GNUNET_ABE_cpabe_create_master_key (void)
+GNUNET_ABE_cpabe_create_master_key(void)
{
struct GNUNET_ABE_AbeMasterKey* key;
- key = GNUNET_new (struct GNUNET_ABE_AbeMasterKey);
+
+ key = GNUNET_new(struct GNUNET_ABE_AbeMasterKey);
gabe_setup(&key->pub, &key->msk);
- GNUNET_assert (NULL != key->pub);
- GNUNET_assert (NULL != key->msk);
+ GNUNET_assert(NULL != key->pub);
+ GNUNET_assert(NULL != key->msk);
return key;
}
@@ -171,13 +171,13 @@ GNUNET_ABE_cpabe_create_master_key (void)
* @return fresh private key; free using #GNUNET_free
*/
void
-GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key)
+GNUNET_ABE_cpabe_delete_master_key(struct GNUNET_ABE_AbeMasterKey *key)
{
- gabe_msk_free (key->msk);
- gabe_pub_free (key->pub);
+ gabe_msk_free(key->msk);
+ gabe_pub_free(key->pub);
//GNUNET_free (key->msk);
//gabe_msk_free (key->msk); //For some reason free of pub implicit?
- GNUNET_free (key);
+ GNUNET_free(key);
}
/**
@@ -189,19 +189,19 @@ GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key)
* @return fresh private key; free using #GNUNET_ABE_cpabe_delete_key
*/
struct GNUNET_ABE_AbeKey*
-GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *key,
- char **attrs)
+GNUNET_ABE_cpabe_create_key(struct GNUNET_ABE_AbeMasterKey *key,
+ char **attrs)
{
struct GNUNET_ABE_AbeKey *prv_key;
int size;
char *tmp;
- prv_key = GNUNET_new (struct GNUNET_ABE_AbeKey);
+ prv_key = GNUNET_new(struct GNUNET_ABE_AbeKey);
prv_key->prv = gabe_keygen(key->pub, key->msk, attrs);
size = gabe_pub_serialize(key->pub, &tmp);
prv_key->pub = gabe_pub_unserialize(tmp, size);
- GNUNET_free (tmp);
- GNUNET_assert (NULL != prv_key->prv);
+ GNUNET_free(tmp);
+ GNUNET_assert(NULL != prv_key->prv);
return prv_key;
}
@@ -214,50 +214,50 @@ GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *key,
* @return fresh private key; free using #GNUNET_free
*/
void
-GNUNET_ABE_cpabe_delete_key (struct GNUNET_ABE_AbeKey *key,
- int delete_pub)
+GNUNET_ABE_cpabe_delete_key(struct GNUNET_ABE_AbeKey *key,
+ int delete_pub)
{
//Memory management in gabe is buggy
- gabe_prv_free (key->prv);
+ gabe_prv_free(key->prv);
if (GNUNET_YES == delete_pub)
- gabe_pub_free (key->pub);
- GNUNET_free (key);
+ gabe_pub_free(key->pub);
+ GNUNET_free(key);
}
static ssize_t
-write_cpabe (void **result,
- uint32_t file_len,
- char* cph_buf,
- int cph_buf_len,
- char* aes_buf,
- int aes_buf_len)
+write_cpabe(void **result,
+ uint32_t file_len,
+ char* cph_buf,
+ int cph_buf_len,
+ char* aes_buf,
+ int aes_buf_len)
{
char *ptr;
uint32_t *len;
- *result = GNUNET_malloc (12 + cph_buf_len + aes_buf_len);
+ *result = GNUNET_malloc(12 + cph_buf_len + aes_buf_len);
ptr = *result;
- len = (uint32_t*) ptr;
- *len = htonl (file_len);
+ len = (uint32_t*)ptr;
+ *len = htonl(file_len);
ptr += 4;
- len = (uint32_t*) ptr;
- *len = htonl (aes_buf_len);
+ len = (uint32_t*)ptr;
+ *len = htonl(aes_buf_len);
ptr += 4;
- GNUNET_memcpy (ptr, aes_buf, aes_buf_len);
+ GNUNET_memcpy(ptr, aes_buf, aes_buf_len);
ptr += aes_buf_len;
- len = (uint32_t*) ptr;
- *len = htonl (cph_buf_len);
+ len = (uint32_t*)ptr;
+ *len = htonl(cph_buf_len);
ptr += 4;
- GNUNET_memcpy (ptr, cph_buf, cph_buf_len);
+ GNUNET_memcpy(ptr, cph_buf, cph_buf_len);
return 12 + cph_buf_len + aes_buf_len;
}
static ssize_t
-read_cpabe (const void *data,
- char** cph_buf,
- int *cph_buf_len,
- char** aes_buf,
- int *aes_buf_len)
+read_cpabe(const void *data,
+ char** cph_buf,
+ int *cph_buf_len,
+ char** aes_buf,
+ int *aes_buf_len)
{
int buf_len;
char *ptr;
@@ -265,18 +265,18 @@ read_cpabe (const void *data,
ptr = (char*)data;
len = (uint32_t*)ptr;
- buf_len = ntohl (*len);
+ buf_len = ntohl(*len);
ptr += 4;
len = (uint32_t*)ptr;
- *aes_buf_len = ntohl (*len);
+ *aes_buf_len = ntohl(*len);
ptr += 4;
- *aes_buf = GNUNET_malloc (*aes_buf_len);
+ *aes_buf = GNUNET_malloc(*aes_buf_len);
GNUNET_memcpy(*aes_buf, ptr, *aes_buf_len);
ptr += *aes_buf_len;
len = (uint32_t*)ptr;
- *cph_buf_len = ntohl (*len);
+ *cph_buf_len = ntohl(*len);
ptr += 4;
- *cph_buf = GNUNET_malloc (*cph_buf_len);
+ *cph_buf = GNUNET_malloc(*cph_buf_len);
GNUNET_memcpy(*cph_buf, ptr, *cph_buf_len);
return buf_len;
@@ -294,11 +294,11 @@ read_cpabe (const void *data,
* @return the size of the encrypted block, -1 for errors
*/
ssize_t
-GNUNET_ABE_cpabe_encrypt (const void *block,
- size_t size,
- const char *policy,
- const struct GNUNET_ABE_AbeMasterKey *key,
- void **result)
+GNUNET_ABE_cpabe_encrypt(const void *block,
+ size_t size,
+ const char *policy,
+ const struct GNUNET_ABE_AbeMasterKey *key,
+ void **result)
{
gabe_cph_t* cph;
char* plt;
@@ -309,15 +309,15 @@ GNUNET_ABE_cpabe_encrypt (const void *block,
int aes_buf_len;
ssize_t result_len;
- if( !(cph = gabe_enc(key->pub, m, (char*)policy)) )
+ if (!(cph = gabe_enc(key->pub, m, (char*)policy)))
return GNUNET_SYSERR;
cph_buf_len = gabe_cph_serialize(cph,
- &cph_buf);
+ &cph_buf);
gabe_cph_free(cph);
- GNUNET_free (cph);
- plt = GNUNET_memdup (block, size);
+ GNUNET_free(cph);
+ plt = GNUNET_memdup(block, size);
aes_buf_len = aes_128_cbc_encrypt(plt, size, m, &aes_buf);
- GNUNET_free (plt);
+ GNUNET_free(plt);
element_clear(m);
result_len = write_cpabe(result, size, cph_buf, cph_buf_len, aes_buf, aes_buf_len);
GNUNET_free(cph_buf);
@@ -336,10 +336,10 @@ GNUNET_ABE_cpabe_encrypt (const void *block,
* @return the size of the encrypted block, -1 for errors
*/
ssize_t
-GNUNET_ABE_cpabe_decrypt (const void *block,
- size_t size,
- const struct GNUNET_ABE_AbeKey *key,
- void **result)
+GNUNET_ABE_cpabe_decrypt(const void *block,
+ size_t size,
+ const struct GNUNET_ABE_AbeKey *key,
+ void **result)
{
char* aes_buf;
char* cph_buf;
@@ -351,22 +351,23 @@ GNUNET_ABE_cpabe_decrypt (const void *block,
read_cpabe(block, &cph_buf, &cph_buf_size, &aes_buf, &aes_buf_size);
cph = gabe_cph_unserialize(key->pub, cph_buf, cph_buf_size);
- if( !gabe_dec(key->pub, key->prv, cph, m) ) {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%s\n", gabe_error());
- GNUNET_free (aes_buf);
- GNUNET_free (cph_buf);
- gabe_cph_free(cph);
- GNUNET_free (cph);
- element_clear (m);
- return GNUNET_SYSERR;
- }
+ if (!gabe_dec(key->pub, key->prv, cph, m))
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "%s\n", gabe_error());
+ GNUNET_free(aes_buf);
+ GNUNET_free(cph_buf);
+ gabe_cph_free(cph);
+ GNUNET_free(cph);
+ element_clear(m);
+ return GNUNET_SYSERR;
+ }
gabe_cph_free(cph);
- GNUNET_free (cph);
+ GNUNET_free(cph);
plt_len = aes_128_cbc_decrypt(aes_buf, aes_buf_size, m, (char**)result);
- GNUNET_free (cph_buf);
- GNUNET_free (aes_buf);
- element_clear (m);
+ GNUNET_free(cph_buf);
+ GNUNET_free(aes_buf);
+ element_clear(m);
//freeing is buggy in gabe
//gabe_prv_free (prv);
//gabe_pub_free (pub);
@@ -382,8 +383,8 @@ GNUNET_ABE_cpabe_decrypt (const void *block,
* @return the size of the encrypted block, -1 for errors
*/
ssize_t
-GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key,
- void **result)
+GNUNET_ABE_cpabe_serialize_key(const struct GNUNET_ABE_AbeKey *key,
+ void **result)
{
ssize_t len;
char *pub;
@@ -391,14 +392,14 @@ GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key,
int pub_len;
int prv_len;
- pub_len = gabe_pub_serialize (key->pub, &pub);
- prv_len = gabe_prv_serialize (key->prv, &prv);
+ pub_len = gabe_pub_serialize(key->pub, &pub);
+ prv_len = gabe_prv_serialize(key->prv, &prv);
len = pub_len + prv_len + 12;
- write_cpabe (result, len, pub, pub_len, prv, prv_len);
+ write_cpabe(result, len, pub, pub_len, prv, prv_len);
- GNUNET_free (pub);
- GNUNET_free (prv);
+ GNUNET_free(pub);
+ GNUNET_free(prv);
return len;
}
@@ -412,8 +413,8 @@ GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key,
* @return the ABE key. NULL of unsuccessful
*/
struct GNUNET_ABE_AbeKey*
-GNUNET_ABE_cpabe_deserialize_key (const void *data,
- size_t len)
+GNUNET_ABE_cpabe_deserialize_key(const void *data,
+ size_t len)
{
struct GNUNET_ABE_AbeKey *key;
char *pub;
@@ -421,17 +422,17 @@ GNUNET_ABE_cpabe_deserialize_key (const void *data,
int prv_len;
int pub_len;
- key = GNUNET_new (struct GNUNET_ABE_AbeKey);
- read_cpabe (data,
- &pub,
- &pub_len,
- &prv,
- &prv_len);
- key->pub = gabe_pub_unserialize (pub, pub_len);
- key->prv = gabe_prv_unserialize (key->pub, prv, prv_len);
-
- GNUNET_free (pub);
- GNUNET_free (prv);
+ key = GNUNET_new(struct GNUNET_ABE_AbeKey);
+ read_cpabe(data,
+ &pub,
+ &pub_len,
+ &prv,
+ &prv_len);
+ key->pub = gabe_pub_unserialize(pub, pub_len);
+ key->prv = gabe_prv_unserialize(key->pub, prv, prv_len);
+
+ GNUNET_free(pub);
+ GNUNET_free(prv);
return key;
}
@@ -444,8 +445,8 @@ GNUNET_ABE_cpabe_deserialize_key (const void *data,
* @return the size of the encrypted block, -1 for errors
*/
ssize_t
-GNUNET_ABE_cpabe_serialize_master_key (const struct GNUNET_ABE_AbeMasterKey *key,
- void **result)
+GNUNET_ABE_cpabe_serialize_master_key(const struct GNUNET_ABE_AbeMasterKey *key,
+ void **result)
{
ssize_t len;
char *pub;
@@ -453,14 +454,14 @@ GNUNET_ABE_cpabe_serialize_master_key (const struct GNUNET_ABE_AbeMasterKey *key
int pub_len;
int msk_len;
- pub_len = gabe_pub_serialize (key->pub, &pub);
- msk_len = gabe_msk_serialize (key->msk, &msk);
+ pub_len = gabe_pub_serialize(key->pub, &pub);
+ msk_len = gabe_msk_serialize(key->msk, &msk);
len = pub_len + msk_len + 12;
- write_cpabe (result, len, pub, pub_len, msk, msk_len);
+ write_cpabe(result, len, pub, pub_len, msk, msk_len);
- GNUNET_free (pub);
- GNUNET_free (msk);
+ GNUNET_free(pub);
+ GNUNET_free(msk);
return len;
}
@@ -474,8 +475,8 @@ GNUNET_ABE_cpabe_serialize_master_key (const struct GNUNET_ABE_AbeMasterKey *key
* @return the ABE key. NULL of unsuccessful
*/
struct GNUNET_ABE_AbeMasterKey*
-GNUNET_ABE_cpabe_deserialize_master_key (const void *data,
- size_t len)
+GNUNET_ABE_cpabe_deserialize_master_key(const void *data,
+ size_t len)
{
struct GNUNET_ABE_AbeMasterKey *key;
char *msk;
@@ -483,17 +484,17 @@ GNUNET_ABE_cpabe_deserialize_master_key (const void *data,
int msk_len;
int pub_len;
- key = GNUNET_new (struct GNUNET_ABE_AbeMasterKey);
- read_cpabe (data,
- &pub,
- &pub_len,
- &msk,
- &msk_len);
- key->pub = gabe_pub_unserialize (pub, pub_len);
- key->msk = gabe_msk_unserialize (key->pub, msk, msk_len);
-
- GNUNET_free (pub);
- GNUNET_free (msk);
+ key = GNUNET_new(struct GNUNET_ABE_AbeMasterKey);
+ read_cpabe(data,
+ &pub,
+ &pub_len,
+ &msk,
+ &msk_len);
+ key->pub = gabe_pub_unserialize(pub, pub_len);
+ key->msk = gabe_msk_unserialize(key->pub, msk, msk_len);
+
+ GNUNET_free(pub);
+ GNUNET_free(msk);
return key;
}
diff --git a/src/abe/test_cpabe.c b/src/abe/test_cpabe.c
index e2c86e986..84b45fc8a 100644
--- a/src/abe/test_cpabe.c
+++ b/src/abe/test_cpabe.c
@@ -11,13 +11,13 @@
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 Martin Schanzenbach
* @file util/test_crypto_abe.c
@@ -30,7 +30,7 @@
#define TESTSTRING "Hello World!"
static int
-testAbecipher ()
+testAbecipher()
{
struct GNUNET_ABE_AbeMasterKey *msk;
struct GNUNET_ABE_AbeKey *key;
@@ -38,49 +38,50 @@ testAbecipher ()
char **attrs;
int size;
char *res;
- msk = GNUNET_ABE_cpabe_create_master_key ();
- size = GNUNET_ABE_cpabe_encrypt (TESTSTRING, strlen (TESTSTRING) + 1,
- "testattr", //Policy
- msk,
- (void*)&result);
- GNUNET_assert (-1 != size);
- attrs = GNUNET_malloc (2 * sizeof (char*));
+
+ msk = GNUNET_ABE_cpabe_create_master_key();
+ size = GNUNET_ABE_cpabe_encrypt(TESTSTRING, strlen(TESTSTRING) + 1,
+ "testattr", //Policy
+ msk,
+ (void*)&result);
+ GNUNET_assert(-1 != size);
+ attrs = GNUNET_malloc(2 * sizeof(char*));
attrs[0] = "testattr";
attrs[1] = NULL;
- key = GNUNET_ABE_cpabe_create_key (msk,
- attrs);
+ key = GNUNET_ABE_cpabe_create_key(msk,
+ attrs);
- size = GNUNET_ABE_cpabe_decrypt (result, size,
- key,
- (void*)&res);
- if (strlen (TESTSTRING) + 1 != size)
- {
- printf ("abeciphertest failed: decryptBlock returned %d\n", size);
- return 1;
- }
- if (0 != strcmp (res, TESTSTRING))
- {
- printf ("abeciphertest failed: %s != %s\n", res, TESTSTRING);
- return 1;
- }
+ size = GNUNET_ABE_cpabe_decrypt(result, size,
+ key,
+ (void*)&res);
+ if (strlen(TESTSTRING) + 1 != size)
+ {
+ printf("abeciphertest failed: decryptBlock returned %d\n", size);
+ return 1;
+ }
+ if (0 != strcmp(res, TESTSTRING))
+ {
+ printf("abeciphertest failed: %s != %s\n", res, TESTSTRING);
+ return 1;
+ }
else
return 0;
}
int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
{
int failureCount = 0;
- GNUNET_log_setup ("test-crypto-abe", "WARNING", NULL);
- failureCount += testAbecipher ();
+ GNUNET_log_setup("test-crypto-abe", "WARNING", NULL);
+ failureCount += testAbecipher();
if (failureCount != 0)
- {
- printf ("%d TESTS FAILED!\n", failureCount);
- return -1;
- }
+ {
+ printf("%d TESTS FAILED!\n", failureCount);
+ return -1;
+ }
return 0;
}
diff --git a/src/arm/arm.h b/src/arm/arm.h
index 937cca1e7..983586060 100644
--- a/src/arm/arm.h
+++ b/src/arm/arm.h
@@ -11,12 +11,12 @@
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 Christian Grothoff
@@ -38,9 +38,7 @@ GNUNET_NETWORK_STRUCT_BEGIN
/**
* Status update from ARM to client.
*/
-struct GNUNET_ARM_StatusMessage
-{
-
+struct GNUNET_ARM_StatusMessage {
/**
* Reply to client, of type is #GNUNET_MESSAGE_TYPE_ARM_STATUS.
*/
@@ -54,8 +52,7 @@ struct GNUNET_ARM_StatusMessage
/* followed by a 0-terminated service name */
};
-struct GNUNET_ARM_Message
-{
+struct GNUNET_ARM_Message {
/**
* Reply to client, type is #GNUNET_MESSAGE_TYPE_ARM_RESULT or
* #GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT.
@@ -84,9 +81,7 @@ struct GNUNET_ARM_Message
/**
* Reply from ARM to client.
*/
-struct GNUNET_ARM_ResultMessage
-{
-
+struct GNUNET_ARM_ResultMessage {
/**
* Reply to client, of type is #GNUNET_MESSAGE_TYPE_ARM_RESULT, with an ID.
*/
@@ -104,8 +99,7 @@ struct GNUNET_ARM_ResultMessage
* '\0' terminated strings. header->size contains the
* total size (including all strings).
*/
-struct GNUNET_ARM_ListResultMessage
-{
+struct GNUNET_ARM_ListResultMessage {
/**
* Reply to client, of type is #GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT,
* with an ID.
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c
index bf0acbcb9..b42c95dc0 100644
--- a/src/arm/arm_api.c
+++ b/src/arm/arm_api.c
@@ -11,12 +11,12 @@
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 arm/arm_api.c
@@ -30,15 +30,14 @@
#include "gnunet_protocols.h"
#include "arm.h"
-#define LOG(kind, ...) GNUNET_log_from (kind, "arm-api", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from(kind, "arm-api", __VA_ARGS__)
/**
* Entry in a doubly-linked list of operations awaiting for replies
* (in-order) from the ARM service.
*/
-struct GNUNET_ARM_Operation
-{
+struct GNUNET_ARM_Operation {
/**
* This is a doubly-linked list.
*/
@@ -94,8 +93,7 @@ struct GNUNET_ARM_Operation
/**
* Handle for interacting with ARM.
*/
-struct GNUNET_ARM_Handle
-{
+struct GNUNET_ARM_Handle {
/**
* Our connection to the ARM service.
*/
@@ -166,7 +164,7 @@ struct GNUNET_ARM_Handle
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/
static int
-reconnect_arm (struct GNUNET_ARM_Handle *h);
+reconnect_arm(struct GNUNET_ARM_Handle *h);
/**
@@ -175,12 +173,12 @@ reconnect_arm (struct GNUNET_ARM_Handle *h);
* @param cls the `struct GNUNET_ARM_Handle`
*/
static void
-reconnect_arm_task (void *cls)
+reconnect_arm_task(void *cls)
{
struct GNUNET_ARM_Handle *h = cls;
h->reconnect_task = NULL;
- reconnect_arm (h);
+ reconnect_arm(h);
}
@@ -191,31 +189,31 @@ reconnect_arm_task (void *cls)
* @param h our handle
*/
static void
-reconnect_arm_later (struct GNUNET_ARM_Handle *h)
+reconnect_arm_later(struct GNUNET_ARM_Handle *h)
{
struct GNUNET_ARM_Operation *op;
if (NULL != h->mq)
- {
- GNUNET_MQ_destroy (h->mq);
- h->mq = NULL;
- }
+ {
+ GNUNET_MQ_destroy(h->mq);
+ h->mq = NULL;
+ }
h->currently_up = GNUNET_NO;
- GNUNET_assert (NULL == h->reconnect_task);
+ GNUNET_assert(NULL == h->reconnect_task);
h->reconnect_task =
- GNUNET_SCHEDULER_add_delayed (h->retry_backoff, &reconnect_arm_task, h);
+ GNUNET_SCHEDULER_add_delayed(h->retry_backoff, &reconnect_arm_task, h);
while (NULL != (op = h->operation_pending_head))
- {
- if (NULL != op->result_cont)
- op->result_cont (op->cont_cls, GNUNET_ARM_REQUEST_DISCONNECTED, 0);
- if (NULL != op->list_cont)
- op->list_cont (op->cont_cls, GNUNET_ARM_REQUEST_DISCONNECTED, 0, NULL);
- GNUNET_ARM_operation_cancel (op);
- }
- GNUNET_assert (NULL == h->operation_pending_head);
- h->retry_backoff = GNUNET_TIME_STD_BACKOFF (h->retry_backoff);
+ {
+ if (NULL != op->result_cont)
+ op->result_cont(op->cont_cls, GNUNET_ARM_REQUEST_DISCONNECTED, 0);
+ if (NULL != op->list_cont)
+ op->list_cont(op->cont_cls, GNUNET_ARM_REQUEST_DISCONNECTED, 0, NULL);
+ GNUNET_ARM_operation_cancel(op);
+ }
+ GNUNET_assert(NULL == h->operation_pending_head);
+ h->retry_backoff = GNUNET_TIME_STD_BACKOFF(h->retry_backoff);
if (NULL != h->conn_status)
- h->conn_status (h->conn_status_cls, GNUNET_NO);
+ h->conn_status(h->conn_status_cls, GNUNET_NO);
}
@@ -227,7 +225,7 @@ reconnect_arm_later (struct GNUNET_ARM_Handle *h)
* @return NULL if not found
*/
static struct GNUNET_ARM_Operation *
-find_op_by_id (struct GNUNET_ARM_Handle *h, uint64_t id)
+find_op_by_id(struct GNUNET_ARM_Handle *h, uint64_t id)
{
struct GNUNET_ARM_Operation *result;
@@ -246,7 +244,7 @@ find_op_by_id (struct GNUNET_ARM_Handle *h, uint64_t id)
* @param res the message received from the arm service
*/
static void
-handle_arm_result (void *cls, const struct GNUNET_ARM_ResultMessage *res)
+handle_arm_result(void *cls, const struct GNUNET_ARM_ResultMessage *res)
{
struct GNUNET_ARM_Handle *h = cls;
struct GNUNET_ARM_Operation *op;
@@ -255,43 +253,43 @@ handle_arm_result (void *cls, const struct GNUNET_ARM_ResultMessage *res)
GNUNET_ARM_ResultCallback result_cont;
void *result_cont_cls;
- id = GNUNET_ntohll (res->arm_msg.request_id);
- op = find_op_by_id (h, id);
+ id = GNUNET_ntohll(res->arm_msg.request_id);
+ op = find_op_by_id(h, id);
if (NULL == op)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Message with unknown id %llu\n",
- (unsigned long long) id);
- return;
- }
-
- result = (enum GNUNET_ARM_Result) ntohl (res->result);
+ {
+ LOG(GNUNET_ERROR_TYPE_DEBUG,
+ "Message with unknown id %llu\n",
+ (unsigned long long)id);
+ return;
+ }
+
+ result = (enum GNUNET_ARM_Result)ntohl(res->result);
if ((GNUNET_YES == op->is_arm_stop) && (GNUNET_ARM_RESULT_STOPPING == result))
- {
- /* special case: if we are stopping 'gnunet-service-arm', we do not just
- wait for the result message, but also wait for the service to close
- the connection (and then we have to close our client handle as well);
- this is done by installing a different receive handler, waiting for
- the connection to go down */
- if (NULL != h->thm)
{
- GNUNET_break (0);
- op->result_cont (h->thm->cont_cls,
- GNUNET_ARM_REQUEST_SENT_OK,
- GNUNET_ARM_RESULT_IS_NOT_KNOWN);
- GNUNET_free (h->thm);
+ /* special case: if we are stopping 'gnunet-service-arm', we do not just
+ wait for the result message, but also wait for the service to close
+ the connection (and then we have to close our client handle as well);
+ this is done by installing a different receive handler, waiting for
+ the connection to go down */
+ if (NULL != h->thm)
+ {
+ GNUNET_break(0);
+ op->result_cont(h->thm->cont_cls,
+ GNUNET_ARM_REQUEST_SENT_OK,
+ GNUNET_ARM_RESULT_IS_NOT_KNOWN);
+ GNUNET_free(h->thm);
+ }
+ GNUNET_CONTAINER_DLL_remove(h->operation_pending_head,
+ h->operation_pending_tail,
+ op);
+ h->thm = op;
+ return;
}
- GNUNET_CONTAINER_DLL_remove (h->operation_pending_head,
- h->operation_pending_tail,
- op);
- h->thm = op;
- return;
- }
result_cont = op->result_cont;
result_cont_cls = op->cont_cls;
- GNUNET_ARM_operation_cancel (op);
+ GNUNET_ARM_operation_cancel(op);
if (NULL != result_cont)
- result_cont (result_cont_cls, GNUNET_ARM_REQUEST_SENT_OK, result);
+ result_cont(result_cont_cls, GNUNET_ARM_REQUEST_SENT_OK, result);
}
@@ -303,27 +301,27 @@ handle_arm_result (void *cls, const struct GNUNET_ARM_ResultMessage *res)
* @return #GNUNET_OK if message is well-formed
*/
static int
-check_arm_list_result (void *cls,
- const struct GNUNET_ARM_ListResultMessage *lres)
+check_arm_list_result(void *cls,
+ const struct GNUNET_ARM_ListResultMessage *lres)
{
- const char *pos = (const char *) &lres[1];
- uint16_t rcount = ntohs (lres->count);
- uint16_t msize = ntohs (lres->arm_msg.header.size) - sizeof (*lres);
+ const char *pos = (const char *)&lres[1];
+ uint16_t rcount = ntohs(lres->count);
+ uint16_t msize = ntohs(lres->arm_msg.header.size) - sizeof(*lres);
uint16_t size_check;
- (void) cls;
+ (void)cls;
size_check = 0;
for (unsigned int i = 0; i < rcount; i++)
- {
- const char *end = memchr (pos, 0, msize - size_check);
- if (NULL == end)
{
- GNUNET_break (0);
- return GNUNET_SYSERR;
+ const char *end = memchr(pos, 0, msize - size_check);
+ if (NULL == end)
+ {
+ GNUNET_break(0);
+ return GNUNET_SYSERR;
+ }
+ size_check += (end - pos) + 1;
+ pos = end + 1;
}
- size_check += (end - pos) + 1;
- pos = end + 1;
- }
return GNUNET_OK;
}
@@ -335,41 +333,41 @@ check_arm_list_result (void *cls,
* @param lres the message received from the arm service
*/
static void
-handle_arm_list_result (void *cls,
- const struct GNUNET_ARM_ListResultMessage *lres)
+handle_arm_list_result(void *cls,
+ const struct GNUNET_ARM_ListResultMessage *lres)
{
struct GNUNET_ARM_Handle *h = cls;
- uint16_t rcount = ntohs (lres->count);
+ uint16_t rcount = ntohs(lres->count);
const char *list[rcount];
- const char *pos = (const char *) &lres[1];
- uint16_t msize = ntohs (lres->arm_msg.header.size) - sizeof (*lres);
+ const char *pos = (const char *)&lres[1];
+ uint16_t msize = ntohs(lres->arm_msg.header.size) - sizeof(*lres);
struct GNUNET_ARM_Operation *op;
uint16_t size_check;
uint64_t id;
- id = GNUNET_ntohll (lres->arm_msg.request_id);
- op = find_op_by_id (h, id);
+ id = GNUNET_ntohll(lres->arm_msg.request_id);
+ op = find_op_by_id(h, id);
if (NULL == op)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Message with unknown id %llu\n",
- (unsigned long long) id);
- return;
- }
+ {
+ LOG(GNUNET_ERROR_TYPE_DEBUG,
+ "Message with unknown id %llu\n",
+ (unsigned long long)id);
+ return;
+ }
size_check = 0;
for (unsigned int i = 0; i < rcount; i++)
- {
- const char *end = memchr (pos, 0, msize - size_check);
-
- /* Assert, as this was already checked in #check_arm_list_result() */
- GNUNET_assert (NULL != end);
- list[i] = pos;
- size_check += (end - pos) + 1;
- pos = end + 1;
- }
+ {
+ const char *end = memchr(pos, 0, msize - size_check);
+
+ /* Assert, as this was already checked in #check_arm_list_result() */
+ GNUNET_assert(NULL != end);
+ list[i] = pos;
+ size_check += (end - pos) + 1;
+ pos = end + 1;
+ }
if (NULL != op->list_cont)
- op->list_cont (op->cont_cls, GNUNET_ARM_REQUEST_SENT_OK, rcount, list);
- GNUNET_ARM_operation_cancel (op);
+ op->list_cont(op->cont_cls, GNUNET_ARM_REQUEST_SENT_OK, rcount, list);
+ GNUNET_ARM_operation_cancel(op);
}
@@ -380,18 +378,18 @@ handle_arm_list_result (void *cls,
* @param msg message received
*/
static void
-handle_confirm (void *cls, const struct GNUNET_MessageHeader *msg)
+handle_confirm(void *cls, const struct GNUNET_MessageHeader *msg)
{
struct GNUNET_ARM_Handle *h = cls;
- (void) msg;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Got confirmation from ARM that we are up!\n");
+ (void)msg;
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "Got confirmation from ARM that we are up!\n");
if (GNUNET_NO == h->currently_up)
- {
- h->currently_up = GNUNET_YES;
- if (NULL != h->conn_status)
- h->conn_status (h->conn_status_cls, GNUNET_YES);
- }
+ {
+ h->currently_up = GNUNET_YES;
+ if (NULL != h->conn_status)
+ h->conn_status(h->conn_status_cls, GNUNET_YES);
+ }
}
@@ -404,22 +402,22 @@ handle_confirm (void *cls, const struct GNUNET_MessageHeader *msg)
* @param error error code
*/
static void
-mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
+mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
{
struct GNUNET_ARM_Handle *h = cls;
struct GNUNET_ARM_Operation *op;
- (void) error;
+ (void)error;
h->currently_up = GNUNET_NO;
if (NULL != (op = h->thm))
- {
- h->thm = NULL;
- op->result_cont (op->cont_cls,
- GNUNET_ARM_REQUEST_SENT_OK,
- GNUNET_ARM_RESULT_STOPPED);
- GNUNET_free (op);
- }
- reconnect_arm_later (h);
+ {
+ h->thm = NULL;
+ op->result_cont(op->cont_cls,
+ GNUNET_ARM_REQUEST_SENT_OK,
+ GNUNET_ARM_RESULT_STOPPED);
+ GNUNET_free(op);
+ }
+ reconnect_arm_later(h);
}
@@ -430,39 +428,39 @@ mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/
static int
-reconnect_arm (struct GNUNET_ARM_Handle *h)
+reconnect_arm(struct GNUNET_ARM_Handle *h)
{
struct GNUNET_MQ_MessageHandler handlers[] =
- {GNUNET_MQ_hd_fixed_size (arm_result,
- GNUNET_MESSAGE_TYPE_ARM_RESULT,
- struct GNUNET_ARM_ResultMessage,
- h),
- GNUNET_MQ_hd_var_size (arm_list_result,
- GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT,
- struct GNUNET_ARM_ListResultMessage,
+ { GNUNET_MQ_hd_fixed_size(arm_result,
+ GNUNET_MESSAGE_TYPE_ARM_RESULT,
+ struct GNUNET_ARM_ResultMessage,
+ h),
+ GNUNET_MQ_hd_var_size(arm_list_result,
+ GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT,
+ struct GNUNET_ARM_ListResultMessage,
+ h),
+ GNUNET_MQ_hd_fixed_size(confirm,
+ GNUNET_MESSAGE_TYPE_ARM_TEST,
+ struct GNUNET_MessageHeader,
h),
- GNUNET_MQ_hd_fixed_size (confirm,
- GNUNET_MESSAGE_TYPE_ARM_TEST,
- struct GNUNET_MessageHeader,
- h),
- GNUNET_MQ_handler_end ()};
+ GNUNET_MQ_handler_end() };
struct GNUNET_MessageHeader *test;
struct GNUNET_MQ_Envelope *env;
if (NULL != h->mq)
return GNUNET_OK;
- GNUNET_assert (GNUNET_NO == h->currently_up);
- h->mq = GNUNET_CLIENT_connect (h->cfg, "arm", handlers, &mq_error_handler, h);
+ GNUNET_assert(GNUNET_NO == h->currently_up);
+ h->mq = GNUNET_CLIENT_connect(h->cfg, "arm", handlers, &mq_error_handler, h);
if (NULL == h->mq)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_CLIENT_connect returned NULL\n");
- if (NULL != h->conn_status)
- h->conn_status (h->conn_status_cls, GNUNET_SYSERR);
- return GNUNET_SYSERR;
- }
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending TEST message to ARM\n");
- env = GNUNET_MQ_msg (test, GNUNET_MESSAGE_TYPE_ARM_TEST);
- GNUNET_MQ_send (h->mq, env);
+ {
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "GNUNET_CLIENT_connect returned NULL\n");
+ if (NULL != h->conn_status)
+ h->conn_status(h->conn_status_cls, GNUNET_SYSERR);
+ return GNUNET_SYSERR;
+ }
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "Sending TEST message to ARM\n");
+ env = GNUNET_MQ_msg(test, GNUNET_MESSAGE_TYPE_ARM_TEST);
+ GNUNET_MQ_send(h->mq, env);
return GNUNET_OK;
}
@@ -479,21 +477,21 @@ reconnect_arm (struct GNUNET_ARM_Handle *h)
* @return context to use for further ARM operations, NULL on error.
*/
struct GNUNET_ARM_Handle *
-GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
- GNUNET_ARM_ConnectionStatusCallback conn_status,
- void *conn_status_cls)
+GNUNET_ARM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg,
+ GNUNET_ARM_ConnectionStatusCallback conn_status,
+ void *conn_status_cls)
{
struct GNUNET_ARM_Handle *h;
- h = GNUNET_new (struct GNUNET_ARM_Handle);
+ h = GNUNET_new(struct GNUNET_ARM_Handle);
h->cfg = cfg;
h->conn_status = conn_status;
h->conn_status_cls = conn_status_cls;
- if (GNUNET_OK != reconnect_arm (h))
- {
- GNUNET_free (h);
- return NULL;
- }
+ if (GNUNET_OK != reconnect_arm(h))
+ {
+ GNUNET_free(h);
+ return NULL;
+ }
return h;
}
@@ -504,38 +502,38 @@ GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
* @param h the handle that was being used
*/
void
-GNUNET_ARM_disconnect (struct GNUNET_ARM_Handle *h)
+GNUNET_ARM_disconnect(struct GNUNET_ARM_Handle *h)
{
struct GNUNET_ARM_Operation *op;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from ARM service\n");
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from ARM service\n");
while (NULL != (op = h->operation_pending_head))
- {
- GNUNET_CONTAINER_DLL_remove (h->operation_pending_head,
- h->operation_pending_tail,
- op);
- if (NULL != op->result_cont)
- op->result_cont (op->cont_cls, GNUNET_ARM_REQUEST_DISCONNECTED, 0);
- if (NULL != op->list_cont)
- op->list_cont (op->cont_cls, GNUNET_ARM_REQUEST_DISCONNECTED, 0, NULL);
- if (NULL != op->async)
{
- GNUNET_SCHEDULER_cancel (op->async);
- op->async = NULL;
+ GNUNET_CONTAINER_DLL_remove(h->operation_pending_head,
+ h->operation_pending_tail,
+ op);
+ if (NULL != op->result_cont)
+ op->result_cont(op->cont_cls, GNUNET_ARM_REQUEST_DISCONNECTED, 0);
+ if (NULL != op->list_cont)
+ op->list_cont(op->cont_cls, GNUNET_ARM_REQUEST_DISCONNECTED, 0, NULL);
+ if (NULL != op->async)
+ {
+ GNUNET_SCHEDULER_cancel(op->async);
+ op->async = NULL;
+ }
+ GNUNET_free(op);
}
- GNUNET_free (op);
- }
if (NULL != h->mq)
- {
- GNUNET_MQ_destroy (h->mq);
- h->mq = NULL;
- }
+ {
+ GNUNET_MQ_destroy(h->mq);
+ h->mq = NULL;
+ }
if (NULL != h->reconnect_task)
- {
- GNUNET_SCHEDULER_cancel (h->reconnect_task);
- h->reconnect_task = NULL;
- }
- GNUNET_free (h);
+ {
+ GNUNET_SCHEDULER_cancel(h->reconnect_task);
+ h->reconnect_task = NULL;
+ }
+ GNUNET_free(h);
}
@@ -548,8 +546,8 @@ GNUNET_ARM_disconnect (struct GNUNET_ARM_Handle *h)
* @return operation status code
*/
static enum GNUNET_ARM_Result
-start_arm_service (struct GNUNET_ARM_Handle *h,
- enum GNUNET_OS_InheritStdioFlags std_inheritance)
+start_arm_service(struct GNUNET_ARM_Handle *h,
+ enum GNUNET_OS_InheritStdioFlags std_inheritance)
{
struct GNUNET_OS_Process *proc;
char *cbinary;
@@ -559,98 +557,98 @@ start_arm_service (struct GNUNET_ARM_Handle *h,
char *loprefix;
char *lopostfix;
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (h->cfg,
- "arm",
- "PREFIX",
- &loprefix))
- loprefix = GNUNET_strdup ("");
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(h->cfg,
+ "arm",
+ "PREFIX",
+ &loprefix))
+ loprefix = GNUNET_strdup("");
else
- loprefix = GNUNET_CONFIGURATION_expand_dollar (h->cfg, loprefix);
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (h->cfg,
- "arm",
- "OPTIONS",
- &lopostfix))
- lopostfix = GNUNET_strdup ("");
+ loprefix = GNUNET_CONFIGURATION_expand_dollar(h->cfg, loprefix);
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(h->cfg,
+ "arm",
+ "OPTIONS",
+ &lopostfix))
+ lopostfix = GNUNET_strdup("");
else
- lopostfix = GNUNET_CONFIGURATION_expand_dollar (h->cfg, lopostfix);
+ lopostfix = GNUNET_CONFIGURATION_expand_dollar(h->cfg, lopostfix);
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (h->cfg, "arm", "BINARY", &cbinary))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, "arm", "BINARY");
- GNUNET_free (loprefix);
- GNUNET_free (lopostfix);
- return GNUNET_ARM_RESULT_IS_NOT_KNOWN;
- }
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (h->cfg,
- "arm",
- "CONFIG",
- &config))
+ GNUNET_CONFIGURATION_get_value_string(h->cfg, "arm", "BINARY", &cbinary))
+ {
+ GNUNET_log_config_missing(GNUNET_ERROR_TYPE_WARNING, "arm", "BINARY");
+ GNUNET_free(loprefix);
+ GNUNET_free(lopostfix);
+ return GNUNET_ARM_RESULT_IS_NOT_KNOWN;
+ }
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename(h->cfg,
+ "arm",
+ "CONFIG",
+ &config))
config = NULL;
- binary = GNUNET_OS_get_libexec_binary_path (cbinary);
- GNUNET_asprintf (&quotedbinary, "\"%s\"", binary);
- GNUNET_free (cbinary);
+ binary = GNUNET_OS_get_libexec_binary_path(cbinary);
+ GNUNET_asprintf(&quotedbinary, "\"%s\"", binary);
+ GNUNET_free(cbinary);
if ((GNUNET_YES ==
- GNUNET_CONFIGURATION_have_value (h->cfg, "TESTING", "WEAKRANDOM")) &&
- (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (h->cfg,
- "TESTING",
- "WEAKRANDOM")) &&
+ GNUNET_CONFIGURATION_have_value(h->cfg, "TESTING", "WEAKRANDOM")) &&
+ (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(h->cfg,
+ "TESTING",
+ "WEAKRANDOM")) &&
(GNUNET_NO ==
- GNUNET_CONFIGURATION_have_value (h->cfg, "TESTING", "HOSTFILE")))
- {
- /* Means we are ONLY running locally */
- /* we're clearly running a test, don't daemonize */
- if (NULL == config)
- proc = GNUNET_OS_start_process_s (GNUNET_NO,
- std_inheritance,
- NULL,
- loprefix,
- quotedbinary,
- /* no daemonization! */
- lopostfix,
- NULL);
- else
- proc = GNUNET_OS_start_process_s (GNUNET_NO,
- std_inheritance,
- NULL,
- loprefix,
- quotedbinary,
- "-c",
- config,
- /* no daemonization! */
- lopostfix,
- NULL);
- }
+ GNUNET_CONFIGURATION_have_value(h->cfg, "TESTING", "HOSTFILE")))
+ {
+ /* Means we are ONLY running locally */
+ /* we're clearly running a test, don't daemonize */
+ if (NULL == config)
+ proc = GNUNET_OS_start_process_s(GNUNET_NO,
+ std_inheritance,
+ NULL,
+ loprefix,
+ quotedbinary,
+ /* no daemonization! */
+ lopostfix,
+ NULL);
+ else
+ proc = GNUNET_OS_start_process_s(GNUNET_NO,
+ std_inheritance,
+ NULL,
+ loprefix,
+ quotedbinary,
+ "-c",
+ config,
+ /* no daemonization! */
+ lopostfix,
+ NULL);
+ }
else
- {
- if (NULL == config)
- proc = GNUNET_OS_start_process_s (GNUNET_NO,
- std_inheritance,
- NULL,
- loprefix,
- quotedbinary,
- "-d", /* do daemonize */
- lopostfix,
- NULL);
- else
- proc = GNUNET_OS_start_process_s (GNUNET_NO,
- std_inheritance,
- NULL,
- loprefix,
- quotedbinary,
- "-c",
- config,
- "-d", /* do daemonize */
- lopostfix,
- NULL);
- }
- GNUNET_free (binary);
- GNUNET_free (quotedbinary);
- GNUNET_free_non_null (config);
- GNUNET_free (loprefix);
- GNUNET_free (lopostfix);
+ {
+ if (NULL == config)
+ proc = GNUNET_OS_start_process_s(GNUNET_NO,
+ std_inheritance,
+ NULL,
+ loprefix,
+ quotedbinary,
+ "-d", /* do daemonize */
+ lopostfix,
+ NULL);
+ else
+ proc = GNUNET_OS_start_process_s(GNUNET_NO,
+ std_inheritance,
+ NULL,
+ loprefix,
+ quotedbinary,
+ "-c",
+ config,
+ "-d", /* do daemonize */
+ lopostfix,
+ NULL);
+ }
+ GNUNET_free(binary);
+ GNUNET_free(quotedbinary);
+ GNUNET_free_non_null(config);
+ GNUNET_free(loprefix);
+ GNUNET_free(lopostfix);
if (NULL == proc)
return GNUNET_ARM_RESULT_START_FAILED;
- GNUNET_OS_process_destroy (proc);
+ GNUNET_OS_process_destroy(proc);
return GNUNET_ARM_RESULT_STARTING;
}
@@ -662,19 +660,19 @@ start_arm_service (struct GNUNET_ARM_Handle *h,
* @param op operation to cancel
*/
void
-GNUNET_ARM_operation_cancel (struct GNUNET_ARM_Operation *op)
+GNUNET_ARM_operation_cancel(struct GNUNET_ARM_Operation *op)
{
struct GNUNET_ARM_Handle *h = op->h;
if (h->thm == op)
- {
- op->result_cont = NULL;
- return;
- }
- GNUNET_CONTAINER_DLL_remove (h->operation_pending_head,
- h->operation_pending_tail,
- op);
- GNUNET_free (op);
+ {
+ op->result_cont = NULL;
+ return;
+ }
+ GNUNET_CONTAINER_DLL_remove(h->operation_pending_head,
+ h->operation_pending_tail,
+ op);
+ GNUNET_free(op);
}
@@ -689,38 +687,38 @@ GNUNET_ARM_operation_cancel (struct GNUNET_ARM_Operation *op)
* @return handle to queue, NULL on error
*/
static struct GNUNET_ARM_Operation *
-change_service (struct GNUNET_ARM_Handle *h,
- const char *service_name,
- GNUNET_ARM_ResultCallback cb,
- void *cb_cls,
- uint16_t type)
+change_service(struct GNUNET_ARM_Handle *h,
+ const char *service_name,
+ GNUNET_ARM_ResultCallback cb,
+ void *cb_cls,
+ uint16_t type)
{
struct GNUNET_ARM_Operation *op;
size_t slen;
struct GNUNET_MQ_Envelope *env;
struct GNUNET_ARM_Message *msg;
- slen = strlen (service_name) + 1;
- if (slen + sizeof (struct GNUNET_ARM_Message) >= GNUNET_MAX_MESSAGE_SIZE)
- {
- GNUNET_break (0);
- return NULL;
- }
+ slen = strlen(service_name) + 1;
+ if (slen + sizeof(struct GNUNET_ARM_Message) >= GNUNET_MAX_MESSAGE_SIZE)
+ {
+ GNUNET_break(0);
+ return NULL;
+ }
if (0 == h->request_id_counter)
h->request_id_counter++;
- op = GNUNET_new (struct GNUNET_ARM_Operation);
+ op = GNUNET_new(struct GNUNET_ARM_Operation);
op->h = h;
op->result_cont = cb;
op->cont_cls = cb_cls;
op->id = h->request_id_counter++;
- GNUNET_CONTAINER_DLL_insert_tail (h->operation_pending_head,
- h->operation_pending_tail,
- op);
- env = GNUNET_MQ_msg_extra (msg, slen, type);
- msg->reserved = htonl (0);
- msg->request_id = GNUNET_htonll (op->id);
- GNUNET_memcpy (&msg[1], service_name, slen);
- GNUNET_MQ_send (h->mq, env);
+ GNUNET_CONTAINER_DLL_insert_tail(h->operation_pending_head,
+ h->operation_pending_tail,
+ op);
+ env = GNUNET_MQ_msg_extra(msg, slen, type);
+ msg->reserved = htonl(0);
+ msg->request_id = GNUNET_htonll(op->id);
+ GNUNET_memcpy(&msg[1], service_name, slen);
+ GNUNET_MQ_send(h->mq, env);
return op;
}
@@ -731,22 +729,22 @@ change_service (struct GNUNET_ARM_Handle *h,
* @param cls the operation that asked ARM to be started
*/
static void
-notify_running (void *cls)
+notify_running(void *cls)
{
struct GNUNET_ARM_Operation *op = cls;
struct GNUNET_ARM_Handle *h = op->h;
op->async = NULL;
- GNUNET_CONTAINER_DLL_remove (h->operation_pending_head,
- h->operation_pending_tail,
- op);
+ GNUNET_CONTAINER_DLL_remove(h->operation_pending_head,
+ h->operation_pending_tail,
+ op);
if (NULL != op->result_cont)
- op->result_cont (op->cont_cls,
- GNUNET_ARM_REQUEST_SENT_OK,
- GNUNET_ARM_RESULT_IS_STARTED_ALREADY);
+ op->result_cont(op->cont_cls,
+ GNUNET_ARM_REQUEST_SENT_OK,
+ GNUNET_ARM_RESULT_IS_STARTED_ALREADY);
if ((GNUNET_YES == h->currently_up) && (NULL != h->conn_status))
- h->conn_status (h->conn_status_cls, GNUNET_YES);
- GNUNET_free (op);
+ h->conn_status(h->conn_status_cls, GNUNET_YES);
+ GNUNET_free(op);
}
@@ -756,22 +754,22 @@ notify_running (void *cls)
* @param cls the operation that asked ARM to be started
*/
static void
-notify_starting (void *cls)
+notify_starting(void *cls)
{
struct GNUNET_ARM_Operation *op = cls;
struct GNUNET_ARM_Handle *h = op->h;
op->async = NULL;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Notifying client that we started the ARM service\n");
- GNUNET_CONTAINER_DLL_remove (h->operation_pending_head,
- h->operation_pending_tail,
- op);
+ LOG(GNUNET_ERROR_TYPE_DEBUG,
+ "Notifying client that we started the ARM service\n");
+ GNUNET_CONTAINER_DLL_remove(h->operation_pending_head,
+ h->operation_pending_tail,
+ op);
if (NULL != op->result_cont)
- op->result_cont (op->cont_cls,
- GNUNET_ARM_REQUEST_SENT_OK,
- op->starting_ret);
- GNUNET_free (op);
+ op->result_cont(op->cont_cls,
+ GNUNET_ARM_REQUEST_SENT_OK,
+ op->starting_ret);
+ GNUNET_free(op);
}
@@ -786,7 +784,7 @@ notify_starting (void *cls)
* @return handle for the operation, NULL on error
*/
struct GNUNET_ARM_Operation *
-GNUNET_ARM_request_service_start (
+GNUNET_ARM_request_service_start(
struct GNUNET_ARM_Handle *h,
const char *service_name,
enum GNUNET_OS_InheritStdioFlags std_inheritance,
@@ -796,13 +794,13 @@ GNUNET_ARM_request_service_start (
struct GNUNET_ARM_Operation *op;
enum GNUNET_ARM_Result ret;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting service `%s'\n", service_name);
- if (0 != strcasecmp ("arm", service_name))
- return change_service (h,
- service_name,
- cont,
- cont_cls,
- GNUNET_MESSAGE_TYPE_ARM_START);
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "Starting service `%s'\n", service_name);
+ if (0 != strcasecmp("arm", service_name))
+ return change_service(h,
+ service_name,
+ cont,
+ cont_cls,
+ GNUNET_MESSAGE_TYPE_ARM_START);
/* Possible cases:
* 1) We're connected to ARM already. Invoke the callback immediately.
@@ -811,37 +809,37 @@ GNUNET_ARM_request_service_start (
* a service test.
*/
if (GNUNET_YES == h->currently_up)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG, "ARM is already running\n");
- op = GNUNET_new (struct GNUNET_ARM_Operation);
- op->h = h;
- op->result_cont = cont;
- op->cont_cls = cont_cls;
- GNUNET_CONTAINER_DLL_insert_tail (h->operation_pending_head,
- h->operation_pending_tail,
- op);
- op->async = GNUNET_SCHEDULER_add_now (&notify_running, op);
- return op;
- }
+ {
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "ARM is already running\n");
+ op = GNUNET_new(struct GNUNET_ARM_Operation);
+ op->h = h;
+ op->result_cont = cont;
+ op->cont_cls = cont_cls;
+ GNUNET_CONTAINER_DLL_insert_tail(h->operation_pending_head,
+ h->operation_pending_tail,
+ op);
+ op->async = GNUNET_SCHEDULER_add_now(&notify_running, op);
+ return op;
+ }
/* This is an inherently uncertain choice, as it is of course
theoretically possible that ARM is up and we just did not
yet complete the MQ handshake. However, given that users
are unlikely to hammer 'gnunet-arm -s' on a busy system,
the above check should catch 99.99% of the cases where ARM
is already running. */
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting ARM service\n");
- ret = start_arm_service (h, std_inheritance);
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "Starting ARM service\n");
+ ret = start_arm_service(h, std_inheritance);
if (GNUNET_ARM_RESULT_STARTING == ret)
- reconnect_arm (h);
- op = GNUNET_new (struct GNUNET_ARM_Operation);
+ reconnect_arm(h);
+ op = GNUNET_new(struct GNUNET_ARM_Operation);
op->h = h;
op->result_cont = cont;
op->cont_cls = cont_cls;
- GNUNET_CONTAINER_DLL_insert_tail (h->operation_pending_head,
- h->operation_pending_tail,
- op);
+ GNUNET_CONTAINER_DLL_insert_tail(h->operation_pending_head,
+ h->operation_pending_tail,
+ op);
op->starting_ret = ret;
- op->async = GNUNET_SCHEDULER_add_now (&notify_starting, op);
+ op->async = GNUNET_SCHEDULER_add_now(&notify_starting, op);
return op;
}
@@ -861,24 +859,24 @@ GNUNET_ARM_request_service_start (
* @return handle for the operation, NULL on error
*/
struct GNUNET_ARM_Operation *
-GNUNET_ARM_request_service_stop (struct GNUNET_ARM_Handle *h,
- const char *service_name,
- GNUNET_ARM_ResultCallback cont,
- void *cont_cls)
+GNUNET_ARM_request_service_stop(struct GNUNET_ARM_Handle *h,
+ const char *service_name,
+ GNUNET_ARM_ResultCallback cont,
+ void *cont_cls)
{
struct GNUNET_ARM_Operation *op;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Stopping service `%s'\n", service_name);
- op = change_service (h,
- service_name,
- cont,
- cont_cls,
- GNUNET_MESSAGE_TYPE_ARM_STOP);
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "Stopping service `%s'\n", service_name);
+ op = change_service(h,
+ service_name,
+ cont,
+ cont_cls,
+ GNUNET_MESSAGE_TYPE_ARM_STOP);
if (NULL == op)
return NULL;
/* If the service is ARM, set a flag as we will use MQ errors
to detect that the process is really gone. */
- if (0 == strcasecmp (service_name, "arm"))
+ if (0 == strcasecmp(service_name, "arm"))
op->is_arm_stop = GNUNET_YES;
return op;
}
@@ -893,29 +891,29 @@ GNUNET_ARM_request_service_stop (struct GNUNET_ARM_Handle *h,
* @return handle for the operation, NULL on error
*/
struct GNUNET_ARM_Operation *
-GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h,
- GNUNET_ARM_ServiceListCallback cont,
- void *cont_cls)
+GNUNET_ARM_request_service_list(struct GNUNET_ARM_Handle *h,
+ GNUNET_ARM_ServiceListCallback cont,
+ void *cont_cls)
{
struct GNUNET_ARM_Operation *op;
struct GNUNET_MQ_Envelope *env;
struct GNUNET_ARM_Message *msg;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Requesting LIST from ARM service\n");
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "Requesting LIST from ARM service\n");
if (0 == h->request_id_counter)
h->request_id_counter++;
- op = GNUNET_new (struct GNUNET_ARM_Operation);
+ op = GNUNET_new(struct GNUNET_ARM_Operation);
op->h = h;
op->list_cont = cont;
op->cont_cls = cont_cls;
op->id = h->request_id_counter++;
- GNUNET_CONTAINER_DLL_insert_tail (h->operation_pending_head,
- h->operation_pending_tail,
- op);
- env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_ARM_LIST);
- msg->reserved = htonl (0);
- msg->request_id = GNUNET_htonll (op->id);
- GNUNET_MQ_send (h->mq, env);
+ GNUNET_CONTAINER_DLL_insert_tail(h->operation_pending_head,
+ h->operation_pending_tail,
+ op);
+ env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_ARM_LIST);
+ msg->reserved = htonl(0);
+ msg->request_id = GNUNET_htonll(op->id);
+ GNUNET_MQ_send(h->mq, env);
return op;
}
diff --git a/src/arm/arm_monitor_api.c b/src/arm/arm_monitor_api.c
index 55b12240f..c6e1e2683 100644
--- a/src/arm/arm_monitor_api.c
+++ b/src/arm/arm_monitor_api.c
@@ -11,12 +11,12 @@
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 arm/arm_monitor_api.c
@@ -30,16 +30,14 @@
#include "gnunet_protocols.h"
#include "arm.h"
-#define INIT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+#define INIT_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
-#define LOG(kind, ...) GNUNET_log_from (kind, "arm-monitor-api", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from(kind, "arm-monitor-api", __VA_ARGS__)
/**
* Handle for interacting with ARM.
*/
-struct GNUNET_ARM_MonitorHandle
-{
-
+struct GNUNET_ARM_MonitorHandle {
/**
* Our control connection to the ARM service.
*/
@@ -79,7 +77,7 @@ struct GNUNET_ARM_MonitorHandle
* @return #GNUNET_OK on success
*/
static int
-reconnect_arm_monitor (struct GNUNET_ARM_MonitorHandle *h);
+reconnect_arm_monitor(struct GNUNET_ARM_MonitorHandle *h);
/**
@@ -88,14 +86,14 @@ reconnect_arm_monitor (struct GNUNET_ARM_MonitorHandle *h);
* @param cls the `struct GNUNET_ARM_MonitorHandle`
*/
static void
-reconnect_arm_monitor_task (void *cls)
+reconnect_arm_monitor_task(void *cls)
{
struct GNUNET_ARM_MonitorHandle *h = cls;
h->reconnect_task = NULL;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Connecting to ARM service for monitoring after delay\n");
- GNUNET_break (GNUNET_OK == reconnect_arm_monitor (h));
+ LOG(GNUNET_ERROR_TYPE_DEBUG,
+ "Connecting to ARM service for monitoring after delay\n");
+ GNUNET_break(GNUNET_OK == reconnect_arm_monitor(h));
}
@@ -106,18 +104,18 @@ reconnect_arm_monitor_task (void *cls)
* @param h our handle
*/
static void
-reconnect_arm_monitor_later (struct GNUNET_ARM_MonitorHandle *h)
+reconnect_arm_monitor_later(struct GNUNET_ARM_MonitorHandle *h)
{
if (NULL != h->mq)
- {
- GNUNET_MQ_destroy (h->mq);
- h->mq = NULL;
- }
- GNUNET_assert (NULL == h->reconnect_task);
- h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->retry_backoff,
- &reconnect_arm_monitor_task,
- h);
- h->retry_backoff = GNUNET_TIME_STD_BACKOFF (h->retry_backoff);
+ {
+ GNUNET_MQ_destroy(h->mq);
+ h->mq = NULL;
+ }
+ GNUNET_assert(NULL == h->reconnect_task);
+ h->reconnect_task = GNUNET_SCHEDULER_add_delayed(h->retry_backoff,
+ &reconnect_arm_monitor_task,
+ h);
+ h->retry_backoff = GNUNET_TIME_STD_BACKOFF(h->retry_backoff);
}
@@ -129,18 +127,18 @@ reconnect_arm_monitor_later (struct GNUNET_ARM_MonitorHandle *h)
* @return #GNUNET_OK if the message is well-formed
*/
static int
-check_monitor_notify (void *cls, const struct GNUNET_ARM_StatusMessage *msg)
+check_monitor_notify(void *cls, const struct GNUNET_ARM_StatusMessage *msg)
{
size_t sl =
- ntohs (msg->header.size) - sizeof (struct GNUNET_ARM_StatusMessage);
- const char *name = (const char *) &msg[1];
+ ntohs(msg->header.size) - sizeof(struct GNUNET_ARM_StatusMessage);
+ const char *name = (const char *)&msg[1];
- (void) cls;
+ (void)cls;
if ((0 == sl) || ('\0' != name[sl - 1]))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+ {
+ GNUNET_break(0);
+ return GNUNET_SYSERR;
+ }
return GNUNET_OK;
}
@@ -152,18 +150,18 @@ check_monitor_notify (void *cls, const struct GNUNET_ARM_StatusMessage *msg)
* @param res the message received from the arm service
*/
static void
-handle_monitor_notify (void *cls, const struct GNUNET_ARM_StatusMessage *res)
+handle_monitor_notify(void *cls, const struct GNUNET_ARM_StatusMessage *res)
{
struct GNUNET_ARM_MonitorHandle *h = cls;
enum GNUNET_ARM_ServiceStatus status;
- status = (enum GNUNET_ARM_ServiceStatus) ntohl (res->status);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received notification from ARM for service `%s' with status %d\n",
- (const char *) &res[1],
- (int) status);
+ status = (enum GNUNET_ARM_ServiceStatus)ntohl(res->status);
+ LOG(GNUNET_ERROR_TYPE_DEBUG,
+ "Received notification from ARM for service `%s' with status %d\n",
+ (const char *)&res[1],
+ (int)status);
if (NULL != h->service_status)
- h->service_status (h->service_status_cls, (const char *) &res[1], status);
+ h->service_status(h->service_status_cls, (const char *)&res[1], status);
}
@@ -176,12 +174,12 @@ handle_monitor_notify (void *cls, const struct GNUNET_ARM_StatusMessage *res)
* @param error error code
*/
static void
-mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
+mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
{
struct GNUNET_ARM_MonitorHandle *h = cls;
- (void) error;
- reconnect_arm_monitor_later (h);
+ (void)error;
+ reconnect_arm_monitor_later(h);
}
@@ -192,29 +190,29 @@ mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
* @return #GNUNET_OK on success
*/
static int
-reconnect_arm_monitor (struct GNUNET_ARM_MonitorHandle *h)
+reconnect_arm_monitor(struct GNUNET_ARM_MonitorHandle *h)
{
struct GNUNET_MQ_MessageHandler handlers[] =
- {GNUNET_MQ_hd_var_size (monitor_notify,
- GNUNET_MESSAGE_TYPE_ARM_STATUS,
- struct GNUNET_ARM_StatusMessage,
- h),
- GNUNET_MQ_handler_end ()};
+ { GNUNET_MQ_hd_var_size(monitor_notify,
+ GNUNET_MESSAGE_TYPE_ARM_STATUS,
+ struct GNUNET_ARM_StatusMessage,
+ h),
+ GNUNET_MQ_handler_end() };
struct GNUNET_MessageHeader *msg;
struct GNUNET_MQ_Envelope *env;
- GNUNET_assert (NULL == h->mq);
- h->mq = GNUNET_CLIENT_connect (h->cfg, "arm", handlers, &mq_error_handler, h);
+ GNUNET_assert(NULL == h->mq);
+ h->mq = GNUNET_CLIENT_connect(h->cfg, "arm", handlers, &mq_error_handler, h);
if (NULL == h->mq)
- {
- if (NULL != h->service_status)
- h->service_status (h->service_status_cls,
- NULL,
- GNUNET_ARM_SERVICE_STOPPED);
- return GNUNET_SYSERR;
- }
- env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_ARM_MONITOR);
- GNUNET_MQ_send (h->mq, env);
+ {
+ if (NULL != h->service_status)
+ h->service_status(h->service_status_cls,
+ NULL,
+ GNUNET_ARM_SERVICE_STOPPED);
+ return GNUNET_SYSERR;
+ }
+ env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_ARM_MONITOR);
+ GNUNET_MQ_send(h->mq, env);
return GNUNET_OK;
}
@@ -231,21 +229,21 @@ reconnect_arm_monitor (struct GNUNET_ARM_MonitorHandle *h)
* @return context to use for further ARM monitor operations, NULL on error.
*/
struct GNUNET_ARM_MonitorHandle *
-GNUNET_ARM_monitor_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
- GNUNET_ARM_ServiceStatusCallback cont,
- void *cont_cls)
+GNUNET_ARM_monitor_start(const struct GNUNET_CONFIGURATION_Handle *cfg,
+ GNUNET_ARM_ServiceStatusCallback cont,
+ void *cont_cls)
{
struct GNUNET_ARM_MonitorHandle *h;
- h = GNUNET_new (struct GNUNET_ARM_MonitorHandle);
+ h = GNUNET_new(struct GNUNET_ARM_MonitorHandle);
h->cfg = cfg;
h->service_status = cont;
h->service_status_cls = cont_cls;
- if (GNUNET_OK != reconnect_arm_monitor (h))
- {
- GNUNET_free (h);
- return NULL;
- }
+ if (GNUNET_OK != reconnect_arm_monitor(h))
+ {
+ GNUNET_free(h);
+ return NULL;
+ }
return h;
}
@@ -256,19 +254,19 @@ GNUNET_ARM_monitor_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
* @param h the handle that was being used
*/
void
-GNUNET_ARM_monitor_stop (struct GNUNET_ARM_MonitorHandle *h)
+GNUNET_ARM_monitor_stop(struct GNUNET_ARM_MonitorHandle *h)
{
if (NULL != h->mq)
- {
- GNUNET_MQ_destroy (h->mq);
- h->mq = NULL;
- }
+ {
+ GNUNET_MQ_destroy(h->mq);
+ h->mq = NULL;
+ }
if (NULL != h->reconnect_task)
- {
- GNUNET_SCHEDULER_cancel (h->reconnect_task);
- h->reconnect_task = NULL;
- }
- GNUNET_free (h);
+ {
+ GNUNET_SCHEDULER_cancel(h->reconnect_task);
+ h->reconnect_task = NULL;
+ }
+ GNUNET_free(h);
}
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c
index f96076231..3396a4dbe 100644
--- a/src/arm/gnunet-arm.c
+++ b/src/arm/gnunet-arm.c
@@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
SPDX-License-Identifier: AGPL3.0-or-later
-*/
+ */
/**
* @file arm/gnunet-arm.c
@@ -144,25 +144,25 @@ static struct GNUNET_ARM_Operation *op;
* were specified when gnunet-arm was run.
*/
static void
-delete_files ()
+delete_files()
{
- GNUNET_log (
+ GNUNET_log(
GNUNET_ERROR_TYPE_DEBUG,
"Will attempt to remove configuration file %s and service directory %s\n",
config_file,
dir);
- if (0 != unlink (config_file))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _ ("Failed to remove configuration file %s\n"),
- config_file);
- }
- if (GNUNET_OK != GNUNET_DISK_directory_remove (dir))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _ ("Failed to remove servicehome directory %s\n"),
- dir);
- }
+ if (0 != unlink(config_file))
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
+ _("Failed to remove configuration file %s\n"),
+ config_file);
+ }
+ if (GNUNET_OK != GNUNET_DISK_directory_remove(dir))
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
+ _("Failed to remove servicehome directory %s\n"),
+ dir);
+ }
}
@@ -173,37 +173,37 @@ delete_files ()
* @param cls closure, unused
*/
static void
-shutdown_task (void *cls)
+shutdown_task(void *cls)
{
- (void) cls;
+ (void)cls;
if (NULL != al_task)
- {
- GNUNET_SCHEDULER_cancel (al_task);
- al_task = NULL;
- }
+ {
+ GNUNET_SCHEDULER_cancel(al_task);
+ al_task = NULL;
+ }
if (NULL != op)
- {
- GNUNET_ARM_operation_cancel (op);
- op = NULL;
- }
+ {
+ GNUNET_ARM_operation_cancel(op);
+ op = NULL;
+ }
if (NULL != h)
- {
- GNUNET_ARM_disconnect (h);
- h = NULL;
- }
+ {
+ GNUNET_ARM_disconnect(h);
+ h = NULL;
+ }
if (NULL != m)
- {
- GNUNET_ARM_monitor_stop (m);
- m = NULL;
- }
+ {
+ GNUNET_ARM_monitor_stop(m);
+ m = NULL;
+ }
if (NULL != timeout_task)
- {
- GNUNET_SCHEDULER_cancel (timeout_task);
- timeout_task = NULL;
- }
+ {
+ GNUNET_SCHEDULER_cancel(timeout_task);
+ timeout_task = NULL;
+ }
if ((GNUNET_YES == end) && (GNUNET_YES == delete))
- delete_files ();
- GNUNET_CONFIGURATION_destroy (cfg);
+ delete_files();
+ GNUNET_CONFIGURATION_destroy(cfg);
cfg = NULL;
}
@@ -215,16 +215,17 @@ shutdown_task (void *cls)
* @return a string interpretation of the request status
*/
static const char *
-req_string (enum GNUNET_ARM_RequestStatus rs)
+req_string(enum GNUNET_ARM_RequestStatus rs)
{
switch (rs)
- {
- case GNUNET_ARM_REQUEST_SENT_OK:
- return _ ("Message was sent successfully");
- case GNUNET_ARM_REQUEST_DISCONNECTED:
- return _ ("We disconnected from ARM before we could send a request");
- }
- return _ ("Unknown request status");
+ {
+ case GNUNET_ARM_REQUEST_SENT_OK:
+ return _("Message was sent successfully");
+
+ case GNUNET_ARM_REQUEST_DISCONNECTED:
+ return _("We disconnected from ARM before we could send a request");
+ }
+ return _("Unknown request status");
}
@@ -235,32 +236,41 @@ req_string (enum GNUNET_ARM_RequestStatus rs)
* @return a string interpretation
*/
static const char *
-ret_string (enum GNUNET_ARM_Result result)
+ret_string(enum GNUNET_ARM_Result result)
{
switch (result)
- {
- case GNUNET_ARM_RESULT_STOPPED:
- return _ ("is stopped");
- case GNUNET_ARM_RESULT_STARTING:
- return _ ("is starting");
- case GNUNET_ARM_RESULT_STOPPING:
- return _ ("is stopping");
- case GNUNET_ARM_RESULT_IS_STARTING_ALREADY:
- return _ ("is starting already");
- case GNUNET_ARM_RESULT_IS_STOPPING_ALREADY:
- return _ ("is stopping already");
- case GNUNET_ARM_RESULT_IS_STARTED_ALREADY:
- return _ ("is started already");
- case GNUNET_ARM_RESULT_IS_STOPPED_ALREADY:
- return _ ("is stopped already");
- case GNUNET_ARM_RESULT_IS_NOT_KNOWN:
- return _ ("service is not known to ARM");
- case GNUNET_ARM_RESULT_START_FAILED:
- return _ ("service failed to start");
- case GNUNET_ARM_RESULT_IN_SHUTDOWN:
- return _ ("service cannot be manipulated because ARM is shutting down");
- }
- return _ ("Unknown result code.");
+ {
+ case GNUNET_ARM_RESULT_STOPPED:
+ return _("is stopped");
+
+ case GNUNET_ARM_RESULT_STARTING:
+ return _("is starting");
+
+ case GNUNET_ARM_RESULT_STOPPING:
+ return _("is stopping");
+
+ case GNUNET_ARM_RESULT_IS_STARTING_ALREADY:
+ return _("is starting already");
+
+ case GNUNET_ARM_RESULT_IS_STOPPING_ALREADY:
+ return _("is stopping already");
+
+ case GNUNET_ARM_RESULT_IS_STARTED_ALREADY:
+ return _("is started already");
+
+ case GNUNET_ARM_RESULT_IS_STOPPED_ALREADY:
+ return _("is stopped already");
+
+ case GNUNET_ARM_RESULT_IS_NOT_KNOWN:
+ return _("service is not known to ARM");
+
+ case GNUNET_ARM_RESULT_START_FAILED:
+ return _("service failed to start");
+
+ case GNUNET_ARM_RESULT_IN_SHUTDOWN:
+ return _("service cannot be manipulated because ARM is shutting down");
+ }
+ return _("Unknown result code.");
}
@@ -270,7 +280,7 @@ ret_string (enum GNUNET_ARM_Result result)
* @param cls closure
*/
static void
-action_loop (void *cls);
+action_loop(void *cls);
/**
@@ -283,18 +293,18 @@ action_loop (void *cls);
* #GNUNET_SYSERR on error.
*/
static void
-conn_status (void *cls, int connected)
+conn_status(void *cls, int connected)
{
static int once;
- (void) cls;
+ (void)cls;
if ((GNUNET_SYSERR == connected) && (0 == once))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Fatal error initializing ARM API.\n"));
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ _("Fatal error initializing ARM API.\n"));
+ GNUNET_SCHEDULER_shutdown();
+ return;
+ }
once = 1;
}
@@ -311,32 +321,32 @@ conn_status (void *cls, int connected)
* according to ARM
*/
static void
-start_callback (void *cls,
- enum GNUNET_ARM_RequestStatus rs,
- enum GNUNET_ARM_Result result)
+start_callback(void *cls,
+ enum GNUNET_ARM_RequestStatus rs,
+ enum GNUNET_ARM_Result result)
{
- (void) cls;
+ (void)cls;
op = NULL;
if (GNUNET_ARM_REQUEST_SENT_OK != rs)
- {
- fprintf (stdout,
- _ ("Failed to start the ARM service: %s\n"),
- req_string (rs));
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
+ {
+ fprintf(stdout,
+ _("Failed to start the ARM service: %s\n"),
+ req_string(rs));
+ GNUNET_SCHEDULER_shutdown();
+ return;
+ }
if ((GNUNET_ARM_RESULT_STARTING != result) &&
(GNUNET_ARM_RESULT_IS_STARTED_ALREADY != result))
- {
- fprintf (stdout,
- _ ("Failed to start the ARM service: %s\n"),
- ret_string (result));
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM service [re]start successful\n");
+ {
+ fprintf(stdout,
+ _("Failed to start the ARM service: %s\n"),
+ ret_string(result));
+ GNUNET_SCHEDULER_shutdown();
+ return;
+ }
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "ARM service [re]start successful\n");
start = 0;
- al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
+ al_task = GNUNET_SCHEDULER_add_now(&action_loop, NULL);
}
@@ -352,44 +362,44 @@ start_callback (void *cls,
* according to ARM
*/
static void
-stop_callback (void *cls,
- enum GNUNET_ARM_RequestStatus rs,
- enum GNUNET_ARM_Result result)
+stop_callback(void *cls,
+ enum GNUNET_ARM_RequestStatus rs,
+ enum GNUNET_ARM_Result result)
{
char *msg;
- (void) cls;
+ (void)cls;
op = NULL;
if (GNUNET_ARM_REQUEST_SENT_OK != rs)
- {
- GNUNET_asprintf (&msg,
- "%s",
- _ (
- "Failed to send a stop request to the ARM service: %s\n"));
- fprintf (stdout, msg, req_string (rs));
- GNUNET_free (msg);
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
+ {
+ GNUNET_asprintf(&msg,
+ "%s",
+ _(
+ "Failed to send a stop request to the ARM service: %s\n"));
+ fprintf(stdout, msg, req_string(rs));
+ GNUNET_free(msg);
+ GNUNET_SCHEDULER_shutdown();
+ return;
+ }
if ((GNUNET_ARM_RESULT_STOPPING != result) &&
(GNUNET_ARM_RESULT_STOPPED != result) &&
(GNUNET_ARM_RESULT_IS_STOPPED_ALREADY != result))
- {
- fprintf (stdout,
- _ ("Failed to stop the ARM service: %s\n"),
- ret_string (result));
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM service shutdown successful\n");
+ {
+ fprintf(stdout,
+ _("Failed to stop the ARM service: %s\n"),
+ ret_string(result));
+ GNUNET_SCHEDULER_shutdown();
+ return;
+ }
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "ARM service shutdown successful\n");
end = 0;
if (restart)
- {
- restart = 0;
- start = 1;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initiating an ARM restart\n");
- }
- al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
+ {
+ restart = 0;
+ start = 1;
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Initiating an ARM restart\n");
+ }
+ al_task = GNUNET_SCHEDULER_add_now(&action_loop, NULL);
}
@@ -405,37 +415,37 @@ stop_callback (void *cls,
* according to ARM
*/
static void
-init_callback (void *cls,
- enum GNUNET_ARM_RequestStatus rs,
- enum GNUNET_ARM_Result result)
+init_callback(void *cls,
+ enum GNUNET_ARM_RequestStatus rs,
+ enum GNUNET_ARM_Result result)
{
- (void) cls;
+ (void)cls;
op = NULL;
if (GNUNET_ARM_REQUEST_SENT_OK != rs)
- {
- fprintf (stdout,
- _ ("Failed to send a request to start the `%s' service: %s\n"),
- init,
- req_string (rs));
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
+ {
+ fprintf(stdout,
+ _("Failed to send a request to start the `%s' service: %s\n"),
+ init,
+ req_string(rs));
+ GNUNET_SCHEDULER_shutdown();
+ return;
+ }
if ((GNUNET_ARM_RESULT_STARTING != result) &&
(GNUNET_ARM_RESULT_IS_STARTED_ALREADY != result))
- {
- fprintf (stdout,
- _ ("Failed to start the `%s' service: %s\n"),
- init,
- ret_string (result));
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Service %s [re]started successfully\n",
- init);
- GNUNET_free (init);
+ {
+ fprintf(stdout,
+ _("Failed to start the `%s' service: %s\n"),
+ init,
+ ret_string(result));
+ GNUNET_SCHEDULER_shutdown();
+ return;
+ }
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Service %s [re]started successfully\n",
+ init);
+ GNUNET_free(init);
init = NULL;
- al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
+ al_task = GNUNET_SCHEDULER_add_now(&action_loop, NULL);
}
@@ -451,42 +461,42 @@ init_callback (void *cls,
* according to ARM
*/
static void
-term_callback (void *cls,
- enum GNUNET_ARM_RequestStatus rs,
- enum GNUNET_ARM_Result result)
+term_callback(void *cls,
+ enum GNUNET_ARM_RequestStatus rs,
+ enum GNUNET_ARM_Result result)
{
char *msg;
- (void) cls;
+ (void)cls;
op = NULL;
if (GNUNET_ARM_REQUEST_SENT_OK != rs)
- {
- GNUNET_asprintf (&msg,
- _ (
- "Failed to send a request to kill the `%s' service: %%s\n"),
- term);
- fprintf (stdout, msg, req_string (rs));
- GNUNET_free (msg);
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
+ {
+ GNUNET_asprintf(&msg,
+ _(
+ "Failed to send a request to kill the `%s' service: %%s\n"),
+ term);
+ fprintf(stdout, msg, req_string(rs));
+ GNUNET_free(msg);
+ GNUNET_SCHEDULER_shutdown();
+ return;
+ }
if ((GNUNET_ARM_RESULT_STOPPED != result) &&
(GNUNET_ARM_RESULT_IS_STOPPED_ALREADY != result))
- {
- fprintf (stdout,
- _ ("Failed to kill the `%s' service: %s\n"),
- term,
- ret_string (result));
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
+ {
+ fprintf(stdout,
+ _("Failed to kill the `%s' service: %s\n"),
+ term,
+ ret_string(result));
+ GNUNET_SCHEDULER_shutdown();
+ return;
+ }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Service %s stopped successfully\n",
- term);
- GNUNET_free (term);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Service %s stopped successfully\n",
+ term);
+ GNUNET_free(term);
term = NULL;
- al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
+ al_task = GNUNET_SCHEDULER_add_now(&action_loop, NULL);
}
@@ -501,39 +511,39 @@ term_callback (void *cls,
* @param list list of services that are running
*/
static void
-list_callback (void *cls,
- enum GNUNET_ARM_RequestStatus rs,
- unsigned int count,
- const char *const *list)
+list_callback(void *cls,
+ enum GNUNET_ARM_RequestStatus rs,
+ unsigned int count,
+ const char *const *list)
{
- (void) cls;
+ (void)cls;
op = NULL;
if (GNUNET_ARM_REQUEST_SENT_OK != rs)
- {
- char *msg;
-
- GNUNET_asprintf (&msg,
- "%s",
- _ ("Failed to request a list of services: %s\n"));
- fprintf (stdout, msg, req_string (rs));
- GNUNET_free (msg);
- ret = 3;
- GNUNET_SCHEDULER_shutdown ();
- }
+ {
+ char *msg;
+
+ GNUNET_asprintf(&msg,
+ "%s",
+ _("Failed to request a list of services: %s\n"));
+ fprintf(stdout, msg, req_string(rs));
+ GNUNET_free(msg);
+ ret = 3;
+ GNUNET_SCHEDULER_shutdown();
+ }
if (NULL == list)
- {
- fprintf (stderr,
- "%s",
- _ ("Error communicating with ARM. ARM not running?\n"));
- GNUNET_SCHEDULER_shutdown ();
- ret = 3;
- return;
- }
- if (! quiet)
- fprintf (stdout, "%s", _ ("Running services:\n"));
+ {
+ fprintf(stderr,
+ "%s",
+ _("Error communicating with ARM. ARM not running?\n"));
+ GNUNET_SCHEDULER_shutdown();
+ ret = 3;
+ return;
+ }
+ if (!quiet)
+ fprintf(stdout, "%s", _("Running services:\n"));
for (unsigned int i = 0; i < count; i++)
- fprintf (stdout, "%s\n", list[i]);
- al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
+ fprintf(stdout, "%s\n", list[i]);
+ al_task = GNUNET_SCHEDULER_add_now(&action_loop, NULL);
}
@@ -544,85 +554,91 @@ list_callback (void *cls,
* @param cls closure, unused
*/
static void
-action_loop (void *cls)
+action_loop(void *cls)
{
- (void) cls;
+ (void)cls;
al_task = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Running requested actions\n");
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Running requested actions\n");
while (1)
- {
- switch (phase++)
{
- case 0:
- if (NULL != term)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Termination action\n");
- op = GNUNET_ARM_request_service_stop (h, term, &term_callback, NULL);
- return;
- }
- break;
- case 1:
- if (end || restart)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "End action\n");
- op = GNUNET_ARM_request_service_stop (h, "arm", &stop_callback, NULL);
- return;
- }
- break;
- case 2:
- if (start)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start action\n");
- op =
- GNUNET_ARM_request_service_start (h,
- "arm",
- (no_stdout
- ? 0
- : GNUNET_OS_INHERIT_STD_OUT) |
- (no_stderr
- ? 0
- : GNUNET_OS_INHERIT_STD_ERR),
- &start_callback,
- NULL);
- return;
- }
- break;
- case 3:
- if (NULL != init)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initialization action\n");
- op = GNUNET_ARM_request_service_start (h,
- init,
- GNUNET_OS_INHERIT_STD_NONE,
- &init_callback,
- NULL);
- return;
- }
- break;
- case 4:
- if (list)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Going to list all running services controlled by ARM.\n");
- op = GNUNET_ARM_request_service_list (h, &list_callback, &list);
- return;
- }
- break;
- case 5:
- if (monitor)
- {
- if (! quiet)
- fprintf (stderr, _ ("Now only monitoring, press CTRL-C to stop.\n"));
- quiet =
- 0; /* does not make sense to stay quiet in monitor mode at this time */
- return; /* done with tasks, just monitor */
- }
- break;
- default: /* last phase */
- GNUNET_SCHEDULER_shutdown ();
- return;
+ switch (phase++)
+ {
+ case 0:
+ if (NULL != term)
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Termination action\n");
+ op = GNUNET_ARM_request_service_stop(h, term, &term_callback, NULL);
+ return;
+ }
+ break;
+
+ case 1:
+ if (end || restart)
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "End action\n");
+ op = GNUNET_ARM_request_service_stop(h, "arm", &stop_callback, NULL);
+ return;
+ }
+ break;
+
+ case 2:
+ if (start)
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Start action\n");
+ op =
+ GNUNET_ARM_request_service_start(h,
+ "arm",
+ (no_stdout
+ ? 0
+ : GNUNET_OS_INHERIT_STD_OUT) |
+ (no_stderr
+ ? 0
+ : GNUNET_OS_INHERIT_STD_ERR),
+ &start_callback,
+ NULL);
+ return;
+ }
+ break;
+
+ case 3:
+ if (NULL != init)
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Initialization action\n");
+ op = GNUNET_ARM_request_service_start(h,
+ init,
+ GNUNET_OS_INHERIT_STD_NONE,
+ &init_callback,
+ NULL);
+ return;
+ }
+ break;
+
+ case 4:
+ if (list)
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Going to list all running services controlled by ARM.\n");
+ op = GNUNET_ARM_request_service_list(h, &list_callback, &list);
+ return;
+ }
+ break;
+
+ case 5:
+ if (monitor)
+ {
+ if (!quiet)
+ fprintf(stderr, _("Now only monitoring, press CTRL-C to stop.\n"));
+ quiet =
+ 0; /* does not make sense to stay quiet in monitor mode at this time */
+ return; /* done with tasks, just monitor */
+ }
+ break;
+
+ default: /* last phase */
+ GNUNET_SCHEDULER_shutdown();
+ return;
+ }
}
- }
}
@@ -634,44 +650,48 @@ action_loop (void *cls)
* @param status status of the service
*/
static void
-srv_status (void *cls,
- const char *service,
- enum GNUNET_ARM_ServiceStatus status)
+srv_status(void *cls,
+ const char *service,
+ enum GNUNET_ARM_ServiceStatus status)
{
const char *msg;
- (void) cls;
+ (void)cls;
switch (status)
- {
- case GNUNET_ARM_SERVICE_MONITORING_STARTED:
- return; /* this should be done silently */
- case GNUNET_ARM_SERVICE_STOPPED:
- msg = _ ("Stopped %s.\n");
- break;
- case GNUNET_ARM_SERVICE_STARTING:
- msg = _ ("Starting %s...\n");
- break;
- case GNUNET_ARM_SERVICE_STOPPING:
- msg = _ ("Stopping %s...\n");
- break;
- default:
- msg = NULL;
- break;
- }
- if (! quiet)
- {
- if (NULL != msg)
- fprintf (stderr, msg, service);
- else
- fprintf (stderr,
- _ ("Unknown status %u for service %s.\n"),
- status,
- service);
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Got service %s status %d\n",
- service,
- (int) status);
+ {
+ case GNUNET_ARM_SERVICE_MONITORING_STARTED:
+ return; /* this should be done silently */
+
+ case GNUNET_ARM_SERVICE_STOPPED:
+ msg = _("Stopped %s.\n");
+ break;
+
+ case GNUNET_ARM_SERVICE_STARTING:
+ msg = _("Starting %s...\n");
+ break;
+
+ case GNUNET_ARM_SERVICE_STOPPING:
+ msg = _("Stopping %s...\n");
+ break;
+
+ default:
+ msg = NULL;
+ break;
+ }
+ if (!quiet)
+ {
+ if (NULL != msg)
+ fprintf(stderr, msg, service);
+ else
+ fprintf(stderr,
+ _("Unknown status %u for service %s.\n"),
+ status,
+ service);
+ }
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Got service %s status %d\n",
+ service,
+ (int)status);
}
@@ -679,12 +699,12 @@ srv_status (void *cls,
* Task run on timeout (if -T is given).
*/
static void
-timeout_task_cb (void *cls)
+timeout_task_cb(void *cls)
{
- (void) cls;
+ (void)cls;
timeout_task = NULL;
ret = 2;
- GNUNET_SCHEDULER_shutdown ();
+ GNUNET_SCHEDULER_shutdown();
}
@@ -697,34 +717,34 @@ timeout_task_cb (void *cls)
* @param c configuration
*/
static void
-run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *c)
+run(void *cls,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *c)
{
- (void) cls;
- (void) args;
- (void) cfgfile;
- cfg = GNUNET_CONFIGURATION_dup (c);
+ (void)cls;
+ (void)args;
+ (void)cfgfile;
+ cfg = GNUNET_CONFIGURATION_dup(c);
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "GNUNET_HOME", &dir))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "PATHS", "GNUNET_HOME");
- return;
- }
- (void) GNUNET_CONFIGURATION_get_value_filename (cfg,
- "arm",
- "CONFIG",
- &config_file);
- if (NULL == (h = GNUNET_ARM_connect (cfg, &conn_status, NULL)))
+ GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "GNUNET_HOME", &dir))
+ {
+ GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR, "PATHS", "GNUNET_HOME");
+ return;
+ }
+ (void)GNUNET_CONFIGURATION_get_value_filename(cfg,
+ "arm",
+ "CONFIG",
+ &config_file);
+ if (NULL == (h = GNUNET_ARM_connect(cfg, &conn_status, NULL)))
return;
if (monitor)
- m = GNUNET_ARM_monitor_start (cfg, &srv_status, NULL);
- al_task = GNUNET_SCHEDULER_add_now (&action_loop, NULL);
- GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
+ m = GNUNET_ARM_monitor_start(cfg, &srv_status, NULL);
+ al_task = GNUNET_SCHEDULER_add_now(&action_loop, NULL);
+ GNUNET_SCHEDULER_add_shutdown(&shutdown_task, NULL);
if (0 != timeout.rel_value_us)
timeout_task =
- GNUNET_SCHEDULER_add_delayed (timeout, &timeout_task_cb, NULL);
+ GNUNET_SCHEDULER_add_delayed(timeout, &timeout_task_cb, NULL);
}
@@ -736,88 +756,88 @@ run (void *cls,
* @return 0 ok, 1 on error, 2 on timeout
*/
int
-main (int argc, char *const *argv)
+main(int argc, char *const *argv)
{
struct GNUNET_GETOPT_CommandLineOption options[] =
- {GNUNET_GETOPT_option_flag ('e',
- "end",
- gettext_noop ("stop all GNUnet services"),
- &end),
- GNUNET_GETOPT_option_string ('i',
- "init",
- "SERVICE",
- gettext_noop ("start a particular service"),
- &init),
- GNUNET_GETOPT_option_string ('k',
- "kill",
- "SERVICE",
- gettext_noop ("stop a particular service"),
- &term),
- GNUNET_GETOPT_option_flag ('s',
- "start",
- gettext_noop (
- "start all GNUnet default services"),
- &start),
- GNUNET_GETOPT_option_flag ('r',
- "restart",
- gettext_noop (
- "stop and start all GNUnet default services"),
- &restart),
- GNUNET_GETOPT_option_flag ('d',
- "delete",
- gettext_noop (
- "delete config file and directory on exit"),
- &delete),
- GNUNET_GETOPT_option_flag ('m',
- "monitor",
- gettext_noop ("monitor ARM activities"),
- &monitor),
- GNUNET_GETOPT_option_flag ('q',
- "quiet",
- gettext_noop ("don't print status messages"),
- &quiet),
- GNUNET_GETOPT_option_relative_time (
- 'T',
- "timeout",
- "DELAY",
- gettext_noop (
- "exit with error status if operation does not finish after DELAY"),
- &timeout),
- GNUNET_GETOPT_option_flag ('I',
- "info",
- gettext_noop (
- "list currently running services"),
- &list),
- GNUNET_GETOPT_option_flag (
- 'O',
- "no-stdout",
- gettext_noop ("don't let gnunet-service-arm inherit standard output"),
- &no_stdout),
- GNUNET_GETOPT_option_flag (
- 'E',
- "no-stderr",
- gettext_noop ("don't let gnunet-service-arm inherit standard error"),
- &no_stderr),
- GNUNET_GETOPT_OPTION_END};
+ { GNUNET_GETOPT_option_flag('e',
+ "end",
+ gettext_noop("stop all GNUnet services"),
+ &end),
+ GNUNET_GETOPT_option_string('i',
+ "init",
+ "SERVICE",
+ gettext_noop("start a particular service"),
+ &init),
+ GNUNET_GETOPT_option_string('k',
+ "kill",
+ "SERVICE",
+ gettext_noop("stop a particular service"),
+ &term),
+ GNUNET_GETOPT_option_flag('s',
+ "start",
+ gettext_noop(
+ "start all GNUnet default services"),
+ &start),
+ GNUNET_GETOPT_option_flag('r',
+ "restart",
+ gettext_noop(
+ "stop and start all GNUnet default services"),
+ &restart),
+ GNUNET_GETOPT_option_flag('d',
+ "delete",
+ gettext_noop(
+ "delete config file and directory on exit"),
+ &delete),
+ GNUNET_GETOPT_option_flag('m',
+ "monitor",
+ gettext_noop("monitor ARM activities"),
+ &monitor),
+ GNUNET_GETOPT_option_flag('q',
+ "quiet",
+ gettext_noop("don't print status messages"),
+ &quiet),
+ GNUNET_GETOPT_option_relative_time(
+ 'T',
+ "timeout",
+ "DELAY",
+ gettext_noop(
+ "exit with error status if operation does not finish after DELAY"),
+ &timeout),
+ GNUNET_GETOPT_option_flag('I',
+ "info",
+ gettext_noop(
+ "list currently running services"),
+ &list),
+ GNUNET_GETOPT_option_flag(
+ 'O',
+ "no-stdout",
+ gettext_noop("don't let gnunet-service-arm inherit standard output"),
+ &no_stdout),
+ GNUNET_GETOPT_option_flag(
+ 'E',
+ "no-stderr",
+ gettext_noop("don't let gnunet-service-arm inherit standard error"),
+ &no_stderr),
+ GNUNET_GETOPT_OPTION_END };
int lret;
- if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv))
return 2;
if (GNUNET_OK ==
- (lret = GNUNET_PROGRAM_run (
+ (lret = GNUNET_PROGRAM_run(
argc,
argv,
"gnunet-arm",
- gettext_noop (
+ gettext_noop(
"Control services and the Automated Restart Manager (ARM)"),
options,
&run,
NULL)))
- {
- GNUNET_free ((void *) argv);
- return ret;
- }
- GNUNET_free ((void *) argv);
+ {
+ GNUNET_free((void *)argv);
+ return ret;
+ }
+ GNUNET_free((void *)argv);
return lret;
}
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index b0f7e07c4..e8c740235 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
SPDX-License-Identifier: AGPL3.0-or-later
-*/
+ */
/**
* @file arm/gnunet-service-arm.c
@@ -29,10 +29,10 @@
#include "gnunet_protocols.h"
#include "arm.h"
-#define LOG(kind, ...) GNUNET_log_from (kind, "util", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from(kind, "util", __VA_ARGS__)
#define LOG_STRERROR(kind, syscall) \
- GNUNET_log_from_strerror (kind, "util", syscall)
+ GNUNET_log_from_strerror(kind, "util", syscall)
#if HAVE_WAIT4
@@ -65,8 +65,7 @@ struct ServiceList;
/**
* Record with information about a listen socket we have open.
*/
-struct ServiceListeningInfo
-{
+struct ServiceListeningInfo {
/**
* This is a linked list.
*/
@@ -107,8 +106,7 @@ struct ServiceListeningInfo
/**
* List of our services.
*/
-struct ServiceList
-{
+struct ServiceList {
/**
* This is a doubly-linked list.
*/
@@ -280,30 +278,30 @@ static struct GNUNET_NotificationContext *notifier;
* parameter is ignore on systems other than LINUX
*/
static void
-add_unixpath (struct sockaddr **saddrs,
- socklen_t *saddrlens,
- const char *unixpath,
- int abstract)
+add_unixpath(struct sockaddr **saddrs,
+ socklen_t *saddrlens,
+ const char *unixpath,
+ int abstract)
{
#ifdef AF_UNIX
struct sockaddr_un *un;
- un = GNUNET_new (struct sockaddr_un);
+ un = GNUNET_new(struct sockaddr_un);
un->sun_family = AF_UNIX;
- GNUNET_strlcpy (un->sun_path, unixpath, sizeof (un->sun_path));
+ GNUNET_strlcpy(un->sun_path, unixpath, sizeof(un->sun_path));
#ifdef LINUX
if (GNUNET_YES == abstract)
un->sun_path[0] = '\0';
#endif
#if HAVE_SOCKADDR_UN_SUN_LEN
- un->sun_len = (u_char) sizeof (struct sockaddr_un);
+ un->sun_len = (u_char)sizeof(struct sockaddr_un);
#endif
- *saddrs = (struct sockaddr *) un;
- *saddrlens = sizeof (struct sockaddr_un);
+ *saddrs = (struct sockaddr *)un;
+ *saddrlens = sizeof(struct sockaddr_un);
#else
/* this function should never be called
* unless AF_UNIX is defined! */
- GNUNET_assert (0);
+ GNUNET_assert(0);
#endif
}
@@ -329,10 +327,10 @@ add_unixpath (struct sockaddr **saddrs,
* set to NULL).
*/
static int
-get_server_addresses (const char *service_name,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct sockaddr ***addrs,
- socklen_t **addr_lens)
+get_server_addresses(const char *service_name,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct sockaddr ***addrs,
+ socklen_t **addr_lens)
{
int disablev6;
struct GNUNET_NETWORK_Handle *desc;
@@ -353,72 +351,72 @@ get_server_addresses (const char *service_name,
*addrs = NULL;
*addr_lens = NULL;
desc = NULL;
- if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "DISABLEV6"))
- {
- if (GNUNET_SYSERR ==
- (disablev6 = GNUNET_CONFIGURATION_get_value_yesno (cfg,
- service_name,
- "DISABLEV6")))
- return GNUNET_SYSERR;
- }
- else
- disablev6 = GNUNET_NO;
-
- if (! disablev6)
- {
- /* probe IPv6 support */
- desc = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0);
- if (NULL == desc)
+ if (GNUNET_CONFIGURATION_have_value(cfg, service_name, "DISABLEV6"))
{
- if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) ||
- (EACCES == errno))
- {
- LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "socket");
+ if (GNUNET_SYSERR ==
+ (disablev6 = GNUNET_CONFIGURATION_get_value_yesno(cfg,
+ service_name,
+ "DISABLEV6")))
return GNUNET_SYSERR;
- }
- LOG (GNUNET_ERROR_TYPE_INFO,
- _ (
- "Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
- service_name,
- strerror (errno));
- disablev6 = GNUNET_YES;
}
- else
+ else
+ disablev6 = GNUNET_NO;
+
+ if (!disablev6)
{
- GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (desc));
- desc = NULL;
+ /* probe IPv6 support */
+ desc = GNUNET_NETWORK_socket_create(PF_INET6, SOCK_STREAM, 0);
+ if (NULL == desc)
+ {
+ if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) ||
+ (EACCES == errno))
+ {
+ LOG_STRERROR(GNUNET_ERROR_TYPE_ERROR, "socket");
+ return GNUNET_SYSERR;
+ }
+ LOG(GNUNET_ERROR_TYPE_INFO,
+ _(
+ "Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
+ service_name,
+ strerror(errno));
+ disablev6 = GNUNET_YES;
+ }
+ else
+ {
+ GNUNET_break(GNUNET_OK == GNUNET_NETWORK_socket_close(desc));
+ desc = NULL;
+ }
}
- }
port = 0;
- if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT"))
- {
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg,
- service_name,
- "PORT",
- &port))
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- _ ("Require valid port number for service `%s' in configuration!\n"),
- service_name);
- }
- if (port > 65535)
+ if (GNUNET_CONFIGURATION_have_value(cfg, service_name, "PORT"))
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
- _ ("Require valid port number for service `%s' in configuration!\n"),
- service_name);
- return GNUNET_SYSERR;
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number(cfg,
+ service_name,
+ "PORT",
+ &port))
+ {
+ LOG(GNUNET_ERROR_TYPE_ERROR,
+ _("Require valid port number for service `%s' in configuration!\n"),
+ service_name);
+ }
+ if (port > 65535)
+ {
+ LOG(GNUNET_ERROR_TYPE_ERROR,
+ _("Require valid port number for service `%s' in configuration!\n"),
+ service_name);
+ return GNUNET_SYSERR;
+ }
}
- }
- if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "BINDTO"))
- {
- GNUNET_break (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (cfg,
+ if (GNUNET_CONFIGURATION_have_value(cfg, service_name, "BINDTO"))
+ {
+ GNUNET_break(GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string(cfg,
service_name,
"BINDTO",
&hostname));
- }
+ }
else
hostname = NULL;
@@ -426,235 +424,235 @@ get_server_addresses (const char *service_name,
abstract = GNUNET_NO;
#ifdef AF_UNIX
if ((GNUNET_YES ==
- GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) &&
- (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg,
- service_name,
- "UNIXPATH",
- &unixpath)) &&
- (0 < strlen (unixpath)))
- {
- /* probe UNIX support */
- struct sockaddr_un s_un;
-
- if (strlen (unixpath) >= sizeof (s_un.sun_path))
+ GNUNET_CONFIGURATION_have_value(cfg, service_name, "UNIXPATH")) &&
+ (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename(cfg,
+ service_name,
+ "UNIXPATH",
+ &unixpath)) &&
+ (0 < strlen(unixpath)))
{
- LOG (GNUNET_ERROR_TYPE_WARNING,
- _ ("UNIXPATH `%s' too long, maximum length is %llu\n"),
- unixpath,
- (unsigned long long) sizeof (s_un.sun_path));
- unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath);
- LOG (GNUNET_ERROR_TYPE_INFO, _ ("Using `%s' instead\n"), unixpath);
- }
+ /* probe UNIX support */
+ struct sockaddr_un s_un;
+
+ if (strlen(unixpath) >= sizeof(s_un.sun_path))
+ {
+ LOG(GNUNET_ERROR_TYPE_WARNING,
+ _("UNIXPATH `%s' too long, maximum length is %llu\n"),
+ unixpath,
+ (unsigned long long)sizeof(s_un.sun_path));
+ unixpath = GNUNET_NETWORK_shorten_unixpath(unixpath);
+ LOG(GNUNET_ERROR_TYPE_INFO, _("Using `%s' instead\n"), unixpath);
+ }
#ifdef LINUX
- abstract = GNUNET_CONFIGURATION_get_value_yesno (cfg,
- "TESTING",
- "USE_ABSTRACT_SOCKETS");
- if (GNUNET_SYSERR == abstract)
- abstract = GNUNET_NO;
+ abstract = GNUNET_CONFIGURATION_get_value_yesno(cfg,
+ "TESTING",
+ "USE_ABSTRACT_SOCKETS");
+ if (GNUNET_SYSERR == abstract)
+ abstract = GNUNET_NO;
#endif
- if ((GNUNET_YES != abstract) &&
- (GNUNET_OK != GNUNET_DISK_directory_create_for_file (unixpath)))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "mkdir", unixpath);
- }
- if (NULL != unixpath)
- {
- desc = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0);
- if (NULL == desc)
- {
- if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) ||
- (EACCES == errno))
- {
- LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "socket");
- GNUNET_free_non_null (hostname);
- GNUNET_free (unixpath);
- return GNUNET_SYSERR;
- }
- LOG (GNUNET_ERROR_TYPE_INFO,
- _ (
- "Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"),
- service_name,
- strerror (errno));
- GNUNET_free (unixpath);
- unixpath = NULL;
+ if ((GNUNET_YES != abstract) &&
+ (GNUNET_OK != GNUNET_DISK_directory_create_for_file(unixpath)))
+ GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR, "mkdir", unixpath);
}
- else
+ if (NULL != unixpath)
{
- GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (desc));
- desc = NULL;
+ desc = GNUNET_NETWORK_socket_create(AF_UNIX, SOCK_STREAM, 0);
+ if (NULL == desc)
+ {
+ if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) ||
+ (EACCES == errno))
+ {
+ LOG_STRERROR(GNUNET_ERROR_TYPE_ERROR, "socket");
+ GNUNET_free_non_null(hostname);
+ GNUNET_free(unixpath);
+ return GNUNET_SYSERR;
+ }
+ LOG(GNUNET_ERROR_TYPE_INFO,
+ _(
+ "Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"),
+ service_name,
+ strerror(errno));
+ GNUNET_free(unixpath);
+ unixpath = NULL;
+ }
+ else
+ {
+ GNUNET_break(GNUNET_OK == GNUNET_NETWORK_socket_close(desc));
+ desc = NULL;
+ }
}
- }
#endif
if ((0 == port) && (NULL == unixpath))
- {
- if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg,
- service_name,
- "START_ON_DEMAND"))
- LOG (GNUNET_ERROR_TYPE_ERROR,
- _ (
- "Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
- service_name);
- GNUNET_free_non_null (hostname);
- return GNUNET_SYSERR;
- }
- if (0 == port)
- {
- saddrs = GNUNET_new_array (2, struct sockaddr *);
- saddrlens = GNUNET_new_array (2, socklen_t);
- add_unixpath (saddrs, saddrlens, unixpath, abstract);
- GNUNET_free_non_null (unixpath);
- GNUNET_free_non_null (hostname);
- *addrs = saddrs;
- *addr_lens = saddrlens;
- return 1;
- }
-
- if (NULL != hostname)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Resolving `%s' since that is where `%s' will bind to.\n",
- hostname,
- service_name);
- memset (&hints, 0, sizeof (struct addrinfo));
- if (disablev6)
- hints.ai_family = AF_INET;
- hints.ai_protocol = IPPROTO_TCP;
- if ((0 != (ret = getaddrinfo (hostname, NULL, &hints, &res))) ||
- (NULL == res))
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
- _ ("Failed to resolve `%s': %s\n"),
- hostname,
- gai_strerror (ret));
- GNUNET_free (hostname);
- GNUNET_free_non_null (unixpath);
- return GNUNET_SYSERR;
- }
- next = res;
- i = 0;
- while (NULL != (pos = next))
- {
- next = pos->ai_next;
- if ((disablev6) && (pos->ai_family == AF_INET6))
- continue;
- i++;
- }
- if (0 == i)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- _ ("Failed to find %saddress for `%s'.\n"),
- disablev6 ? "IPv4 " : "",
- hostname);
- freeaddrinfo (res);
- GNUNET_free (hostname);
- GNUNET_free_non_null (unixpath);
+ if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(cfg,
+ service_name,
+ "START_ON_DEMAND"))
+ LOG(GNUNET_ERROR_TYPE_ERROR,
+ _(
+ "Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
+ service_name);
+ GNUNET_free_non_null(hostname);
return GNUNET_SYSERR;
}
- resi = i;
- if (NULL != unixpath)
- resi++;
- saddrs = GNUNET_new_array (resi + 1, struct sockaddr *);
- saddrlens = GNUNET_new_array (resi + 1, socklen_t);
- i = 0;
- if (NULL != unixpath)
+ if (0 == port)
{
- add_unixpath (saddrs, saddrlens, unixpath, abstract);
- i++;
+ saddrs = GNUNET_new_array(2, struct sockaddr *);
+ saddrlens = GNUNET_new_array(2, socklen_t);
+ add_unixpath(saddrs, saddrlens, unixpath, abstract);
+ GNUNET_free_non_null(unixpath);
+ GNUNET_free_non_null(hostname);
+ *addrs = saddrs;
+ *addr_lens = saddrlens;
+ return 1;
}
- next = res;
- while (NULL != (pos = next))
- {
- next = pos->ai_next;
- if ((disablev6) && (AF_INET6 == pos->ai_family))
- continue;
- if ((IPPROTO_TCP != pos->ai_protocol) && (0 != pos->ai_protocol))
- continue; /* not TCP */
- if ((SOCK_STREAM != pos->ai_socktype) && (0 != pos->ai_socktype))
- continue; /* huh? */
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Service `%s' will bind to `%s'\n",
- service_name,
- GNUNET_a2s (pos->ai_addr, pos->ai_addrlen));
- if (AF_INET == pos->ai_family)
- {
- GNUNET_assert (sizeof (struct sockaddr_in) == pos->ai_addrlen);
- saddrlens[i] = pos->ai_addrlen;
- saddrs[i] = GNUNET_malloc (saddrlens[i]);
- GNUNET_memcpy (saddrs[i], pos->ai_addr, saddrlens[i]);
- ((struct sockaddr_in *) saddrs[i])->sin_port = htons (port);
- }
- else
- {
- GNUNET_assert (AF_INET6 == pos->ai_family);
- GNUNET_assert (sizeof (struct sockaddr_in6) == pos->ai_addrlen);
- saddrlens[i] = pos->ai_addrlen;
- saddrs[i] = GNUNET_malloc (saddrlens[i]);
- GNUNET_memcpy (saddrs[i], pos->ai_addr, saddrlens[i]);
- ((struct sockaddr_in6 *) saddrs[i])->sin6_port = htons (port);
- }
- i++;
- }
- GNUNET_free (hostname);
- freeaddrinfo (res);
- resi = i;
- }
- else
- {
- /* will bind against everything, just set port */
- if (disablev6)
+
+ if (NULL != hostname)
{
- /* V4-only */
- resi = 1;
+ LOG(GNUNET_ERROR_TYPE_DEBUG,
+ "Resolving `%s' since that is where `%s' will bind to.\n",
+ hostname,
+ service_name);
+ memset(&hints, 0, sizeof(struct addrinfo));
+ if (disablev6)
+ hints.ai_family = AF_INET;
+ hints.ai_protocol = IPPROTO_TCP;
+ if ((0 != (ret = getaddrinfo(hostname, NULL, &hints, &res))) ||
+ (NULL == res))
+ {
+ LOG(GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to resolve `%s': %s\n"),
+ hostname,
+ gai_strerror(ret));
+ GNUNET_free(hostname);
+ GNUNET_free_non_null(unixpath);
+ return GNUNET_SYSERR;
+ }
+ next = res;
+ i = 0;
+ while (NULL != (pos = next))
+ {
+ next = pos->ai_next;
+ if ((disablev6) && (pos->ai_family == AF_INET6))
+ continue;
+ i++;
+ }
+ if (0 == i)
+ {
+ LOG(GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to find %saddress for `%s'.\n"),
+ disablev6 ? "IPv4 " : "",
+ hostname);
+ freeaddrinfo(res);
+ GNUNET_free(hostname);
+ GNUNET_free_non_null(unixpath);
+ return GNUNET_SYSERR;
+ }
+ resi = i;
if (NULL != unixpath)
resi++;
+ saddrs = GNUNET_new_array(resi + 1, struct sockaddr *);
+ saddrlens = GNUNET_new_array(resi + 1, socklen_t);
i = 0;
- saddrs = GNUNET_new_array (resi + 1, struct sockaddr *);
- saddrlens = GNUNET_new_array (resi + 1, socklen_t);
if (NULL != unixpath)
- {
- add_unixpath (saddrs, saddrlens, unixpath, abstract);
- i++;
- }
- saddrlens[i] = sizeof (struct sockaddr_in);
- saddrs[i] = GNUNET_malloc (saddrlens[i]);
-#if HAVE_SOCKADDR_IN_SIN_LEN
- ((struct sockaddr_in *) saddrs[i])->sin_len = saddrlens[i];
-#endif
- ((struct sockaddr_in *) saddrs[i])->sin_family = AF_INET;
- ((struct sockaddr_in *) saddrs[i])->sin_port = htons (port);
+ {
+ add_unixpath(saddrs, saddrlens, unixpath, abstract);
+ i++;
+ }
+ next = res;
+ while (NULL != (pos = next))
+ {
+ next = pos->ai_next;
+ if ((disablev6) && (AF_INET6 == pos->ai_family))
+ continue;
+ if ((IPPROTO_TCP != pos->ai_protocol) && (0 != pos->ai_protocol))
+ continue; /* not TCP */
+ if ((SOCK_STREAM != pos->ai_socktype) && (0 != pos->ai_socktype))
+ continue; /* huh? */
+ LOG(GNUNET_ERROR_TYPE_DEBUG,
+ "Service `%s' will bind to `%s'\n",
+ service_name,
+ GNUNET_a2s(pos->ai_addr, pos->ai_addrlen));
+ if (AF_INET == pos->ai_family)
+ {
+ GNUNET_assert(sizeof(struct sockaddr_in) == pos->ai_addrlen);
+ saddrlens[i] = pos->ai_addrlen;
+ saddrs[i] = GNUNET_malloc(saddrlens[i]);
+ GNUNET_memcpy(saddrs[i], pos->ai_addr, saddrlens[i]);
+ ((struct sockaddr_in *)saddrs[i])->sin_port = htons(port);
+ }
+ else
+ {
+ GNUNET_assert(AF_INET6 == pos->ai_family);
+ GNUNET_assert(sizeof(struct sockaddr_in6) == pos->ai_addrlen);
+ saddrlens[i] = pos->ai_addrlen;
+ saddrs[i] = GNUNET_malloc(saddrlens[i]);
+ GNUNET_memcpy(saddrs[i], pos->ai_addr, saddrlens[i]);
+ ((struct sockaddr_in6 *)saddrs[i])->sin6_port = htons(port);
+ }
+ i++;
+ }
+ GNUNET_free(hostname);
+ freeaddrinfo(res);
+ resi = i;
}
- else
+ else
{
- /* dual stack */
- resi = 2;
- if (NULL != unixpath)
- resi++;
- saddrs = GNUNET_new_array (resi + 1, struct sockaddr *);
- saddrlens = GNUNET_new_array (resi + 1, socklen_t);
- i = 0;
- if (NULL != unixpath)
- {
- add_unixpath (saddrs, saddrlens, unixpath, abstract);
- i++;
- }
- saddrlens[i] = sizeof (struct sockaddr_in6);
- saddrs[i] = GNUNET_malloc (saddrlens[i]);
+ /* will bind against everything, just set port */
+ if (disablev6)
+ {
+ /* V4-only */
+ resi = 1;
+ if (NULL != unixpath)
+ resi++;
+ i = 0;
+ saddrs = GNUNET_new_array(resi + 1, struct sockaddr *);
+ saddrlens = GNUNET_new_array(resi + 1, socklen_t);
+ if (NULL != unixpath)
+ {
+ add_unixpath(saddrs, saddrlens, unixpath, abstract);
+ i++;
+ }
+ saddrlens[i] = sizeof(struct sockaddr_in);
+ saddrs[i] = GNUNET_malloc(saddrlens[i]);
+#if HAVE_SOCKADDR_IN_SIN_LEN
+ ((struct sockaddr_in *)saddrs[i])->sin_len = saddrlens[i];
+#endif
+ ((struct sockaddr_in *)saddrs[i])->sin_family = AF_INET;
+ ((struct sockaddr_in *)saddrs[i])->sin_port = htons(port);
+ }
+ else
+ {
+ /* dual stack */
+ resi = 2;
+ if (NULL != unixpath)
+ resi++;
+ saddrs = GNUNET_new_array(resi + 1, struct sockaddr *);
+ saddrlens = GNUNET_new_array(resi + 1, socklen_t);
+ i = 0;
+ if (NULL != unixpath)
+ {
+ add_unixpath(saddrs, saddrlens, unixpath, abstract);
+ i++;
+ }
+ saddrlens[i] = sizeof(struct sockaddr_in6);
+ saddrs[i] = GNUNET_malloc(saddrlens[i]);
#if HAVE_SOCKADDR_IN_SIN_LEN
- ((struct sockaddr_in6 *) saddrs[i])->sin6_len = saddrlens[0];
+ ((struct sockaddr_in6 *)saddrs[i])->sin6_len = saddrlens[0];
#endif
- ((struct sockaddr_in6 *) saddrs[i])->sin6_family = AF_INET6;
- ((struct sockaddr_in6 *) saddrs[i])->sin6_port = htons (port);
- i++;
- saddrlens[i] = sizeof (struct sockaddr_in);
- saddrs[i] = GNUNET_malloc (saddrlens[i]);
+ ((struct sockaddr_in6 *)saddrs[i])->sin6_family = AF_INET6;
+ ((struct sockaddr_in6 *)saddrs[i])->sin6_port = htons(port);
+ i++;
+ saddrlens[i] = sizeof(struct sockaddr_in);
+ saddrs[i] = GNUNET_malloc(saddrlens[i]);
#if HAVE_SOCKADDR_IN_SIN_LEN
- ((struct sockaddr_in *) saddrs[i])->sin_len = saddrlens[1];
+ ((struct sockaddr_in *)saddrs[i])->sin_len = saddrlens[1];
#endif
- ((struct sockaddr_in *) saddrs[i])->sin_family = AF_INET;
- ((struct sockaddr_in *) saddrs[i])->sin_port = htons (port);
+ ((struct sockaddr_in *)saddrs[i])->sin_family = AF_INET;
+ ((struct sockaddr_in *)saddrs[i])->sin_port = htons(port);
+ }
}
- }
- GNUNET_free_non_null (unixpath);
+ GNUNET_free_non_null(unixpath);
*addrs = saddrs;
*addr_lens = saddrlens;
return resi;
@@ -672,19 +670,19 @@ get_server_addresses (const char *service_name,
* @return NULL if it was not found
*/
static void
-signal_result (struct GNUNET_SERVICE_Client *client,
- const char *name,
- uint64_t request_id,
- enum GNUNET_ARM_Result result)
+signal_result(struct GNUNET_SERVICE_Client *client,
+ const char *name,
+ uint64_t request_id,
+ enum GNUNET_ARM_Result result)
{
struct GNUNET_MQ_Envelope *env;
struct GNUNET_ARM_ResultMessage *msg;
- (void) name;
- env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_ARM_RESULT);
- msg->result = htonl (result);
- msg->arm_msg.request_id = GNUNET_htonll (request_id);
- GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
+ (void)name;
+ env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_ARM_RESULT);
+ msg->result = htonl(result);
+ msg->arm_msg.request_id = GNUNET_htonll(request_id);
+ GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client), env);
}
@@ -697,34 +695,34 @@ signal_result (struct GNUNET_SERVICE_Client *client,
* otherwise, send to all clients in the notifier
*/
static void
-broadcast_status (const char *name,
- enum GNUNET_ARM_ServiceStatus status,
- struct GNUNET_SERVICE_Client *unicast)
+broadcast_status(const char *name,
+ enum GNUNET_ARM_ServiceStatus status,
+ struct GNUNET_SERVICE_Client *unicast)
{
struct GNUNET_MQ_Envelope *env;
struct GNUNET_ARM_StatusMessage *msg;
size_t namelen;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending status %u of service `%s' to client\n",
- (unsigned int) status,
- name);
- namelen = strlen (name) + 1;
- env = GNUNET_MQ_msg_extra (msg, namelen, GNUNET_MESSAGE_TYPE_ARM_STATUS);
- msg->status = htonl ((uint32_t) (status));
- GNUNET_memcpy ((char *) &msg[1], name, namelen);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Sending status %u of service `%s' to client\n",
+ (unsigned int)status,
+ name);
+ namelen = strlen(name) + 1;
+ env = GNUNET_MQ_msg_extra(msg, namelen, GNUNET_MESSAGE_TYPE_ARM_STATUS);
+ msg->status = htonl((uint32_t)(status));
+ GNUNET_memcpy((char *)&msg[1], name, namelen);
if (NULL == unicast)
- {
- if (NULL != notifier)
- GNUNET_notification_context_broadcast (notifier,
- &msg->header,
- GNUNET_YES);
- GNUNET_MQ_discard (env);
- }
+ {
+ if (NULL != notifier)
+ GNUNET_notification_context_broadcast(notifier,
+ &msg->header,
+ GNUNET_YES);
+ GNUNET_MQ_discard(env);
+ }
else
- {
- GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (unicast), env);
- }
+ {
+ GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(unicast), env);
+ }
}
@@ -737,9 +735,9 @@ broadcast_status (const char *name,
* being started. 0 if starting was not requested.
*/
static void
-start_process (struct ServiceList *sl,
- struct GNUNET_SERVICE_Client *client,
- uint64_t request_id)
+start_process(struct ServiceList *sl,
+ struct GNUNET_SERVICE_Client *client,
+ uint64_t request_id)
{
char *loprefix;
char *options;
@@ -755,194 +753,194 @@ start_process (struct ServiceList *sl,
lsocks = NULL;
ls = 0;
for (sli = sl->listen_head; NULL != sli; sli = sli->next)
- {
- GNUNET_array_append (lsocks,
- ls,
- GNUNET_NETWORK_get_fd (sli->listen_socket));
- if (NULL != sli->accept_task)
{
- GNUNET_SCHEDULER_cancel (sli->accept_task);
- sli->accept_task = NULL;
+ GNUNET_array_append(lsocks,
+ ls,
+ GNUNET_NETWORK_get_fd(sli->listen_socket));
+ if (NULL != sli->accept_task)
+ {
+ GNUNET_SCHEDULER_cancel(sli->accept_task);
+ sli->accept_task = NULL;
+ }
}
- }
#if WINDOWS
- GNUNET_array_append (lsocks, ls, INVALID_SOCKET);
+ GNUNET_array_append(lsocks, ls, INVALID_SOCKET);
#else
- GNUNET_array_append (lsocks, ls, -1);
+ GNUNET_array_append(lsocks, ls, -1);
#endif
/* obtain configuration */
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
- sl->name,
- "PREFIX",
- &loprefix))
- loprefix = GNUNET_strdup (prefix_command);
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg,
+ sl->name,
+ "PREFIX",
+ &loprefix))
+ loprefix = GNUNET_strdup(prefix_command);
else
- loprefix = GNUNET_CONFIGURATION_expand_dollar (cfg, loprefix);
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
- sl->name,
- "OPTIONS",
- &options))
+ loprefix = GNUNET_CONFIGURATION_expand_dollar(cfg, loprefix);
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg,
+ sl->name,
+ "OPTIONS",
+ &options))
options = NULL;
else
- options = GNUNET_CONFIGURATION_expand_dollar (cfg, options);
+ options = GNUNET_CONFIGURATION_expand_dollar(cfg, options);
{
char *new_options;
char *optpos;
char *fin_options;
- fin_options = GNUNET_strdup (final_option);
+ fin_options = GNUNET_strdup(final_option);
/* replace '{}' with service name */
- while (NULL != (optpos = strstr (fin_options, "{}")))
- {
- /* terminate string at opening parenthesis */
- *optpos = 0;
- GNUNET_asprintf (&new_options,
- "%s%s%s",
- fin_options,
- sl->name,
- optpos + 2);
- GNUNET_free (fin_options);
- fin_options = new_options;
- }
+ while (NULL != (optpos = strstr(fin_options, "{}")))
+ {
+ /* terminate string at opening parenthesis */
+ *optpos = 0;
+ GNUNET_asprintf(&new_options,
+ "%s%s%s",
+ fin_options,
+ sl->name,
+ optpos + 2);
+ GNUNET_free(fin_options);
+ fin_options = new_options;
+ }
if (NULL != options)
- {
- /* combine "fin_options" with "options" */
- optpos = options;
- GNUNET_asprintf (&options, "%s %s", fin_options, optpos);
- GNUNET_free (fin_options);
- GNUNET_free (optpos);
- }
+ {
+ /* combine "fin_options" with "options" */
+ optpos = options;
+ GNUNET_asprintf(&options, "%s %s", fin_options, optpos);
+ GNUNET_free(fin_options);
+ GNUNET_free(optpos);
+ }
else
- {
- /* only have "fin_options", use that */
- options = fin_options;
- }
+ {
+ /* only have "fin_options", use that */
+ options = fin_options;
+ }
}
- options = GNUNET_CONFIGURATION_expand_dollar (cfg, options);
- use_debug = GNUNET_CONFIGURATION_get_value_yesno (cfg, sl->name, "DEBUG");
+ options = GNUNET_CONFIGURATION_expand_dollar(cfg, options);
+ use_debug = GNUNET_CONFIGURATION_get_value_yesno(cfg, sl->name, "DEBUG");
{
const char *service_type = NULL;
- const char *choices[] = {"GNUNET", "SIMPLE", NULL};
+ const char *choices[] = { "GNUNET", "SIMPLE", NULL };
is_simple_service = GNUNET_NO;
- if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_choice (cfg,
- sl->name,
- "TYPE",
- choices,
- &service_type)) &&
- (0 == strcasecmp (service_type, "SIMPLE")))
+ if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_choice(cfg,
+ sl->name,
+ "TYPE",
+ choices,
+ &service_type)) &&
+ (0 == strcasecmp(service_type, "SIMPLE")))
is_simple_service = GNUNET_YES;
}
- GNUNET_assert (NULL == sl->proc);
+ GNUNET_assert(NULL == sl->proc);
if (GNUNET_YES == is_simple_service)
- {
- /* A simple service will receive no GNUnet specific
- command line options. */
- binary = GNUNET_strdup (sl->binary);
- binary = GNUNET_CONFIGURATION_expand_dollar (cfg, binary);
- GNUNET_asprintf (&quotedbinary, "\"%s\"", sl->binary);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Starting simple service `%s' using binary `%s'\n",
- sl->name,
- sl->binary);
- /* FIXME: dollar expansion should only be done outside
- * of ''-quoted strings, escaping should be considered. */
- if (NULL != options)
- options = GNUNET_CONFIGURATION_expand_dollar (cfg, options);
- sl->proc = GNUNET_OS_start_process_s (sl->pipe_control,
- GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- lsocks,
- loprefix,
- quotedbinary,
- options,
- NULL);
- }
- else
- {
- /* actually start process */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Starting service `%s' using binary `%s' and configuration `%s'\n",
- sl->name,
- sl->binary,
- sl->config);
- binary = GNUNET_OS_get_libexec_binary_path (sl->binary);
- GNUNET_asprintf (&quotedbinary, "\"%s\"", binary);
-
- if (GNUNET_YES == use_debug)
{
- if (NULL == sl->config)
- sl->proc = GNUNET_OS_start_process_s (sl->pipe_control,
- GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- lsocks,
- loprefix,
- quotedbinary,
- "-L",
- "DEBUG",
- options,
- NULL);
- else
- sl->proc = GNUNET_OS_start_process_s (sl->pipe_control,
- GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- lsocks,
- loprefix,
- quotedbinary,
- "-c",
- sl->config,
- "-L",
- "DEBUG",
- options,
- NULL);
+ /* A simple service will receive no GNUnet specific
+ command line options. */
+ binary = GNUNET_strdup(sl->binary);
+ binary = GNUNET_CONFIGURATION_expand_dollar(cfg, binary);
+ GNUNET_asprintf(&quotedbinary, "\"%s\"", sl->binary);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Starting simple service `%s' using binary `%s'\n",
+ sl->name,
+ sl->binary);
+ /* FIXME: dollar expansion should only be done outside
+ * of ''-quoted strings, escaping should be considered. */
+ if (NULL != options)
+ options = GNUNET_CONFIGURATION_expand_dollar(cfg, options);
+ sl->proc = GNUNET_OS_start_process_s(sl->pipe_control,
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ lsocks,
+ loprefix,
+ quotedbinary,
+ options,
+ NULL);
}
- else
+ else
{
- if (NULL == sl->config)
- sl->proc = GNUNET_OS_start_process_s (sl->pipe_control,
- GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- lsocks,
- loprefix,
- quotedbinary,
- options,
- NULL);
+ /* actually start process */
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Starting service `%s' using binary `%s' and configuration `%s'\n",
+ sl->name,
+ sl->binary,
+ sl->config);
+ binary = GNUNET_OS_get_libexec_binary_path(sl->binary);
+ GNUNET_asprintf(&quotedbinary, "\"%s\"", binary);
+
+ if (GNUNET_YES == use_debug)
+ {
+ if (NULL == sl->config)
+ sl->proc = GNUNET_OS_start_process_s(sl->pipe_control,
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ lsocks,
+ loprefix,
+ quotedbinary,
+ "-L",
+ "DEBUG",
+ options,
+ NULL);
+ else
+ sl->proc = GNUNET_OS_start_process_s(sl->pipe_control,
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ lsocks,
+ loprefix,
+ quotedbinary,
+ "-c",
+ sl->config,
+ "-L",
+ "DEBUG",
+ options,
+ NULL);
+ }
else
- sl->proc = GNUNET_OS_start_process_s (sl->pipe_control,
- GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- lsocks,
- loprefix,
- quotedbinary,
- "-c",
- sl->config,
- options,
- NULL);
+ {
+ if (NULL == sl->config)
+ sl->proc = GNUNET_OS_start_process_s(sl->pipe_control,
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ lsocks,
+ loprefix,
+ quotedbinary,
+ options,
+ NULL);
+ else
+ sl->proc = GNUNET_OS_start_process_s(sl->pipe_control,
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ lsocks,
+ loprefix,
+ quotedbinary,
+ "-c",
+ sl->config,
+ options,
+ NULL);
+ }
}
- }
- GNUNET_free (binary);
- GNUNET_free (quotedbinary);
+ GNUNET_free(binary);
+ GNUNET_free(quotedbinary);
if (NULL == sl->proc)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Failed to start service `%s'\n"),
- sl->name);
- if (client)
- signal_result (client,
- sl->name,
- request_id,
- GNUNET_ARM_RESULT_START_FAILED);
- }
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to start service `%s'\n"),
+ sl->name);
+ if (client)
+ signal_result(client,
+ sl->name,
+ request_id,
+ GNUNET_ARM_RESULT_START_FAILED);
+ }
else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _ ("Starting service `%s'\n"),
- sl->name);
- broadcast_status (sl->name, GNUNET_ARM_SERVICE_STARTING, NULL);
- if (client)
- signal_result (client, sl->name, request_id, GNUNET_ARM_RESULT_STARTING);
- }
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ _("Starting service `%s'\n"),
+ sl->name);
+ broadcast_status(sl->name, GNUNET_ARM_SERVICE_STARTING, NULL);
+ if (client)
+ signal_result(client, sl->name, request_id, GNUNET_ARM_RESULT_STARTING);
+ }
/* clean up */
- GNUNET_free (loprefix);
- GNUNET_free (options);
- GNUNET_array_grow (lsocks, ls, 0);
+ GNUNET_free(loprefix);
+ GNUNET_free(options);
+ GNUNET_array_grow(lsocks, ls, 0);
}
@@ -954,17 +952,17 @@ start_process (struct ServiceList *sl,
* @return NULL if it was not found
*/
static struct ServiceList *
-find_service (const char *name)
+find_service(const char *name)
{
struct ServiceList *sl;
sl = running_head;
while (sl != NULL)
- {
- if (0 == strcasecmp (sl->name, name))
- return sl;
- sl = sl->next;
- }
+ {
+ if (0 == strcasecmp(sl->name, name))
+ return sl;
+ sl = sl->next;
+ }
return NULL;
}
@@ -976,14 +974,14 @@ find_service (const char *name)
* @param cls callback data, `struct ServiceListeningInfo` describing a listen socket
*/
static void
-accept_connection (void *cls)
+accept_connection(void *cls)
{
struct ServiceListeningInfo *sli = cls;
struct ServiceList *sl = sli->sl;
sli->accept_task = NULL;
- GNUNET_assert (GNUNET_NO == in_shutdown);
- start_process (sl, NULL, 0);
+ GNUNET_assert(GNUNET_NO == in_shutdown);
+ start_process(sl, NULL, 0);
}
@@ -996,121 +994,125 @@ accept_connection (void *cls)
* @param sl service entry for the service in question
*/
static void
-create_listen_socket (struct sockaddr *sa,
- socklen_t addr_len,
- struct ServiceList *sl)
+create_listen_socket(struct sockaddr *sa,
+ socklen_t addr_len,
+ struct ServiceList *sl)
{
static int on = 1;
struct GNUNET_NETWORK_Handle *sock;
struct ServiceListeningInfo *sli;
+
#ifndef WINDOWS
int match_uid;
int match_gid;
#endif
switch (sa->sa_family)
- {
- case AF_INET:
- sock = GNUNET_NETWORK_socket_create (PF_INET, SOCK_STREAM, 0);
- break;
- case AF_INET6:
- sock = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0);
- break;
- case AF_UNIX:
- if (0 == strcmp (GNUNET_a2s (sa, addr_len),
- "@")) /* Do not bind to blank UNIX path! */
- return;
- sock = GNUNET_NETWORK_socket_create (PF_UNIX, SOCK_STREAM, 0);
- break;
- default:
- GNUNET_break (0);
- sock = NULL;
- errno = EAFNOSUPPORT;
- break;
- }
+ {
+ case AF_INET:
+ sock = GNUNET_NETWORK_socket_create(PF_INET, SOCK_STREAM, 0);
+ break;
+
+ case AF_INET6:
+ sock = GNUNET_NETWORK_socket_create(PF_INET6, SOCK_STREAM, 0);
+ break;
+
+ case AF_UNIX:
+ if (0 == strcmp(GNUNET_a2s(sa, addr_len),
+ "@")) /* Do not bind to blank UNIX path! */
+ return;
+ sock = GNUNET_NETWORK_socket_create(PF_UNIX, SOCK_STREAM, 0);
+ break;
+
+ default:
+ GNUNET_break(0);
+ sock = NULL;
+ errno = EAFNOSUPPORT;
+ break;
+ }
if (NULL == sock)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Unable to create socket for service `%s': %s\n"),
- sl->name,
- strerror (errno));
- GNUNET_free (sa);
- return;
- }
- if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (sock,
- SOL_SOCKET,
- SO_REUSEADDR,
- &on,
- sizeof (on)))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "setsockopt");
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ _("Unable to create socket for service `%s': %s\n"),
+ sl->name,
+ strerror(errno));
+ GNUNET_free(sa);
+ return;
+ }
+ if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt(sock,
+ SOL_SOCKET,
+ SO_REUSEADDR,
+ &on,
+ sizeof(on)))
+ GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "setsockopt");
#ifdef IPV6_V6ONLY
if ((sa->sa_family == AF_INET6) &&
- (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (sock,
- IPPROTO_IPV6,
- IPV6_V6ONLY,
- &on,
- sizeof (on))))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "setsockopt");
+ (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt(sock,
+ IPPROTO_IPV6,
+ IPV6_V6ONLY,
+ &on,
+ sizeof(on))))
+ GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "setsockopt");
#endif
#ifndef WINDOWS
if (AF_UNIX == sa->sa_family)
- GNUNET_NETWORK_unix_precheck ((struct sockaddr_un *) sa);
+ GNUNET_NETWORK_unix_precheck((struct sockaddr_un *)sa);
#endif
if (GNUNET_OK !=
- GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) sa, addr_len))
- {
- GNUNET_log (
- GNUNET_ERROR_TYPE_WARNING,
- _ (
- "Unable to bind listening socket for service `%s' to address `%s': %s\n"),
- sl->name,
- GNUNET_a2s (sa, addr_len),
- strerror (errno));
- GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock));
- GNUNET_free (sa);
- return;
- }
+ GNUNET_NETWORK_socket_bind(sock, (const struct sockaddr *)sa, addr_len))
+ {
+ GNUNET_log(
+ GNUNET_ERROR_TYPE_WARNING,
+ _(
+ "Unable to bind listening socket for service `%s' to address `%s': %s\n"),
+ sl->name,
+ GNUNET_a2s(sa, addr_len),
+ strerror(errno));
+ GNUNET_break(GNUNET_OK == GNUNET_NETWORK_socket_close(sock));
+ GNUNET_free(sa);
+ return;
+ }
#ifndef WINDOWS
if ((AF_UNIX == sa->sa_family)
#ifdef LINUX
/* Permission settings are not required when abstract sockets are used */
- && ('\0' != ((const struct sockaddr_un *) sa)->sun_path[0])
+ && ('\0' != ((const struct sockaddr_un *)sa)->sun_path[0])
#endif
- )
- {
- match_uid =
- GNUNET_CONFIGURATION_get_value_yesno (cfg, sl->name, "UNIX_MATCH_UID");
- match_gid =
- GNUNET_CONFIGURATION_get_value_yesno (cfg, sl->name, "UNIX_MATCH_GID");
- GNUNET_DISK_fix_permissions (((const struct sockaddr_un *) sa)->sun_path,
- match_uid,
- match_gid);
- }
+ )
+ {
+ match_uid =
+ GNUNET_CONFIGURATION_get_value_yesno(cfg, sl->name, "UNIX_MATCH_UID");
+ match_gid =
+ GNUNET_CONFIGURATION_get_value_yesno(cfg, sl->name, "UNIX_MATCH_GID");
+ GNUNET_DISK_fix_permissions(((const struct sockaddr_un *)sa)->sun_path,
+ match_uid,
+ match_gid);
+ }
#endif
- if (GNUNET_OK != GNUNET_NETWORK_socket_listen (sock, 5))
- {
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "listen");
- GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock));
- GNUNET_free (sa);
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _ ("ARM now monitors connections to service `%s' at `%s'\n"),
- sl->name,
- GNUNET_a2s (sa, addr_len));
- sli = GNUNET_new (struct ServiceListeningInfo);
+ if (GNUNET_OK != GNUNET_NETWORK_socket_listen(sock, 5))
+ {
+ GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, "listen");
+ GNUNET_break(GNUNET_OK == GNUNET_NETWORK_socket_close(sock));
+ GNUNET_free(sa);
+ return;
+ }
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ _("ARM now monitors connections to service `%s' at `%s'\n"),
+ sl->name,
+ GNUNET_a2s(sa, addr_len));
+ sli = GNUNET_new(struct ServiceListeningInfo);
sli->service_addr = sa;
sli->service_addr_len = addr_len;
sli->listen_socket = sock;
sli->sl = sl;
sli->accept_task =
- GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
- sock,
- &accept_connection,
- sli);
- GNUNET_CONTAINER_DLL_insert (sl->listen_head, sl->listen_tail, sli);
+ GNUNET_SCHEDULER_add_read_net(GNUNET_TIME_UNIT_FOREVER_REL,
+ sock,
+ &accept_connection,
+ sli);
+ GNUNET_CONTAINER_DLL_insert(sl->listen_head, sl->listen_tail, sli);
}
@@ -1121,15 +1123,15 @@ create_listen_socket (struct sockaddr *sa,
* @param sl entry to free
*/
static void
-free_service (struct ServiceList *sl)
+free_service(struct ServiceList *sl)
{
- GNUNET_assert (GNUNET_YES == in_shutdown);
- GNUNET_CONTAINER_DLL_remove (running_head, running_tail, sl);
- GNUNET_assert (NULL == sl->listen_head);
- GNUNET_free_non_null (sl->config);
- GNUNET_free_non_null (sl->binary);
- GNUNET_free (sl->name);
- GNUNET_free (sl);
+ GNUNET_assert(GNUNET_YES == in_shutdown);
+ GNUNET_CONTAINER_DLL_remove(running_head, running_tail, sl);
+ GNUNET_assert(NULL == sl->listen_head);
+ GNUNET_free_non_null(sl->config);
+ GNUNET_free_non_null(sl->binary);
+ GNUNET_free(sl->name);
+ GNUNET_free(sl);
}
@@ -1142,10 +1144,10 @@ free_service (struct ServiceList *sl)
* #GNUNET_SYSERR to close it (signal serious error)
*/
static int
-check_start (void *cls, const struct GNUNET_ARM_Message *amsg)
+check_start(void *cls, const struct GNUNET_ARM_Message *amsg)
{
- (void) cls;
- GNUNET_MQ_check_zero_termination (amsg);
+ (void)cls;
+ GNUNET_MQ_check_zero_termination(amsg);
return GNUNET_OK;
}
@@ -1157,43 +1159,43 @@ check_start (void *cls, const struct GNUNET_ARM_Message *amsg)
* @param amsg the actual message
*/
static void
-handle_start (void *cls, const struct GNUNET_ARM_Message *amsg)
+handle_start(void *cls, const struct GNUNET_ARM_Message *amsg)
{
struct GNUNET_SERVICE_Client *client = cls;
const char *servicename;
struct ServiceList *sl;
uint64_t request_id;
- request_id = GNUNET_ntohll (amsg->request_id);
- servicename = (const char *) &amsg[1];
- GNUNET_SERVICE_client_continue (client);
+ request_id = GNUNET_ntohll(amsg->request_id);
+ servicename = (const char *)&amsg[1];
+ GNUNET_SERVICE_client_continue(client);
if (GNUNET_YES == in_shutdown)
- {
- signal_result (client,
- servicename,
- request_id,
- GNUNET_ARM_RESULT_IN_SHUTDOWN);
- return;
- }
- sl = find_service (servicename);
+ {
+ signal_result(client,
+ servicename,
+ request_id,
+ GNUNET_ARM_RESULT_IN_SHUTDOWN);
+ return;
+ }
+ sl = find_service(servicename);
if (NULL == sl)
- {
- signal_result (client,
- servicename,
- request_id,
- GNUNET_ARM_RESULT_IS_NOT_KNOWN);
- return;
- }
+ {
+ signal_result(client,
+ servicename,
+ request_id,
+ GNUNET_ARM_RESULT_IS_NOT_KNOWN);
+ return;
+ }
sl->force_start = GNUNET_YES;
if (NULL != sl->proc)
- {
- signal_result (client,
- servicename,
- request_id,
- GNUNET_ARM_RESULT_IS_STARTED_ALREADY);
- return;
- }
- start_process (sl, client, request_id);
+ {
+ signal_result(client,
+ servicename,
+ request_id,
+ GNUNET_ARM_RESULT_IS_STARTED_ALREADY);
+ return;
+ }
+ start_process(sl, client, request_id);
}
@@ -1203,11 +1205,11 @@ handle_start (void *cls, const struct GNUNET_ARM_Message *amsg)
* @param cls closure (refers to service)
*/
static void
-trigger_shutdown (void *cls)
+trigger_shutdown(void *cls)
{
- (void) cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Triggering shutdown\n");
- GNUNET_SCHEDULER_shutdown ();
+ (void)cls;
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Triggering shutdown\n");
+ GNUNET_SCHEDULER_shutdown();
}
@@ -1220,10 +1222,10 @@ trigger_shutdown (void *cls)
* #GNUNET_SYSERR to close it (signal serious error)
*/
static int
-check_stop (void *cls, const struct GNUNET_ARM_Message *amsg)
+check_stop(void *cls, const struct GNUNET_ARM_Message *amsg)
{
- (void) cls;
- GNUNET_MQ_check_zero_termination (amsg);
+ (void)cls;
+ GNUNET_MQ_check_zero_termination(amsg);
return GNUNET_OK;
}
@@ -1235,72 +1237,72 @@ check_stop (void *cls, const struct GNUNET_ARM_Message *amsg)
* @param amsg the actual message
*/
static void
-handle_stop (void *cls, const struct GNUNET_ARM_Message *amsg)
+handle_stop(void *cls, const struct GNUNET_ARM_Message *amsg)
{
struct GNUNET_SERVICE_Client *client = cls;
struct ServiceList *sl;
const char *servicename;
uint64_t request_id;
- request_id = GNUNET_ntohll (amsg->request_id);
- servicename = (const char *) &amsg[1];
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _ ("Preparing to stop `%s'\n"),
- servicename);
- GNUNET_SERVICE_client_continue (client);
- if (0 == strcasecmp (servicename, "arm"))
- {
- broadcast_status (servicename, GNUNET_ARM_SERVICE_STOPPING, NULL);
- signal_result (client, servicename, request_id, GNUNET_ARM_RESULT_STOPPING);
- GNUNET_SERVICE_client_persist (client);
- GNUNET_SCHEDULER_add_now (&trigger_shutdown, NULL);
- return;
- }
- sl = find_service (servicename);
+ request_id = GNUNET_ntohll(amsg->request_id);
+ servicename = (const char *)&amsg[1];
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ _("Preparing to stop `%s'\n"),
+ servicename);
+ GNUNET_SERVICE_client_continue(client);
+ if (0 == strcasecmp(servicename, "arm"))
+ {
+ broadcast_status(servicename, GNUNET_ARM_SERVICE_STOPPING, NULL);
+ signal_result(client, servicename, request_id, GNUNET_ARM_RESULT_STOPPING);
+ GNUNET_SERVICE_client_persist(client);
+ GNUNET_SCHEDULER_add_now(&trigger_shutdown, NULL);
+ return;
+ }
+ sl = find_service(servicename);
if (NULL == sl)
- {
- signal_result (client,
- servicename,
- request_id,
- GNUNET_ARM_RESULT_IS_NOT_KNOWN);
- return;
- }
+ {
+ signal_result(client,
+ servicename,
+ request_id,
+ GNUNET_ARM_RESULT_IS_NOT_KNOWN);
+ return;
+ }
sl->force_start = GNUNET_NO;
if (GNUNET_YES == in_shutdown)
- {
- /* shutdown in progress */
- signal_result (client,
- servicename,
- request_id,
- GNUNET_ARM_RESULT_IN_SHUTDOWN);
- return;
- }
+ {
+ /* shutdown in progress */
+ signal_result(client,
+ servicename,
+ request_id,
+ GNUNET_ARM_RESULT_IN_SHUTDOWN);
+ return;
+ }
if (NULL != sl->killing_client)
- {
- /* killing already in progress */
- signal_result (client,
- servicename,
- request_id,
- GNUNET_ARM_RESULT_IS_STOPPING_ALREADY);
- return;
- }
+ {
+ /* killing already in progress */
+ signal_result(client,
+ servicename,
+ request_id,
+ GNUNET_ARM_RESULT_IS_STOPPING_ALREADY);
+ return;
+ }
if (NULL == sl->proc)
- {
- /* process is down */
- signal_result (client,
- servicename,
- request_id,
- GNUNET_ARM_RESULT_IS_STOPPED_ALREADY);
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending kill signal to service `%s', waiting for process to die.\n",
- servicename);
- broadcast_status (servicename, GNUNET_ARM_SERVICE_STOPPING, NULL);
+ {
+ /* process is down */
+ signal_result(client,
+ servicename,
+ request_id,
+ GNUNET_ARM_RESULT_IS_STOPPED_ALREADY);
+ return;
+ }
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Sending kill signal to service `%s', waiting for process to die.\n",
+ servicename);
+ broadcast_status(servicename, GNUNET_ARM_SERVICE_STOPPING, NULL);
/* no signal_start - only when it's STOPPED */
- sl->killed_at = GNUNET_TIME_absolute_get ();
- if (0 != GNUNET_OS_process_kill (sl->proc, GNUNET_TERM_SIG))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
+ sl->killed_at = GNUNET_TIME_absolute_get();
+ if (0 != GNUNET_OS_process_kill(sl->proc, GNUNET_TERM_SIG))
+ GNUNET_log_strerror(GNUNET_ERROR_TYPE_WARNING, "kill");
sl->killing_client = client;
sl->killing_client_request_id = request_id;
}
@@ -1313,7 +1315,7 @@ handle_stop (void *cls, const struct GNUNET_ARM_Message *amsg)
* @param message the actual message
*/
static void
-handle_list (void *cls, const struct GNUNET_ARM_Message *request)
+handle_list(void *cls, const struct GNUNET_ARM_Message *request)
{
struct GNUNET_SERVICE_Client *client = cls;
struct GNUNET_MQ_Envelope *env;
@@ -1323,40 +1325,40 @@ handle_list (void *cls, const struct GNUNET_ARM_Message *request)
uint16_t count;
char *pos;
- GNUNET_break (0 == ntohl (request->reserved));
+ GNUNET_break(0 == ntohl(request->reserved));
count = 0;
string_list_size = 0;
/* first count the running processes get their name's size */
for (sl = running_head; NULL != sl; sl = sl->next)
- {
- if (NULL != sl->proc)
{
- string_list_size += strlen (sl->name);
- string_list_size += strlen (sl->binary);
- string_list_size += 4;
- count++;
+ if (NULL != sl->proc)
+ {
+ string_list_size += strlen(sl->name);
+ string_list_size += strlen(sl->binary);
+ string_list_size += 4;
+ count++;
+ }
}
- }
- env = GNUNET_MQ_msg_extra (msg,
- string_list_size,
- GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT);
+ env = GNUNET_MQ_msg_extra(msg,
+ string_list_size,
+ GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT);
msg->arm_msg.request_id = request->request_id;
- msg->count = htons (count);
+ msg->count = htons(count);
- pos = (char *) &msg[1];
+ pos = (char *)&msg[1];
for (sl = running_head; NULL != sl; sl = sl->next)
- {
- if (NULL != sl->proc)
{
- size_t s = strlen (sl->name) + strlen (sl->binary) + 4;
- GNUNET_snprintf (pos, s, "%s (%s)", sl->name, sl->binary);
- pos += s;
+ if (NULL != sl->proc)
+ {
+ size_t s = strlen(sl->name) + strlen(sl->binary) + 4;
+ GNUNET_snprintf(pos, s, "%s (%s)", sl->name, sl->binary);
+ pos += s;
+ }
}
- }
- GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
- GNUNET_SERVICE_client_continue (client);
+ GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client), env);
+ GNUNET_SERVICE_client_continue(client);
}
@@ -1367,16 +1369,16 @@ handle_list (void *cls, const struct GNUNET_ARM_Message *request)
* @param message the actual message
*/
static void
-handle_test (void *cls, const struct GNUNET_MessageHeader *message)
+handle_test(void *cls, const struct GNUNET_MessageHeader *message)
{
struct GNUNET_SERVICE_Client *client = cls;
struct GNUNET_MQ_Envelope *env;
struct GNUNET_MessageHeader *msg;
- (void) message;
- env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_ARM_TEST);
- GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
- GNUNET_SERVICE_client_continue (client);
+ (void)message;
+ env = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_ARM_TEST);
+ GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client), env);
+ GNUNET_SERVICE_client_continue(client);
}
@@ -1385,24 +1387,24 @@ handle_test (void *cls, const struct GNUNET_MessageHeader *message)
* tasks, signal handler and the server.
*/
static void
-do_shutdown ()
+do_shutdown()
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Last shutdown phase\n");
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Last shutdown phase\n");
if (NULL != notifier)
- {
- GNUNET_notification_context_destroy (notifier);
- notifier = NULL;
- }
+ {
+ GNUNET_notification_context_destroy(notifier);
+ notifier = NULL;
+ }
if (NULL != service)
- {
- GNUNET_SERVICE_shutdown (service);
- service = NULL;
- }
+ {
+ GNUNET_SERVICE_shutdown(service);
+ service = NULL;
+ }
if (NULL != child_death_task)
- {
- GNUNET_SCHEDULER_cancel (child_death_task);
- child_death_task = NULL;
- }
+ {
+ GNUNET_SCHEDULER_cancel(child_death_task);
+ child_death_task = NULL;
+ }
}
@@ -1413,13 +1415,13 @@ do_shutdown ()
* @return number of active services found
*/
static unsigned int
-list_count (struct ServiceList *running_head)
+list_count(struct ServiceList *running_head)
{
struct ServiceList *i;
unsigned int res;
for (res = 0, i = running_head; NULL != i; i = i->next, res++)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s\n", i->name);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s\n", i->name);
return res;
}
@@ -1430,61 +1432,61 @@ list_count (struct ServiceList *running_head)
* @param cls closure, NULL if we need to self-restart
*/
static void
-shutdown_task (void *cls)
+shutdown_task(void *cls)
{
struct ServiceList *pos;
struct ServiceList *nxt;
struct ServiceListeningInfo *sli;
- (void) cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "First shutdown phase\n");
+ (void)cls;
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "First shutdown phase\n");
if (NULL != child_restart_task)
- {
- GNUNET_SCHEDULER_cancel (child_restart_task);
- child_restart_task = NULL;
- }
+ {
+ GNUNET_SCHEDULER_cancel(child_restart_task);
+ child_restart_task = NULL;
+ }
in_shutdown = GNUNET_YES;
/* first, stop listening */
for (pos = running_head; NULL != pos; pos = pos->next)
- {
- while (NULL != (sli = pos->listen_head))
{
- GNUNET_CONTAINER_DLL_remove (pos->listen_head, pos->listen_tail, sli);
- if (NULL != sli->accept_task)
- {
- GNUNET_SCHEDULER_cancel (sli->accept_task);
- sli->accept_task = NULL;
- }
- GNUNET_break (GNUNET_OK ==
- GNUNET_NETWORK_socket_close (sli->listen_socket));
- GNUNET_free (sli->service_addr);
- GNUNET_free (sli);
+ while (NULL != (sli = pos->listen_head))
+ {
+ GNUNET_CONTAINER_DLL_remove(pos->listen_head, pos->listen_tail, sli);
+ if (NULL != sli->accept_task)
+ {
+ GNUNET_SCHEDULER_cancel(sli->accept_task);
+ sli->accept_task = NULL;
+ }
+ GNUNET_break(GNUNET_OK ==
+ GNUNET_NETWORK_socket_close(sli->listen_socket));
+ GNUNET_free(sli->service_addr);
+ GNUNET_free(sli);
+ }
}
- }
/* then, shutdown all existing service processes */
nxt = running_head;
while (NULL != (pos = nxt))
- {
- nxt = pos->next;
- if (NULL != pos->proc)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stopping service `%s'\n", pos->name);
- pos->killed_at = GNUNET_TIME_absolute_get ();
- if (0 != GNUNET_OS_process_kill (pos->proc, GNUNET_TERM_SIG))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- }
- else
{
- free_service (pos);
+ nxt = pos->next;
+ if (NULL != pos->proc)
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Stopping service `%s'\n", pos->name);
+ pos->killed_at = GNUNET_TIME_absolute_get();
+ if (0 != GNUNET_OS_process_kill(pos->proc, GNUNET_TERM_SIG))
+ GNUNET_log_strerror(GNUNET_ERROR_TYPE_WARNING, "kill");
+ }
+ else
+ {
+ free_service(pos);
+ }
}
- }
/* finally, should all service processes be already gone, terminate for real */
if (NULL == running_head)
- do_shutdown ();
+ do_shutdown();
else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Delaying shutdown, have %u childs still running\n",
- list_count (running_head));
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Delaying shutdown, have %u childs still running\n",
+ list_count(running_head));
}
@@ -1494,73 +1496,73 @@ shutdown_task (void *cls)
* @param cls closure, always NULL
*/
static void
-delayed_restart_task (void *cls)
+delayed_restart_task(void *cls)
{
struct ServiceList *sl;
struct GNUNET_TIME_Relative lowestRestartDelay;
struct ServiceListeningInfo *sli;
- (void) cls;
+ (void)cls;
child_restart_task = NULL;
- GNUNET_assert (GNUNET_NO == in_shutdown);
+ GNUNET_assert(GNUNET_NO == in_shutdown);
lowestRestartDelay = GNUNET_TIME_UNIT_FOREVER_REL;
/* check for services that need to be restarted due to
* configuration changes or because the last restart failed */
for (sl = running_head; NULL != sl; sl = sl->next)
- {
- if (NULL != sl->proc)
- continue;
- /* service is currently not running */
- if (0 == GNUNET_TIME_absolute_get_remaining (sl->restart_at).rel_value_us)
{
- /* restart is now allowed */
- if (sl->force_start)
- {
- /* process should run by default, start immediately */
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _ ("Restarting service `%s'.\n"),
- sl->name);
- start_process (sl, NULL, 0);
- }
+ if (NULL != sl->proc)
+ continue;
+ /* service is currently not running */
+ if (0 == GNUNET_TIME_absolute_get_remaining(sl->restart_at).rel_value_us)
+ {
+ /* restart is now allowed */
+ if (sl->force_start)
+ {
+ /* process should run by default, start immediately */
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ _("Restarting service `%s'.\n"),
+ sl->name);
+ start_process(sl, NULL, 0);
+ }
+ else
+ {
+ /* process is run on-demand, ensure it is re-started if there is demand */
+ for (sli = sl->listen_head; NULL != sli; sli = sli->next)
+ if (NULL == sli->accept_task)
+ {
+ /* accept was actually paused, so start it again */
+ sli->accept_task =
+ GNUNET_SCHEDULER_add_read_net(GNUNET_TIME_UNIT_FOREVER_REL,
+ sli->listen_socket,
+ &accept_connection,
+ sli);
+ }
+ }
+ }
else
- {
- /* process is run on-demand, ensure it is re-started if there is demand */
- for (sli = sl->listen_head; NULL != sli; sli = sli->next)
- if (NULL == sli->accept_task)
- {
- /* accept was actually paused, so start it again */
- sli->accept_task =
- GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
- sli->listen_socket,
- &accept_connection,
- sli);
- }
- }
- }
- else
- {
- /* update calculation for earliest time to reactivate a service */
- lowestRestartDelay =
- GNUNET_TIME_relative_min (lowestRestartDelay,
- GNUNET_TIME_absolute_get_remaining (
- sl->restart_at));
+ {
+ /* update calculation for earliest time to reactivate a service */
+ lowestRestartDelay =
+ GNUNET_TIME_relative_min(lowestRestartDelay,
+ GNUNET_TIME_absolute_get_remaining(
+ sl->restart_at));
+ }
}
- }
if (lowestRestartDelay.rel_value_us !=
GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Will restart process in %s\n",
- GNUNET_STRINGS_relative_time_to_string (lowestRestartDelay,
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Will restart process in %s\n",
+ GNUNET_STRINGS_relative_time_to_string(lowestRestartDelay,
GNUNET_YES));
- child_restart_task =
- GNUNET_SCHEDULER_add_delayed_with_priority (lowestRestartDelay,
- GNUNET_SCHEDULER_PRIORITY_IDLE,
- &delayed_restart_task,
- NULL);
- }
+ child_restart_task =
+ GNUNET_SCHEDULER_add_delayed_with_priority(lowestRestartDelay,
+ GNUNET_SCHEDULER_PRIORITY_IDLE,
+ &delayed_restart_task,
+ NULL);
+ }
}
@@ -1571,7 +1573,7 @@ delayed_restart_task (void *cls)
* @param cls closure, NULL
*/
static void
-maint_child_death (void *cls)
+maint_child_death(void *cls)
{
struct ServiceList *pos;
struct ServiceList *next;
@@ -1584,199 +1586,199 @@ maint_child_death (void *cls)
unsigned long statusCode;
const struct GNUNET_DISK_FileHandle *pr;
- (void) cls;
- pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ);
+ (void)cls;
+ pr = GNUNET_DISK_pipe_handle(sigpipe, GNUNET_DISK_PIPE_END_READ);
child_death_task = NULL;
/* consume the signal */
- GNUNET_break (0 < GNUNET_DISK_file_read (pr, &c, sizeof (c)));
+ GNUNET_break(0 < GNUNET_DISK_file_read(pr, &c, sizeof(c)));
/* check for services that died (WAITPID) */
next = running_head;
while (NULL != (pos = next))
- {
- next = pos->next;
-
- if (NULL == pos->proc)
{
- if (GNUNET_YES == in_shutdown)
- free_service (pos);
- continue;
- }
+ next = pos->next;
+
+ if (NULL == pos->proc)
+ {
+ if (GNUNET_YES == in_shutdown)
+ free_service(pos);
+ continue;
+ }
#if HAVE_WAIT4
- if (NULL != wait_file)
- {
- /* need to use 'wait4()' to obtain and log performance data */
- struct rusage ru;
- int status;
- pid_t pid;
-
- pid = GNUNET_OS_process_get_pid (pos->proc);
- ret = wait4 (pid, &status, WNOHANG, &ru);
- if (ret <= 0)
- continue; /* no process done */
- if (WIFEXITED (status))
- {
- statusType = GNUNET_OS_PROCESS_EXITED;
- statusCode = WEXITSTATUS (status);
- }
- else if (WIFSIGNALED (status))
- {
- statusType = GNUNET_OS_PROCESS_SIGNALED;
- statusCode = WTERMSIG (status);
- }
- else if (WIFSTOPPED (status))
- {
- statusType = GNUNET_OS_PROCESS_SIGNALED;
- statusCode = WSTOPSIG (status);
- }
+ if (NULL != wait_file)
+ {
+ /* need to use 'wait4()' to obtain and log performance data */
+ struct rusage ru;
+ int status;
+ pid_t pid;
+
+ pid = GNUNET_OS_process_get_pid(pos->proc);
+ ret = wait4(pid, &status, WNOHANG, &ru);
+ if (ret <= 0)
+ continue; /* no process done */
+ if (WIFEXITED(status))
+ {
+ statusType = GNUNET_OS_PROCESS_EXITED;
+ statusCode = WEXITSTATUS(status);
+ }
+ else if (WIFSIGNALED(status))
+ {
+ statusType = GNUNET_OS_PROCESS_SIGNALED;
+ statusCode = WTERMSIG(status);
+ }
+ else if (WIFSTOPPED(status))
+ {
+ statusType = GNUNET_OS_PROCESS_SIGNALED;
+ statusCode = WSTOPSIG(status);
+ }
#ifdef WIFCONTINUED
- else if (WIFCONTINUED (status))
- {
- statusType = GNUNET_OS_PROCESS_RUNNING;
- statusCode = 0;
- }
+ else if (WIFCONTINUED(status))
+ {
+ statusType = GNUNET_OS_PROCESS_RUNNING;
+ statusCode = 0;
+ }
#endif
- else
- {
- statusType = GNUNET_OS_PROCESS_UNKNOWN;
- statusCode = 0;
- }
- if ((GNUNET_OS_PROCESS_EXITED == statusType) ||
- (GNUNET_OS_PROCESS_SIGNALED == statusType))
- {
- double utime = ru.ru_utime.tv_sec + (ru.ru_utime.tv_usec / 10e6);
- double stime = ru.ru_stime.tv_sec + (ru.ru_stime.tv_usec / 10e6);
- fprintf (wait_file,
- "%s(%u) %.3f %.3f %llu %llu %llu %llu %llu\n",
- pos->binary,
- (unsigned int) pid,
- utime,
- stime,
- (unsigned long long) ru.ru_maxrss,
- (unsigned long long) ru.ru_inblock,
- (unsigned long long) ru.ru_oublock,
- (unsigned long long) ru.ru_nvcsw,
- (unsigned long long) ru.ru_nivcsw);
- }
- }
- else /* continue with JUST this "if" as "else" (intentionally no brackets!) */
+ else
+ {
+ statusType = GNUNET_OS_PROCESS_UNKNOWN;
+ statusCode = 0;
+ }
+ if ((GNUNET_OS_PROCESS_EXITED == statusType) ||
+ (GNUNET_OS_PROCESS_SIGNALED == statusType))
+ {
+ double utime = ru.ru_utime.tv_sec + (ru.ru_utime.tv_usec / 10e6);
+ double stime = ru.ru_stime.tv_sec + (ru.ru_stime.tv_usec / 10e6);
+ fprintf(wait_file,
+ "%s(%u) %.3f %.3f %llu %llu %llu %llu %llu\n",
+ pos->binary,
+ (unsigned int)pid,
+ utime,
+ stime,
+ (unsigned long long)ru.ru_maxrss,
+ (unsigned long long)ru.ru_inblock,
+ (unsigned long long)ru.ru_oublock,
+ (unsigned long long)ru.ru_nvcsw,
+ (unsigned long long)ru.ru_nivcsw);
+ }
+ }
+ else /* continue with JUST this "if" as "else" (intentionally no brackets!) */
#endif
- if ((GNUNET_SYSERR == (ret = GNUNET_OS_process_status (pos->proc,
- &statusType,
- &statusCode))) ||
+ if ((GNUNET_SYSERR == (ret = GNUNET_OS_process_status(pos->proc,
+ &statusType,
+ &statusCode))) ||
(ret == GNUNET_NO) || (statusType == GNUNET_OS_PROCESS_STOPPED) ||
(statusType == GNUNET_OS_PROCESS_UNKNOWN) ||
(statusType == GNUNET_OS_PROCESS_RUNNING))
- continue;
+ continue;
- if (statusType == GNUNET_OS_PROCESS_EXITED)
- {
- statstr = _ (/* process termination method */ "exit");
- statcode = statusCode;
- }
- else if (statusType == GNUNET_OS_PROCESS_SIGNALED)
- {
- statstr = _ (/* process termination method */ "signal");
- statcode = statusCode;
- }
- else
- {
- statstr = _ (/* process termination method */ "unknown");
- statcode = 0;
- }
- if (0 != pos->killed_at.abs_value_us)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _ ("Service `%s' took %s to terminate\n"),
- pos->name,
- GNUNET_STRINGS_relative_time_to_string (
- GNUNET_TIME_absolute_get_duration (pos->killed_at),
- GNUNET_YES));
- }
- GNUNET_OS_process_destroy (pos->proc);
- pos->proc = NULL;
- broadcast_status (pos->name, GNUNET_ARM_SERVICE_STOPPED, NULL);
- if (NULL != pos->killing_client)
- {
- signal_result (pos->killing_client,
- pos->name,
- pos->killing_client_request_id,
- GNUNET_ARM_RESULT_STOPPED);
- pos->killing_client = NULL;
- pos->killing_client_request_id = 0;
- }
- if (GNUNET_YES != in_shutdown)
- {
- if ((statusType == GNUNET_OS_PROCESS_EXITED) && (statcode == 0))
- {
- /* process terminated normally, allow restart at any time */
- pos->restart_at.abs_value_us = 0;
- GNUNET_log (
- GNUNET_ERROR_TYPE_INFO,
- _ ("Service `%s' terminated normally, will restart at any time\n"),
- pos->name);
- /* process can still be re-started on-demand, ensure it is re-started if there is demand */
- for (sli = pos->listen_head; NULL != sli; sli = sli->next)
+ if (statusType == GNUNET_OS_PROCESS_EXITED)
{
- GNUNET_break (NULL == sli->accept_task);
- sli->accept_task =
- GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
- sli->listen_socket,
- &accept_connection,
- sli);
+ statstr = _(/* process termination method */ "exit");
+ statcode = statusCode;
+ }
+ else if (statusType == GNUNET_OS_PROCESS_SIGNALED)
+ {
+ statstr = _(/* process termination method */ "signal");
+ statcode = statusCode;
}
- }
else
- {
- GNUNET_log (
- GNUNET_ERROR_TYPE_INFO,
- _ ("Service `%s' terminated with status %s/%d, will restart in %s\n"),
- pos->name,
- statstr,
- statcode,
- GNUNET_STRINGS_relative_time_to_string (pos->backoff, GNUNET_YES));
{
- /* Reduce backoff based on runtime of the process,
- so that there is a cool-down if a process actually
- runs for a while. */
- struct GNUNET_TIME_Relative runtime;
- unsigned int minutes;
-
- runtime = GNUNET_TIME_absolute_get_duration (pos->restart_at);
- minutes =
- runtime.rel_value_us / GNUNET_TIME_UNIT_MINUTES.rel_value_us;
- if (minutes > 31)
- pos->backoff = GNUNET_TIME_UNIT_ZERO;
+ statstr = _(/* process termination method */ "unknown");
+ statcode = 0;
+ }
+ if (0 != pos->killed_at.abs_value_us)
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ _("Service `%s' took %s to terminate\n"),
+ pos->name,
+ GNUNET_STRINGS_relative_time_to_string(
+ GNUNET_TIME_absolute_get_duration(pos->killed_at),
+ GNUNET_YES));
+ }
+ GNUNET_OS_process_destroy(pos->proc);
+ pos->proc = NULL;
+ broadcast_status(pos->name, GNUNET_ARM_SERVICE_STOPPED, NULL);
+ if (NULL != pos->killing_client)
+ {
+ signal_result(pos->killing_client,
+ pos->name,
+ pos->killing_client_request_id,
+ GNUNET_ARM_RESULT_STOPPED);
+ pos->killing_client = NULL;
+ pos->killing_client_request_id = 0;
+ }
+ if (GNUNET_YES != in_shutdown)
+ {
+ if ((statusType == GNUNET_OS_PROCESS_EXITED) && (statcode == 0))
+ {
+ /* process terminated normally, allow restart at any time */
+ pos->restart_at.abs_value_us = 0;
+ GNUNET_log(
+ GNUNET_ERROR_TYPE_INFO,
+ _("Service `%s' terminated normally, will restart at any time\n"),
+ pos->name);
+ /* process can still be re-started on-demand, ensure it is re-started if there is demand */
+ for (sli = pos->listen_head; NULL != sli; sli = sli->next)
+ {
+ GNUNET_break(NULL == sli->accept_task);
+ sli->accept_task =
+ GNUNET_SCHEDULER_add_read_net(GNUNET_TIME_UNIT_FOREVER_REL,
+ sli->listen_socket,
+ &accept_connection,
+ sli);
+ }
+ }
else
- pos->backoff.rel_value_us <<= minutes;
+ {
+ GNUNET_log(
+ GNUNET_ERROR_TYPE_INFO,
+ _("Service `%s' terminated with status %s/%d, will restart in %s\n"),
+ pos->name,
+ statstr,
+ statcode,
+ GNUNET_STRINGS_relative_time_to_string(pos->backoff, GNUNET_YES));
+ {
+ /* Reduce backoff based on runtime of the process,
+ so that there is a cool-down if a process actually
+ runs for a while. */
+ struct GNUNET_TIME_Relative runtime;
+ unsigned int minutes;
+
+ runtime = GNUNET_TIME_absolute_get_duration(pos->restart_at);
+ minutes =
+ runtime.rel_value_us / GNUNET_TIME_UNIT_MINUTES.rel_value_us;
+ if (minutes > 31)
+ pos->backoff = GNUNET_TIME_UNIT_ZERO;
+ else
+ pos->backoff.rel_value_us <<= minutes;
+ }
+ /* schedule restart */
+ pos->restart_at = GNUNET_TIME_relative_to_absolute(pos->backoff);
+ pos->backoff = GNUNET_TIME_STD_BACKOFF(pos->backoff);
+ if (NULL != child_restart_task)
+ GNUNET_SCHEDULER_cancel(child_restart_task);
+ child_restart_task =
+ GNUNET_SCHEDULER_add_with_priority(GNUNET_SCHEDULER_PRIORITY_IDLE,
+ &delayed_restart_task,
+ NULL);
+ }
+ }
+ else
+ {
+ free_service(pos);
}
- /* schedule restart */
- pos->restart_at = GNUNET_TIME_relative_to_absolute (pos->backoff);
- pos->backoff = GNUNET_TIME_STD_BACKOFF (pos->backoff);
- if (NULL != child_restart_task)
- GNUNET_SCHEDULER_cancel (child_restart_task);
- child_restart_task =
- GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
- &delayed_restart_task,
- NULL);
- }
- }
- else
- {
- free_service (pos);
}
- }
child_death_task =
- GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
- pr,
- &maint_child_death,
- NULL);
+ GNUNET_SCHEDULER_add_read_file(GNUNET_TIME_UNIT_FOREVER_REL,
+ pr,
+ &maint_child_death,
+ NULL);
if ((NULL == running_head) && (GNUNET_YES == in_shutdown))
- do_shutdown ();
+ do_shutdown();
else if (GNUNET_YES == in_shutdown)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Delaying shutdown after child's death, still have %u children\n",
- list_count (running_head));
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Delaying shutdown after child's death, still have %u children\n",
+ list_count(running_head));
}
@@ -1785,17 +1787,17 @@ maint_child_death (void *cls)
* respective handler by writing to the trigger pipe.
*/
static void
-sighandler_child_death ()
+sighandler_child_death()
{
static char c;
int old_errno = errno; /* back-up errno */
- GNUNET_break (
+ GNUNET_break(
1 ==
- GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle (sigpipe,
- GNUNET_DISK_PIPE_END_WRITE),
- &c,
- sizeof (c)));
+ GNUNET_DISK_file_write(GNUNET_DISK_pipe_handle(sigpipe,
+ GNUNET_DISK_PIPE_END_WRITE),
+ &c,
+ sizeof(c)));
errno = old_errno; /* restore errno */
}
@@ -1809,7 +1811,7 @@ sighandler_child_death ()
* @return #GNUNET_OK (continue)
*/
static void
-setup_service (void *cls, const char *section)
+setup_service(void *cls, const char *section)
{
struct ServiceList *sl;
char *binary;
@@ -1819,65 +1821,65 @@ setup_service (void *cls, const char *section)
socklen_t *addr_lens;
int ret;
- (void) cls;
- if (0 == strcasecmp (section, "arm"))
+ (void)cls;
+ if (0 == strcasecmp(section, "arm"))
return;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg, section, "BINARY", &binary))
- {
- /* not a service section */
- return;
- }
+ GNUNET_CONFIGURATION_get_value_string(cfg, section, "BINARY", &binary))
+ {
+ /* not a service section */
+ return;
+ }
if ((GNUNET_YES ==
- GNUNET_CONFIGURATION_have_value (cfg, section, "RUN_PER_USER")) &&
+ GNUNET_CONFIGURATION_have_value(cfg, section, "RUN_PER_USER")) &&
(GNUNET_YES ==
- GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "RUN_PER_USER")))
- {
- if (GNUNET_NO == start_user)
+ GNUNET_CONFIGURATION_get_value_yesno(cfg, section, "RUN_PER_USER")))
{
- GNUNET_free (binary);
- return; /* user service, and we don't deal with those */
+ if (GNUNET_NO == start_user)
+ {
+ GNUNET_free(binary);
+ return; /* user service, and we don't deal with those */
+ }
}
- }
else
- {
- if (GNUNET_NO == start_system)
{
- GNUNET_free (binary);
- return; /* system service, and we don't deal with those */
+ if (GNUNET_NO == start_system)
+ {
+ GNUNET_free(binary);
+ return; /* system service, and we don't deal with those */
+ }
}
- }
- sl = find_service (section);
+ sl = find_service(section);
if (NULL != sl)
- {
- /* got the same section twice!? */
- GNUNET_break (0);
- GNUNET_free (binary);
- return;
- }
+ {
+ /* got the same section twice!? */
+ GNUNET_break(0);
+ GNUNET_free(binary);
+ return;
+ }
config = NULL;
- if (((GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
- section,
- "CONFIG",
- &config)) &&
- (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
- "PATHS",
- "DEFAULTCONFIG",
- &config))) ||
- (0 != stat (config, &sbuf)))
- {
- if (NULL != config)
+ if (((GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename(cfg,
+ section,
+ "CONFIG",
+ &config)) &&
+ (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename(cfg,
+ "PATHS",
+ "DEFAULTCONFIG",
+ &config))) ||
+ (0 != stat(config, &sbuf)))
{
- GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING,
- section,
- "CONFIG",
- strerror (errno));
- GNUNET_free (config);
- config = NULL;
+ if (NULL != config)
+ {
+ GNUNET_log_config_invalid(GNUNET_ERROR_TYPE_WARNING,
+ section,
+ "CONFIG",
+ strerror(errno));
+ GNUNET_free(config);
+ config = NULL;
+ }
}
- }
- sl = GNUNET_new (struct ServiceList);
- sl->name = GNUNET_strdup (section);
+ sl = GNUNET_new(struct ServiceList);
+ sl->name = GNUNET_strdup(section);
sl->binary = binary;
sl->config = config;
sl->backoff = GNUNET_TIME_UNIT_MILLISECONDS;
@@ -1885,32 +1887,32 @@ setup_service (void *cls, const char *section)
#if WINDOWS
sl->pipe_control = GNUNET_YES;
#else
- if (GNUNET_CONFIGURATION_have_value (cfg, section, "PIPECONTROL"))
+ if (GNUNET_CONFIGURATION_have_value(cfg, section, "PIPECONTROL"))
sl->pipe_control =
- GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "PIPECONTROL");
+ GNUNET_CONFIGURATION_get_value_yesno(cfg, section, "PIPECONTROL");
#endif
- GNUNET_CONTAINER_DLL_insert (running_head, running_tail, sl);
+ GNUNET_CONTAINER_DLL_insert(running_head, running_tail, sl);
if (GNUNET_YES ==
- GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "IMMEDIATE_START"))
- {
- sl->force_start = GNUNET_YES;
- if (GNUNET_YES ==
- GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "NOARMBIND"))
- return;
- }
+ GNUNET_CONFIGURATION_get_value_yesno(cfg, section, "IMMEDIATE_START"))
+ {
+ sl->force_start = GNUNET_YES;
+ if (GNUNET_YES ==
+ GNUNET_CONFIGURATION_get_value_yesno(cfg, section, "NOARMBIND"))
+ return;
+ }
else
- {
- if (GNUNET_YES !=
- GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "START_ON_DEMAND"))
- return;
- }
- if (0 >= (ret = get_server_addresses (section, cfg, &addrs, &addr_lens)))
+ {
+ if (GNUNET_YES !=
+ GNUNET_CONFIGURATION_get_value_yesno(cfg, section, "START_ON_DEMAND"))
+ return;
+ }
+ if (0 >= (ret = get_server_addresses(section, cfg, &addrs, &addr_lens)))
return;
/* this will free (or capture) addrs[i] */
- for (unsigned int i = 0; i < (unsigned int) ret; i++)
- create_listen_socket (addrs[i], addr_lens[i], sl);
- GNUNET_free (addrs);
- GNUNET_free (addr_lens);
+ for (unsigned int i = 0; i < (unsigned int)ret; i++)
+ create_listen_socket(addrs[i], addr_lens[i], sl);
+ GNUNET_free(addrs);
+ GNUNET_free(addr_lens);
}
@@ -1923,16 +1925,16 @@ setup_service (void *cls, const char *section)
* @return @a client
*/
static void *
-client_connect_cb (void *cls,
- struct GNUNET_SERVICE_Client *client,
- struct GNUNET_MQ_Handle *mq)
+client_connect_cb(void *cls,
+ struct GNUNET_SERVICE_Client *client,
+ struct GNUNET_MQ_Handle *mq)
{
/* All clients are considered to be of the "monitor" kind
* (that is, they don't affect ARM shutdown).
*/
- (void) cls;
- (void) mq;
- GNUNET_SERVICE_client_mark_monitor (client);
+ (void)cls;
+ (void)mq;
+ GNUNET_SERVICE_client_mark_monitor(client);
return client;
}
@@ -1945,12 +1947,12 @@ client_connect_cb (void *cls,
* @param app_ctx must match @a client
*/
static void
-client_disconnect_cb (void *cls,
- struct GNUNET_SERVICE_Client *client,
- void *app_ctx)
+client_disconnect_cb(void *cls,
+ struct GNUNET_SERVICE_Client *client,
+ void *app_ctx)
{
- (void) cls;
- GNUNET_assert (client == app_ctx);
+ (void)cls;
+ GNUNET_assert(client == app_ctx);
for (struct ServiceList *sl = running_head; NULL != sl; sl = sl->next)
if (sl->killing_client == client)
sl->killing_client = NULL;
@@ -1966,18 +1968,18 @@ client_disconnect_cb (void *cls,
* #GNUNET_SYSERR to close it (signal serious error)
*/
static void
-handle_monitor (void *cls, const struct GNUNET_MessageHeader *message)
+handle_monitor(void *cls, const struct GNUNET_MessageHeader *message)
{
struct GNUNET_SERVICE_Client *client = cls;
- (void) message;
+ (void)message;
/* FIXME: might want to start by letting monitor know about
services that are already running */
/* Removal is handled by the server implementation, internally. */
- GNUNET_notification_context_add (notifier,
- GNUNET_SERVICE_client_get_mq (client));
- broadcast_status ("arm", GNUNET_ARM_SERVICE_MONITORING_STARTED, client);
- GNUNET_SERVICE_client_continue (client);
+ GNUNET_notification_context_add(notifier,
+ GNUNET_SERVICE_client_get_mq(client));
+ broadcast_status("arm", GNUNET_ARM_SERVICE_MONITORING_STARTED, client);
+ GNUNET_SERVICE_client_continue(client);
}
@@ -1989,71 +1991,71 @@ handle_monitor (void *cls, const struct GNUNET_MessageHeader *message)
* @param c configuration to use
*/
static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *c,
- struct GNUNET_SERVICE_Handle *serv)
+run(void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *c,
+ struct GNUNET_SERVICE_Handle *serv)
{
struct ServiceList *sl;
- (void) cls;
+ (void)cls;
cfg = c;
service = serv;
- GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
- child_death_task = GNUNET_SCHEDULER_add_read_file (
+ GNUNET_SCHEDULER_add_shutdown(&shutdown_task, NULL);
+ child_death_task = GNUNET_SCHEDULER_add_read_file(
GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ),
+ GNUNET_DISK_pipe_handle(sigpipe, GNUNET_DISK_PIPE_END_READ),
&maint_child_death,
NULL);
#if HAVE_WAIT4
if (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_filename (cfg,
- "ARM",
- "RESOURCE_DIAGNOSTICS",
- &wait_filename))
- {
- wait_file = fopen (wait_filename, "w");
- if (NULL == wait_file)
+ GNUNET_CONFIGURATION_get_value_filename(cfg,
+ "ARM",
+ "RESOURCE_DIAGNOSTICS",
+ &wait_filename))
{
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "fopen",
- wait_filename);
+ wait_file = fopen(wait_filename, "w");
+ if (NULL == wait_file)
+ {
+ GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR,
+ "fopen",
+ wait_filename);
+ }
}
- }
#endif
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
- "ARM",
- "GLOBAL_PREFIX",
- &prefix_command))
- prefix_command = GNUNET_strdup ("");
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg,
+ "ARM",
+ "GLOBAL_PREFIX",
+ &prefix_command))
+ prefix_command = GNUNET_strdup("");
else
- prefix_command = GNUNET_CONFIGURATION_expand_dollar (cfg, prefix_command);
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
- "ARM",
- "GLOBAL_POSTFIX",
- &final_option))
- final_option = GNUNET_strdup ("");
+ prefix_command = GNUNET_CONFIGURATION_expand_dollar(cfg, prefix_command);
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg,
+ "ARM",
+ "GLOBAL_POSTFIX",
+ &final_option))
+ final_option = GNUNET_strdup("");
else
- final_option = GNUNET_CONFIGURATION_expand_dollar (cfg, final_option);
+ final_option = GNUNET_CONFIGURATION_expand_dollar(cfg, final_option);
start_user =
- GNUNET_CONFIGURATION_get_value_yesno (cfg, "ARM", "START_USER_SERVICES");
+ GNUNET_CONFIGURATION_get_value_yesno(cfg, "ARM", "START_USER_SERVICES");
start_system =
- GNUNET_CONFIGURATION_get_value_yesno (cfg, "ARM", "START_SYSTEM_SERVICES");
+ GNUNET_CONFIGURATION_get_value_yesno(cfg, "ARM", "START_SYSTEM_SERVICES");
if ((GNUNET_NO == start_user) && (GNUNET_NO == start_system))
- {
- GNUNET_log (
- GNUNET_ERROR_TYPE_ERROR,
- "Please configure either START_USER_SERVICES or START_SYSTEM_SERVICES or both.\n");
- GNUNET_SCHEDULER_shutdown ();
- global_ret = 1;
- return;
- }
- GNUNET_CONFIGURATION_iterate_sections (cfg, &setup_service, NULL);
+ {
+ GNUNET_log(
+ GNUNET_ERROR_TYPE_ERROR,
+ "Please configure either START_USER_SERVICES or START_SYSTEM_SERVICES or both.\n");
+ GNUNET_SCHEDULER_shutdown();
+ global_ret = 1;
+ return;
+ }
+ GNUNET_CONFIGURATION_iterate_sections(cfg, &setup_service, NULL);
/* start default services... */
for (sl = running_head; NULL != sl; sl = sl->next)
if (GNUNET_YES == sl->force_start)
- start_process (sl, NULL, 0);
- notifier = GNUNET_notification_context_create (MAX_NOTIFY_QUEUE);
+ start_process(sl, NULL, 0);
+ notifier = GNUNET_notification_context_create(MAX_NOTIFY_QUEUE);
}
@@ -2065,61 +2067,61 @@ run (void *cls,
* @return 0 ok, 1 on error
*/
int
-main (int argc, char *const *argv)
+main(int argc, char *const *argv)
{
struct GNUNET_SIGNAL_Context *shc_chld;
struct GNUNET_MQ_MessageHandler handlers[] =
- {GNUNET_MQ_hd_var_size (start,
- GNUNET_MESSAGE_TYPE_ARM_START,
- struct GNUNET_ARM_Message,
+ { GNUNET_MQ_hd_var_size(start,
+ GNUNET_MESSAGE_TYPE_ARM_START,
+ struct GNUNET_ARM_Message,
+ NULL),
+ GNUNET_MQ_hd_var_size(stop,
+ GNUNET_MESSAGE_TYPE_ARM_STOP,
+ struct GNUNET_ARM_Message,
+ NULL),
+ GNUNET_MQ_hd_fixed_size(monitor,
+ GNUNET_MESSAGE_TYPE_ARM_MONITOR,
+ struct GNUNET_MessageHeader,
NULL),
- GNUNET_MQ_hd_var_size (stop,
- GNUNET_MESSAGE_TYPE_ARM_STOP,
+ GNUNET_MQ_hd_fixed_size(list,
+ GNUNET_MESSAGE_TYPE_ARM_LIST,
struct GNUNET_ARM_Message,
NULL),
- GNUNET_MQ_hd_fixed_size (monitor,
- GNUNET_MESSAGE_TYPE_ARM_MONITOR,
- struct GNUNET_MessageHeader,
- NULL),
- GNUNET_MQ_hd_fixed_size (list,
- GNUNET_MESSAGE_TYPE_ARM_LIST,
- struct GNUNET_ARM_Message,
- NULL),
- GNUNET_MQ_hd_fixed_size (test,
- GNUNET_MESSAGE_TYPE_ARM_TEST,
- struct GNUNET_MessageHeader,
- NULL),
- GNUNET_MQ_handler_end ()};
-
- sigpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO, GNUNET_NO);
- GNUNET_assert (NULL != sigpipe);
+ GNUNET_MQ_hd_fixed_size(test,
+ GNUNET_MESSAGE_TYPE_ARM_TEST,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_handler_end() };
+
+ sigpipe = GNUNET_DISK_pipe(GNUNET_NO, GNUNET_NO, GNUNET_NO, GNUNET_NO);
+ GNUNET_assert(NULL != sigpipe);
shc_chld =
- GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death);
- if (0 != GNUNET_SERVICE_run_ (argc,
- argv,
- "arm",
- GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN,
- &run,
- &client_connect_cb,
- &client_disconnect_cb,
- NULL,
- handlers))
+ GNUNET_SIGNAL_handler_install(GNUNET_SIGCHLD, &sighandler_child_death);
+ if (0 != GNUNET_SERVICE_run_(argc,
+ argv,
+ "arm",
+ GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN,
+ &run,
+ &client_connect_cb,
+ &client_disconnect_cb,
+ NULL,
+ handlers))
global_ret = 2;
#if HAVE_WAIT4
if (NULL != wait_file)
- {
- fclose (wait_file);
- wait_file = NULL;
- }
+ {
+ fclose(wait_file);
+ wait_file = NULL;
+ }
if (NULL != wait_filename)
- {
- GNUNET_free (wait_filename);
- wait_filename = NULL;
- }
+ {
+ GNUNET_free(wait_filename);
+ wait_filename = NULL;
+ }
#endif
- GNUNET_SIGNAL_handler_uninstall (shc_chld);
+ GNUNET_SIGNAL_handler_uninstall(shc_chld);
shc_chld = NULL;
- GNUNET_DISK_pipe_close (sigpipe);
+ GNUNET_DISK_pipe_close(sigpipe);
sigpipe = NULL;
return global_ret;
}
@@ -2131,11 +2133,11 @@ main (int argc, char *const *argv)
/**
* MINIMIZE heap size (way below 128k) since this process doesn't need much.
*/
-void __attribute__ ((constructor)) GNUNET_ARM_memory_init ()
+void __attribute__ ((constructor)) GNUNET_ARM_memory_init()
{
- mallopt (M_TRIM_THRESHOLD, 4 * 1024);
- mallopt (M_TOP_PAD, 1 * 1024);
- malloc_trim (0);
+ mallopt(M_TRIM_THRESHOLD, 4 * 1024);
+ mallopt(M_TOP_PAD, 1 * 1024);
+ malloc_trim(0);
}
#endif
diff --git a/src/arm/mockup-service.c b/src/arm/mockup-service.c
index 667556314..6134f17b3 100644
--- a/src/arm/mockup-service.c
+++ b/src/arm/mockup-service.c
@@ -11,12 +11,12 @@
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
-*/
+ */
#include <stdlib.h>
#include "platform.h"
@@ -33,15 +33,15 @@ static int special_ret = 0;
* @param message the actual message
*/
static void
-handle_stop (void *cls, const struct GNUNET_MessageHeader *message)
+handle_stop(void *cls, const struct GNUNET_MessageHeader *message)
{
struct GNUNET_SERVICE_Client *client = cls;
- (void) message;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _ ("Initiating shutdown as requested by client.\n"));
- GNUNET_SERVICE_client_persist (client);
- GNUNET_SCHEDULER_shutdown ();
+ (void)message;
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ _("Initiating shutdown as requested by client.\n"));
+ GNUNET_SERVICE_client_persist(client);
+ GNUNET_SCHEDULER_shutdown();
/* ARM won't exponentially increase restart delay if we
* terminate normally. This changes the return code.
*/
@@ -58,12 +58,12 @@ handle_stop (void *cls, const struct GNUNET_MessageHeader *message)
* @return @a c
*/
static void *
-client_connect_cb (void *cls,
- struct GNUNET_SERVICE_Client *c,
- struct GNUNET_MQ_Handle *mq)
+client_connect_cb(void *cls,
+ struct GNUNET_SERVICE_Client *c,
+ struct GNUNET_MQ_Handle *mq)
{
- (void) cls;
- (void) mq;
+ (void)cls;
+ (void)mq;
return c;
}
@@ -76,23 +76,23 @@ client_connect_cb (void *cls,
* @param internal_cls should be equal to @a c
*/
static void
-client_disconnect_cb (void *cls,
- struct GNUNET_SERVICE_Client *c,
- void *internal_cls)
+client_disconnect_cb(void *cls,
+ struct GNUNET_SERVICE_Client *c,
+ void *internal_cls)
{
- (void) cls;
- GNUNET_assert (c == internal_cls);
+ (void)cls;
+ GNUNET_assert(c == internal_cls);
}
static void
-run (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_SERVICE_Handle *service)
+run(void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_SERVICE_Handle *service)
{
- (void) cls;
- (void) cfg;
- (void) service;
+ (void)cls;
+ (void)cfg;
+ (void)service;
/* nothing to do */
}
@@ -100,20 +100,23 @@ run (void *cls,
/**
* Define "main" method using service macro.
*/
-GNUNET_SERVICE_MAIN ("do-nothing",
- GNUNET_SERVICE_OPTION_NONE,
- &run,
- &client_connect_cb,
- &client_disconnect_cb,
- NULL,
- GNUNET_MQ_hd_fixed_size (stop,
- GNUNET_MESSAGE_TYPE_ARM_STOP,
- struct GNUNET_MessageHeader,
- NULL),
- GNUNET_MQ_handler_end ());
+GNUNET_SERVICE_MAIN("do-nothing",
+ GNUNET_SERVICE_OPTION_NONE,
+ &run,
+ &client_connect_cb,
+ &client_disconnect_cb,
+ NULL,
+ GNUNET_MQ_hd_fixed_size(stop,
+ GNUNET_MESSAGE_TYPE_ARM_STOP,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_handler_end());
/**
* MINIMIZE heap size (way below 128k) since this process doesn't need much.
*/
-void __attribute__ ((destructor)) GNUNET_mockup_done () { _exit (special_ret); }
+void __attribute__ ((destructor)) GNUNET_mockup_done()
+{
+ _exit(special_ret);
+}
diff --git a/src/arm/test_arm_api.c b/src/arm/test_arm_api.c
index f851595b0..84d6f1bfd 100644
--- a/src/arm/test_arm_api.c
+++ b/src/arm/test_arm_api.c
@@ -11,12 +11,12 @@
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 arm/test_arm_api.c
* @brief testcase for arm_api.c
@@ -26,9 +26,9 @@
#include "gnunet_arm_service.h"
#include "gnunet_resolver_service.h"
-#define LOG(...) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
+#define LOG(...) GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
+#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 15)
static const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -42,139 +42,139 @@ static int phase = 0;
static void
-arm_stop_cb (void *cls,
- enum GNUNET_ARM_RequestStatus status,
- enum GNUNET_ARM_Result result)
+arm_stop_cb(void *cls,
+ enum GNUNET_ARM_RequestStatus status,
+ enum GNUNET_ARM_Result result)
{
op = NULL;
/* (6), a stop request should be sent to ARM successfully */
/* ARM should report that it is stopping */
- GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK);
- GNUNET_break (result == GNUNET_ARM_RESULT_STOPPED);
- GNUNET_break (phase == 6);
+ GNUNET_break(status == GNUNET_ARM_REQUEST_SENT_OK);
+ GNUNET_break(result == GNUNET_ARM_RESULT_STOPPED);
+ GNUNET_break(phase == 6);
phase++;
- LOG ("Sent 'STOP' request for arm to ARM %s\n",
- (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully");
- GNUNET_SCHEDULER_shutdown ();
+ LOG("Sent 'STOP' request for arm to ARM %s\n",
+ (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully");
+ GNUNET_SCHEDULER_shutdown();
}
static void
-resolver_stop_cb (void *cls,
- enum GNUNET_ARM_RequestStatus status,
- enum GNUNET_ARM_Result result)
+resolver_stop_cb(void *cls,
+ enum GNUNET_ARM_RequestStatus status,
+ enum GNUNET_ARM_Result result)
{
op = NULL;
/* (5), a stop request should be sent to ARM successfully.
* ARM should report that resolver is stopped.
*/
- GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK);
- GNUNET_break (result == GNUNET_ARM_RESULT_STOPPED);
- GNUNET_break (phase == 5);
- LOG ("Sent 'STOP' request for resolver to ARM %s\n",
- (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully");
+ GNUNET_break(status == GNUNET_ARM_REQUEST_SENT_OK);
+ GNUNET_break(result == GNUNET_ARM_RESULT_STOPPED);
+ GNUNET_break(phase == 5);
+ LOG("Sent 'STOP' request for resolver to ARM %s\n",
+ (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully");
phase++;
- GNUNET_assert (NULL == op);
- op = GNUNET_ARM_request_service_stop (arm,
- "arm",
- &arm_stop_cb,
- NULL);
+ GNUNET_assert(NULL == op);
+ op = GNUNET_ARM_request_service_stop(arm,
+ "arm",
+ &arm_stop_cb,
+ NULL);
}
static void
-dns_notify (void *cls,
- const struct sockaddr *addr,
- socklen_t addrlen)
+dns_notify(void *cls,
+ const struct sockaddr *addr,
+ socklen_t addrlen)
{
if (addr == NULL)
{
/* (4), resolver should finish resolving localhost */
- GNUNET_break (phase == 4);
+ GNUNET_break(phase == 4);
phase++;
- LOG ("Finished resolving localhost\n");
+ LOG("Finished resolving localhost\n");
if (ok != 0)
ok = 2;
- GNUNET_assert (NULL == op);
- op = GNUNET_ARM_request_service_stop (arm,
- "resolver",
- &resolver_stop_cb,
- NULL);
+ GNUNET_assert(NULL == op);
+ op = GNUNET_ARM_request_service_stop(arm,
+ "resolver",
+ &resolver_stop_cb,
+ NULL);
return;
}
/* (3), resolver should resolve localhost */
- GNUNET_break (phase == 3);
- LOG ("Resolved localhost\n");
+ GNUNET_break(phase == 3);
+ LOG("Resolved localhost\n");
phase++;
- GNUNET_break (addr != NULL);
+ GNUNET_break(addr != NULL);
ok = 0;
}
static void
-resolver_start_cb (void *cls,
- enum GNUNET_ARM_RequestStatus status,
- enum GNUNET_ARM_Result result)
+resolver_start_cb(void *cls,
+ enum GNUNET_ARM_RequestStatus status,
+ enum GNUNET_ARM_Result result)
{
op = NULL;
/* (2), the start request for resolver should be sent successfully
* ARM should report that resolver service is starting.
*/
- GNUNET_assert (status == GNUNET_ARM_REQUEST_SENT_OK);
- GNUNET_break (phase == 2);
- GNUNET_break (result == GNUNET_ARM_RESULT_STARTING);
- LOG ("Sent 'START' request for resolver to ARM %s\n",
- (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully");
+ GNUNET_assert(status == GNUNET_ARM_REQUEST_SENT_OK);
+ GNUNET_break(phase == 2);
+ GNUNET_break(result == GNUNET_ARM_RESULT_STARTING);
+ LOG("Sent 'START' request for resolver to ARM %s\n",
+ (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully");
phase++;
- GNUNET_RESOLVER_ip_get ("localhost",
- AF_INET,
- TIMEOUT,
- &dns_notify, NULL);
+ GNUNET_RESOLVER_ip_get("localhost",
+ AF_INET,
+ TIMEOUT,
+ &dns_notify, NULL);
}
static void
-arm_conn (void *cls,
- int connected)
+arm_conn(void *cls,
+ int connected)
{
if (GNUNET_SYSERR == connected)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Fatal error initializing ARM API.\n"));
- GNUNET_SCHEDULER_shutdown ();
- GNUNET_assert (0);
- return;
- }
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ _("Fatal error initializing ARM API.\n"));
+ GNUNET_SCHEDULER_shutdown();
+ GNUNET_assert(0);
+ return;
+ }
if (GNUNET_YES == connected)
- {
- /* (1), arm connection should be established */
- LOG ("Connected to ARM\n");
- GNUNET_break (phase == 1);
- phase++;
- GNUNET_assert (NULL == op);
- op = GNUNET_ARM_request_service_start (arm,
- "resolver",
- GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- &resolver_start_cb,
- NULL);
- }
+ {
+ /* (1), arm connection should be established */
+ LOG("Connected to ARM\n");
+ GNUNET_break(phase == 1);
+ phase++;
+ GNUNET_assert(NULL == op);
+ op = GNUNET_ARM_request_service_start(arm,
+ "resolver",
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ &resolver_start_cb,
+ NULL);
+ }
else
- {
- /* (7), ARM should stop (we disconnect from it) */
- LOG ("Disconnected from ARM\n");
- GNUNET_break (phase == 7);
- if (phase != 7)
- ok = 3;
- else if (ok == 1)
- ok = 0;
- }
+ {
+ /* (7), ARM should stop (we disconnect from it) */
+ LOG("Disconnected from ARM\n");
+ GNUNET_break(phase == 7);
+ if (phase != 7)
+ ok = 3;
+ else if (ok == 1)
+ ok = 0;
+ }
}
static void
-arm_start_cb (void *cls,
- enum GNUNET_ARM_RequestStatus status,
- enum GNUNET_ARM_Result result)
+arm_start_cb(void *cls,
+ enum GNUNET_ARM_RequestStatus status,
+ enum GNUNET_ARM_Result result)
{
op = NULL;
/* (0) The request should be "sent" successfully
@@ -182,55 +182,55 @@ arm_start_cb (void *cls,
* by itself).
* ARM API should report that ARM service is starting.
*/
- GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK);
- GNUNET_break (phase == 0);
- LOG ("Sent 'START' request for arm to ARM %s\n",
- (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully");
- GNUNET_break (result == GNUNET_ARM_RESULT_STARTING);
+ GNUNET_break(status == GNUNET_ARM_REQUEST_SENT_OK);
+ GNUNET_break(phase == 0);
+ LOG("Sent 'START' request for arm to ARM %s\n",
+ (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully");
+ GNUNET_break(result == GNUNET_ARM_RESULT_STARTING);
phase++;
}
static void
-do_shutdown (void *cls)
+do_shutdown(void *cls)
{
if (NULL != op)
- {
- GNUNET_ARM_operation_cancel (op);
- op = NULL;
- }
+ {
+ GNUNET_ARM_operation_cancel(op);
+ op = NULL;
+ }
if (NULL != arm)
- {
- GNUNET_ARM_disconnect (arm);
- arm = NULL;
- }
+ {
+ GNUNET_ARM_disconnect(arm);
+ arm = NULL;
+ }
}
static void
-task (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *c)
+task(void *cls,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *c)
{
cfg = c;
- arm = GNUNET_ARM_connect (cfg,
- &arm_conn,
- NULL);
+ arm = GNUNET_ARM_connect(cfg,
+ &arm_conn,
+ NULL);
if (NULL == arm)
return;
- GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
- NULL);
- op = GNUNET_ARM_request_service_start (arm,
- "arm",
- GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- &arm_start_cb,
- NULL);
+ GNUNET_SCHEDULER_add_shutdown(&do_shutdown,
+ NULL);
+ op = GNUNET_ARM_request_service_start(arm,
+ "arm",
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ &arm_start_cb,
+ NULL);
}
int
-main (int argc, char *argvx[])
+main(int argc, char *argvx[])
{
char *const argv[] = {
"test-arm-api",
@@ -240,13 +240,14 @@ main (int argc, char *argvx[])
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END
};
- GNUNET_log_setup ("test-arm-api",
- "WARNING",
- NULL);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
- argv, "test-arm-api", "nohelp", options,
- &task, NULL));
+
+ GNUNET_log_setup("test-arm-api",
+ "WARNING",
+ NULL);
+ GNUNET_assert(GNUNET_OK ==
+ GNUNET_PROGRAM_run((sizeof(argv) / sizeof(char *)) - 1,
+ argv, "test-arm-api", "nohelp", options,
+ &task, NULL));
return ok;
}
diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c
index 43984f9bf..8190d29c2 100644
--- a/src/arm/test_exponential_backoff.c
+++ b/src/arm/test_exponential_backoff.c
@@ -11,12 +11,12 @@
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 arm/test_exponential_backoff.c
* @brief testcase for gnunet-service-arm.c
@@ -27,15 +27,15 @@
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
-#define LOG(...) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
+#define LOG(...) GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
#define LOG_BACKOFF GNUNET_NO
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
+#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
#define SERVICE_TEST_TIMEOUT GNUNET_TIME_UNIT_FOREVER_REL
-#define FIVE_MILLISECONDS GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 5)
+#define FIVE_MILLISECONDS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 5)
#define SERVICE "do-nothing"
@@ -74,8 +74,7 @@ static char *killLogFileName;
/**
* Context for handling the shutdown of a service.
*/
-struct ShutdownContext
-{
+struct ShutdownContext {
/**
* Connection to the service that is being shutdown.
*/
@@ -85,12 +84,11 @@ struct ShutdownContext
* Task set up to cancel the shutdown request on timeout.
*/
struct GNUNET_SCHEDULER_Task *cancel_task;
-
};
static void
-kill_task (void *cbData);
+kill_task(void *cbData);
/**
@@ -99,9 +97,9 @@ kill_task (void *cbData);
* @param cls closure
*/
static void
-service_shutdown_timeout (void *cls)
+service_shutdown_timeout(void *cls)
{
- GNUNET_assert (0);
+ GNUNET_assert(0);
}
@@ -114,196 +112,196 @@ service_shutdown_timeout (void *cls)
* @param error error code
*/
static void
-mq_error_handler (void *cls,
- enum GNUNET_MQ_Error error)
+mq_error_handler(void *cls,
+ enum GNUNET_MQ_Error error)
{
struct ShutdownContext *shutdown_ctx = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Service shutdown complete (MQ error).\n");
- GNUNET_SCHEDULER_cancel (shutdown_ctx->cancel_task);
- GNUNET_MQ_destroy (shutdown_ctx->mq);
- GNUNET_free (shutdown_ctx);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Service shutdown complete (MQ error).\n");
+ GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task);
+ GNUNET_MQ_destroy(shutdown_ctx->mq);
+ GNUNET_free(shutdown_ctx);
}
static void
-kill_task (void *cbData)
+kill_task(void *cbData)
{
struct ShutdownContext *shutdown_ctx
- = GNUNET_new (struct ShutdownContext);
+ = GNUNET_new(struct ShutdownContext);
struct GNUNET_MQ_Envelope *env;
struct GNUNET_MessageHeader *msg;
struct GNUNET_MQ_MessageHandler handlers[] = {
- GNUNET_MQ_handler_end ()
+ GNUNET_MQ_handler_end()
};
kt = NULL;
if (trialCount == 13)
- {
- LOG ("Saw enough kills, asking ARM to stop mock service for good\n");
- GNUNET_ARM_request_service_stop (arm,
- SERVICE,
- NULL,
- NULL);
- ok = 0;
- trialCount++;
- GNUNET_free (shutdown_ctx);
- return;
- }
- shutdown_ctx->mq = GNUNET_CLIENT_connect (cfg,
- SERVICE,
- handlers,
- &mq_error_handler,
- shutdown_ctx);
- GNUNET_assert (NULL != shutdown_ctx->mq);
+ {
+ LOG("Saw enough kills, asking ARM to stop mock service for good\n");
+ GNUNET_ARM_request_service_stop(arm,
+ SERVICE,
+ NULL,
+ NULL);
+ ok = 0;
+ trialCount++;
+ GNUNET_free(shutdown_ctx);
+ return;
+ }
+ shutdown_ctx->mq = GNUNET_CLIENT_connect(cfg,
+ SERVICE,
+ handlers,
+ &mq_error_handler,
+ shutdown_ctx);
+ GNUNET_assert(NULL != shutdown_ctx->mq);
trialCount++;
- LOG ("Sending a shutdown request to the mock service\n");
- env = GNUNET_MQ_msg (msg,
- GNUNET_MESSAGE_TYPE_ARM_STOP); /* FIXME: abuse of message type */
- GNUNET_MQ_send (shutdown_ctx->mq,
- env);
+ LOG("Sending a shutdown request to the mock service\n");
+ env = GNUNET_MQ_msg(msg,
+ GNUNET_MESSAGE_TYPE_ARM_STOP); /* FIXME: abuse of message type */
+ GNUNET_MQ_send(shutdown_ctx->mq,
+ env);
shutdown_ctx->cancel_task
- = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
- &service_shutdown_timeout,
- shutdown_ctx);
+ = GNUNET_SCHEDULER_add_delayed(TIMEOUT,
+ &service_shutdown_timeout,
+ shutdown_ctx);
}
static void
-trigger_disconnect (void *cls)
+trigger_disconnect(void *cls)
{
- GNUNET_ARM_disconnect (arm);
- GNUNET_ARM_monitor_stop (mon);
+ GNUNET_ARM_disconnect(arm);
+ GNUNET_ARM_monitor_stop(mon);
if (NULL != kt)
- {
- GNUNET_SCHEDULER_cancel (kt);
- kt = NULL;
- }
+ {
+ GNUNET_SCHEDULER_cancel(kt);
+ kt = NULL;
+ }
}
static void
-arm_stop_cb (void *cls,
- enum GNUNET_ARM_RequestStatus status,
- enum GNUNET_ARM_Result result)
+arm_stop_cb(void *cls,
+ enum GNUNET_ARM_RequestStatus status,
+ enum GNUNET_ARM_Result result)
{
- GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK);
- GNUNET_break (result == GNUNET_ARM_RESULT_STOPPED);
- LOG ("ARM service stopped\n");
- GNUNET_SCHEDULER_shutdown ();
+ GNUNET_break(status == GNUNET_ARM_REQUEST_SENT_OK);
+ GNUNET_break(result == GNUNET_ARM_RESULT_STOPPED);
+ LOG("ARM service stopped\n");
+ GNUNET_SCHEDULER_shutdown();
}
static void
-srv_status (void *cls,
- const char *service,
- enum GNUNET_ARM_ServiceStatus status)
+srv_status(void *cls,
+ const char *service,
+ enum GNUNET_ARM_ServiceStatus status)
{
if (status == GNUNET_ARM_SERVICE_MONITORING_STARTED)
- {
- LOG ("ARM monitor started, starting mock service\n");
- phase++;
- GNUNET_ARM_request_service_start (arm,
- SERVICE,
- GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- NULL,
- NULL);
- return;
- }
- if (0 != strcasecmp (service, SERVICE))
+ {
+ LOG("ARM monitor started, starting mock service\n");
+ phase++;
+ GNUNET_ARM_request_service_start(arm,
+ SERVICE,
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ NULL,
+ NULL);
+ return;
+ }
+ if (0 != strcasecmp(service, SERVICE))
return; /* not what we care about */
if (phase == 1)
- {
- GNUNET_break (status == GNUNET_ARM_SERVICE_STARTING);
- GNUNET_break (phase == 1);
- LOG ("do-nothing is starting\n");
- phase++;
- ok = 1;
- GNUNET_assert (NULL == kt);
- startedWaitingAt = GNUNET_TIME_absolute_get ();
- kt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &kill_task,
- NULL);
- }
- else if (phase == 2)
- {
- /* We passively monitor ARM for status updates. ARM should tell us
- * when do-nothing dies (no need to run a service upness test ourselves).
- */
- if (status == GNUNET_ARM_SERVICE_STARTING)
{
- waitedFor = GNUNET_TIME_absolute_get_duration (startedWaitingAt);
- LOG ("Waited for: %s\n",
- GNUNET_STRINGS_relative_time_to_string (waitedFor,
- GNUNET_YES));
-
- LOG ("do-nothing is starting, killing it...\n");
- GNUNET_assert (NULL == kt);
- kt = GNUNET_SCHEDULER_add_now (&kill_task, &ok);
+ GNUNET_break(status == GNUNET_ARM_SERVICE_STARTING);
+ GNUNET_break(phase == 1);
+ LOG("do-nothing is starting\n");
+ phase++;
+ ok = 1;
+ GNUNET_assert(NULL == kt);
+ startedWaitingAt = GNUNET_TIME_absolute_get();
+ kt = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS,
+ &kill_task,
+ NULL);
}
- else if ((status == GNUNET_ARM_SERVICE_STOPPED) && (trialCount == 14))
+ else if (phase == 2)
{
- phase++;
- LOG ("do-nothing stopped working %u times, we are done here\n",
- (unsigned int) trialCount);
- GNUNET_ARM_request_service_stop (arm,
- "arm",
- &arm_stop_cb,
- NULL);
+ /* We passively monitor ARM for status updates. ARM should tell us
+ * when do-nothing dies (no need to run a service upness test ourselves).
+ */
+ if (status == GNUNET_ARM_SERVICE_STARTING)
+ {
+ waitedFor = GNUNET_TIME_absolute_get_duration(startedWaitingAt);
+ LOG("Waited for: %s\n",
+ GNUNET_STRINGS_relative_time_to_string(waitedFor,
+ GNUNET_YES));
+
+ LOG("do-nothing is starting, killing it...\n");
+ GNUNET_assert(NULL == kt);
+ kt = GNUNET_SCHEDULER_add_now(&kill_task, &ok);
+ }
+ else if ((status == GNUNET_ARM_SERVICE_STOPPED) && (trialCount == 14))
+ {
+ phase++;
+ LOG("do-nothing stopped working %u times, we are done here\n",
+ (unsigned int)trialCount);
+ GNUNET_ARM_request_service_stop(arm,
+ "arm",
+ &arm_stop_cb,
+ NULL);
+ }
}
- }
}
static void
-arm_start_cb (void *cls,
- enum GNUNET_ARM_RequestStatus status,
- enum GNUNET_ARM_Result result)
+arm_start_cb(void *cls,
+ enum GNUNET_ARM_RequestStatus status,
+ enum GNUNET_ARM_Result result)
{
- GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK);
- GNUNET_break (result == GNUNET_ARM_RESULT_STARTING);
- GNUNET_break (phase == 0);
- LOG ("Sent 'START' request for arm to ARM %s\n",
- (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully");
+ GNUNET_break(status == GNUNET_ARM_REQUEST_SENT_OK);
+ GNUNET_break(result == GNUNET_ARM_RESULT_STARTING);
+ GNUNET_break(phase == 0);
+ LOG("Sent 'START' request for arm to ARM %s\n",
+ (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully");
}
static void
-task (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *c)
+task(void *cls,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *c)
{
cfg = c;
- arm = GNUNET_ARM_connect (cfg, NULL, NULL);
+ arm = GNUNET_ARM_connect(cfg, NULL, NULL);
if (NULL == arm)
- {
- GNUNET_break (0);
- return;
- }
- mon = GNUNET_ARM_monitor_start (cfg,
- &srv_status,
- NULL);
- if (NULL == mon)
- {
- GNUNET_break (0);
- GNUNET_ARM_disconnect (arm);
- arm = NULL;
- return;
- }
- GNUNET_ARM_request_service_start (arm,
- "arm",
- GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- &arm_start_cb,
- NULL);
- GNUNET_SCHEDULER_add_shutdown (&trigger_disconnect,
+ {
+ GNUNET_break(0);
+ return;
+ }
+ mon = GNUNET_ARM_monitor_start(cfg,
+ &srv_status,
NULL);
+ if (NULL == mon)
+ {
+ GNUNET_break(0);
+ GNUNET_ARM_disconnect(arm);
+ arm = NULL;
+ return;
+ }
+ GNUNET_ARM_request_service_start(arm,
+ "arm",
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ &arm_start_cb,
+ NULL);
+ GNUNET_SCHEDULER_add_shutdown(&trigger_disconnect,
+ NULL);
}
static int
-check ()
+check()
{
char *const argv[] = {
"test-exponential-backoff",
@@ -315,14 +313,14 @@ check ()
};
/* Running ARM and running the do_nothing task */
- GNUNET_assert (GNUNET_OK ==
- GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
- argv,
- "test-exponential-backoff",
- "nohelp",
- options,
- &task,
- NULL));
+ GNUNET_assert(GNUNET_OK ==
+ GNUNET_PROGRAM_run((sizeof(argv) / sizeof(char *)) - 1,
+ argv,
+ "test-exponential-backoff",
+ "nohelp",
+ options,
+ &task,
+ NULL));
return ok;
}
@@ -336,47 +334,47 @@ check ()
static int
-init ()
+init()
{
struct GNUNET_CONFIGURATION_Handle *cfg;
char pwd[PATH_MAX];
char *binary;
- cfg = GNUNET_CONFIGURATION_create ();
- if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg,
- "test_arm_api_data.conf"))
- {
- GNUNET_CONFIGURATION_destroy (cfg);
- return GNUNET_SYSERR;
- }
- if (NULL == getcwd (pwd, PATH_MAX))
- return GNUNET_SYSERR;
- GNUNET_assert (0 < GNUNET_asprintf (&binary,
- "%s/%s",
- pwd,
- BINARY));
- GNUNET_CONFIGURATION_set_value_string (cfg,
- SERVICE,
- "BINARY",
- binary);
- GNUNET_free (binary);
- if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg,
- CFGFILENAME))
- {
- GNUNET_CONFIGURATION_destroy (cfg);
+ cfg = GNUNET_CONFIGURATION_create();
+ if (GNUNET_OK != GNUNET_CONFIGURATION_parse(cfg,
+ "test_arm_api_data.conf"))
+ {
+ GNUNET_CONFIGURATION_destroy(cfg);
+ return GNUNET_SYSERR;
+ }
+ if (NULL == getcwd(pwd, PATH_MAX))
return GNUNET_SYSERR;
- }
- GNUNET_CONFIGURATION_destroy (cfg);
+ GNUNET_assert(0 < GNUNET_asprintf(&binary,
+ "%s/%s",
+ pwd,
+ BINARY));
+ GNUNET_CONFIGURATION_set_value_string(cfg,
+ SERVICE,
+ "BINARY",
+ binary);
+ GNUNET_free(binary);
+ if (GNUNET_OK != GNUNET_CONFIGURATION_write(cfg,
+ CFGFILENAME))
+ {
+ GNUNET_CONFIGURATION_destroy(cfg);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_CONFIGURATION_destroy(cfg);
#if LOG_BACKOFF
- killLogFileName = GNUNET_DISK_mktemp ("exponential-backoff-waiting.log");
- if (NULL == (killLogFilePtr = fopen (killLogFileName,
- "w")))
+ killLogFileName = GNUNET_DISK_mktemp("exponential-backoff-waiting.log");
+ if (NULL == (killLogFilePtr = fopen(killLogFileName,
+ "w")))
{
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
- "fopen",
- killLogFileName);
- GNUNET_free (killLogFileName);
+ GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_WARNING,
+ "fopen",
+ killLogFileName);
+ GNUNET_free(killLogFileName);
return GNUNET_SYSERR;
}
#endif
@@ -385,29 +383,29 @@ init ()
static void
-houseKeep ()
+houseKeep()
{
#if LOG_BACKOFF
- GNUNET_assert (0 == fclose (killLogFilePtr));
- GNUNET_free (killLogFileName);
+ GNUNET_assert(0 == fclose(killLogFilePtr));
+ GNUNET_free(killLogFileName);
#endif
- (void) unlink (CFGFILENAME);
+ (void)unlink(CFGFILENAME);
}
int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
{
int ret;
- GNUNET_log_setup ("test-exponential-backoff",
- "WARNING",
- NULL);
+ GNUNET_log_setup("test-exponential-backoff",
+ "WARNING",
+ NULL);
- if (GNUNET_OK != init ())
+ if (GNUNET_OK != init())
return 1;
- ret = check ();
- houseKeep ();
+ ret = check();
+ houseKeep();
return ret;
}
diff --git a/src/arm/test_gnunet_service_arm.c b/src/arm/test_gnunet_service_arm.c
index 9508581de..8c8c664f9 100644
--- a/src/arm/test_gnunet_service_arm.c
+++ b/src/arm/test_gnunet_service_arm.c
@@ -11,12 +11,12 @@
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 arm/test_gnunet_service_arm.c
* @brief testcase for gnunet-service-arm.c; tests ARM by making it start the resolver
@@ -34,9 +34,9 @@
* (by checking if running before starting, so really this time is always waited on
* startup (annoying)).
*/
-#define START_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 50)
+#define START_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 50)
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
+#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
static int ret = 1;
@@ -51,141 +51,141 @@ static const char hostname[] = "www.gnu.org"; /* any domain should do */
static void
-trigger_disconnect (void *cls)
+trigger_disconnect(void *cls)
{
- GNUNET_ARM_disconnect (arm);
+ GNUNET_ARM_disconnect(arm);
arm = NULL;
}
static void
-arm_stop_cb (void *cls,
- enum GNUNET_ARM_RequestStatus status,
- enum GNUNET_ARM_Result result)
+arm_stop_cb(void *cls,
+ enum GNUNET_ARM_RequestStatus status,
+ enum GNUNET_ARM_Result result)
{
- GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK);
- GNUNET_break (result == GNUNET_ARM_RESULT_STOPPED);
+ GNUNET_break(status == GNUNET_ARM_REQUEST_SENT_OK);
+ GNUNET_break(result == GNUNET_ARM_RESULT_STOPPED);
if (result != GNUNET_ARM_RESULT_STOPPED)
- {
- GNUNET_break (0);
- ret = 4;
- }
- GNUNET_SCHEDULER_add_now (&trigger_disconnect, NULL);
+ {
+ GNUNET_break(0);
+ ret = 4;
+ }
+ GNUNET_SCHEDULER_add_now(&trigger_disconnect, NULL);
}
static void
-service_list (void *cls,
- enum GNUNET_ARM_RequestStatus rs,
- unsigned int count,
- const char *const*list)
+service_list(void *cls,
+ enum GNUNET_ARM_RequestStatus rs,
+ unsigned int count,
+ const char *const*list)
{
unsigned int i;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%u services are are currently running\n",
- count);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "%u services are are currently running\n",
+ count);
if (GNUNET_ARM_REQUEST_SENT_OK != rs)
goto stop_arm;
- for (i=0;i<count;i++)
- {
- if (0 == strcasecmp (list[i],
- "resolver (gnunet-service-resolver)"))
+ for (i = 0; i < count; i++)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Got service list, now stopping arm\n");
- ret = 0;
+ if (0 == strcasecmp(list[i],
+ "resolver (gnunet-service-resolver)"))
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Got service list, now stopping arm\n");
+ ret = 0;
+ }
}
- }
- stop_arm:
- GNUNET_ARM_request_service_stop (arm,
- "arm",
- &arm_stop_cb,
- NULL);
+stop_arm:
+ GNUNET_ARM_request_service_stop(arm,
+ "arm",
+ &arm_stop_cb,
+ NULL);
}
static void
-hostname_resolve_cb (void *cls,
- const struct sockaddr *addr,
- socklen_t addrlen)
+hostname_resolve_cb(void *cls,
+ const struct sockaddr *addr,
+ socklen_t addrlen)
{
if ((0 == ret) || (4 == ret) || (1 == resolved_ok))
return;
if (NULL == addr)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to resolve hostname!\n");
- GNUNET_break (0);
- ret = 3;
- GNUNET_ARM_request_service_stop (arm,
- "arm",
- &arm_stop_cb,
- NULL);
- return;
- }
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ "Failed to resolve hostname!\n");
+ GNUNET_break(0);
+ ret = 3;
+ GNUNET_ARM_request_service_stop(arm,
+ "arm",
+ &arm_stop_cb,
+ NULL);
+ return;
+ }
if (0 == asked_for_a_list)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Resolved hostname, now checking the service list\n");
- GNUNET_ARM_request_service_list (arm,
- &service_list,
- NULL);
- asked_for_a_list = 1;
- resolved_ok = 1;
- }
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Resolved hostname, now checking the service list\n");
+ GNUNET_ARM_request_service_list(arm,
+ &service_list,
+ NULL);
+ asked_for_a_list = 1;
+ resolved_ok = 1;
+ }
}
static void
-arm_start_cb (void *cls,
- enum GNUNET_ARM_RequestStatus status,
- enum GNUNET_ARM_Result result)
+arm_start_cb(void *cls,
+ enum GNUNET_ARM_RequestStatus status,
+ enum GNUNET_ARM_Result result)
{
- GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK);
- GNUNET_break (result == GNUNET_ARM_RESULT_STARTING);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Trying to resolve a hostname via the resolver service!\n");
+ GNUNET_break(status == GNUNET_ARM_REQUEST_SENT_OK);
+ GNUNET_break(result == GNUNET_ARM_RESULT_STARTING);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Trying to resolve a hostname via the resolver service!\n");
/* connect to the resolver service */
if (NULL ==
- GNUNET_RESOLVER_ip_get (hostname,
- AF_UNSPEC,
- TIMEOUT,
- &hostname_resolve_cb,
- NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unable initiate connection to resolver service\n");
- GNUNET_break (0);
- ret = 2;
- GNUNET_ARM_request_service_stop (arm,
- "arm",
- &arm_stop_cb,
- NULL);
- }
+ GNUNET_RESOLVER_ip_get(hostname,
+ AF_UNSPEC,
+ TIMEOUT,
+ &hostname_resolve_cb,
+ NULL))
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ "Unable initiate connection to resolver service\n");
+ GNUNET_break(0);
+ ret = 2;
+ GNUNET_ARM_request_service_stop(arm,
+ "arm",
+ &arm_stop_cb,
+ NULL);
+ }
}
static void
-run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *c)
+run(void *cls,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *c)
{
- arm = GNUNET_ARM_connect (c,
- NULL,
- NULL);
- GNUNET_ARM_request_service_start (arm,
- "arm",
- GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- &arm_start_cb,
- NULL);
+ arm = GNUNET_ARM_connect(c,
+ NULL,
+ NULL);
+ GNUNET_ARM_request_service_start(arm,
+ "arm",
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ &arm_start_cb,
+ NULL);
}
int
-main (int argc, char *av[])
+main(int argc, char *av[])
{
static char *const argv[] = {
"test-gnunet-service-arm",
@@ -203,27 +203,27 @@ main (int argc, char *av[])
struct addrinfo *ai;
int ret;
- if (0 != (ret = getaddrinfo (hostname, NULL, NULL, &ai)))
- {
- fprintf (stderr,
- "Failed to resolve `%s', testcase not run.\n",
- hostname);
- return 77;
- }
- freeaddrinfo (ai);
+ if (0 != (ret = getaddrinfo(hostname, NULL, NULL, &ai)))
+ {
+ fprintf(stderr,
+ "Failed to resolve `%s', testcase not run.\n",
+ hostname);
+ return 77;
+ }
+ freeaddrinfo(ai);
}
#elif HAVE_GETHOSTBYNAME2
{
struct hostent *host;
- host = gethostbyname2 (hostname, AF_INET);
+ host = gethostbyname2(hostname, AF_INET);
if (NULL == host)
- host = gethostbyname2 (hostname, AF_INET6);
+ host = gethostbyname2(hostname, AF_INET6);
if (NULL == host)
{
- fprintf (stderr,
- "Failed to resolve `%s', testcase not run.\n",
- hostname);
+ fprintf(stderr,
+ "Failed to resolve `%s', testcase not run.\n",
+ hostname);
return 77;
}
}
@@ -231,34 +231,34 @@ main (int argc, char *av[])
{
struct hostent *host;
- host = gethostbyname (hostname);
+ host = gethostbyname(hostname);
if (NULL == host)
{
- fprintf (stderr,
- "Failed to resolve `%s', testcase not run.\n",
- hostname);
+ fprintf(stderr,
+ "Failed to resolve `%s', testcase not run.\n",
+ hostname);
return 77;
}
}
#else
- fprintf (stderr,
- "libc fails to have resolver function, testcase not run.\n");
+ fprintf(stderr,
+ "libc fails to have resolver function, testcase not run.\n");
return 77;
#endif
- GNUNET_log_setup ("test-gnunet-service-arm",
- "WARNING",
- NULL);
- GNUNET_break (GNUNET_OK ==
- GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
- argv, "test-gnunet-service-arm",
- "nohelp", options,
- &run, NULL));
+ GNUNET_log_setup("test-gnunet-service-arm",
+ "WARNING",
+ NULL);
+ GNUNET_break(GNUNET_OK ==
+ GNUNET_PROGRAM_run((sizeof(argv) / sizeof(char *)) - 1,
+ argv, "test-gnunet-service-arm",
+ "nohelp", options,
+ &run, NULL));
if (0 != ret)
- {
- fprintf (stderr,
- "Test failed with error code %d\n",
- ret);
- }
+ {
+ fprintf(stderr,
+ "Test failed with error code %d\n",
+ ret);
+ }
return ret;
}
diff --git a/src/ats-tests/ats-testing-experiment.c b/src/ats-tests/ats-testing-experiment.c
index b91c652b0..db5f411dd 100644
--- a/src/ats-tests/ats-testing-experiment.c
+++ b/src/ats-tests/ats-testing-experiment.c
@@ -1,19 +1,19 @@
/*
- This file is part of GNUnet.
- Copyright (C) 2010-2013 GNUnet e.V.
+ This file is part of GNUnet.
+ Copyright (C) 2010-2013 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 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.
+ 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/>.
+ 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
*/
@@ -28,29 +28,35 @@
#include "ats-testing.h"
const char *
-print_op (enum OperationType op)
+print_op(enum OperationType op)
{
- switch (op) {
+ switch (op)
+ {
case START_SEND:
return "START_SEND";
+
case STOP_SEND:
return "STOP_SEND";
+
case START_PREFERENCE:
return "START_PREFERENCE";
+
case STOP_PREFERENCE:
return "STOP_PREFERENCE";
+
default:
break;
- }
+ }
return "";
}
static struct Experiment *
-create_experiment ()
+create_experiment()
{
struct Experiment *e;
- e = GNUNET_new (struct Experiment);
+
+ e = GNUNET_new(struct Experiment);
e->name = NULL;
e->num_masters = 0;
e->num_slaves = 0;
@@ -60,7 +66,7 @@ create_experiment ()
}
static void
-free_experiment (struct Experiment *e)
+free_experiment(struct Experiment *e)
{
struct Episode *cur;
struct Episode *next;
@@ -69,28 +75,28 @@ free_experiment (struct Experiment *e)
next = e->start;
for (cur = next; NULL != cur; cur = next)
- {
- next = cur->next;
-
- next_o = cur->head;
- for (cur_o = next_o; NULL != cur_o; cur_o = next_o)
{
- next_o = cur_o->next;
- GNUNET_free (cur_o);
+ next = cur->next;
+
+ next_o = cur->head;
+ for (cur_o = next_o; NULL != cur_o; cur_o = next_o)
+ {
+ next_o = cur_o->next;
+ GNUNET_free(cur_o);
+ }
+ GNUNET_free(cur);
}
- GNUNET_free (cur);
- }
- GNUNET_free_non_null (e->name);
- GNUNET_free_non_null (e->cfg_file);
- GNUNET_free (e);
+ GNUNET_free_non_null(e->name);
+ GNUNET_free_non_null(e->cfg_file);
+ GNUNET_free(e);
}
static int
-load_episode (struct Experiment *e,
- struct Episode *cur,
- struct GNUNET_CONFIGURATION_Handle *cfg)
+load_episode(struct Experiment *e,
+ struct Episode *cur,
+ struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct GNUNET_ATS_TEST_Operation *o;
char *sec_name;
@@ -100,272 +106,272 @@ load_episode (struct Experiment *e,
char *pref;
int op_counter = 0;
- fprintf (stderr, "Parsing episode %u\n",cur->id);
- GNUNET_asprintf (&sec_name, "episode-%u", cur->id);
+ fprintf(stderr, "Parsing episode %u\n", cur->id);
+ GNUNET_asprintf(&sec_name, "episode-%u", cur->id);
while (1)
- {
- /* Load operation */
- GNUNET_asprintf (&op_name, "op-%u-operation", op_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
- sec_name, op_name, &op))
{
- GNUNET_free (op_name);
- break;
- }
- o = GNUNET_new (struct GNUNET_ATS_TEST_Operation);
- /* operations = set_rate, start_send, stop_send, set_preference */
- if (0 == strcmp (op, "start_send"))
- {
- o->type = START_SEND;
- }
- else if (0 == strcmp (op, "stop_send"))
- {
- o->type = STOP_SEND;
- }
- else if (0 == strcmp (op, "start_preference"))
- {
- o->type = START_PREFERENCE;
- }
- else if (0 == strcmp (op, "stop_preference"))
- {
- o->type = STOP_PREFERENCE;
- }
- else
- {
- fprintf (stderr, "Invalid operation %u `%s' in episode %u\n",
- op_counter, op, cur->id);
- GNUNET_free (op);
- GNUNET_free (op_name);
- GNUNET_free (o);
- GNUNET_free (sec_name);
- return GNUNET_SYSERR;
- }
- GNUNET_free (op_name);
-
- /* Get source */
- GNUNET_asprintf(&op_name, "op-%u-src", op_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
- sec_name, op_name, &o->src_id))
- {
- fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
- op_counter, op, cur->id);
- GNUNET_free (op);
- GNUNET_free (op_name);
- GNUNET_free (o);
- GNUNET_free (sec_name);
- return GNUNET_SYSERR;
- }
- if (o->src_id > (e->num_masters - 1))
- {
- fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n",
- o->src_id, op_counter, op, cur->id);
- GNUNET_free (op);
- GNUNET_free (op_name);
- GNUNET_free (o);
- GNUNET_free (sec_name);
- return GNUNET_SYSERR;
- }
- GNUNET_free (op_name);
-
- /* Get destination */
- GNUNET_asprintf(&op_name, "op-%u-dest", op_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
- sec_name, op_name, &o->dest_id))
- {
- fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
- op_counter, op, cur->id);
- GNUNET_free (op);
- GNUNET_free (op_name);
- GNUNET_free (o);
- GNUNET_free (sec_name);
- return GNUNET_SYSERR;
- }
- if (o->dest_id > (e->num_slaves - 1))
- {
- fprintf (stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n",
- o->dest_id, op_counter, op, cur->id);
- GNUNET_free (op);
- GNUNET_free (op_name);
- GNUNET_free (o);
- GNUNET_free (sec_name);
- return GNUNET_SYSERR;
- }
- GNUNET_free (op_name);
-
- GNUNET_asprintf(&op_name, "op-%u-type", op_counter);
- if ( (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string(cfg,
- sec_name, op_name, &type)) &&
- (STOP_SEND != o->type) &&
- (STOP_PREFERENCE != o->type) )
- {
- /* Load arguments for set_rate, start_send, set_preference */
- if (0 == strcmp (type, "constant"))
- {
- o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT;
- }
- else if (0 == strcmp (type, "linear"))
- {
- o->gen_type = GNUNET_ATS_TEST_TG_LINEAR;
- }
- else if (0 == strcmp (type, "sinus"))
- {
- o->gen_type = GNUNET_ATS_TEST_TG_SINUS;
- }
- else if (0 == strcmp (type, "random"))
- {
- o->gen_type = GNUNET_ATS_TEST_TG_RANDOM;
- }
+ /* Load operation */
+ GNUNET_asprintf(&op_name, "op-%u-operation", op_counter);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
+ sec_name, op_name, &op))
+ {
+ GNUNET_free(op_name);
+ break;
+ }
+ o = GNUNET_new(struct GNUNET_ATS_TEST_Operation);
+ /* operations = set_rate, start_send, stop_send, set_preference */
+ if (0 == strcmp(op, "start_send"))
+ {
+ o->type = START_SEND;
+ }
+ else if (0 == strcmp(op, "stop_send"))
+ {
+ o->type = STOP_SEND;
+ }
+ else if (0 == strcmp(op, "start_preference"))
+ {
+ o->type = START_PREFERENCE;
+ }
+ else if (0 == strcmp(op, "stop_preference"))
+ {
+ o->type = STOP_PREFERENCE;
+ }
else
- {
- fprintf (stderr, "Invalid type %u `%s' in episode %u\n",
- op_counter, op, cur->id);
- GNUNET_free (type);
- GNUNET_free (op);
- GNUNET_free (op_name);
- GNUNET_free (sec_name);
- GNUNET_free (o);
- return GNUNET_SYSERR;
- }
- GNUNET_free (op_name);
-
- /* Get base rate */
- GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
- sec_name, op_name, &o->base_rate))
- {
- fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n",
- op_counter, op, cur->id);
- GNUNET_free (type);
- GNUNET_free (op);
- GNUNET_free (op_name);
- GNUNET_free (sec_name);
- GNUNET_free (o);
- return GNUNET_SYSERR;
- }
- GNUNET_free (op_name);
-
- /* Get max rate */
- GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
- sec_name, op_name, &o->max_rate))
- {
- if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
- (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) ||
- (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
{
- fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n",
- op_counter, op, cur->id);
- GNUNET_free (type);
- GNUNET_free (op_name);
- GNUNET_free (op);
- GNUNET_free (o);
- GNUNET_free (sec_name);
+ fprintf(stderr, "Invalid operation %u `%s' in episode %u\n",
+ op_counter, op, cur->id);
+ GNUNET_free(op);
+ GNUNET_free(op_name);
+ GNUNET_free(o);
+ GNUNET_free(sec_name);
return GNUNET_SYSERR;
}
- }
- GNUNET_free (op_name);
-
- /* Get period */
- GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg,
- sec_name, op_name, &o->period))
- {
- o->period = cur->duration;
- }
- GNUNET_free (op_name);
-
- if (START_PREFERENCE == o->type)
- {
- /* Get frequency */
- GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg,
- sec_name, op_name, &o->frequency))
- {
- fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n",
+ GNUNET_free(op_name);
+
+ /* Get source */
+ GNUNET_asprintf(&op_name, "op-%u-src", op_counter);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
+ sec_name, op_name, &o->src_id))
+ {
+ fprintf(stderr, "Missing src in operation %u `%s' in episode %u\n",
op_counter, op, cur->id);
- GNUNET_free (type);
- GNUNET_free (op_name);
- GNUNET_free (op);
- GNUNET_free (o);
- GNUNET_free (sec_name);
- return GNUNET_SYSERR;
- }
- GNUNET_free (op_name);
-
- /* Get preference */
- GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg,
- sec_name, op_name, &pref))
- {
- fprintf (stderr, "Missing preference in operation %u `%s' in episode %u\n",
+ GNUNET_free(op);
+ GNUNET_free(op_name);
+ GNUNET_free(o);
+ GNUNET_free(sec_name);
+ return GNUNET_SYSERR;
+ }
+ if (o->src_id > (e->num_masters - 1))
+ {
+ fprintf(stderr, "Invalid src %llu in operation %u `%s' in episode %u\n",
+ o->src_id, op_counter, op, cur->id);
+ GNUNET_free(op);
+ GNUNET_free(op_name);
+ GNUNET_free(o);
+ GNUNET_free(sec_name);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_free(op_name);
+
+ /* Get destination */
+ GNUNET_asprintf(&op_name, "op-%u-dest", op_counter);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
+ sec_name, op_name, &o->dest_id))
+ {
+ fprintf(stderr, "Missing src in operation %u `%s' in episode %u\n",
op_counter, op, cur->id);
- GNUNET_free (type);
- GNUNET_free (op_name);
- GNUNET_free (op);
- GNUNET_free_non_null (pref);
- GNUNET_free (o);
- GNUNET_free (sec_name);
- return GNUNET_SYSERR;
- }
+ GNUNET_free(op);
+ GNUNET_free(op_name);
+ GNUNET_free(o);
+ GNUNET_free(sec_name);
+ return GNUNET_SYSERR;
+ }
+ if (o->dest_id > (e->num_slaves - 1))
+ {
+ fprintf(stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n",
+ o->dest_id, op_counter, op, cur->id);
+ GNUNET_free(op);
+ GNUNET_free(op_name);
+ GNUNET_free(o);
+ GNUNET_free(sec_name);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_free(op_name);
- if (0 == strcmp(pref, "bandwidth"))
- o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH;
- else if (0 == strcmp(pref, "latency"))
- o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY;
+ GNUNET_asprintf(&op_name, "op-%u-type", op_counter);
+ if ((GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string(cfg,
+ sec_name, op_name, &type)) &&
+ (STOP_SEND != o->type) &&
+ (STOP_PREFERENCE != o->type))
+ {
+ /* Load arguments for set_rate, start_send, set_preference */
+ if (0 == strcmp(type, "constant"))
+ {
+ o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT;
+ }
+ else if (0 == strcmp(type, "linear"))
+ {
+ o->gen_type = GNUNET_ATS_TEST_TG_LINEAR;
+ }
+ else if (0 == strcmp(type, "sinus"))
+ {
+ o->gen_type = GNUNET_ATS_TEST_TG_SINUS;
+ }
+ else if (0 == strcmp(type, "random"))
+ {
+ o->gen_type = GNUNET_ATS_TEST_TG_RANDOM;
+ }
else
- {
- fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n",
- op_counter, op, cur->id);
- GNUNET_free (type);
- GNUNET_free (op_name);
- GNUNET_free (op);
- GNUNET_free_non_null (pref);
- GNUNET_free (o);
- GNUNET_free (sec_name);
+ {
+ fprintf(stderr, "Invalid type %u `%s' in episode %u\n",
+ op_counter, op, cur->id);
+ GNUNET_free(type);
+ GNUNET_free(op);
+ GNUNET_free(op_name);
+ GNUNET_free(sec_name);
+ GNUNET_free(o);
return GNUNET_SYSERR;
- }
- GNUNET_free (pref);
- GNUNET_free (op_name);
- }
- }
+ }
+ GNUNET_free(op_name);
+
+ /* Get base rate */
+ GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
+ sec_name, op_name, &o->base_rate))
+ {
+ fprintf(stderr, "Missing base rate in operation %u `%s' in episode %u\n",
+ op_counter, op, cur->id);
+ GNUNET_free(type);
+ GNUNET_free(op);
+ GNUNET_free(op_name);
+ GNUNET_free(sec_name);
+ GNUNET_free(o);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_free(op_name);
+
+ /* Get max rate */
+ GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
+ sec_name, op_name, &o->max_rate))
+ {
+ if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
+ (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) ||
+ (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
+ {
+ fprintf(stderr, "Missing max rate in operation %u `%s' in episode %u\n",
+ op_counter, op, cur->id);
+ GNUNET_free(type);
+ GNUNET_free(op_name);
+ GNUNET_free(op);
+ GNUNET_free(o);
+ GNUNET_free(sec_name);
+ return GNUNET_SYSERR;
+ }
+ }
+ GNUNET_free(op_name);
+
+ /* Get period */
+ GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg,
+ sec_name, op_name, &o->period))
+ {
+ o->period = cur->duration;
+ }
+ GNUNET_free(op_name);
+
+ if (START_PREFERENCE == o->type)
+ {
+ /* Get frequency */
+ GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg,
+ sec_name, op_name, &o->frequency))
+ {
+ fprintf(stderr, "Missing frequency in operation %u `%s' in episode %u\n",
+ op_counter, op, cur->id);
+ GNUNET_free(type);
+ GNUNET_free(op_name);
+ GNUNET_free(op);
+ GNUNET_free(o);
+ GNUNET_free(sec_name);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_free(op_name);
+
+ /* Get preference */
+ GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
+ sec_name, op_name, &pref))
+ {
+ fprintf(stderr, "Missing preference in operation %u `%s' in episode %u\n",
+ op_counter, op, cur->id);
+ GNUNET_free(type);
+ GNUNET_free(op_name);
+ GNUNET_free(op);
+ GNUNET_free_non_null(pref);
+ GNUNET_free(o);
+ GNUNET_free(sec_name);
+ return GNUNET_SYSERR;
+ }
+
+ if (0 == strcmp(pref, "bandwidth"))
+ o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH;
+ else if (0 == strcmp(pref, "latency"))
+ o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY;
+ else
+ {
+ fprintf(stderr, "Invalid preference in operation %u `%s' in episode %u\n",
+ op_counter, op, cur->id);
+ GNUNET_free(type);
+ GNUNET_free(op_name);
+ GNUNET_free(op);
+ GNUNET_free_non_null(pref);
+ GNUNET_free(o);
+ GNUNET_free(sec_name);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_free(pref);
+ GNUNET_free(op_name);
+ }
+ }
- /* Safety checks */
- if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
- (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
- {
- if ((o->max_rate - o->base_rate) > o->base_rate)
- {
- /* This will cause an underflow */
- GNUNET_break (0);
- }
- fprintf (stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n");
- }
+ /* Safety checks */
+ if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
+ (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
+ {
+ if ((o->max_rate - o->base_rate) > o->base_rate)
+ {
+ /* This will cause an underflow */
+ GNUNET_break(0);
+ }
+ fprintf(stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n");
+ }
- if ((START_SEND == o->type) || (START_PREFERENCE == o->type))
- fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n",
- op_counter, cur->id, print_op (o->type), o->src_id,
- o->dest_id, (NULL != type) ? type : "",
- o->base_rate, o->max_rate,
- GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES));
- else
- fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n",
- op_counter, cur->id, print_op (o->type), o->src_id, o->dest_id);
+ if ((START_SEND == o->type) || (START_PREFERENCE == o->type))
+ fprintf(stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n",
+ op_counter, cur->id, print_op(o->type), o->src_id,
+ o->dest_id, (NULL != type) ? type : "",
+ o->base_rate, o->max_rate,
+ GNUNET_STRINGS_relative_time_to_string(o->period, GNUNET_YES));
+ else
+ fprintf(stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n",
+ op_counter, cur->id, print_op(o->type), o->src_id, o->dest_id);
- GNUNET_free_non_null (type);
- GNUNET_free (op);
+ GNUNET_free_non_null(type);
+ GNUNET_free(op);
- GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o);
- op_counter++;
- }
- GNUNET_free (sec_name);
+ GNUNET_CONTAINER_DLL_insert(cur->head, cur->tail, o);
+ op_counter++;
+ }
+ GNUNET_free(sec_name);
return GNUNET_OK;
}
static int
-load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
+load_episodes(struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
{
int e_counter = 0;
char *sec_name;
@@ -376,373 +382,380 @@ load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
e_counter = 0;
last = NULL;
while (1)
- {
- GNUNET_asprintf(&sec_name, "episode-%u", e_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg,
- sec_name, "duration", &e_duration))
{
- GNUNET_free (sec_name);
- break;
- }
+ GNUNET_asprintf(&sec_name, "episode-%u", e_counter);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg,
+ sec_name, "duration", &e_duration))
+ {
+ GNUNET_free(sec_name);
+ break;
+ }
- cur = GNUNET_new (struct Episode);
- cur->duration = e_duration;
- cur->id = e_counter;
+ cur = GNUNET_new(struct Episode);
+ cur->duration = e_duration;
+ cur->id = e_counter;
- if (GNUNET_OK != load_episode (e, cur, cfg))
- {
- GNUNET_free (sec_name);
- GNUNET_free (cur);
- return GNUNET_SYSERR;
- }
+ if (GNUNET_OK != load_episode(e, cur, cfg))
+ {
+ GNUNET_free(sec_name);
+ GNUNET_free(cur);
+ return GNUNET_SYSERR;
+ }
- fprintf (stderr, "Found episode %u with duration %s \n",
- e_counter,
- GNUNET_STRINGS_relative_time_to_string(cur->duration, GNUNET_YES));
-
- /* Update experiment */
- e->num_episodes ++;
- e->total_duration = GNUNET_TIME_relative_add(e->total_duration, cur->duration);
- /* Put in linked list */
- if (NULL == last)
- e->start = cur;
- else
- last->next = cur;
-
- GNUNET_free (sec_name);
- e_counter ++;
- last = cur;
- }
+ fprintf(stderr, "Found episode %u with duration %s \n",
+ e_counter,
+ GNUNET_STRINGS_relative_time_to_string(cur->duration, GNUNET_YES));
+
+ /* Update experiment */
+ e->num_episodes++;
+ e->total_duration = GNUNET_TIME_relative_add(e->total_duration, cur->duration);
+ /* Put in linked list */
+ if (NULL == last)
+ e->start = cur;
+ else
+ last->next = cur;
+
+ GNUNET_free(sec_name);
+ e_counter++;
+ last = cur;
+ }
return e_counter;
}
static void
-timeout_experiment (void *cls)
+timeout_experiment(void *cls)
{
struct Experiment *e = cls;
+
e->experiment_timeout_task = NULL;
- fprintf (stderr, "Experiment timeout!\n");
+ fprintf(stderr, "Experiment timeout!\n");
if (NULL != e->episode_timeout_task)
- {
- GNUNET_SCHEDULER_cancel (e->episode_timeout_task);
- e->episode_timeout_task = NULL;
- }
+ {
+ GNUNET_SCHEDULER_cancel(e->episode_timeout_task);
+ e->episode_timeout_task = NULL;
+ }
- e->e_done_cb (e, GNUNET_TIME_absolute_get_duration(e->start_time),
- GNUNET_SYSERR);
+ e->e_done_cb(e, GNUNET_TIME_absolute_get_duration(e->start_time),
+ GNUNET_SYSERR);
}
static void
-enforce_start_send (struct GNUNET_ATS_TEST_Operation *op)
+enforce_start_send(struct GNUNET_ATS_TEST_Operation *op)
{
struct BenchmarkPeer *peer;
struct BenchmarkPartner *partner;
- peer = GNUNET_ATS_TEST_get_peer (op->src_id);
+ peer = GNUNET_ATS_TEST_get_peer(op->src_id);
if (NULL == peer)
- {
- GNUNET_break (0);
- return;
- }
+ {
+ GNUNET_break(0);
+ return;
+ }
- partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
+ partner = GNUNET_ATS_TEST_get_partner(op->src_id, op->dest_id);
if (NULL == partner)
- {
- GNUNET_break (0);
- return;
- }
+ {
+ GNUNET_break(0);
+ return;
+ }
- fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
+ fprintf(stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id);
if (NULL != partner->tg)
- {
- fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",op->src_id, op->dest_id);
- GNUNET_ATS_TEST_generate_traffic_stop(partner->tg);
- partner->tg = NULL;
- }
+ {
+ fprintf(stderr, "Stopping traffic between master %llu slave %llu\n", op->src_id, op->dest_id);
+ GNUNET_ATS_TEST_generate_traffic_stop(partner->tg);
+ partner->tg = NULL;
+ }
partner->tg = GNUNET_ATS_TEST_generate_traffic_start(peer, partner,
- op->gen_type, op->base_rate, op->max_rate, op->period,
- GNUNET_TIME_UNIT_FOREVER_REL);
+ op->gen_type, op->base_rate, op->max_rate, op->period,
+ GNUNET_TIME_UNIT_FOREVER_REL);
}
static void
-enforce_stop_send (struct GNUNET_ATS_TEST_Operation *op)
+enforce_stop_send(struct GNUNET_ATS_TEST_Operation *op)
{
struct BenchmarkPartner *p;
- p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
+
+ p = GNUNET_ATS_TEST_get_partner(op->src_id, op->dest_id);
if (NULL == p)
- {
- GNUNET_break (0);
- return;
- }
+ {
+ GNUNET_break(0);
+ return;
+ }
- fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
+ fprintf(stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id);
if (NULL != p->tg)
- {
- fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",
- op->src_id, op->dest_id);
- GNUNET_ATS_TEST_generate_traffic_stop(p->tg);
- p->tg = NULL;
- }
+ {
+ fprintf(stderr, "Stopping traffic between master %llu slave %llu\n",
+ op->src_id, op->dest_id);
+ GNUNET_ATS_TEST_generate_traffic_stop(p->tg);
+ p->tg = NULL;
+ }
}
static void
-enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op)
+enforce_start_preference(struct GNUNET_ATS_TEST_Operation *op)
{
struct BenchmarkPeer *peer;
struct BenchmarkPartner *partner;
- peer = GNUNET_ATS_TEST_get_peer (op->src_id);
+ peer = GNUNET_ATS_TEST_get_peer(op->src_id);
if (NULL == peer)
- {
- GNUNET_break (0);
- return;
- }
+ {
+ GNUNET_break(0);
+ return;
+ }
- partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
+ partner = GNUNET_ATS_TEST_get_partner(op->src_id, op->dest_id);
if (NULL == partner)
- {
- GNUNET_break (0);
- return;
- }
+ {
+ GNUNET_break(0);
+ return;
+ }
- fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
+ fprintf(stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id);
if (NULL != partner->pg)
- {
- fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",
- op->src_id, op->dest_id);
- GNUNET_ATS_TEST_generate_preferences_stop(partner->pg);
- partner->pg = NULL;
- }
+ {
+ fprintf(stderr, "Stopping traffic between master %llu slave %llu\n",
+ op->src_id, op->dest_id);
+ GNUNET_ATS_TEST_generate_preferences_stop(partner->pg);
+ partner->pg = NULL;
+ }
partner->pg = GNUNET_ATS_TEST_generate_preferences_start(peer, partner,
- op->gen_type, op->base_rate, op->max_rate, op->period, op->frequency,
- op->pref_type);
+ op->gen_type, op->base_rate, op->max_rate, op->period, op->frequency,
+ op->pref_type);
}
static void
-enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op)
+enforce_stop_preference(struct GNUNET_ATS_TEST_Operation *op)
{
struct BenchmarkPartner *p;
- p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
+
+ p = GNUNET_ATS_TEST_get_partner(op->src_id, op->dest_id);
if (NULL == p)
- {
- GNUNET_break (0);
- return;
- }
+ {
+ GNUNET_break(0);
+ return;
+ }
- fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
+ fprintf(stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id);
if (NULL != p->pg)
- {
- fprintf (stderr, "Stopping preference between master %llu slave %llu\n",
- op->src_id, op->dest_id);
- GNUNET_ATS_TEST_generate_preferences_stop (p->pg);
- p->pg = NULL;
- }
+ {
+ fprintf(stderr, "Stopping preference between master %llu slave %llu\n",
+ op->src_id, op->dest_id);
+ GNUNET_ATS_TEST_generate_preferences_stop(p->pg);
+ p->pg = NULL;
+ }
}
-static void enforce_episode (struct Episode *ep)
+static void enforce_episode(struct Episode *ep)
{
struct GNUNET_ATS_TEST_Operation *cur;
+
for (cur = ep->head; NULL != cur; cur = cur->next)
- {
-
- fprintf (stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n",
- print_op (cur->type), cur->src_id, cur->dest_id, cur->base_rate);
- switch (cur->type) {
- case START_SEND:
- enforce_start_send (cur);
- break;
- case STOP_SEND:
- enforce_stop_send (cur);
- break;
- case START_PREFERENCE:
- enforce_start_preference (cur);
- break;
- case STOP_PREFERENCE:
- enforce_stop_preference (cur);
- break;
- default:
- break;
+ {
+ fprintf(stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n",
+ print_op(cur->type), cur->src_id, cur->dest_id, cur->base_rate);
+ switch (cur->type)
+ {
+ case START_SEND:
+ enforce_start_send(cur);
+ break;
+
+ case STOP_SEND:
+ enforce_stop_send(cur);
+ break;
+
+ case START_PREFERENCE:
+ enforce_start_preference(cur);
+ break;
+
+ case STOP_PREFERENCE:
+ enforce_stop_preference(cur);
+ break;
+
+ default:
+ break;
+ }
}
- }
}
static void
-timeout_episode (void *cls)
+timeout_episode(void *cls)
{
struct Experiment *e = cls;
e->episode_timeout_task = NULL;
if (NULL != e->ep_done_cb)
- e->ep_done_cb (e->cur);
+ e->ep_done_cb(e->cur);
/* Scheduling next */
e->cur = e->cur->next;
if (NULL == e->cur)
- {
- /* done */
- fprintf (stderr, "Last episode done!\n");
- if (NULL != e->experiment_timeout_task)
{
- GNUNET_SCHEDULER_cancel (e->experiment_timeout_task);
- e->experiment_timeout_task = NULL;
+ /* done */
+ fprintf(stderr, "Last episode done!\n");
+ if (NULL != e->experiment_timeout_task)
+ {
+ GNUNET_SCHEDULER_cancel(e->experiment_timeout_task);
+ e->experiment_timeout_task = NULL;
+ }
+ e->e_done_cb(e, GNUNET_TIME_absolute_get_duration(e->start_time), GNUNET_OK);
+ return;
}
- e->e_done_cb (e, GNUNET_TIME_absolute_get_duration(e->start_time), GNUNET_OK);
- return;
- }
- fprintf (stderr, "Running episode %u with timeout %s\n",
- e->cur->id,
- GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES));
+ fprintf(stderr, "Running episode %u with timeout %s\n",
+ e->cur->id,
+ GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES));
enforce_episode(e->cur);
- e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed (e->cur->duration,
- &timeout_episode, e);
+ e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed(e->cur->duration,
+ &timeout_episode, e);
}
void
-GNUNET_ATS_TEST_experimentation_run (struct Experiment *e,
- GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb,
- GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb)
+GNUNET_ATS_TEST_experimentation_run(struct Experiment *e,
+ GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb,
+ GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb)
{
- fprintf (stderr, "Running experiment `%s' with timeout %s\n", e->name,
- GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES));
+ fprintf(stderr, "Running experiment `%s' with timeout %s\n", e->name,
+ GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES));
e->e_done_cb = e_done_cb;
e->ep_done_cb = ep_done_cb;
e->start_time = GNUNET_TIME_absolute_get();
/* Start total time out */
- e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed (e->max_duration,
- &timeout_experiment, e);
+ e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed(e->max_duration,
+ &timeout_experiment, e);
/* Start */
e->cur = e->start;
- fprintf (stderr, "Running episode %u with timeout %s\n",
- e->cur->id,
- GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES));
+ fprintf(stderr, "Running episode %u with timeout %s\n",
+ e->cur->id,
+ GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES));
enforce_episode(e->cur);
- e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed (e->cur->duration,
- &timeout_episode, e);
-
-
+ e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed(e->cur->duration,
+ &timeout_episode, e);
}
struct Experiment *
-GNUNET_ATS_TEST_experimentation_load (const char *filename)
+GNUNET_ATS_TEST_experimentation_load(const char *filename)
{
struct Experiment *e;
struct GNUNET_CONFIGURATION_Handle *cfg;
+
e = NULL;
cfg = GNUNET_CONFIGURATION_create();
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, filename))
- {
- fprintf (stderr, "Failed to load `%s'\n", filename);
- GNUNET_CONFIGURATION_destroy (cfg);
- return NULL;
- }
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load(cfg, filename))
+ {
+ fprintf(stderr, "Failed to load `%s'\n", filename);
+ GNUNET_CONFIGURATION_destroy(cfg);
+ return NULL;
+ }
- e = create_experiment ();
+ e = create_experiment();
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment",
- "name", &e->name))
- {
- fprintf (stderr, "Invalid %s", "name");
- free_experiment (e);
- return NULL;
- }
+ "name", &e->name))
+ {
+ fprintf(stderr, "Invalid %s", "name");
+ free_experiment(e);
+ return NULL;
+ }
else
- fprintf (stderr, "Experiment name: `%s'\n", e->name);
-
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, "experiment",
- "cfg_file", &e->cfg_file))
- {
- fprintf (stderr, "Invalid %s", "cfg_file");
- free_experiment (e);
- return NULL;
- }
+ fprintf(stderr, "Experiment name: `%s'\n", e->name);
+
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename(cfg, "experiment",
+ "cfg_file", &e->cfg_file))
+ {
+ fprintf(stderr, "Invalid %s", "cfg_file");
+ free_experiment(e);
+ return NULL;
+ }
else
- fprintf (stderr, "Experiment name: `%s'\n", e->cfg_file);
+ fprintf(stderr, "Experiment name: `%s'\n", e->cfg_file);
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment",
- "masters", &e->num_masters))
- {
- fprintf (stderr, "Invalid %s", "masters");
- free_experiment (e);
- return NULL;
- }
+ "masters", &e->num_masters))
+ {
+ fprintf(stderr, "Invalid %s", "masters");
+ free_experiment(e);
+ return NULL;
+ }
else
- fprintf (stderr, "Experiment masters: `%llu'\n",
- e->num_masters);
+ fprintf(stderr, "Experiment masters: `%llu'\n",
+ e->num_masters);
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment",
- "slaves", &e->num_slaves))
- {
- fprintf (stderr, "Invalid %s", "slaves");
- free_experiment (e);
- return NULL;
- }
+ "slaves", &e->num_slaves))
+ {
+ fprintf(stderr, "Invalid %s", "slaves");
+ free_experiment(e);
+ return NULL;
+ }
else
- fprintf (stderr, "Experiment slaves: `%llu'\n",
- e->num_slaves);
+ fprintf(stderr, "Experiment slaves: `%llu'\n",
+ e->num_slaves);
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
- "log_freq", &e->log_freq))
- {
- fprintf (stderr, "Invalid %s", "log_freq");
- free_experiment (e);
- return NULL;
- }
+ "log_freq", &e->log_freq))
+ {
+ fprintf(stderr, "Invalid %s", "log_freq");
+ free_experiment(e);
+ return NULL;
+ }
else
- fprintf (stderr, "Experiment logging frequency: `%s'\n",
- GNUNET_STRINGS_relative_time_to_string (e->log_freq, GNUNET_YES));
+ fprintf(stderr, "Experiment logging frequency: `%s'\n",
+ GNUNET_STRINGS_relative_time_to_string(e->log_freq, GNUNET_YES));
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
- "max_duration", &e->max_duration))
- {
- fprintf (stderr, "Invalid %s", "max_duration");
- free_experiment (e);
- return NULL;
- }
+ "max_duration", &e->max_duration))
+ {
+ fprintf(stderr, "Invalid %s", "max_duration");
+ free_experiment(e);
+ return NULL;
+ }
else
- fprintf (stderr, "Experiment duration: `%s'\n",
- GNUNET_STRINGS_relative_time_to_string (e->max_duration, GNUNET_YES));
+ fprintf(stderr, "Experiment duration: `%s'\n",
+ GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES));
- load_episodes (e, cfg);
- fprintf (stderr, "Loaded %u episodes with total duration %s\n",
- e->num_episodes,
- GNUNET_STRINGS_relative_time_to_string (e->total_duration, GNUNET_YES));
+ load_episodes(e, cfg);
+ fprintf(stderr, "Loaded %u episodes with total duration %s\n",
+ e->num_episodes,
+ GNUNET_STRINGS_relative_time_to_string(e->total_duration, GNUNET_YES));
- GNUNET_CONFIGURATION_destroy (cfg);
+ GNUNET_CONFIGURATION_destroy(cfg);
return e;
}
void
-GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e)
+GNUNET_ATS_TEST_experimentation_stop(struct Experiment *e)
{
if (NULL != e->experiment_timeout_task)
- {
- GNUNET_SCHEDULER_cancel (e->experiment_timeout_task);
- e->experiment_timeout_task = NULL;
- }
+ {
+ GNUNET_SCHEDULER_cancel(e->experiment_timeout_task);
+ e->experiment_timeout_task = NULL;
+ }
if (NULL != e->episode_timeout_task)
- {
- GNUNET_SCHEDULER_cancel (e->episode_timeout_task);
- e->episode_timeout_task = NULL;
- }
- free_experiment (e);
+ {
+ GNUNET_SCHEDULER_cancel(e->episode_timeout_task);
+ e->episode_timeout_task = NULL;
+ }
+ free_experiment(e);
}
/* end of file ats-testing-experiment.c*/
diff --git a/src/ats-tests/ats-testing-log.c b/src/ats-tests/ats-testing-log.c
index 8624904a5..a362955d2 100644
--- a/src/ats-tests/ats-testing-log.c
+++ b/src/ats-tests/ats-testing-log.c
@@ -1,19 +1,19 @@
/*
- This file is part of GNUnet.
- Copyright (C) 2010-2013 GNUnet e.V.
+ This file is part of GNUnet.
+ Copyright (C) 2010-2013 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 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.
+ 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/>.
+ 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
*/
@@ -28,25 +28,25 @@
#include "ats-testing.h"
#define THROUGHPUT_TEMPLATE "#!/usr/bin/gnuplot \n" \
-"set datafile separator ';' \n" \
-"set title \"Throughput between Master and Slaves\" \n" \
-"set xlabel \"Time in ms\" \n" \
-"set ylabel \"Bytes/s\" \n" \
-"set grid \n"
+ "set datafile separator ';' \n" \
+ "set title \"Throughput between Master and Slaves\" \n" \
+ "set xlabel \"Time in ms\" \n" \
+ "set ylabel \"Bytes/s\" \n" \
+ "set grid \n"
#define RTT_TEMPLATE "#!/usr/bin/gnuplot \n" \
-"set datafile separator ';' \n" \
-"set title \"Application level roundtrip time between Master and Slaves\" \n" \
-"set xlabel \"Time in ms\" \n" \
-"set ylabel \"ms\" \n" \
-"set grid \n"
+ "set datafile separator ';' \n" \
+ "set title \"Application level roundtrip time between Master and Slaves\" \n" \
+ "set xlabel \"Time in ms\" \n" \
+ "set ylabel \"ms\" \n" \
+ "set grid \n"
#define BW_TEMPLATE "#!/usr/bin/gnuplot \n" \
-"set datafile separator ';' \n" \
-"set title \"Bandwidth inbound and outbound between Master and Slaves\" \n" \
-"set xlabel \"Time in ms\" \n" \
-"set ylabel \"Bytes / s \" \n" \
-"set grid \n"
+ "set datafile separator ';' \n" \
+ "set title \"Bandwidth inbound and outbound between Master and Slaves\" \n" \
+ "set xlabel \"Time in ms\" \n" \
+ "set ylabel \"Bytes / s \" \n" \
+ "set grid \n"
#define LOG_ITEMS_TIME 2
#define LOG_ITEMS_PER_PEER 17
@@ -72,8 +72,7 @@
/**
* A single logging time step for a partner
*/
-struct PartnerLoggingTimestep
-{
+struct PartnerLoggingTimestep {
/**
* Peer
*/
@@ -143,8 +142,7 @@ struct PartnerLoggingTimestep
/**
* A single logging time step for a peer
*/
-struct PeerLoggingTimestep
-{
+struct PeerLoggingTimestep {
/**
* Next in DLL
*/
@@ -199,8 +197,7 @@ struct PeerLoggingTimestep
/**
* Entry for a benchmark peer
*/
-struct LoggingPeer
-{
+struct LoggingPeer {
/**
* Peer
*/
@@ -222,8 +219,7 @@ struct LoggingPeer
struct PeerLoggingTimestep *tail;
};
-struct LoggingHandle
-{
+struct LoggingHandle {
/**
* Logging task
*/
@@ -248,179 +244,179 @@ struct LoggingHandle
static void
-write_throughput_gnuplot_script (char * fn, struct LoggingPeer *lp, char **fs, int slaves)
+write_throughput_gnuplot_script(char * fn, struct LoggingPeer *lp, char **fs, int slaves)
{
struct GNUNET_DISK_FileHandle *f;
char * gfn;
char *data;
int c_s;
- GNUNET_asprintf (&gfn, "gnuplot_throughput_%s",fn);
- fprintf (stderr, "Writing throughput plot for master %u and %u slaves to `%s'\n",
- lp->peer->no, slaves, gfn);
+ GNUNET_asprintf(&gfn, "gnuplot_throughput_%s", fn);
+ fprintf(stderr, "Writing throughput plot for master %u and %u slaves to `%s'\n",
+ lp->peer->no, slaves, gfn);
- f = GNUNET_DISK_file_open (gfn,
- GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE);
+ f = GNUNET_DISK_file_open(gfn,
+ GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
+ GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE);
if (NULL == f)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn);
- GNUNET_free (gfn);
- return;
- }
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn);
+ GNUNET_free(gfn);
+ return;
+ }
/* Write header */
if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, THROUGHPUT_TEMPLATE,
- strlen(THROUGHPUT_TEMPLATE)))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Cannot write data to plot file `%s'\n", gfn);
+ strlen(THROUGHPUT_TEMPLATE)))
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ "Cannot write data to plot file `%s'\n", gfn);
/* Write master data */
- GNUNET_asprintf (&data,
- "plot '%s' using 2:%u with lines title 'Master %u send total', \\\n" \
- "'%s' using 2:%u with lines title 'Master %u receive total', \\\n",
- fn, LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no,
- fn, LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no);
+ GNUNET_asprintf(&data,
+ "plot '%s' using 2:%u with lines title 'Master %u send total', \\\n" \
+ "'%s' using 2:%u with lines title 'Master %u receive total', \\\n",
+ fn, LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no,
+ fn, LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no);
if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data)))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
- GNUNET_free (data);
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
+ GNUNET_free(data);
for (c_s = 0; c_s < slaves; c_s++)
- {
- GNUNET_asprintf (&data, "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \
- "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n",
- fs[c_s],
- LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_SENT,
- lp->peer->no,
- lp->peer->partners[c_s].dest->no,
- fs[c_s],
- LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_RECV,
- lp->peer->no,
- lp->peer->partners[c_s].dest->no,
- (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1");
- if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data)))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
- GNUNET_free (data);
- }
+ {
+ GNUNET_asprintf(&data, "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \
+ "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n",
+ fs[c_s],
+ LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_SENT,
+ lp->peer->no,
+ lp->peer->partners[c_s].dest->no,
+ fs[c_s],
+ LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_RECV,
+ lp->peer->no,
+ lp->peer->partners[c_s].dest->no,
+ (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1");
+ if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data)))
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
+ GNUNET_free(data);
+ }
if (GNUNET_SYSERR == GNUNET_DISK_file_close(f))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Cannot close gnuplot file `%s'\n", gfn);
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ "Cannot close gnuplot file `%s'\n", gfn);
else
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Data successfully written to plot file `%s'\n", gfn);
- GNUNET_free (gfn);
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Data successfully written to plot file `%s'\n", gfn);
+ GNUNET_free(gfn);
}
static void
-write_rtt_gnuplot_script (char * fn, struct LoggingPeer *lp, char **fs, int slaves)
+write_rtt_gnuplot_script(char * fn, struct LoggingPeer *lp, char **fs, int slaves)
{
struct GNUNET_DISK_FileHandle *f;
char * gfn;
char *data;
int c_s;
- GNUNET_asprintf (&gfn, "gnuplot_rtt_%s",fn);
- fprintf (stderr, "Writing rtt plot for master %u to `%s'\n",
- lp->peer->no, gfn);
+ GNUNET_asprintf(&gfn, "gnuplot_rtt_%s", fn);
+ fprintf(stderr, "Writing rtt plot for master %u to `%s'\n",
+ lp->peer->no, gfn);
- f = GNUNET_DISK_file_open (gfn,
- GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE);
+ f = GNUNET_DISK_file_open(gfn,
+ GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
+ GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE);
if (NULL == f)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn);
- GNUNET_free (gfn);
- return;
- }
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn);
+ GNUNET_free(gfn);
+ return;
+ }
/* Write header */
if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, RTT_TEMPLATE, strlen(RTT_TEMPLATE)))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
for (c_s = 0; c_s < slaves; c_s++)
- {
- GNUNET_asprintf (&data, "%s'%s' using 2:%u with lines title 'Master %u - Slave %u '%s\n",
- (0 == c_s) ? "plot " :"",
- fs[c_s],
- LOG_ITEMS_TIME + LOG_ITEM_APP_RTT,
- lp->peer->no,
- lp->peer->partners[c_s].dest->no,
- (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1");
- if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data)))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
- GNUNET_free (data);
- }
+ {
+ GNUNET_asprintf(&data, "%s'%s' using 2:%u with lines title 'Master %u - Slave %u '%s\n",
+ (0 == c_s) ? "plot " : "",
+ fs[c_s],
+ LOG_ITEMS_TIME + LOG_ITEM_APP_RTT,
+ lp->peer->no,
+ lp->peer->partners[c_s].dest->no,
+ (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1");
+ if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data)))
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
+ GNUNET_free(data);
+ }
if (GNUNET_SYSERR == GNUNET_DISK_file_close(f))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn);
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn);
else
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn);
- GNUNET_free (gfn);
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn);
+ GNUNET_free(gfn);
}
static void
-write_bw_gnuplot_script (char * fn, struct LoggingPeer *lp, char **fs, int slaves)
+write_bw_gnuplot_script(char * fn, struct LoggingPeer *lp, char **fs, int slaves)
{
struct GNUNET_DISK_FileHandle *f;
char * gfn;
char *data;
int c_s;
- GNUNET_asprintf (&gfn, "gnuplot_bw_%s",fn);
- fprintf (stderr, "Writing bandwidth plot for master %u to `%s'\n",
- lp->peer->no, gfn);
+ GNUNET_asprintf(&gfn, "gnuplot_bw_%s", fn);
+ fprintf(stderr, "Writing bandwidth plot for master %u to `%s'\n",
+ lp->peer->no, gfn);
- f = GNUNET_DISK_file_open (gfn,
- GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE);
+ f = GNUNET_DISK_file_open(gfn,
+ GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
+ GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE);
if (NULL == f)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn);
- GNUNET_free (gfn);
- return;
- }
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn);
+ GNUNET_free(gfn);
+ return;
+ }
/* Write header */
if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, BW_TEMPLATE, strlen(BW_TEMPLATE)))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Cannot write data to plot file `%s'\n", gfn);
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ "Cannot write data to plot file `%s'\n", gfn);
for (c_s = 0; c_s < slaves; c_s++)
- {
- GNUNET_asprintf (&data, "%s"\
- "'%s' using 2:%u with lines title 'BW out master %u - Slave %u ', \\\n" \
- "'%s' using 2:%u with lines title 'BW in master %u - Slave %u '"\
- "%s\n",
- (0 == c_s) ? "plot " :"",
- fs[c_s],
- LOG_ITEMS_TIME + LOG_ITEM_ATS_BW_OUT,
- lp->peer->no, c_s,
- fs[c_s],
- LOG_ITEMS_TIME + LOG_ITEM_ATS_BW_IN,
- lp->peer->no, c_s,
- (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1");
- if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data)))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
- GNUNET_free (data);
- }
+ {
+ GNUNET_asprintf(&data, "%s" \
+ "'%s' using 2:%u with lines title 'BW out master %u - Slave %u ', \\\n" \
+ "'%s' using 2:%u with lines title 'BW in master %u - Slave %u '" \
+ "%s\n",
+ (0 == c_s) ? "plot " : "",
+ fs[c_s],
+ LOG_ITEMS_TIME + LOG_ITEM_ATS_BW_OUT,
+ lp->peer->no, c_s,
+ fs[c_s],
+ LOG_ITEMS_TIME + LOG_ITEM_ATS_BW_IN,
+ lp->peer->no, c_s,
+ (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1");
+ if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data)))
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
+ GNUNET_free(data);
+ }
if (GNUNET_SYSERR == GNUNET_DISK_file_close(f))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn);
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn);
else
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn);
- GNUNET_free (gfn);
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn);
+ GNUNET_free(gfn);
}
void
-GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l,
- const char *experiment_name,
- int plots)
+GNUNET_ATS_TEST_logging_write_to_file(struct LoggingHandle *l,
+ const char *experiment_name,
+ int plots)
{
struct GNUNET_DISK_FileHandle *f[l->num_slaves];
struct GNUNET_DISK_FileHandle *f_m;
@@ -439,179 +435,178 @@ GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l,
tmp_exp_name = experiment_name;
for (c_m = 0; c_m < l->num_masters; c_m++)
- {
- GNUNET_asprintf (&filename_master, "%s_%llu_master%u_%s",
- experiment_name, timestamp.abs_value_us, c_m, l->name);
- fprintf (stderr, "Writing data for master %u to file `%s'\n",
- c_m,filename_master);
-
- f_m = GNUNET_DISK_file_open (filename_master,
- GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
- if (NULL == f_m)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename_master);
- GNUNET_free (filename_master);
- return;
- }
-
- GNUNET_asprintf (&data, "# master %u; experiment : %s\n"
- "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; \n" ,
- c_m, experiment_name);
- if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_m, data, strlen(data)))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Cannot write data to log file `%s'\n",filename_master);
- GNUNET_free (data);
-
- for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++)
- {
- GNUNET_asprintf (&filename_slaves[c_s], "%s_%llu_master%u_slave_%u_%s",
- tmp_exp_name, timestamp.abs_value_us, c_m, c_s, l->name);
-
- fprintf (stderr, "Writing data for master %u slave %u to file `%s'\n",
- c_m, c_s, filename_slaves[c_s]);
-
- f[c_s] = GNUNET_DISK_file_open (filename_slaves[c_s],
- GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
- GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
- if (NULL == f[c_s])
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename_slaves[c_s]);
- GNUNET_free (filename_slaves[c_s]);
- GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close(f_m));
- GNUNET_free (filename_master);
- return;
- }
-
- /* Header */
- GNUNET_asprintf (&data, "# master %u; slave %u ; experiment : %s\n"
- "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; " \
- "rtt; bw in; bw out; ats_cost_lan; ats_cost_wlan; ats_delay; ats_distance; ats_network_type; ats_utilization_up ;ats_utilization_down;" \
- "pref bandwidth; pref delay\n",
- c_m, c_s, experiment_name);
- if (GNUNET_SYSERR == GNUNET_DISK_file_write(f[c_s], data, strlen(data)))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Cannot write data to log file `%s'\n",filename_slaves[c_s]);
- GNUNET_free (data);
- }
-
- for (cur_lt = l->lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next)
{
- if (l->verbose)
- fprintf (stderr,
- "Master [%u]: timestamp %llu %llu ; %u %u %u ; %u %u %u\n",
- l->lp[c_m].peer->no,
- (long long unsigned int) cur_lt->timestamp.abs_value_us,
- (long long unsigned int) GNUNET_TIME_absolute_get_difference(l->lp[c_m].start,
- cur_lt->timestamp).rel_value_us / 1000,
- cur_lt->total_messages_sent,
- cur_lt->total_bytes_sent,
- cur_lt->total_throughput_send,
- cur_lt->total_messages_received,
- cur_lt->total_bytes_received,
- cur_lt->total_throughput_recv);
-
- /* Assembling master string */
- GNUNET_asprintf (&data, "%llu;%llu;%u;%u;%u;%u;%u;%u;\n",
- (long long unsigned int) cur_lt->timestamp.abs_value_us,
- (long long unsigned int) GNUNET_TIME_absolute_get_difference(l->lp[c_m].start,
- cur_lt->timestamp).rel_value_us / 1000,
- cur_lt->total_messages_sent,
- cur_lt->total_bytes_sent,
- cur_lt->total_throughput_send,
- cur_lt->total_messages_received,
- cur_lt->total_bytes_received,
- cur_lt->total_throughput_recv);
+ GNUNET_asprintf(&filename_master, "%s_%llu_master%u_%s",
+ experiment_name, timestamp.abs_value_us, c_m, l->name);
+ fprintf(stderr, "Writing data for master %u to file `%s'\n",
+ c_m, filename_master);
+
+ f_m = GNUNET_DISK_file_open(filename_master,
+ GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
+ GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
+ if (NULL == f_m)
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename_master);
+ GNUNET_free(filename_master);
+ return;
+ }
+ GNUNET_asprintf(&data, "# master %u; experiment : %s\n"
+ "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; \n",
+ c_m, experiment_name);
if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_m, data, strlen(data)))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Cannot write data to master file %u\n", c_m);
- GNUNET_free (data);
-
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ "Cannot write data to log file `%s'\n", filename_master);
+ GNUNET_free(data);
for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++)
- {
- plt = &cur_lt->slaves_log[c_s];
- /* Log partners */
-
- /* Assembling slave string */
- GNUNET_asprintf(&data,
- "%llu;%llu;%u;%u;%u;%u;%u;%u;%.3f;%u;%u;%u;%u;%u;%u;%u;%.3f;%.3f\n",
- (long long unsigned int) cur_lt->timestamp.abs_value_us,
- (long long unsigned int) GNUNET_TIME_absolute_get_difference(l->lp[c_m].start,
- cur_lt->timestamp).rel_value_us / 1000,
- plt->total_messages_sent,
- plt->total_bytes_sent,
- plt->throughput_sent,
- plt->total_messages_received,
- plt->total_bytes_received,
- plt->throughput_recv,
- (double) plt->app_rtt / 1000,
- plt->bandwidth_in,
- plt->bandwidth_out,
- plt->ats_delay,
- plt->ats_distance,
- plt->ats_network_type,
- plt->ats_utilization_out,
- plt->ats_utilization_in,
- plt->pref_bandwidth,
- plt->pref_delay);
-
- if (l->verbose)
- fprintf (stderr,
- "\t Slave [%u]: %u %u %u ; %u %u %u rtt %u delay %llu bw_in %u bw_out %u \n",
- plt->slave->no,
- plt->total_messages_sent,
- plt->total_bytes_sent,
- plt->throughput_sent,
- plt->total_messages_received,
- plt->total_bytes_received,
- plt->throughput_recv,
- plt->app_rtt,
- (long long unsigned int) plt->ats_delay.rel_value_us,
- plt->bandwidth_in,
- plt->bandwidth_out);
-
- if (GNUNET_SYSERR == GNUNET_DISK_file_write(f[c_s], data, strlen(data)))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Cannot write data to log file `%s'\n", filename_slaves[c_s]);
- GNUNET_free (data);
-
- }
- }
+ {
+ GNUNET_asprintf(&filename_slaves[c_s], "%s_%llu_master%u_slave_%u_%s",
+ tmp_exp_name, timestamp.abs_value_us, c_m, c_s, l->name);
+
+ fprintf(stderr, "Writing data for master %u slave %u to file `%s'\n",
+ c_m, c_s, filename_slaves[c_s]);
+
+ f[c_s] = GNUNET_DISK_file_open(filename_slaves[c_s],
+ GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
+ GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
+ if (NULL == f[c_s])
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename_slaves[c_s]);
+ GNUNET_free(filename_slaves[c_s]);
+ GNUNET_break(GNUNET_OK == GNUNET_DISK_file_close(f_m));
+ GNUNET_free(filename_master);
+ return;
+ }
+
+ /* Header */
+ GNUNET_asprintf(&data, "# master %u; slave %u ; experiment : %s\n"
+ "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; " \
+ "rtt; bw in; bw out; ats_cost_lan; ats_cost_wlan; ats_delay; ats_distance; ats_network_type; ats_utilization_up ;ats_utilization_down;" \
+ "pref bandwidth; pref delay\n",
+ c_m, c_s, experiment_name);
+ if (GNUNET_SYSERR == GNUNET_DISK_file_write(f[c_s], data, strlen(data)))
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ "Cannot write data to log file `%s'\n", filename_slaves[c_s]);
+ GNUNET_free(data);
+ }
- for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++)
- {
- if (GNUNET_SYSERR == GNUNET_DISK_file_close(f[c_s]))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Cannot close log file for master[%u] slave[%u]\n", c_m, c_s);
- continue;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Data file successfully written to log file for `%s'\n",
- filename_slaves[c_s]);
- }
+ for (cur_lt = l->lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next)
+ {
+ if (l->verbose)
+ fprintf(stderr,
+ "Master [%u]: timestamp %llu %llu ; %u %u %u ; %u %u %u\n",
+ l->lp[c_m].peer->no,
+ (long long unsigned int)cur_lt->timestamp.abs_value_us,
+ (long long unsigned int)GNUNET_TIME_absolute_get_difference(l->lp[c_m].start,
+ cur_lt->timestamp).rel_value_us / 1000,
+ cur_lt->total_messages_sent,
+ cur_lt->total_bytes_sent,
+ cur_lt->total_throughput_send,
+ cur_lt->total_messages_received,
+ cur_lt->total_bytes_received,
+ cur_lt->total_throughput_recv);
+
+ /* Assembling master string */
+ GNUNET_asprintf(&data, "%llu;%llu;%u;%u;%u;%u;%u;%u;\n",
+ (long long unsigned int)cur_lt->timestamp.abs_value_us,
+ (long long unsigned int)GNUNET_TIME_absolute_get_difference(l->lp[c_m].start,
+ cur_lt->timestamp).rel_value_us / 1000,
+ cur_lt->total_messages_sent,
+ cur_lt->total_bytes_sent,
+ cur_lt->total_throughput_send,
+ cur_lt->total_messages_received,
+ cur_lt->total_bytes_received,
+ cur_lt->total_throughput_recv);
+
+ if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_m, data, strlen(data)))
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ "Cannot write data to master file %u\n", c_m);
+ GNUNET_free(data);
+
+
+ for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++)
+ {
+ plt = &cur_lt->slaves_log[c_s];
+ /* Log partners */
+
+ /* Assembling slave string */
+ GNUNET_asprintf(&data,
+ "%llu;%llu;%u;%u;%u;%u;%u;%u;%.3f;%u;%u;%u;%u;%u;%u;%u;%.3f;%.3f\n",
+ (long long unsigned int)cur_lt->timestamp.abs_value_us,
+ (long long unsigned int)GNUNET_TIME_absolute_get_difference(l->lp[c_m].start,
+ cur_lt->timestamp).rel_value_us / 1000,
+ plt->total_messages_sent,
+ plt->total_bytes_sent,
+ plt->throughput_sent,
+ plt->total_messages_received,
+ plt->total_bytes_received,
+ plt->throughput_recv,
+ (double)plt->app_rtt / 1000,
+ plt->bandwidth_in,
+ plt->bandwidth_out,
+ plt->ats_delay,
+ plt->ats_distance,
+ plt->ats_network_type,
+ plt->ats_utilization_out,
+ plt->ats_utilization_in,
+ plt->pref_bandwidth,
+ plt->pref_delay);
+
+ if (l->verbose)
+ fprintf(stderr,
+ "\t Slave [%u]: %u %u %u ; %u %u %u rtt %u delay %llu bw_in %u bw_out %u \n",
+ plt->slave->no,
+ plt->total_messages_sent,
+ plt->total_bytes_sent,
+ plt->throughput_sent,
+ plt->total_messages_received,
+ plt->total_bytes_received,
+ plt->throughput_recv,
+ plt->app_rtt,
+ (long long unsigned int)plt->ats_delay.rel_value_us,
+ plt->bandwidth_in,
+ plt->bandwidth_out);
+
+ if (GNUNET_SYSERR == GNUNET_DISK_file_write(f[c_s], data, strlen(data)))
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ "Cannot write data to log file `%s'\n", filename_slaves[c_s]);
+ GNUNET_free(data);
+ }
+ }
- if (GNUNET_SYSERR == GNUNET_DISK_file_close(f_m))
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "close",
- filename_master);
- GNUNET_free (filename_master);
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Data file successfully written to log file for master `%s'\n", filename_master);
+ for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++)
+ {
+ if (GNUNET_SYSERR == GNUNET_DISK_file_close(f[c_s]))
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ "Cannot close log file for master[%u] slave[%u]\n", c_m, c_s);
+ continue;
+ }
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Data file successfully written to log file for `%s'\n",
+ filename_slaves[c_s]);
+ }
- if (GNUNET_YES == plots)
- {
- write_throughput_gnuplot_script (filename_master, &l->lp[c_m], filename_slaves, l->num_slaves);
- write_rtt_gnuplot_script (filename_master, &l->lp[c_m], filename_slaves, l->num_slaves);
- write_bw_gnuplot_script (filename_master, &l->lp[c_m], filename_slaves, l->num_slaves);
+ if (GNUNET_SYSERR == GNUNET_DISK_file_close(f_m))
+ {
+ GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR,
+ "close",
+ filename_master);
+ GNUNET_free(filename_master);
+ return;
+ }
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Data file successfully written to log file for master `%s'\n", filename_master);
+
+ if (GNUNET_YES == plots)
+ {
+ write_throughput_gnuplot_script(filename_master, &l->lp[c_m], filename_slaves, l->num_slaves);
+ write_rtt_gnuplot_script(filename_master, &l->lp[c_m], filename_slaves, l->num_slaves);
+ write_bw_gnuplot_script(filename_master, &l->lp[c_m], filename_slaves, l->num_slaves);
+ }
}
- }
- GNUNET_free (filename_master);
+ GNUNET_free(filename_master);
}
/**
@@ -620,7 +615,7 @@ GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l,
* @param l logging handle to use
*/
void
-GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l)
+GNUNET_ATS_TEST_logging_now(struct LoggingHandle *l)
{
struct LoggingPeer *bp;
struct PeerLoggingTimestep *mlt;
@@ -638,180 +633,180 @@ GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l)
return;
for (c_m = 0; c_m < l->num_masters; c_m++)
- {
- bp = &l->lp[c_m];
- mlt = GNUNET_new (struct PeerLoggingTimestep);
- GNUNET_CONTAINER_DLL_insert_tail(l->lp[c_m].head, l->lp[c_m].tail, mlt);
- prev_log_mlt = mlt->prev;
-
- /* Collect data */
- /* Current master state */
- mlt->timestamp = GNUNET_TIME_absolute_get();
- mlt->total_bytes_sent = bp->peer->total_bytes_sent;
- mlt->total_messages_sent = bp->peer->total_messages_sent;
- mlt->total_bytes_received = bp->peer->total_bytes_received;
- mlt->total_messages_received = bp->peer->total_messages_received;
-
- /* Throughput */
- if (NULL == prev_log_mlt)
- {
- /* Get difference to start */
- delta = GNUNET_TIME_absolute_get_difference (l->lp[c_m].start, mlt->timestamp);
- }
- else
- {
- /* Get difference to last timestep */
- delta = GNUNET_TIME_absolute_get_difference (mlt->prev->timestamp, mlt->timestamp);
- }
-
- /* Multiplication factor for throughput calculation */
- mult = (double) GNUNET_TIME_UNIT_SECONDS.rel_value_us / (delta.rel_value_us);
-
- /* Total throughput */
- if (NULL != prev_log_mlt)
- {
- if (mlt->total_bytes_sent - mlt->prev->total_bytes_sent > 0)
- {
- mlt->total_throughput_send = mult * (mlt->total_bytes_sent - mlt->prev->total_bytes_sent);
- }
- else
- {
- mlt->total_throughput_send = 0;
- // mlt->total_throughput_send = prev_log_mlt->total_throughput_send; /* no msgs send */
- }
-
- if (mlt->total_bytes_received - mlt->prev->total_bytes_received > 0)
- {
- mlt->total_throughput_recv = mult * (mlt->total_bytes_received - mlt->prev->total_bytes_received);
- }
- else
- {
- mlt->total_throughput_recv = 0;
- //mlt->total_throughput_recv = prev_log_mlt->total_throughput_recv; /* no msgs received */
- }
- }
- else
- {
- mlt->total_throughput_send = mult * mlt->total_bytes_sent;
- mlt->total_throughput_recv = mult * mlt->total_bytes_received;
- }
-
- if (GNUNET_YES == l->verbose)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Master[%u] delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n",
- c_m,
- (unsigned long long) delta.rel_value_us,
- mlt->total_bytes_sent,
- mlt->total_bytes_received,
- mlt->total_throughput_send,
- mlt->total_throughput_recv);
- }
-
- mlt->slaves_log = GNUNET_malloc (bp->peer->num_partners *
- sizeof (struct PartnerLoggingTimestep));
-
- for (c_s = 0; c_s < bp->peer->num_partners; c_s++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Collect logging data master[%u] slave [%u]\n", c_m, c_s);
-
- p = &bp->peer->partners[c_s];
- slt = &mlt->slaves_log[c_s];
-
- slt->slave = p->dest;
- /* Bytes sent from master to this slave */
- slt->total_bytes_sent = p->bytes_sent;
- /* Messages sent from master to this slave */
- slt->total_messages_sent = p->messages_sent;
- /* Bytes master received from this slave */
- slt->total_bytes_received = p->bytes_received;
- /* Messages master received from this slave */
- slt->total_messages_received = p->messages_received;
- slt->total_app_rtt = p->total_app_rtt;
- /* ats performance information */
- slt->ats_delay = p->props.delay;
- slt->ats_distance = p->props.distance;
- slt->ats_network_type = p->props.scope;
- slt->ats_utilization_in = p->props.utilization_out;
- slt->ats_utilization_out = p->props.utilization_out;
- slt->bandwidth_in = p->bandwidth_in;
- slt->bandwidth_out = p->bandwidth_out;
- slt->pref_bandwidth = p->pref_bandwidth;
- slt->pref_delay = p->pref_delay;
-
- /* Total application level rtt */
+ bp = &l->lp[c_m];
+ mlt = GNUNET_new(struct PeerLoggingTimestep);
+ GNUNET_CONTAINER_DLL_insert_tail(l->lp[c_m].head, l->lp[c_m].tail, mlt);
+ prev_log_mlt = mlt->prev;
+
+ /* Collect data */
+ /* Current master state */
+ mlt->timestamp = GNUNET_TIME_absolute_get();
+ mlt->total_bytes_sent = bp->peer->total_bytes_sent;
+ mlt->total_messages_sent = bp->peer->total_messages_sent;
+ mlt->total_bytes_received = bp->peer->total_bytes_received;
+ mlt->total_messages_received = bp->peer->total_messages_received;
+
+ /* Throughput */
if (NULL == prev_log_mlt)
- {
- if (0 != slt->total_messages_sent)
- app_rtt = slt->total_app_rtt / slt->total_messages_sent;
- else
- app_rtt = 0;
- }
+ {
+ /* Get difference to start */
+ delta = GNUNET_TIME_absolute_get_difference(l->lp[c_m].start, mlt->timestamp);
+ }
else
- {
- prev_log_slt = &prev_log_mlt->slaves_log[c_s];
- if ((slt->total_messages_sent - prev_log_slt->total_messages_sent) > 0)
- app_rtt = (slt->total_app_rtt - prev_log_slt->total_app_rtt) /
- (slt->total_messages_sent - prev_log_slt->total_messages_sent);
- else
{
- app_rtt = prev_log_slt->app_rtt; /* No messages were */
+ /* Get difference to last timestep */
+ delta = GNUNET_TIME_absolute_get_difference(mlt->prev->timestamp, mlt->timestamp);
}
- }
- slt->app_rtt = app_rtt;
- /* Partner throughput */
+ /* Multiplication factor for throughput calculation */
+ mult = (double)GNUNET_TIME_UNIT_SECONDS.rel_value_us / (delta.rel_value_us);
+
+ /* Total throughput */
if (NULL != prev_log_mlt)
- {
- prev_log_slt = &prev_log_mlt->slaves_log[c_s];
- if (slt->total_bytes_sent > prev_log_slt->total_bytes_sent)
- slt->throughput_sent = mult * (slt->total_bytes_sent - prev_log_slt->total_bytes_sent);
- else
- slt->throughput_sent = 0;
-
- if (slt->total_bytes_received > prev_log_slt->total_bytes_received)
- slt->throughput_recv = mult *
- (slt->total_bytes_received - prev_log_slt->total_bytes_received);
- else
- slt->throughput_recv = 0;
- }
+ {
+ if (mlt->total_bytes_sent - mlt->prev->total_bytes_sent > 0)
+ {
+ mlt->total_throughput_send = mult * (mlt->total_bytes_sent - mlt->prev->total_bytes_sent);
+ }
+ else
+ {
+ mlt->total_throughput_send = 0;
+ // mlt->total_throughput_send = prev_log_mlt->total_throughput_send; /* no msgs send */
+ }
+
+ if (mlt->total_bytes_received - mlt->prev->total_bytes_received > 0)
+ {
+ mlt->total_throughput_recv = mult * (mlt->total_bytes_received - mlt->prev->total_bytes_received);
+ }
+ else
+ {
+ mlt->total_throughput_recv = 0;
+ //mlt->total_throughput_recv = prev_log_mlt->total_throughput_recv; /* no msgs received */
+ }
+ }
else
- {
- slt->throughput_sent = mult * slt->total_bytes_sent;
- slt->throughput_recv = mult * slt->total_bytes_received;
- }
+ {
+ mlt->total_throughput_send = mult * mlt->total_bytes_sent;
+ mlt->total_throughput_recv = mult * mlt->total_bytes_received;
+ }
if (GNUNET_YES == l->verbose)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Master [%u] -> Slave [%u]: delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n",
- c_m, c_s,
- (unsigned long long) delta.rel_value_us,
- mlt->total_bytes_sent,
- mlt->total_bytes_received,
- slt->throughput_sent,
- slt->throughput_recv);
- }
- else
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Master [%u]: slave [%u]\n",
- bp->peer->no, p->dest->no);
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ "Master[%u] delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n",
+ c_m,
+ (unsigned long long)delta.rel_value_us,
+ mlt->total_bytes_sent,
+ mlt->total_bytes_received,
+ mlt->total_throughput_send,
+ mlt->total_throughput_recv);
+ }
+
+ mlt->slaves_log = GNUNET_malloc(bp->peer->num_partners *
+ sizeof(struct PartnerLoggingTimestep));
+
+ for (c_s = 0; c_s < bp->peer->num_partners; c_s++)
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Collect logging data master[%u] slave [%u]\n", c_m, c_s);
+
+ p = &bp->peer->partners[c_s];
+ slt = &mlt->slaves_log[c_s];
+
+ slt->slave = p->dest;
+ /* Bytes sent from master to this slave */
+ slt->total_bytes_sent = p->bytes_sent;
+ /* Messages sent from master to this slave */
+ slt->total_messages_sent = p->messages_sent;
+ /* Bytes master received from this slave */
+ slt->total_bytes_received = p->bytes_received;
+ /* Messages master received from this slave */
+ slt->total_messages_received = p->messages_received;
+ slt->total_app_rtt = p->total_app_rtt;
+ /* ats performance information */
+ slt->ats_delay = p->props.delay;
+ slt->ats_distance = p->props.distance;
+ slt->ats_network_type = p->props.scope;
+ slt->ats_utilization_in = p->props.utilization_out;
+ slt->ats_utilization_out = p->props.utilization_out;
+ slt->bandwidth_in = p->bandwidth_in;
+ slt->bandwidth_out = p->bandwidth_out;
+ slt->pref_bandwidth = p->pref_bandwidth;
+ slt->pref_delay = p->pref_delay;
+
+ /* Total application level rtt */
+ if (NULL == prev_log_mlt)
+ {
+ if (0 != slt->total_messages_sent)
+ app_rtt = slt->total_app_rtt / slt->total_messages_sent;
+ else
+ app_rtt = 0;
+ }
+ else
+ {
+ prev_log_slt = &prev_log_mlt->slaves_log[c_s];
+ if ((slt->total_messages_sent - prev_log_slt->total_messages_sent) > 0)
+ app_rtt = (slt->total_app_rtt - prev_log_slt->total_app_rtt) /
+ (slt->total_messages_sent - prev_log_slt->total_messages_sent);
+ else
+ {
+ app_rtt = prev_log_slt->app_rtt; /* No messages were */
+ }
+ }
+ slt->app_rtt = app_rtt;
+
+ /* Partner throughput */
+ if (NULL != prev_log_mlt)
+ {
+ prev_log_slt = &prev_log_mlt->slaves_log[c_s];
+ if (slt->total_bytes_sent > prev_log_slt->total_bytes_sent)
+ slt->throughput_sent = mult * (slt->total_bytes_sent - prev_log_slt->total_bytes_sent);
+ else
+ slt->throughput_sent = 0;
+
+ if (slt->total_bytes_received > prev_log_slt->total_bytes_received)
+ slt->throughput_recv = mult *
+ (slt->total_bytes_received - prev_log_slt->total_bytes_received);
+ else
+ slt->throughput_recv = 0;
+ }
+ else
+ {
+ slt->throughput_sent = mult * slt->total_bytes_sent;
+ slt->throughput_recv = mult * slt->total_bytes_received;
+ }
+
+ if (GNUNET_YES == l->verbose)
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ "Master [%u] -> Slave [%u]: delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n",
+ c_m, c_s,
+ (unsigned long long)delta.rel_value_us,
+ mlt->total_bytes_sent,
+ mlt->total_bytes_received,
+ slt->throughput_sent,
+ slt->throughput_recv);
+ }
+ else
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Master [%u]: slave [%u]\n",
+ bp->peer->no, p->dest->no);
+ }
}
- }
}
static void
-collect_log_task (void *cls)
+collect_log_task(void *cls)
{
struct LoggingHandle *l = cls;
l->log_task = NULL;
- GNUNET_ATS_TEST_logging_now (l);
- l->log_task = GNUNET_SCHEDULER_add_delayed (l->frequency,
- &collect_log_task,
- l);
+ GNUNET_ATS_TEST_logging_now(l);
+ l->log_task = GNUNET_SCHEDULER_add_delayed(l->frequency,
+ &collect_log_task,
+ l);
}
@@ -821,20 +816,20 @@ collect_log_task (void *cls)
* @param l the logging handle
*/
void
-GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l)
+GNUNET_ATS_TEST_logging_stop(struct LoggingHandle *l)
{
- if (GNUNET_YES!= l->running)
+ if (GNUNET_YES != l->running)
return;
if (NULL != l->log_task)
- {
- GNUNET_SCHEDULER_cancel (l->log_task);
- l->log_task = NULL;
- }
+ {
+ GNUNET_SCHEDULER_cancel(l->log_task);
+ l->log_task = NULL;
+ }
l->running = GNUNET_NO;
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- _("Stop logging\n"));
+ _("Stop logging\n"));
}
/**
@@ -843,26 +838,26 @@ GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l)
* @param l the logging handle
*/
void
-GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l)
+GNUNET_ATS_TEST_logging_clean_up(struct LoggingHandle *l)
{
int c_m;
struct PeerLoggingTimestep *cur;
if (GNUNET_YES == l->running)
- GNUNET_ATS_TEST_logging_stop (l);
+ GNUNET_ATS_TEST_logging_stop(l);
for (c_m = 0; c_m < l->num_masters; c_m++)
- {
- while (NULL != (cur = l->lp[c_m].head))
{
- GNUNET_CONTAINER_DLL_remove (l->lp[c_m].head, l->lp[c_m].tail, cur);
- GNUNET_free (cur->slaves_log);
- GNUNET_free (cur);
+ while (NULL != (cur = l->lp[c_m].head))
+ {
+ GNUNET_CONTAINER_DLL_remove(l->lp[c_m].head, l->lp[c_m].tail, cur);
+ GNUNET_free(cur->slaves_log);
+ GNUNET_free(cur);
+ }
}
- }
- GNUNET_free (l->lp);
- GNUNET_free (l);
+ GNUNET_free(l->lp);
+ GNUNET_free(l);
}
@@ -889,24 +884,24 @@ GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency,
int c_m;
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- _("Start logging `%s'\n"), testname);
+ _("Start logging `%s'\n"), testname);
- l = GNUNET_new (struct LoggingHandle);
+ l = GNUNET_new(struct LoggingHandle);
l->num_masters = num_masters;
l->num_slaves = num_slaves;
l->name = testname;
l->frequency = log_frequency;
l->verbose = verbose;
- l->lp = GNUNET_malloc (num_masters * sizeof (struct LoggingPeer));
+ l->lp = GNUNET_malloc(num_masters * sizeof(struct LoggingPeer));
- for (c_m = 0; c_m < num_masters; c_m ++)
- {
- l->lp[c_m].peer = &masters[c_m];
- l->lp[c_m].start = GNUNET_TIME_absolute_get();
- }
+ for (c_m = 0; c_m < num_masters; c_m++)
+ {
+ l->lp[c_m].peer = &masters[c_m];
+ l->lp[c_m].start = GNUNET_TIME_absolute_get();
+ }
/* Schedule logging task */
- l->log_task = GNUNET_SCHEDULER_add_now (&collect_log_task, l);
+ l->log_task = GNUNET_SCHEDULER_add_now(&collect_log_task, l);
l->running = GNUNET_YES;
return l;
diff --git a/src/ats-tests/ats-testing-preferences.c b/src/ats-tests/ats-testing-preferences.c
index ba2f133b9..a14e66736 100644
--- a/src/ats-tests/ats-testing-preferences.c
+++ b/src/ats-tests/ats-testing-preferences.c
@@ -1,19 +1,19 @@
/*
- This file is part of GNUnet.
- Copyright (C) 2010-2013 GNUnet e.V.
+ This file is part of GNUnet.
+ Copyright (C) 2010-2013 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 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.
+ 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/>.
+ 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
*/
@@ -33,76 +33,82 @@ static struct PreferenceGenerator *pg_tail;
extern struct GNUNET_ATS_TEST_Topology *top;
static double
-get_preference (struct PreferenceGenerator *pg)
+get_preference(struct PreferenceGenerator *pg)
{
struct GNUNET_TIME_Relative time_delta;
double delta_value;
double pref_value;
/* Calculate the current preference value */
- switch (pg->type) {
+ switch (pg->type)
+ {
case GNUNET_ATS_TEST_TG_CONSTANT:
pref_value = pg->base_value;
break;
+
case GNUNET_ATS_TEST_TG_LINEAR:
time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start);
/* Calculate point of time in the current period */
time_delta.rel_value_us = time_delta.rel_value_us %
- pg->duration_period.rel_value_us;
- delta_value = ((double) time_delta.rel_value_us /
- pg->duration_period.rel_value_us) * (pg->max_value - pg->base_value);
+ pg->duration_period.rel_value_us;
+ delta_value = ((double)time_delta.rel_value_us /
+ pg->duration_period.rel_value_us) * (pg->max_value - pg->base_value);
if ((pg->max_value < pg->base_value) &&
((pg->max_value - pg->base_value) > pg->base_value))
- {
- /* This will cause an underflow */
- GNUNET_break (0);
- }
+ {
+ /* This will cause an underflow */
+ GNUNET_break(0);
+ }
pref_value = pg->base_value + delta_value;
break;
+
case GNUNET_ATS_TEST_TG_RANDOM:
- delta_value = (double) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- 10000 * (pg->max_value - pg->base_value)) / 10000;
+ delta_value = (double)GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK,
+ 10000 * (pg->max_value - pg->base_value)) / 10000;
pref_value = pg->base_value + delta_value;
break;
+
case GNUNET_ATS_TEST_TG_SINUS:
time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start);
/* Calculate point of time in the current period */
time_delta.rel_value_us = time_delta.rel_value_us %
- pg->duration_period.rel_value_us;
+ pg->duration_period.rel_value_us;
if ((pg->max_value - pg->base_value) > pg->base_value)
- {
- /* This will cause an underflow for second half of sinus period,
- * will be detected in general when experiments are loaded */
- GNUNET_break (0);
- }
+ {
+ /* This will cause an underflow for second half of sinus period,
+ * will be detected in general when experiments are loaded */
+ GNUNET_break(0);
+ }
delta_value = (pg->max_value - pg->base_value) *
- sin ( (2 * M_PI) / ((double) pg->duration_period.rel_value_us) *
- time_delta.rel_value_us);
+ sin((2 * M_PI) / ((double)pg->duration_period.rel_value_us) *
+ time_delta.rel_value_us);
pref_value = pg->base_value + delta_value;
break;
+
default:
pref_value = 0.0;
break;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Current preference value is %f\n",
- pref_value);
+ }
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Current preference value is %f\n",
+ pref_value);
return pref_value;
}
static void
-set_pref_task (void *cls)
+set_pref_task(void *cls)
{
struct BenchmarkPartner *p = cls;
double pref_value;
+
p->pg->set_task = NULL;
- pref_value = get_preference (p->pg);
+ pref_value = get_preference(p->pg);
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "Setting preference for master [%u] and slave [%u] for %s to %f\n",
- p->me->no, p->dest->no,
- GNUNET_ATS_print_preference_type (p->pg->kind), pref_value);
+ "Setting preference for master [%u] and slave [%u] for %s to %f\n",
+ p->me->no, p->dest->no,
+ GNUNET_ATS_print_preference_type(p->pg->kind), pref_value);
GNUNET_ATS_performance_change_preference(p->me->ats_perf_handle,
&p->dest->id,
@@ -110,20 +116,22 @@ set_pref_task (void *cls)
pref_value,
GNUNET_ATS_PREFERENCE_END);
- switch (p->pg->kind) {
+ switch (p->pg->kind)
+ {
case GNUNET_ATS_PREFERENCE_BANDWIDTH:
p->pref_bandwidth = pref_value;
break;
+
case GNUNET_ATS_PREFERENCE_LATENCY:
p->pref_delay = pref_value;
break;
+
default:
break;
- }
-
- p->pg->set_task = GNUNET_SCHEDULER_add_delayed (p->pg->frequency,
- set_pref_task, p);
+ }
+ p->pg->set_task = GNUNET_SCHEDULER_add_delayed(p->pg->frequency,
+ set_pref_task, p);
}
@@ -142,25 +150,25 @@ set_pref_task (void *cls)
* @return the preference generator
*/
struct PreferenceGenerator *
-GNUNET_ATS_TEST_generate_preferences_start (struct BenchmarkPeer *src,
- struct BenchmarkPartner *dest,
- enum GeneratorType type,
- unsigned int base_value,
- unsigned int value_rate,
- struct GNUNET_TIME_Relative period,
- struct GNUNET_TIME_Relative frequency,
- enum GNUNET_ATS_PreferenceKind kind)
+GNUNET_ATS_TEST_generate_preferences_start(struct BenchmarkPeer *src,
+ struct BenchmarkPartner *dest,
+ enum GeneratorType type,
+ unsigned int base_value,
+ unsigned int value_rate,
+ struct GNUNET_TIME_Relative period,
+ struct GNUNET_TIME_Relative frequency,
+ enum GNUNET_ATS_PreferenceKind kind)
{
struct PreferenceGenerator *pg;
if (NULL != dest->pg)
- {
- GNUNET_break (0);
- return NULL;
- }
+ {
+ GNUNET_break(0);
+ return NULL;
+ }
- pg = GNUNET_new (struct PreferenceGenerator);
- GNUNET_CONTAINER_DLL_insert (pg_head, pg_tail, pg);
+ pg = GNUNET_new(struct PreferenceGenerator);
+ GNUNET_CONTAINER_DLL_insert(pg_head, pg_tail, pg);
pg->type = type;
pg->src = src;
pg->dest = dest;
@@ -171,58 +179,63 @@ GNUNET_ATS_TEST_generate_preferences_start (struct BenchmarkPeer *src,
pg->frequency = frequency;
pg->time_start = GNUNET_TIME_absolute_get();
- switch (type) {
+ switch (type)
+ {
case GNUNET_ATS_TEST_TG_CONSTANT:
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Setting up constant preference generator master[%u] `%s' and slave [%u] `%s' max %u Bips\n",
- dest->me->no, GNUNET_i2s (&dest->me->id),
- dest->dest->no, GNUNET_i2s (&dest->dest->id),
- base_value);
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Setting up constant preference generator master[%u] `%s' and slave [%u] `%s' max %u Bips\n",
+ dest->me->no, GNUNET_i2s(&dest->me->id),
+ dest->dest->no, GNUNET_i2s(&dest->dest->id),
+ base_value);
break;
+
case GNUNET_ATS_TEST_TG_LINEAR:
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Setting up linear preference generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bips\n",
- dest->me->no, GNUNET_i2s (&dest->me->id),
- dest->dest->no, GNUNET_i2s (&dest->dest->id),
- base_value, value_rate);
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Setting up linear preference generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bips\n",
+ dest->me->no, GNUNET_i2s(&dest->me->id),
+ dest->dest->no, GNUNET_i2s(&dest->dest->id),
+ base_value, value_rate);
break;
+
case GNUNET_ATS_TEST_TG_SINUS:
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Setting up sinus preference generator master[%u] `%s' and slave [%u] `%s' baserate %u Bips, amplitude %u Bps\n",
- dest->me->no, GNUNET_i2s (&dest->me->id),
- dest->dest->no, GNUNET_i2s (&dest->dest->id),
- base_value, value_rate);
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Setting up sinus preference generator master[%u] `%s' and slave [%u] `%s' baserate %u Bips, amplitude %u Bps\n",
+ dest->me->no, GNUNET_i2s(&dest->me->id),
+ dest->dest->no, GNUNET_i2s(&dest->dest->id),
+ base_value, value_rate);
break;
+
case GNUNET_ATS_TEST_TG_RANDOM:
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Setting up random preference generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bps\n",
- dest->me->no, GNUNET_i2s (&dest->me->id),
- dest->dest->no, GNUNET_i2s (&dest->dest->id),
- base_value, value_rate);
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Setting up random preference generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bps\n",
+ dest->me->no, GNUNET_i2s(&dest->me->id),
+ dest->dest->no, GNUNET_i2s(&dest->dest->id),
+ base_value, value_rate);
break;
+
default:
break;
- }
+ }
dest->pg = pg;
- pg->set_task = GNUNET_SCHEDULER_add_now (&set_pref_task, dest);
+ pg->set_task = GNUNET_SCHEDULER_add_now(&set_pref_task, dest);
return pg;
}
void
-GNUNET_ATS_TEST_generate_preferences_stop (struct PreferenceGenerator *pg)
+GNUNET_ATS_TEST_generate_preferences_stop(struct PreferenceGenerator *pg)
{
- GNUNET_CONTAINER_DLL_remove (pg_head, pg_tail, pg);
+ GNUNET_CONTAINER_DLL_remove(pg_head, pg_tail, pg);
pg->dest->pg = NULL;
if (NULL != pg->set_task)
- {
- GNUNET_SCHEDULER_cancel (pg->set_task);
- pg->set_task = NULL;
- }
+ {
+ GNUNET_SCHEDULER_cancel(pg->set_task);
+ pg->set_task = NULL;
+ }
- GNUNET_free (pg);
+ GNUNET_free(pg);
}
@@ -230,16 +243,17 @@ GNUNET_ATS_TEST_generate_preferences_stop (struct PreferenceGenerator *pg)
* Stop all preferences generators
*/
void
-GNUNET_ATS_TEST_generate_preferences_stop_all ()
+GNUNET_ATS_TEST_generate_preferences_stop_all()
{
struct PreferenceGenerator *cur;
struct PreferenceGenerator *next;
+
next = pg_head;
for (cur = next; NULL != cur; cur = next)
- {
+ {
next = cur->next;
GNUNET_ATS_TEST_generate_preferences_stop(cur);
- }
+ }
}
/* end of file ats-testing-preferences.c */
diff --git a/src/ats-tests/ats-testing-traffic.c b/src/ats-tests/ats-testing-traffic.c
index 3756596c9..01462980c 100644
--- a/src/ats-tests/ats-testing-traffic.c
+++ b/src/ats-tests/ats-testing-traffic.c
@@ -1,19 +1,19 @@
/*
- This file is part of GNUnet.
- Copyright (C) 2010-2013, 2016 GNUnet e.V.
+ This file is part of GNUnet.
+ Copyright (C) 2010-2013, 2016 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 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.
+ 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/>.
+ 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
*/
@@ -33,7 +33,7 @@ static struct TrafficGenerator *tg_tail;
extern struct GNUNET_ATS_TEST_Topology *top;
static struct GNUNET_TIME_Relative
-get_delay (struct TrafficGenerator *tg)
+get_delay(struct TrafficGenerator *tg)
{
struct GNUNET_TIME_Relative delay;
struct GNUNET_TIME_Relative time_delta;
@@ -43,65 +43,70 @@ get_delay (struct TrafficGenerator *tg)
delay.rel_value_us = 0;
/* Calculate the current transmission rate based on the type of traffic */
- switch (tg->type) {
+ switch (tg->type)
+ {
case GNUNET_ATS_TEST_TG_CONSTANT:
if (UINT32_MAX == tg->base_rate)
return GNUNET_TIME_UNIT_ZERO;
cur_rate = tg->base_rate;
break;
+
case GNUNET_ATS_TEST_TG_LINEAR:
time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start);
/* Calculate point of time in the current period */
time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us;
- delta_rate = ((double) time_delta.rel_value_us / tg->duration_period.rel_value_us) *
- (tg->max_rate - tg->base_rate);
+ delta_rate = ((double)time_delta.rel_value_us / tg->duration_period.rel_value_us) *
+ (tg->max_rate - tg->base_rate);
if ((tg->max_rate < tg->base_rate) && ((tg->max_rate - tg->base_rate) > tg->base_rate))
- {
- /* This will cause an underflow */
- GNUNET_break (0);
- }
+ {
+ /* This will cause an underflow */
+ GNUNET_break(0);
+ }
cur_rate = tg->base_rate + delta_rate;
break;
+
case GNUNET_ATS_TEST_TG_RANDOM:
- cur_rate = tg->base_rate + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- tg->max_rate - tg->base_rate);
+ cur_rate = tg->base_rate + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK,
+ tg->max_rate - tg->base_rate);
break;
+
case GNUNET_ATS_TEST_TG_SINUS:
time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start);
/* Calculate point of time in the cu