]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_hep: Add support for named capture agents.
authorNaveen Albert <asterisk@phreaknet.org>
Mon, 21 Nov 2022 18:53:49 +0000 (18:53 +0000)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Fri, 9 Dec 2022 03:31:42 +0000 (21:31 -0600)
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

configs/samples/hep.conf.sample
doc/CHANGES-staging/res_hep.txt [new file with mode: 0644]
res/res_hep.c

index 48586445e44f55122846ac5ea4b22597ae729eb3..db39bed26e7da32fe8941565a8ba5b464efa7cb1 100644 (file)
@@ -22,6 +22,9 @@ capture_password = foo             ; If specified, the authorization password
 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 (file)
index 0000000..fb386a1
--- /dev/null
@@ -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.
index 3241801b059427a07b145f6fe973dd72ffdcd454..36f7e43ec8261e3a3d8efdcaf75887e8f2470fed 100644 (file)
@@ -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 @@ enum hepv3_chunk_types {
 
        /*! 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 @@ struct hepv3_global_config {
        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 @@ static int hep_queue_cb(void *data)
        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 @@ static int hep_queue_cb(void *data)
                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 @@ static int hep_queue_cb(void *data)
        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 @@ static int load_module(void)
        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) {