wireshark/ui/preference_utils.h
Michael Mann 268841f3e0 Combine Decode As and port preferences for tcp.port dissector table.
This patch introduces new APIs to allow dissectors to have a preference for
a (TCP) port, but the underlying data is actually part of Decode As functionality.
For now the APIs are intentionally separate from the regular APIs that register a
dissector within a dissector table.  It may be possible to eventually combine the
two so that all dissectors that register with a dissector table have an opportunity
to "automatically" have a preference to adjust the "table value" through the
preferences dialog.

The tcp.port dissector table was used as the guinea pig.  This will eventually be
expanded to other dissector tables as well (most notably UDP ports).  Some
dissectors that "shared" a TCP/UDP port preference were also converted. It also
removed the need for some preference callback functions (mostly when the callback
function was the proto_reg_handoff function) so there is cleanup around that.

Dissectors that has a port preference whose default was 0 were switched to using
the dissector_add_for_decode_as_with_preference API rather than dissector_add_uint_with_preference

Also added comments for TCP ports used that aren't IANA registered.

Change-Id: I99604f95d426ad345f4b494598d94178b886eb67
Reviewed-on: https://code.wireshark.org/review/17724
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-10-08 02:44:53 +00:00

163 lines
4.4 KiB
C

/* preference_utils.h
* Routines for handling preferences
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* 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
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __PREFRENCE_UTILS_H__
#define __PREFRENCE_UTILS_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** @file
* Preference utility routines.
* @ingroup prefs_group
*/
/** "Stash" a preference.
* Copy a preference to its stashed value. Can be called from prefs_pref_foreach().
*
* @param pref A preference.
* @param unused unused
*/
extern guint pref_stash(pref_t *pref, gpointer unused _U_);
typedef struct pref_unstash_data
{
/* Used to set prefs_changed member to TRUE if the preference
differs from its stashed values. Also used by "decode as" types
to look up dissector short name */
module_t *module;
/* Qt uses stashed values to then "applies" them
during unstash. Use this flag for that behavior */
gboolean handle_decode_as;
} pref_unstash_data_t;
/** "Unstash" a preference.
* Set a preference to its stashed value. Can be called from prefs_pref_foreach().
*
* @param pref A preference.
* @param unstash_data_p A pointer to a pref_unstash_data_t structure.
*
* @return Always returns 0.
*/
extern guint pref_unstash(pref_t *pref, gpointer unstash_data_p);
/** Clean up a stashed preference.
* Can be called from prefs_pref_foreach().
*
* @param pref A preference.
* @param unused unused
*
* @return Always returns 0.
*/
extern guint pref_clean_stash(pref_t *pref, gpointer unused _U_);
/** Set a stashed preference to its default value.
*
*@param pref A preference.
*/
extern void reset_stashed_pref(pref_t *pref);
/** If autoscroll in live captures is active or not
*/
extern gboolean auto_scroll_live;
/** Fill in capture options with values from the preferences
*/
extern void prefs_to_capture_opts(void);
/** Save all preferences
*/
extern void prefs_main_write(void);
/** Convenient function for plugin_if
*
* Note: The preferences must exist, it is not possible to create entries
* using this function
*
* @param module the module for the preference
* @param key the key for the preference
* @param value the new value as string for the preference
*
* @return true if the value has been stored successfully
*/
extern gboolean prefs_store_ext(const char * module, const char * key, const char * value);
/** Convenient function for the writing of multiple preferences, without
* explicitly having prefs_t variables.
*
* Note: The preferences must exist, it is not possible to create entries
* using this function
*
* @param module the module for the preference
* @param pref_values a hash table
*
* @return true if the value has been stored successfully
*/
extern gboolean prefs_store_ext_multiple(const char * module, GHashTable * pref_values);
/** Add a custom column.
*
* @param fmt column format
* @param title column title
* @param custom_field column custom field
* @param custom_occurrence custom occurrence
*
* @return The index of the inserted column
*/
gint column_prefs_add_custom(gint fmt, const gchar *title,
const gchar *custom_field,
gint custom_occurrence);
/** Remove a column.
*
* @param col_link Column list entry
*/
void column_prefs_remove_link(GList* col_link);
/** Remove a column.
*
* @param col Column number
*/
void column_prefs_remove_nth(gint col);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __PREFRENCE_UTILS_H__ */
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/