2019-11-04 09:42:29 +00:00
|
|
|
/* conversation_filter.h
|
2015-10-29 03:57:37 +00:00
|
|
|
* Routines for dissector-generated conversation filters for use as
|
|
|
|
* display and color filters
|
2014-12-09 02:40:24 +00:00
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-08 16:59:17 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2014-12-09 02:40:24 +00:00
|
|
|
*/
|
|
|
|
|
2015-10-29 03:30:55 +00:00
|
|
|
#ifndef __DISSECTOR_FILTERS_H__
|
|
|
|
#define __DISSECTOR_FILTERS_H__
|
2014-12-09 02:40:24 +00:00
|
|
|
|
|
|
|
#include "ws_symbol_export.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
/** @file
|
|
|
|
*/
|
|
|
|
|
2022-04-15 00:49:03 +00:00
|
|
|
/** Initialize internal structures */
|
|
|
|
extern void conversation_filters_init(void);
|
|
|
|
|
2023-01-26 22:26:04 +00:00
|
|
|
/**
|
|
|
|
* Callback function which checks for filter availability.
|
|
|
|
*
|
|
|
|
* @param pinfo packet_info pointer for the current packet.
|
|
|
|
* @param user_data User data provided to register_conversation_filter or register_log_conversation_filter.
|
|
|
|
* @return TRUE if the packet has a valid conversation filter, FALSE otherwise.
|
|
|
|
*/
|
|
|
|
typedef gboolean (*is_filter_valid_func)(struct _packet_info *pinfo, void *user_data);
|
2014-12-09 02:40:24 +00:00
|
|
|
|
|
|
|
/** callback function definition: return the available filter for this packet or NULL if no filter is available,
|
|
|
|
Filter needs to be freed after use */
|
2023-01-26 22:26:04 +00:00
|
|
|
/**
|
|
|
|
* Callback function which creates a conversation filter.
|
|
|
|
*
|
|
|
|
* @param pinfo packet_info pointer for the current packet.
|
|
|
|
* @param user_data User data provided to register_conversation_filter or register_log_conversation_filter.
|
|
|
|
* @return A filter for the conversation on success, NULL on failure. The filter must be gfreed.
|
|
|
|
*/
|
|
|
|
typedef gchar* (*build_filter_string_func)(struct _packet_info *pinfo, void *user_data);
|
2014-12-09 02:40:24 +00:00
|
|
|
|
2023-01-26 22:26:04 +00:00
|
|
|
/**
|
|
|
|
* Register a new packet conversation filter.
|
|
|
|
*
|
|
|
|
* @param proto_name The protocol name.
|
|
|
|
* @param display_name A friendly name for the filter.
|
|
|
|
* @param is_filter_valid A callback function conforming to is_filter_valid_func.
|
|
|
|
* @param build_filter_string A callback function conforming to build_filter_string_func.
|
|
|
|
* @param user_data User-defined data which is passed to the callback functions. Can be NULL.
|
|
|
|
*/
|
2015-10-29 03:30:55 +00:00
|
|
|
WS_DLL_PUBLIC void register_conversation_filter(const char *proto_name, const char *display_name,
|
2023-01-26 22:26:04 +00:00
|
|
|
is_filter_valid_func is_filter_valid, build_filter_string_func build_filter_string, void *user_data);
|
2021-05-19 22:32:13 +00:00
|
|
|
|
2023-01-26 22:26:04 +00:00
|
|
|
/**
|
|
|
|
* Register a new log conversation filter.
|
|
|
|
*
|
|
|
|
* @param proto_name The protocol name.
|
|
|
|
* @param display_name A friendly name for the filter.
|
|
|
|
* @param is_filter_valid A callback function conforming to is_filter_valid_func.
|
|
|
|
* @param build_filter_string A callback function conforming to build_filter_string_func.
|
|
|
|
* @param user_data User-defined data which is passed to the callback functions. Can be NULL.
|
|
|
|
*/
|
2022-03-10 20:21:12 +00:00
|
|
|
WS_DLL_PUBLIC void register_log_conversation_filter(const char *proto_name, const char *display_name,
|
2023-01-26 22:26:04 +00:00
|
|
|
is_filter_valid_func is_filter_valid, build_filter_string_func build_filter_string, void *user_data);
|
2022-04-15 00:49:03 +00:00
|
|
|
/**
|
|
|
|
* Prepend a protocol to the list of filterable protocols.
|
2022-04-26 17:10:30 +00:00
|
|
|
* @param proto_name A valid protocol name.
|
2022-04-15 00:49:03 +00:00
|
|
|
*/
|
|
|
|
WS_DLL_PUBLIC void add_conversation_filter_protocol(const char *proto_name);
|
2014-12-09 02:40:24 +00:00
|
|
|
|
2022-04-15 00:49:03 +00:00
|
|
|
/** Cleanup internal structures */
|
2017-01-20 11:19:18 +00:00
|
|
|
extern void conversation_filters_cleanup(void);
|
|
|
|
|
2017-06-20 18:08:39 +00:00
|
|
|
/**
|
|
|
|
* Tries to build a suitable display filter for the conversation in the current
|
|
|
|
* packet. More specific matches are tried first (like TCP ports) followed by
|
|
|
|
* less specific ones (IP addresses). NULL is returned when no filter is found.
|
|
|
|
*
|
2022-04-07 21:32:20 +00:00
|
|
|
* @param pinfo Packet info
|
|
|
|
* @return A display filter for the conversation. Should be freed with g_free.
|
2017-06-20 18:08:39 +00:00
|
|
|
*/
|
|
|
|
WS_DLL_PUBLIC gchar *conversation_filter_from_packet(struct _packet_info *pinfo);
|
|
|
|
|
2022-04-07 21:32:20 +00:00
|
|
|
/**
|
|
|
|
* Tries to build a suitable display filter for the conversation in the current
|
|
|
|
* log entry. More specific matches are tried first (like TCP ports) followed by
|
|
|
|
* less specific ones (IP addresses). NULL is returned when no filter is found.
|
|
|
|
*
|
|
|
|
* @param pinfo Packet info
|
|
|
|
* @return A display filter for the conversation. Should be freed with g_free.
|
|
|
|
*/
|
|
|
|
WS_DLL_PUBLIC gchar *conversation_filter_from_log(struct _packet_info *pinfo);
|
|
|
|
|
2014-12-09 02:40:24 +00:00
|
|
|
/*** THE FOLLOWING SHOULD NOT BE USED BY ANY DISSECTORS!!! ***/
|
|
|
|
|
2015-10-29 03:30:55 +00:00
|
|
|
typedef struct conversation_filter_s {
|
|
|
|
const char * proto_name;
|
|
|
|
const char * display_name;
|
2015-10-29 04:21:36 +00:00
|
|
|
is_filter_valid_func is_filter_valid;
|
|
|
|
build_filter_string_func build_filter_string;
|
2023-01-26 22:26:04 +00:00
|
|
|
void * user_data;
|
2015-10-29 03:30:55 +00:00
|
|
|
} conversation_filter_t;
|
2014-12-09 02:40:24 +00:00
|
|
|
|
2022-04-07 21:32:20 +00:00
|
|
|
WS_DLL_PUBLIC GList *packet_conv_filter_list;
|
|
|
|
WS_DLL_PUBLIC GList *log_conv_filter_list;
|
2014-12-09 02:40:24 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2019-11-04 09:42:29 +00:00
|
|
|
#endif /* conversation_filter.h */
|