Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
extcap-base.h
1 /* extcap_base.h
2  * Base function for extcaps
3  *
4  * Copyright 2016, Dario Lombardo
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * SPDX-License-Identifier: GPL-2.0-or-later
11  */
12 #ifndef __EXTCAP_BASE_H__
13 #define __EXTCAP_BASE_H__
14 
15 #include "config.h"
16 
17 #include <glib.h>
18 #include <glib/gprintf.h>
19 #include <stdlib.h>
20 #include <stdint.h>
21 
22 #ifdef HAVE_GETOPT_H
23  #include <getopt.h>
24 #endif
25 
26 #ifndef HAVE_GETOPT_LONG
27  #include "wsutil/wsgetopt.h"
28 #endif
29 
30 #ifdef _WIN32
31  #include <io.h>
32 #endif
33 
34 #include <wsutil/socket.h>
35 
36 #define EXTCAP_BASE_OPTIONS_ENUM \
37  EXTCAP_OPT_LIST_INTERFACES, \
38  EXTCAP_OPT_VERSION, \
39  EXTCAP_OPT_LIST_DLTS, \
40  EXTCAP_OPT_INTERFACE, \
41  EXTCAP_OPT_CONFIG, \
42  EXTCAP_OPT_CAPTURE, \
43  EXTCAP_OPT_CAPTURE_FILTER, \
44  EXTCAP_OPT_FIFO, \
45  EXTCAP_OPT_DEBUG, \
46  EXTCAP_OPT_DEBUG_FILE
47 
48 
49 #define EXTCAP_BASE_OPTIONS \
50  { "extcap-interfaces", no_argument, NULL, EXTCAP_OPT_LIST_INTERFACES}, \
51  { "extcap-version", optional_argument, NULL, EXTCAP_OPT_VERSION}, \
52  { "extcap-dlts", no_argument, NULL, EXTCAP_OPT_LIST_DLTS}, \
53  { "extcap-interface", required_argument, NULL, EXTCAP_OPT_INTERFACE}, \
54  { "extcap-config", no_argument, NULL, EXTCAP_OPT_CONFIG}, \
55  { "capture", no_argument, NULL, EXTCAP_OPT_CAPTURE}, \
56  { "extcap-capture-filter", required_argument, NULL, EXTCAP_OPT_CAPTURE_FILTER}, \
57  { "fifo", required_argument, NULL, EXTCAP_OPT_FIFO}, \
58  { "debug", required_argument, NULL, EXTCAP_OPT_DEBUG}, \
59  { "debug-file", required_argument, NULL, EXTCAP_OPT_DEBUG_FILE}
60 
61 #if defined(_WIN32)
62  BOOLEAN IsHandleRedirected(DWORD handle);
63  void attach_parent_console();
64 #endif
65 
66 typedef struct _extcap_parameters
67 {
68  char * exename;
69  char * fifo;
70  char * interface;
71  char * capture_filter;
72 
73  char * version;
74  char * helppage;
75  uint8_t capture;
76  uint8_t show_config;
77 
78  char * ws_version;
79 
80  /* private content */
81  GList * interfaces;
82  uint8_t do_version;
83  uint8_t do_list_dlts;
84  uint8_t do_list_interfaces;
85 
86  char * help_header;
87  GList * help_options;
88 
90 
91 void extcap_base_register_interface(extcap_parameters * extcap, const char * interface, const char * ifdescription, uint16_t dlt, const char * dltdescription );
92 void extcap_base_register_interface_ext(extcap_parameters * extcap, const char * interface, const char * ifdescription, uint16_t dlt, const char * dltname, const char * dltdescription );
93 void extcap_base_set_util_info(extcap_parameters * extcap, const char * exename, const char * major, const char * minor, const char * release, const char * helppage);
94 uint8_t extcap_base_parse_options(extcap_parameters * extcap, int result, char * optargument);
95 uint8_t extcap_base_handle_interface(extcap_parameters * extcap);
96 void extcap_base_cleanup(extcap_parameters ** extcap);
97 void extcap_help_add_header(extcap_parameters * extcap, char * help_header);
98 void extcap_help_add_option(extcap_parameters * extcap, const char * help_option_name, const char * help_optionn_desc);
99 void extcap_help_print(extcap_parameters * extcap);
100 void extcap_cmdline_debug(char** ar, const unsigned n);
101 void extcap_init_custom_log(const char* filename);
102 void extcap_config_debug(unsigned* count);
103 void extcap_base_help(void);
104 
105 #endif
106 
107 /*
108  * Editor modelines - https://www.wireshark.org/tools/modelines.html
109  *
110  * Local variables:
111  * c-basic-offset: 8
112  * tab-width: 8
113  * indent-tabs-mode: t
114  * End:
115  *
116  * vi: set shiftwidth=8 tabstop=8 noexpandtab:
117  * :indentSize=8:tabSize=8:noTabs=false:
118  */
Definition: extcap-base.h:66