2 * Routines for capture options setting
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
36 #include "capture_opts.h"
37 #include "ringbuffer.h"
39 #include <wsutil/clopts_common.h>
40 #include <wsutil/cmdarg_err.h>
41 #include <wsutil/file_util.h>
43 #include "caputils/capture_ifinfo.h"
44 #include "caputils/capture-pcap-util.h"
46 #include "ui/filter_files.h"
48 static gboolean capture_opts_output_to_pipe(const char *save_file, gboolean *is_pipe);
52 capture_opts_init(capture_options *capture_opts)
54 capture_opts->ifaces = g_array_new(FALSE, FALSE, sizeof(interface_options));
55 capture_opts->all_ifaces = g_array_new(FALSE, FALSE, sizeof(interface_t));
56 capture_opts->num_selected = 0;
57 capture_opts->default_options.name = NULL;
58 capture_opts->default_options.descr = NULL;
59 capture_opts->default_options.cfilter = NULL;
60 capture_opts->default_options.has_snaplen = FALSE;
61 capture_opts->default_options.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
62 capture_opts->default_options.linktype = -1; /* use interface default */
63 capture_opts->default_options.promisc_mode = TRUE;
64 capture_opts->default_options.if_type = IF_WIRED;
66 capture_opts->default_options.extcap = NULL;
67 capture_opts->default_options.extcap_fifo = NULL;
68 capture_opts->default_options.extcap_args = NULL;
69 capture_opts->default_options.extcap_userdata = NULL;
70 capture_opts->default_options.extcap_pid = INVALID_EXTCAP_PID;
71 capture_opts->default_options.extcap_control_in = NULL;
72 capture_opts->default_options.extcap_control_out = NULL;
74 #ifdef CAN_SET_CAPTURE_BUFFER_SIZE
75 capture_opts->default_options.buffer_size = DEFAULT_CAPTURE_BUFFER_SIZE;
77 capture_opts->default_options.monitor_mode = FALSE;
78 #ifdef HAVE_PCAP_REMOTE
79 capture_opts->default_options.src_type = CAPTURE_IFLOCAL;
80 capture_opts->default_options.remote_host = NULL;
81 capture_opts->default_options.remote_port = NULL;
82 capture_opts->default_options.auth_type = CAPTURE_AUTH_NULL;
83 capture_opts->default_options.auth_username = NULL;
84 capture_opts->default_options.auth_password = NULL;
85 capture_opts->default_options.datatx_udp = FALSE;
86 capture_opts->default_options.nocap_rpcap = TRUE;
87 capture_opts->default_options.nocap_local = FALSE;
89 #ifdef HAVE_PCAP_SETSAMPLING
90 capture_opts->default_options.sampling_method = CAPTURE_SAMP_NONE;
91 capture_opts->default_options.sampling_param = 0;
93 capture_opts->default_options.timestamp_type = NULL;
94 capture_opts->saving_to_file = FALSE;
95 capture_opts->save_file = NULL;
96 capture_opts->group_read_access = FALSE;
97 #ifdef PCAP_NG_DEFAULT
98 capture_opts->use_pcapng = TRUE; /* Save as pcap-ng by default */
100 capture_opts->use_pcapng = FALSE; /* Save as pcap by default */
102 capture_opts->real_time_mode = TRUE;
103 capture_opts->show_info = TRUE;
104 capture_opts->restart = FALSE;
105 capture_opts->orig_save_file = NULL;
107 capture_opts->multi_files_on = FALSE;
108 capture_opts->has_file_duration = FALSE;
109 capture_opts->file_duration = 60; /* 1 min */
110 capture_opts->has_file_interval = FALSE;
111 capture_opts->file_interval = 60; /* 1 min */
112 capture_opts->has_ring_num_files = FALSE;
113 capture_opts->ring_num_files = RINGBUFFER_MIN_NUM_FILES;
115 capture_opts->has_autostop_files = FALSE;
116 capture_opts->autostop_files = 1;
117 capture_opts->has_autostop_packets = FALSE;
118 capture_opts->autostop_packets = 0;
119 capture_opts->has_autostop_filesize = FALSE;
120 capture_opts->autostop_filesize = 1000; /* 1 MB */
121 capture_opts->has_autostop_duration = FALSE;
122 capture_opts->autostop_duration = 60; /* 1 min */
123 capture_opts->capture_comment = NULL;
125 capture_opts->output_to_pipe = FALSE;
126 capture_opts->capture_child = FALSE;
130 capture_opts_cleanup(capture_options *capture_opts)
135 if (capture_opts->ifaces) {
136 g_array_free(capture_opts->ifaces, TRUE);
137 capture_opts->ifaces = NULL;
139 if (capture_opts->all_ifaces) {
140 g_array_free(capture_opts->all_ifaces, TRUE);
141 capture_opts->all_ifaces = NULL;
145 /* log content of capture_opts */
147 capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_options *capture_opts) {
150 g_log(log_domain, log_level, "CAPTURE OPTIONS :");
152 for (i = 0; i < capture_opts->ifaces->len; i++) {
153 interface_options interface_opts;
155 interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
156 g_log(log_domain, log_level, "Interface name[%02d] : %s", i, interface_opts.name ? interface_opts.name : "(unspecified)");
157 g_log(log_domain, log_level, "Interface description[%02d] : %s", i, interface_opts.descr ? interface_opts.descr : "(unspecified)");
158 g_log(log_domain, log_level, "Console display name[%02d]: %s", i, interface_opts.console_display_name ? interface_opts.console_display_name : "(unspecified)");
159 g_log(log_domain, log_level, "Capture filter[%02d] : %s", i, interface_opts.cfilter ? interface_opts.cfilter : "(unspecified)");
160 g_log(log_domain, log_level, "Snap length[%02d] (%u) : %d", i, interface_opts.has_snaplen, interface_opts.snaplen);
161 g_log(log_domain, log_level, "Link Type[%02d] : %d", i, interface_opts.linktype);
162 g_log(log_domain, log_level, "Promiscuous Mode[%02d]: %s", i, interface_opts.promisc_mode?"TRUE":"FALSE");
164 g_log(log_domain, log_level, "Extcap[%02d] : %s", i, interface_opts.extcap ? interface_opts.extcap : "(unspecified)");
165 g_log(log_domain, log_level, "Extcap FIFO[%02d] : %s", i, interface_opts.extcap_fifo ? interface_opts.extcap_fifo : "(unspecified)");
166 g_log(log_domain, log_level, "Extcap PID[%02d] : %d", i, interface_opts.extcap_pid);
168 #ifdef CAN_SET_CAPTURE_BUFFER_SIZE
169 g_log(log_domain, log_level, "Buffer size[%02d] : %d (MB)", i, interface_opts.buffer_size);
171 g_log(log_domain, log_level, "Monitor Mode[%02d] : %s", i, interface_opts.monitor_mode?"TRUE":"FALSE");
172 #ifdef HAVE_PCAP_REMOTE
173 g_log(log_domain, log_level, "Capture source[%02d] : %s", i,
174 interface_opts.src_type == CAPTURE_IFLOCAL ? "Local interface" :
175 interface_opts.src_type == CAPTURE_IFREMOTE ? "Remote interface" :
177 if (interface_opts.src_type == CAPTURE_IFREMOTE) {
178 g_log(log_domain, log_level, "Remote host[%02d] : %s", i, interface_opts.remote_host ? interface_opts.remote_host : "(unspecified)");
179 g_log(log_domain, log_level, "Remote port[%02d] : %s", i, interface_opts.remote_port ? interface_opts.remote_port : "(unspecified)");
181 g_log(log_domain, log_level, "Authentication[%02d] : %s", i,
182 interface_opts.auth_type == CAPTURE_AUTH_NULL ? "Null" :
183 interface_opts.auth_type == CAPTURE_AUTH_PWD ? "By username/password" :
185 if (interface_opts.auth_type == CAPTURE_AUTH_PWD) {
186 g_log(log_domain, log_level, "Auth username[%02d] : %s", i, interface_opts.auth_username ? interface_opts.auth_username : "(unspecified)");
187 g_log(log_domain, log_level, "Auth password[%02d] : <hidden>", i);
189 g_log(log_domain, log_level, "UDP data tfer[%02d] : %u", i, interface_opts.datatx_udp);
190 g_log(log_domain, log_level, "No cap. RPCAP[%02d] : %u", i, interface_opts.nocap_rpcap);
191 g_log(log_domain, log_level, "No cap. local[%02d] : %u", i, interface_opts.nocap_local);
193 #ifdef HAVE_PCAP_SETSAMPLING
194 g_log(log_domain, log_level, "Sampling meth.[%02d] : %d", i, interface_opts.sampling_method);
195 g_log(log_domain, log_level, "Sampling param.[%02d] : %d", i, interface_opts.sampling_param);
197 g_log(log_domain, log_level, "Timestamp type [%02d] : %s", i, interface_opts.timestamp_type);
199 g_log(log_domain, log_level, "Interface name[df] : %s", capture_opts->default_options.name ? capture_opts->default_options.name : "(unspecified)");
200 g_log(log_domain, log_level, "Interface Descr[df] : %s", capture_opts->default_options.descr ? capture_opts->default_options.descr : "(unspecified)");
201 g_log(log_domain, log_level, "Capture filter[df] : %s", capture_opts->default_options.cfilter ? capture_opts->default_options.cfilter : "(unspecified)");
202 g_log(log_domain, log_level, "Snap length[df] (%u) : %d", capture_opts->default_options.has_snaplen, capture_opts->default_options.snaplen);
203 g_log(log_domain, log_level, "Link Type[df] : %d", capture_opts->default_options.linktype);
204 g_log(log_domain, log_level, "Promiscuous Mode[df]: %s", capture_opts->default_options.promisc_mode?"TRUE":"FALSE");
206 g_log(log_domain, log_level, "Extcap[df] : %s", capture_opts->default_options.extcap ? capture_opts->default_options.extcap : "(unspecified)");
207 g_log(log_domain, log_level, "Extcap FIFO[df] : %s", capture_opts->default_options.extcap_fifo ? capture_opts->default_options.extcap_fifo : "(unspecified)");
209 #ifdef CAN_SET_CAPTURE_BUFFER_SIZE
210 g_log(log_domain, log_level, "Buffer size[df] : %d (MB)", capture_opts->default_options.buffer_size);
212 g_log(log_domain, log_level, "Monitor Mode[df] : %s", capture_opts->default_options.monitor_mode?"TRUE":"FALSE");
213 #ifdef HAVE_PCAP_REMOTE
214 g_log(log_domain, log_level, "Capture source[df] : %s",
215 capture_opts->default_options.src_type == CAPTURE_IFLOCAL ? "Local interface" :
216 capture_opts->default_options.src_type == CAPTURE_IFREMOTE ? "Remote interface" :
218 if (capture_opts->default_options.src_type == CAPTURE_IFREMOTE) {
219 g_log(log_domain, log_level, "Remote host[df] : %s", capture_opts->default_options.remote_host ? capture_opts->default_options.remote_host : "(unspecified)");
220 g_log(log_domain, log_level, "Remote port[df] : %s", capture_opts->default_options.remote_port ? capture_opts->default_options.remote_port : "(unspecified)");
222 g_log(log_domain, log_level, "Authentication[df] : %s",
223 capture_opts->default_options.auth_type == CAPTURE_AUTH_NULL ? "Null" :
224 capture_opts->default_options.auth_type == CAPTURE_AUTH_PWD ? "By username/password" :
226 if (capture_opts->default_options.auth_type == CAPTURE_AUTH_PWD) {
227 g_log(log_domain, log_level, "Auth username[df] : %s", capture_opts->default_options.auth_username ? capture_opts->default_options.auth_username : "(unspecified)");
228 g_log(log_domain, log_level, "Auth password[df] : <hidden>");
230 g_log(log_domain, log_level, "UDP data tfer[df] : %u", capture_opts->default_options.datatx_udp);
231 g_log(log_domain, log_level, "No cap. RPCAP[df] : %u", capture_opts->default_options.nocap_rpcap);
232 g_log(log_domain, log_level, "No cap. local[df] : %u", capture_opts->default_options.nocap_local);
234 #ifdef HAVE_PCAP_SETSAMPLING
235 g_log(log_domain, log_level, "Sampling meth. [df] : %d", capture_opts->default_options.sampling_method);
236 g_log(log_domain, log_level, "Sampling param.[df] : %d", capture_opts->default_options.sampling_param);
238 g_log(log_domain, log_level, "Timestamp type [df] : %s", capture_opts->default_options.timestamp_type ? capture_opts->default_options.timestamp_type : "(unspecified)");
239 g_log(log_domain, log_level, "SavingToFile : %u", capture_opts->saving_to_file);
240 g_log(log_domain, log_level, "SaveFile : %s", (capture_opts->save_file) ? capture_opts->save_file : "");
241 g_log(log_domain, log_level, "GroupReadAccess : %u", capture_opts->group_read_access);
242 g_log(log_domain, log_level, "Fileformat : %s", (capture_opts->use_pcapng) ? "PCAPNG" : "PCAP");
243 g_log(log_domain, log_level, "RealTimeMode : %u", capture_opts->real_time_mode);
244 g_log(log_domain, log_level, "ShowInfo : %u", capture_opts->show_info);
246 g_log(log_domain, log_level, "MultiFilesOn : %u", capture_opts->multi_files_on);
247 g_log(log_domain, log_level, "FileDuration (%u) : %u", capture_opts->has_file_duration, capture_opts->file_duration);
248 g_log(log_domain, log_level, "FileInterval (%u) : %u", capture_opts->has_file_interval, capture_opts->file_interval);
249 g_log(log_domain, log_level, "RingNumFiles (%u) : %u", capture_opts->has_ring_num_files, capture_opts->ring_num_files);
251 g_log(log_domain, log_level, "AutostopFiles (%u) : %u", capture_opts->has_autostop_files, capture_opts->autostop_files);
252 g_log(log_domain, log_level, "AutostopPackets (%u) : %u", capture_opts->has_autostop_packets, capture_opts->autostop_packets);
253 g_log(log_domain, log_level, "AutostopFilesize(%u) : %u (KB)", capture_opts->has_autostop_filesize, capture_opts->autostop_filesize);
254 g_log(log_domain, log_level, "AutostopDuration(%u) : %u", capture_opts->has_autostop_duration, capture_opts->autostop_duration);
258 * Given a string of the form "<autostop criterion>:<value>", as might appear
259 * as an argument to a "-a" option, parse it and set the criterion in
260 * question. Return an indication of whether it succeeded or failed
264 set_autostop_criterion(capture_options *capture_opts, const char *autostoparg)
268 colonp = strchr(autostoparg, ':');
276 * Skip over any white space (there probably won't be any, but
277 * as we allow it in the preferences file, we might as well
280 while (g_ascii_isspace(*p))
284 * Put the colon back, so if our caller uses, in an
285 * error message, the string they passed us, the message
291 if (strcmp(autostoparg,"duration") == 0) {
292 capture_opts->has_autostop_duration = TRUE;
293 capture_opts->autostop_duration = get_positive_int(p,"autostop duration");
294 } else if (strcmp(autostoparg,"filesize") == 0) {
295 capture_opts->has_autostop_filesize = TRUE;
296 capture_opts->autostop_filesize = get_nonzero_guint32(p,"autostop filesize");
297 } else if (strcmp(autostoparg,"files") == 0) {
298 capture_opts->multi_files_on = TRUE;
299 capture_opts->has_autostop_files = TRUE;
300 capture_opts->autostop_files = get_positive_int(p,"autostop files");
304 *colonp = ':'; /* put the colon back */
308 static gboolean get_filter_arguments(capture_options* capture_opts, const char* arg)
312 char* filter_exp = NULL;
314 colonp = strchr(arg, ':');
319 if (strcmp(arg, "predef") == 0) {
322 filterItem = get_filter_list_first(CFILTER_LIST);
323 while (filterItem != NULL) {
324 filter_def *filterDef;
326 filterDef = (filter_def*)filterItem->data;
327 if (strcmp(val, filterDef->name) == 0) {
328 filter_exp = g_strdup(filterDef->strval);
331 filterItem = filterItem->next;
336 if (filter_exp == NULL) {
337 /* No filter expression found yet; fallback to previous implemention
338 and assume the arg contains a filter expression */
340 *colonp = ':'; /* restore colon */
342 filter_exp = g_strdup(arg);
345 if (capture_opts->ifaces->len > 0) {
346 interface_options interface_opts;
348 interface_opts = g_array_index(capture_opts->ifaces, interface_options, capture_opts->ifaces->len - 1);
349 capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, capture_opts->ifaces->len - 1);
350 g_free(interface_opts.cfilter);
351 interface_opts.cfilter = filter_exp;
352 g_array_append_val(capture_opts->ifaces, interface_opts);
356 g_free(capture_opts->default_options.cfilter);
357 capture_opts->default_options.cfilter = filter_exp;
363 * Given a string of the form "<ring buffer file>:<duration>", as might appear
364 * as an argument to a "-b" option, parse it and set the arguments in
365 * question. Return an indication of whether it succeeded or failed
369 get_ring_arguments(capture_options *capture_opts, const char *arg)
371 gchar *p = NULL, *colonp;
373 colonp = strchr(arg, ':');
381 * Skip over any white space (there probably won't be any, but
382 * as we allow it in the preferences file, we might as well
385 while (g_ascii_isspace(*p))
389 * Put the colon back, so if our caller uses, in an
390 * error message, the string they passed us, the message
397 if (strcmp(arg,"files") == 0) {
398 capture_opts->has_ring_num_files = TRUE;
399 capture_opts->ring_num_files = get_nonzero_guint32(p, "number of ring buffer files");
400 } else if (strcmp(arg,"filesize") == 0) {
401 capture_opts->has_autostop_filesize = TRUE;
402 capture_opts->autostop_filesize = get_nonzero_guint32(p, "ring buffer filesize");
403 } else if (strcmp(arg,"duration") == 0) {
404 capture_opts->has_file_duration = TRUE;
405 capture_opts->file_duration = get_positive_int(p, "ring buffer duration");
406 } else if (strcmp(arg,"interval") == 0) {
407 capture_opts->has_file_interval = TRUE;
408 capture_opts->file_interval = get_positive_int(p, "ring buffer interval");
411 *colonp = ':'; /* put the colon back */
415 #ifdef HAVE_PCAP_SETSAMPLING
417 * Given a string of the form "<sampling type>:<value>", as might appear
418 * as an argument to a "-m" option, parse it and set the arguments in
419 * question. Return an indication of whether it succeeded or failed
423 get_sampling_arguments(capture_options *capture_opts, const char *arg)
425 gchar *p = NULL, *colonp;
427 colonp = strchr(arg, ':');
434 while (g_ascii_isspace(*p))
441 if (strcmp(arg, "count") == 0) {
442 if (capture_opts->ifaces->len > 0) {
443 interface_options interface_opts;
445 interface_opts = g_array_index(capture_opts->ifaces, interface_options, capture_opts->ifaces->len - 1);
446 capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, capture_opts->ifaces->len - 1);
447 interface_opts.sampling_method = CAPTURE_SAMP_BY_COUNT;
448 interface_opts.sampling_param = get_positive_int(p, "sampling count");
449 g_array_append_val(capture_opts->ifaces, interface_opts);
451 capture_opts->default_options.sampling_method = CAPTURE_SAMP_BY_COUNT;
452 capture_opts->default_options.sampling_param = get_positive_int(p, "sampling count");
454 } else if (strcmp(arg, "timer") == 0) {
455 if (capture_opts->ifaces->len > 0) {
456 interface_options interface_opts;
458 interface_opts = g_array_index(capture_opts->ifaces, interface_options, capture_opts->ifaces->len - 1);
459 capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, capture_opts->ifaces->len - 1);
460 interface_opts.sampling_method = CAPTURE_SAMP_BY_TIMER;
461 interface_opts.sampling_param = get_positive_int(p, "sampling timer");
462 g_array_append_val(capture_opts->ifaces, interface_opts);
464 capture_opts->default_options.sampling_method = CAPTURE_SAMP_BY_TIMER;
465 capture_opts->default_options.sampling_param = get_positive_int(p, "sampling timer");
473 #ifdef HAVE_PCAP_REMOTE
475 * Given a string of the form "<username>:<password>", as might appear
476 * as an argument to a "-A" option, parse it and set the arguments in
477 * question. Return an indication of whether it succeeded or failed
481 get_auth_arguments(capture_options *capture_opts, const char *arg)
483 gchar *p = NULL, *colonp;
485 colonp = strchr(arg, ':');
492 while (g_ascii_isspace(*p))
495 if (capture_opts->ifaces->len > 0) {
496 interface_options interface_opts;
498 interface_opts = g_array_index(capture_opts->ifaces, interface_options, capture_opts->ifaces->len - 1);
499 capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, capture_opts->ifaces->len - 1);
500 interface_opts.auth_type = CAPTURE_AUTH_PWD;
501 interface_opts.auth_username = g_strdup(arg);
502 interface_opts.auth_password = g_strdup(p);
503 g_array_append_val(capture_opts->ifaces, interface_opts);
505 capture_opts->default_options.auth_type = CAPTURE_AUTH_PWD;
506 capture_opts->default_options.auth_username = g_strdup(arg);
507 capture_opts->default_options.auth_password = g_strdup(p);
515 capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str_p)
523 interface_options interface_opts;
526 * If the argument is a number, treat it as an index into the list
527 * of adapters, as printed by "tshark -D".
529 * This should be OK on UNIX systems, as interfaces shouldn't have
530 * names that begin with digits. It can be useful on Windows, where
531 * more than one interface can have the same name.
533 adapter_index = strtol(optarg_str_p, &p, 10);
534 if (p != NULL && *p == '\0') {
535 if (adapter_index < 0) {
536 cmdarg_err("The specified adapter index is a negative number");
539 if (adapter_index > INT_MAX) {
540 cmdarg_err("The specified adapter index is too large (greater than %d)",
544 if (adapter_index == 0) {
545 cmdarg_err("There is no interface with that adapter index");
548 if_list = capture_interface_list(&err, &err_str, NULL);
549 if (if_list == NULL) {
551 cmdarg_err("There are no interfaces on which a capture can be done");
553 cmdarg_err("%s", err_str);
558 if_info = (if_info_t *)g_list_nth_data(if_list, (int)(adapter_index - 1));
559 if (if_info == NULL) {
560 cmdarg_err("There is no interface with that adapter index");
563 interface_opts.name = g_strdup(if_info->name);
564 if (if_info->friendly_name != NULL) {
566 * We have a friendly name for the interface, so display that
567 * instead of the interface name/guid.
569 * XXX - on UN*X, the interface name is not quite so ugly,
570 * and might be more familiar to users; display them both?
572 interface_opts.console_display_name = g_strdup(if_info->friendly_name);
574 /* fallback to the interface name */
575 interface_opts.console_display_name = g_strdup(if_info->name);
577 interface_opts.if_type = if_info->type;
579 interface_opts.extcap = g_strdup(if_info->extcap);
581 free_interface_list(if_list);
582 } else if (capture_opts->capture_child) {
583 /* In Wireshark capture child mode, thus proper device name is supplied. */
584 /* No need for trying to match it for friendly names. */
585 interface_opts.name = g_strdup(optarg_str_p);
586 interface_opts.console_display_name = g_strdup(optarg_str_p);
587 interface_opts.if_type = capture_opts->default_options.if_type;
589 interface_opts.extcap = g_strdup(capture_opts->default_options.extcap);
593 * Retrieve the interface list so that we can search for the
594 * specified option amongst both the interface names and the
595 * friendly names and so that we find the friendly name even
596 * if an interface name was specified.
598 * If we can't get the list, just use the specified option as
599 * the interface name, so that the user can try specifying an
600 * interface explicitly for testing purposes.
602 if_list = capture_interface_list(&err, NULL, NULL);
603 if (if_list != NULL) {
604 /* try and do an exact match (case insensitive) */
609 for (if_entry = g_list_first(if_list); if_entry != NULL;
610 if_entry = g_list_next(if_entry))
612 if_info = (if_info_t *)if_entry->data;
613 /* exact name check */
614 if (g_ascii_strcasecmp(if_info->name, optarg_str_p) == 0) {
615 /* exact match on the interface name, use that for displaying etc */
616 interface_opts.name = g_strdup(if_info->name);
618 if (if_info->friendly_name != NULL) {
620 * If we have a friendly name, use that for the
621 * console display name, as it is the basis for
622 * the auto generated temp filename.
624 interface_opts.console_display_name = g_strdup(if_info->friendly_name);
626 interface_opts.console_display_name = g_strdup(if_info->name);
628 interface_opts.if_type = if_info->type;
630 interface_opts.extcap = g_strdup(if_info->extcap);
636 /* exact friendly name check */
637 if (if_info->friendly_name != NULL &&
638 g_ascii_strcasecmp(if_info->friendly_name, optarg_str_p) == 0) {
639 /* exact match - use the friendly name for display */
640 interface_opts.name = g_strdup(if_info->name);
641 interface_opts.console_display_name = g_strdup(if_info->friendly_name);
642 interface_opts.if_type = if_info->type;
644 interface_opts.extcap = g_strdup(if_info->extcap);
651 /* didn't find, attempt a case insensitive prefix match of the friendly name*/
653 size_t prefix_length;
655 prefix_length = strlen(optarg_str_p);
656 for (if_entry = g_list_first(if_list); if_entry != NULL;
657 if_entry = g_list_next(if_entry))
659 if_info = (if_info_t *)if_entry->data;
661 if (if_info->friendly_name != NULL &&
662 g_ascii_strncasecmp(if_info->friendly_name, optarg_str_p, prefix_length) == 0) {
663 /* prefix match - use the friendly name for display */
664 interface_opts.name = g_strdup(if_info->name);
665 interface_opts.console_display_name = g_strdup(if_info->friendly_name);
666 interface_opts.if_type = if_info->type;
668 interface_opts.extcap = g_strdup(if_info->extcap);
677 * We didn't find the interface in the list; just use
678 * the specified name, so that, for example, if an
679 * interface doesn't show up in the list for some
680 * reason, the user can try specifying it explicitly
681 * for testing purposes.
683 interface_opts.name = g_strdup(optarg_str_p);
684 interface_opts.console_display_name = g_strdup(optarg_str_p);
685 interface_opts.if_type = capture_opts->default_options.if_type;
687 interface_opts.extcap = g_strdup(capture_opts->default_options.extcap);
690 free_interface_list(if_list);
692 interface_opts.name = g_strdup(optarg_str_p);
693 interface_opts.console_display_name = g_strdup(optarg_str_p);
694 interface_opts.if_type = capture_opts->default_options.if_type;
696 interface_opts.extcap = g_strdup(capture_opts->default_options.extcap);
701 /* We don't set iface_descr here because doing so requires
702 * capture_ui_utils.c which requires epan/prefs.c which is
703 * probably a bit too much dependency for here...
705 interface_opts.descr = g_strdup(capture_opts->default_options.descr);
706 interface_opts.cfilter = g_strdup(capture_opts->default_options.cfilter);
707 interface_opts.snaplen = capture_opts->default_options.snaplen;
708 interface_opts.has_snaplen = capture_opts->default_options.has_snaplen;
709 interface_opts.linktype = capture_opts->default_options.linktype;
710 interface_opts.promisc_mode = capture_opts->default_options.promisc_mode;
712 interface_opts.extcap_fifo = g_strdup(capture_opts->default_options.extcap_fifo);
713 interface_opts.extcap_args = NULL;
714 interface_opts.extcap_pid = INVALID_EXTCAP_PID;
715 interface_opts.extcap_userdata = NULL;
716 interface_opts.extcap_control_in = g_strdup(capture_opts->default_options.extcap_control_in);
717 interface_opts.extcap_control_out = g_strdup(capture_opts->default_options.extcap_control_out);
719 #ifdef CAN_SET_CAPTURE_BUFFER_SIZE
720 interface_opts.buffer_size = capture_opts->default_options.buffer_size;
722 interface_opts.monitor_mode = capture_opts->default_options.monitor_mode;
723 #ifdef HAVE_PCAP_REMOTE
724 interface_opts.src_type = capture_opts->default_options.src_type;
725 interface_opts.remote_host = g_strdup(capture_opts->default_options.remote_host);
726 interface_opts.remote_port = g_strdup(capture_opts->default_options.remote_port);
727 interface_opts.auth_type = capture_opts->default_options.auth_type;
728 interface_opts.auth_username = g_strdup(capture_opts->default_options.auth_username);
729 interface_opts.auth_password = g_strdup(capture_opts->default_options.auth_password);
730 interface_opts.datatx_udp = capture_opts->default_options.datatx_udp;
731 interface_opts.nocap_rpcap = capture_opts->default_options.nocap_rpcap;
732 interface_opts.nocap_local = capture_opts->default_options.nocap_local;
734 #ifdef HAVE_PCAP_SETSAMPLING
735 interface_opts.sampling_method = capture_opts->default_options.sampling_method;
736 interface_opts.sampling_param = capture_opts->default_options.sampling_param;
738 interface_opts.timestamp_type = capture_opts->default_options.timestamp_type;
740 g_array_append_val(capture_opts->ifaces, interface_opts);
747 capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg_str_p, gboolean *start_capture)
752 case LONGOPT_NUM_CAP_COMMENT: /* capture comment */
753 if (capture_opts->capture_comment) {
754 cmdarg_err("--capture-comment can be set only once per file");
757 capture_opts->capture_comment = g_strdup(optarg_str_p);
759 case 'a': /* autostop criteria */
760 if (set_autostop_criterion(capture_opts, optarg_str_p) == FALSE) {
761 cmdarg_err("Invalid or unknown -a flag \"%s\"", optarg_str_p);
765 #ifdef HAVE_PCAP_REMOTE
767 if (get_auth_arguments(capture_opts, optarg_str_p) == FALSE) {
768 cmdarg_err("Invalid or unknown -A arg \"%s\"", optarg_str_p);
773 case 'b': /* Ringbuffer option */
774 capture_opts->multi_files_on = TRUE;
775 if (get_ring_arguments(capture_opts, optarg_str_p) == FALSE) {
776 cmdarg_err("Invalid or unknown -b arg \"%s\"", optarg_str_p);
780 #ifdef CAN_SET_CAPTURE_BUFFER_SIZE
781 case 'B': /* Buffer size */
782 if (capture_opts->ifaces->len > 0) {
783 interface_options interface_opts;
785 interface_opts = g_array_index(capture_opts->ifaces, interface_options, capture_opts->ifaces->len - 1);
786 capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, capture_opts->ifaces->len - 1);
787 interface_opts.buffer_size = get_positive_int(optarg_str_p, "buffer size");
788 g_array_append_val(capture_opts->ifaces, interface_opts);
790 capture_opts->default_options.buffer_size = get_positive_int(optarg_str_p, "buffer size");
794 case 'c': /* Capture n packets */
795 capture_opts->has_autostop_packets = TRUE;
796 capture_opts->autostop_packets = get_positive_int(optarg_str_p, "packet count");
798 case 'f': /* capture filter */
799 get_filter_arguments(capture_opts, optarg_str_p);
801 case 'g': /* enable group read access on the capture file(s) */
802 capture_opts->group_read_access = TRUE;
804 case 'H': /* Hide capture info dialog box */
805 capture_opts->show_info = FALSE;
807 case LONGOPT_SET_TSTAMP_TYPE: /* Set capture time stamp type */
808 if (capture_opts->ifaces->len > 0) {
809 interface_options interface_opts;
811 interface_opts = g_array_index(capture_opts->ifaces, interface_options, capture_opts->ifaces->len - 1);
812 capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, capture_opts->ifaces->len - 1);
813 g_free(interface_opts.timestamp_type);
814 interface_opts.timestamp_type = g_strdup(optarg_str_p);
815 g_array_append_val(capture_opts->ifaces, interface_opts);
817 g_free(capture_opts->default_options.timestamp_type);
818 capture_opts->default_options.timestamp_type = g_strdup(optarg_str_p);
821 case 'i': /* Use interface x */
822 status = capture_opts_add_iface_opt(capture_opts, optarg_str_p);
827 #ifdef HAVE_PCAP_CREATE
828 case 'I': /* Capture in monitor mode */
829 if (capture_opts->ifaces->len > 0) {
830 interface_options interface_opts;
832 interface_opts = g_array_index(capture_opts->ifaces, interface_options, capture_opts->ifaces->len - 1);
833 capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, capture_opts->ifaces->len - 1);
834 interface_opts.monitor_mode = TRUE;
835 g_array_append_val(capture_opts->ifaces, interface_opts);
837 capture_opts->default_options.monitor_mode = TRUE;
841 case 'k': /* Start capture immediately */
842 *start_capture = TRUE;
844 /*case 'l':*/ /* Automatic scrolling in live capture mode */
845 #ifdef HAVE_PCAP_SETSAMPLING
847 if (get_sampling_arguments(capture_opts, optarg_str_p) == FALSE) {
848 cmdarg_err("Invalid or unknown -m arg \"%s\"", optarg_str_p);
853 case 'n': /* Use pcapng format */
854 capture_opts->use_pcapng = TRUE;
856 case 'p': /* Don't capture in promiscuous mode */
857 if (capture_opts->ifaces->len > 0) {
858 interface_options interface_opts;
860 interface_opts = g_array_index(capture_opts->ifaces, interface_options, capture_opts->ifaces->len - 1);
861 capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, capture_opts->ifaces->len - 1);
862 interface_opts.promisc_mode = FALSE;
863 g_array_append_val(capture_opts->ifaces, interface_opts);
865 capture_opts->default_options.promisc_mode = FALSE;
868 case 'P': /* Use pcap format */
869 capture_opts->use_pcapng = FALSE;
871 #ifdef HAVE_PCAP_REMOTE
873 if (capture_opts->ifaces->len > 0) {
874 interface_options interface_opts;
876 interface_opts = g_array_index(capture_opts->ifaces, interface_options, capture_opts->ifaces->len - 1);
877 capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, capture_opts->ifaces->len - 1);
878 interface_opts.nocap_rpcap = FALSE;
879 g_array_append_val(capture_opts->ifaces, interface_opts);
881 capture_opts->default_options.nocap_rpcap = FALSE;
885 case 's': /* Set the snapshot (capture) length */
886 snaplen = get_natural_int(optarg_str_p, "snapshot length");
888 * Make a snapshot length of 0 equivalent to the maximum packet
889 * length, mirroring what tcpdump does.
892 snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
893 if (capture_opts->ifaces->len > 0) {
894 interface_options interface_opts;
896 interface_opts = g_array_index(capture_opts->ifaces, interface_options, capture_opts->ifaces->len - 1);
897 capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, capture_opts->ifaces->len - 1);
898 interface_opts.has_snaplen = TRUE;
899 interface_opts.snaplen = snaplen;
900 g_array_append_val(capture_opts->ifaces, interface_opts);
902 capture_opts->default_options.snaplen = snaplen;
903 capture_opts->default_options.has_snaplen = TRUE;
906 case 'S': /* "Real-Time" mode: used for following file ala tail -f */
907 capture_opts->real_time_mode = TRUE;
909 #ifdef HAVE_PCAP_REMOTE
911 if (capture_opts->ifaces->len > 0) {
912 interface_options interface_opts;
914 interface_opts = g_array_index(capture_opts->ifaces, interface_options, capture_opts->ifaces->len - 1);
915 capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, capture_opts->ifaces->len - 1);
916 interface_opts.datatx_udp = TRUE;
917 g_array_append_val(capture_opts->ifaces, interface_opts);
919 capture_opts->default_options.datatx_udp = TRUE;
923 case 'w': /* Write to capture file x */
924 capture_opts->saving_to_file = TRUE;
925 g_free(capture_opts->save_file);
926 capture_opts->save_file = g_strdup(optarg_str_p);
927 status = capture_opts_output_to_pipe(capture_opts->save_file, &capture_opts->output_to_pipe);
929 case 'y': /* Set the pcap data link type */
930 if (capture_opts->ifaces->len > 0) {
931 interface_options interface_opts;
933 interface_opts = g_array_index(capture_opts->ifaces, interface_options, capture_opts->ifaces->len - 1);
934 capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, capture_opts->ifaces->len - 1);
935 interface_opts.linktype = linktype_name_to_val(optarg_str_p);
936 if (interface_opts.linktype == -1) {
937 cmdarg_err("The specified data link type \"%s\" isn't valid",
941 g_array_append_val(capture_opts->ifaces, interface_opts);
943 capture_opts->default_options.linktype = linktype_name_to_val(optarg_str_p);
944 if (capture_opts->default_options.linktype == -1) {
945 cmdarg_err("The specified data link type \"%s\" isn't valid",
952 /* the caller is responsible to send us only the right opt's */
953 g_assert_not_reached();
960 capture_opts_print_if_capabilities(if_capabilities_t *caps, char *name, int queries)
962 GList *lt_entry, *ts_entry;
964 if (queries & CAPS_QUERY_LINK_TYPES) {
965 if (caps->can_set_rfmon)
966 printf("Data link types of interface %s when %sin monitor mode (use option -y to set):\n",
967 name, queries & CAPS_MONITOR_MODE ? "" : "not ");
969 printf("Data link types of interface %s (use option -y to set):\n", name);
970 for (lt_entry = caps->data_link_types; lt_entry != NULL;
971 lt_entry = g_list_next(lt_entry)) {
972 data_link_info_t *data_link_info = (data_link_info_t *)lt_entry->data;
973 printf(" %s", data_link_info->name);
974 if (data_link_info->description != NULL)
975 printf(" (%s)", data_link_info->description);
977 printf(" (not supported)");
982 if (queries & CAPS_QUERY_TIMESTAMP_TYPES) {
983 printf("Timestamp types of the interface (use option --time-stamp-type to set):\n");
984 for (ts_entry = caps->timestamp_types; ts_entry != NULL;
985 ts_entry = g_list_next(ts_entry)) {
986 timestamp_info_t *timestamp = (timestamp_info_t *)ts_entry->data;
987 printf(" %s", timestamp->name);
988 if (timestamp->description != NULL)
989 printf(" (%s)", timestamp->description);
997 /* Print an ASCII-formatted list of interfaces. */
999 capture_opts_print_interfaces(GList *if_list)
1005 i = 1; /* Interface id number */
1006 for (if_entry = g_list_first(if_list); if_entry != NULL;
1007 if_entry = g_list_next(if_entry)) {
1008 if_info = (if_info_t *)if_entry->data;
1009 printf("%d. %s", i++, if_info->name);
1011 /* Print the interface friendly name, if it exists;
1012 if not fall back to vendor description, if it exists. */
1013 if (if_info->friendly_name != NULL){
1014 printf(" (%s)", if_info->friendly_name);
1016 if (if_info->vendor_description != NULL)
1017 printf(" (%s)", if_info->vendor_description);
1025 capture_opts_trim_snaplen(capture_options *capture_opts, int snaplen_min)
1028 interface_options interface_opts;
1030 if (capture_opts->ifaces->len > 0) {
1031 for (i = 0; i < capture_opts->ifaces->len; i++) {
1032 interface_opts = g_array_index(capture_opts->ifaces, interface_options, 0);
1033 capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, 0);
1034 if (interface_opts.snaplen < 1)
1035 interface_opts.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
1036 else if (interface_opts.snaplen < snaplen_min)
1037 interface_opts.snaplen = snaplen_min;
1038 g_array_append_val(capture_opts->ifaces, interface_opts);
1041 if (capture_opts->default_options.snaplen < 1)
1042 capture_opts->default_options.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
1043 else if (capture_opts->default_options.snaplen < snaplen_min)
1044 capture_opts->default_options.snaplen = snaplen_min;
1050 capture_opts_trim_ring_num_files(capture_options *capture_opts)
1052 /* Check the value range of the ring_num_files parameter */
1053 if (capture_opts->ring_num_files > RINGBUFFER_MAX_NUM_FILES) {
1054 cmdarg_err("Too many ring buffer files (%u). Reducing to %u.\n", capture_opts->ring_num_files, RINGBUFFER_MAX_NUM_FILES);
1055 capture_opts->ring_num_files = RINGBUFFER_MAX_NUM_FILES;
1056 } else if (capture_opts->ring_num_files > RINGBUFFER_WARN_NUM_FILES) {
1057 cmdarg_err("%u is a lot of ring buffer files.\n", capture_opts->ring_num_files);
1059 #if RINGBUFFER_MIN_NUM_FILES > 0
1060 else if (capture_opts->ring_num_files < RINGBUFFER_MIN_NUM_FILES)
1061 cmdarg_err("Too few ring buffer files (%u). Increasing to %u.\n", capture_opts->ring_num_files, RINGBUFFER_MIN_NUM_FILES);
1062 capture_opts->ring_num_files = RINGBUFFER_MIN_NUM_FILES;
1067 * If no interface was specified explicitly, pick a default.
1070 capture_opts_default_iface_if_necessary(capture_options *capture_opts,
1071 const char *capture_device)
1075 /* Did the user specify an interface to use? */
1076 if (capture_opts->num_selected != 0 || capture_opts->ifaces->len != 0) {
1077 /* yes they did, return immediately - nothing further to do here */
1081 /* No - is a default specified in the preferences file? */
1082 if (capture_device != NULL) {
1084 status = capture_opts_add_iface_opt(capture_opts, capture_device);
1087 /* No default in preferences file, just pick the first interface from the list of interfaces. */
1088 return capture_opts_add_iface_opt(capture_opts, "1");
1092 #define S_IFIFO _S_IFIFO
1095 #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
1098 /* copied from filesystem.c */
1100 capture_opts_test_for_fifo(const char *path)
1104 if (ws_stat64(path, &statb) < 0)
1107 if (S_ISFIFO(statb.st_mode))
1114 capture_opts_output_to_pipe(const char *save_file, gboolean *is_pipe)
1120 if (save_file != NULL) {
1121 /* We're writing to a capture file. */
1122 if (strcmp(save_file, "-") == 0) {
1123 /* Writing to stdout. */
1124 /* XXX - should we check whether it's a pipe? It's arguably
1125 silly to do "-w - >output_file" rather than "-w output_file",
1126 but by not checking we might be violating the Principle Of
1127 Least Astonishment. */
1130 /* not writing to stdout, test for a FIFO (aka named pipe) */
1131 err = capture_opts_test_for_fifo(save_file);
1134 case ENOENT: /* it doesn't exist, so we'll be creating it,
1135 and it won't be a FIFO */
1136 case 0: /* found it, but it's not a FIFO */
1139 case ESPIPE: /* it is a FIFO */
1143 default: /* couldn't stat it */
1144 break; /* ignore: later attempt to open */
1145 /* will generate a nice msg */
1154 capture_opts_del_iface(capture_options *capture_opts, guint if_index)
1156 interface_options interface_opts;
1158 interface_opts = g_array_index(capture_opts->ifaces, interface_options, if_index);
1159 /* XXX - check if found? */
1161 g_free(interface_opts.name);
1162 g_free(interface_opts.descr);
1163 if (interface_opts.console_display_name != NULL)
1164 g_free(interface_opts.console_display_name);
1165 g_free(interface_opts.cfilter);
1166 g_free(interface_opts.timestamp_type);
1168 g_free(interface_opts.extcap);
1169 g_free(interface_opts.extcap_fifo);
1170 if (interface_opts.extcap_args)
1171 g_hash_table_unref(interface_opts.extcap_args);
1172 if (interface_opts.extcap_pid != INVALID_EXTCAP_PID)
1173 g_spawn_close_pid(interface_opts.extcap_pid);
1174 g_free(interface_opts.extcap_userdata);
1175 g_free(interface_opts.extcap_control_in);
1176 g_free(interface_opts.extcap_control_out);
1178 #ifdef HAVE_PCAP_REMOTE
1179 if (interface_opts.src_type == CAPTURE_IFREMOTE) {
1180 g_free(interface_opts.remote_host);
1181 g_free(interface_opts.remote_port);
1182 g_free(interface_opts.auth_username);
1183 g_free(interface_opts.auth_password);
1186 capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, if_index);
1192 * Add all non-hidden selected interfaces in the "all interfaces" list
1193 * to the list of interfaces for the capture.
1196 collect_ifaces(capture_options *capture_opts)
1200 interface_options interface_opts;
1202 /* Empty out the existing list of interfaces. */
1203 for (i = capture_opts->ifaces->len; i != 0; i--)
1204 capture_opts_del_iface(capture_opts, i-1);
1206 /* Now fill the list up again. */
1207 for (i = 0; i < capture_opts->all_ifaces->len; i++) {
1208 device = g_array_index(capture_opts->all_ifaces, interface_t, i);
1209 if (!device.hidden && device.selected) {
1210 interface_opts.name = g_strdup(device.name);
1211 interface_opts.descr = g_strdup(device.display_name);
1212 interface_opts.console_display_name = g_strdup(device.name);
1213 interface_opts.linktype = device.active_dlt;
1214 interface_opts.cfilter = g_strdup(device.cfilter);
1215 interface_opts.timestamp_type = g_strdup(device.timestamp_type);
1216 interface_opts.snaplen = device.snaplen;
1217 interface_opts.has_snaplen = device.has_snaplen;
1218 interface_opts.promisc_mode = device.pmode;
1219 interface_opts.if_type = device.if_info.type;
1221 interface_opts.extcap = g_strdup(device.if_info.extcap);
1222 interface_opts.extcap_fifo = NULL;
1223 interface_opts.extcap_userdata = NULL;
1224 interface_opts.extcap_args = device.external_cap_args_settings;
1225 interface_opts.extcap_pid = INVALID_EXTCAP_PID;
1226 if (interface_opts.extcap_args)
1227 g_hash_table_ref(interface_opts.extcap_args);
1228 interface_opts.extcap_userdata = NULL;
1229 interface_opts.extcap_control_in = NULL;
1230 interface_opts.extcap_control_out = NULL;
1232 #ifdef CAN_SET_CAPTURE_BUFFER_SIZE
1233 interface_opts.buffer_size = device.buffer;
1235 #ifdef HAVE_PCAP_CREATE
1236 interface_opts.monitor_mode = device.monitor_mode_enabled;
1238 #ifdef HAVE_PCAP_REMOTE
1239 interface_opts.src_type = CAPTURE_IFREMOTE;
1240 interface_opts.remote_host = g_strdup(device.remote_opts.remote_host_opts.remote_host);
1241 interface_opts.remote_port = g_strdup(device.remote_opts.remote_host_opts.remote_port);
1242 interface_opts.auth_type = device.remote_opts.remote_host_opts.auth_type;
1243 interface_opts.auth_username = g_strdup(device.remote_opts.remote_host_opts.auth_username);
1244 interface_opts.auth_password = g_strdup(device.remote_opts.remote_host_opts.auth_password);
1245 interface_opts.datatx_udp = device.remote_opts.remote_host_opts.datatx_udp;
1246 interface_opts.nocap_rpcap = device.remote_opts.remote_host_opts.nocap_rpcap;
1247 interface_opts.nocap_local = device.remote_opts.remote_host_opts.nocap_local;
1249 #ifdef HAVE_PCAP_SETSAMPLING
1250 interface_opts.sampling_method = device.remote_opts.sampling_method;
1251 interface_opts.sampling_param = device.remote_opts.sampling_param;
1253 g_array_append_val(capture_opts->ifaces, interface_opts);
1261 capture_opts_free_interface_t_links(gpointer elem, gpointer unused _U_)
1263 link_row* e = (link_row*)elem;
1270 capture_opts_free_interface_t_addrs(gpointer elem, gpointer unused _U_)
1276 capture_opts_free_interface_t(interface_t *device)
1278 if (device != NULL) {
1279 g_free(device->name);
1280 g_free(device->display_name);
1281 g_free(device->friendly_name);
1282 g_free(device->addresses);
1283 g_free(device->cfilter);
1284 g_free(device->timestamp_type);
1285 g_list_foreach(device->links,
1286 capture_opts_free_interface_t_links, NULL);
1287 g_list_free(device->links);
1288 #ifdef HAVE_PCAP_REMOTE
1289 g_free(device->remote_opts.remote_host_opts.remote_host);
1290 g_free(device->remote_opts.remote_host_opts.remote_port);
1291 g_free(device->remote_opts.remote_host_opts.auth_username);
1292 g_free(device->remote_opts.remote_host_opts.auth_password);
1294 g_free(device->if_info.name);
1295 g_free(device->if_info.friendly_name);
1296 g_free(device->if_info.vendor_description);
1297 g_slist_foreach(device->if_info.addrs,
1298 capture_opts_free_interface_t_addrs, NULL);
1299 g_slist_free(device->if_info.addrs);
1301 g_free(device->if_info.extcap);
1306 #endif /* HAVE_LIBPCAP */
1309 * Editor modelines - http://www.wireshark.org/tools/modelines.html
1314 * indent-tabs-mode: nil
1317 * vi: set shiftwidth=4 tabstop=8 expandtab:
1318 * :indentSize=4:tabSize=8:noTabs=true: