aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-07-11 22:10:15 +0000
committerChristian Grothoff <christian@grothoff.org>2014-07-11 22:10:15 +0000
commita0c135cba1d033ea9cb04a6aa3ec269d82769fc2 (patch)
treee190a2b03e51e740dd93c10a9dea41f9e3a20ff6
parentb289d8b09eb3417314578a77f49606dbdf5292bf (diff)
downloadgnunet-a0c135cba1d033ea9cb04a6aa3ec269d82769fc2.tar.gz
gnunet-a0c135cba1d033ea9cb04a6aa3ec269d82769fc2.zip
-fixing doxygen, indentation
-rw-r--r--po/POTFILES.in2
-rw-r--r--src/include/gnunet_sensor_util_lib.h2
-rw-r--r--src/sensor/gnunet-service-sensor-reporting.c83
3 files changed, 55 insertions, 32 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in
index fe62da13d..09802bfed 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -267,7 +267,9 @@ src/secretsharing/gnunet-service-secretsharing.c
267src/secretsharing/secretsharing_api.c 267src/secretsharing/secretsharing_api.c
268src/secretsharing/secretsharing_common.c 268src/secretsharing/secretsharing_common.c
269src/sensor/gnunet-sensor.c 269src/sensor/gnunet-sensor.c
270src/sensor/gnunet-service-sensor-analysis.c
270src/sensor/gnunet-service-sensor.c 271src/sensor/gnunet-service-sensor.c
272src/sensor/plugin_sensor_model_gaussian.c
271src/sensor/sensor_api.c 273src/sensor/sensor_api.c
272src/set/gnunet-service-set.c 274src/set/gnunet-service-set.c
273src/set/gnunet-service-set_intersection.c 275src/set/gnunet-service-set_intersection.c
diff --git a/src/include/gnunet_sensor_util_lib.h b/src/include/gnunet_sensor_util_lib.h
index 56e0bc868..54066decb 100644
--- a/src/include/gnunet_sensor_util_lib.h
+++ b/src/include/gnunet_sensor_util_lib.h
@@ -209,7 +209,7 @@ struct GNUNET_SENSOR_Reading
209 void *value; 209 void *value;
210 210
211 /** 211 /**
212 * Size of @value 212 * Size of @e value
213 */ 213 */
214 uint16_t value_size; 214 uint16_t value_size;
215 215
diff --git a/src/sensor/gnunet-service-sensor-reporting.c b/src/sensor/gnunet-service-sensor-reporting.c
index 1aef51aab..2292649e2 100644
--- a/src/sensor/gnunet-service-sensor-reporting.c
+++ b/src/sensor/gnunet-service-sensor-reporting.c
@@ -61,7 +61,7 @@ struct ReportingContext
61 61
62 /** 62 /**
63 * Collection point reporting task 63 * Collection point reporting task
64 * (OR GNUNET_SCHEDULER_NO_TASK) 64 * (or #GNUNET_SCHEDULER_NO_TASK)
65 */ 65 */
66 GNUNET_SCHEDULER_TaskIdentifier cp_task; 66 GNUNET_SCHEDULER_TaskIdentifier cp_task;
67 67
@@ -76,7 +76,7 @@ struct ReportingContext
76 void *last_value; 76 void *last_value;
77 77
78 /** 78 /**
79 * Size of @last_value 79 * Size of @e last_value
80 */ 80 */
81 size_t last_value_size; 81 size_t last_value_size;
82 82
@@ -125,13 +125,13 @@ struct CadetChannelContext
125 void *pending_msg; 125 void *pending_msg;
126 126
127 /** 127 /**
128 * Size of @pending_msg 128 * Size of @e pending_msg
129 */ 129 */
130 size_t pending_msg_size; 130 size_t pending_msg_size;
131 131
132 /** 132 /**
133 * Handle to CADET tranmission request in case we are sending 133 * Handle to CADET tranmission request in case we are sending
134 * (sending == GNUNET_YES) 134 * (sending == #GNUNET_YES)
135 */ 135 */
136 struct GNUNET_CADET_TransmitHandle *th; 136 struct GNUNET_CADET_TransmitHandle *th;
137 137
@@ -232,15 +232,18 @@ destroy_cadet_channel_context (struct CadetChannelContext *cc)
232 GNUNET_free (cc); 232 GNUNET_free (cc);
233} 233}
234 234
235
235/** 236/**
236 * Stop sensor reporting module 237 * Stop sensor reporting module
237 */ 238 */
238void SENSOR_reporting_stop () 239void
240SENSOR_reporting_stop ()
239{ 241{
240 struct ReportingContext *rc; 242 struct ReportingContext *rc;
241 struct CadetChannelContext *cc; 243 struct CadetChannelContext *cc;
242 244
243 LOG (GNUNET_ERROR_TYPE_DEBUG, "Stopping sensor reporting module.\n"); 245 LOG (GNUNET_ERROR_TYPE_DEBUG,
246 "Stopping sensor reporting module.\n");
244 while (NULL != cc_head) 247 while (NULL != cc_head)
245 { 248 {
246 cc = cc_head; 249 cc = cc_head;
@@ -265,6 +268,7 @@ void SENSOR_reporting_stop ()
265 } 268 }
266} 269}
267 270
271
268/** 272/**
269 * Returns CADET channel established to given peer 273 * Returns CADET channel established to given peer
270 * or creates a new one 274 * or creates a new one
@@ -297,6 +301,7 @@ get_cadet_channel (struct GNUNET_PeerIdentity pid)
297 return cc; 301 return cc;
298} 302}
299 303
304
300/** 305/**
301 * Construct a reading message ready to be sent over CADET channel 306 * Construct a reading message ready to be sent over CADET channel
302 * 307 *
@@ -306,7 +311,7 @@ get_cadet_channel (struct GNUNET_PeerIdentity pid)
306 */ 311 */
307static size_t 312static size_t
308construct_reading_message (struct ReportingContext *rc, 313construct_reading_message (struct ReportingContext *rc,
309 struct GNUNET_SENSOR_ReadingMessage **msg) 314 struct GNUNET_SENSOR_ReadingMessage **msg)
310{ 315{
311 struct GNUNET_SENSOR_ReadingMessage *ret; 316 struct GNUNET_SENSOR_ReadingMessage *ret;
312 uint16_t sensorname_size; 317 uint16_t sensorname_size;
@@ -333,6 +338,7 @@ construct_reading_message (struct ReportingContext *rc,
333 return total_size; 338 return total_size;
334} 339}
335 340
341
336/** 342/**
337 * Function called to notify a client about the connection begin ready 343 * Function called to notify a client about the connection begin ready
338 * to queue more data. @a buf will be NULL and @a size zero if the 344 * to queue more data. @a buf will be NULL and @a size zero if the
@@ -351,7 +357,8 @@ do_report_collection_point (void *cls, size_t size, void *buf)
351 357
352 cc->th = NULL; 358 cc->th = NULL;
353 cc->sending = GNUNET_NO; 359 cc->sending = GNUNET_NO;
354 LOG (GNUNET_ERROR_TYPE_DEBUG, "Copying to CADET transmit buffer.\n"); 360 LOG (GNUNET_ERROR_TYPE_DEBUG,
361 "Copying to CADET transmit buffer.\n");
355 if (NULL == buf) 362 if (NULL == buf)
356 { 363 {
357 LOG (GNUNET_ERROR_TYPE_WARNING, 364 LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -374,14 +381,16 @@ do_report_collection_point (void *cls, size_t size, void *buf)
374 return written; 381 return written;
375} 382}
376 383
384
377/** 385/**
378 * Task scheduled to send values to collection point 386 * Task scheduled to send values to collection point
379 * 387 *
380 * @param cls closure, a 'struct CollectionReportingContext *' 388 * @param cls closure, a `struct CollectionReportingContext *`
381 * @param tc unused 389 * @param tc unused
382 */ 390 */
383static void report_collection_point 391static void
384(void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc) 392report_collection_point (void *cls,
393 const struct GNUNET_SCHEDULER_TaskContext* tc)
385{ 394{
386 struct ReportingContext *rc = cls; 395 struct ReportingContext *rc = cls;
387 struct SensorInfo *sensor = rc->sensor; 396 struct SensorInfo *sensor = rc->sensor;
@@ -392,22 +401,26 @@ static void report_collection_point
392 rc->cp_task = GNUNET_SCHEDULER_NO_TASK; 401 rc->cp_task = GNUNET_SCHEDULER_NO_TASK;
393 if (0 == rc->last_value_size) /* Did not receive a sensor value yet */ 402 if (0 == rc->last_value_size) /* Did not receive a sensor value yet */
394 { 403 {
395 LOG (GNUNET_ERROR_TYPE_WARNING, "Did not receive a value from `%s' " 404 LOG (GNUNET_ERROR_TYPE_WARNING,
396 "to report yet.\n", rc->sensor->name); 405 "Did not receive a value from `%s' to report yet.\n",
406 rc->sensor->name);
397 rc->cp_task = GNUNET_SCHEDULER_add_delayed (sensor->collection_interval, 407 rc->cp_task = GNUNET_SCHEDULER_add_delayed (sensor->collection_interval,
398 &report_collection_point, rc); 408 &report_collection_point, rc);
399 return; 409 return;
400 } 410 }
401 LOG (GNUNET_ERROR_TYPE_DEBUG, "Now trying to report last seen value of `%s' " 411 LOG (GNUNET_ERROR_TYPE_DEBUG,
402 "to collection point.\n", rc->sensor->name); 412 "Now trying to report last seen value of `%s' "
413 "to collection point.\n",
414 rc->sensor->name);
403 GNUNET_assert (NULL != sensor->collection_point); 415 GNUNET_assert (NULL != sensor->collection_point);
404 cc = get_cadet_channel (*sensor->collection_point); 416 cc = get_cadet_channel (*sensor->collection_point);
405 if (GNUNET_YES == cc->sending) 417 if (GNUNET_YES == cc->sending)
406 { 418 {
407 LOG (GNUNET_ERROR_TYPE_DEBUG, 419 LOG (GNUNET_ERROR_TYPE_DEBUG,
408 "Cadet channel to collection point busy, " 420 "Cadet channel to collection point busy, "
409 "trying again for sensor `%s' after %d seconds.\n", rc->sensor->name, 421 "trying again for sensor `%s' after %d seconds.\n",
410 COLLECTION_RETRY); 422 rc->sensor->name,
423 COLLECTION_RETRY);
411 rc->cp_task = GNUNET_SCHEDULER_add_delayed ( 424 rc->cp_task = GNUNET_SCHEDULER_add_delayed (
412 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, COLLECTION_RETRY), 425 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, COLLECTION_RETRY),
413 &report_collection_point, rc); 426 &report_collection_point, rc);
@@ -427,7 +440,8 @@ static void report_collection_point
427 &report_collection_point, rc); 440 &report_collection_point, rc);
428} 441}
429 442
430/* 443
444/**
431 * Sensor value watch callback 445 * Sensor value watch callback
432 */ 446 */
433static int 447static int
@@ -448,12 +462,15 @@ sensor_watch_cb (void *cls,
448 memcpy (rc->last_value, record->value, record->value_size); 462 memcpy (rc->last_value, record->value, record->value_size);
449 rc->last_value_size = record->value_size; 463 rc->last_value_size = record->value_size;
450 rc->timestamp = GNUNET_TIME_absolute_get().abs_value_us; 464 rc->timestamp = GNUNET_TIME_absolute_get().abs_value_us;
451 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received a sensor `%s' watch value at " 465 LOG (GNUNET_ERROR_TYPE_DEBUG,
452 "timestamp %" PRIu64 ", updating notification last_value.\n", 466 "Received a sensor `%s' watch value at "
453 rc->sensor->name, rc->timestamp); 467 "timestamp %" PRIu64 ", updating notification last_value.\n",
468 rc->sensor->name,
469 rc->timestamp);
454 return GNUNET_YES; 470 return GNUNET_YES;
455} 471}
456 472
473
457/** 474/**
458 * Iterator for defined sensors 475 * Iterator for defined sensors
459 * Watches sensors for readings to report 476 * Watches sensors for readings to report
@@ -509,6 +526,7 @@ init_sensor_reporting (void *cls,
509 return GNUNET_YES; 526 return GNUNET_YES;
510} 527}
511 528
529
512/** 530/**
513 * Function called whenever a channel is destroyed. Should clean up 531 * Function called whenever a channel is destroyed. Should clean up
514 * any associated state. 532 * any associated state.
@@ -520,9 +538,10 @@ init_sensor_reporting (void *cls,
520 * @param channel_ctx place where local state associated 538 * @param channel_ctx place where local state associated
521 * with the channel is stored 539 * with the channel is stored
522 */ 540 */
523static void cadet_channel_destroyed (void *cls, 541static void
524 const struct GNUNET_CADET_Channel *channel, 542cadet_channel_destroyed (void *cls,
525 void *channel_ctx) 543 const struct GNUNET_CADET_Channel *channel,
544 void *channel_ctx)
526{ 545{
527 struct CadetChannelContext *cc = channel_ctx; 546 struct CadetChannelContext *cc = channel_ctx;
528 547
@@ -545,13 +564,14 @@ static void cadet_channel_destroyed (void *cls,
545 */ 564 */
546int 565int
547SENSOR_reporting_start (const struct GNUNET_CONFIGURATION_Handle *c, 566SENSOR_reporting_start (const struct GNUNET_CONFIGURATION_Handle *c,
548 struct GNUNET_CONTAINER_MultiHashMap *sensors) 567 struct GNUNET_CONTAINER_MultiHashMap *sensors)
549{ 568{
550 static struct GNUNET_CADET_MessageHandler cadet_handlers[] = { 569 static struct GNUNET_CADET_MessageHandler cadet_handlers[] = {
551 {NULL, 0, 0} 570 {NULL, 0, 0}
552 }; 571 };
553 572
554 LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting sensor reporting module.\n"); 573 LOG (GNUNET_ERROR_TYPE_DEBUG,
574 "Starting sensor reporting module.\n");
555 GNUNET_assert(NULL != sensors); 575 GNUNET_assert(NULL != sensors);
556 cfg = c; 576 cfg = c;
557 peerstore = GNUNET_PEERSTORE_connect(cfg); 577 peerstore = GNUNET_PEERSTORE_connect(cfg);
@@ -571,13 +591,14 @@ SENSOR_reporting_start (const struct GNUNET_CONFIGURATION_Handle *c,
571 if (NULL == cadet) 591 if (NULL == cadet)
572 { 592 {
573 LOG (GNUNET_ERROR_TYPE_ERROR, 593 LOG (GNUNET_ERROR_TYPE_ERROR,
574 _("Failed to connect to CADET service.\n")); 594 _("Failed to connect to CADET service.\n"));
575 SENSOR_reporting_stop (); 595 SENSOR_reporting_stop ();
576 return GNUNET_SYSERR; 596 return GNUNET_SYSERR;
577 } 597 }
578 GNUNET_CRYPTO_get_peer_identity(cfg, &mypeerid); 598 GNUNET_CRYPTO_get_peer_identity (cfg,
579 GNUNET_CONTAINER_multihashmap_iterate(sensors, &init_sensor_reporting, NULL); 599 &mypeerid);
580 600 GNUNET_CONTAINER_multihashmap_iterate(sensors,
601 &init_sensor_reporting, NULL);
581 return GNUNET_OK; 602 return GNUNET_OK;
582} 603}
583 604