Wireshark  4.3.0
The Wireshark network protocol analyzer
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 "glib.h"
16 
17 #include <epan/tap.h>
18 #include <epan/conversation.h>
20 
21 #include <QAbstractListModel>
22 
34 class ATapDataModel : public QAbstractListModel
35 {
36  Q_OBJECT
37 public:
38 
39  enum {
40  DISPLAY_FILTER = Qt::UserRole,
41  UNFORMATTED_DISPLAYDATA,
42 #ifdef HAVE_MAXMINDDB
43  GEODATA_AVAILABLE,
44  GEODATA_LOOKUPTABLE,
45  GEODATA_ADDRESS,
46 #endif
47  TIMELINE_DATA,
48  ENDPOINT_DATATYPE,
49  PROTO_ID,
50  CONVERSATION_ID,
51  ROW_IS_FILTERED,
52  DATA_ADDRESS_TYPE,
53  DATA_IPV4_INTEGER,
54  DATA_IPV6_LIST,
55  };
56 
57  typedef enum {
58  DATAMODEL_ENDPOINT,
59  DATAMODEL_CONVERSATION,
60  DATAMODEL_UNKNOWN
61  } dataModelType;
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  void setResolveNames(bool resolve);
137 
147  bool allowsNameResolution() const;
148 
154  void useAbsoluteTime(bool absolute);
155 
161  void useNanosecondTimestamps(bool nanoseconds);
162 
169  bool portsAreHidden() const;
170 
177  bool showTotalColumn() const;
178 
188  bool enableTap();
189 
193  void disableTap();
194 
200  dataModelType modelType() const;
201 
202 #ifdef HAVE_MAXMINDDB
209  bool hasGeoIPData();
210 #endif
211 
212 signals:
213  void tapListenerChanged(bool enable);
214 
215 protected:
216 
217  static void tapReset(void *tapdata);
218  static void tapDraw(void *tap_data);
219 
220  virtual tap_packet_cb conversationPacketHandler();
221 
222  conv_hash_t * hash();
223 
224  void resetData();
225  void updateData(GArray * data);
226 
227  dataModelType _type;
228  GArray * storage_;
229  QString _filter;
230 
231  bool _absoluteTime;
232  bool _nanoseconds;
233  bool _resolveNames;
234  bool _disableTap;
235 
236  double _minRelStartTime;
237  double _maxRelStopTime;
238 
239  register_ct_t* registerTable() const;
240 
241 private:
242  int _protoId;
243 
244  conv_hash_t hash_;
245 };
246 
248 {
249  Q_OBJECT
250 public:
251 
252  typedef enum
253  {
254  ENDP_COLUMN_ADDR,
255  ENDP_COLUMN_PORT,
256  ENDP_COLUMN_PACKETS,
257  ENDP_COLUMN_BYTES,
258  ENDP_COLUMN_PACKETS_TOTAL,
259  ENDP_COLUMN_BYTES_TOTAL,
260  ENDP_COLUMN_PKT_AB,
261  ENDP_COLUMN_BYTES_AB,
262  ENDP_COLUMN_PKT_BA,
263  ENDP_COLUMN_BYTES_BA,
264  ENDP_NUM_COLUMNS,
265  ENDP_COLUMN_GEO_COUNTRY = ENDP_NUM_COLUMNS,
266  ENDP_COLUMN_GEO_CITY,
267  ENDP_COLUMN_GEO_LATITUDE,
268  ENDP_COLUMN_GEO_LONGITUDE,
269  ENDP_COLUMN_GEO_AS_NUM,
270  ENDP_COLUMN_GEO_AS_ORG,
271  ENDP_NUM_GEO_COLUMNS
272  } endpoint_column_type_e;
273 
274  explicit EndpointDataModel(int protoId, QString filter, QObject *parent = nullptr);
275 
276  int columnCount(const QModelIndex &parent = QModelIndex()) const;
277  QVariant headerData(int section, Qt::Orientation orientation = Qt::Horizontal, int role = Qt::DisplayRole) const;
278  QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const;
279 
280 };
281 
283 {
284  Q_OBJECT
285 public:
286 
287  typedef enum {
288  CONV_COLUMN_SRC_ADDR,
289  CONV_COLUMN_SRC_PORT,
290  CONV_COLUMN_DST_ADDR,
291  CONV_COLUMN_DST_PORT,
292  CONV_COLUMN_PACKETS,
293  CONV_COLUMN_BYTES,
294  CONV_COLUMN_CONV_ID,
295  CONV_COLUMN_PACKETS_TOTAL,
296  CONV_COLUMN_BYTES_TOTAL,
297  CONV_COLUMN_PKT_AB,
298  CONV_COLUMN_BYTES_AB,
299  CONV_COLUMN_PKT_BA,
300  CONV_COLUMN_BYTES_BA,
301  CONV_COLUMN_START,
302  CONV_COLUMN_DURATION,
303  CONV_COLUMN_BPS_AB,
304  CONV_COLUMN_BPS_BA,
305  CONV_NUM_COLUMNS,
306  CONV_INDEX_COLUMN = CONV_NUM_COLUMNS
307  } conversation_column_type_e;
308 
309  explicit ConversationDataModel(int protoId, QString filter, QObject *parent = nullptr);
310 
311  int columnCount(const QModelIndex &parent = QModelIndex()) const;
312  QVariant headerData(int section, Qt::Orientation orientation = Qt::Horizontal, int role = Qt::DisplayRole) const;
313  QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const;
314 
315  void doDataUpdate();
316 
317  conv_item_t * itemForRow(int row);
318 
325  bool showConversationId(int row = 0) const;
326 
327 };
328 
329 #endif // ATAP_DATA_MODEL_H
DataModel for tap user data.
Definition: atap_data_model.h:35
bool showTotalColumn() const
A total column is filled.
Definition: atap_data_model.cpp:316
bool resolveNames() const
Is the model set to resolve names in address and ports columns.
Definition: atap_data_model.cpp:223
void useAbsoluteTime(bool absolute)
Use absolute time for any column supporting it.
Definition: atap_data_model.cpp:264
bool enableTap()
Enable tapping in this model.
Definition: atap_data_model.cpp:104
ATapDataModel(dataModelType type, int protoId, QString filter, QObject *parent=nullptr)
Construct a new ATapDataModel object.
Definition: atap_data_model.cpp:38
QString tap() const
Returns the name for the tap being used.
Definition: atap_data_model.cpp:79
bool allowsNameResolution() const
Does the model allow names to be resolved.
Definition: atap_data_model.cpp:238
dataModelType modelType() const
Return the model type.
Definition: atap_data_model.cpp:306
void setFilter(QString filter)
Set the filter string.
Definition: atap_data_model.cpp:284
void setResolveNames(bool resolve)
Enable or disable if names should be resolved.
Definition: atap_data_model.cpp:228
void disableTap()
Disable the tapping for this model.
Definition: atap_data_model.cpp:131
void useNanosecondTimestamps(bool nanoseconds)
Use nanosecond timestamps if requested.
Definition: atap_data_model.cpp:274
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:140
bool portsAreHidden() const
Are ports hidden for this model.
Definition: atap_data_model.cpp:311
int protoId() const
The protocol id for the tap.
Definition: atap_data_model.cpp:74
QString filter() const
Return a filter set for the model.
Definition: atap_data_model.cpp:301
Definition: atap_data_model.h:283
bool showConversationId(int row=0) const
Show the conversation id if available.
Definition: atap_data_model.cpp:841
Definition: atap_data_model.h:248
Definition: conversation_table.h:53
Definition: conversation_table.h:116
Definition: conversation_table.c:24