36 #define LOG(type, ...) \
37 GNUNET_log (type, __VA_ARGS__)
43 LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
50 #define LOG_SQLITE(db, msg, level, cmd) \
52 GNUNET_log_from (level, "sqlite", _ ( \
53 "`%s' failed at %s:%d with error: %s\n"), \
54 cmd, __FILE__, __LINE__, sqlite3_errmsg (db)); \
56 GNUNET_asprintf (msg, _ ("`%s' failed at %s:%u with error: %s"), cmd, \
57 __FILE__, __LINE__, sqlite3_errmsg (db)); \
87 static struct sqlite3 *
db;
175 static const char *query_insert =
176 "INSERT INTO ats_info("
209 if (SQLITE_OK != sqlite3_prepare_v2 (
db, query_insert, -1, &
stmt_insert,
216 if ((SQLITE_OK != sqlite3_bind_text (
stmt_insert, 1,
259 run (
void *cls,
char *
const *
args,
const char *cfgfile,
262 const char *query_create =
263 "CREATE TABLE ats_info ("
277 if (SQLITE_OK != sqlite3_open (dbfile, &
db))
289 if (0 != sqlite3_exec (
db, query_create, NULL, NULL, NULL))
290 DEBUG (
"SQLite Error: %d. Perhaps the database `%s' already exits.\n",
291 sqlite3_errcode (
db), dbfile);
292 DEBUG (
"Opened database %s\n", dbfile);
305 main (
int argc,
char *
const *argv)
318 "Daemon to log latency values of connections to neighbours"),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
static int ret
Return value of the commandline.
static struct Experiment * e
static char * address
GNS address for this phone.
#define LOG(type,...)
Logging shorthand.
static void do_shutdown(void *cls)
Shutdown.
static struct GNUNET_CONTAINER_MultiPeerMap * map
Handle to the map used to store old latency values for peers.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run.
#define DEBUG(...)
Debug logging shorthand.
static struct GNUNET_ATS_PerformanceHandle * ats
Handle to the ATS performance subsystem.
static void addr_info_cb(void *cls, const struct GNUNET_HELLO_Address *address, int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, const struct GNUNET_ATS_Properties *prop)
Signature of a function that is called with QoS information about an address.
#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 'file...
int main(int argc, char *const *argv)
Execution entry point.
static struct sqlite3 * db
The SQLite database handle.
static struct sqlite3_stmt * stmt_insert
Prepared statement for inserting values into the database table.
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.
Automatic transport selection and outbound bandwidth determination.
struct GNUNET_ATS_PerformanceHandle * GNUNET_ATS_performance_init(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ATS_AddressInformationCallback addr_info_cb, void *addr_info_cb_cls)
Get handle to access performance API of the ATS subsystem.
void GNUNET_ATS_performance_done(struct GNUNET_ATS_PerformanceHandle *ph)
Client is done using the ATS performance subsystem, release resources.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
static int free_iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_contains(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Check if the map contains any value under the given key (including values that are NULL).
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_free_nz(ptr)
Wrapper around free.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Entry type to be used in the map to store old latency values.
struct GNUNET_PeerIdentity id
The peer's identity.
unsigned int latency
The last known value for latency.
ATS performance characteristics for an address.
struct GNUNET_TIME_Relative delay
Delay.
32-bit bandwidth used for network exchange by GNUnet, in bytes per second.
Internal representation of the hash map.
Definition of a command line option.
An address for communicating with a peer.
The identity of the host (wraps the signing key of the peer).
uint64_t rel_value_us
The actual value.