### Bug Summary

File: | extcap/wifidump.c
Warning: | line 418, column 9 Opened stream never closed. Potential resource leak

### Annotated Source Code

Press '?' to see keyboard shortcuts

Show analyzer invocation
clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name wifidump.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -ffloat16-excess-precision=fast -fbfloat16-excess-precision=fast -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/builds/wireshark/wireshark/build -fcoverage-compilation-dir=/builds/wireshark/wireshark/build -resource-dir /usr/lib/llvm-21/lib/clang/21 -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -D G_DISABLE_DEPRECATED -D G_DISABLE_SINGLE_INCLUDES -D WS_DEBUG -D WS_DEBUG_UTF_8 -I /builds/wireshark/wireshark/build -I /builds/wireshark/wireshark -I /builds/wireshark/wireshark/include -D _GLIBCXX_ASSERTIONS -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/builds/wireshark/wireshark/= -fmacro-prefix-map=/builds/wireshark/wireshark/build/= -fmacro-prefix-map=../= -Wno-format-nonliteral -std=gnu11 -ferror-limit 19 -fvisibility=hidden -fwrapv -fwrapv-pointer -fstrict-flex-arrays=3 -stack-protector 2 -fstack-clash-protection -fcf-protection=full -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fexceptions -fcolor-diagnostics -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /builds/wireshark/wireshark/sbout/2025-12-03-100318-3593-1 -x c /builds/wireshark/wireshark/extcap/wifidump.c

Keyboard shortcuts:

- Use 'j/k' keys for keyboard navigation
- Use 'Shift+S' to show/hide relevant lines
- Use '?' to toggle this window

Close
Show only relevant lines Show control flow arrows

1 | /* wifidump.c
2 | * wifidump is an extcap tool used to capture Wi-Fi frames using a remote ssh host
3 | *
4 | * Adapted from sshdump.
5 | *
6 | * Copyright 2022, Adrian Granados <adrian@intuitibits.com>
7 | *
8 | * Wireshark - Network traffic analyzer
9 | * By Gerald Combs <gerald@wireshark.org>
10 | * Copyright 1998 Gerald Combs
11 | *
12 | * SPDX-License-Identifier: GPL-2.0-or-later
13 | */
14 |
15 | #include "config.h"
16 | #define WS_LOG_DOMAIN"wifidump" "wifidump"
17 |
18 | #include <extcap/extcap-base.h>
19 | #include <extcap/ssh-base.h>
20 | #include <wsutil/interface.h>
21 | #include <wsutil/file_util.h>
22 | #include <wsutil/strtoi.h>
23 | #include <wsutil/filesystem.h>
24 | #include <wsutil/privileges.h>
25 | #include <wsutil/please_report_bug.h>
26 | #include <wsutil/wslog.h>
27 | #include <wsutil/application_flavor.h>
28 |
29 | #include <errno(*__errno_location ()).h>
30 | #include <string.h>
31 | #include <fcntl.h>
32 |
33 | #include <cli_main.h>
34 |
35 | static char* wifidump_extcap_interface;
36 | #define DEFAULT_WIFIDUMP_EXTCAP_INTERFACE"wifidump" "wifidump"
37 |
38 | #define WIFIDUMP_VERSION_MAJOR"1" "1"
39 | #define WIFIDUMP_VERSION_MINOR"0" "0"
40 | #define WIFIDUMP_VERSION_RELEASE"0" "0"
41 |
42 | #define SSH_READ_BLOCK_SIZE256 256
43 |
44 | enum {
45 | EXTCAP_BASE_OPTIONS_ENUMEXTCAP_OPT_LIST_INTERFACES, EXTCAP_OPT_VERSION, EXTCAP_OPT_LIST_DLTS , EXTCAP_OPT_INTERFACE, EXTCAP_OPT_CONFIG, EXTCAP_OPT_CONFIG_OPTION_NAME , EXTCAP_OPT_CONFIG_OPTION_VALUE, EXTCAP_OPT_CLEANUP_POSTKILL , EXTCAP_OPT_CAPTURE, EXTCAP_OPT_CAPTURE_FILTER, EXTCAP_OPT_FIFO , EXTCAP_OPT_LOG_LEVEL, EXTCAP_OPT_LOG_FILE,
46 | OPT_HELP,
47 | OPT_VERSION,
48 | OPT_REMOTE_HOST,
49 | OPT_REMOTE_PORT,
50 | OPT_REMOTE_USERNAME,
51 | OPT_REMOTE_PASSWORD,
52 | OPT_REMOTE_INTERFACE,
53 | OPT_REMOTE_CHANNEL_FREQUENCY,
54 | OPT_REMOTE_CHANNEL_WIDTH,
55 | OPT_REMOTE_FILTER,
56 | OPT_SSHKEY,
57 | OPT_SSHKEY_PASSPHRASE,
58 | OPT_PROXYCOMMAND,
59 | OPT_SSH_SHA1,
60 | OPT_REMOTE_COUNT
61 | };
62 |
63 | static const struct ws_option longopts[] = {
64 | EXTCAP_BASE_OPTIONS{ "extcap-interfaces", 0, ((void*)0), EXTCAP_OPT_LIST_INTERFACES }, { "extcap-version", 2, ((void*)0), EXTCAP_OPT_VERSION}, { "extcap-dlts" , 0, ((void*)0), EXTCAP_OPT_LIST_DLTS}, { "extcap-interface", 1, ((void*)0), EXTCAP_OPT_INTERFACE}, { "extcap-config", 0, ( (void*)0), EXTCAP_OPT_CONFIG}, { "extcap-config-option-name", 1, ((void*)0), EXTCAP_OPT_CONFIG_OPTION_NAME}, { "extcap-config-option-value" , 1, ((void*)0), EXTCAP_OPT_CONFIG_OPTION_VALUE }, { "extcap-cleanup-postkill" , 0, ((void*)0), EXTCAP_OPT_CLEANUP_POSTKILL }, { "capture", 0 , ((void*)0), EXTCAP_OPT_CAPTURE}, { "extcap-capture-filter", 1, ((void*)0), EXTCAP_OPT_CAPTURE_FILTER}, { "fifo", 1, ((void *)0), EXTCAP_OPT_FIFO}, { "log-level", 1, ((void*)0), EXTCAP_OPT_LOG_LEVEL }, { "log-file", 1, ((void*)0), EXTCAP_OPT_LOG_FILE},
65 | { "help", ws_no_argument0, NULL((void*)0), OPT_HELP},
66 | { "version", ws_no_argument0, NULL((void*)0), OPT_VERSION},
67 | SSH_BASE_PACKET_OPTIONS{ "remote-host", 1, ((void*)0), OPT_REMOTE_HOST}, { "remote-port" , 1, ((void*)0), OPT_REMOTE_PORT}, { "remote-username", 1, (( void*)0), OPT_REMOTE_USERNAME}, { "remote-password", 1, ((void *)0), OPT_REMOTE_PASSWORD}, { "remote-count", 1, ((void*)0), OPT_REMOTE_COUNT }, { "sshkey", 1, ((void*)0), OPT_SSHKEY}, { "sshkey-passphrase" , 1, ((void*)0), OPT_SSHKEY_PASSPHRASE}, { "proxycommand", 1, ((void*)0), OPT_PROXYCOMMAND}, { "ssh-sha1", 0, ((void*)0), OPT_SSH_SHA1 }, { "remote-interface", 1, ((void*)0), OPT_REMOTE_INTERFACE} , { "remote-filter", 1, ((void*)0), OPT_REMOTE_FILTER},
68 | { "remote-channel-frequency", ws_required_argument1, NULL((void*)0), OPT_REMOTE_CHANNEL_FREQUENCY},
69 | { "remote-channel-width", ws_required_argument1, NULL((void*)0), OPT_REMOTE_CHANNEL_WIDTH},
70 | { 0, 0, 0, 0}
71 | };
72 |
73 | static const char * remote_capture_functions =
74 | "\n"
75 | "function iface_down {\n"
76 | " local iface=$1\n"
77 | " sudo ip link set $iface down > /dev/null 2>&1\n"
78 | "}\n"
79 | "\n"
80 | "function iface_up {\n"
81 | " local iface=$1\n"
82 | " sudo ip link set $iface up > /dev/null 2>&1\n"
83 | "}\n"
84 | "\n"
85 | "function iface_monitor {\n"
86 | " local iface=$1\n"
87 | " sudo iw dev $iface set monitor control otherbss > /dev/null 2>&1 ||\n"
88 | " sudo iw dev $iface set type monitor control otherbss > /dev/null 2>&1\n"
89 | "}\n"
90 | "\n"
91 | "function iface_scan {\n"
92 | " local iface=$1\n"
93 | " iface_down $iface &&\n"
94 | " sudo iw dev $iface set type managed > /dev/null 2>&1 &&\n"
95 | " iface_up $iface &&\n"
96 | " sudo iw dev $iface scan > /dev/null 2>&1\n"
97 | "}\n"
98 | "\n"
99 | "function iface_config {\n"
100 | " local iface=$1\n"
101 | " local freq=$2\n"
102 | " local ch_width=$3\n"
103 | " local center_freq=$4\n"
104 | " if [ $freq -eq $center_freq ]; then\n"
105 | " sudo iw dev $1 set freq $freq $ch_width 2>&1\n"
106 | " else\n"
107 | " sudo iw dev $1 set freq $freq $ch_width $center_freq 2>&1\n"
108 | " fi\n"
109 | "}\n"
110 | "\n"
111 | "function iface_start {\n"
112 | " local iface=$1\n"
113 | " local count=$2\n"
114 | " local filter=\"${@:3}\"\n"
115 | " if [ $count -gt 0 ]; then\n"
116 | " sudo tcpdump -i $iface -U -w - -c $count $filter\n"
117 | " else\n"
118 | " sudo tcpdump -i $iface -U -w - $filter\n"
119 | " fi\n"
120 | "}\n"
121 | "\n"
122 | "function capture_generic {\n"
123 | " local iface=$1\n"
124 | " local freq=$2\n"
125 | " local ch_width=$3\n"
126 | " local center_freq=$4\n"
127 | " local count=$5\n"
128 | " local filter=\"${@:6}\"\n"
129 | " if ! { iwconfig $iface | grep Monitor > /dev/null 2>&1; }; then\n"
130 | " iface_down $iface &&\n"
131 | " iface_monitor $iface &&\n"
132 | " iface_up $iface\n"
133 | " else\n"
134 | " iface_monitor $iface\n"
135 | " fi\n"
136 | " iface_config $iface $freq $ch_width $center_freq &&\n"
137 | " iface_start $iface $count $filter\n"
138 | "}\n"
139 | "\n"
140 | "function capture_iwlwifi {\n"
141 | " local iface=$1\n"
142 | " local freq=$2\n"
143 | " local ch_width=$3\n"
144 | " local center_freq=$4\n"
145 | " local count=$5\n"
146 | " local filter=\"${@:6}\"\n"
147 | " INDEX=`sudo iw dev $iface info | grep wiphy | grep -Eo '[0-9]+'`\n"
148 | " sudo iw phy phy${INDEX} channels | grep $freq | grep -i disabled > /dev/null 2>&1 &&\n"
149 | " iface_scan $iface\n"
150 | " MON=${iface}mon\n"
151 | " sudo iw $iface interface add $MON type monitor flags none > /dev/null 2>&1\n"
152 | " iface_up $MON &&\n"
153 | " iface_down $iface &&\n"
154 | " iface_config $MON $freq $ch_width $center_freq &&\n"
155 | " iface_start $MON $count $filter\n"
156 | "}\n"
157 | "\n"
158 | "function capture {\n"
159 | " local iface=$1\n"
160 | " local freq=$2\n"
161 | " local ch_width=$3\n"
162 | " local center_freq=$4\n"
163 | " local count=$5\n"
164 | " local filter=\"${@:6}\"\n"
165 | " if [ \"$iface\" == \"auto\" ]; then\n"
166 | " iface=`sudo iw dev | grep -i interface | awk '{ print $2 }' | sort | head -n 1`\n"
167 | " fi\n"
168 | " local driver=`/usr/sbin/ethtool -i $iface | grep driver | awk '{ print $2 }'`\n"
169 | " if [ $driver = \"iwlwifi\" ]; then\n"
170 | " capture_iwlwifi $iface $freq $ch_width $center_freq $count $filter\n"
171 | " else\n"
172 | " capture_generic $iface $freq $ch_width $center_freq $count $filter\n"
173 | " fi\n"
174 | "}\n"
175 | "\n";
176 |
177 | static unsigned int wifi_freqs_2dot4_5ghz[] = {
178 | 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462,
179 | 2467, 2472, 2484,
180 | 5180, 5200, 5220, 5240, 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580,
181 | 5600, 5620, 5640, 5660, 5680, 5700, 5720, 5745, 5765, 5785, 5805, 5825,
182 | 0
183 | };
184 |
185 | static unsigned int freq_to_channel(unsigned int freq_mhz) {
186 | if (freq_mhz == 2484)
187 | return 14;
188 | else if (freq_mhz >= 2412 && freq_mhz <= 2484)
189 | return ((freq_mhz - 2412) / 5) + 1;
190 | else if (freq_mhz >= 5160 && freq_mhz <= 5885)
191 | return ((freq_mhz - 5180) / 5) + 36;
192 | else if (freq_mhz >= 5955 && freq_mhz <= 7115)
193 | return ((freq_mhz - 5955) / 5) + 1;
194 | else
195 | return 0;
196 | }
197 |
198 | static const char *freq_to_band(unsigned int freq_mhz)
199 | {
200 | if (freq_mhz >= 2412 && freq_mhz <= 2484)
201 | return "2.4 GHz";
202 | else if (freq_mhz >= 5160 && freq_mhz <= 5885)
203 | return "5 GHz";
204 | else if (freq_mhz >= 5955 && freq_mhz <= 7115)
205 | return "6 GHz";
206 | else
207 | return NULL((void*)0);
208 | }
209 |
210 | static unsigned int center_freq(unsigned int freq_mhz, unsigned int ch_width_mhz) {
211 |
212 | unsigned int start_freq;
213 |
214 | if (ch_width_mhz == 20) {
215 | return freq_mhz;
216 | }
217 | else if (ch_width_mhz == 40) {
218 | if (freq_mhz >= 5180 && freq_mhz <= 5720) {
219 | for (start_freq = 5180; start_freq <= 5700; start_freq += ch_width_mhz) {
220 | if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 20))
221 | return ((start_freq * 2) + 20) / 2;
222 | }
223 | }
224 | else if (freq_mhz >= 5745 && freq_mhz <= 5765)
225 | return 5755;
226 | else if (freq_mhz >= 5785 && freq_mhz <= 5805)
227 | return 5795;
228 | else if (freq_mhz >= 5955 && freq_mhz <= 7095) {
229 | for (start_freq = 5955; start_freq <= 7075; start_freq += ch_width_mhz) {
230 | if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 20))
231 | return ((start_freq * 2) + 20) / 2;
232 | }
233 | }
234 | }
235 | else if (ch_width_mhz == 80) {
236 | if (freq_mhz >= 5180 && freq_mhz <= 5660) {
237 | for (start_freq = 5180; start_freq <= 5660; start_freq += ch_width_mhz) {
238 | if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 60))
239 | return ((start_freq * 2) + 60) / 2;
240 | }
241 | }
242 | else if (freq_mhz >= 5745 && freq_mhz <= 5805)
243 | return 5775;
244 | else if (freq_mhz >= 5955 && freq_mhz <= 7055) {
245 | for (start_freq = 5955; start_freq <= 6995; start_freq += ch_width_mhz) {
246 | if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 60))
247 | return ((start_freq * 2) + 60) / 2;
248 | }
249 | }
250 | }
251 | else if (ch_width_mhz == 160) {
252 | if (freq_mhz >= 5180 && freq_mhz <= 5640) {
253 | for (start_freq = 5180; start_freq <= 5500; start_freq += ch_width_mhz) {
254 | if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 140))
255 | return ((start_freq * 2) + 140) / 2;
256 | }
257 | }
258 | else if (freq_mhz >= 5955 && freq_mhz <= 7055) {
259 | for (start_freq = 5955; start_freq <= 6915; start_freq += ch_width_mhz) {
260 | if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 140))
261 | return ((start_freq * 2) + 140) / 2;
262 | }
263 | }
264 | }
265 |
266 | return -1;
267 | }
268 |
269 | static int ssh_loop_read(ssh_channel channel, FILE* fp)
270 | {
271 | int nbytes;
272 | int ret = EXIT_SUCCESS0;
273 | char buffer[SSH_READ_BLOCK_SIZE256];
274 |
275 | /* read from stdin until data are available */
276 | while (ssh_channel_is_open(channel) && !ssh_channel_is_eof(channel)) {
277 | nbytes = ssh_channel_read(channel, buffer, SSH_READ_BLOCK_SIZE256, 0);
278 | if (nbytes < 0) {
279 | ws_warning("Error reading from channel")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 279, __func__, "Error reading from channel"); } } while (0);
280 | goto end;
281 | }
282 | if (nbytes == 0) {
283 | break;
284 | }
285 | if (fwrite(buffer, 1, nbytes, fp) != (unsigned)nbytes) {
286 | ws_warning("Error writing to fifo")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 286, __func__, "Error writing to fifo"); } } while (0);
287 | ret = EXIT_FAILURE1;
288 | goto end;
289 | }
290 | fflush(fp);
291 | }
292 |
293 | /* read loop finished... maybe something wrong happened. Read from stderr */
294 | while (ssh_channel_is_open(channel) && !ssh_channel_is_eof(channel)) {
295 | nbytes = ssh_channel_read(channel, buffer, SSH_READ_BLOCK_SIZE256, 1);
296 | if (nbytes < 0) {
297 | ws_warning("Error reading from channel")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 297, __func__, "Error reading from channel"); } } while (0);
298 | goto end;
299 | }
300 | if (fwrite(buffer, 1, nbytes, stderrstderr) != (unsigned)nbytes) {
301 | ws_warning("Error writing to stderr")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 301, __func__, "Error writing to stderr"); } } while (0);
302 | break;
303 | }
304 | }
305 |
306 | end:
307 | if (ssh_channel_send_eof(channel) != SSH_OK0) {
308 | ws_warning("Error sending EOF in ssh channel")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 308, __func__, "Error sending EOF in ssh channel"); } } while (0);
309 | ret = EXIT_FAILURE1;
310 | }
311 | return ret;
312 | }
313 |
314 | static ssh_channel run_ssh_command(ssh_session sshs, const char* capture_functions,
315 | const char* iface, const uint16_t channel_frequency, const uint16_t channel_width,
316 | const uint16_t center_frequency, const char* cfilter, const uint32_t count)
317 | {
318 | char* cmdline;
319 | ssh_channel channel;
320 | char* quoted_iface = NULL((void*)0);
321 | char* quoted_filter = NULL((void*)0);
322 | char* count_str = NULL((void*)0);
323 | unsigned int remote_port = 22;
324 |
325 | channel = ssh_channel_new(sshs);
326 | if (!channel) {
327 | ws_warning("Can't create channel")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 327, __func__, "Can't create channel"); } } while (0);
328 | return NULL((void*)0);
329 | }
330 |
331 | if (ssh_channel_open_session(channel) != SSH_OK0) {
332 | ws_warning("Can't open session")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 332, __func__, "Can't open session"); } } while (0);
333 | ssh_channel_free(channel);
334 | return NULL((void*)0);
335 | }
336 |
337 | ssh_options_get_port(sshs, &remote_port);
338 |
339 | quoted_iface = iface ? g_shell_quote(iface) : NULL((void*)0);
340 | quoted_filter = g_shell_quote(cfilter ? cfilter : "");
341 | cmdline = ws_strdup_printf("%s capture %s %u %u %u %u %s",wmem_strdup_printf(((void*)0), "%s capture %s %u %u %u %u %s" , capture_functions, quoted_iface ? quoted_iface : "auto", channel_frequency , channel_width, center_frequency, count, quoted_filter)
342 | capture_functions,wmem_strdup_printf(((void*)0), "%s capture %s %u %u %u %u %s" , capture_functions, quoted_iface ? quoted_iface : "auto", channel_frequency , channel_width, center_frequency, count, quoted_filter)
343 | quoted_iface ? quoted_iface : "auto",wmem_strdup_printf(((void*)0), "%s capture %s %u %u %u %u %s" , capture_functions, quoted_iface ? quoted_iface : "auto", channel_frequency , channel_width, center_frequency, count, quoted_filter)
344 | channel_frequency,wmem_strdup_printf(((void*)0), "%s capture %s %u %u %u %u %s" , capture_functions, quoted_iface ? quoted_iface : "auto", channel_frequency , channel_width, center_frequency, count, quoted_filter)
345 | channel_width,wmem_strdup_printf(((void*)0), "%s capture %s %u %u %u %u %s" , capture_functions, quoted_iface ? quoted_iface : "auto", channel_frequency , channel_width, center_frequency, count, quoted_filter)
346 | center_frequency,wmem_strdup_printf(((void*)0), "%s capture %s %u %u %u %u %s" , capture_functions, quoted_iface ? quoted_iface : "auto", channel_frequency , channel_width, center_frequency, count, quoted_filter)
347 | count,wmem_strdup_printf(((void*)0), "%s capture %s %u %u %u %u %s" , capture_functions, quoted_iface ? quoted_iface : "auto", channel_frequency , channel_width, center_frequency, count, quoted_filter)
348 | quoted_filter)wmem_strdup_printf(((void*)0), "%s capture %s %u %u %u %u %s" , capture_functions, quoted_iface ? quoted_iface : "auto", channel_frequency , channel_width, center_frequency, count, quoted_filter);
349 |
350 | ws_debug("Running: %s", cmdline)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_DEBUG, "extcap/wifidump.c" , 350, __func__, "Running: %s", cmdline); } } while (0);
351 | if (ssh_channel_request_exec(channel, cmdline) != SSH_OK0) {
352 | ws_warning("Can't request exec")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 352, __func__, "Can't request exec"); } } while (0);
353 | ssh_channel_close(channel);
354 | ssh_channel_free(channel);
355 | channel = NULL((void*)0);
356 | }
357 |
358 | g_free(quoted_iface);
359 | g_free(quoted_filter);
360 | g_free(cmdline);
361 | g_free(count_str);
362 |
363 | return channel;
364 | }
365 |
366 | static int ssh_open_remote_connection(const ssh_params_t* params, const char* capture_functions,
367 | const char* iface, const uint16_t channel_frequency, const uint16_t channel_width,
368 | const uint16_t center_frequency, const char* cfilter, const uint32_t count, const char* fifo)
369 | {
370 | ssh_session sshs = NULL((void*)0);
371 | ssh_channel channel = NULL((void*)0);
372 | FILE* fp = stdoutstdout;
373 | int ret = EXIT_FAILURE1;
374 | char* err_info = NULL((void*)0);
375 |
376 | if (g_strcmp0(fifo, "-")) {
24 | ← | Assuming the condition is true | →
25 | ← | Taking true branch | →
377 | /* Open or create the output file */
378 | fp = fopen(fifo, "wb");
26 | ← | Stream opened here | →
27 | ← | Assuming that 'fopen' is successful | →
379 | if (fp
27.1 | 'fp' is not equal to NULL
== NULL((void*)0)) {
28 | ← | Taking false branch | →
380 | ws_warning("Error creating output file: %s (%s)", fifo, g_strerror(errno))do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 380, __func__, "Error creating output file: %s (%s)", fifo, g_strerror((*__errno_location ()))); } } while (0);
381 | return EXIT_FAILURE1;
382 | }
383 | }
384 |
385 | sshs = create_ssh_connection(params, &err_info);
386 |
387 | if (!sshs) {
29 | ← | Assuming 'sshs' is null | →
30 | ← | Taking true branch | →
388 | ws_warning("Error creating connection.")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 388, __func__, "Error creating connection."); } } while (0);
31 | ← | Taking true branch | →
32 | ← | Loop condition is false. Exiting loop | →
389 | goto cleanup;
33 | ← | Control jumps to line 409 | →
390 | }
391 |
392 | channel = run_ssh_command(sshs, capture_functions, iface, channel_frequency,
393 | channel_width, center_frequency, cfilter, count);
394 |
395 | if (!channel) {
396 | ws_warning("Can't run ssh command.")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 396, __func__, "Can't run ssh command."); } } while (0);
397 | goto cleanup;
398 | }
399 |
400 | /* read from channel and write into fp */
401 | if (ssh_loop_read(channel, fp) != EXIT_SUCCESS0) {
402 | ws_warning("Error in read loop.")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 402, __func__, "Error in read loop."); } } while (0);
403 | ret = EXIT_FAILURE1;
404 | goto cleanup;
405 | }
406 |
407 | ret = EXIT_SUCCESS0;
408 | cleanup:
409 | if (err_info)
34 | ← | Assuming 'err_info' is null | →
35 | ← | Taking false branch | →
410 | ws_warning("%s", err_info)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 410, __func__, "%s", err_info); } } while (0);
411 | g_free(err_info);
412 |
413 | /* clean up and exit */
414 | ssh_cleanup(&sshs, &channel);
415 |
416 | if (g_strcmp0(fifo, "-"))
36 | ← | Assuming the condition is false | →
37 | ← | Taking false branch | →
417 | fclose(fp);
418 | return ret;
38 | ← | Opened stream never closed. Potential resource leak
419 | }
420 |
421 | static int list_config(char *interface)
422 | {
423 | unsigned inc = 0;
424 | int i, psc;
425 |
426 | if (!interface) {
427 | ws_warning("ERROR: No interface specified.")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 427, __func__, "ERROR: No interface specified."); } } while (0);
428 | return EXIT_FAILURE1;
429 | }
430 |
431 | if (g_strcmp0(interface, wifidump_extcap_interface)) {
432 | ws_warning("ERROR: interface must be %s", wifidump_extcap_interface)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 432, __func__, "ERROR: interface must be %s", wifidump_extcap_interface ); } } while (0);
433 | return EXIT_FAILURE1;
434 | }
435 |
436 | // Server tab
437 | printf("arg {number=%u}{call=--remote-host}{display=Remote SSH server address}"
438 | "{type=string}{tooltip=The remote SSH host. It can be both "
439 | "an IP address or a hostname}{required=true}{group=Server}\n", inc++);
440 | printf("arg {number=%u}{call=--remote-port}{display=Remote SSH server port}"
441 | "{type=unsigned}{tooltip=The remote SSH host port (1-65535)}"
442 | "{range=1,65535}{group=Server}\n", inc++);
443 |
444 | // Authentication tab
445 | printf("arg {number=%u}{call=--remote-username}{display=Remote SSH server username}"
446 | "{type=string}{tooltip=The remote SSH username. If not provided, "
447 | "the current user will be used}{group=Authentication}\n", inc++);
448 | printf("arg {number=%u}{call=--remote-password}{display=Remote SSH server password}"
449 | "{type=password}{tooltip=The SSH password, used when other methods (SSH agent "
450 | "or key files) are unavailable.}{group=Authentication}\n", inc++);
451 | printf("arg {number=%u}{call=--sshkey}{display=Path to SSH private key}"
452 | "{type=fileselect}{tooltip=The path on the local filesystem of the private ssh key}"
453 | "{mustexist=true}{group=Authentication}\n", inc++);
454 | printf("arg {number=%u}{call=--sshkey-passphrase}{display=SSH key passphrase}"
455 | "{type=password}{tooltip=Passphrase to unlock the SSH private key}{group=Authentication}\n",
456 | inc++);
457 | printf("arg {number=%u}{call=--ssh-sha1}{display=Support SHA-1 keys (deprecated)}"
458 | "{type=boolflag}{tooltip=Support keys and key exchange algorithms using SHA-1 (deprecated)}{group=Authentication}"
459 | "\n", inc++);
460 |
461 |
462 | // Capture tab
463 | printf("arg {number=%u}{call=--remote-interface}{display=Remote interface}"
464 | "{type=string}{tooltip=The remote network interface used to capture"
465 | "}{default=auto}{group=Capture}\n", inc++);
466 | printf("arg {number=%u}{call=--remote-channel-frequency}{display=Remote channel}"
467 | "{type=selector}{tooltip=The remote channel used to capture}{group=Capture}\n", inc);
468 |
469 | unsigned int freq = 0;
470 | for (i = 0; (freq = wifi_freqs_2dot4_5ghz[i]); i++) {
471 | printf("value {arg=%u}{value=%u}{display=%s, Channel %u}\n", inc, freq, freq_to_band(freq), freq_to_channel(freq));
472 | }
473 |
474 | for (freq = 5955, psc = 3; freq <= 7115; freq += 20, psc++) {
475 | printf("value {arg=%u}{value=%u}{display=%s, Channel %u%s}\n", inc, freq,
476 | freq_to_band(freq), freq_to_channel(freq), (psc % 4 == 0) ? " (PSC)" : "");
477 | }
478 | inc++;
479 |
480 | printf("arg {number=%u}{call=--remote-channel-width}{display=Remote channel width}"
481 | "{type=selector}{tooltip=The remote channel width used to capture}"
482 | "{group=Capture}\n", inc);
483 | printf("value {arg=%u}{value=20}{display=20 MHz}\n", inc);
484 | printf("value {arg=%u}{value=40}{display=40 MHz}\n", inc);
485 | printf("value {arg=%u}{value=80}{display=80 MHz}\n", inc);
486 | printf("value {arg=%u}{value=160}{display=160 MHz}\n", inc);
487 | inc++;
488 |
489 | printf("arg {number=%u}{call=--remote-filter}{display=Remote capture filter}{type=string}"
490 | "{tooltip=The remote capture filter}{group=Capture}\n", inc++);
491 | printf("arg {number=%u}{call=--remote-count}{display=Frames to capture}"
492 | "{type=unsigned}{tooltip=The number of remote frames to capture.}"
493 | "{group=Capture}\n", inc++);
494 |
495 | extcap_config_debug(&inc);
496 |
497 | return EXIT_SUCCESS0;
498 | }
499 |
500 | static char* concat_filters(const char* extcap_filter, const char* remote_filter)
501 | {
502 | if (!extcap_filter && remote_filter)
503 | return g_strdup(remote_filter)g_strdup_inline (remote_filter);
504 |
505 | if (!remote_filter && extcap_filter)
506 | return g_strdup(extcap_filter)g_strdup_inline (extcap_filter);
507 |
508 | if (!remote_filter && !extcap_filter)
509 | return NULL((void*)0);
510 |
511 | return ws_strdup_printf("(%s) and (%s)", extcap_filter, remote_filter)wmem_strdup_printf(((void*)0), "(%s) and (%s)", extcap_filter , remote_filter);
512 | }
513 |
514 | int main(int argc, char *argv[])
515 | {
516 | char* err_msg;
517 | int result;
518 | int option_idx = 0;
519 | ssh_params_t* ssh_params = ssh_params_new();
520 | char* remote_interface = NULL((void*)0);
521 | uint16_t remote_channel_frequency = 0;
522 | uint16_t remote_channel_width = 0;
523 | uint16_t remote_center_frequency = 0;
524 | char* remote_filter = NULL((void*)0);
525 | uint32_t count = 0;
526 | int ret = EXIT_FAILURE1;
527 | extcap_parameters* extcap_conf = g_new0(extcap_parameters, 1)((extcap_parameters *) g_malloc0_n ((1), sizeof (extcap_parameters )));
528 | char* help_url;
529 | char* help_header = NULL((void*)0);
530 | char* interface_description = g_strdup("Wi-Fi remote capture")g_strdup_inline ("Wi-Fi remote capture");
531 |
532 | /* Set the program name. */
533 | g_set_prgname("wifidump");
534 |
535 | /* Initialize log handler early so we can have proper logging during startup. */
536 | extcap_log_init();
537 |
538 | wifidump_extcap_interface = g_path_get_basename(argv[0]);
539 | if (g_str_has_suffix(wifidump_extcap_interface, ".exe")(__builtin_constant_p (".exe")? __extension__ ({ const char * const __str = (wifidump_extcap_interface); const char * const __suffix = (".exe"); gboolean __result = (0); if (__str == ( (void*)0) || __suffix == ((void*)0)) __result = (g_str_has_suffix ) (__str, __suffix); else { const size_t __str_len = strlen ( ((__str) + !(__str))); const size_t __suffix_len = strlen ((( __suffix) + !(__suffix))); if (__str_len >= __suffix_len) __result = memcmp (__str + __str_len - __suffix_len, ((__suffix) + !( __suffix)), __suffix_len) == 0; } __result; }) : (g_str_has_suffix ) (wifidump_extcap_interface, ".exe") )) {
1 | '?' condition is true | →
2 | ← | Assuming '__str' is equal to null | →
3 | ← | Assuming the condition is false | →
4 | ← | Taking false branch | →
540 | wifidump_extcap_interface[strlen(wifidump_extcap_interface) - 4] = '\0';
541 | }
542 |
543 | /*
544 | * Get credential information for later use.
545 | */
546 | init_process_policies();
547 |
548 | /*
549 | * Attempt to get the pathname of the directory containing the
550 | * executable file.
551 | */
552 | err_msg = configuration_init(argv[0], "wireshark");
553 | if (err_msg != NULL((void*)0)) {
5 | ← | Assuming 'err_msg' is equal to NULL | →
6 | ← | Taking false branch | →
554 | ws_warning("Can't get pathname of directory containing the extcap program: %s.",do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 555, __func__, "Can't get pathname of directory containing the extcap program: %s." , err_msg); } } while (0)
555 | err_msg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 555, __func__, "Can't get pathname of directory containing the extcap program: %s." , err_msg); } } while (0);
556 | g_free(err_msg);
557 | }
558 |
559 | help_url = data_file_url("wifidump.html", application_configuration_environment_prefix());
560 | extcap_base_set_util_info(extcap_conf, argv[0], WIFIDUMP_VERSION_MAJOR"1", WIFIDUMP_VERSION_MINOR"0",
561 | WIFIDUMP_VERSION_RELEASE"0", help_url);
562 | g_free(help_url);
563 | add_libssh_info(extcap_conf);
564 | if (g_strcmp0(wifidump_extcap_interface, DEFAULT_WIFIDUMP_EXTCAP_INTERFACE"wifidump")) {
7 | ← | Assuming the condition is false | →
8 | ← | Taking false branch | →
565 | char* temp = interface_description;
566 | interface_description = ws_strdup_printf("%s, custom version", interface_description)wmem_strdup_printf(((void*)0), "%s, custom version", interface_description );
567 | g_free(temp);
568 | }
569 | extcap_base_register_interface(extcap_conf, wifidump_extcap_interface, interface_description, 147, "Remote capture dependent DLT");
570 | g_free(interface_description);
571 |
572 | help_header = ws_strdup_printf(wmem_strdup_printf(((void*)0), " %s --extcap-interfaces\n" " %s --extcap-interface=%s --extcap-dlts\n" " %s --extcap-interface=%s --extcap-config\n" " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 " "--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 " "--remote-channel-width 40 --fifo=FILENAME --capture\n", argv [0], argv[0], wifidump_extcap_interface, argv[0], wifidump_extcap_interface , argv[0], wifidump_extcap_interface)
573 | " %s --extcap-interfaces\n"wmem_strdup_printf(((void*)0), " %s --extcap-interfaces\n" " %s --extcap-interface=%s --extcap-dlts\n" " %s --extcap-interface=%s --extcap-config\n" " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 " "--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 " "--remote-channel-width 40 --fifo=FILENAME --capture\n", argv [0], argv[0], wifidump_extcap_interface, argv[0], wifidump_extcap_interface , argv[0], wifidump_extcap_interface)
574 | " %s --extcap-interface=%s --extcap-dlts\n"wmem_strdup_printf(((void*)0), " %s --extcap-interfaces\n" " %s --extcap-interface=%s --extcap-dlts\n" " %s --extcap-interface=%s --extcap-config\n" " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 " "--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 " "--remote-channel-width 40 --fifo=FILENAME --capture\n", argv [0], argv[0], wifidump_extcap_interface, argv[0], wifidump_extcap_interface , argv[0], wifidump_extcap_interface)
575 | " %s --extcap-interface=%s --extcap-config\n"wmem_strdup_printf(((void*)0), " %s --extcap-interfaces\n" " %s --extcap-interface=%s --extcap-dlts\n" " %s --extcap-interface=%s --extcap-config\n" " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 " "--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 " "--remote-channel-width 40 --fifo=FILENAME --capture\n", argv [0], argv[0], wifidump_extcap_interface, argv[0], wifidump_extcap_interface , argv[0], wifidump_extcap_interface)
576 | " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 "wmem_strdup_printf(((void*)0), " %s --extcap-interfaces\n" " %s --extcap-interface=%s --extcap-dlts\n" " %s --extcap-interface=%s --extcap-config\n" " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 " "--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 " "--remote-channel-width 40 --fifo=FILENAME --capture\n", argv [0], argv[0], wifidump_extcap_interface, argv[0], wifidump_extcap_interface , argv[0], wifidump_extcap_interface)
577 | "--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 "wmem_strdup_printf(((void*)0), " %s --extcap-interfaces\n" " %s --extcap-interface=%s --extcap-dlts\n" " %s --extcap-interface=%s --extcap-config\n" " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 " "--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 " "--remote-channel-width 40 --fifo=FILENAME --capture\n", argv [0], argv[0], wifidump_extcap_interface, argv[0], wifidump_extcap_interface , argv[0], wifidump_extcap_interface)
578 | "--remote-channel-width 40 --fifo=FILENAME --capture\n", argv[0], argv[0], wifidump_extcap_interface, argv[0],wmem_strdup_printf(((void*)0), " %s --extcap-interfaces\n" " %s --extcap-interface=%s --extcap-dlts\n" " %s --extcap-interface=%s --extcap-config\n" " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 " "--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 " "--remote-channel-width 40 --fifo=FILENAME --capture\n", argv [0], argv[0], wifidump_extcap_interface, argv[0], wifidump_extcap_interface , argv[0], wifidump_extcap_interface)
579 | wifidump_extcap_interface, argv[0], wifidump_extcap_interface)wmem_strdup_printf(((void*)0), " %s --extcap-interfaces\n" " %s --extcap-interface=%s --extcap-dlts\n" " %s --extcap-interface=%s --extcap-config\n" " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 " "--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 " "--remote-channel-width 40 --fifo=FILENAME --capture\n", argv [0], argv[0], wifidump_extcap_interface, argv[0], wifidump_extcap_interface , argv[0], wifidump_extcap_interface);
580 | extcap_help_add_header(extcap_conf, help_header);
581 | g_free(help_header);
582 | extcap_help_add_option(extcap_conf, "--help", "print this help");
583 | extcap_help_add_option(extcap_conf, "--version", "print the version");
584 | extcap_help_add_option(extcap_conf, "--remote-host <host>", "the remote SSH host");
585 | extcap_help_add_option(extcap_conf, "--remote-port <port>", "the remote SSH port");
586 | extcap_help_add_option(extcap_conf, "--remote-username <username>", "the remote SSH username");
587 | extcap_help_add_option(extcap_conf, "--remote-password <password>", "the remote SSH password. If not specified, ssh-agent and ssh-key are used");
588 | extcap_help_add_option(extcap_conf, "--sshkey <public key path>", "the path of the ssh key");
589 | extcap_help_add_option(extcap_conf, "--sshkey-passphrase <public key passphrase>", "the passphrase to unlock public ssh");
590 | extcap_help_add_option(extcap_conf, "--ssh-sha1", "support keys and key exchange using SHA-1 (deprecated)");
591 | extcap_help_add_option(extcap_conf, "--remote-interface <iface>", "the remote capture interface");
592 | extcap_help_add_option(extcap_conf, "--remote-channel-frequency <channel_frequency>", "the remote channel frequency in MHz");
593 | extcap_help_add_option(extcap_conf, "--remote-channel-width <channel_width>", "the remote channel width in MHz");
594 | extcap_help_add_option(extcap_conf, "--remote-filter <filter>", "a filter for remote capture");
595 | extcap_help_add_option(extcap_conf, "--remote-count <count>", "the number of frames to capture");
596 |
597 | ws_opterr = 0;
598 | ws_optind = 0;
599 |
600 | if (argc == 1) {
9 | ← | Assuming 'argc' is not equal to 1 | →
10 | ← | Taking false branch | →
601 | extcap_help_print(extcap_conf);
602 | goto end;
603 | }
604 |
605 | while ((result = ws_getopt_long(argc, argv, ":", longopts, &option_idx)) != -1) {
11 | ← | Assuming the condition is false | →
12 | ← | Loop condition is false. Execution continues on line 701 | →
606 |
607 | switch (result) {
608 |
609 | case OPT_HELP:
610 | extcap_help_print(extcap_conf);
611 | ret = EXIT_SUCCESS0;
612 | goto end;
613 |
614 | case OPT_VERSION:
615 | extcap_version_print(extcap_conf);
616 | ret = EXIT_SUCCESS0;
617 | goto end;
618 |
619 | case OPT_REMOTE_HOST:
620 | g_free(ssh_params->host);
621 | ssh_params->host = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
622 | break;
623 |
624 | case OPT_REMOTE_PORT:
625 | if (!ws_strtou16(ws_optarg, NULL((void*)0), &ssh_params->port) || ssh_params->port == 0) {
626 | ws_warning("Invalid port: %s", ws_optarg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 626, __func__, "Invalid port: %s", ws_optarg); } } while (0 );
627 | goto end;
628 | }
629 | break;
630 |
631 | case OPT_REMOTE_USERNAME:
632 | g_free(ssh_params->username);
633 | ssh_params->username = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
634 | break;
635 |
636 | case OPT_REMOTE_PASSWORD:
637 | g_free(ssh_params->password);
638 | ssh_params->password = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
639 | memset(ws_optarg, 'X', strlen(ws_optarg));
640 | break;
641 |
642 | case OPT_SSHKEY:
643 | g_free(ssh_params->sshkey_path);
644 | ssh_params->sshkey_path = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
645 | break;
646 |
647 | case OPT_SSHKEY_PASSPHRASE:
648 | g_free(ssh_params->sshkey_passphrase);
649 | ssh_params->sshkey_passphrase = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
650 | memset(ws_optarg, 'X', strlen(ws_optarg));
651 | break;
652 |
653 | case OPT_SSH_SHA1:
654 | ssh_params->ssh_sha1 = true1;
655 | break;
656 |
657 | case OPT_REMOTE_INTERFACE:
658 | g_free(remote_interface);
659 | remote_interface = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
660 | break;
661 |
662 | case OPT_REMOTE_CHANNEL_FREQUENCY:
663 | if (!ws_strtou16(ws_optarg, NULL((void*)0), &remote_channel_frequency)) {
664 | ws_warning("Invalid channel frequency: %s", ws_optarg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 664, __func__, "Invalid channel frequency: %s", ws_optarg); } } while (0);
665 | goto end;
666 | }
667 | break;
668 |
669 | case OPT_REMOTE_CHANNEL_WIDTH:
670 | if (!ws_strtou16(ws_optarg, NULL((void*)0), &remote_channel_width)) {
671 | ws_warning("Invalid channel width: %s", ws_optarg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 671, __func__, "Invalid channel width: %s", ws_optarg); } } while (0);
672 | goto end;
673 | }
674 | break;
675 |
676 | case OPT_REMOTE_FILTER:
677 | g_free(remote_filter);
678 | remote_filter = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
679 | break;
680 |
681 | case OPT_REMOTE_COUNT:
682 | if (!ws_strtou32(ws_optarg, NULL((void*)0), &count)) {
683 | ws_warning("Invalid value for count: %s", ws_optarg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 683, __func__, "Invalid value for count: %s", ws_optarg); } } while (0);
684 | goto end;
685 | }
686 | break;
687 |
688 | case ':':
689 | /* missing option argument */
690 | ws_warning("Option '%s' requires an argument", argv[ws_optind - 1])do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 690, __func__, "Option '%s' requires an argument", argv[ws_optind - 1]); } } while (0);
691 | break;
692 |
693 | default:
694 | if (!extcap_base_parse_options(extcap_conf, result - EXTCAP_OPT_LIST_INTERFACES, ws_optarg)) {
695 | ws_warning("Invalid option: %s", argv[ws_optind - 1])do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 695, __func__, "Invalid option: %s", argv[ws_optind - 1]); } } while (0);
696 | goto end;
697 | }
698 | }
699 | }
700 |
701 | extcap_cmdline_debug(argv, argc);
702 |
703 | if (extcap_base_handle_interface(extcap_conf)) {
13 | ← | Assuming the condition is false | →
14 | ← | Taking false branch | →
704 | ret = EXIT_SUCCESS0;
705 | goto end;
706 | }
707 |
708 | if (extcap_conf->show_config) {
15 | ← | Assuming field 'show_config' is 0 | →
16 | ← | Taking false branch | →
709 | ret = list_config(extcap_conf->interface);
710 | goto end;
711 | }
712 |
713 | err_msg = ws_init_sockets();
714 | if (err_msg != NULL((void*)0)) {
17 | ← | Assuming 'err_msg' is equal to NULL | →
18 | ← | Taking false branch | →
715 | ws_warning("ERROR: %s", err_msg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 715, __func__, "ERROR: %s", err_msg); } } while (0);
716 | g_free(err_msg);
717 | ws_warning("%s", please_report_bug())do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 717, __func__, "%s", please_report_bug()); } } while (0);
718 | goto end;
719 | }
720 |
721 | if (extcap_conf->capture) {
19 | ← | Assuming field 'capture' is not equal to 0 | →
20 | ← | Taking true branch | →
722 | char* filter;
723 |
724 | if (!ssh_params->host) {
21 | ← | Assuming field 'host' is non-null | →
22 | ← | Taking false branch | →
725 | ws_warning("Missing parameter: --remote-host")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 725, __func__, "Missing parameter: --remote-host"); } } while (0);
726 | goto end;
727 | }
728 | remote_center_frequency = center_freq(remote_channel_frequency, remote_channel_width);
729 | filter = concat_filters(extcap_conf->capture_filter, remote_filter);
730 | ssh_params_set_log_level(ssh_params, extcap_conf->debug);
731 | ret = ssh_open_remote_connection(ssh_params, remote_capture_functions,
23 | ← | Calling 'ssh_open_remote_connection' | →
732 | remote_interface, remote_channel_frequency, remote_channel_width, remote_center_frequency,
733 | filter, count, extcap_conf->fifo);
734 | g_free(filter);
735 | } else {
736 | ws_debug("You should not come here... maybe some parameter missing?")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_DEBUG, "extcap/wifidump.c" , 736, __func__, "You should not come here... maybe some parameter missing?" ); } } while (0);
737 | ret = EXIT_FAILURE1;
738 | }
739 |
740 | end:
741 | /* clean up stuff */
742 | ssh_params_free(ssh_params);
743 | g_free(remote_interface);
744 | g_free(remote_filter);
745 | extcap_base_cleanup(&extcap_conf);
746 | return ret;
747 | }
748 |
749 | /*
750 | * Editor modelines - https://www.wireshark.org/tools/modelines.html
751 | *
752 | * Local variables:
753 | * c-basic-offset: 8
754 | * tab-width: 8
755 | * indent-tabs-mode: t
756 | * End:
757 | *
758 | * vi: set shiftwidth=8 tabstop=8 noexpandtab:
759 | * :indentSize=8:tabSize=8:noTabs=false:
760 | */