Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Enumerations | Functions
res_hep.h File Reference

Routines for integration with Homer using HEPv3. More...

#include "asterisk/netsock2.h"
Include dependency graph for res_hep.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  hepv3_capture_info
 HEPv3 Capture Info. More...
 

Enumerations

enum  hep_uuid_type { HEP_UUID_TYPE_CALL_ID = 0, HEP_UUID_TYPE_CHANNEL }
 
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
}
 HEPv3 Packet Capture Types. More...
 

Functions

struct hepv3_capture_infohepv3_create_capture_info (const void *payload, size_t len)
 Create a hepv3_capture_info object. 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...
 

Detailed Description

Routines for integration with Homer using HEPv3.

Author
Alexandr Dubovikov alexa[email protected].ndr.[email protected].dubov[email protected].ikov[email protected].@sipc[email protected].aptu[email protected].re.or[email protected].g
Matt Jordan mjord[email protected].[email protected][email protected].igium[email protected]..com

Definition in file res_hep.h.

Enumeration Type Documentation

◆ hep_uuid_type

Enumerator
HEP_UUID_TYPE_CALL_ID 
HEP_UUID_TYPE_CHANNEL 

Definition at line 52 of file res_hep.h.

◆ hepv3_capture_type

HEPv3 Packet Capture Types.

Enumerator
HEPV3_CAPTURE_TYPE_SIP 
HEPV3_CAPTURE_TYPE_H323 
HEPV3_CAPTURE_TYPE_SDP 
HEPV3_CAPTURE_TYPE_RTP 
HEPV3_CAPTURE_TYPE_RTCP 
HEPV3_CAPTURE_TYPE_MGCP 
HEPV3_CAPTURE_TYPE_MEGACO 
HEPV3_CAPTURE_TYPE_M2UA 
HEPV3_CAPTURE_TYPE_M3UA 
HEPV3_CAPTURE_TYPE_IAX 

Definition at line 39 of file res_hep.h.

Function Documentation

◆ hepv3_create_capture_info()

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.

Parameters
payloadThe payload to send to the HEP capture node
lenLength of payload
Return values
Ahepv3_capture_info ref counted object on success
NULLon error

Definition at line 428 of file res_hep.c.

References ao2_alloc, ao2_ref, ast_malloc, capture_info_dtor(), sip_to_pjsip::info(), hepv3_capture_info::len, len(), NULL, hepv3_capture_info::payload, and hepv3_capture_info::protocol_id.

Referenced by logging_on_rx_msg(), logging_on_tx_msg(), and rtcp_message_handler().

429 {
430  struct hepv3_capture_info *info;
431 
432  info = ao2_alloc(sizeof(*info), capture_info_dtor);
433  if (!info) {
434  return NULL;
435  }
436 
437  info->payload = ast_malloc(len);
438  if (!info->payload) {
439  ao2_ref(info, -1);
440  return NULL;
441  }
442  memcpy(info->payload, payload, len);
443  info->len = len;
444 
445  /* Set a reasonable default */
446  info->protocol_id = IPPROTO_UDP;
447 
448  return info;
449 }
#define NULL
Definition: resample.c:96
HEPv3 Capture Info.
Definition: res_hep.h:58
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:193
static void capture_info_dtor(void *obj)
Destructor for a hepv3_capture_info object.
Definition: res_hep.c:401
def info(msg)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
void * payload
Definition: res_hep.h:66

◆ hepv3_get_uuid_type()

enum hep_uuid_type hepv3_get_uuid_type ( void  )

Get the preferred UUID type.

Since
13.10.0
Return values
Thetype of UUID the packet should use

Definition at line 409 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().

410 {
412 
413  if (!config) {
414  /* Well, that's unfortunate. Return something. */
415  return HEP_UUID_TYPE_CALL_ID;
416  }
417 
418  return config->general->uuid_type;
419 }
char * config
Definition: conf2ael.c:66
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
The configuration settings for this module.
Definition: cdr.c:222
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ hepv3_is_loaded()

int hepv3_is_loaded ( void  )

Return whether or not we're currently loaded and active.

Return values
0The module is not loaded
1The module is loaded

Definition at line 421 of file res_hep.c.

References ao2_cleanup, ao2_global_obj_ref, config, and RAII_VAR.

Referenced by load_module().

422 {
424 
425  return config && config->general->enabled;
426 }
char * config
Definition: conf2ael.c:66
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
The configuration settings for this module.
Definition: cdr.c:222
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ hepv3_send_packet()

int hepv3_send_packet ( struct hepv3_capture_info capture_info)

Send a generic packet capture to HEPv3.

Parameters
capture_infoInformation 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.

Return values
0on success
-1on error

Definition at line 581 of file res_hep.c.

References ao2_cleanup, ao2_global_obj_ref, ao2_ref, ast_taskprocessor_push(), config, hep_queue_cb(), and RAII_VAR.

Referenced by logging_on_rx_msg(), logging_on_tx_msg(), and rtcp_message_handler().

582 {
584  int res;
585 
586  if (!config || !config->general->enabled) {
587  ao2_ref(capture_info, -1);
588  return 0;
589  }
590 
591  res = ast_taskprocessor_push(hep_queue_tp, hep_queue_cb, capture_info);
592  if (res == -1) {
593  ao2_ref(capture_info, -1);
594  }
595 
596  return res;
597 }
char * config
Definition: conf2ael.c:66
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
The configuration settings for this module.
Definition: cdr.c:222
static struct ast_taskprocessor * hep_queue_tp
Definition: res_hep.c:278
int ast_taskprocessor_push(struct ast_taskprocessor *tps, int(*task_exe)(void *datap), void *datap) attribute_warn_unused_result
Push a task into the specified taskprocessor queue and signal the taskprocessor thread.
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static int hep_queue_cb(void *data)
Callback function for the hep_queue_tp taskprocessor.
Definition: res_hep.c:452