[Asterisk-code-review] res_hep: Add support for named capture agents. (asterisk[18])
Friendly Automation
asteriskteam at digium.com
Thu Dec 8 21:31:03 CST 2022
Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/19682 )
Change subject: res_hep: Add support for named capture agents.
......................................................................
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
---
M configs/samples/hep.conf.sample
A doc/CHANGES-staging/res_hep.txt
M res/res_hep.c
3 files changed, 45 insertions(+), 1 deletion(-)
Approvals:
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
diff --git a/configs/samples/hep.conf.sample b/configs/samples/hep.conf.sample
index 4858644..db39bed 100644
--- a/configs/samples/hep.conf.sample
+++ b/configs/samples/hep.conf.sample
@@ -22,6 +22,9 @@
capture_id = 1234 ; A unique integer identifier for this
; server. This ID will be embedded sent
; with each packet from this server.
+;capture_name = asterisk ; A unique string identifier for this
+ ; server. This ID will be embedded sent
+ ; with each packet from this server.
uuid_type = call-id ; Specify the preferred source for the Homer
; correlation UUID. Valid options are:
; - 'call-id' for the PJSIP or chan_sip SIP
diff --git a/doc/CHANGES-staging/res_hep.txt b/doc/CHANGES-staging/res_hep.txt
new file mode 100644
index 0000000..fb386a1
--- /dev/null
+++ b/doc/CHANGES-staging/res_hep.txt
@@ -0,0 +1,5 @@
+Subject: Add support for named capture agent.
+
+A name for the capture agent can now be specified
+using the capture_name option which, if specified,
+will be sent to the HEP server.
diff --git a/res/res_hep.c b/res/res_hep.c
index 3241801..36f7e43 100644
--- a/res/res_hep.c
+++ b/res/res_hep.c
@@ -78,6 +78,9 @@
<configOption name="capture_id" default="0">
<synopsis>The ID for this capture agent.</synopsis>
</configOption>
+ <configOption name="capture_name" default="">
+ <synopsis>The name for this capture agent.</synopsis>
+ </configOption>
</configObject>
</configFile>
</configInfo>
@@ -155,6 +158,9 @@
/*! THE UUID FOR THIS PACKET */
CHUNK_TYPE_UUID = 0X0011,
+
+ /*! THE CAPTURE AGENT NAME */
+ CHUNK_TYPE_CAPTURE_AGENT_NAME = 0X0013,
};
#define INITIALIZE_GENERIC_HEP_IDS(hep_chunk, type) do { \
@@ -240,6 +246,7 @@
AST_DECLARE_STRING_FIELDS(
AST_STRING_FIELD(capture_address); /*!< Address to send to */
AST_STRING_FIELD(capture_password); /*!< Password for Homer server */
+ AST_STRING_FIELD(capture_name); /*!< Capture name for this agent */
);
};
@@ -458,7 +465,7 @@
unsigned int packet_len = 0, sock_buffer_len;
struct hep_chunk_ip4 ipv4_src, ipv4_dst;
struct hep_chunk_ip6 ipv6_src, ipv6_dst;
- struct hep_chunk auth_key, payload, uuid;
+ struct hep_chunk auth_key, payload, uuid, capturename;
void *sock_buffer;
int res;
@@ -512,6 +519,10 @@
INITIALIZE_GENERIC_HEP_IDS_VAR(&auth_key, CHUNK_TYPE_AUTH_KEY, strlen(config->general->capture_password));
packet_len += (sizeof(auth_key) + strlen(config->general->capture_password));
}
+ if (!ast_strlen_zero(config->general->capture_name)) {
+ INITIALIZE_GENERIC_HEP_IDS_VAR(&capturename, CHUNK_TYPE_CAPTURE_AGENT_NAME, strlen(config->general->capture_name));
+ packet_len += (sizeof(capturename) + strlen(config->general->capture_name));
+ }
INITIALIZE_GENERIC_HEP_IDS_VAR(&uuid, CHUNK_TYPE_UUID, strlen(capture_info->uuid));
packet_len += (sizeof(uuid) + strlen(capture_info->uuid));
INITIALIZE_GENERIC_HEP_IDS_VAR(&payload,
@@ -556,6 +567,14 @@
memcpy(sock_buffer + sock_buffer_len, capture_info->uuid, strlen(capture_info->uuid));
sock_buffer_len += strlen(capture_info->uuid);
+ /* Capture Agent Name */
+ if (!ast_strlen_zero(config->general->capture_name)) {
+ memcpy(sock_buffer + sock_buffer_len, &capturename, sizeof(capturename));
+ sock_buffer_len += sizeof(capturename);
+ memcpy(sock_buffer + sock_buffer_len, config->general->capture_name, strlen(config->general->capture_name));
+ sock_buffer_len += strlen(config->general->capture_name);
+ }
+
/* Packet! */
memcpy(sock_buffer + sock_buffer_len, &payload, sizeof(payload));
sock_buffer_len += sizeof(payload);
@@ -681,6 +700,7 @@
aco_option_register(&cfg_info, "capture_address", ACO_EXACT, global_options, "", OPT_STRINGFIELD_T, 1, STRFLDSET(struct hepv3_global_config, capture_address));
aco_option_register(&cfg_info, "capture_password", ACO_EXACT, global_options, "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct hepv3_global_config, capture_password));
aco_option_register(&cfg_info, "capture_id", ACO_EXACT, global_options, "0", OPT_UINT_T, 0, STRFLDSET(struct hepv3_global_config, capture_id));
+ aco_option_register(&cfg_info, "capture_name", ACO_EXACT, global_options, "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct hepv3_global_config, capture_name));
aco_option_register_custom(&cfg_info, "uuid_type", ACO_EXACT, global_options, "call-id", uuid_type_handler, 0);
if (aco_process_config(&cfg_info, 0) == ACO_PROCESS_ERROR) {
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19682
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 18
Gerrit-Change-Id: I6136583017f9dd08daeb8be02f60fb8df4639a2b
Gerrit-Change-Number: 19682
Gerrit-PatchSet: 2
Gerrit-Owner: N A <asterisk at phreaknet.org>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221209/3789c876/attachment.html>
More information about the asterisk-code-review
mailing list