radiotap: Updates to the radiotap dissector to avoid confusion.
[metze/wireshark/wip.git] / epan / sequence_analysis.h
1 /* sequence-analysis.h
2  * Flow sequence analysis
3  *
4  * Copied from gtk/graph_analysis.h
5  *
6  * Copyright 2004, Verso Technologies Inc.
7  * By Alejandro Vaquero <alejandrovaquero@yahoo.com>
8  *
9  * based on rtp_analysis.c and io_stat
10  *
11  *
12  * Wireshark - Network traffic analyzer
13  * By Gerald Combs <gerald@wireshark.org>
14  * Copyright 1998 Gerald Combs
15  *
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.
20  *
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.
25  *
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.
29  */
30
31 #ifndef __EPAN_SEQUENCE_ANALYSIS_H__
32 #define __EPAN_SEQUENCE_ANALYSIS_H__
33
34 #include "ws_symbol_export.h"
35
36 #include <glib.h>
37
38 #include "packet_info.h"
39 #include "tap.h"
40 #include "address.h"
41 #include "wsutil/file_util.h"
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif /* __cplusplus */
46
47 #define MAX_NUM_NODES 40
48
49 /** defines an entry for the graph analysis */
50 typedef struct _seq_analysis_item {
51     guint32 frame_number;
52     address src_addr;
53     guint16 port_src;
54     address dst_addr;
55     guint16 port_dst;
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;
68
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;
79
80 /** Structure for information about a registered sequence analysis function */
81 typedef struct register_analysis register_analysis_t;
82
83 #if 0
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); \
88 }
89 #else
90 #define SEQ_ANALYSIS_DEBUG()
91 #endif
92
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);
94
95 /** Helper function to get sequence analysis name
96  *
97  * @param analysis Registered sequence analysis
98  * @return sequence analysis name string
99  */
100 WS_DLL_PUBLIC const char* sequence_analysis_get_name(register_analysis_t* analysis);
101
102 /** Helper function to get tap listener name
103  *
104  * @param analysis Registered sequence analysis
105  * @return sequence analysis tap listener string
106  */
107 WS_DLL_PUBLIC const char* sequence_analysis_get_tap_listener_name(register_analysis_t* analysis);
108
109 /** Helper function to get UI name
110  *
111  * @param analysis Registered sequence analysis
112  * @return sequence analysis UI string
113  */
114 WS_DLL_PUBLIC const char* sequence_analysis_get_ui_name(register_analysis_t* analysis);
115
116 /** Get tap function handler from sequence analysis
117  *
118  * @param analysis Registered sequence analysis
119  * @return tap function handler of sequence analysis
120  */
121 WS_DLL_PUBLIC tap_packet_cb sequence_analysis_get_packet_func(register_analysis_t* analysis);
122
123 /** Helper function to get tap flags
124  *
125  * @param analysis Registered sequence analysis
126  * @return sequence analysis tap flags
127  */
128 WS_DLL_PUBLIC guint sequence_analysis_get_tap_flags(register_analysis_t* analysis);
129
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
133  *
134  * @param pinfo packet info
135  * @param sainfo info determining address type
136  * @return sequence analysis tap flags
137  */
138 WS_DLL_PUBLIC seq_analysis_item_t* sequence_analysis_create_sai_with_addresses(packet_info *pinfo, seq_analysis_info_t *sainfo);
139
140 /** Helper function to set colors for analysis the same as Wireshark display
141  *
142  * @param pinfo packet info
143  * @param sai item to set color
144  */
145 WS_DLL_PUBLIC void sequence_analysis_use_color_filter(packet_info *pinfo, seq_analysis_item_t *sai);
146
147 /** Helper function to set frame label and comments to use protocol and info column data
148  *
149  * @param pinfo packet info
150  * @param sai item to set label and comments
151  */
152 WS_DLL_PUBLIC void sequence_analysis_use_col_info_as_label_comment(packet_info *pinfo, seq_analysis_item_t *sai);
153
154 /** Find a registered sequence analysis "protocol" by name
155  *
156  * @param name Registered sequence analysis to find
157  * @return registered sequence analysis, NULL if not found
158  */
159 WS_DLL_PUBLIC register_analysis_t* sequence_analysis_find_by_name(const char* name);
160
161 /** Interator to walk sequence_analysis tables and execute func
162  *
163  * @param func action to be performed on all sequence_analysis tables
164  * @param user_data any data needed to help perform function
165  */
166 WS_DLL_PUBLIC void sequence_analysis_table_iterate_tables(wmem_foreach_func func, gpointer user_data);
167
168 /** Create and initialize a seq_analysis_info_t struct
169  * @return A pointer to a newly allocated seq_analysis_info_t struct.
170  */
171 WS_DLL_PUBLIC seq_analysis_info_t *sequence_analysis_info_new(void);
172
173 /** Free a seq_analysis_info_t struct.
174  * @param sainfo A pointer to the seq_analysis_info_t struct to be freed.
175  */
176 WS_DLL_PUBLIC void sequence_analysis_info_free(seq_analysis_info_t * sainfo);
177
178 /** Sort a seq_analysis_info_t struct.
179  * @param sainfo A pointer to the seq_analysis_info_t struct to be sorted
180  */
181 WS_DLL_PUBLIC void sequence_analysis_list_sort(seq_analysis_info_t *sainfo);
182
183 /** Free the segment list
184  *
185  * @param sainfo Sequence analysis information.
186  */
187 WS_DLL_PUBLIC void sequence_analysis_list_free(seq_analysis_info_t *sainfo);
188
189 /** Fill in the node address list
190  *
191  * @param sainfo Sequence analysis information.
192  * @return The number of transaction items (not nodes) processed.
193  */
194 WS_DLL_PUBLIC int sequence_analysis_get_nodes(seq_analysis_info_t *sainfo);
195
196 /** Free the node address list
197  *
198  * @param sainfo Sequence analysis information.
199  */
200 WS_DLL_PUBLIC void sequence_analysis_free_nodes(seq_analysis_info_t *sainfo);
201
202
203 /** Write an ASCII version of the sequence diagram to a file.
204  *
205  * @param of File to write.
206  * @param sainfo Sequence analysis information.
207  * @param first_node Start drawing at this node.
208  */
209 WS_DLL_PUBLIC void sequence_analysis_dump_to_file(FILE *of, seq_analysis_info_t *sainfo, unsigned int first_node);
210
211 #ifdef __cplusplus
212 }
213 #endif /* __cplusplus */
214
215 #endif /* __EPAN_SEQUENCE_ANALYSIS_H__ */
216
217 /*
218  * Editor modelines
219  *
220  * Local Variables:
221  * c-basic-offset: 4
222  * tab-width: 8
223  * indent-tabs-mode: nil
224  * End:
225  *
226  * ex: set shiftwidth=4 tabstop=8 expandtab:
227  * :indentSize=4:tabSize=8:noTabs=true:
228  */