static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer) { h = GNUNET_PEERSTORE_connect (cfg); GNUNET_assert (NULL != h); memset (&pid, 1, sizeof (pid)); test1 (); }
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer) { h = GNUNET_PEERSTORE_connect (cfg); GNUNET_assert (NULL != h); memset (&p, 4, sizeof (p)); GNUNET_PEERSTORE_watch (h, ss, &p, k, &watch_cb, NULL); GNUNET_PEERSTORE_store (h, ss, &p, k, val, strlen (val) + 1, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_PEERSTORE_STOREOPTION_REPLACE, NULL, NULL); }
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer) { h = GNUNET_PEERSTORE_connect (cfg); GNUNET_assert (NULL != h); memset (&p1, 1, sizeof (p1)); memset (&p2, 2, sizeof (p2)); GNUNET_PEERSTORE_store (h, ss, &p1, k1, val, strlen (val) + 1, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_PEERSTORE_STOREOPTION_REPLACE, NULL, NULL); GNUNET_PEERSTORE_store (h, ss, &p1, k2, val, strlen (val) + 1, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_PEERSTORE_STOREOPTION_REPLACE, NULL, NULL); GNUNET_PEERSTORE_store (h, ss, &p2, k3, val, strlen (val) + 1, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_PEERSTORE_STOREOPTION_REPLACE, NULL, NULL); ic = GNUNET_PEERSTORE_iterate (h, ss, &p1, k1, GNUNET_TIME_UNIT_FOREVER_REL, iter1_cb, NULL); }
/** * Process sensordashboard requests. * * @param cls closure * @param server the initialized server * @param cfg configuration to use */ static void run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { static const struct GNUNET_SERVER_MessageHandler handlers[] = { {NULL, NULL, 0, 0} }; static struct GNUNET_CADET_MessageHandler cadet_handlers[] = { {&handle_sensor_reading, GNUNET_MESSAGE_TYPE_SENSOR_READING, 0}, {&handle_sensor_list_req, GNUNET_MESSAGE_TYPE_SENSOR_LIST_REQ, sizeof (struct GNUNET_MessageHeader)}, {&handle_sensor_full_req, GNUNET_MESSAGE_TYPE_SENSOR_FULL_REQ, sizeof (struct GNUNET_MessageHeader)}, {&handle_anomaly_report, GNUNET_MESSAGE_TYPE_SENSOR_ANOMALY_REPORT, sizeof (struct GNUNET_MessageHeader) + sizeof (struct GNUNET_SENSOR_crypto_pow_block) + sizeof (struct GNUNET_SENSOR_AnomalyReportMessage)}, {NULL, 0, 0} }; static uint32_t cadet_ports[] = { GNUNET_APPLICATION_TYPE_SENSORDASHBOARD, GNUNET_APPLICATION_TYPE_SENSORUPDATE, GNUNET_APPLICATION_TYPE_END }; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "SENSOR", "SENSOR_DIR", &sensor_dir)) sensor_dir = GNUNET_SENSOR_get_default_sensor_dir (); sensors = GNUNET_SENSOR_load_all_sensors (sensor_dir); GNUNET_assert (NULL != sensors); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "sensor-reporting", "POW_MATCHING_BITS", &pow_matching_bits)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "sensor-reporting", "POW_MATCHING_BITS"); GNUNET_SCHEDULER_add_now (&cleanup_task, NULL); return; } if (pow_matching_bits > sizeof (struct GNUNET_HashCode)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Matching bits value too large (%d > %d).\n", pow_matching_bits, sizeof (struct GNUNET_HashCode)); GNUNET_SCHEDULER_add_now (&cleanup_task, NULL); return; } cadet = GNUNET_CADET_connect (cfg, NULL, &cadet_channel_created, &cadet_channel_destroyed, cadet_handlers, cadet_ports); if (NULL == cadet) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to connect to `%s' service.\n"), "CADET"); GNUNET_SCHEDULER_add_now (&cleanup_task, NULL); return; } peerstore = GNUNET_PEERSTORE_connect (cfg); if (NULL == peerstore) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to connect to `%s' service.\n"), "PEERSTORE"); GNUNET_SCHEDULER_add_now (&cleanup_task, NULL); return; } GNUNET_SERVER_add_handlers (server, handlers); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, NULL); }