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 * SPDX-License-Identifier: GPL-2.0-or-later
19 #ifndef __EPAN_SEQUENCE_ANALYSIS_H__
20 #define __EPAN_SEQUENCE_ANALYSIS_H__
22 #include "ws_symbol_export.h"
26 #include "packet_info.h"
29 #include "wsutil/file_util.h"
33 #endif /* __cplusplus */
35 #define MAX_NUM_NODES 40
37 /** defines info types for graph analysis additional information */
38 typedef enum _ga_info_type
{
43 /** defines an entry for the graph analysis */
44 typedef struct _seq_analysis_item
{
45 uint32_t frame_number
;
50 char *frame_label
; /**< the label on top of the arrow */
51 char *time_str
; /**< timestamp */
52 char *comment
; /**< a comment that appears at the right of the graph */
53 uint16_t conv_num
; /**< The conversation number. Used for coloring VoIP calls. */
54 unsigned fg_color
; /**< Foreground color, 0xRRGGBB. Qt only. */
55 unsigned bg_color
; /**< Background color, 0xRRGGBB. Qt only. */
56 bool has_color_filter
; /**< Set if packet has color filter. Qt only. */
57 bool display
; /**< indicate if the packet is displayed or not in the graph */
58 unsigned src_node
; /**< this is used by graph_analysis.c to identify the node */
59 unsigned dst_node
; /**< a node is an IP address that will be displayed in columns */
60 uint16_t line_style
; /**< the arrow line width in pixels*/
61 ga_info_type info_type
; /**< type of info for item */
62 void *info_ptr
; /**< ptr to info for item */
63 } seq_analysis_item_t
;
65 /** defines the graph analysis structure */
66 typedef struct _seq_analysis_info
{
67 const char* name
; /**< Name of sequence analysis */
68 bool any_addr
; /**< any addr (DL+net) vs net-only */
69 int nconv
; /**< number of conversations in the list */
70 GQueue
* items
; /**< list of seq_analysis_info_t */
71 GHashTable
*ht
; /**< hash table of seq_analysis_info_t */
72 address nodes
[MAX_NUM_NODES
]; /**< horizontal node list */
73 uint8_t occurrence
[MAX_NUM_NODES
]; /**< horizontal occurrence list 0|1 */
74 uint32_t num_nodes
; /**< actual number of nodes */
75 } seq_analysis_info_t
;
77 /** Structure for information about a registered sequence analysis function */
78 typedef struct register_analysis register_analysis_t
;
80 WS_DLL_PUBLIC
void register_seq_analysis(const char* name
, const char* ui_name
, const int proto_id
, const char* tap_listener
, unsigned tap_flags
, tap_packet_cb tap_func
);
82 /** Helper function to get sequence analysis name
84 * @param analysis Registered sequence analysis
85 * @return sequence analysis name string
87 WS_DLL_PUBLIC
const char* sequence_analysis_get_name(register_analysis_t
* analysis
);
89 /** Helper function to get tap listener name
91 * @param analysis Registered sequence analysis
92 * @return sequence analysis tap listener string
94 WS_DLL_PUBLIC
const char* sequence_analysis_get_tap_listener_name(register_analysis_t
* analysis
);
96 /** Helper function to get UI name
98 * @param analysis Registered sequence analysis
99 * @return sequence analysis UI string
101 WS_DLL_PUBLIC
const char* sequence_analysis_get_ui_name(register_analysis_t
* analysis
);
103 /** Get tap function handler from sequence analysis
105 * @param analysis Registered sequence analysis
106 * @return tap function handler of sequence analysis
108 WS_DLL_PUBLIC tap_packet_cb
sequence_analysis_get_packet_func(register_analysis_t
* analysis
);
110 /** Helper function to get tap flags
112 * @param analysis Registered sequence analysis
113 * @return sequence analysis tap flags
115 WS_DLL_PUBLIC
unsigned sequence_analysis_get_tap_flags(register_analysis_t
* analysis
);
117 /** Helper function to create a sequence analysis item with address fields populated
118 * Allocate a seq_analysis_item_t to return and populate the time_str and src_addr and dst_addr
119 * members based on seq_analysis_info_t any_addr member
121 * @param pinfo packet info
122 * @param sainfo info determining address type
123 * @return sequence analysis tap flags
125 WS_DLL_PUBLIC seq_analysis_item_t
* sequence_analysis_create_sai_with_addresses(packet_info
*pinfo
, seq_analysis_info_t
*sainfo
);
127 /** Helper function to set colors for analysis the same as Wireshark display
129 * @param pinfo packet info
130 * @param sai item to set color
132 WS_DLL_PUBLIC
void sequence_analysis_use_color_filter(packet_info
*pinfo
, seq_analysis_item_t
*sai
);
134 /** Helper function to set frame label and comments to use protocol and info column data
136 * @param pinfo packet info
137 * @param sai item to set label and comments
139 WS_DLL_PUBLIC
void sequence_analysis_use_col_info_as_label_comment(packet_info
*pinfo
, seq_analysis_item_t
*sai
);
141 /** Find a registered sequence analysis "protocol" by name
143 * @param name Registered sequence analysis to find
144 * @return registered sequence analysis, NULL if not found
146 WS_DLL_PUBLIC register_analysis_t
* sequence_analysis_find_by_name(const char* name
);
148 /** Interator to walk sequence_analysis tables and execute func
150 * @param func action to be performed on all sequence_analysis tables
151 * @param user_data any data needed to help perform function
153 WS_DLL_PUBLIC
void sequence_analysis_table_iterate_tables(wmem_foreach_func func
, void *user_data
);
155 /** Create and initialize a seq_analysis_info_t struct
156 * @return A pointer to a newly allocated seq_analysis_info_t struct.
158 WS_DLL_PUBLIC seq_analysis_info_t
*sequence_analysis_info_new(void);
160 /** Free a seq_analysis_info_t struct.
161 * @param sainfo A pointer to the seq_analysis_info_t struct to be freed.
163 WS_DLL_PUBLIC
void sequence_analysis_info_free(seq_analysis_info_t
* sainfo
);
165 /** Sort a seq_analysis_info_t struct.
166 * @param sainfo A pointer to the seq_analysis_info_t struct to be sorted
168 WS_DLL_PUBLIC
void sequence_analysis_list_sort(seq_analysis_info_t
*sainfo
);
170 /** Free the segment list
172 * @param sainfo Sequence analysis information.
174 WS_DLL_PUBLIC
void sequence_analysis_list_free(seq_analysis_info_t
*sainfo
);
176 /** Fill in the node address list
178 * @param sainfo Sequence analysis information.
179 * @return The number of transaction items (not nodes) processed.
181 WS_DLL_PUBLIC
int sequence_analysis_get_nodes(seq_analysis_info_t
*sainfo
);
183 /** Free the node address list
185 * @param sainfo Sequence analysis information.
187 WS_DLL_PUBLIC
void sequence_analysis_free_nodes(seq_analysis_info_t
*sainfo
);
190 /** Write an ASCII version of the sequence diagram to a file.
192 * @param of File to write.
193 * @param sainfo Sequence analysis information.
194 * @param first_node Start drawing at this node.
196 WS_DLL_PUBLIC
void sequence_analysis_dump_to_file(FILE *of
, seq_analysis_info_t
*sainfo
, unsigned first_node
);
200 #endif /* __cplusplus */
202 #endif /* __EPAN_SEQUENCE_ANALYSIS_H__ */
210 * indent-tabs-mode: nil
213 * ex: set shiftwidth=4 tabstop=8 expandtab:
214 * :indentSize=4:tabSize=8:noTabs=true: