res_hep.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 1999 - 2014, Digium, Inc.
  5. *
  6. * Alexandr Dubovikov <alexandr.dubovikov@sipcapture.org>
  7. * Matt Jordan <mjordan@digium.com>
  8. *
  9. * See http://www.asterisk.org for more information about
  10. * the Asterisk project. Please do not directly contact
  11. * any of the maintainers of this project for assistance;
  12. * the project provides a web site, mailing lists and IRC
  13. * channels for your use.
  14. *
  15. * This program is free software, distributed under the terms of
  16. * the GNU General Public License Version 2. See the LICENSE file
  17. * at the top of the source tree.
  18. */
  19. /*!
  20. * \file
  21. * \brief Routines for integration with Homer using HEPv3
  22. *
  23. * \author Alexandr Dubovikov <alexandr.dubovikov@sipcapture.org>
  24. * \author Matt Jordan <mjordan@digium.com>
  25. *
  26. */
  27. #ifndef _ASTERISK_RES_HEPV3_H
  28. #define _ASTERISK_RES_HEPV3_H
  29. #if defined(__cplusplus) || defined(c_plusplus)
  30. extern "C" {
  31. #endif
  32. #include "asterisk/netsock2.h"
  33. /*! \brief HEPv3 Packet Capture Types */
  34. enum hepv3_capture_type {
  35. HEPV3_CAPTURE_TYPE_SIP = 0x01,
  36. HEPV3_CAPTURE_TYPE_H323 = 0x02,
  37. HEPV3_CAPTURE_TYPE_SDP = 0x03,
  38. HEPV3_CAPTURE_TYPE_RTP = 0x04,
  39. HEPV3_CAPTURE_TYPE_RTCP = 0x05,
  40. HEPV3_CAPTURE_TYPE_MGCP = 0x06,
  41. HEPV3_CAPTURE_TYPE_MEGACO = 0x07,
  42. HEPV3_CAPTURE_TYPE_M2UA = 0x08,
  43. HEPV3_CAPTURE_TYPE_M3UA = 0x09,
  44. HEPV3_CAPTURE_TYPE_IAX = 0x10,
  45. };
  46. enum hep_uuid_type {
  47. HEP_UUID_TYPE_CALL_ID = 0,
  48. HEP_UUID_TYPE_CHANNEL,
  49. };
  50. /*! \brief HEPv3 Capture Info */
  51. struct hepv3_capture_info {
  52. /*! The source address of the packet */
  53. struct ast_sockaddr src_addr;
  54. /*! The destination address of the packet */
  55. struct ast_sockaddr dst_addr;
  56. /*! The time the packet was captured */
  57. struct timeval capture_time;
  58. /*! The actual payload */
  59. void *payload;
  60. /*! Some UUID for the packet */
  61. char *uuid;
  62. /*! The \ref hepv3_capture_type packet type captured */
  63. enum hepv3_capture_type capture_type;
  64. /*! The size of the payload */
  65. size_t len;
  66. /*! If non-zero, the payload accompanying this capture info will be compressed */
  67. unsigned int zipped:1;
  68. /*! The IPPROTO_* protocol where we captured the packet */
  69. int protocol_id;
  70. };
  71. /*!
  72. * \brief Create a \ref hepv3_capture_info object
  73. *
  74. * This returned object is an ao2 reference counted object.
  75. *
  76. * Any attribute in the returned \ref hepv3_capture_info that is a
  77. * pointer should point to something that is allocated on the heap,
  78. * as it will be free'd when the \ref hepv3_capture_info object is
  79. * reclaimed.
  80. *
  81. * \param payload The payload to send to the HEP capture node
  82. * \param len Length of \ref payload
  83. *
  84. * \retval A \ref hepv3_capture_info ref counted object on success
  85. * \retval NULL on error
  86. */
  87. struct hepv3_capture_info *hepv3_create_capture_info(const void *payload, size_t len);
  88. /*!
  89. * \brief Send a generic packet capture to HEPv3
  90. *
  91. * \param capture_info Information describing the packet. This
  92. * should be a reference counted object, created via
  93. * \ref hepv3_create_capture_info.
  94. *
  95. * Once this function is called, it assumes ownership of the
  96. * \ref capture_info object and steals the reference of the
  97. * object. Regardless of success or failure, the calling function
  98. * should assumed that this function will own the object.
  99. *
  100. * \retval 0 on success
  101. * \retval -1 on error
  102. */
  103. int hepv3_send_packet(struct hepv3_capture_info *capture_info);
  104. /*!
  105. * \brief Get the preferred UUID type
  106. *
  107. * \since 13.10.0
  108. *
  109. * \retval The type of UUID the packet should use
  110. */
  111. enum hep_uuid_type hepv3_get_uuid_type(void);
  112. /*!
  113. * \brief Return whether or not we're currently loaded and active
  114. *
  115. * \retval 0 The module is not loaded
  116. * \retval 1 The module is loaded
  117. */
  118. int hepv3_is_loaded(void);
  119. #if defined(__cplusplus) || defined(c_plusplus)
  120. }
  121. #endif
  122. #endif /* _ASTERISK_RES_HEPV3_H */