| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
atap_data_model.h
Go to the documentation of this file.
1
9
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
35 public:
36
40 enum {
41 DISPLAY_FILTER = Qt::UserRole,
42 UNFORMATTED_DISPLAYDATA,
43#ifdef HAVE_MAXMINDDB
44 GEODATA_AVAILABLE,
45 GEODATA_LOOKUPTABLE,
46 GEODATA_ADDRESS,
47#endif
48 TIMELINE_DATA,
49 ENDPOINT_DATATYPE,
50 PROTO_ID,
51 CONVERSATION_ID,
52 ROW_IS_FILTERED,
53 DATA_ADDRESS_TYPE,
54 DATA_IPV4_INTEGER,
55 DATA_IPV6_LIST,
56};
57
61 typedef enum {
62 DATAMODEL_ENDPOINT,
63 DATAMODEL_CONVERSATION,
64 DATAMODEL_UNKNOWN
65} dataModelType;
66
67 conv_hash_t hash_;
68
82 explicit ATapDataModel(dataModelType type, int protoId, QString filter, QObject *parent = nullptr);
83
85 virtual ~ATapDataModel();
86
95 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
96
103 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override= 0;
104
113 virtual QVariant headerData(int section, Qt::Orientation orientation = Qt::Horizontal, int role = Qt::DisplayRole) const override= 0;
114
122 virtual QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override= 0;
123
129 QString tap() const;
130
136 int protoId() const;
137
145 void setFilter(QString filter);
146
152 QString filter() const;
153
160 bool resolveNames() const;
161
167 virtual void setResolveNames(bool resolve) = 0;
168
178 bool allowsNameResolution() const;
179
185 virtual void useAbsoluteTime(bool absolute) = 0;
186
194 virtual void useNanosecondTimestamps(bool nanoseconds) = 0;
195
200 void setMachineReadable(bool machineReadable);
201
206 void limitToDisplayFilter(bool limit);
207
214 bool portsAreHidden() const;
215
224 bool isFilterApplied() const;
225
235 bool enableTap();
236
240 void disableTap();
241
247 dataModelType modelType() const;
248
254 conv_hash_t * hash();
255
259 void updateFlags(unsigned flag);
260
261#ifdef HAVE_MAXMINDDB
268 bool hasGeoIPData();
269#endif
270
271signals:
276 void tapListenerChanged(bool enable);
277
278 protected:
279
284 static void tapReset(void *tapdata);
285
290 static void tapDraw(void *tap_data);
291
296 virtual tap_packet_cb conversationPacketHandler();
297
301 void resetData();
302
307 void updateData(GArray * data);
308
309 dataModelType _type;
310 GArray * storage_;
311 QString _filter;
312
313 bool _absoluteTime;
314 // XXX - There are other possible time precisions besides
315 // microseconds and nanoseconds; e.g., Netmon 2.3 uses
316 // 100 ns, and pcapng can have one of many values.
317 bool _nanoseconds;
318 bool _resolveNames;
319 bool _machineReadable;
320 bool _disableTap;
321
322 double _minRelStartTime;
323 double _maxRelStopTime;
324
325 unsigned _tapFlags;
326
331 register_ct_t* registerTable() const;
332
333 private:
334 int _protoId;
335
336};
337
341 class EndpointDataModel : public ATapDataModel
342{
343 Q_OBJECT
344 public:
348 typedef enum
349 {
350 ENDP_COLUMN_ADDR,
351 ENDP_COLUMN_PORT,
352 ENDP_COLUMN_PACKETS,
353 ENDP_COLUMN_BYTES,
354 ENDP_COLUMN_PACKETS_TOTAL,
355 ENDP_COLUMN_BYTES_TOTAL,
356 ENDP_COLUMN_PKT_AB,
357 ENDP_COLUMN_BYTES_AB,
358 ENDP_COLUMN_PKT_BA,
359 ENDP_COLUMN_BYTES_BA,
360 ENDP_NUM_COLUMNS,
361 ENDP_COLUMN_GEO_COUNTRY = ENDP_NUM_COLUMNS,
362 ENDP_COLUMN_GEO_CITY,
363 ENDP_COLUMN_GEO_LATITUDE,
364 ENDP_COLUMN_GEO_LONGITUDE,
365 ENDP_COLUMN_GEO_AS_NUM,
366 ENDP_COLUMN_GEO_AS_ORG,
367 ENDP_NUM_GEO_COLUMNS
368 } endpoint_column_type_e;
369
376 explicit EndpointDataModel(int protoId, QString filter, QObject *parent = nullptr);
377
384 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
385
393 QVariant headerData(int section, Qt::Orientation orientation = Qt::Horizontal,
394 int role = Qt::DisplayRole) const override;
395
402 QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override;
403
409 void setResolveNames(bool resolve) override;
410
416 void useAbsoluteTime(bool absolute) override;
417
423 void useNanosecondTimestamps(bool nanoseconds) override;
424};
425
426
435 class ConversationDataModel : public ATapDataModel
436{
437 Q_OBJECT
438
439 public:
446 typedef enum {
447 CONV_COLUMN_SRC_ADDR,
448 CONV_COLUMN_SRC_PORT,
449 CONV_COLUMN_DST_ADDR,
450 CONV_COLUMN_DST_PORT,
451 CONV_COLUMN_PACKETS,
452 CONV_COLUMN_BYTES,
453 CONV_COLUMN_CONV_ID,
454 CONV_COLUMN_PACKETS_TOTAL,
455 CONV_COLUMN_BYTES_TOTAL,
456 CONV_COLUMN_PKT_AB,
457 CONV_COLUMN_BYTES_AB,
458 CONV_COLUMN_PKT_BA,
459 CONV_COLUMN_BYTES_BA,
460 CONV_COLUMN_START,
461 CONV_COLUMN_DURATION,
462 CONV_COLUMN_BPS_AB,
463 CONV_COLUMN_BPS_BA,
464 CONV_NUM_COLUMNS,
465 CONV_INDEX_COLUMN = CONV_NUM_COLUMNS
466 } conversation_column_type_e;
467
474 typedef enum {
475 CONV_TCP_EXT_COLUMN_A = CONV_INDEX_COLUMN,
476 CONV_TCP_EXT_NUM_COLUMNS,
477 CONV_TCP_EXT_INDEX_COLUMN = CONV_TCP_EXT_NUM_COLUMNS
478 } conversation_tcp_ext_column_type_e;
479
486 explicit ConversationDataModel(int protoId, QString filter, QObject *parent = nullptr);
487
493 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
494
502 QVariant headerData(int section, Qt::Orientation orientation = Qt::Horizontal,
503 int role = Qt::DisplayRole) const override;
504
511 QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override;
512
520 void doDataUpdate();
521
528 conv_item_t *itemForRow(int row);
529
539 bool showConversationId(int row = 0) const;
540
546 void setResolveNames(bool resolve) override;
547
553 void useAbsoluteTime(bool absolute) override;
554
560 void useNanosecondTimestamps(bool nanoseconds) override;
561};
562
563#endif // ATAP_DATA_MODEL_H
ATapDataModel::setResolveNames
virtual void setResolveNames(bool resolve)=0
Enable or disable if names should be resolved.
ATapDataModel::conversationPacketHandler
virtual tap_packet_cb conversationPacketHandler()
Retrieves the callback function used to handle conversation packets.
Definition atap_data_model.cpp:221
ATapDataModel::_disableTap
bool _disableTap
Definition atap_data_model.h:320
ATapDataModel::setMachineReadable
void setMachineReadable(bool machineReadable)
Sets whether the data should be presented in a machine-readable format.
Definition atap_data_model.cpp:159
ATapDataModel::headerData
virtual QVariant headerData(int section, Qt::Orientation orientation=Qt::Horizontal, int role=Qt::DisplayRole) const override=0
Return the header data for the specified section and orientation.
ATapDataModel::tapDraw
static void tapDraw(void *tap_data)
Callback to draw or update the tap data.
Definition atap_data_model.cpp:197
ATapDataModel::resolveNames
bool resolveNames() const
Is the model set to resolve names in address and ports columns.
Definition atap_data_model.cpp:265
ATapDataModel::~ATapDataModel
virtual ~ATapDataModel()
Destructor.
Definition atap_data_model.cpp:65
ATapDataModel::enableTap
bool enableTap()
Enable tapping in this model.
Definition atap_data_model.cpp:109
ATapDataModel::resetData
void resetData()
Resets the internal model data.
Definition atap_data_model.cpp:234
ATapDataModel::ATapDataModel
ATapDataModel(dataModelType type, int protoId, QString filter, QObject *parent=nullptr)
Construct a new ATapDataModel object.
Definition atap_data_model.cpp:38
ATapDataModel::tapListenerChanged
void tapListenerChanged(bool enable)
Signal emitted when the tap listener state changes.
ATapDataModel::updateData
void updateData(GArray *data)
Updates the model with new data.
Definition atap_data_model.cpp:252
ATapDataModel::tap
QString tap() const
Returns the name for the tap being used.
Definition atap_data_model.cpp:82
ATapDataModel::registerTable
register_ct_t * registerTable() const
Gets the conversation registration table for this tap.
Definition atap_data_model.cpp:213
ATapDataModel::limitToDisplayFilter
void limitToDisplayFilter(bool limit)
Limits the data model to the currently active display filter.
Definition atap_data_model.cpp:170
ATapDataModel::allowsNameResolution
bool allowsNameResolution() const
Does the model allow names to be resolved.
Definition atap_data_model.cpp:270
ATapDataModel::_resolveNames
bool _resolveNames
Definition atap_data_model.h:318
ATapDataModel::dataModelType
dataModelType
Identifies which statistical data model is active in the endpoint/conversation dialog.
Definition atap_data_model.h:61
ATapDataModel::DATAMODEL_CONVERSATION
@ DATAMODEL_CONVERSATION
Definition atap_data_model.h:63
ATapDataModel::DATAMODEL_UNKNOWN
@ DATAMODEL_UNKNOWN
Definition atap_data_model.h:64
ATapDataModel::DATAMODEL_ENDPOINT
@ DATAMODEL_ENDPOINT
Definition atap_data_model.h:62
ATapDataModel::isFilterApplied
bool isFilterApplied() const
Checks if a display filter has to be applied.
Definition atap_data_model.cpp:328
ATapDataModel::useAbsoluteTime
virtual void useAbsoluteTime(bool absolute)=0
Use absolute time for any column supporting it.
ATapDataModel::_tapFlags
unsigned _tapFlags
Definition atap_data_model.h:325
ATapDataModel::hash_
conv_hash_t hash_
Definition atap_data_model.h:67
ATapDataModel::_nanoseconds
bool _nanoseconds
Definition atap_data_model.h:317
ATapDataModel::_machineReadable
bool _machineReadable
Definition atap_data_model.h:319
ATapDataModel::modelType
dataModelType modelType() const
Return the model type.
Definition atap_data_model.cpp:318
ATapDataModel::_type
dataModelType _type
Definition atap_data_model.h:309
ATapDataModel::setFilter
void setFilter(QString filter)
Set the filter string.
Definition atap_data_model.cpp:296
ATapDataModel::DATA_IPV4_INTEGER
@ DATA_IPV4_INTEGER
Definition atap_data_model.h:54
ATapDataModel::UNFORMATTED_DISPLAYDATA
@ UNFORMATTED_DISPLAYDATA
Definition atap_data_model.h:42
ATapDataModel::DATA_ADDRESS_TYPE
@ DATA_ADDRESS_TYPE
Definition atap_data_model.h:53
ATapDataModel::DATA_IPV6_LIST
@ DATA_IPV6_LIST
Definition atap_data_model.h:55
ATapDataModel::ENDPOINT_DATATYPE
@ ENDPOINT_DATATYPE
Definition atap_data_model.h:49
ATapDataModel::TIMELINE_DATA
@ TIMELINE_DATA
Definition atap_data_model.h:48
ATapDataModel::ROW_IS_FILTERED
@ ROW_IS_FILTERED
Definition atap_data_model.h:52
ATapDataModel::PROTO_ID
@ PROTO_ID
Definition atap_data_model.h:50
ATapDataModel::CONVERSATION_ID
@ CONVERSATION_ID
Definition atap_data_model.h:51
ATapDataModel::DISPLAY_FILTER
@ DISPLAY_FILTER
Definition atap_data_model.h:41
ATapDataModel::tapReset
static void tapReset(void *tapdata)
Callback to reset the tap data.
Definition atap_data_model.cpp:187
ATapDataModel::_maxRelStopTime
double _maxRelStopTime
Definition atap_data_model.h:323
ATapDataModel::_filter
QString _filter
Definition atap_data_model.h:311
ATapDataModel::hash
conv_hash_t * hash()
Return the conversation hash table for this model.
Definition atap_data_model.cpp:208
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::storage_
GArray * storage_
Definition atap_data_model.h:310
ATapDataModel::_minRelStartTime
double _minRelStartTime
Definition atap_data_model.h:322
ATapDataModel::portsAreHidden
bool portsAreHidden() const
Are ports hidden for this model.
Definition atap_data_model.cpp:323
ATapDataModel::_absoluteTime
bool _absoluteTime
Definition atap_data_model.h:313
ATapDataModel::data
virtual QVariant data(const QModelIndex &idx, int role=Qt::DisplayRole) const override=0
Return the data for the specified index and role.
ATapDataModel::columnCount
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const override=0
Return the number of columns in the model.
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
ATapDataModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
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
ConversationDataModel::useAbsoluteTime
void useAbsoluteTime(bool absolute) override
Switch timestamp display between absolute and relative time.
Definition atap_data_model.cpp:989
ConversationDataModel::conversation_tcp_ext_column_type_e
conversation_tcp_ext_column_type_e
Additional column indices for the TCP extended column block.
Definition atap_data_model.h:474
ConversationDataModel::CONV_TCP_EXT_COLUMN_A
@ CONV_TCP_EXT_COLUMN_A
Definition atap_data_model.h:475
ConversationDataModel::CONV_TCP_EXT_INDEX_COLUMN
@ CONV_TCP_EXT_INDEX_COLUMN
Definition atap_data_model.h:477
ConversationDataModel::CONV_TCP_EXT_NUM_COLUMNS
@ CONV_TCP_EXT_NUM_COLUMNS
Definition atap_data_model.h:476
ConversationDataModel::ConversationDataModel
ConversationDataModel(int protoId, QString filter, QObject *parent=nullptr)
Construct a ConversationDataModel for a given protocol and filter.
Definition atap_data_model.cpp:624
ConversationDataModel::conversation_column_type_e
conversation_column_type_e
Column indices for the standard conversation statistics table.
Definition atap_data_model.h:446
ConversationDataModel::CONV_COLUMN_SRC_ADDR
@ CONV_COLUMN_SRC_ADDR
Definition atap_data_model.h:447
ConversationDataModel::CONV_COLUMN_SRC_PORT
@ CONV_COLUMN_SRC_PORT
Definition atap_data_model.h:448
ConversationDataModel::CONV_COLUMN_CONV_ID
@ CONV_COLUMN_CONV_ID
Definition atap_data_model.h:453
ConversationDataModel::CONV_COLUMN_BYTES_TOTAL
@ CONV_COLUMN_BYTES_TOTAL
Definition atap_data_model.h:455
ConversationDataModel::CONV_COLUMN_PKT_AB
@ CONV_COLUMN_PKT_AB
Definition atap_data_model.h:456
ConversationDataModel::CONV_NUM_COLUMNS
@ CONV_NUM_COLUMNS
Definition atap_data_model.h:464
ConversationDataModel::CONV_COLUMN_BYTES_AB
@ CONV_COLUMN_BYTES_AB
Definition atap_data_model.h:457
ConversationDataModel::CONV_COLUMN_BPS_BA
@ CONV_COLUMN_BPS_BA
Definition atap_data_model.h:463
ConversationDataModel::CONV_COLUMN_BPS_AB
@ CONV_COLUMN_BPS_AB
Definition atap_data_model.h:462
ConversationDataModel::CONV_COLUMN_DST_PORT
@ CONV_COLUMN_DST_PORT
Definition atap_data_model.h:450
ConversationDataModel::CONV_COLUMN_BYTES
@ CONV_COLUMN_BYTES
Definition atap_data_model.h:452
ConversationDataModel::CONV_COLUMN_START
@ CONV_COLUMN_START
Definition atap_data_model.h:460
ConversationDataModel::CONV_INDEX_COLUMN
@ CONV_INDEX_COLUMN
Definition atap_data_model.h:465
ConversationDataModel::CONV_COLUMN_PACKETS_TOTAL
@ CONV_COLUMN_PACKETS_TOTAL
Definition atap_data_model.h:454
ConversationDataModel::CONV_COLUMN_DST_ADDR
@ CONV_COLUMN_DST_ADDR
Definition atap_data_model.h:449
ConversationDataModel::CONV_COLUMN_BYTES_BA
@ CONV_COLUMN_BYTES_BA
Definition atap_data_model.h:459
ConversationDataModel::CONV_COLUMN_DURATION
@ CONV_COLUMN_DURATION
Definition atap_data_model.h:461
ConversationDataModel::CONV_COLUMN_PKT_BA
@ CONV_COLUMN_PKT_BA
Definition atap_data_model.h:458
ConversationDataModel::CONV_COLUMN_PACKETS
@ CONV_COLUMN_PACKETS
Definition atap_data_model.h:451
ConversationDataModel::doDataUpdate
void doDataUpdate()
Recalculate derived values (throughput, duration) after a tap update.
Definition atap_data_model.cpp:628
ConversationDataModel::headerData
QVariant headerData(int section, Qt::Orientation orientation=Qt::Horizontal, int role=Qt::DisplayRole) const override
Return header data for the conversation table.
Definition atap_data_model.cpp:661
ConversationDataModel::showConversationId
bool showConversationId(int row=0) const
Return whether a conversation ID column should be shown.
Definition atap_data_model.cpp:963
ConversationDataModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Return the number of columns, including any TCP extended columns.
Definition atap_data_model.cpp:653
ConversationDataModel::data
QVariant data(const QModelIndex &idx, int role=Qt::DisplayRole) const override
Return data for a cell in the conversation table.
Definition atap_data_model.cpp:721
ConversationDataModel::useNanosecondTimestamps
void useNanosecondTimestamps(bool nanoseconds) override
Enable or disable nanosecond precision in timestamp display.
Definition atap_data_model.cpp:1001
ConversationDataModel::itemForRow
conv_item_t * itemForRow(int row)
Return the raw conv_item_t for a given table row.
Definition atap_data_model.cpp:956
ConversationDataModel::setResolveNames
void setResolveNames(bool resolve) override
Enable or disable address name resolution for all address cells.
Definition atap_data_model.cpp:978
EndpointDataModel::useNanosecondTimestamps
void useNanosecondTimestamps(bool nanoseconds) override
Enable or disable nanosecond precision in timestamp display.
Definition atap_data_model.cpp:615
EndpointDataModel::ENDP_COLUMN_GEO_CITY
@ ENDP_COLUMN_GEO_CITY
Definition atap_data_model.h:362
EndpointDataModel::ENDP_COLUMN_GEO_LONGITUDE
@ ENDP_COLUMN_GEO_LONGITUDE
Definition atap_data_model.h:364
EndpointDataModel::ENDP_COLUMN_PACKETS
@ ENDP_COLUMN_PACKETS
Definition atap_data_model.h:352
EndpointDataModel::ENDP_COLUMN_GEO_AS_NUM
@ ENDP_COLUMN_GEO_AS_NUM
Definition atap_data_model.h:365
EndpointDataModel::ENDP_NUM_GEO_COLUMNS
@ ENDP_NUM_GEO_COLUMNS
Definition atap_data_model.h:367
EndpointDataModel::ENDP_COLUMN_BYTES_AB
@ ENDP_COLUMN_BYTES_AB
Definition atap_data_model.h:357
EndpointDataModel::ENDP_COLUMN_PKT_AB
@ ENDP_COLUMN_PKT_AB
Definition atap_data_model.h:356
EndpointDataModel::ENDP_NUM_COLUMNS
@ ENDP_NUM_COLUMNS
Definition atap_data_model.h:360
EndpointDataModel::ENDP_COLUMN_BYTES
@ ENDP_COLUMN_BYTES
Definition atap_data_model.h:353
EndpointDataModel::ENDP_COLUMN_BYTES_TOTAL
@ ENDP_COLUMN_BYTES_TOTAL
Definition atap_data_model.h:355
EndpointDataModel::ENDP_COLUMN_GEO_AS_ORG
@ ENDP_COLUMN_GEO_AS_ORG
Definition atap_data_model.h:366
EndpointDataModel::ENDP_COLUMN_PORT
@ ENDP_COLUMN_PORT
Definition atap_data_model.h:351
EndpointDataModel::ENDP_COLUMN_BYTES_BA
@ ENDP_COLUMN_BYTES_BA
Definition atap_data_model.h:359
EndpointDataModel::ENDP_COLUMN_ADDR
@ ENDP_COLUMN_ADDR
Definition atap_data_model.h:350
EndpointDataModel::ENDP_COLUMN_GEO_LATITUDE
@ ENDP_COLUMN_GEO_LATITUDE
Definition atap_data_model.h:363
EndpointDataModel::ENDP_COLUMN_PKT_BA
@ ENDP_COLUMN_PKT_BA
Definition atap_data_model.h:358
EndpointDataModel::ENDP_COLUMN_PACKETS_TOTAL
@ ENDP_COLUMN_PACKETS_TOTAL
Definition atap_data_model.h:354
EndpointDataModel::ENDP_COLUMN_GEO_COUNTRY
@ ENDP_COLUMN_GEO_COUNTRY
Definition atap_data_model.h:361
EndpointDataModel::setResolveNames
void setResolveNames(bool resolve) override
Enable or disable address name resolution for all address cells.
Definition atap_data_model.cpp:595
EndpointDataModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Return the number of columns, including GeoIP columns if available.
Definition atap_data_model.cpp:338
EndpointDataModel::useAbsoluteTime
void useAbsoluteTime(bool absolute) override
Switch timestamp display between absolute and relative time.
Definition atap_data_model.cpp:606
EndpointDataModel::data
QVariant data(const QModelIndex &idx, int role=Qt::DisplayRole) const override
Return data for a cell in the endpoint table.
Definition atap_data_model.cpp:406
EndpointDataModel::headerData
QVariant headerData(int section, Qt::Orientation orientation=Qt::Horizontal, int role=Qt::DisplayRole) const override
Return header data for the endpoint table.
Definition atap_data_model.cpp:350
EndpointDataModel::EndpointDataModel
EndpointDataModel(int protoId, QString filter, QObject *parent=nullptr)
Construct an EndpointDataModel for a given protocol and filter.
Definition atap_data_model.cpp:334
conversation.h
conversation_table.h
conv_item_t
struct _conversation_item_t conv_item_t
register_ct_t
struct register_ct register_ct_t
Definition conversation_table.h:141
conv_hash_t
struct _conversation_hash_t conv_hash_t
tap.h