| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
atap_data_model.h
Go to the documentation of this file.
1
10#ifndef ATAP_DATA_MODEL_H
11#define ATAP_DATA_MODEL_H
12
13#include "config.h"
14
15#include <epan/tap.h>
16#include <epan/conversation.h>
17#include <epan/conversation_table.h>
18
19#include <QAbstractListModel>
20
32 class ATapDataModel : public QAbstractListModel
33{
34 Q_OBJECT
35public:
36
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,
53 };
54
55 typedef enum {
56 DATAMODEL_ENDPOINT,
57 DATAMODEL_CONVERSATION,
58 DATAMODEL_UNKNOWN
59 } dataModelType;
60
61 conv_hash_t hash_;
62
76 explicit ATapDataModel(dataModelType type, int protoId, QString filter, QObject *parent = nullptr);
77 virtual ~ATapDataModel();
78
87 int rowCount(const QModelIndex &parent = QModelIndex()) const;
88
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;
92
98 QString tap() const;
99
105 int protoId() const;
106
114 void setFilter(QString filter);
115
121 QString filter() const;
122
129 bool resolveNames() const;
130
136 virtual void setResolveNames(bool resolve) = 0;
137
147 bool allowsNameResolution() const;
148
154 virtual void useAbsoluteTime(bool absolute) = 0;
155
163 virtual void useNanosecondTimestamps(bool nanoseconds) = 0;
164
165 void setMachineReadable(bool machineReadable);
166
167 void limitToDisplayFilter(bool limit);
168
175 bool portsAreHidden() const;
176
183 bool showTotalColumn() const;
184
194 bool enableTap();
195
199 void disableTap();
200
206 dataModelType modelType() const;
207
208 conv_hash_t * hash();
209
213 void updateFlags(unsigned flag);
214
215#ifdef HAVE_MAXMINDDB
222 bool hasGeoIPData();
223#endif
224
225signals:
226 void tapListenerChanged(bool enable);
227
228protected:
229
230 static void tapReset(void *tapdata);
231 static void tapDraw(void *tap_data);
232
233 virtual tap_packet_cb conversationPacketHandler();
234
235 void resetData();
236 void updateData(GArray * data);
237
238 dataModelType _type;
239 GArray * storage_;
240 QString _filter;
241
242 bool _absoluteTime;
243 // XXX - There are other possible time precisions besides
244 // microseconds and nanoseconds; e.g., Netmon 2.3 uses
245 // 100 ns, and pcapng can have one of many values.
246 bool _nanoseconds;
247 bool _resolveNames;
248 bool _machineReadable;
249 bool _disableTap;
250
251 double _minRelStartTime;
252 double _maxRelStopTime;
253
254 unsigned _tapFlags;
255
256 register_ct_t* registerTable() const;
257
258private:
259 int _protoId;
260
261};
262
263 class EndpointDataModel : public ATapDataModel
264{
265 Q_OBJECT
266public:
267
268 typedef enum
269 {
270 ENDP_COLUMN_ADDR,
271 ENDP_COLUMN_PORT,
272 ENDP_COLUMN_PACKETS,
273 ENDP_COLUMN_BYTES,
274 ENDP_COLUMN_PACKETS_TOTAL,
275 ENDP_COLUMN_BYTES_TOTAL,
276 ENDP_COLUMN_PKT_AB,
277 ENDP_COLUMN_BYTES_AB,
278 ENDP_COLUMN_PKT_BA,
279 ENDP_COLUMN_BYTES_BA,
280 ENDP_NUM_COLUMNS,
281 ENDP_COLUMN_GEO_COUNTRY = ENDP_NUM_COLUMNS,
282 ENDP_COLUMN_GEO_CITY,
283 ENDP_COLUMN_GEO_LATITUDE,
284 ENDP_COLUMN_GEO_LONGITUDE,
285 ENDP_COLUMN_GEO_AS_NUM,
286 ENDP_COLUMN_GEO_AS_ORG,
287 ENDP_NUM_GEO_COLUMNS
288 } endpoint_column_type_e;
289
290 explicit EndpointDataModel(int protoId, QString filter, QObject *parent = nullptr);
291
292 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
293 QVariant headerData(int section, Qt::Orientation orientation = Qt::Horizontal, int role = Qt::DisplayRole) const override;
294 QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override;
295
296 void setResolveNames(bool resolve) override;
297 void useAbsoluteTime(bool absolute) override;
298 void useNanosecondTimestamps(bool nanoseconds) override;
299};
300
301 class ConversationDataModel : public ATapDataModel
302{
303 Q_OBJECT
304public:
305
306 typedef enum {
307 CONV_COLUMN_SRC_ADDR,
308 CONV_COLUMN_SRC_PORT,
309 CONV_COLUMN_DST_ADDR,
310 CONV_COLUMN_DST_PORT,
311 CONV_COLUMN_PACKETS,
312 CONV_COLUMN_BYTES,
313 CONV_COLUMN_CONV_ID,
314 CONV_COLUMN_PACKETS_TOTAL,
315 CONV_COLUMN_BYTES_TOTAL,
316 CONV_COLUMN_PKT_AB,
317 CONV_COLUMN_BYTES_AB,
318 CONV_COLUMN_PKT_BA,
319 CONV_COLUMN_BYTES_BA,
320 CONV_COLUMN_START,
321 CONV_COLUMN_DURATION,
322 CONV_COLUMN_BPS_AB,
323 CONV_COLUMN_BPS_BA,
324 CONV_NUM_COLUMNS,
325 CONV_INDEX_COLUMN = CONV_NUM_COLUMNS
326 } conversation_column_type_e;
327
328 typedef enum {
329 CONV_TCP_EXT_COLUMN_A = CONV_INDEX_COLUMN,
330 CONV_TCP_EXT_NUM_COLUMNS,
331 CONV_TCP_EXT_INDEX_COLUMN = CONV_TCP_EXT_NUM_COLUMNS
332 } conversation_tcp_ext_column_type_e;
333
334 explicit ConversationDataModel(int protoId, QString filter, QObject *parent = nullptr);
335
336 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
337 QVariant headerData(int section, Qt::Orientation orientation = Qt::Horizontal, int role = Qt::DisplayRole) const override;
338 QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override;
339
340 void doDataUpdate();
341
342 conv_item_t * itemForRow(int row);
343
350 bool showConversationId(int row = 0) const;
351
352 void setResolveNames(bool resolve) override;
353 void useAbsoluteTime(bool absolute) override;
354 void useNanosecondTimestamps(bool nanoseconds) override;
355};
356
357#endif // ATAP_DATA_MODEL_H
ATapDataModel
DataModel for tap user data.
Definition atap_data_model.h:33
ATapDataModel::setResolveNames
virtual void setResolveNames(bool resolve)=0
Enable or disable if names should be resolved.
ATapDataModel::showTotalColumn
bool showTotalColumn() const
A total column is filled.
Definition atap_data_model.cpp:328
ATapDataModel::resolveNames
bool resolveNames() const
Is the model set to resolve names in address and ports columns.
Definition atap_data_model.cpp:265
ATapDataModel::enableTap
bool enableTap()
Enable tapping in this model.
Definition atap_data_model.cpp:109
ATapDataModel::tap
QString tap() const
Returns the name for the tap being used.
Definition atap_data_model.cpp:82
ATapDataModel::allowsNameResolution
bool allowsNameResolution() const
Does the model allow names to be resolved.
Definition atap_data_model.cpp:270
ATapDataModel::useAbsoluteTime
virtual void useAbsoluteTime(bool absolute)=0
Use absolute time for any column supporting it.
ATapDataModel::modelType
dataModelType modelType() const
Return the model type.
Definition atap_data_model.cpp:318
ATapDataModel::setFilter
void setFilter(QString filter)
Set the filter string.
Definition atap_data_model.cpp:296
ATapDataModel::disableTap
void disableTap()
Disable the tapping for this model.
Definition atap_data_model.cpp:136
ATapDataModel::updateFlags
void updateFlags(unsigned flag)
Update the flags.
Definition atap_data_model.cpp:145
ATapDataModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const
Number of rows under the given parent in this model, which is the total number of rows for the empty ...
Definition atap_data_model.cpp:182
ATapDataModel::portsAreHidden
bool portsAreHidden() const
Are ports hidden for this model.
Definition atap_data_model.cpp:323
ATapDataModel::protoId
int protoId() const
The protocol id for the tap.
Definition atap_data_model.cpp:77
ATapDataModel::useNanosecondTimestamps
virtual void useNanosecondTimestamps(bool nanoseconds)=0
Use nanosecond timestamps if requested.
ATapDataModel::filter
QString filter() const
Return a filter set for the model.
Definition atap_data_model.cpp:313
ConversationDataModel
Definition atap_data_model.h:302
ConversationDataModel::useAbsoluteTime
void useAbsoluteTime(bool absolute) override
Use absolute time for any column supporting it.
Definition atap_data_model.cpp:943
ConversationDataModel::showConversationId
bool showConversationId(int row=0) const
Show the conversation id if available.
Definition atap_data_model.cpp:917
ConversationDataModel::useNanosecondTimestamps
void useNanosecondTimestamps(bool nanoseconds) override
Use nanosecond timestamps if requested.
Definition atap_data_model.cpp:955
ConversationDataModel::setResolveNames
void setResolveNames(bool resolve) override
Enable or disable if names should be resolved.
Definition atap_data_model.cpp:932
EndpointDataModel
Definition atap_data_model.h:264
EndpointDataModel::useNanosecondTimestamps
void useNanosecondTimestamps(bool nanoseconds) override
Use nanosecond timestamps if requested.
Definition atap_data_model.cpp:589
EndpointDataModel::setResolveNames
void setResolveNames(bool resolve) override
Enable or disable if names should be resolved.
Definition atap_data_model.cpp:569
EndpointDataModel::useAbsoluteTime
void useAbsoluteTime(bool absolute) override
Use absolute time for any column supporting it.
Definition atap_data_model.cpp:580
conversation.h
conversation_table.h
_conversation_hash_t
Definition conversation_table.h:72
_conversation_item_t
Definition conversation_table.h:140
register_ct
Definition conversation_table.c:24
tap.h