<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19682">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span></span><br></pre><div style="white-space:pre-wrap">Approvals:
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_hep: Add support for named capture agents.<br><br>Adds support for the capture agent name field<br>of the Homer protocol to Asterisk by allowing<br>users to specify a name that will be sent to<br>the HEP server.<br><br>ASTERISK-30322 #close<br><br>Change-Id: I6136583017f9dd08daeb8be02f60fb8df4639a2b<br>---<br>M configs/samples/hep.conf.sample<br>A doc/CHANGES-staging/res_hep.txt<br>M res/res_hep.c<br>3 files changed, 45 insertions(+), 1 deletion(-)<br><br></pre>
<pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/configs/samples/hep.conf.sample b/configs/samples/hep.conf.sample</span><br><span>index 4858644..db39bed 100644</span><br><span>--- a/configs/samples/hep.conf.sample</span><br><span>+++ b/configs/samples/hep.conf.sample</span><br><span>@@ -22,6 +22,9 @@</span><br><span> capture_id = 1234                  ; A unique integer identifier for this</span><br><span>                                    ; server. This ID will be embedded sent</span><br><span>                                    ; with each packet from this server.</span><br><span style="color: hsl(120, 100%, 40%);">+;capture_name = asterisk           ; A unique string identifier for this</span><br><span style="color: hsl(120, 100%, 40%);">+                                   ; server. This ID will be embedded sent</span><br><span style="color: hsl(120, 100%, 40%);">+                                   ; with each packet from this server.</span><br><span> uuid_type = call-id                ; Specify the preferred source for the Homer</span><br><span>                                    ; correlation UUID. Valid options are:</span><br><span>                                    ; - 'call-id' for the PJSIP or chan_sip SIP</span><br><span>diff --git a/doc/CHANGES-staging/res_hep.txt b/doc/CHANGES-staging/res_hep.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..fb386a1</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/res_hep.txt</span><br><span>@@ -0,0 +1,5 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: Add support for named capture agent.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+A name for the capture agent can now be specified</span><br><span style="color: hsl(120, 100%, 40%);">+using the capture_name option which, if specified,</span><br><span style="color: hsl(120, 100%, 40%);">+will be sent to the HEP server.</span><br><span>diff --git a/res/res_hep.c b/res/res_hep.c</span><br><span>index 3241801..36f7e43 100644</span><br><span>--- a/res/res_hep.c</span><br><span>+++ b/res/res_hep.c</span><br><span>@@ -78,6 +78,9 @@</span><br><span>                                 <configOption name="capture_id" default="0"></span><br><span>                                       <synopsis>The ID for this capture agent.</synopsis></span><br><span>                              </configOption></span><br><span style="color: hsl(120, 100%, 40%);">+                         <configOption name="capture_name" default=""></span><br><span style="color: hsl(120, 100%, 40%);">+                                       <synopsis>The name for this capture agent.</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+                             </configOption></span><br><span>                        </configObject></span><br><span>                </configFile></span><br><span>  </configInfo></span><br><span>@@ -155,6 +158,9 @@</span><br><span> </span><br><span>        /*! THE UUID FOR THIS PACKET */</span><br><span>      CHUNK_TYPE_UUID = 0X0011,</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /*! THE CAPTURE AGENT NAME */</span><br><span style="color: hsl(120, 100%, 40%);">+ CHUNK_TYPE_CAPTURE_AGENT_NAME = 0X0013,</span><br><span> };</span><br><span> </span><br><span> #define INITIALIZE_GENERIC_HEP_IDS(hep_chunk, type) do { \</span><br><span>@@ -240,6 +246,7 @@</span><br><span>        AST_DECLARE_STRING_FIELDS(</span><br><span>           AST_STRING_FIELD(capture_address);   /*!< Address to send to */</span><br><span>           AST_STRING_FIELD(capture_password);  /*!< Password for Homer server */</span><br><span style="color: hsl(120, 100%, 40%);">+             AST_STRING_FIELD(capture_name);      /*!< Capture name for this agent */</span><br><span>  );</span><br><span> };</span><br><span> </span><br><span>@@ -458,7 +465,7 @@</span><br><span>   unsigned int packet_len = 0, sock_buffer_len;</span><br><span>        struct hep_chunk_ip4 ipv4_src, ipv4_dst;</span><br><span>     struct hep_chunk_ip6 ipv6_src, ipv6_dst;</span><br><span style="color: hsl(0, 100%, 40%);">-        struct hep_chunk auth_key, payload, uuid;</span><br><span style="color: hsl(120, 100%, 40%);">+     struct hep_chunk auth_key, payload, uuid, capturename;</span><br><span>       void *sock_buffer;</span><br><span>   int res;</span><br><span> </span><br><span>@@ -512,6 +519,10 @@</span><br><span>          INITIALIZE_GENERIC_HEP_IDS_VAR(&auth_key, CHUNK_TYPE_AUTH_KEY, strlen(config->general->capture_password));</span><br><span>                 packet_len += (sizeof(auth_key) + strlen(config->general->capture_password));</span><br><span>  }</span><br><span style="color: hsl(120, 100%, 40%);">+     if (!ast_strlen_zero(config->general->capture_name))  {</span><br><span style="color: hsl(120, 100%, 40%);">+         INITIALIZE_GENERIC_HEP_IDS_VAR(&capturename, CHUNK_TYPE_CAPTURE_AGENT_NAME, strlen(config->general->capture_name));</span><br><span style="color: hsl(120, 100%, 40%);">+         packet_len += (sizeof(capturename) + strlen(config->general->capture_name));</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span>    INITIALIZE_GENERIC_HEP_IDS_VAR(&uuid, CHUNK_TYPE_UUID, strlen(capture_info->uuid));</span><br><span>   packet_len += (sizeof(uuid) + strlen(capture_info->uuid));</span><br><span>        INITIALIZE_GENERIC_HEP_IDS_VAR(&payload,</span><br><span>@@ -556,6 +567,14 @@</span><br><span>  memcpy(sock_buffer + sock_buffer_len, capture_info->uuid, strlen(capture_info->uuid));</span><br><span>         sock_buffer_len += strlen(capture_info->uuid);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Capture Agent Name */</span><br><span style="color: hsl(120, 100%, 40%);">+      if (!ast_strlen_zero(config->general->capture_name)) {</span><br><span style="color: hsl(120, 100%, 40%);">+          memcpy(sock_buffer + sock_buffer_len, &capturename, sizeof(capturename));</span><br><span style="color: hsl(120, 100%, 40%);">+         sock_buffer_len += sizeof(capturename);</span><br><span style="color: hsl(120, 100%, 40%);">+               memcpy(sock_buffer + sock_buffer_len, config->general->capture_name, strlen(config->general->capture_name));</span><br><span style="color: hsl(120, 100%, 40%);">+              sock_buffer_len += strlen(config->general->capture_name);</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  /* Packet! */</span><br><span>        memcpy(sock_buffer + sock_buffer_len, &payload, sizeof(payload));</span><br><span>        sock_buffer_len += sizeof(payload);</span><br><span>@@ -681,6 +700,7 @@</span><br><span>    aco_option_register(&cfg_info, "capture_address", ACO_EXACT, global_options, "", OPT_STRINGFIELD_T, 1, STRFLDSET(struct hepv3_global_config, capture_address));</span><br><span>      aco_option_register(&cfg_info, "capture_password", ACO_EXACT, global_options, "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct hepv3_global_config, capture_password));</span><br><span>    aco_option_register(&cfg_info, "capture_id", ACO_EXACT, global_options, "0", OPT_UINT_T, 0, STRFLDSET(struct hepv3_global_config, capture_id));</span><br><span style="color: hsl(120, 100%, 40%);">+       aco_option_register(&cfg_info, "capture_name", ACO_EXACT, global_options, "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct hepv3_global_config, capture_name));</span><br><span>    aco_option_register_custom(&cfg_info, "uuid_type", ACO_EXACT, global_options, "call-id", uuid_type_handler, 0);</span><br><span> </span><br><span>  if (aco_process_config(&cfg_info, 0) == ACO_PROCESS_ERROR) {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19682">change 19682</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/19682"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: I6136583017f9dd08daeb8be02f60fb8df4639a2b </div>
<div style="display:none"> Gerrit-Change-Number: 19682 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: N A <asterisk@phreaknet.org> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>