Asterisk - The Open Source Telephony Project  21.4.1
res_hep.h
Go to the documentation of this file.
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 */
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_MEGACO = 0x07,
46  HEPV3_CAPTURE_TYPE_M2UA = 0x08,
47  HEPV3_CAPTURE_TYPE_M3UA = 0x09,
48  HEPV3_CAPTURE_TYPE_IAX = 0x10,
49 };
50 
51 enum hep_uuid_type {
52  HEP_UUID_TYPE_CALL_ID = 0,
53  HEP_UUID_TYPE_CHANNEL,
54 };
55 
56 /*! \brief HEPv3 Capture Info */
58  /*! The source address of the packet */
60  /*! The destination address of the packet */
62  /*! The time the packet was captured */
63  struct timeval capture_time;
64  /*! The actual payload */
65  void *payload;
66  /*! Some UUID for the packet */
67  char *uuid;
68  /*! The \ref hepv3_capture_type packet type captured */
70  /*! The size of the payload */
71  size_t len;
72  /*! If non-zero, the payload accompanying this capture info will be compressed */
73  unsigned int zipped:1;
74  /*! The IPPROTO_* protocol where we captured the packet */
76 };
77 
78 /*!
79  * \brief Create a \ref hepv3_capture_info object
80  *
81  * This returned object is an ao2 reference counted object.
82  *
83  * Any attribute in the returned \ref hepv3_capture_info that is a
84  * pointer should point to something that is allocated on the heap,
85  * as it will be free'd when the \ref hepv3_capture_info object is
86  * reclaimed.
87  *
88  * \param payload The payload to send to the HEP capture node
89  * \param len Length of \p payload
90  *
91  * \return A \ref hepv3_capture_info ref counted object on success
92  * \retval NULL on error
93  */
94 struct hepv3_capture_info *hepv3_create_capture_info(const void *payload, size_t len);
95 
96 /*!
97  * \brief Send a generic packet capture to HEPv3
98  *
99  * \param capture_info Information describing the packet. This
100  * should be a reference counted object, created via
101  * \ref hepv3_create_capture_info.
102  *
103  * Once this function is called, it assumes ownership of the
104  * \p capture_info object and steals the reference of the
105  * object. Regardless of success or failure, the calling function
106  * should assumed that this function will own the object.
107  *
108  * \retval 0 on success
109  * \retval -1 on error
110  */
111 int hepv3_send_packet(struct hepv3_capture_info *capture_info);
112 
113 /*!
114  * \brief Get the preferred UUID type
115  *
116  * \since 13.10.0
117  *
118  * \return The type of UUID the packet should use
119  */
120 enum hep_uuid_type hepv3_get_uuid_type(void);
121 
122 /*!
123  * \brief Return whether or not we're currently loaded and active
124  *
125  * \retval 0 The module is not loaded
126  * \retval 1 The module is loaded
127  */
128 int hepv3_is_loaded(void);
129 
130 #if defined(__cplusplus) || defined(c_plusplus)
131 }
132 #endif
133 
134 #endif /* _ASTERISK_RES_HEPV3_H */
struct ast_sockaddr src_addr
Definition: res_hep.h:59
enum hepv3_capture_type capture_type
Definition: res_hep.h:69
struct ast_sockaddr dst_addr
Definition: res_hep.h:61
hepv3_capture_type
HEPv3 Packet Capture Types.
Definition: res_hep.h:39
Socket address structure.
Definition: netsock2.h:97
unsigned int zipped
Definition: res_hep.h:73
HEPv3 Capture Info.
Definition: res_hep.h:57
Network socket handling.
struct hepv3_capture_info * hepv3_create_capture_info(const void *payload, size_t len)
Create a hepv3_capture_info object.
Definition: res_hep.c:435
enum hep_uuid_type hepv3_get_uuid_type(void)
Get the preferred UUID type.
Definition: res_hep.c:416
int hepv3_is_loaded(void)
Return whether or not we're currently loaded and active.
Definition: res_hep.c:428
struct timeval capture_time
Definition: res_hep.h:63
int hepv3_send_packet(struct hepv3_capture_info *capture_info)
Send a generic packet capture to HEPv3.
Definition: res_hep.c:600
void * payload
Definition: res_hep.h:65