res_hep/res_hep_pjsip: Add a HEPv3 capture agent module and a logger for PJSIP
[asterisk/asterisk.git] / include / asterisk / res_hep.h
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 /*!
21  * \file
22  * \brief Routines for integration with Homer using HEPv3
23  *
24  * \author Alexandr Dubovikov <alexandr.dubovikov@sipcapture.org>
25  * \author Matt Jordan <mjordan@digium.com>
26  *
27  */
28
29 #ifndef _ASTERISK_RES_HEPV3_H
30 #define _ASTERISK_RES_HEPV3_H
31
32 #if defined(__cplusplus) || defined(c_plusplus)
33 extern "C" {
34 #endif
35
36 #include "asterisk/netsock2.h"
37
38 /*! \brief HEPv3 Packet Capture Types */
39 enum hepv3_capture_type {
40         HEPV3_CAPTURE_TYPE_SIP    = 0x01,
41         HEPV3_CAPTURE_TYPE_H323   = 0x02,
42         HEPV3_CAPTURE_TYPE_SDP    = 0x03,
43         HEPV3_CAPTURE_TYPE_RTP    = 0x04,
44         HEPV3_CAPTURE_TYPE_RTCP   = 0x05,
45         HEPV3_CAPTURE_TYPE_MGCP   = 0x06,
46         HEPV3_CAPTURE_TYPE_MEGACO = 0x07,
47         HEPV3_CAPTURE_TYPE_M2UA   = 0x08,
48         HEPV3_CAPTURE_TYPE_M3UA   = 0x09,
49         HEPV3_CAPTURE_TYPE_IAX    = 0x10,
50 };
51
52 /*! \brief HEPv3 Capture Info */
53 struct hepv3_capture_info {
54         /*! The source address of the packet */
55         struct ast_sockaddr src_addr;
56         /*! The destination address of the packet */
57         struct ast_sockaddr dst_addr;
58         /*! The time the packet was captured */
59         struct timeval capture_time;
60         /*! The actual payload */
61         void *payload;
62         /*! Some UUID for the packet */
63         char *uuid;
64         /*! The \ref hepv3_capture_type packet type captured */
65         enum hepv3_capture_type capture_type;
66         /*! The size of the payload */
67         size_t len;
68         /*! If non-zero, the payload accompanying this capture info will be compressed */
69         unsigned int zipped:1;
70 };
71
72 /*!
73  * \brief Create a \ref hepv3_capture_info object
74  *
75  * This returned object is an ao2 reference counted object.
76  *
77  * Any attribute in the returned \ref hepv3_capture_info that is a
78  * pointer should point to something that is allocated on the heap,
79  * as it will be free'd when the \ref hepv3_capture_info object is
80  * reclaimed.
81  *
82  * \param payload The payload to send to the HEP capture node
83  * \param len     Length of \ref payload
84  *
85  * \retval A \ref hepv3_capture_info ref counted object on success
86  * \retval NULL on error
87  */
88 struct hepv3_capture_info *hepv3_create_capture_info(const void *payload, size_t len);
89
90 /*!
91  * \brief Send a generic packet capture to HEPv3
92  *
93  * \param capture_info Information describing the packet. This
94  * should be a reference counted object, created via
95  * \ref hepv3_create_capture_info.
96  *
97  * Once this function is called, it assumes ownership of the
98  * \ref capture_info object and steals the reference of the
99  * object. Regardless of success or failure, the calling function
100  * should assumed that this function will own the object.
101  *
102  * \retval 0 on success
103  * \retval -1 on error
104  */
105 int hepv3_send_packet(struct hepv3_capture_info *capture_info);
106
107 #if defined(__cplusplus) || defined(c_plusplus)
108 }
109 #endif
110
111 #endif /* _ASTERISK_RES_HEPV3_H */