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
68typedef struct _extcap_parameters
69{
70 char* exename;
71 char* fifo;
72 char* interface;
75 char* version;
78 char* helppage;
79 uint8_t capture;
80 uint8_t show_config;
85 char* ws_version;
87 /* private content */
88 GList* interfaces;
89 uint8_t do_version;
90 uint8_t do_list_dlts;
95 GList* help_options;
97 enum ws_log_level debug;
99 void (*cleanup_postkill_cb)(void);
101
108extern bool extcap_end_application;
109
119void extcap_base_register_interface(extcap_parameters * extcap, const char * interface, const char * ifdescription, uint16_t dlt, const char * dltdescription );
120
131void extcap_base_register_interface_ext(extcap_parameters * extcap, const char * interface, const char * ifdescription, uint16_t dlt, const char * dltname, const char * dltdescription );
132
144
156
170void extcap_base_set_util_info(extcap_parameters * extcap, const char * exename, const char * major, const char * minor, const char * release, const char * helppage);
171
180void extcap_base_set_compiled_with(extcap_parameters * extcap, const char *fmt, ...);
181
189void extcap_base_set_running_with(extcap_parameters * extcap, const char *fmt, ...);
190
199uint8_t extcap_base_parse_options(extcap_parameters * extcap, int result, char * optargument);
200
211
218
225void extcap_help_add_header(extcap_parameters * extcap, char * help_header);
226
234void extcap_help_add_option(extcap_parameters * extcap, const char * help_option_name, const char * help_option_desc);
235
242
249
258void extcap_cmdline_debug(char** ar, const unsigned n);
259
265void extcap_config_debug(unsigned* count);
266
273
280void extcap_log_init(void);
281
288void extcap_log_cmdarg_err(const char *msg_format, va_list ap);
289
290#ifdef __cplusplus
291}
292#endif // __cplusplus
293
294#endif // __EXTCAP_BASE_H__
295
296/*
297 * Editor modelines - https://www.wireshark.org/tools/modelines.html
298 *
299 * Local variables:
300 * c-basic-offset: 4
301 * tab-width: 8
302 * indent-tabs-mode: nil
303 * End:
304 *
305 * vi: set shiftwidth=4 tabstop=8 expandtab:
306 * :indentSize=4:tabSize=8:noTabs=true:
307 */
void extcap_help_add_header(extcap_parameters *extcap, char *help_header)
Adds a header to the help text.
Definition extcap-base.c:391
void extcap_help_print(extcap_parameters *extcap)
Print help information for extcap.
Definition extcap-base.c:371
uint8_t extcap_base_handle_interface(extcap_parameters *extcap)
Handle interface operations based on provided parameters.
Definition extcap-base.c:298
bool extcap_base_register_cleanup_postkill_cb(extcap_parameters *extcap, void(*callback)(void))
Registers a callback function to be called after the extcap application is killed.
void extcap_base_register_interface_ext(extcap_parameters *extcap, const char *interface, const char *ifdescription, uint16_t dlt, const char *dltname, const char *dltdescription)
Registers an interface with extended information for the extcap framework.
Definition extcap-base.c:79
void extcap_log_cmdarg_err(const char *msg_format, va_list ap)
Logs a command argument error message.
Definition extcap-base.c:452
bool extcap_base_register_graceful_shutdown_cb(extcap_parameters *extcap, void(*callback)(void))
Registers a callback function for graceful shutdown in the extcap framework.
void extcap_base_register_interface(extcap_parameters *extcap, const char *interface, const char *ifdescription, uint16_t dlt, const char *dltdescription)
Registers a basic interface with the extcap framework.
Definition extcap-base.c:74
uint8_t extcap_base_parse_options(extcap_parameters *extcap, int result, char *optargument)
Parses options for an extcap tool.
Definition extcap-base.c:186
void extcap_help_add_option(extcap_parameters *extcap, const char *help_option_name, const char *help_option_desc)
Adds a help option to the extcap parameters.
Definition extcap-base.c:382
struct _extcap_parameters extcap_parameters
Holds all runtime parameters and state for an extcap plugin, parsed from command-line arguments and u...
void extcap_config_debug(unsigned *count)
Initialize logging for extcap.
Definition extcap-base.c:420
void extcap_version_print(extcap_parameters *extcap)
Print the version information of an extcap tool.
Definition extcap-base.c:362
void extcap_log_init(void)
Initialize logging for extcap.
Definition extcap-base.c:178
bool extcap_end_application
Flag indicating whether a graceful shutdown of the extcap application has been requested.
Definition extcap-base.c:50
void extcap_base_cleanup(extcap_parameters **extcap)
Cleans up and frees memory allocated for extcap parameters.
Definition extcap-base.c:338
void extcap_cmdline_debug(char **ar, const unsigned n)
Log the command line arguments for debugging purposes.
Definition extcap-base.c:435
void extcap_base_help(void)
Display help information for extcap.
void extcap_base_set_compiled_with(extcap_parameters *extcap, const char *fmt,...)
Set the "compiled with" information string for an extcap utility.
Definition extcap-base.c:160
void extcap_base_set_util_info(extcap_parameters *extcap, const char *exename, const char *major, const char *minor, const char *release, const char *helppage)
Set the version and help page information for an extcap utility.
Definition extcap-base.c:142
void extcap_base_set_running_with(extcap_parameters *extcap, const char *fmt,...)
Set the running_with field of extcap_parameters with a formatted string.
Definition extcap-base.c:169
Holds all runtime parameters and state for an extcap plugin, parsed from command-line arguments and u...
Definition extcap-base.h:69
void(* cleanup_postkill_cb)(void)
Definition extcap-base.h:99
char * helppage
Definition extcap-base.h:78
char * fifo
Definition extcap-base.h:71
uint8_t show_config_option
Definition extcap-base.h:81
char * running_with
Definition extcap-base.h:77
char * interface
Definition extcap-base.h:72
GList * help_options
Definition extcap-base.h:95
uint8_t do_version
Definition extcap-base.h:89
char * version
Definition extcap-base.h:75
char * exename
Definition extcap-base.h:70
uint8_t do_cleanup_postkill
Definition extcap-base.h:92
char * compiled_with
Definition extcap-base.h:76
uint8_t show_config
Definition extcap-base.h:80
char * ws_version
Definition extcap-base.h:85
enum ws_log_level debug
Definition extcap-base.h:97
uint8_t do_list_dlts
Definition extcap-base.h:90
char * capture_filter
Definition extcap-base.h:73
uint8_t capture
Definition extcap-base.h:79
char * help_header
Definition extcap-base.h:94
GList * interfaces
Definition extcap-base.h:88
char * config_option_value
Definition extcap-base.h:83
uint8_t do_list_interfaces
Definition extcap-base.h:91
char * config_option_name
Definition extcap-base.h:82