2 * Flow sequence analysis
4 * Copied from gtk/graph_analysis.h
6 * Copyright 2004, Verso Technologies Inc.
7 * By Alejandro Vaquero <alejandrovaquero@yahoo.com>
9 * based on rtp_analysis.c and io_stat
12 * Wireshark - Network traffic analyzer
13 * By Gerald Combs <gerald@wireshark.org>
14 * Copyright 1998 Gerald Combs
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 #ifndef __EPAN_SEQUENCE_ANALYSIS_H__
32 #define __EPAN_SEQUENCE_ANALYSIS_H__
34 #include "ws_symbol_export.h"
38 #include "packet_info.h"
41 #include "wsutil/file_util.h"
45 #endif /* __cplusplus */
47 #define MAX_NUM_NODES 40
49 /** defines an entry for the graph analysis */
50 typedef struct _seq_analysis_item {
56 gchar *frame_label; /**< the label on top of the arrow */
57 gchar *time_str; /**< timestamp */
58 gchar *comment; /**< a comment that appears at the right of the graph */
59 guint16 conv_num; /**< The conversation number. Used for coloring VoIP calls. */
60 unsigned fg_color; /**< Foreground color, 0xRRGGBB. Qt only. */
61 unsigned bg_color; /**< Background color, 0xRRGGBB. Qt only. */
62 gboolean has_color_filter; /**< Set if packet has color filter. Qt only. */
63 gboolean display; /**< indicate if the packet is displayed or not in the graph */
64 guint src_node; /**< this is used by graph_analysis.c to identify the node */
65 guint dst_node; /**< a node is an IP address that will be displayed in columns */
66 guint16 line_style; /**< the arrow line width in pixels*/
67 } seq_analysis_item_t;
69 /** defines the graph analysis structure */
70 typedef struct _seq_analysis_info {
71 const char* name; /**< Name of sequence analysis */
72 gboolean any_addr; /**< any addr (DL+net) vs net-only */
73 int nconv; /**< number of conversations in the list */
74 GQueue* items; /**< list of seq_analysis_info_t */
75 GHashTable *ht; /**< hash table of seq_analysis_info_t */
76 address nodes[MAX_NUM_NODES]; /**< horizontal node list */
77 guint32 num_nodes; /**< actual number of nodes */
78 } seq_analysis_info_t;
80 /** Structure for information about a registered sequence analysis function */
81 typedef struct register_analysis register_analysis_t;
84 #define SEQ_ANALYSIS_DEBUG(...) { \
85 char *SEQ_ANALYSIS_DEBUG_MSG = g_strdup_printf(__VA_ARGS__); \
86 g_warning("sequence analysis: %s:%d %s", G_STRFUNC, __LINE__, SEQ_ANALYSIS_DEBUG_MSG); \
87 g_free(SEQ_ANALYSIS_DEBUG_MSG); \
90 #define SEQ_ANALYSIS_DEBUG()
93 WS_DLL_PUBLIC void register_seq_analysis(const char* name, const char* ui_name, const int proto_id, const char* tap_listener, guint tap_flags, tap_packet_cb tap_func);
95 /** Helper function to get sequence analysis name
97 * @param analysis Registered sequence analysis
98 * @return sequence analysis name string
100 WS_DLL_PUBLIC const char* sequence_analysis_get_name(register_analysis_t* analysis);
102 /** Helper function to get tap listener name
104 * @param analysis Registered sequence analysis
105 * @return sequence analysis tap listener string
107 WS_DLL_PUBLIC const char* sequence_analysis_get_tap_listener_name(register_analysis_t* analysis);
109 /** Helper function to get UI name
111 * @param analysis Registered sequence analysis
112 * @return sequence analysis UI string
114 WS_DLL_PUBLIC const char* sequence_analysis_get_ui_name(register_analysis_t* analysis);
116 /** Get tap function handler from sequence analysis
118 * @param analysis Registered sequence analysis
119 * @return tap function handler of sequence analysis
121 WS_DLL_PUBLIC tap_packet_cb sequence_analysis_get_packet_func(register_analysis_t* analysis);
123 /** Helper function to get tap flags
125 * @param analysis Registered sequence analysis
126 * @return sequence analysis tap flags
128 WS_DLL_PUBLIC guint sequence_analysis_get_tap_flags(register_analysis_t* analysis);
130 /** Helper function to create a sequence analysis item with address fields populated
131 * Allocate a seq_analysis_item_t to return and populate the time_str and src_addr and dst_addr
132 * members based on seq_analysis_info_t any_addr member
134 * @param pinfo packet info
135 * @param sainfo info determining address type
136 * @return sequence analysis tap flags
138 WS_DLL_PUBLIC seq_analysis_item_t* sequence_analysis_create_sai_with_addresses(packet_info *pinfo, seq_analysis_info_t *sainfo);
140 /** Helper function to set colors for analysis the same as Wireshark display
142 * @param pinfo packet info
143 * @param sai item to set color
145 WS_DLL_PUBLIC void sequence_analysis_use_color_filter(packet_info *pinfo, seq_analysis_item_t *sai);
147 /** Helper function to set frame label and comments to use protocol and info column data
149 * @param pinfo packet info
150 * @param sai item to set label and comments
152 WS_DLL_PUBLIC void sequence_analysis_use_col_info_as_label_comment(packet_info *pinfo, seq_analysis_item_t *sai);
154 /** Find a registered sequence analysis "protocol" by name
156 * @param name Registered sequence analysis to find
157 * @return registered sequence analysis, NULL if not found
159 WS_DLL_PUBLIC register_analysis_t* sequence_analysis_find_by_name(const char* name);
161 /** Interator to walk sequence_analysis tables and execute func
163 * @param func action to be performed on all sequence_analysis tables
164 * @param user_data any data needed to help perform function
166 WS_DLL_PUBLIC void sequence_analysis_table_iterate_tables(wmem_foreach_func func, gpointer user_data);
168 /** Create and initialize a seq_analysis_info_t struct
169 * @return A pointer to a newly allocated seq_analysis_info_t struct.
171 WS_DLL_PUBLIC seq_analysis_info_t *sequence_analysis_info_new(void);
173 /** Free a seq_analysis_info_t struct.
174 * @param sainfo A pointer to the seq_analysis_info_t struct to be freed.
176 WS_DLL_PUBLIC void sequence_analysis_info_free(seq_analysis_info_t * sainfo);
178 /** Sort a seq_analysis_info_t struct.
179 * @param sainfo A pointer to the seq_analysis_info_t struct to be sorted
181 WS_DLL_PUBLIC void sequence_analysis_list_sort(seq_analysis_info_t *sainfo);
183 /** Free the segment list
185 * @param sainfo Sequence analysis information.
187 WS_DLL_PUBLIC void sequence_analysis_list_free(seq_analysis_info_t *sainfo);
189 /** Fill in the node address list
191 * @param sainfo Sequence analysis information.
192 * @return The number of transaction items (not nodes) processed.
194 WS_DLL_PUBLIC int sequence_analysis_get_nodes(seq_analysis_info_t *sainfo);
196 /** Free the node address list
198 * @param sainfo Sequence analysis information.
200 WS_DLL_PUBLIC void sequence_analysis_free_nodes(seq_analysis_info_t *sainfo);
203 /** Write an ASCII version of the sequence diagram to a file.
205 * @param of File to write.
206 * @param sainfo Sequence analysis information.
207 * @param first_node Start drawing at this node.
209 WS_DLL_PUBLIC void sequence_analysis_dump_to_file(FILE *of, seq_analysis_info_t *sainfo, unsigned int first_node);
213 #endif /* __cplusplus */
215 #endif /* __EPAN_SEQUENCE_ANALYSIS_H__ */
223 * indent-tabs-mode: nil
226 * ex: set shiftwidth=4 tabstop=8 expandtab:
227 * :indentSize=4:tabSize=8:noTabs=true: