Skip to content

Commit 1c57387

Browse files
InterLinked1gtjoseph
authored andcommitted
res_hep: Add support for named capture agents.
Adds support for the capture agent name field of the Homer protocol to Asterisk by allowing users to specify a name that will be sent to the HEP server. ASTERISK-30322 #close Change-Id: I6136583017f9dd08daeb8be02f60fb8df4639a2b
1 parent 97d1613 commit 1c57387

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

configs/samples/hep.conf.sample

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ capture_password = foo ; If specified, the authorization password
2222
capture_id = 1234 ; A unique integer identifier for this
2323
; server. This ID will be embedded sent
2424
; with each packet from this server.
25+
;capture_name = asterisk ; A unique string identifier for this
26+
; server. This ID will be embedded sent
27+
; with each packet from this server.
2528
uuid_type = call-id ; Specify the preferred source for the Homer
2629
; correlation UUID. Valid options are:
2730
; - 'call-id' for the PJSIP or chan_sip SIP

doc/CHANGES-staging/res_hep.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Subject: Add support for named capture agent.
2+
3+
A name for the capture agent can now be specified
4+
using the capture_name option which, if specified,
5+
will be sent to the HEP server.

res/res_hep.c

+21-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@
7878
<configOption name="capture_id" default="0">
7979
<synopsis>The ID for this capture agent.</synopsis>
8080
</configOption>
81+
<configOption name="capture_name" default="">
82+
<synopsis>The name for this capture agent.</synopsis>
83+
</configOption>
8184
</configObject>
8285
</configFile>
8386
</configInfo>
@@ -155,6 +158,9 @@ enum hepv3_chunk_types {
155158

156159
/*! THE UUID FOR THIS PACKET */
157160
CHUNK_TYPE_UUID = 0X0011,
161+
162+
/*! THE CAPTURE AGENT NAME */
163+
CHUNK_TYPE_CAPTURE_AGENT_NAME = 0X0013,
158164
};
159165

160166
#define INITIALIZE_GENERIC_HEP_IDS(hep_chunk, type) do { \
@@ -240,6 +246,7 @@ struct hepv3_global_config {
240246
AST_DECLARE_STRING_FIELDS(
241247
AST_STRING_FIELD(capture_address); /*!< Address to send to */
242248
AST_STRING_FIELD(capture_password); /*!< Password for Homer server */
249+
AST_STRING_FIELD(capture_name); /*!< Capture name for this agent */
243250
);
244251
};
245252

@@ -458,7 +465,7 @@ static int hep_queue_cb(void *data)
458465
unsigned int packet_len = 0, sock_buffer_len;
459466
struct hep_chunk_ip4 ipv4_src, ipv4_dst;
460467
struct hep_chunk_ip6 ipv6_src, ipv6_dst;
461-
struct hep_chunk auth_key, payload, uuid;
468+
struct hep_chunk auth_key, payload, uuid, capturename;
462469
void *sock_buffer;
463470
int res;
464471

@@ -512,6 +519,10 @@ static int hep_queue_cb(void *data)
512519
INITIALIZE_GENERIC_HEP_IDS_VAR(&auth_key, CHUNK_TYPE_AUTH_KEY, strlen(config->general->capture_password));
513520
packet_len += (sizeof(auth_key) + strlen(config->general->capture_password));
514521
}
522+
if (!ast_strlen_zero(config->general->capture_name)) {
523+
INITIALIZE_GENERIC_HEP_IDS_VAR(&capturename, CHUNK_TYPE_CAPTURE_AGENT_NAME, strlen(config->general->capture_name));
524+
packet_len += (sizeof(capturename) + strlen(config->general->capture_name));
525+
}
515526
INITIALIZE_GENERIC_HEP_IDS_VAR(&uuid, CHUNK_TYPE_UUID, strlen(capture_info->uuid));
516527
packet_len += (sizeof(uuid) + strlen(capture_info->uuid));
517528
INITIALIZE_GENERIC_HEP_IDS_VAR(&payload,
@@ -556,6 +567,14 @@ static int hep_queue_cb(void *data)
556567
memcpy(sock_buffer + sock_buffer_len, capture_info->uuid, strlen(capture_info->uuid));
557568
sock_buffer_len += strlen(capture_info->uuid);
558569

570+
/* Capture Agent Name */
571+
if (!ast_strlen_zero(config->general->capture_name)) {
572+
memcpy(sock_buffer + sock_buffer_len, &capturename, sizeof(capturename));
573+
sock_buffer_len += sizeof(capturename);
574+
memcpy(sock_buffer + sock_buffer_len, config->general->capture_name, strlen(config->general->capture_name));
575+
sock_buffer_len += strlen(config->general->capture_name);
576+
}
577+
559578
/* Packet! */
560579
memcpy(sock_buffer + sock_buffer_len, &payload, sizeof(payload));
561580
sock_buffer_len += sizeof(payload);
@@ -681,6 +700,7 @@ static int load_module(void)
681700
aco_option_register(&cfg_info, "capture_address", ACO_EXACT, global_options, "", OPT_STRINGFIELD_T, 1, STRFLDSET(struct hepv3_global_config, capture_address));
682701
aco_option_register(&cfg_info, "capture_password", ACO_EXACT, global_options, "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct hepv3_global_config, capture_password));
683702
aco_option_register(&cfg_info, "capture_id", ACO_EXACT, global_options, "0", OPT_UINT_T, 0, STRFLDSET(struct hepv3_global_config, capture_id));
703+
aco_option_register(&cfg_info, "capture_name", ACO_EXACT, global_options, "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct hepv3_global_config, capture_name));
684704
aco_option_register_custom(&cfg_info, "uuid_type", ACO_EXACT, global_options, "call-id", uuid_type_handler, 0);
685705

686706
if (aco_process_config(&cfg_info, 0) == ACO_PROCESS_ERROR) {

0 commit comments

Comments
 (0)