diff options
Diffstat (limited to 'src/sensor/gnunet-sensor.c')
-rw-r--r-- | src/sensor/gnunet-sensor.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/sensor/gnunet-sensor.c b/src/sensor/gnunet-sensor.c index ec7b5cb9e..7b7be61ef 100644 --- a/src/sensor/gnunet-sensor.c +++ b/src/sensor/gnunet-sensor.c | |||
@@ -39,6 +39,11 @@ static int get_all; | |||
39 | */ | 39 | */ |
40 | static char *get_sensor; | 40 | static char *get_sensor; |
41 | 41 | ||
42 | /** | ||
43 | * option '-f' | ||
44 | */ | ||
45 | static char *force_anomaly; | ||
46 | |||
42 | /* | 47 | /* |
43 | * Handle to sensor service | 48 | * Handle to sensor service |
44 | */ | 49 | */ |
@@ -92,6 +97,21 @@ print_sensor_info (void *cls, const struct SensorInfoShort *sensor, | |||
92 | 97 | ||
93 | 98 | ||
94 | /** | 99 | /** |
100 | * Continuation called after a force anomaly request is sent. | ||
101 | * | ||
102 | * @param cls Closure (unused) | ||
103 | * @param emsg Error message, NULL of no error | ||
104 | */ | ||
105 | void | ||
106 | force_anomaly_cont (void *cls, const char *emsg) | ||
107 | { | ||
108 | if (NULL != emsg) | ||
109 | printf ("Error: %s\n", emsg); | ||
110 | GNUNET_SCHEDULER_shutdown (); | ||
111 | } | ||
112 | |||
113 | |||
114 | /** | ||
95 | * Main function that will be run by the scheduler. | 115 | * Main function that will be run by the scheduler. |
96 | * | 116 | * |
97 | * @param cls closure | 117 | * @param cls closure |
@@ -118,6 +138,11 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
118 | GNUNET_SENSOR_iterate (sensor_handle, GNUNET_TIME_UNIT_FOREVER_REL, | 138 | GNUNET_SENSOR_iterate (sensor_handle, GNUNET_TIME_UNIT_FOREVER_REL, |
119 | get_sensor, &print_sensor_info, NULL); | 139 | get_sensor, &print_sensor_info, NULL); |
120 | } | 140 | } |
141 | else if (NULL != force_anomaly) | ||
142 | { | ||
143 | GNUNET_SENSOR_force_anomaly (sensor_handle, "nse", GNUNET_YES, | ||
144 | &force_anomaly_cont, NULL); | ||
145 | } | ||
121 | ret = 0; | 146 | ret = 0; |
122 | } | 147 | } |
123 | 148 | ||
@@ -139,6 +164,9 @@ main (int argc, char *const *argv) | |||
139 | {'g', "get-sensor", NULL, | 164 | {'g', "get-sensor", NULL, |
140 | gettext_noop ("Retrieve information about a single sensor"), | 165 | gettext_noop ("Retrieve information about a single sensor"), |
141 | 1, &GNUNET_GETOPT_set_string, &get_sensor}, | 166 | 1, &GNUNET_GETOPT_set_string, &get_sensor}, |
167 | {'f', "force anomaly", NULL, | ||
168 | gettext_noop ("Force an anomaly on a sensor, use only for testing"), | ||
169 | 1, &GNUNET_GETOPT_set_string, &force_anomaly}, | ||
142 | GNUNET_GETOPT_OPTION_END | 170 | GNUNET_GETOPT_OPTION_END |
143 | }; | 171 | }; |
144 | 172 | ||