Wireshark 4.5.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_CAPTURE, \
41 EXTCAP_OPT_CAPTURE_FILTER, \
42 EXTCAP_OPT_FIFO, \
43 EXTCAP_OPT_LOG_LEVEL, \
44 EXTCAP_OPT_LOG_FILE
45
46
47#define EXTCAP_BASE_OPTIONS \
48 { "extcap-interfaces", ws_no_argument, NULL, EXTCAP_OPT_LIST_INTERFACES}, \
49 { "extcap-version", ws_optional_argument, NULL, EXTCAP_OPT_VERSION}, \
50 { "extcap-dlts", ws_no_argument, NULL, EXTCAP_OPT_LIST_DLTS}, \
51 { "extcap-interface", ws_required_argument, NULL, EXTCAP_OPT_INTERFACE}, \
52 { "extcap-config", ws_no_argument, NULL, EXTCAP_OPT_CONFIG}, \
53 { "capture", ws_no_argument, NULL, EXTCAP_OPT_CAPTURE}, \
54 { "extcap-capture-filter", ws_required_argument, NULL, EXTCAP_OPT_CAPTURE_FILTER}, \
55 { "fifo", ws_required_argument, NULL, EXTCAP_OPT_FIFO}, \
56 { "log-level", ws_required_argument, NULL, EXTCAP_OPT_LOG_LEVEL}, \
57 { "log-file", ws_required_argument, NULL, EXTCAP_OPT_LOG_FILE}
58
59typedef struct _extcap_parameters
60{
61 char * exename;
62 char * fifo;
63 char * interface;
64 char * capture_filter;
65
66 char * version;
67 char * compiled_with;
68 char * running_with;
69 char * helppage;
70 uint8_t capture;
71 uint8_t show_config;
72
73 char * ws_version;
74
75 /* private content */
76 GList * interfaces;
77 uint8_t do_version;
78 uint8_t do_list_dlts;
79 uint8_t do_list_interfaces;
80
81 char * help_header;
82 GList * help_options;
83
84 enum ws_log_level debug;
86
87/* used to inform to extcap application that end of application is requested */
88extern bool extcap_end_application;
89
90void extcap_base_register_interface(extcap_parameters * extcap, const char * interface, const char * ifdescription, uint16_t dlt, const char * dltdescription );
91void extcap_base_register_interface_ext(extcap_parameters * extcap, const char * interface, const char * ifdescription, uint16_t dlt, const char * dltname, const char * dltdescription );
92
93/* used to inform extcap framework that graceful shutdown supported by the extcap
94 */
95bool extcap_base_register_graceful_shutdown_cb(extcap_parameters * extcap, void (*callback)(void));
96
97void extcap_base_set_util_info(extcap_parameters * extcap, const char * exename, const char * major, const char * minor, const char * release, const char * helppage);
98void extcap_base_set_compiled_with(extcap_parameters * extcap, const char *fmt, ...);
99void extcap_base_set_running_with(extcap_parameters * extcap, const char *fmt, ...);
100uint8_t extcap_base_parse_options(extcap_parameters * extcap, int result, char * optargument);
101uint8_t extcap_base_handle_interface(extcap_parameters * extcap);
102void extcap_base_cleanup(extcap_parameters ** extcap);
103void extcap_help_add_header(extcap_parameters * extcap, char * help_header);
104void extcap_help_add_option(extcap_parameters * extcap, const char * help_option_name, const char * help_optionn_desc);
105void extcap_version_print(extcap_parameters * extcap);
106void extcap_help_print(extcap_parameters * extcap);
107void extcap_cmdline_debug(char** ar, const unsigned n);
108void extcap_config_debug(unsigned* count);
109void extcap_base_help(void);
110void extcap_log_init(void);
111
112/*
113 * Report errors and warnings through ws_warning().
114 *
115 * Unfortunately, ws_warning() may be a macro, so we do it by calling
116 * ws_logv() with the appropriate arguments.
117 */
118void extcap_log_cmdarg_err(const char *msg_format, va_list ap);
119
120#ifdef __cplusplus
121}
122#endif // __cplusplus
123
124#endif // __EXTCAP_BASE_H__
125
126/*
127 * Editor modelines - https://www.wireshark.org/tools/modelines.html
128 *
129 * Local variables:
130 * c-basic-offset: 4
131 * tab-width: 8
132 * indent-tabs-mode: nil
133 * End:
134 *
135 * vi: set shiftwidth=4 tabstop=8 expandtab:
136 * :indentSize=4:tabSize=8:noTabs=true:
137 */
Definition extcap-base.h:60