sensor.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. This file is part of GNUnet
  3. (C) 2012-2013 Christian Grothoff (and other contributing authors)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA.
  16. */
  17. /**
  18. * @file sensor/sensor.h
  19. * @brief IPC messages and private service declarations
  20. * @author Omar Tarabai
  21. */
  22. #include "gnunet_sensor_service.h"
  23. #include "gnunet_sensor_util_lib.h"
  24. GNUNET_NETWORK_STRUCT_BEGIN
  25. /**
  26. * Carries a summary of a sensor
  27. *
  28. */
  29. struct SensorInfoMessage
  30. {
  31. /**
  32. * Message header
  33. */
  34. struct GNUNET_MessageHeader header;
  35. /**
  36. * Length of sensor name. Allocated at position 0 after this struct.
  37. */
  38. uint16_t name_len;
  39. /**
  40. * First part of version number
  41. */
  42. uint16_t version_major;
  43. /**
  44. * Second part of version number
  45. */
  46. uint16_t version_minor;
  47. /**
  48. * Length of sensor description. Allocated at position 1 after this struct.
  49. */
  50. uint16_t description_len;
  51. };
  52. /**
  53. * A message sent to the sensor service to force an anomaly status on a sensor.
  54. */
  55. struct ForceAnomalyMessage
  56. {
  57. /**
  58. * Message header
  59. */
  60. struct GNUNET_MessageHeader header;
  61. /**
  62. * Hash of the sensor name
  63. */
  64. struct GNUNET_HashCode sensor_name_hash;
  65. /**
  66. * New status
  67. */
  68. uint16_t anomalous;
  69. };
  70. GNUNET_NETWORK_STRUCT_END
  71. /**
  72. * Stop the sensor analysis module
  73. */
  74. void
  75. SENSOR_analysis_stop ();
  76. /**
  77. * Start the sensor analysis module
  78. *
  79. * @param c our service configuration
  80. * @param sensors multihashmap of loaded sensors
  81. * @return #GNUNET_OK if started successfully, #GNUNET_SYSERR otherwise
  82. */
  83. int
  84. SENSOR_analysis_start (const struct GNUNET_CONFIGURATION_Handle *c,
  85. struct GNUNET_CONTAINER_MultiHashMap *s);
  86. /**
  87. * Stop sensor anomaly reporting module
  88. */
  89. void
  90. SENSOR_reporting_stop ();
  91. /**
  92. * Used by the analysis module to tell the reporting module about a change in
  93. * the anomaly status of a sensor.
  94. *
  95. * @param sensor Related sensor
  96. * @param anomalous The new sensor anomalous status
  97. */
  98. void
  99. SENSOR_reporting_anomaly_update (struct GNUNET_SENSOR_SensorInfo *sensor,
  100. int anomalous);
  101. /**
  102. * Start the sensor anomaly reporting module
  103. *
  104. * @param c our service configuration
  105. * @param s multihashmap of loaded sensors
  106. * @return #GNUNET_OK if started successfully, #GNUNET_SYSERR otherwise
  107. */
  108. int
  109. SENSOR_reporting_start (const struct GNUNET_CONFIGURATION_Handle *c,
  110. struct GNUNET_CONTAINER_MultiHashMap *s);
  111. /**
  112. * Stop the sensor update module
  113. */
  114. void
  115. SENSOR_update_stop ();
  116. /**
  117. * Start the sensor update module
  118. *
  119. * @param c our service configuration
  120. * @param s multihashmap of loaded sensors
  121. * @param cb callback to reset service components when we have new updates
  122. * @return #GNUNET_OK if started successfully, #GNUNET_SYSERR otherwise
  123. */
  124. int
  125. SENSOR_update_start (const struct GNUNET_CONFIGURATION_Handle *c,
  126. struct GNUNET_CONTAINER_MultiHashMap *s, void (*cb) ());
  127. /**
  128. * Stop the sensor monitoring module
  129. */
  130. void
  131. SENSOR_monitoring_stop ();
  132. /**
  133. * Start the sensor monitoring module
  134. *
  135. * @param c our service configuration
  136. * @param sensors multihashmap of loaded sensors
  137. * @return #GNUNET_OK if started successfully, #GNUNET_SYSERR otherwise
  138. */
  139. int
  140. SENSOR_monitoring_start (const struct GNUNET_CONFIGURATION_Handle *c,
  141. struct GNUNET_CONTAINER_MultiHashMap *s);