res_hep/res_hep_pjsip: Add a HEPv3 capture agent module and a logger for PJSIP

This patch adds the following:
(1) A new module, res_hep, which implements a generic packet capture agent for
the Homer Encapsulation Protocol (HEP) version 3. Note that this code is based
on a patch provided by Alexandr Dubovikov; I basically just wrapped it up,
added configuration via the configuration framework, and threw in a
taskprocessor.
(2) A new module, res_hep_pjsip, which forwards all SIP message traffic that
passes through the res_pjsip stack over to res_hep for encapsulation and
transmission to a HEPv3 capture server.

Much thanks to Alexandr for his Asterisk patch for this code and for a *lot*
of patience waiting for me to port it to 12/trunk. Due to some dithering on
my part, this has taken the better part of a year to port forward (I still
blame CDRs for the delay).

ASTERISK-23557 #close

Review: https://reviewboard.asterisk.org/r/3207/
........

Merged revisions 411534 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@411556 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Matthew Jordan
2014-03-28 18:32:50 +00:00
parent a35ce3924b
commit ef0c9fe4d8
6 changed files with 917 additions and 10 deletions

111
include/asterisk/res_hep.h Normal file
View File

@@ -0,0 +1,111 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 1999 - 2014, Digium, Inc.
*
* Alexandr Dubovikov <alexandr.dubovikov@sipcapture.org>
* Matt Jordan <mjordan@digium.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief Routines for integration with Homer using HEPv3
*
* \author Alexandr Dubovikov <alexandr.dubovikov@sipcapture.org>
* \author Matt Jordan <mjordan@digium.com>
*
*/
#ifndef _ASTERISK_RES_HEPV3_H
#define _ASTERISK_RES_HEPV3_H
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
#include "asterisk/netsock2.h"
/*! \brief HEPv3 Packet Capture Types */
enum hepv3_capture_type {
HEPV3_CAPTURE_TYPE_SIP = 0x01,
HEPV3_CAPTURE_TYPE_H323 = 0x02,
HEPV3_CAPTURE_TYPE_SDP = 0x03,
HEPV3_CAPTURE_TYPE_RTP = 0x04,
HEPV3_CAPTURE_TYPE_RTCP = 0x05,
HEPV3_CAPTURE_TYPE_MGCP = 0x06,
HEPV3_CAPTURE_TYPE_MEGACO = 0x07,
HEPV3_CAPTURE_TYPE_M2UA = 0x08,
HEPV3_CAPTURE_TYPE_M3UA = 0x09,
HEPV3_CAPTURE_TYPE_IAX = 0x10,
};
/*! \brief HEPv3 Capture Info */
struct hepv3_capture_info {
/*! The source address of the packet */
struct ast_sockaddr src_addr;
/*! The destination address of the packet */
struct ast_sockaddr dst_addr;
/*! The time the packet was captured */
struct timeval capture_time;
/*! The actual payload */
void *payload;
/*! Some UUID for the packet */
char *uuid;
/*! The \ref hepv3_capture_type packet type captured */
enum hepv3_capture_type capture_type;
/*! The size of the payload */
size_t len;
/*! If non-zero, the payload accompanying this capture info will be compressed */
unsigned int zipped:1;
};
/*!
* \brief Create a \ref hepv3_capture_info object
*
* This returned object is an ao2 reference counted object.
*
* Any attribute in the returned \ref hepv3_capture_info that is a
* pointer should point to something that is allocated on the heap,
* as it will be free'd when the \ref hepv3_capture_info object is
* reclaimed.
*
* \param payload The payload to send to the HEP capture node
* \param len Length of \ref payload
*
* \retval A \ref hepv3_capture_info ref counted object on success
* \retval NULL on error
*/
struct hepv3_capture_info *hepv3_create_capture_info(const void *payload, size_t len);
/*!
* \brief Send a generic packet capture to HEPv3
*
* \param capture_info Information describing the packet. This
* should be a reference counted object, created via
* \ref hepv3_create_capture_info.
*
* Once this function is called, it assumes ownership of the
* \ref capture_info object and steals the reference of the
* object. Regardless of success or failure, the calling function
* should assumed that this function will own the object.
*
* \retval 0 on success
* \retval -1 on error
*/
int hepv3_send_packet(struct hepv3_capture_info *capture_info);
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
#endif /* _ASTERISK_RES_HEPV3_H */