1 /*
2 ** Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
3 ** Copyright (C) 2010-2013 Sourcefire, Inc.
4 ** Author: Michael R. Altizer <mialtize@cisco.com>
5 **
6 ** This program is free software; you can redistribute it and/or modify
7 ** it under the terms of the GNU General Public License Version 2 as
8 ** published by the Free Software Foundation.  You may not use, modify or
9 ** distribute this program under any other version of the GNU General
10 ** Public License.
11 **
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; if not, write to the Free Software
19 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 */
21 
22 #ifndef _DAQ_H
23 #define _DAQ_H
24 
25 #include <stdio.h>
26 #include <daq_common.h>
27 
28 #define DAQ_VERSION 7
29 
30 /* Definition of the structures returned by daq_get_module_list(). */
31 typedef struct {
32     char *name;         /* Module name */
33     uint32_t version;   /* Module version */
34     uint32_t type;      /* Module capabilities */
35 } DAQ_Module_Info_t;
36 
37 /* Library version information functions. */
38 DAQ_LINKAGE uint32_t daq_version_number(void);
39 DAQ_LINKAGE const char *daq_version_string(void);
40 
41 /* Functions for loading, handling, and unloading DAQ modules. */
42 DAQ_LINKAGE void daq_set_verbosity(int level);
43 DAQ_LINKAGE int daq_load_modules(const char *module_dirs[]);
44 DAQ_LINKAGE const DAQ_Module_t *daq_find_module(const char *name);
45 DAQ_LINKAGE int daq_get_module_list(DAQ_Module_Info_t *list[]);
46 DAQ_LINKAGE void daq_free_module_list(DAQ_Module_Info_t *list, int size);
47 DAQ_LINKAGE void daq_unload_modules(void);
48 DAQ_LINKAGE void daq_print_stats(DAQ_Stats_t *stats, FILE *fp);
49 
50 /* Enumeration to String translation functions. */
51 DAQ_LINKAGE const char *daq_mode_string(DAQ_Mode mode);
52 DAQ_LINKAGE const char *daq_state_string(DAQ_State state);
53 DAQ_LINKAGE const char *daq_verdict_string(DAQ_Verdict verdict);
54 
55 /* DAQ Configuration Dictionary Functions */
56 DAQ_LINKAGE const char *daq_config_get_value(DAQ_Config_t *config, const char *key);
57 DAQ_LINKAGE void daq_config_set_value(DAQ_Config_t *config, const char *key, const char *value);
58 DAQ_LINKAGE void daq_config_clear_value(DAQ_Config_t *config, const char *key);
59 DAQ_LINKAGE void daq_config_clear_values(DAQ_Config_t *config);
60 
61 /* DAQ Module functions. */
62 DAQ_LINKAGE const char *daq_get_name(const DAQ_Module_t *module);
63 DAQ_LINKAGE uint32_t daq_get_type(const DAQ_Module_t *module);
64 
65 /* DAQ Module Instance functions */
66 DAQ_LINKAGE int daq_initialize(const DAQ_Module_t *module, const DAQ_Config_t *config, void **handle, char *errbuf, size_t len);
67 DAQ_LINKAGE int daq_set_filter(const DAQ_Module_t *module, void *handle, const char *filter);
68 DAQ_LINKAGE int daq_start(const DAQ_Module_t *module, void *handle);
69 DAQ_LINKAGE int daq_acquire(const DAQ_Module_t *module, void *handle, int cnt, DAQ_Analysis_Func_t callback, void *user);
70 DAQ_LINKAGE int daq_acquire_with_meta(const DAQ_Module_t *module, void *handle, int cnt,
71                                       DAQ_Analysis_Func_t callback, DAQ_Meta_Func_t metaback,
72                                       void *user);
73 DAQ_LINKAGE int daq_inject(const DAQ_Module_t *module, void *handle, const DAQ_PktHdr_t *hdr, const uint8_t *packet_data, uint32_t len, int reverse);
74 DAQ_LINKAGE int daq_breakloop(const DAQ_Module_t *module, void *handle);
75 DAQ_LINKAGE int daq_stop(const DAQ_Module_t *module, void *handle);
76 DAQ_LINKAGE int daq_shutdown(const DAQ_Module_t *module, void *handle);
77 DAQ_LINKAGE DAQ_State daq_check_status(const DAQ_Module_t *module, void *handle);
78 DAQ_LINKAGE int daq_get_stats(const DAQ_Module_t *module, void *handle, DAQ_Stats_t *stats);
79 DAQ_LINKAGE void daq_reset_stats(const DAQ_Module_t *module, void *handle);
80 DAQ_LINKAGE int daq_get_snaplen(const DAQ_Module_t *module, void *handle);
81 DAQ_LINKAGE uint32_t daq_get_capabilities(const DAQ_Module_t *module, void *handle);
82 DAQ_LINKAGE int daq_get_datalink_type(const DAQ_Module_t *module, void *handle);
83 DAQ_LINKAGE const char *daq_get_error(const DAQ_Module_t *module, void *handle);
84 DAQ_LINKAGE void daq_clear_error(const DAQ_Module_t *module, void *handle);
85 DAQ_LINKAGE int daq_modify_flow(const DAQ_Module_t *module, void *handle, const DAQ_PktHdr_t *hdr, const DAQ_ModFlow_t *modify);
86 DAQ_LINKAGE int daq_query_flow(const DAQ_Module_t *module, void *handle, const DAQ_PktHdr_t *hdr, DAQ_QueryFlow_t *query);
87 DAQ_LINKAGE int daq_hup_prep(const DAQ_Module_t *module, void *handle, void **new_config);
88 DAQ_LINKAGE int daq_hup_apply(const DAQ_Module_t *module, void *handle, void *new_config, void **old_config);
89 DAQ_LINKAGE int daq_hup_post(const DAQ_Module_t *module, void *handle, void *old_config);
90 DAQ_LINKAGE int daq_dp_add_dc(const DAQ_Module_t *module, void *handle, const DAQ_PktHdr_t *hdr, DAQ_DP_key_t *dp_key,
91         const uint8_t *packet_data, DAQ_Data_Channel_Params_t *params);
92 
93 #endif /* _DAQ_H */
94