security_events.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2009, Digium, Inc.
  5. *
  6. * Russell Bryant <russell@digium.com>
  7. *
  8. * See http://www.asterisk.org for more information about
  9. * the Asterisk project. Please do not directly contact
  10. * any of the maintainers of this project for assistance;
  11. * the project provides a web site, mailing lists and IRC
  12. * channels for your use.
  13. *
  14. * This program is free software, distributed under the terms of
  15. * the GNU General Public License Version 2. See the LICENSE file
  16. * at the top of the source tree.
  17. */
  18. /*!
  19. * \file
  20. *
  21. * \brief Security Event Reporting API
  22. *
  23. * \author Russell Bryant <russell@digium.com>
  24. */
  25. #ifndef __AST_SECURITY_EVENTS_H__
  26. #define __AST_SECURITY_EVENTS_H__
  27. #include "asterisk/event.h"
  28. /* Data structure definitions */
  29. #include "asterisk/security_events_defs.h"
  30. #if defined(__cplusplus) || defined(c_plusplus)
  31. extern "C" {
  32. #endif
  33. /*!
  34. * \brief Report a security event
  35. *
  36. * \param[in] sec security event data. Callers of this function should never
  37. * declare an instance of ast_security_event_common directly. The
  38. * argument should be an instance of a specific security event
  39. * descriptor which has ast_security_event_common at the very
  40. * beginning.
  41. *
  42. * \retval 0 success
  43. * \retval non-zero failure
  44. */
  45. int ast_security_event_report(const struct ast_security_event_common *sec);
  46. struct ast_security_event_ie_type {
  47. enum ast_event_ie_type ie_type;
  48. /*! \brief For internal usage */
  49. size_t offset;
  50. };
  51. /*!
  52. * \brief A \ref stasis_topic which publishes messages for security related issues.
  53. * \since 12
  54. *
  55. * \retval \ref stasis_topic for security related issues.
  56. * \retval NULL on error
  57. */
  58. struct stasis_topic *ast_security_topic(void);
  59. /*!
  60. * \brief A \ref stasis_message_type for security events
  61. * \since 12
  62. *
  63. * \retval NULL on error
  64. * \retval \ref stasis_message_type for security events
  65. *
  66. * \note Messages of this type should always be issued on and expected from
  67. * the \ref ast_security_topic \ref stasis_topic
  68. */
  69. struct stasis_message_type *ast_security_event_type(void);
  70. /*!
  71. * \brief initializes stasis topic/event types for \ref ast_security_topic and \ref ast_security_event_type
  72. * \since 12
  73. *
  74. * \retval 0 on success
  75. * \retval -1 on failure
  76. */
  77. int ast_security_stasis_init(void);
  78. /*!
  79. * \brief Get the list of required IEs for a given security event sub-type
  80. *
  81. * \param[in] event_type security event sub-type
  82. *
  83. * \retval NULL invalid event_type
  84. * \retval non-NULL An array terminated with the value AST_EVENT_IE_END
  85. *
  86. * \since 1.8
  87. */
  88. const struct ast_security_event_ie_type *ast_security_event_get_required_ies(
  89. const enum ast_security_event_type event_type);
  90. /*!
  91. * \brief Get the list of optional IEs for a given security event sub-type
  92. *
  93. * \param[in] event_type security event sub-type
  94. *
  95. * \retval NULL invalid event_type
  96. * \retval non-NULL An array terminated with the value AST_EVENT_IE_END
  97. *
  98. * \since 1.8
  99. */
  100. const struct ast_security_event_ie_type *ast_security_event_get_optional_ies(
  101. const enum ast_security_event_type event_type);
  102. /*!
  103. * \brief Get the name of a security event sub-type
  104. *
  105. * \param[in] event_type security event sub-type
  106. *
  107. * \retval NULL if event_type is invalid
  108. * \retval non-NULL the name of the security event type
  109. *
  110. * \since 1.8
  111. */
  112. const char *ast_security_event_get_name(const enum ast_security_event_type event_type);
  113. /*!
  114. * \brief Get the name of a security event severity
  115. *
  116. * \param[in] severity security event severity
  117. *
  118. * \retval NULL if severity is invalid
  119. * \retval non-NULL the name of the security event severity
  120. *
  121. * \since 1.8
  122. */
  123. const char *ast_security_event_severity_get_name(
  124. const enum ast_security_event_severity severity);
  125. #if defined(__cplusplus) || defined(c_plusplus)
  126. }
  127. #endif
  128. #endif /* __AST_SECURITY_EVENTS_H__ */