2005-01-16 02:56:28 +00:00
|
|
|
/* capture_ui_utils.c
|
|
|
|
* Declarations of utilities for capture user interfaces
|
2003-09-10 05:35:26 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2003-09-10 05:35:26 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2003-09-10 05:35:26 +00:00
|
|
|
*/
|
|
|
|
|
2005-01-16 02:56:28 +00:00
|
|
|
#ifndef __CAPTURE_UI_UTILS_H__
|
|
|
|
#define __CAPTURE_UI_UTILS_H__
|
2003-09-10 05:35:26 +00:00
|
|
|
|
2007-08-22 18:56:20 +00:00
|
|
|
#include "capture_opts.h"
|
|
|
|
|
2011-12-29 00:08:47 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2004-06-01 20:28:05 +00:00
|
|
|
/** @file
|
|
|
|
* GList of available capture interfaces.
|
|
|
|
*/
|
|
|
|
|
2008-04-18 14:29:54 +00:00
|
|
|
/**
|
|
|
|
* Find user-specified capture device description that matches interface
|
|
|
|
* name, if any.
|
2015-03-19 00:27:57 +00:00
|
|
|
*
|
|
|
|
* @param if_name The name of the interface.
|
|
|
|
*
|
|
|
|
* @return The device description (must be g_free'd later) or NULL
|
|
|
|
* if not found.
|
2008-04-18 14:29:54 +00:00
|
|
|
*/
|
|
|
|
char *capture_dev_user_descr_find(const gchar *if_name);
|
|
|
|
|
2008-06-02 17:45:03 +00:00
|
|
|
/**
|
|
|
|
* Find user-specified link-layer header type that matches interface
|
|
|
|
* name, if any.
|
2015-03-19 00:27:57 +00:00
|
|
|
*
|
|
|
|
* @param if_name The name of the interface.
|
|
|
|
*
|
|
|
|
* @return The link-layer header type (a DLT_) or -1 if not found.
|
2008-06-02 17:45:03 +00:00
|
|
|
*/
|
|
|
|
gint capture_dev_user_linktype_find(const gchar *if_name);
|
|
|
|
|
2015-03-25 03:22:00 +00:00
|
|
|
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
|
2013-03-07 09:16:55 +00:00
|
|
|
/**
|
|
|
|
* Find user-specified buffer size that matches interface
|
|
|
|
* name, if any.
|
2015-03-19 00:27:57 +00:00
|
|
|
*
|
|
|
|
* @param if_name The name of the interface.
|
|
|
|
*
|
|
|
|
* @return The buffer size or -1 if not found.
|
2013-03-07 09:16:55 +00:00
|
|
|
*/
|
|
|
|
gint capture_dev_user_buffersize_find(const gchar *if_name);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find user-specified snap length that matches interface
|
|
|
|
* name, if any.
|
2015-03-19 00:27:57 +00:00
|
|
|
*
|
|
|
|
* @param if_name The name of the interface.
|
|
|
|
* @param hassnap Pointer to a variable to be set to TRUE if the
|
|
|
|
* interface should be given a snap length or FALSE if it shouldn't
|
|
|
|
* be given a snap length.
|
|
|
|
* @param snaplen Pointer to a variable to be set to the snap length
|
|
|
|
* if the interface should be given a snap length or the maximum
|
|
|
|
* snap length if it shouldn't be given a snap length.
|
|
|
|
*
|
|
|
|
* @return TRUE if found or FALSE if not found.
|
2013-03-07 09:16:55 +00:00
|
|
|
*/
|
2015-03-18 23:58:15 +00:00
|
|
|
gboolean capture_dev_user_snaplen_find(const gchar *if_name, gboolean *hassnap, int *snaplen);
|
2013-03-07 09:16:55 +00:00
|
|
|
|
2013-03-13 12:38:08 +00:00
|
|
|
/**
|
|
|
|
* Find user-specified promiscuous mode that matches interface
|
|
|
|
* name, if any.
|
2015-04-04 21:01:56 +00:00
|
|
|
*
|
|
|
|
* @param if_name The name of the interface.
|
|
|
|
* @param pmode Pointer to a variable to be set to TRUE if promiscuous
|
|
|
|
* mode should be used and FALSE if it shouldn't be used.
|
|
|
|
*
|
|
|
|
* @return TRUE if found or FALSE if not found.
|
2013-03-13 12:38:08 +00:00
|
|
|
*/
|
2015-04-04 21:01:56 +00:00
|
|
|
gboolean capture_dev_user_pmode_find(const gchar *if_name, gboolean *pmode);
|
2013-03-13 12:38:08 +00:00
|
|
|
|
2014-06-04 09:03:59 +00:00
|
|
|
/**
|
|
|
|
* Find user-specified capture filter that matches interface
|
|
|
|
* name, if any.
|
2015-03-19 00:27:57 +00:00
|
|
|
*
|
2016-02-23 18:04:16 +00:00
|
|
|
* This is deprecated and should not be used in new code.
|
|
|
|
*
|
2015-03-19 00:27:57 +00:00
|
|
|
* @param if_name The name of the interface.
|
|
|
|
*
|
|
|
|
* @return The capture filter (must be g_free'd later) or NULL if not found.
|
2014-06-04 09:03:59 +00:00
|
|
|
*/
|
|
|
|
gchar* capture_dev_user_cfilter_find(const gchar *if_name);
|
|
|
|
|
2005-01-16 02:48:41 +00:00
|
|
|
/** Return as descriptive a name for an interface as we can get.
|
|
|
|
* If the user has specified a comment, use that. Otherwise,
|
2010-03-04 01:12:04 +00:00
|
|
|
* if capture_interface_list() supplies a description, use that,
|
2005-01-16 02:48:41 +00:00
|
|
|
* otherwise use the interface name.
|
|
|
|
*
|
2005-04-19 22:32:52 +00:00
|
|
|
* @param if_name The name of the interface.
|
2005-01-16 02:48:41 +00:00
|
|
|
*
|
2005-04-19 22:32:52 +00:00
|
|
|
* @return The descriptive name (must be g_free'd later)
|
2005-01-16 02:48:41 +00:00
|
|
|
*/
|
|
|
|
char *get_interface_descriptive_name(const char *if_name);
|
|
|
|
|
2004-06-01 20:28:05 +00:00
|
|
|
/** Build the GList of available capture interfaces.
|
|
|
|
*
|
2010-03-04 01:12:04 +00:00
|
|
|
* @param if_list An interface list from capture_interface_list().
|
2004-09-02 21:49:36 +00:00
|
|
|
* @param do_hide Hide the "hidden" interfaces.
|
|
|
|
*
|
2005-04-19 22:32:52 +00:00
|
|
|
* @return A list of if_info_t structs (use free_capture_combo_list() later).
|
2004-06-01 20:28:05 +00:00
|
|
|
*/
|
2003-09-10 05:35:26 +00:00
|
|
|
GList *build_capture_combo_list(GList *if_list, gboolean do_hide);
|
2004-06-01 20:28:05 +00:00
|
|
|
|
|
|
|
/** Free the GList from build_capture_combo_list().
|
|
|
|
*
|
|
|
|
* @param combo_list the interface list from build_capture_combo_list()
|
|
|
|
*/
|
2003-09-10 05:35:26 +00:00
|
|
|
void free_capture_combo_list(GList *combo_list);
|
|
|
|
|
2004-09-02 21:49:36 +00:00
|
|
|
|
|
|
|
/** Given text that contains an interface name possibly prefixed by an
|
|
|
|
* interface description, extract the interface name.
|
|
|
|
*
|
|
|
|
* @param if_text A string containing the interface description + name.
|
|
|
|
* This is usually the data from one of the list elements returned by
|
|
|
|
* build_capture_combo_list().
|
|
|
|
*
|
2005-04-19 22:32:52 +00:00
|
|
|
* @return The raw interface name, without description (must NOT be g_free'd later)
|
2004-09-02 21:49:36 +00:00
|
|
|
*/
|
2005-12-14 07:29:38 +00:00
|
|
|
const char *get_if_name(const char *if_text);
|
2004-09-02 21:49:36 +00:00
|
|
|
|
2007-08-22 18:56:20 +00:00
|
|
|
/** Return the interface description (after setting it if not already set)
|
|
|
|
*
|
|
|
|
* @param capture_opts The capture_options structure that contains the used interface
|
2011-06-27 00:09:03 +00:00
|
|
|
* @param i The index of the interface
|
2007-08-22 18:56:20 +00:00
|
|
|
*
|
2011-06-27 00:09:03 +00:00
|
|
|
* @return A pointer to interface_opts->descr
|
2007-08-22 18:56:20 +00:00
|
|
|
*/
|
2011-05-19 12:19:03 +00:00
|
|
|
const char *get_iface_description_for_interface(capture_options *capture_opts, guint i);
|
2005-04-19 22:32:52 +00:00
|
|
|
|
2015-03-22 23:58:42 +00:00
|
|
|
/** Set the active DLT for a device appropriately.
|
|
|
|
*
|
|
|
|
* @param device the device on which to set the active DLT
|
|
|
|
* @param global_default_dlt the global default DLT
|
|
|
|
*/
|
|
|
|
extern void set_active_dlt(interface_t *device, int global_default_dlt);
|
|
|
|
|
2015-04-05 23:42:35 +00:00
|
|
|
/** Get a descriptive string for a list of interfaces.
|
|
|
|
*
|
|
|
|
* @param capture_opts The capture_options structure that contains the interfaces
|
|
|
|
* @param style flags to indicate the style of string to use:
|
|
|
|
*
|
|
|
|
* IFLIST_QUOTE_IF_DESCRIPTION: put the interface descriptive string in
|
|
|
|
* single quotes
|
|
|
|
*
|
|
|
|
* IFLIST_SHOW_FILTER: include the capture filters in the string
|
|
|
|
*
|
|
|
|
* @return A GString set to the descriptive string
|
|
|
|
*/
|
|
|
|
#define IFLIST_QUOTE_IF_DESCRIPTION 0x00000001
|
|
|
|
#define IFLIST_SHOW_FILTER 0x00000002
|
|
|
|
|
|
|
|
extern GString *get_iface_list_string(capture_options *capture_opts, guint32 style);
|
|
|
|
|
2015-12-02 06:32:48 +00:00
|
|
|
/** Get the interface display name to present in the interfaces list.
|
|
|
|
*
|
|
|
|
* @param description A user-specified capture device description
|
|
|
|
* @param if_info The if_info for the interface
|
|
|
|
*
|
|
|
|
* @return A interface display name (must be g_free'd later)
|
|
|
|
*/
|
|
|
|
extern gchar *get_iface_display_name(const gchar *description, const if_info_t *if_info);
|
|
|
|
|
2011-12-29 00:08:47 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2014-10-14 19:58:21 +00:00
|
|
|
#endif /* __CAPTURE_UI_UTILS_H__ */
|
|
|
|
|
2014-10-12 18:56:12 +00:00
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 2
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
2014-10-14 19:58:21 +00:00
|
|
|
* vi: set shiftwidth=2 tabstop=8 expandtab:
|
2014-10-12 18:56:12 +00:00
|
|
|
* :indentSize=2:tabSize=8:noTabs=true:
|
|
|
|
*/
|