#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_transport_service.h"
#include "gnunet_transport_manipulation_service.h"
#include "gnunet_ats_service.h"
#include "gnunet_testing_lib.h"
#include <sqlite3.h>
Go to the source code of this file.
Data Structures | |
struct | WhiteListRow |
Whilelist entry. More... | |
Macros | |
#define | LOG(type, ...) GNUNET_log (type, __VA_ARGS__) |
Logging shorthand. More... | |
#define | DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
Debug logging shorthand. More... | |
#define | LOG_SQLITE(db, msg, level, cmd) |
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' on file 'filename' with the message given by strerror(errno). More... | |
Functions | |
static int | iterator (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Iterator over hash map entries. More... | |
static void | cleanup_map () |
Cleaup and destroy the map. More... | |
static int | check_access (void *cls, const struct GNUNET_PeerIdentity *pid) |
Function that decides if a connection is acceptable or not. More... | |
static int | get_identity (unsigned int offset, struct GNUNET_PeerIdentity *id) |
static int | load_keys (const struct GNUNET_CONFIGURATION_Handle *c) |
Function to load keys. More... | |
static void | unload_keys () |
Function to unload keys. More... | |
static void | do_shutdown (void *cls) |
Shutdown task to cleanup our resources and exit. More... | |
static int | db_read_whitelist (struct sqlite3 *db, int pid, struct WhiteListRow **wl_rows) |
Function to read whitelist rows from the database. More... | |
static void | run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) |
Main function that will be run. More... | |
int | main (int argc, char *const *argv) |
The main function. More... | |
Variables | |
static struct GNUNET_CONTAINER_MultiPeerMap * | map |
The map to store the peer identities to allow/deny. More... | |
static struct sqlite3 * | db |
The database connection. More... | |
static struct GNUNET_TRANSPORT_Blacklist * | bh |
The blacklist handle we obtain from transport when we register ourselves for access control. More... | |
struct GNUNET_DISK_FileHandle * | hostkeys_fd |
The hostkeys file. More... | |
static struct GNUNET_DISK_MapHandle * | hostkeys_map |
The hostkeys map. More... | |
static void * | hostkeys_data |
The hostkeys data. More... | |
static struct GNUNET_TRANSPORT_ManipulationHandle * | transport |
Handle to the transport service. More... | |
static unsigned int | num_hostkeys |
The number of hostkeys in the hostkeys array. More... | |
#define LOG | ( | type, | |
... | |||
) | GNUNET_log (type, __VA_ARGS__) |
Logging shorthand.
Definition at line 40 of file gnunet-daemon-testbed-underlay.c.
#define DEBUG | ( | ... | ) | LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
Debug logging shorthand.
Definition at line 46 of file gnunet-daemon-testbed-underlay.c.
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' on file 'filename' with the message given by strerror(errno).
Definition at line 54 of file gnunet-daemon-testbed-underlay.c.
|
static |
Cleaup and destroy the map.
Definition at line 131 of file gnunet-daemon-testbed-underlay.c.
References GNUNET_assert, GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_SYSERR, iterator(), and map.
Referenced by do_shutdown().
|
static |
Function that decides if a connection is acceptable or not.
cls | closure |
pid | peer to approve or disapproave |
Definition at line 153 of file gnunet-daemon-testbed-underlay.c.
References DEBUG, GNUNET_assert, GNUNET_CONTAINER_multipeermap_contains(), GNUNET_i2s(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, map, and pid.
Referenced by run().
|
static |
Definition at line 170 of file gnunet-daemon-testbed-underlay.c.
References GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTING_HOSTKEYFILESIZE, hostkeys_data, id, and num_hostkeys.
Referenced by run().
|
static |
Function to load keys.
Definition at line 212 of file gnunet-daemon-testbed-underlay.c.
References _, GNUNET_asprintf(), GNUNET_DISK_file_map(), GNUNET_DISK_file_open(), GNUNET_DISK_file_size(), GNUNET_DISK_MAP_TYPE_READ, GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_strerror, GNUNET_log_strerror_file, GNUNET_OK, GNUNET_OS_installation_get_path(), GNUNET_OS_IPK_DATADIR, GNUNET_SYSERR, GNUNET_TESTING_HOSTKEYFILESIZE, GNUNET_YES, hostkeys_data, hostkeys_fd, hostkeys_map, LOG, and num_hostkeys.
Referenced by run().
|
static |
Function to unload keys.
Definition at line 266 of file gnunet-daemon-testbed-underlay.c.
References GNUNET_assert, GNUNET_DISK_file_close(), GNUNET_DISK_file_unmap(), hostkeys_data, hostkeys_fd, and hostkeys_map.
Referenced by do_shutdown().
|
static |
Shutdown task to cleanup our resources and exit.
cls | NULL |
Definition at line 289 of file gnunet-daemon-testbed-underlay.c.
References bh, cleanup_map(), GNUNET_TRANSPORT_blacklist_cancel(), GNUNET_TRANSPORT_manipulation_disconnect(), transport, and unload_keys().
Referenced by run().
|
static |
Function to read whitelist rows from the database.
db | the database connection |
pid | the identity of this peer |
wl_rows | where to store the retrieved whitelist rows |
Definition at line 312 of file gnunet-daemon-testbed-underlay.c.
References db, GNUNET_ERROR_TYPE_ERROR, GNUNET_new, GNUNET_SYSERR, LOG_SQLITE, lr, pid, and ret.
Referenced by run().
|
static |
Main function that will be run.
cls | closure |
args | remaining command-line arguments |
cfgfile | name of the configuration file used (for saving, can be NULL!) |
c | configuration |
Definition at line 361 of file gnunet-daemon-testbed-underlay.c.
References bh, check_access(), db, db_read_whitelist(), DEBUG, delay, do_shutdown(), get_identity(), GNUNET_assert, GNUNET_break, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CONTAINER_multipeermap_create(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_i2s(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SYSERR, GNUNET_TRANSPORT_blacklist(), GNUNET_TRANSPORT_manipulation_connect(), GNUNET_TRANSPORT_manipulation_disconnect(), GNUNET_TRANSPORT_manipulation_set(), WhiteListRow::id, identity, WhiteListRow::latency, load_keys(), LOG, LOG_SQLITE, map, WhiteListRow::next, pid, GNUNET_TIME_Relative::rel_value_us, ret, and transport.
Referenced by main().
int main | ( | int | argc, |
char *const * | argv | ||
) |
The main function.
argc | number of arguments from the command line |
argv | command line arguments |
Definition at line 460 of file gnunet-daemon-testbed-underlay.c.
References _, GNUNET_free_nz, GNUNET_GETOPT_OPTION_END, GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), options, ret, and run().
|
static |
The map to store the peer identities to allow/deny.
Definition at line 68 of file gnunet-daemon-testbed-underlay.c.
Referenced by check_access(), cleanup_map(), iterator(), and run().
|
static |
The database connection.
Definition at line 73 of file gnunet-daemon-testbed-underlay.c.
Referenced by db_read_whitelist(), and run().
|
static |
The blacklist handle we obtain from transport when we register ourselves for access control.
Definition at line 79 of file gnunet-daemon-testbed-underlay.c.
Referenced by do_shutdown(), and run().
struct GNUNET_DISK_FileHandle* hostkeys_fd |
The hostkeys file.
Definition at line 84 of file gnunet-daemon-testbed-underlay.c.
Referenced by load_keys(), and unload_keys().
|
static |
The hostkeys map.
Definition at line 89 of file gnunet-daemon-testbed-underlay.c.
Referenced by load_keys(), and unload_keys().
|
static |
The hostkeys data.
Definition at line 94 of file gnunet-daemon-testbed-underlay.c.
Referenced by get_identity(), load_keys(), print_key(), and unload_keys().
|
static |
Handle to the transport service.
This is used for setting link metrics
Definition at line 99 of file gnunet-daemon-testbed-underlay.c.
Referenced by do_shutdown(), and run().
|
static |
The number of hostkeys in the hostkeys array.
Definition at line 104 of file gnunet-daemon-testbed-underlay.c.
Referenced by get_identity(), and load_keys().