3 * Copyright 1998 Mike Hall <mlh@io.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #endif /* __cplusplus */
32 #include <epan/epan.h>
33 #include <epan/packet.h>
34 #include <epan/ipv6.h>
35 #include "ws_symbol_export.h"
50 /* Type of follow we are doing */
77 typedef union _stream_addr {
79 struct e_in6_addr ipv6;
84 typedef gboolean (*follow_print_line_func)(char *, size_t, gboolean, void *);
85 typedef frs_return_t (*follow_read_stream_func)(struct _follow_info *follow_info, follow_print_line_func follow_print, void *arg);
93 typedef struct _follow_info {
94 show_stream_t show_stream;
95 char *filter_out_filter;
97 guint bytes_written[2]; /* Index with FROM_CLIENT or FROM_SERVER for readability. */
105 struct register_follow;
106 typedef struct register_follow register_follow_t;
108 typedef gchar* (*follow_conv_filter_func)(packet_info* pinfo, int* stream);
109 typedef gchar* (*follow_index_filter_func)(int stream);
110 typedef gchar* (*follow_address_filter_func)(address* src_addr, address* dst_addr, int src_port, int dst_port);
111 typedef gchar* (*follow_port_to_display_func)(wmem_allocator_t *allocator, guint port);
112 typedef gboolean (*follow_tap_func)(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, const void *data);
115 void register_follow_stream(const int proto_id, const char* tap_listener,
116 follow_conv_filter_func conv_filter, follow_index_filter_func index_filter, follow_address_filter_func address_filter,
117 follow_port_to_display_func port_to_display, follow_tap_func tap_handler);
119 /** Get protocol ID from registered follower
121 * @param follower Registered follower
122 * @return protocol id of follower
124 WS_DLL_PUBLIC int get_follow_proto_id(register_follow_t* follower);
126 /** Get tap name string from registered follower (used for register_tap_listener)
128 * @param follower Registered follower
129 * @return tap name string of follower
131 WS_DLL_PUBLIC const char* get_follow_tap_string(register_follow_t* follower);
133 /** Get a registered follower by protocol short name
135 * @param proto_short_name Protocol short name
136 * @return tap registered follower if match, otherwise NULL
138 WS_DLL_PUBLIC register_follow_t* get_follow_by_name(const char* proto_short_name);
140 /** Provide function that builds a follow filter based on the current packet's conversation.
142 * @param follower [in] Registered follower
143 * @return A filter function handler
145 WS_DLL_PUBLIC follow_conv_filter_func get_follow_conv_func(register_follow_t* follower);
147 /** Provide function that builds a follow filter based on stream.
149 * @param follower [in] Registered follower
150 * @return A filter function handler
152 WS_DLL_PUBLIC follow_index_filter_func get_follow_index_func(register_follow_t* follower);
154 /** Provide function that builds a follow filter based on address/port pairs.
156 * @param follower [in] Registered follower
157 * @return A filter function handler
159 WS_DLL_PUBLIC follow_address_filter_func get_follow_address_func(register_follow_t* follower);
161 /** Provide function that resolves port number to name based on follower.
163 * @param follower [in] Registered follower
164 * @return A port resolver function handler
166 WS_DLL_PUBLIC follow_port_to_display_func get_follow_port_to_display(register_follow_t* follower);
168 /** Provide function that handles tap data (tap_packet_cb parameter of register_tap_listener)
170 * @param follower [in] Registered follower
171 * @return A tap data handler
173 WS_DLL_PUBLIC follow_tap_func get_follow_tap_handler(register_follow_t* follower);
176 /** Tap function handler when dissector's tap provides follow data as a tvb.
177 * Used by TCP, UDP and HTTP followers
179 WS_DLL_PUBLIC gboolean
180 follow_tvb_tap_listener(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const void *data);
182 /** Interator to walk all registered followers and execute func
184 * @param func action to be performed on all converation tables
185 * @param user_data any data needed to help perform function
187 WS_DLL_PUBLIC void follow_iterate_followers(GFunc func, gpointer user_data);
189 /** Generate -z stat (tap) name for a follower
190 * Currently used only by TShark
192 * @param follower [in] Registered follower
193 * @return A tap data handler
195 WS_DLL_PUBLIC gchar* follow_get_stat_tap_string(register_follow_t* follower);
197 /** Clear counters, addresses and ports of follow_info_t
199 * @param info [in] follower info
201 WS_DLL_PUBLIC void follow_reset_stream(follow_info_t* info);
205 #endif /* __cplusplus */