AST_MODULE_INFO: Format corrections to the usages of AST_MODULE_INFO macro.
[asterisk/asterisk.git] / res / res_hep.c
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2014, Digium, Inc.
5  *
6  * Alexandr Dubovikov <alexandr.dubovikov@sipcapture.org>
7  * Matt Jordan <mjordan@digium.com>
8  *
9  * See http://www.asterisk.org for more information about
10  * the Asterisk project. Please do not directly contact
11  * any of the maintainers of this project for assistance;
12  * the project provides a web site, mailing lists and IRC
13  * channels for your use.
14  *
15  * This program is free software, distributed under the terms of
16  * the GNU General Public License Version 2. See the LICENSE file
17  * at the top of the source tree.
18  */
19
20 /*!
21  * \file
22  * \brief Routines for integration with Homer using HEPv3
23  *
24  * \author Alexandr Dubovikov <alexandr.dubovikov@sipcapture.org>
25  * \author Matt Jordan <mjordan@digium.com>
26  *
27  */
28
29 /*!
30  * \li \ref res_hep.c uses the configuration file \ref hep.conf
31  * \addtogroup configuration_file Configuration Files
32  */
33
34 /*!
35  * \page hep.conf hep.conf
36  * \verbinclude hep.conf.sample
37  */
38
39 /*** MODULEINFO
40         <support_level>extended</support_level>
41  ***/
42
43 /*** DOCUMENTATION
44         <configInfo name="res_hep" language="en_US">
45                 <synopsis>Resource for integration with Homer using HEPv3</synopsis>
46                 <configFile name="hep.conf">
47                         <configObject name="general">
48                                 <synopsis>General settings.</synopsis>
49                                 <description><para>
50                                         The <emphasis>general</emphasis> settings section contains information
51                                         to configure Asterisk as a Homer capture agent.
52                                         </para>
53                                 </description>
54                                 <configOption name="enabled" default="yes">
55                                         <synopsis>Enable or disable packet capturing.</synopsis>
56                                         <description>
57                                                 <enumlist>
58                                                         <enum name="no" />
59                                                         <enum name="yes" />
60                                                 </enumlist>
61                                         </description>
62                                 </configOption>
63                                 <configOption name="capture_address" default="192.168.1.1:9061">
64                                         <synopsis>The address and port of the Homer server to send packets to.</synopsis>
65                                 </configOption>
66                                 <configOption name="capture_password">
67                                         <synopsis>If set, the authentication password to send to Homer.</synopsis>
68                                 </configOption>
69                                 <configOption name="capture_id" default="0">
70                                         <synopsis>The ID for this capture agent.</synopsis>
71                                 </configOption>
72                         </configObject>
73                 </configFile>
74         </configInfo>
75 ***/
76
77 #include "asterisk.h"
78
79 ASTERISK_REGISTER_FILE()
80
81 #include "asterisk/module.h"
82 #include "asterisk/astobj2.h"
83 #include "asterisk/config_options.h"
84 #include "asterisk/taskprocessor.h"
85 #include "asterisk/res_hep.h"
86
87 #include <netinet/ip.h>
88 #include <netinet/tcp.h>
89 #include <netinet/udp.h>
90 #include <netinet/ip6.h>
91
92 #define DEFAULT_HEP_SERVER ""
93
94 /*! Generic vendor ID. Used for HEPv3 standard packets */
95 #define GENERIC_VENDOR_ID 0x0000
96
97 /*! Asterisk vendor ID. Used for custom data to send to a capture node */
98 #define ASTERISK_VENDOR_ID 0x0004
99
100 /*! Chunk types from the HEPv3 Spec */
101 enum hepv3_chunk_types {
102
103         /*! THE IP PROTOCOL FAMILY */
104         CHUNK_TYPE_IP_PROTOCOL_FAMILY = 0X0001,
105
106         /*! THE IP PROTOCOL ID (UDP, TCP, ETC.) */
107         CHUNK_TYPE_IP_PROTOCOL_ID = 0X0002,
108
109         /*! IF IPV4, THE SOURCE ADDRESS */
110         CHUNK_TYPE_IPV4_SRC_ADDR = 0X0003,
111
112         /*! IF IPV4, THE DESTINATION ADDRESS */
113         CHUNK_TYPE_IPV4_DST_ADDR = 0X0004,
114
115         /*! IF IPV6, THE SOURCE ADDRESS */
116         CHUNK_TYPE_IPV6_SRC_ADDR = 0X0005,
117
118         /*! IF IPV6, THE DESTINATION ADDRESS */
119         CHUNK_TYPE_IPV6_DST_ADDR = 0X0006,
120
121         /*! THE SOURCE PORT */
122         CHUNK_TYPE_SRC_PORT = 0X0007,
123
124         /*! THE DESTINATION PORT */
125         CHUNK_TYPE_DST_PORT = 0X0008,
126
127         /*! THE CAPTURE TIME (SECONDS) */
128         CHUNK_TYPE_TIMESTAMP_SEC = 0X0009,
129
130         /*! THE CAPTURE TIME (MICROSECONDS) */
131         CHUNK_TYPE_TIMESTAMP_USEC = 0X000A,
132
133         /*! THE PROTOCOL PACKET TYPE. SEE /REF HEPV3_CAPTURE_TYPE */
134         CHUNK_TYPE_PROTOCOL_TYPE = 0X000B,
135
136         /*! OUR CAPTURE AGENT ID */
137         CHUNK_TYPE_CAPTURE_AGENT_ID = 0X000C,
138
139         /*! A KEEP ALIVE TIMER */
140         CHUNK_TYPE_KEEP_ALIVE_TIMER = 0X000D,
141
142         /*! THE \REF CAPTURE_PASSWORD IF DEFINED */
143         CHUNK_TYPE_AUTH_KEY = 0X000E,
144
145         /*! THE ONE AND ONLY PAYLOAD */
146         CHUNK_TYPE_PAYLOAD = 0X000F,
147
148         /*! THE ONE AND ONLY (ZIPPED) PAYLOAD */
149         CHUNK_TYPE_PAYLOAD_ZIP = 0X0010,
150
151         /*! THE UUID FOR THIS PACKET */
152         CHUNK_TYPE_UUID = 0X0011,
153 };
154
155 #define INITIALIZE_GENERIC_HEP_IDS(hep_chunk, type) do { \
156         (hep_chunk)->vendor_id = htons(GENERIC_VENDOR_ID); \
157         (hep_chunk)->type_id = htons((type)); \
158         } while (0)
159
160 #define INITIALIZE_GENERIC_HEP_IDS_VAR(hep_chunk, type, len) do { \
161         INITIALIZE_GENERIC_HEP_IDS((hep_chunk), (type)); \
162         (hep_chunk)->length = htons(sizeof(*(hep_chunk)) + len); \
163         } while (0)
164
165 #define INITIALIZE_GENERIC_HEP_CHUNK(hep_item, type) do { \
166         INITIALIZE_GENERIC_HEP_IDS(&(hep_item)->chunk, (type)); \
167         (hep_item)->chunk.length = htons(sizeof(*(hep_item))); \
168         } while (0)
169
170 #define INITIALIZE_GENERIC_HEP_CHUNK_DATA(hep_item, type, value) do { \
171         INITIALIZE_GENERIC_HEP_CHUNK((hep_item), (type)); \
172         (hep_item)->data = (value); \
173         } while (0)
174
175 /*
176  * HEPv3 Types.
177  * Note that the content in these is stored in network byte order.
178  */
179
180 struct hep_chunk {
181         u_int16_t vendor_id;
182         u_int16_t type_id;
183         u_int16_t length;
184 } __attribute__((packed));
185
186 struct hep_chunk_uint8 {
187         struct hep_chunk chunk;
188         u_int8_t data;
189 } __attribute__((packed));
190
191 struct hep_chunk_uint16 {
192         struct hep_chunk chunk;
193         u_int16_t data;
194 } __attribute__((packed));
195
196 struct hep_chunk_uint32 {
197         struct hep_chunk chunk;
198         u_int32_t data;
199 } __attribute__((packed));
200
201 struct hep_chunk_ip4 {
202         struct hep_chunk chunk;
203         struct in_addr data;
204 } __attribute__((packed));
205
206 struct hep_chunk_ip6 {
207         struct hep_chunk chunk;
208         struct in6_addr data;
209 } __attribute__((packed));
210
211 struct hep_ctrl {
212         char id[4];
213         u_int16_t length;
214 } __attribute__((packed));
215
216 /* HEP structures */
217
218 struct hep_generic {
219         struct hep_ctrl         header;
220         struct hep_chunk_uint8  ip_family;
221         struct hep_chunk_uint8  ip_proto;
222         struct hep_chunk_uint16 src_port;
223         struct hep_chunk_uint16 dst_port;
224         struct hep_chunk_uint32 time_sec;
225         struct hep_chunk_uint32 time_usec;
226         struct hep_chunk_uint8  proto_t;
227         struct hep_chunk_uint32 capt_id;
228 } __attribute__((packed));
229
230 /*! \brief Global configuration for the module */
231 struct hepv3_global_config {
232         unsigned int enabled;                    /*!< Whether or not sending is enabled */
233         unsigned int capture_id;                 /*!< Capture ID for this agent */
234         AST_DECLARE_STRING_FIELDS(
235                 AST_STRING_FIELD(capture_address);   /*!< Address to send to */
236                 AST_STRING_FIELD(capture_password);  /*!< Password for Homer server */
237         );
238 };
239
240 /*! \brief The actual module config */
241 struct module_config {
242         struct hepv3_global_config *general; /*!< The general config settings */
243 };
244
245 /*! \brief Run-time data derived from \ref hepv3_global_config */
246 struct hepv3_runtime_data {
247         struct ast_sockaddr remote_addr;  /*!< The address to send to */
248         int sockfd;                       /*!< The socket file descriptor */
249 };
250
251 static struct aco_type global_option = {
252         .type = ACO_GLOBAL,
253         .name = "general",
254         .item_offset = offsetof(struct module_config, general),
255         .category_match = ACO_WHITELIST,
256         .category = "^general$",
257 };
258
259 struct aco_type *global_options[] = ACO_TYPES(&global_option);
260
261 struct aco_file hepv3_conf = {
262         .filename = "hep.conf",
263         .types = ACO_TYPES(&global_option),
264 };
265
266 /*! \brief The module configuration container */
267 static AO2_GLOBAL_OBJ_STATIC(global_config);
268
269 /*! \brief Current module data */
270 static AO2_GLOBAL_OBJ_STATIC(global_data);
271
272 static struct ast_taskprocessor *hep_queue_tp;
273
274 static void *module_config_alloc(void);
275 static void hepv3_config_post_apply(void);
276
277 /*! \brief Register information about the configs being processed by this module */
278 CONFIG_INFO_STANDARD(cfg_info, global_config, module_config_alloc,
279         .files = ACO_FILES(&hepv3_conf),
280         .post_apply_config = hepv3_config_post_apply,
281 );
282
283 static void hepv3_config_dtor(void *obj)
284 {
285         struct hepv3_global_config *config = obj;
286
287         ast_string_field_free_memory(config);
288 }
289
290 /*! \brief HEPv3 configuration object allocation */
291 static void *hepv3_config_alloc(void)
292 {
293         struct hepv3_global_config *config;
294
295         config = ao2_alloc(sizeof(*config), hepv3_config_dtor);
296         if (!config || ast_string_field_init(config, 32)) {
297                 return NULL;
298         }
299
300         return config;
301 }
302
303 /*! \brief Configuration object destructor */
304 static void module_config_dtor(void *obj)
305 {
306         struct module_config *config = obj;
307
308         if (config->general) {
309                 ao2_ref(config->general, -1);
310         }
311 }
312
313 /*! \brief Module config constructor */
314 static void *module_config_alloc(void)
315 {
316         struct module_config *config;
317
318         config = ao2_alloc(sizeof(*config), module_config_dtor);
319         if (!config) {
320                 return NULL;
321         }
322
323         config->general = hepv3_config_alloc();
324         if (!config->general) {
325                 ao2_ref(config, -1);
326                 config = NULL;
327         }
328
329         return config;
330 }
331
332 /*! \brief HEPv3 run-time data destructor */
333 static void hepv3_data_dtor(void *obj)
334 {
335         struct hepv3_runtime_data *data = obj;
336
337         if (data->sockfd > -1) {
338                 close(data->sockfd);
339                 data->sockfd = -1;
340         }
341 }
342
343 /*! \brief Allocate the HEPv3 run-time data */
344 static struct hepv3_runtime_data *hepv3_data_alloc(struct hepv3_global_config *config)
345 {
346         struct hepv3_runtime_data *data;
347
348         data = ao2_alloc(sizeof(*data), hepv3_data_dtor);
349         if (!data) {
350                 return NULL;
351         }
352
353         if (!ast_sockaddr_parse(&data->remote_addr, config->capture_address, PARSE_PORT_REQUIRE)) {
354                 ast_log(AST_LOG_WARNING, "Failed to create address from %s\n", config->capture_address);
355                 ao2_ref(data, -1);
356                 return NULL;
357         }
358
359         data->sockfd = socket(ast_sockaddr_is_ipv6(&data->remote_addr) ? AF_INET6 : AF_INET, SOCK_DGRAM, 0);
360         if (data->sockfd < 0) {
361                 ast_log(AST_LOG_WARNING, "Failed to create socket for address %s: %s\n",
362                                 config->capture_address, strerror(errno));
363                 ao2_ref(data, -1);
364                 return NULL;
365         }
366
367         return data;
368 }
369
370 /*! \brief Destructor for a \ref hepv3_capture_info object */
371 static void capture_info_dtor(void *obj)
372 {
373         struct hepv3_capture_info *info = obj;
374
375         ast_free(info->uuid);
376         ast_free(info->payload);
377 }
378
379 struct hepv3_capture_info *hepv3_create_capture_info(const void *payload, size_t len)
380 {
381         struct hepv3_capture_info *info;
382
383         info = ao2_alloc(sizeof(*info), capture_info_dtor);
384         if (!info) {
385                 return NULL;
386         }
387
388         info->payload = ast_malloc(len);
389         if (!info->payload) {
390                 ao2_ref(info, -1);
391                 return NULL;
392         }
393         memcpy(info->payload, payload, len);
394         info->len = len;
395
396         return info;
397 }
398
399 /*! \brief Callback function for the \ref hep_queue_tp taskprocessor */
400 static int hep_queue_cb(void *data)
401 {
402         RAII_VAR(struct module_config *, config, ao2_global_obj_ref(global_config), ao2_cleanup);
403         RAII_VAR(struct hepv3_runtime_data *, hepv3_data, ao2_global_obj_ref(global_data), ao2_cleanup);
404         RAII_VAR(struct hepv3_capture_info *, capture_info, data, ao2_cleanup);
405         struct hep_generic hg_pkt;
406         unsigned int packet_len = 0, sock_buffer_len;
407         struct hep_chunk_ip4 ipv4_src, ipv4_dst;
408         struct hep_chunk_ip6 ipv6_src, ipv6_dst;
409         struct hep_chunk auth_key, payload, uuid;
410         void *sock_buffer;
411         int res;
412
413         if (!capture_info || !config || !hepv3_data) {
414                 return 0;
415         }
416
417         if (ast_sockaddr_is_ipv4(&capture_info->src_addr) != ast_sockaddr_is_ipv4(&capture_info->dst_addr)) {
418                 ast_log(AST_LOG_NOTICE, "Unable to send packet: Address Family mismatch between source/destination\n");
419                 return -1;
420         }
421
422         packet_len = sizeof(hg_pkt);
423
424         /* Build HEPv3 header, capture info, and calculate the total packet size */
425         memcpy(hg_pkt.header.id, "\x48\x45\x50\x33", 4);
426
427         INITIALIZE_GENERIC_HEP_CHUNK_DATA(&hg_pkt.ip_proto, CHUNK_TYPE_IP_PROTOCOL_ID, 0x11);
428         INITIALIZE_GENERIC_HEP_CHUNK_DATA(&hg_pkt.src_port, CHUNK_TYPE_SRC_PORT, htons(ast_sockaddr_port(&capture_info->src_addr)));
429         INITIALIZE_GENERIC_HEP_CHUNK_DATA(&hg_pkt.dst_port, CHUNK_TYPE_DST_PORT, htons(ast_sockaddr_port(&capture_info->dst_addr)));
430         INITIALIZE_GENERIC_HEP_CHUNK_DATA(&hg_pkt.time_sec, CHUNK_TYPE_TIMESTAMP_SEC, htonl(capture_info->capture_time.tv_sec));
431         INITIALIZE_GENERIC_HEP_CHUNK_DATA(&hg_pkt.time_usec, CHUNK_TYPE_TIMESTAMP_USEC, htonl(capture_info->capture_time.tv_usec));
432         INITIALIZE_GENERIC_HEP_CHUNK_DATA(&hg_pkt.proto_t, CHUNK_TYPE_PROTOCOL_TYPE, capture_info->capture_type);
433         INITIALIZE_GENERIC_HEP_CHUNK_DATA(&hg_pkt.capt_id, CHUNK_TYPE_CAPTURE_AGENT_ID, htonl(config->general->capture_id));
434
435         if (ast_sockaddr_is_ipv4(&capture_info->src_addr)) {
436                 INITIALIZE_GENERIC_HEP_CHUNK_DATA(&hg_pkt.ip_family,
437                         CHUNK_TYPE_IP_PROTOCOL_FAMILY, AF_INET);
438
439                 INITIALIZE_GENERIC_HEP_CHUNK(&ipv4_src, CHUNK_TYPE_IPV4_SRC_ADDR);
440                 inet_pton(AF_INET, ast_sockaddr_stringify_addr(&capture_info->src_addr), &ipv4_src.data);
441
442                 INITIALIZE_GENERIC_HEP_CHUNK(&ipv4_dst, CHUNK_TYPE_IPV4_DST_ADDR);
443                 inet_pton(AF_INET, ast_sockaddr_stringify_addr(&capture_info->dst_addr), &ipv4_dst.data);
444
445                 packet_len += (sizeof(ipv4_src) + sizeof(ipv4_dst));
446         } else {
447                 INITIALIZE_GENERIC_HEP_CHUNK_DATA(&hg_pkt.ip_family,
448                         CHUNK_TYPE_IP_PROTOCOL_FAMILY, AF_INET6);
449
450                 INITIALIZE_GENERIC_HEP_CHUNK(&ipv6_src, CHUNK_TYPE_IPV6_SRC_ADDR);
451                 inet_pton(AF_INET6, ast_sockaddr_stringify_addr(&capture_info->src_addr), &ipv6_src.data);
452
453                 INITIALIZE_GENERIC_HEP_CHUNK(&ipv6_dst, CHUNK_TYPE_IPV6_DST_ADDR);
454                 inet_pton(AF_INET6, ast_sockaddr_stringify_addr(&capture_info->dst_addr), &ipv6_dst.data);
455
456                 packet_len += (sizeof(ipv6_src) + sizeof(ipv6_dst));
457         }
458
459         if (!ast_strlen_zero(config->general->capture_password))  {
460                 INITIALIZE_GENERIC_HEP_IDS_VAR(&auth_key, CHUNK_TYPE_AUTH_KEY, strlen(config->general->capture_password));
461                 packet_len += (sizeof(auth_key) + strlen(config->general->capture_password));
462         }
463         INITIALIZE_GENERIC_HEP_IDS_VAR(&uuid, CHUNK_TYPE_UUID, strlen(capture_info->uuid));
464         packet_len += (sizeof(uuid) + strlen(capture_info->uuid));
465         INITIALIZE_GENERIC_HEP_IDS_VAR(&payload,
466                 capture_info->zipped ? CHUNK_TYPE_PAYLOAD_ZIP : CHUNK_TYPE_PAYLOAD, capture_info->len);
467         packet_len += (sizeof(payload) + capture_info->len);
468         hg_pkt.header.length = htons(packet_len);
469
470         /* Build the buffer to send */
471         sock_buffer = ast_malloc(packet_len);
472         if (!sock_buffer) {
473                 return -1;
474         }
475
476         /* Copy in the header */
477         memcpy(sock_buffer, &hg_pkt, sizeof(hg_pkt));
478         sock_buffer_len = sizeof(hg_pkt);
479
480         /* Addresses */
481         if (ast_sockaddr_is_ipv4(&capture_info->src_addr)) {
482                 memcpy(sock_buffer + sock_buffer_len, &ipv4_src, sizeof(ipv4_src));
483                 sock_buffer_len += sizeof(ipv4_src);
484                 memcpy(sock_buffer + sock_buffer_len, &ipv4_dst, sizeof(ipv4_dst));
485                 sock_buffer_len += sizeof(ipv4_dst);
486         } else {
487                 memcpy(sock_buffer + sock_buffer_len, &ipv6_src, sizeof(ipv6_src));
488                 sock_buffer_len += sizeof(ipv6_src);
489                 memcpy(sock_buffer + sock_buffer_len, &ipv6_dst, sizeof(ipv6_dst));
490                 sock_buffer_len += sizeof(ipv6_dst);
491         }
492
493         /* Auth Key */
494         if (!ast_strlen_zero(config->general->capture_password)) {
495                 memcpy(sock_buffer + sock_buffer_len, &auth_key, sizeof(auth_key));
496                 sock_buffer_len += sizeof(auth_key);
497                 memcpy(sock_buffer + sock_buffer_len, config->general->capture_password, strlen(config->general->capture_password));
498                 sock_buffer_len += strlen(config->general->capture_password);
499         }
500
501         /* UUID */
502         memcpy(sock_buffer + sock_buffer_len, &uuid, sizeof(uuid));
503         sock_buffer_len += sizeof(uuid);
504         memcpy(sock_buffer + sock_buffer_len, capture_info->uuid, strlen(capture_info->uuid));
505         sock_buffer_len += strlen(capture_info->uuid);
506
507         /* Packet! */
508         memcpy(sock_buffer + sock_buffer_len, &payload, sizeof(payload));
509         sock_buffer_len += sizeof(payload);
510         memcpy(sock_buffer + sock_buffer_len, capture_info->payload, capture_info->len);
511         sock_buffer_len += capture_info->len;
512
513         ast_assert(sock_buffer_len == packet_len);
514
515         res = ast_sendto(hepv3_data->sockfd, sock_buffer, sock_buffer_len, 0, &hepv3_data->remote_addr);
516         if (res < 0) {
517                 ast_log(AST_LOG_ERROR, "Error [%d] while sending packet to HEPv3 server: %s\n",
518                         errno, strerror(errno));
519         } else if (res != sock_buffer_len) {
520                 ast_log(AST_LOG_WARNING, "Failed to send complete packet to HEPv3 server: %d of %u sent\n",
521                         res, sock_buffer_len);
522                 res = -1;
523         }
524
525         ast_free(sock_buffer);
526         return res;
527 }
528
529 int hepv3_send_packet(struct hepv3_capture_info *capture_info)
530 {
531         RAII_VAR(struct module_config *, config, ao2_global_obj_ref(global_config), ao2_cleanup);
532         int res;
533
534         if (!config || !config->general->enabled) {
535                 ao2_ref(capture_info, -1);
536                 return 0;
537         }
538
539         res = ast_taskprocessor_push(hep_queue_tp, hep_queue_cb, capture_info);
540         if (res == -1) {
541                 ao2_ref(capture_info, -1);
542         }
543
544         return res;
545 }
546
547 /*!
548  * \brief Post-apply callback for the config framework.
549  *
550  * This will create the run-time information from the supplied
551  * configuration.
552 */
553 static void hepv3_config_post_apply(void)
554 {
555         RAII_VAR(struct module_config *, mod_cfg, ao2_global_obj_ref(global_config), ao2_cleanup);
556         struct hepv3_runtime_data *data;
557
558         data = hepv3_data_alloc(mod_cfg->general);
559         if (!data) {
560                 return;
561         }
562
563         ao2_global_obj_replace_unref(global_data, data);
564         ao2_ref(data, -1);
565 }
566
567 /*!
568  * \brief Reload the module
569  */
570 static int reload_module(void)
571 {
572         if (aco_process_config(&cfg_info, 1) == ACO_PROCESS_ERROR) {
573                 return -1;
574         }
575         return 0;
576 }
577
578 /*!
579  * \brief Unload the module
580  */
581 static int unload_module(void)
582 {
583         hep_queue_tp = ast_taskprocessor_unreference(hep_queue_tp);
584
585         ao2_global_obj_release(global_config);
586         ao2_global_obj_release(global_data);
587         aco_info_destroy(&cfg_info);
588
589         return 0;
590 }
591
592 /*!
593  * \brief Load the module
594  */
595 static int load_module(void)
596 {
597         if (aco_info_init(&cfg_info)) {
598                 goto error;
599         }
600
601         hep_queue_tp = ast_taskprocessor_get("hep_queue_tp", TPS_REF_DEFAULT);
602         if (!hep_queue_tp) {
603                 goto error;
604         }
605
606         aco_option_register(&cfg_info, "enabled", ACO_EXACT, global_options, "yes", OPT_BOOL_T, 1, FLDSET(struct hepv3_global_config, enabled));
607         aco_option_register(&cfg_info, "capture_address", ACO_EXACT, global_options, DEFAULT_HEP_SERVER, OPT_STRINGFIELD_T, 0, STRFLDSET(struct hepv3_global_config, capture_address));
608         aco_option_register(&cfg_info, "capture_password", ACO_EXACT, global_options, "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct hepv3_global_config, capture_password));
609         aco_option_register(&cfg_info, "capture_id", ACO_EXACT, global_options, "0", OPT_UINT_T, 0, STRFLDSET(struct hepv3_global_config, capture_id));
610
611         if (aco_process_config(&cfg_info, 0) == ACO_PROCESS_ERROR) {
612                 goto error;
613         }
614
615         return AST_MODULE_LOAD_SUCCESS;
616
617 error:
618         aco_info_destroy(&cfg_info);
619         return AST_MODULE_LOAD_DECLINE;
620 }
621
622 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "HEPv3 API",
623         .support_level = AST_MODULE_SUPPORT_EXTENDED,
624         .load = load_module,
625         .unload = unload_module,
626         .reload = reload_module,
627         .load_pri = AST_MODPRI_APP_DEPEND,
628 );