sensor: towards anomaly reporting
[oweals/gnunet.git] / src / sensor / gnunet-service-sensor.c
1 /*
2      This file is part of GNUnet.
3      (C)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file sensor/gnunet-service-sensor.c
23  * @brief sensor service implementation
24  * @author Omar Tarabai
25  */
26 #include <inttypes.h>
27 #include "platform.h"
28 #include "gnunet_util_lib.h"
29 #include "sensor.h"
30 #include "gnunet_statistics_service.h"
31 #include "gnunet_peerstore_service.h"
32
33 /**
34  * Our configuration.
35  */
36 static const struct GNUNET_CONFIGURATION_Handle *cfg;
37
38 /**
39  * Hashmap of loaded sensor definitions
40  */
41 static struct GNUNET_CONTAINER_MultiHashMap *sensors;
42
43 /**
44  * Handle to statistics service
45  */
46 static struct GNUNET_STATISTICS_Handle *statistics;
47
48 /**
49  * Handle to peerstore service
50  */
51 static struct GNUNET_PEERSTORE_Handle *peerstore;
52
53 /**
54  * Service name
55  */
56 static char *subsystem = "sensor";
57
58 /**
59  * My peer id
60  */
61 static struct GNUNET_PeerIdentity peerid;
62
63
64 /**
65  * Resets the service by stopping components, reloading sensors and starting
66  * components. This is needed when we receive new sensor updates.
67  */
68 static void
69 reset ();
70
71
72 /**
73  * Change the state of the sensor.
74  * Write the change to file to make it persistent.
75  *
76  * @param sensor sensor info struct
77  * @param state new enabled state: #GNUNET_YES / #GNUNET_NO
78  */
79 static void
80 set_sensor_enabled (struct GNUNET_SENSOR_SensorInfo *sensor, int state)
81 {
82   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sensor `%s': Setting enabled to %d.\n",
83               sensor->name, state);
84   sensor->enabled = GNUNET_NO;
85   GNUNET_assert (NULL != sensor->cfg);
86   GNUNET_CONFIGURATION_set_value_string (sensor->cfg, sensor->name, "ENABLED",
87                                          (GNUNET_YES == state) ? "YES" : "NO");
88   GNUNET_CONFIGURATION_write (sensor->cfg, sensor->def_file);
89 }
90
91
92 /**
93  * Stops components and destroys sensors
94  */
95 static void
96 stop ()
97 {
98   SENSOR_update_stop ();
99   SENSOR_analysis_stop ();
100   SENSOR_reporting_value_stop ();
101   SENSOR_reporting_anomaly_stop ();
102   GNUNET_SENSOR_destroy_sensors (sensors);
103 }
104
105
106 /**
107  * Task run during shutdown.
108  *
109  * @param cls unused
110  * @param tc unused
111  */
112 static void
113 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
114 {
115   stop ();
116   if (NULL != statistics)
117   {
118     GNUNET_STATISTICS_destroy (statistics, GNUNET_YES);
119     statistics = NULL;
120   }
121   if (NULL != peerstore)
122   {
123     GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES);
124     peerstore = NULL;
125   }
126   GNUNET_SCHEDULER_shutdown ();
127 }
128
129
130 /**
131  * A client disconnected.  Remove all of its data structure entries.
132  *
133  * @param cls closure, NULL
134  * @param client identification of the client
135  */
136 static void
137 handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
138 {
139 }
140
141
142 /**
143  * Creates a structure with basic sensor info to be sent to a client.
144  *
145  * @param sensor sensor information
146  * @return message ready to be sent to client
147  */
148 static struct SensorInfoMessage *
149 create_sensor_info_msg (struct GNUNET_SENSOR_SensorInfo *sensor)
150 {
151   struct SensorInfoMessage *msg;
152   uint16_t len;
153   size_t name_len;
154   size_t desc_len;
155   char *str_ptr;
156
157   name_len = strlen (sensor->name);
158   if (NULL == sensor->description)
159     desc_len = 0;
160   else
161     desc_len = strlen (sensor->description) + 1;
162   len = 0;
163   len += sizeof (struct SensorInfoMessage);
164   len += name_len;
165   len += desc_len;
166   msg = GNUNET_malloc (len);
167   msg->header.size = htons (len);
168   msg->header.type = htons (GNUNET_MESSAGE_TYPE_SENSOR_INFO);
169   msg->name_len = htons (name_len);
170   msg->description_len = htons (desc_len);
171   msg->version_major = htons (sensor->version_major);
172   msg->version_minor = htons (sensor->version_minor);
173   str_ptr = (char *) &msg[1];
174   memcpy (str_ptr, sensor->name, name_len);
175   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending sensor name (%d): %.*s\n",
176               name_len, name_len, str_ptr);
177   str_ptr += name_len;
178   memcpy (str_ptr, sensor->description, desc_len);
179   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
180               "Sending sensor description (%d): %.*s\n", desc_len, desc_len,
181               str_ptr);
182   return msg;
183 }
184
185
186 /**
187  * Handle GET SENSOR message.
188  *
189  * @param cls closure
190  * @param client identification of the client
191  * @param message the actual message
192  */
193 static void
194 handle_get_sensor (void *cls, struct GNUNET_SERVER_Client *client,
195                    const struct GNUNET_MessageHeader *message)
196 {
197   struct GNUNET_SERVER_TransmitContext *tc;
198   char *sensorname;
199   size_t sensorname_len;
200   struct GNUNET_HashCode key;
201   struct GNUNET_SENSOR_SensorInfo *sensorinfo;
202   struct SensorInfoMessage *msg;
203
204   sensorname = (char *) &message[1];
205   sensorname_len = ntohs (message->size) - sizeof (struct GNUNET_MessageHeader);
206   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
207               "`%s' message received for sensor (%d) `%.*s'\n", "GET SENSOR",
208               sensorname_len, sensorname_len, sensorname);
209   tc = GNUNET_SERVER_transmit_context_create (client);
210   GNUNET_CRYPTO_hash (sensorname, sensorname_len, &key);
211   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
212               "Created key hash for requested sensor\n");
213   sensorinfo =
214       (struct GNUNET_SENSOR_SensorInfo *)
215       GNUNET_CONTAINER_multihashmap_get (sensors, &key);
216   if (NULL != sensorinfo)
217   {
218     msg = create_sensor_info_msg (sensorinfo);
219     GNUNET_SERVER_transmit_context_append_message (tc,
220                                                    (struct GNUNET_MessageHeader
221                                                     *) msg);
222     GNUNET_free (msg);
223   }
224   else
225     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
226                 "Requested sensor `%.*s' was not found\n", sensorname_len,
227                 sensorname);
228   GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
229                                               GNUNET_MESSAGE_TYPE_SENSOR_END);
230   GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
231 }
232
233
234 /**
235  * Iterator for sensors and adds them to transmit context
236  *
237  * @param cls a `struct GNUNET_SERVER_TransmitContext *`
238  * @param key hash of sensor name, key to hashmap
239  * @param value a `struct GNUNET_SENSOR_SensorInfo *`
240  */
241 static int
242 add_sensor_to_tc (void *cls, const struct GNUNET_HashCode *key, void *value)
243 {
244   struct GNUNET_SERVER_TransmitContext *tc = cls;
245   struct GNUNET_SENSOR_SensorInfo *sensorinfo = value;
246   struct SensorInfoMessage *msg;
247
248   msg = create_sensor_info_msg (sensorinfo);
249   GNUNET_SERVER_transmit_context_append_message (tc,
250                                                  (struct GNUNET_MessageHeader *)
251                                                  msg);
252
253   GNUNET_free (msg);
254   return GNUNET_YES;
255 }
256
257
258 /**
259  * Handle GET ALL SENSORS message.
260  *
261  * @param cls closure
262  * @param client identification of the client
263  * @param message the actual message
264  */
265 static void
266 handle_get_all_sensors (void *cls, struct GNUNET_SERVER_Client *client,
267                         const struct GNUNET_MessageHeader *message)
268 {
269   struct GNUNET_SERVER_TransmitContext *tc;
270
271   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "`%s' message received.\n",
272               "GET ALL SENSOR");
273   tc = GNUNET_SERVER_transmit_context_create (client);
274   GNUNET_CONTAINER_multihashmap_iterate (sensors, &add_sensor_to_tc, tc);
275   GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
276                                               GNUNET_MESSAGE_TYPE_SENSOR_END);
277   GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
278 }
279
280
281 /**
282  * Do a series of checks to determine if sensor should execute
283  *
284  * @return #GNUNET_YES / #GNUNET_NO
285  */
286 static int
287 should_run_sensor (struct GNUNET_SENSOR_SensorInfo *sensorinfo)
288 {
289   struct GNUNET_TIME_Absolute now;
290
291   if (GNUNET_NO == sensorinfo->enabled)
292   {
293     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
294                 "Sensor `%s' is disabled, will not run\n", sensorinfo->name);
295     return GNUNET_NO;
296   }
297   now = GNUNET_TIME_absolute_get ();
298   if (NULL != sensorinfo->start_time &&
299       now.abs_value_us < sensorinfo->start_time->abs_value_us)
300   {
301     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
302                 "Start time for sensor `%s' not reached yet, will not run\n",
303                 sensorinfo->name);
304     return GNUNET_NO;
305   }
306   if (NULL != sensorinfo->end_time &&
307       now.abs_value_us >= sensorinfo->end_time->abs_value_us)
308   {
309     GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Sensor `%s' expired, disabling.\n",
310                 sensorinfo->name);
311     set_sensor_enabled (sensorinfo, GNUNET_NO);
312     return GNUNET_NO;
313   }
314   return GNUNET_YES;
315 }
316
317
318 /**
319  * Callback function to process statistic values
320  *
321  * @param cls `struct GNUNET_SENSOR_SensorInfo *`
322  * @param ss name of subsystem that created the statistic
323  * @param name the name of the datum
324  * @param value the current value
325  * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
326  * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
327  */
328 static int
329 sensor_statistics_iterator (void *cls, const char *ss, const char *name,
330                             uint64_t value, int is_persistent)
331 {
332   struct GNUNET_SENSOR_SensorInfo *sensorinfo = cls;
333   double dvalue = (double) value;
334   struct GNUNET_TIME_Absolute expiry;
335
336   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
337               "Received a value for sensor `%s': %" PRIu64 "\n",
338               sensorinfo->name, value);
339   expiry = GNUNET_TIME_relative_to_absolute (sensorinfo->lifetime);
340   GNUNET_PEERSTORE_store (peerstore, subsystem, &peerid, sensorinfo->name,
341                           &dvalue, sizeof (dvalue), expiry,
342                           GNUNET_PEERSTORE_STOREOPTION_MULTIPLE, NULL, NULL);
343   return GNUNET_SYSERR;         /* We only want one value */
344 }
345
346
347 /**
348  * Continuation called after sensor gets all gnunet statistics values
349  *
350  * @param cls `struct GNUNET_SENSOR_SensorInfo *`
351  * @param success #GNUNET_OK if statistics were
352  *        successfully obtained, #GNUNET_SYSERR if not.
353  */
354 static void
355 end_sensor_run_stat (void *cls, int success)
356 {
357   struct GNUNET_SENSOR_SensorInfo *sensorinfo = cls;
358
359   sensorinfo->gnunet_stat_get_handle = NULL;
360   sensorinfo->running = GNUNET_NO;
361 }
362
363
364 /**
365  * Tries to parse a received sensor value to its
366  * expected datatype
367  *
368  * @param value the string value received, should be null terminated
369  * @param sensor sensor information struct
370  * @param ret pointer to parsed value
371  * @return size of new parsed value, 0 for error
372  */
373 static size_t
374 parse_sensor_value (const char *value, struct GNUNET_SENSOR_SensorInfo *sensor,
375                     void **ret)
376 {
377   double *dval;
378   char *endptr;
379
380   *ret = NULL;
381   if ('\0' == *value)
382     return 0;
383   if (0 == strcmp ("numeric", sensor->expected_datatype))
384   {
385     dval = GNUNET_new (double);
386
387     *dval = strtod (value, &endptr);
388     if (value == endptr)
389       return 0;
390     *ret = dval;
391     return sizeof (double);
392   }
393   if (0 == strcmp ("string", sensor->expected_datatype))
394   {
395     *ret = GNUNET_strdup (value);
396     return strlen (value) + 1;
397   }
398   GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
399               _
400               ("Unknown value type expected by sensor, this should not happen.\n"));
401   return 0;
402 }
403
404
405 /**
406  * Callback for output of executed sensor process
407  *
408  * @param cls `struct GNUNET_SENSOR_SensorInfo *`
409  * @param line line of output from a command, NULL for the end
410  */
411 static void
412 sensor_process_callback (void *cls, const char *line)
413 {
414   struct GNUNET_SENSOR_SensorInfo *sensorinfo = cls;
415   void *value;
416   size_t valsize;
417   struct GNUNET_TIME_Absolute expiry;
418
419   if (NULL == line)
420   {
421     GNUNET_OS_command_stop (sensorinfo->ext_cmd);
422     sensorinfo->ext_cmd = NULL;
423     sensorinfo->running = GNUNET_NO;
424     sensorinfo->ext_cmd_value_received = GNUNET_NO;
425     return;
426   }
427   if (GNUNET_YES == sensorinfo->ext_cmd_value_received)
428     return;                     /* We only want one *valid* value */
429   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received a value for sensor `%s': %s\n",
430               sensorinfo->name, line);
431   valsize = parse_sensor_value (line, sensorinfo, &value);
432   if (valsize == 0)             /* invalid value, FIXME: should we disable the sensor now? */
433   {
434     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
435                 _("Received an invalid value for sensor `%s': %s\n"),
436                 sensorinfo->name, line);
437   }
438   else
439   {
440     sensorinfo->ext_cmd_value_received = GNUNET_YES;
441     expiry = GNUNET_TIME_relative_to_absolute (sensorinfo->lifetime);
442     GNUNET_PEERSTORE_store (peerstore, subsystem, &peerid, sensorinfo->name,
443                             value, valsize, expiry,
444                             GNUNET_PEERSTORE_STOREOPTION_MULTIPLE, NULL, NULL);
445     GNUNET_free (value);
446   }
447 }
448
449
450 /**
451  * Checks if the given file is a path
452  *
453  * @return #GNUNET_YES / #GNUNET_NO
454  */
455 static int
456 is_path (char *filename)
457 {
458   size_t filename_len;
459   int i;
460
461   filename_len = strlen (filename);
462   for (i = 0; i < filename_len; i++)
463   {
464     if (DIR_SEPARATOR == filename[i])
465       return GNUNET_YES;
466   }
467   return GNUNET_NO;
468 }
469
470
471 /**
472  * Actual execution of a sensor
473  *
474  * @param cls 'struct SensorInfo'
475  * @param tc unsed
476  */
477 static void
478 sensor_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
479 {
480   struct GNUNET_SENSOR_SensorInfo *sensorinfo = cls;
481   int check_result;
482   char *sensors_dir;
483   char *process_path;
484
485   sensorinfo->execution_task =
486       GNUNET_SCHEDULER_add_delayed (sensorinfo->interval, &sensor_run,
487                                     sensorinfo);
488   if (GNUNET_YES == sensorinfo->running)        //FIXME: should we try to kill?
489   {
490     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
491                 "Sensor `%s' running for too long, will try again next interval\n",
492                 sensorinfo->name);
493     return;
494   }
495   if (GNUNET_NO == should_run_sensor (sensorinfo))
496     return;
497   sensorinfo->running = GNUNET_YES;
498   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
499               "Starting the execution of sensor `%s'\n", sensorinfo->name);
500   if (0 == strcmp ("gnunet-statistics", sensorinfo->source))
501   {
502     sensorinfo->gnunet_stat_get_handle = GNUNET_STATISTICS_get (statistics, sensorinfo->gnunet_stat_service, sensorinfo->gnunet_stat_name, sensorinfo->interval,        //try to get values only for the interval of the sensor
503                                                                 &end_sensor_run_stat,
504                                                                 &sensor_statistics_iterator,
505                                                                 sensorinfo);
506   }
507   else if (0 == strcmp ("process", sensorinfo->source))
508   {
509     if (GNUNET_YES == is_path (sensorinfo->ext_process))
510     {
511       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
512                   _
513                   ("Sensor `%s': External process should not be a path, disabling sensor.\n"),
514                   sensorinfo->name);
515       set_sensor_enabled (sensorinfo, GNUNET_NO);
516       return;
517     }
518     //check if the process exists in $PATH
519     process_path = GNUNET_strdup (sensorinfo->ext_process);
520     check_result =
521         GNUNET_OS_check_helper_binary (process_path, GNUNET_NO, NULL);
522     if (GNUNET_SYSERR == check_result)
523     {
524       //search in sensor directory
525       sensors_dir = GNUNET_SENSOR_get_sensor_dir ();
526       GNUNET_free (process_path);
527       GNUNET_asprintf (&process_path, "%s%s-files%s%s", sensors_dir,
528                        sensorinfo->name, DIR_SEPARATOR_STR,
529                        sensorinfo->ext_process);
530       GNUNET_free (sensors_dir);
531       check_result =
532           GNUNET_OS_check_helper_binary (process_path, GNUNET_NO, NULL);
533     }
534     if (GNUNET_SYSERR == check_result)
535     {
536       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
537                   _
538                   ("Sensor `%s' process `%s' problem: binary doesn't exist or not executable\n"),
539                   sensorinfo->name, sensorinfo->ext_process);
540       set_sensor_enabled (sensorinfo, GNUNET_NO);
541       sensorinfo->running = GNUNET_NO;
542       GNUNET_free (process_path);
543       return;
544     }
545     sensorinfo->ext_cmd_value_received = GNUNET_NO;
546     sensorinfo->ext_cmd =
547         GNUNET_OS_command_run (&sensor_process_callback, sensorinfo,
548                                GNUNET_TIME_UNIT_FOREVER_REL, process_path,
549                                sensorinfo->ext_process, sensorinfo->ext_args,
550                                NULL);
551     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Process started for sensor `%s'\n",
552                 sensorinfo->name);
553     GNUNET_free (process_path);
554   }
555   else
556   {
557     sensorinfo->running = GNUNET_NO;
558     GNUNET_break (0);           /* shouldn't happen */
559   }
560 }
561
562
563 /**
564  * Starts the execution of a sensor
565  *
566  * @param cls unused
567  * @param key hash of sensor name, key to hashmap (unused)
568  * @param value a `struct GNUNET_SENSOR_SensorInfo *`
569  * @return #GNUNET_YES if we should continue to
570  *         iterate,
571  *         #GNUNET_NO if not.
572  */
573 static int
574 schedule_sensor (void *cls, const struct GNUNET_HashCode *key, void *value)
575 {
576   struct GNUNET_SENSOR_SensorInfo *sensorinfo = value;
577
578   if (GNUNET_NO == should_run_sensor (sensorinfo))
579     return GNUNET_YES;
580   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
581               "Scheduling sensor `%s' to run after %" PRIu64 " microseconds\n",
582               sensorinfo->name, sensorinfo->interval.rel_value_us);
583   if (GNUNET_SCHEDULER_NO_TASK != sensorinfo->execution_task)
584   {
585     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
586                 _
587                 ("Sensor `%s' execution task already set, this should not happen\n"),
588                 sensorinfo->name);
589     return GNUNET_NO;
590   }
591   sensorinfo->execution_task =
592       GNUNET_SCHEDULER_add_delayed (sensorinfo->interval, &sensor_run,
593                                     sensorinfo);
594   return GNUNET_YES;
595 }
596
597
598 /**
599  * Starts the execution of all enabled sensors
600  */
601 static void
602 schedule_all_sensors ()
603 {
604   GNUNET_CONTAINER_multihashmap_iterate (sensors, &schedule_sensor, NULL);
605 }
606
607
608 /**
609  * Loads sensors and starts different service components
610  */
611 static void
612 start ()
613 {
614   sensors = GNUNET_SENSOR_load_all_sensors ();
615   schedule_all_sensors ();
616   SENSOR_reporting_value_start (cfg, sensors);
617   SENSOR_reporting_anomaly_start (cfg, sensors);
618   SENSOR_analysis_start (cfg, sensors);
619   SENSOR_update_start (cfg, sensors, &reset);
620 }
621
622
623 /**
624  * Process statistics requests.
625  *
626  * @param cls closure
627  * @param server the initialized server
628  * @param c configuration to use
629  */
630 static void
631 run (void *cls, struct GNUNET_SERVER_Handle *server,
632      const struct GNUNET_CONFIGURATION_Handle *c)
633 {
634   static const struct GNUNET_SERVER_MessageHandler handlers[] = {
635     {&handle_get_sensor, NULL, GNUNET_MESSAGE_TYPE_SENSOR_GET,
636      0},
637     {&handle_get_all_sensors, NULL, GNUNET_MESSAGE_TYPE_SENSOR_GETALL,
638      sizeof (struct GNUNET_MessageHeader)},
639     {NULL, NULL, 0, 0}
640   };
641
642   cfg = c;
643   statistics = GNUNET_STATISTICS_create ("sensor", cfg);
644   GNUNET_CRYPTO_get_peer_identity (cfg, &peerid);
645   peerstore = GNUNET_PEERSTORE_connect (cfg);
646   GNUNET_SERVER_add_handlers (server, handlers);
647   GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
648   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
649                                 NULL);
650   start ();
651 }
652
653
654 /**
655  * Resets the service by stopping components, reloading sensors and starting
656  * components. This is needed when we receive new sensor updates.
657  */
658 static void
659 reset ()
660 {
661   stop ();
662   start ();
663 }
664
665
666 /**
667  * The main function for the sensor service.
668  *
669  * @param argc number of arguments from the command line
670  * @param argv command line arguments
671  * @return 0 ok, 1 on error
672  */
673 int
674 main (int argc, char *const *argv)
675 {
676   return (GNUNET_OK ==
677           GNUNET_SERVICE_run (argc, argv, "sensor", GNUNET_SERVICE_OPTION_NONE,
678                               &run, NULL)) ? 0 : 1;
679 }
680
681 /* end of gnunet-service-sensor.c */