Kerberos: add kerberos_inject_longterm_key() helper function
[wireshark-sm.git] / ui / qt / models / atap_data_model.h
blob759c71fbd52c0c7dac31f389cf8951c02c8d5023
1 /** @file
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
10 #ifndef ATAP_DATA_MODEL_H
11 #define ATAP_DATA_MODEL_H
13 #include "config.h"
15 #include <epan/tap.h>
16 #include <epan/conversation.h>
17 #include <epan/conversation_table.h>
19 #include <QAbstractListModel>
21 /**
22 * @brief DataModel for tap user data
24 * This datamodel provides the management for all tap data for the conversation
25 * and endpoint dialogs. It predominantly is implemented to work with conversation
26 * tap data. The management of displaying and correctly presenting the information
27 * is done in the corresponding type classes
29 * @see EndpointDataModel
30 * @see ConversationDataModel
32 class ATapDataModel : public QAbstractListModel
34 Q_OBJECT
35 public:
37 enum {
38 DISPLAY_FILTER = Qt::UserRole,
39 UNFORMATTED_DISPLAYDATA,
40 #ifdef HAVE_MAXMINDDB
41 GEODATA_AVAILABLE,
42 GEODATA_LOOKUPTABLE,
43 GEODATA_ADDRESS,
44 #endif
45 TIMELINE_DATA,
46 ENDPOINT_DATATYPE,
47 PROTO_ID,
48 CONVERSATION_ID,
49 ROW_IS_FILTERED,
50 DATA_ADDRESS_TYPE,
51 DATA_IPV4_INTEGER,
52 DATA_IPV6_LIST,
55 typedef enum {
56 DATAMODEL_ENDPOINT,
57 DATAMODEL_CONVERSATION,
58 DATAMODEL_UNKNOWN
59 } dataModelType;
61 conv_hash_t hash_;
63 /**
64 * @brief Construct a new ATapDataModel object
66 * The tap will not be created automatically, but must be enabled by calling enableTap
68 * @param type an element of dataModelType. Either DATAMODEL_ENDPOINT or DATAMODEL_CONVERSATION are supported
69 * at this time
70 * @param protoId the protocol id for which the tap is created
71 * @param filter a potential filter to be used for the tap
72 * @param parent the parent for the class
74 * @see enableTap
76 explicit ATapDataModel(dataModelType type, int protoId, QString filter, QObject *parent = nullptr);
77 virtual ~ATapDataModel();
79 /**
80 * @brief Number of rows under the given parent in this model, which
81 * is the total number of rows for the empty QModelIndex, and 0 for
82 * any valid parent index (as no row has children; this is a flat table.)
84 * @param parent index of parent, QModelIndex() for the root
85 * @return int the number of rows under the parent
87 int rowCount(const QModelIndex &parent = QModelIndex()) const;
89 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const = 0;
90 virtual QVariant headerData(int section, Qt::Orientation orientation = Qt::Horizontal, int role = Qt::DisplayRole) const = 0;
91 virtual QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const = 0;
93 /**
94 * @brief Returns the name for the tap being used
96 * @return QString the tap name, normally identical with the protocol name
98 QString tap() const;
101 * @brief The protocol id for the tap
103 * @return int the id given in the constructor
105 int protoId() const;
108 * @brief Set the filter string.
110 * A set filter can be reset by providing an empty string
112 * @param filter the filter for the tap
114 void setFilter(QString filter);
117 * @brief Return a filter set for the model
119 * @return QString the filter string for the model
121 QString filter() const;
124 * @brief Is the model set to resolve names in address and ports columns
126 * @return true yes, names will be resolved
127 * @return false no they won't
129 bool resolveNames() const;
132 * @brief Enable or disable if names should be resolved
134 * @param resolve true if names should be resolved
136 void setResolveNames(bool resolve);
139 * @brief Does the model allow names to be resolved
141 * @return true yes, names may be resolved (set via setResolveNames)
142 * @return false no, they won't be resolved
144 * @see setResolveNames
145 * @see resolveNames
147 bool allowsNameResolution() const;
150 * @brief Use absolute time for any column supporting it
152 * @param absolute true to use absolute time values
154 void useAbsoluteTime(bool absolute);
157 * @brief Use nanosecond timestamps if requested
159 * @param nanoseconds use nanosecond timestamps if required and requested
161 void useNanosecondTimestamps(bool nanoseconds);
164 * @brief Are ports hidden for this model
166 * @return true the ports are hidden
167 * @return false the ports are not hidden
169 bool portsAreHidden() const;
172 * @brief A total column is filled
174 * @return true if the column is filled
175 * @return false the column is empty
177 bool showTotalColumn() const;
180 * @brief Enable tapping in this model.
182 * This will register the tap listener with the corresponding packet function.
183 * @note if the tap has not been disabled, this method will do nothing
185 * @return true the tap has been enabled
186 * @return false the tap has not been enabled
188 bool enableTap();
191 * @brief Disable the tapping for this model
193 void disableTap();
196 * @brief Return the model type
198 * @return dataModelType
200 dataModelType modelType() const;
202 conv_hash_t * hash();
205 * @brief Update the flags
207 void updateFlags(unsigned flag);
209 #ifdef HAVE_MAXMINDDB
211 * @brief Does this model have geoip data available
213 * @return true it has
214 * @return false it has not
216 bool hasGeoIPData();
217 #endif
219 signals:
220 void tapListenerChanged(bool enable);
222 protected:
224 static void tapReset(void *tapdata);
225 static void tapDraw(void *tap_data);
227 virtual tap_packet_cb conversationPacketHandler();
229 void resetData();
230 void updateData(GArray * data);
232 dataModelType _type;
233 GArray * storage_;
234 QString _filter;
236 bool _absoluteTime;
237 bool _nanoseconds;
238 bool _resolveNames;
239 bool _disableTap;
241 double _minRelStartTime;
242 double _maxRelStopTime;
244 unsigned _tapFlags;
246 register_ct_t* registerTable() const;
248 private:
249 int _protoId;
253 class EndpointDataModel : public ATapDataModel
255 Q_OBJECT
256 public:
258 typedef enum
260 ENDP_COLUMN_ADDR,
261 ENDP_COLUMN_PORT,
262 ENDP_COLUMN_PACKETS,
263 ENDP_COLUMN_BYTES,
264 ENDP_COLUMN_PACKETS_TOTAL,
265 ENDP_COLUMN_BYTES_TOTAL,
266 ENDP_COLUMN_PKT_AB,
267 ENDP_COLUMN_BYTES_AB,
268 ENDP_COLUMN_PKT_BA,
269 ENDP_COLUMN_BYTES_BA,
270 ENDP_NUM_COLUMNS,
271 ENDP_COLUMN_GEO_COUNTRY = ENDP_NUM_COLUMNS,
272 ENDP_COLUMN_GEO_CITY,
273 ENDP_COLUMN_GEO_LATITUDE,
274 ENDP_COLUMN_GEO_LONGITUDE,
275 ENDP_COLUMN_GEO_AS_NUM,
276 ENDP_COLUMN_GEO_AS_ORG,
277 ENDP_NUM_GEO_COLUMNS
278 } endpoint_column_type_e;
280 explicit EndpointDataModel(int protoId, QString filter, QObject *parent = nullptr);
282 int columnCount(const QModelIndex &parent = QModelIndex()) const;
283 QVariant headerData(int section, Qt::Orientation orientation = Qt::Horizontal, int role = Qt::DisplayRole) const;
284 QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const;
288 class ConversationDataModel : public ATapDataModel
290 Q_OBJECT
291 public:
293 typedef enum {
294 CONV_COLUMN_SRC_ADDR,
295 CONV_COLUMN_SRC_PORT,
296 CONV_COLUMN_DST_ADDR,
297 CONV_COLUMN_DST_PORT,
298 CONV_COLUMN_PACKETS,
299 CONV_COLUMN_BYTES,
300 CONV_COLUMN_CONV_ID,
301 CONV_COLUMN_PACKETS_TOTAL,
302 CONV_COLUMN_BYTES_TOTAL,
303 CONV_COLUMN_PKT_AB,
304 CONV_COLUMN_BYTES_AB,
305 CONV_COLUMN_PKT_BA,
306 CONV_COLUMN_BYTES_BA,
307 CONV_COLUMN_START,
308 CONV_COLUMN_DURATION,
309 CONV_COLUMN_BPS_AB,
310 CONV_COLUMN_BPS_BA,
311 CONV_NUM_COLUMNS,
312 CONV_INDEX_COLUMN = CONV_NUM_COLUMNS
313 } conversation_column_type_e;
315 typedef enum {
316 CONV_TCP_EXT_COLUMN_A = CONV_INDEX_COLUMN,
317 CONV_TCP_EXT_NUM_COLUMNS,
318 CONV_TCP_EXT_INDEX_COLUMN = CONV_TCP_EXT_NUM_COLUMNS
319 } conversation_tcp_ext_column_type_e;
321 explicit ConversationDataModel(int protoId, QString filter, QObject *parent = nullptr);
323 int columnCount(const QModelIndex &parent = QModelIndex()) const;
324 QVariant headerData(int section, Qt::Orientation orientation = Qt::Horizontal, int role = Qt::DisplayRole) const;
325 QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const;
327 void doDataUpdate();
329 conv_item_t * itemForRow(int row);
332 * @brief Show the conversation id if available
334 * @return true a conversation id exists
335 * @return false none available
337 bool showConversationId(int row = 0) const;
341 #endif // ATAP_DATA_MODEL_H