Asterisk - The Open Source Telephony Project GIT-master-d5a0626
|
Routines for integration with Homer using HEPv3. More...
#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/astobj2.h"
#include "asterisk/config_options.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/res_hep.h"
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <netinet/ip6.h>
Go to the source code of this file.
Data Structures | |
struct | hep_chunk |
struct | hep_chunk_ip4 |
struct | hep_chunk_ip6 |
struct | hep_chunk_uint16 |
struct | hep_chunk_uint32 |
struct | hep_chunk_uint8 |
struct | hep_ctrl |
struct | hep_generic |
struct | hepv3_global_config |
Global configuration for the module. More... | |
struct | hepv3_runtime_data |
Run-time data derived from hepv3_global_config. More... | |
struct | module_config |
The configuration settings for this module. More... | |
Macros | |
#define | ASTERISK_VENDOR_ID 0x0004 |
#define | GENERIC_VENDOR_ID 0x0000 |
#define | INITIALIZE_GENERIC_HEP_CHUNK(hep_item, type) |
#define | INITIALIZE_GENERIC_HEP_CHUNK_DATA(hep_item, type, value) |
#define | INITIALIZE_GENERIC_HEP_IDS(hep_chunk, type) |
#define | INITIALIZE_GENERIC_HEP_IDS_VAR(hep_chunk, type, len) |
Enumerations | |
enum | hepv3_chunk_types { CHUNK_TYPE_IP_PROTOCOL_FAMILY = 0X0001 , CHUNK_TYPE_IP_PROTOCOL_ID = 0X0002 , CHUNK_TYPE_IPV4_SRC_ADDR = 0X0003 , CHUNK_TYPE_IPV4_DST_ADDR = 0X0004 , CHUNK_TYPE_IPV6_SRC_ADDR = 0X0005 , CHUNK_TYPE_IPV6_DST_ADDR = 0X0006 , CHUNK_TYPE_SRC_PORT = 0X0007 , CHUNK_TYPE_DST_PORT = 0X0008 , CHUNK_TYPE_TIMESTAMP_SEC = 0X0009 , CHUNK_TYPE_TIMESTAMP_USEC = 0X000A , CHUNK_TYPE_PROTOCOL_TYPE = 0X000B , CHUNK_TYPE_CAPTURE_AGENT_ID = 0X000C , CHUNK_TYPE_KEEP_ALIVE_TIMER = 0X000D , CHUNK_TYPE_AUTH_KEY = 0X000E , CHUNK_TYPE_PAYLOAD = 0X000F , CHUNK_TYPE_PAYLOAD_ZIP = 0X0010 , CHUNK_TYPE_UUID = 0X0011 , CHUNK_TYPE_CAPTURE_AGENT_NAME = 0X0013 } |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static | AO2_GLOBAL_OBJ_STATIC (global_config) |
The module configuration container. More... | |
static | AO2_GLOBAL_OBJ_STATIC (global_data) |
Current module data. More... | |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static void | capture_info_dtor (void *obj) |
Destructor for a hepv3_capture_info object. More... | |
CONFIG_INFO_STANDARD (cfg_info, global_config, module_config_alloc,.files=ACO_FILES(&hepv3_conf),.pre_apply_config=hepv3_config_pre_apply,.post_apply_config=hepv3_config_post_apply,) | |
Register information about the configs being processed by this module. More... | |
static int | hep_queue_cb (void *data) |
Callback function for the hep_queue_tp taskprocessor. More... | |
static void * | hepv3_config_alloc (void) |
HEPv3 configuration object allocation. More... | |
static void | hepv3_config_dtor (void *obj) |
static void | hepv3_config_post_apply (void) |
Post-apply callback for the config framework. More... | |
static int | hepv3_config_pre_apply (void) |
Pre-apply callback for the config framework. More... | |
struct hepv3_capture_info * | hepv3_create_capture_info (const void *payload, size_t len) |
Create a hepv3_capture_info object. More... | |
static struct hepv3_runtime_data * | hepv3_data_alloc (struct hepv3_global_config *config) |
Allocate the HEPv3 run-time data. More... | |
static void | hepv3_data_dtor (void *obj) |
HEPv3 run-time data destructor. More... | |
enum hep_uuid_type | hepv3_get_uuid_type (void) |
Get the preferred UUID type. More... | |
int | hepv3_is_loaded (void) |
Return whether or not we're currently loaded and active. More... | |
int | hepv3_send_packet (struct hepv3_capture_info *capture_info) |
Send a generic packet capture to HEPv3. More... | |
static int | load_module (void) |
Load the module. More... | |
static void * | module_config_alloc (void) |
Module config constructor. More... | |
static void | module_config_dtor (void *obj) |
Configuration object destructor. More... | |
static int | reload_module (void) |
Reload the module. More... | |
static int | unload_module (void) |
Unload the module. More... | |
static int | uuid_type_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) |
Handler for the uuid_type attribute. More... | |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "HEPv3 API" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_APP_DEPEND, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct aco_type | global_option |
struct aco_type * | global_options [] = ACO_TYPES(&global_option) |
static struct ast_taskprocessor * | hep_queue_tp |
struct aco_file | hepv3_conf |
Routines for integration with Homer using HEPv3.
Definition in file res_hep.c.
#define ASTERISK_VENDOR_ID 0x0004 |
#define GENERIC_VENDOR_ID 0x0000 |
#define INITIALIZE_GENERIC_HEP_CHUNK | ( | hep_item, | |
type | |||
) |
enum hepv3_chunk_types |
Chunk types from the HEPv3 Spec
Definition at line 109 of file res_hep.c.
|
static |
The module configuration container.
|
static |
Current module data.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
|
static |
Destructor for a hepv3_capture_info object.
Definition at line 408 of file res_hep.c.
References ast_free, and sip_to_pjsip::info().
Referenced by hepv3_create_capture_info().
CONFIG_INFO_STANDARD | ( | cfg_info | , |
global_config | , | ||
module_config_alloc | , | ||
. | files = ACO_FILES(&hepv3_conf) , |
||
. | pre_apply_config = hepv3_config_pre_apply , |
||
. | post_apply_config = hepv3_config_post_apply |
||
) |
Register information about the configs being processed by this module.
|
static |
Callback function for the hep_queue_tp taskprocessor.
Definition at line 459 of file res_hep.c.
References ao2_cleanup, ao2_global_obj_ref, ast_assert, ast_free, ast_log, AST_LOG_ERROR, AST_LOG_NOTICE, AST_LOG_WARNING, ast_malloc, ast_sendto(), ast_sockaddr_is_ipv4(), ast_sockaddr_port, ast_sockaddr_stringify_addr(), ast_strlen_zero(), hep_generic::capt_id, CHUNK_TYPE_AUTH_KEY, CHUNK_TYPE_CAPTURE_AGENT_ID, CHUNK_TYPE_CAPTURE_AGENT_NAME, CHUNK_TYPE_DST_PORT, CHUNK_TYPE_IP_PROTOCOL_FAMILY, CHUNK_TYPE_IP_PROTOCOL_ID, CHUNK_TYPE_IPV4_DST_ADDR, CHUNK_TYPE_IPV4_SRC_ADDR, CHUNK_TYPE_IPV6_DST_ADDR, CHUNK_TYPE_IPV6_SRC_ADDR, CHUNK_TYPE_PAYLOAD, CHUNK_TYPE_PAYLOAD_ZIP, CHUNK_TYPE_PROTOCOL_TYPE, CHUNK_TYPE_SRC_PORT, CHUNK_TYPE_TIMESTAMP_SEC, CHUNK_TYPE_TIMESTAMP_USEC, CHUNK_TYPE_UUID, config, hep_chunk_ip4::data, hep_chunk_ip6::data, hep_generic::dst_port, errno, hep_generic::header, hep_ctrl::id, INITIALIZE_GENERIC_HEP_CHUNK, INITIALIZE_GENERIC_HEP_CHUNK_DATA, INITIALIZE_GENERIC_HEP_IDS_VAR, hep_generic::ip_family, hep_generic::ip_proto, hep_ctrl::length, hep_generic::proto_t, RAII_VAR, hep_generic::src_port, hep_generic::time_sec, and hep_generic::time_usec.
Referenced by hepv3_send_packet().
|
static |
HEPv3 configuration object allocation.
Definition at line 306 of file res_hep.c.
References ao2_alloc, ast_string_field_init, config, hepv3_config_dtor(), and NULL.
Referenced by module_config_alloc().
|
static |
Definition at line 298 of file res_hep.c.
References ast_string_field_free_memory, and config.
Referenced by hepv3_config_alloc().
|
static |
Post-apply callback for the config framework.
This will create the run-time information from the supplied configuration.
Definition at line 646 of file res_hep.c.
References ao2_cleanup, ao2_global_obj_ref, ao2_global_obj_replace_unref, ao2_ref, hepv3_data_alloc(), and RAII_VAR.
|
static |
Pre-apply callback for the config framework.
This validates that required fields exist and are populated.
Definition at line 623 of file res_hep.c.
References aco_pending_config(), ast_log, AST_LOG_ERROR, ast_strlen_zero(), and config.
struct hepv3_capture_info * hepv3_create_capture_info | ( | const void * | payload, |
size_t | len | ||
) |
Create a hepv3_capture_info object.
This returned object is an ao2 reference counted object.
Any attribute in the returned 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 hepv3_capture_info object is reclaimed.
payload | The payload to send to the HEP capture node |
len | Length of payload |
NULL | on error |
Definition at line 435 of file res_hep.c.
References ao2_alloc, ao2_ref, ast_malloc, capture_info_dtor(), sip_to_pjsip::info(), len(), NULL, and hepv3_capture_info::payload.
Referenced by logging_on_rx_msg(), logging_on_tx_msg(), and rtcp_message_handler().
|
static |
Allocate the HEPv3 run-time data.
Definition at line 378 of file res_hep.c.
References ao2_alloc, ao2_ref, AST_AF_UNSPEC, ast_log, AST_LOG_WARNING, ast_sockaddr_is_ipv6(), ast_sockaddr_resolve_first_af(), config, errno, hepv3_data_dtor(), NULL, PARSE_PORT_REQUIRE, hepv3_runtime_data::remote_addr, and hepv3_runtime_data::sockfd.
Referenced by hepv3_config_post_apply().
|
static |
HEPv3 run-time data destructor.
Definition at line 367 of file res_hep.c.
References hepv3_runtime_data::sockfd.
Referenced by hepv3_data_alloc().
enum hep_uuid_type hepv3_get_uuid_type | ( | void | ) |
Get the preferred UUID type.
Definition at line 416 of file res_hep.c.
References ao2_cleanup, ao2_global_obj_ref, config, HEP_UUID_TYPE_CALL_ID, and RAII_VAR.
Referenced by assign_uuid().
int hepv3_is_loaded | ( | void | ) |
Return whether or not we're currently loaded and active.
0 | The module is not loaded |
1 | The module is loaded |
Definition at line 428 of file res_hep.c.
References ao2_cleanup, ao2_global_obj_ref, config, and RAII_VAR.
Referenced by load_module().
int hepv3_send_packet | ( | struct hepv3_capture_info * | capture_info | ) |
Send a generic packet capture to HEPv3.
capture_info | Information describing the packet. This should be a reference counted object, created via hepv3_create_capture_info. |
Once this function is called, it assumes ownership of the 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.
0 | on success |
-1 | on error |
Definition at line 600 of file res_hep.c.
References ao2_cleanup, ao2_global_obj_ref, ao2_ref, ast_taskprocessor_push(), config, hep_queue_cb(), hep_queue_tp, and RAII_VAR.
Referenced by logging_on_rx_msg(), logging_on_tx_msg(), and rtcp_message_handler().
|
static |
Load the module.
Definition at line 688 of file res_hep.c.
References ACO_EXACT, aco_info_destroy(), aco_info_init(), aco_option_register, aco_option_register_custom, aco_process_config(), ACO_PROCESS_ERROR, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_taskprocessor_get(), enabled, error(), FLDSET, global_options, hep_queue_tp, OPT_BOOL_T, OPT_STRINGFIELD_T, OPT_UINT_T, STRFLDSET, TPS_REF_DEFAULT, and uuid_type_handler().
|
static |
Module config constructor.
Definition at line 329 of file res_hep.c.
References ao2_alloc, ao2_ref, config, hepv3_config_alloc(), module_config_dtor(), and NULL.
|
static |
Configuration object destructor.
Definition at line 319 of file res_hep.c.
References ao2_ref, and config.
Referenced by module_config_alloc().
|
static |
Reload the module.
Definition at line 663 of file res_hep.c.
References aco_process_config(), and ACO_PROCESS_ERROR.
|
static |
Unload the module.
Definition at line 674 of file res_hep.c.
References aco_info_destroy(), ao2_global_obj_release, ast_taskprocessor_unreference(), and hep_queue_tp.
|
static |
Handler for the uuid_type attribute.
Definition at line 348 of file res_hep.c.
References HEP_UUID_TYPE_CALL_ID, HEP_UUID_TYPE_CHANNEL, and var.
Referenced by load_module().
|
static |
|
static |
struct aco_type* global_options[] = ACO_TYPES(&global_option) |
Definition at line 272 of file res_hep.c.
Referenced by load_module().
|
static |
Definition at line 285 of file res_hep.c.
Referenced by hepv3_send_packet(), load_module(), and unload_module().
struct aco_file hepv3_conf |