1 /*
2 ** Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved.
3 ** Copyright (C) 2012-2013 Sourcefire, Inc.
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License Version 2 as
7 ** published by the Free Software Foundation.  You may not use, modify or
8 ** distribute this program under any other version of the GNU General
9 ** Public License.
10 **
11 ** This program is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ** GNU General Public License for more details.
15 **
16 ** You should have received a copy of the GNU General Public License
17 ** along with this program; if not, write to the Free Software
18 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 **
20 ** Date: 01-27-2012
21 ** Author: Hui Cao <hcao@sourcefire.com>
22 */
23 
24 #ifndef _OUTPUT_API_H
25 #define _OUTPUT_API_H
26 
27 #include "output_common.h"
28 
29 typedef enum _DynamicOutputTypeFlag
30 {
31     DYNAMIC_OUTPUT_TYPE_FLAG__ALERT = 0x00000001,
32     DYNAMIC_OUTPUT_TYPE_FLAG__LOG   = 0x00000002,
33     DYNAMIC_OUTPUT_TYPE_FLAG__ALL   = 0x7fffffff
34 
35 } DynamicOutputTypeFlag;
36 
37 struct _output_dict_entry
38 {
39     char *key;
40     char *value;
41     struct _output_dict_entry *next;
42 };
43 
44 typedef struct _output_module
45 {
46     /* The version of the API this module implements.
47        This *must* be the first element in the structure. */
48     const uint32_t api_major_version;
49     const uint32_t api_minor_version;
50     /* The version of the OUTPUT module itself - can be completely arbitrary. */
51     const uint32_t module_version;
52     /* The name of the module (tcpdump, alert_full, unified, etc.) */
53     const char *name;
54     /* Various flags describing the module and its capabilities (alert, log etc.) */
55     const uint32_t type;
56     /* The name of the default log file */
57     const char *default_file;
58     /* load output module*/
59     void (*load) (struct _SnortConfig *, char *arg);
60     /* Parse the output device configuration --required*/
61     int (*parse_args) (void **config, char *arg, const char *default_output_file);
62     /* Post configuration*/
63     void (*postconfig)(struct _SnortConfig *, int unused, void *data);
64     /* Alert function */
65     void (*alert_output) (void *packet, char *msg, void *arg, void *event);
66     /* Log function */
67     void (*log_output) (void *packet, char *msg, void *arg, void *event);
68     /* Restart/rotate the device */
69     void (*rotate) (struct _SnortConfig *, int signal, void *arg);
70     /* Close the device and clean up --required */
71     void (*shutdown) (int signal, void *arg);
72     void  *next;
73 
74 } Output_Module_t;
75 
76 void init_output_module(struct _SnortConfig *, Output_Module_t *, char *);
77 
78 #define OUTPUT_API_MAJOR_VERSION    0x00020000
79 #define OUTPUT_API_MINOR_VERSION    0x00000001
80 
81 #endif /* _OUTPUT_API_H */
82