Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
extcap-base.h
Go to the documentation of this file.
1
13#ifndef __EXTCAP_BASE_H__
14#define __EXTCAP_BASE_H__
15
16#include <glib.h>
17#include <glib/gprintf.h>
18#include <stdlib.h>
19#include <stdint.h>
20#include <stdbool.h>
21
22#include <wsutil/ws_getopt.h>
23
24#ifdef _WIN32
25#include <io.h>
26#endif
27
28#include <wsutil/socket.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif // __cplusplus
33
34#define EXTCAP_BASE_OPTIONS_ENUM \
35 EXTCAP_OPT_LIST_INTERFACES, \
36 EXTCAP_OPT_VERSION, \
37 EXTCAP_OPT_LIST_DLTS, \
38 EXTCAP_OPT_INTERFACE, \
39 EXTCAP_OPT_CONFIG, \
40 EXTCAP_OPT_CONFIG_OPTION_NAME, \
41 EXTCAP_OPT_CONFIG_OPTION_VALUE, \
42 EXTCAP_OPT_CLEANUP_POSTKILL, \
43 EXTCAP_OPT_CAPTURE, \
44 EXTCAP_OPT_CAPTURE_FILTER, \
45 EXTCAP_OPT_FIFO, \
46 EXTCAP_OPT_LOG_LEVEL, \
47 EXTCAP_OPT_LOG_FILE
48
49
50#define EXTCAP_BASE_OPTIONS \
51 { "extcap-interfaces", ws_no_argument, NULL, EXTCAP_OPT_LIST_INTERFACES}, \
52 { "extcap-version", ws_optional_argument, NULL, EXTCAP_OPT_VERSION}, \
53 { "extcap-dlts", ws_no_argument, NULL, EXTCAP_OPT_LIST_DLTS}, \
54 { "extcap-interface", ws_required_argument, NULL, EXTCAP_OPT_INTERFACE}, \
55 { "extcap-config", ws_no_argument, NULL, EXTCAP_OPT_CONFIG}, \
56 { "extcap-config-option-name", ws_required_argument, NULL, EXTCAP_OPT_CONFIG_OPTION_NAME}, \
57 { "extcap-config-option-value", ws_required_argument, NULL, EXTCAP_OPT_CONFIG_OPTION_VALUE }, \
58 { "extcap-cleanup-postkill", ws_no_argument, NULL, EXTCAP_OPT_CLEANUP_POSTKILL }, \
59 { "capture", ws_no_argument, NULL, EXTCAP_OPT_CAPTURE}, \
60 { "extcap-capture-filter", ws_required_argument, NULL, EXTCAP_OPT_CAPTURE_FILTER}, \
61 { "fifo", ws_required_argument, NULL, EXTCAP_OPT_FIFO}, \
62 { "log-level", ws_required_argument, NULL, EXTCAP_OPT_LOG_LEVEL}, \
63 { "log-file", ws_required_argument, NULL, EXTCAP_OPT_LOG_FILE}
64
65typedef struct _extcap_parameters
66{
67 char * exename;
68 char * fifo;
69 char * interface;
70 char * capture_filter;
71
72 char * version;
73 char * compiled_with;
74 char * running_with;
75 char * helppage;
76 uint8_t capture;
77 uint8_t show_config;
78 uint8_t show_config_option;
79 char * config_option_name;
80 char * config_option_value;
81
82 char * ws_version;
83
84 /* private content */
85 GList * interfaces;
86 uint8_t do_version;
87 uint8_t do_list_dlts;
88 uint8_t do_list_interfaces;
89 uint8_t do_cleanup_postkill;
90
91 char * help_header;
92 GList * help_options;
93
94 enum ws_log_level debug;
95
96 void (*cleanup_postkill_cb)(void);
98
99/* used to inform to extcap application that end of application is requested */
100extern bool extcap_end_application;
101
102void extcap_base_register_interface(extcap_parameters * extcap, const char * interface, const char * ifdescription, uint16_t dlt, const char * dltdescription );
103void extcap_base_register_interface_ext(extcap_parameters * extcap, const char * interface, const char * ifdescription, uint16_t dlt, const char * dltname, const char * dltdescription );
104
105/* used to inform extcap framework that graceful shutdown supported by the extcap
106 */
107bool extcap_base_register_graceful_shutdown_cb(extcap_parameters * extcap, void (*callback)(void));
108
109/* used to cleanup extcap if previous program was terminated
110 */
111bool extcap_base_register_cleanup_postkill_cb(extcap_parameters* extcap, void (*callback)(void));
112
113void extcap_base_set_util_info(extcap_parameters * extcap, const char * exename, const char * major, const char * minor, const char * release, const char * helppage);
114void extcap_base_set_compiled_with(extcap_parameters * extcap, const char *fmt, ...);
115void extcap_base_set_running_with(extcap_parameters * extcap, const char *fmt, ...);
116uint8_t extcap_base_parse_options(extcap_parameters * extcap, int result, char * optargument);
117uint8_t extcap_base_handle_interface(extcap_parameters * extcap);
118void extcap_base_cleanup(extcap_parameters ** extcap);
119void extcap_help_add_header(extcap_parameters * extcap, char * help_header);
120void extcap_help_add_option(extcap_parameters * extcap, const char * help_option_name, const char * help_optionn_desc);
121void extcap_version_print(extcap_parameters * extcap);
122void extcap_help_print(extcap_parameters * extcap);
123void extcap_cmdline_debug(char** ar, const unsigned n);
124void extcap_config_debug(unsigned* count);
125void extcap_base_help(void);
126void extcap_log_init(void);
127
128/*
129 * Report errors and warnings through ws_warning().
130 *
131 * Unfortunately, ws_warning() may be a macro, so we do it by calling
132 * ws_logv() with the appropriate arguments.
133 */
134void extcap_log_cmdarg_err(const char *msg_format, va_list ap);
135
136#ifdef __cplusplus
137}
138#endif // __cplusplus
139
140#endif // __EXTCAP_BASE_H__
141
142/*
143 * Editor modelines - https://www.wireshark.org/tools/modelines.html
144 *
145 * Local variables:
146 * c-basic-offset: 4
147 * tab-width: 8
148 * indent-tabs-mode: nil
149 * End:
150 *
151 * vi: set shiftwidth=4 tabstop=8 expandtab:
152 * :indentSize=4:tabSize=8:noTabs=true:
153 */
Definition extcap-base.h:66