diff options
author | Omar Tarabai <tarabai@devegypt.com> | 2014-05-02 14:42:03 +0000 |
---|---|---|
committer | Omar Tarabai <tarabai@devegypt.com> | 2014-05-02 14:42:03 +0000 |
commit | bd5d6005ef1020d6a8ada0ee60589cc0f5ec740b (patch) | |
tree | 9e919b5da9f5bf0499b73109ed5e0aaa2e2358e3 /src/sensor | |
parent | f5743f7009ec5ab505963b7cf4338917caa136d1 (diff) | |
download | gnunet-bd5d6005ef1020d6a8ada0ee60589cc0f5ec740b.tar.gz gnunet-bd5d6005ef1020d6a8ada0ee60589cc0f5ec740b.zip |
bug fix
Diffstat (limited to 'src/sensor')
-rw-r--r-- | src/sensor/gnunet-service-sensor.c | 17 | ||||
-rw-r--r-- | src/sensor/sensor_api.c | 16 |
2 files changed, 24 insertions, 9 deletions
diff --git a/src/sensor/gnunet-service-sensor.c b/src/sensor/gnunet-service-sensor.c index 2f7ffaa0a..5a574f77d 100644 --- a/src/sensor/gnunet-service-sensor.c +++ b/src/sensor/gnunet-service-sensor.c | |||
@@ -365,9 +365,9 @@ reload_sensors_dir_cb(void *cls, const char *filename) | |||
365 | return GNUNET_OK; | 365 | return GNUNET_OK; |
366 | } | 366 | } |
367 | if(GNUNET_YES == add_sensor_to_hashmap(sensor, sensors)) | 367 | if(GNUNET_YES == add_sensor_to_hashmap(sensor, sensors)) |
368 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Sensor `%s' added to global hashmap\n"), sensor->name); | 368 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, _("Sensor `%s' added to global hashmap\n"), sensor->name); |
369 | else | 369 | else |
370 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, ("Could not add sensor `%s' to global hashmap\n"), sensor->name); | 370 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, ("Could not add sensor `%s' to global hashmap\n"), sensor->name); |
371 | 371 | ||
372 | return GNUNET_OK; | 372 | return GNUNET_OK; |
373 | } | 373 | } |
@@ -413,7 +413,7 @@ reload_sensors() | |||
413 | /** | 413 | /** |
414 | * Creates a structure with basic sensor info to be sent to a client | 414 | * Creates a structure with basic sensor info to be sent to a client |
415 | * | 415 | * |
416 | * @parm sensor sensor information | 416 | * @param sensor sensor information |
417 | * @return message ready to be sent to client | 417 | * @return message ready to be sent to client |
418 | */ | 418 | */ |
419 | static struct SensorInfoMessage * | 419 | static struct SensorInfoMessage * |
@@ -423,6 +423,7 @@ create_sensor_info_msg(struct SensorInfo *sensor) | |||
423 | uint16_t len; | 423 | uint16_t len; |
424 | size_t name_len; | 424 | size_t name_len; |
425 | size_t desc_len; | 425 | size_t desc_len; |
426 | char *str_ptr; | ||
426 | 427 | ||
427 | name_len = strlen(sensor->name); | 428 | name_len = strlen(sensor->name); |
428 | if(NULL == sensor->description) | 429 | if(NULL == sensor->description) |
@@ -440,8 +441,14 @@ create_sensor_info_msg(struct SensorInfo *sensor) | |||
440 | msg->description_len = htons(desc_len); | 441 | msg->description_len = htons(desc_len); |
441 | msg->version_major = htons(sensor->version_major); | 442 | msg->version_major = htons(sensor->version_major); |
442 | msg->version_minor = htons(sensor->version_minor); | 443 | msg->version_minor = htons(sensor->version_minor); |
443 | memcpy(&msg[1], sensor->name, name_len); | 444 | str_ptr = (char*) &msg[1]; |
444 | memcpy((&msg[1]) + name_len, sensor->description, desc_len); | 445 | memcpy(str_ptr, sensor->name, name_len); |
446 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending sensor name (%d): %.*s\n", | ||
447 | name_len, name_len, str_ptr); | ||
448 | str_ptr += name_len; | ||
449 | memcpy(str_ptr, sensor->description, desc_len); | ||
450 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending sensor description (%d): %.*s\n", | ||
451 | desc_len, desc_len, str_ptr); | ||
445 | 452 | ||
446 | return msg; | 453 | return msg; |
447 | } | 454 | } |
diff --git a/src/sensor/sensor_api.c b/src/sensor/sensor_api.c index 985c29a0f..bb248315b 100644 --- a/src/sensor/sensor_api.c +++ b/src/sensor/sensor_api.c | |||
@@ -366,7 +366,7 @@ sensor_handler(void *cls, const struct GNUNET_MessageHeader *msg) | |||
366 | struct SensorInfoShort *sensor; | 366 | struct SensorInfoShort *sensor; |
367 | size_t name_len; | 367 | size_t name_len; |
368 | size_t desc_len; | 368 | size_t desc_len; |
369 | 369 | char *str_ptr; | |
370 | 370 | ||
371 | h->in_receive = GNUNET_NO; | 371 | h->in_receive = GNUNET_NO; |
372 | if (NULL == msg) | 372 | if (NULL == msg) |
@@ -400,7 +400,7 @@ sensor_handler(void *cls, const struct GNUNET_MessageHeader *msg) | |||
400 | if (GNUNET_MESSAGE_TYPE_SENSOR_END == ntohs (msg->type)) | 400 | if (GNUNET_MESSAGE_TYPE_SENSOR_END == ntohs (msg->type)) |
401 | { | 401 | { |
402 | /* normal end of list of sensors, signal end, process next pending request */ | 402 | /* normal end of list of sensors, signal end, process next pending request */ |
403 | LOG (GNUNET_ERROR_TYPE_INFO, | 403 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
404 | "Received end of list of sensors from `%s' service\n", "SENSOR"); | 404 | "Received end of list of sensors from `%s' service\n", "SENSOR"); |
405 | GNUNET_SENSOR_iterate_sensor_cancel(ic); | 405 | GNUNET_SENSOR_iterate_sensor_cancel(ic); |
406 | trigger_transmit (h); | 406 | trigger_transmit (h); |
@@ -432,9 +432,17 @@ sensor_handler(void *cls, const struct GNUNET_MessageHeader *msg) | |||
432 | return; | 432 | return; |
433 | } | 433 | } |
434 | sensor = GNUNET_new(struct SensorInfoShort); | 434 | sensor = GNUNET_new(struct SensorInfoShort); |
435 | sensor->name = GNUNET_strndup((char *)&im[1], name_len); | 435 | str_ptr = (char *)&im[1]; |
436 | sensor->name = GNUNET_strndup(str_ptr, name_len); | ||
437 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received sensor name (%d): %.*s\n", | ||
438 | name_len, name_len, str_ptr); | ||
439 | str_ptr += name_len; | ||
436 | if(desc_len > 0) | 440 | if(desc_len > 0) |
437 | sensor->description = GNUNET_strndup((char *)((&im[1]) + name_len), desc_len); | 441 | { |
442 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received sensor description (%d): %.*s\n", | ||
443 | desc_len, desc_len, str_ptr); | ||
444 | sensor->description = GNUNET_strndup(str_ptr, desc_len); | ||
445 | } | ||
438 | sensor->version_major = ntohs(im->version_major); | 446 | sensor->version_major = ntohs(im->version_major); |
439 | sensor->version_minor = ntohs(im->version_minor); | 447 | sensor->version_minor = ntohs(im->version_minor); |
440 | h->in_receive = GNUNET_YES; | 448 | h->in_receive = GNUNET_YES; |