Ensure to have a valid string pointer when writing OS SHB option
[metze/wireshark/wip.git] / ui / tap-sequence-analysis.h
1 /* tap-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 __TAP_SEQUENCE_ANALYSIS_H__
32 #define __TAP_SEQUENCE_ANALYSIS_H__
33
34 #include <glib.h>
35
36 #include "cfile.h"
37 #include "epan/address.h"
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif /* __cplusplus */
42
43 #define MAX_NUM_NODES 40
44
45 typedef enum seq_analysis_type_ {
46     SEQ_ANALYSIS_ANY,
47     SEQ_ANALYSIS_TCP,
48     SEQ_ANALYSIS_VOIP
49 } seq_analysis_type;
50
51 /** defines an entry for the graph analysis */
52 typedef struct _seq_analysis_item {
53     guint32 frame_number;
54     address src_addr;
55     guint16 port_src;
56     address dst_addr;
57     guint16 port_dst;
58     gchar *frame_label;                 /**< the label on top of the arrow */
59     gchar *time_str;                    /**< timestamp */
60     gchar *comment;                     /**< a comment that appears at the right of the graph */
61     guint16 conv_num;                   /**< The conversation number. Used for coloring VoIP calls. */
62     unsigned fg_color;                  /**< Foreground color, 0xRRGGBB. Qt only. */
63     unsigned bg_color;                  /**< Background color, 0xRRGGBB. Qt only. */
64     gboolean display;                   /**< indicate if the packet is displayed or not in the graph */
65     guint src_node;                     /**< this is used by graph_analysis.c to identify the node */
66     guint dst_node;                     /**< a node is an IP address that will be displayed in columns */
67     guint16 line_style;                 /**< the arrow line width in pixels*/
68     gchar *protocol;                    /**< the label of the protocol defined in the IP packet */
69 } seq_analysis_item_t;
70
71 /** defines the graph analysis structure */
72 typedef struct _seq_analysis_info {
73     seq_analysis_type type;  /**< sequence type */
74     gboolean    all_packets; /**< all packets vs only displayed */
75     gboolean    any_addr;    /**< any addr (DL+net) vs net-only */
76     int         nconv;       /**< number of conversations in the list */
77     GQueue*     items;       /**< list of seq_analysis_info_t */
78     GHashTable *ht;          /**< hash table of seq_analysis_info_t */
79     address nodes[MAX_NUM_NODES]; /**< horizontal node list */
80     guint32 num_nodes;       /**< actual number of nodes */
81 } seq_analysis_info_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 /** Create and initialize a seq_analysis_info_t struct
94  * @return A pointer to a newly allocated seq_analysis_info_t struct.
95  */
96 seq_analysis_info_t *sequence_analysis_info_new(void);
97
98 /** Free a seq_analysis_info_t struct.
99  * @param sainfo A pointer to the seq_analysis_info_t struct to be freed.
100  */
101 void sequence_analysis_info_free(seq_analysis_info_t * sainfo);
102
103 /** Fill in the segment list for sequence analysis
104  *
105  * @param cf Capture file to scan
106  * @param sainfo Sequence analysis information. A valid type must be set.
107  */
108 void sequence_analysis_list_get(capture_file *cf, seq_analysis_info_t *sainfo);
109
110 void sequence_analysis_list_sort(seq_analysis_info_t *sainfo);
111
112 /** Free the segment list
113  *
114  * @param sainfo Sequence analysis information.
115  */
116 void sequence_analysis_list_free(seq_analysis_info_t *sainfo);
117
118 /** Fill in the node address list
119  *
120  * @param sainfo Sequence analysis information.
121  * @return The number of transaction items (not nodes) processed.
122  */
123 int sequence_analysis_get_nodes(seq_analysis_info_t *sainfo);
124
125 /** Write an ASCII version of the sequence diagram to a file.
126  *
127  * @param pathname Pathname of the file to write.
128  * @param sainfo Sequence analysis information.
129  * @param cf Capture file associated with the diagram.
130  * @param first_node Start drawing at this node.
131  * @return TRUE on success, FALSE on failure.
132  */
133 gboolean sequence_analysis_dump_to_file(const char *pathname, seq_analysis_info_t *sainfo, capture_file *cf, unsigned int first_node);
134
135 #ifdef __cplusplus
136 }
137 #endif /* __cplusplus */
138
139 #endif /* __TAP_SEQUENCE_ANALYSIS_H__ */
140
141 /*
142  * Editor modelines
143  *
144  * Local Variables:
145  * c-basic-offset: 4
146  * tab-width: 8
147  * indent-tabs-mode: nil
148  * End:
149  *
150  * ex: set shiftwidth=4 tabstop=8 expandtab:
151  * :indentSize=4:tabSize=8:noTabs=true:
152  */