Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
expert_info_model.h
Go to the documentation of this file.
1
12#ifndef EXPERT_INFO_MODEL_H
13#define EXPERT_INFO_MODEL_H
14
15#include <config.h>
16
17#include <QAbstractItemModel>
18#include <QList>
19#include <QMap>
20
21#include <ui/qt/capture_file.h>
22
23#include <epan/expert.h>
24#include <epan/tap.h>
25#include <epan/column-utils.h>
26
31{
32public:
39 ExpertPacketItem(const expert_info_t& expert_info, column_info *cinfo, ExpertPacketItem* parent);
40
44 virtual ~ExpertPacketItem();
45
50 unsigned int packetNum() const { return packet_num_; }
51
56 int group() const { return group_; }
57
62 int severity() const { return severity_; }
63
68 int hfId() const { return hf_id_; }
69
74 QString protocol() const { return protocol_; }
75
80 QString summary() const { return summary_; }
81
86 QString colInfo() const { return info_; }
87
97 static QString groupKey(bool group_by_summary, int severity, int group, QString protocol, int expert_hf);
98
104 QString groupKey(bool group_by_summary);
105
111 void appendChild(ExpertPacketItem* child, QString hash);
112
119
125 ExpertPacketItem* child(QString hash);
126
131 int childCount() const;
132
137 int row() const;
138
144
145private:
147 unsigned int packet_num_;
148
150 int group_;
151
153 int severity_;
154
156 int hf_id_;
157
159 int row_;
160
166 QByteArray protocol_;
167
169 QByteArray summary_;
170
172 QByteArray info_;
173
175 QList<ExpertPacketItem*> childItems_;
176
178 ExpertPacketItem* parentItem_;
179
181 QHash<QString, ExpertPacketItem*> hashChild_; //optimization for insertion
182};
183
187class ExpertInfoModel : public QAbstractItemModel
188{
189public:
196
200 virtual ~ExpertInfoModel();
201
215
226
234 QModelIndex index(int row, int column,
235 const QModelIndex &parent = QModelIndex()) const;
236
242 QModelIndex parent(const QModelIndex &index) const;
243
244#if 0
250 Qt::ItemFlags flags(const QModelIndex &index) const;
251#endif
252
259 QVariant data(const QModelIndex &index, int role) const;
260
266 int rowCount(const QModelIndex &parent = QModelIndex()) const;
267
273 int columnCount(const QModelIndex &parent = QModelIndex()) const;
274
280 int numEvents(enum ExpertSeverity severity);
281
285 void clear();
286
287 //GUI helpers
292 void setGroupBySummary(bool group_by_summary);
293
294 // Called from tapPacket
299 void addExpertInfo(const struct expert_info_s& expert_info);
300
305 static void tapReset(void *eid_ptr);
306
315 static tap_packet_status tapPacket(void *eid_ptr, struct _packet_info *pinfo, struct epan_dissect *, const void *data, tap_flags_t flags);
316
321 static void tapDraw(void *eid_ptr);
322
323private:
325 CaptureFile& capture_file_;
326
331 ExpertPacketItem* createRootItem();
332
334 bool group_by_summary_;
335
337 ExpertPacketItem* root_;
338
340 QHash<enum ExpertSeverity, int> eventCounts_;
341};
342#endif // EXPERT_INFO_MODEL_H
Manages a capture file and its associated state and operations.
Definition capture_file.h:27
A model managing the expert information tree data.
Definition expert_info_model.h:188
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Generates an index for the given row and column.
Definition expert_info_model.cpp:135
static tap_packet_status tapPacket(void *eid_ptr, struct _packet_info *pinfo, struct epan_dissect *, const void *data, tap_flags_t flags)
Callback used by register_tap_listener when a packet is processed.
Definition expert_info_model.cpp:446
QModelIndex parent(const QModelIndex &index) const
Retrieves the parent of a given index.
Definition expert_info_model.cpp:195
int numEvents(enum ExpertSeverity severity)
Gets the total number of events for a specific severity.
Definition expert_info_model.cpp:130
static void tapReset(void *eid_ptr)
Callback used by register_tap_listener to reset the tap.
Definition expert_info_model.cpp:437
ExpertColumn
Enumerates the columns in the expert info model.
Definition expert_info_model.h:205
@ colCount
Definition expert_info_model.h:210
@ colLast
Definition expert_info_model.h:213
@ colGroup
Definition expert_info_model.h:208
@ colSeverity
Definition expert_info_model.h:206
@ colProtocol
Definition expert_info_model.h:209
@ colPacket
Definition expert_info_model.h:211
@ colSummary
Definition expert_info_model.h:207
@ colHf
Definition expert_info_model.h:212
int rowCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of rows under a given parent.
Definition expert_info_model.cpp:361
void addExpertInfo(const struct expert_info_s &expert_info)
Adds a new expert information entry to the model.
Definition expert_info_model.cpp:404
void setGroupBySummary(bool group_by_summary)
Sets whether the model groups items by summary.
Definition expert_info_model.cpp:354
void clear()
Clears all expert information data from the model.
Definition expert_info_model.cpp:107
int columnCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of columns under a given parent.
Definition expert_info_model.cpp:399
ExpertSeverity
Enumerates the severity levels for expert information.
Definition expert_info_model.h:219
@ severityNote
Definition expert_info_model.h:222
@ severityComment
Definition expert_info_model.h:224
@ severityChat
Definition expert_info_model.h:223
@ severityError
Definition expert_info_model.h:220
@ severityWarn
Definition expert_info_model.h:221
virtual ~ExpertInfoModel()
Destroys the ExpertInfoModel.
Definition expert_info_model.cpp:102
static void tapDraw(void *eid_ptr)
Callback used by register_tap_listener to draw or update results.
Definition expert_info_model.cpp:464
Represents a single packet or group item in the expert information tree.
Definition expert_info_model.h:31
static QString groupKey(bool group_by_summary, int severity, int group, QString protocol, int expert_hf)
Generates a grouping key based on item properties.
Definition expert_info_model.cpp:42
ExpertPacketItem * parentItem()
Retrieves the parent of this item.
Definition expert_info_model.cpp:86
int row() const
Gets the row index of this item relative to its parent.
Definition expert_info_model.cpp:81
int group() const
Retrieves the expert group ID.
Definition expert_info_model.h:56
QString protocol() const
Retrieves the protocol name.
Definition expert_info_model.h:74
unsigned int packetNum() const
Retrieves the packet number.
Definition expert_info_model.h:50
void appendChild(ExpertPacketItem *child, QString hash)
Appends a child item to this item.
Definition expert_info_model.cpp:58
virtual ~ExpertPacketItem()
Destroys the ExpertPacketItem.
Definition expert_info_model.cpp:32
int childCount() const
Gets the number of children this item has.
Definition expert_info_model.cpp:76
QString colInfo() const
Retrieves the column info text.
Definition expert_info_model.h:86
int severity() const
Retrieves the severity level.
Definition expert_info_model.h:62
QString summary() const
Retrieves the summary text.
Definition expert_info_model.h:80
ExpertPacketItem * child(int row)
Retrieves the child item at a specific row.
Definition expert_info_model.cpp:66
int hfId() const
Retrieves the header field ID.
Definition expert_info_model.h:68
#define PI_CHAT
Definition proto.h:936
#define PI_WARN
Definition proto.h:940
#define PI_NOTE
Definition proto.h:938
#define PI_COMMENT
Definition proto.h:934
#define PI_ERROR
Definition proto.h:942
Represents a capture file and its associated metadata.
Definition cfile.h:84
Represents the metadata and indexing information for a single captured frame.
Definition packet_info.h:43
Definition column-info.h:59
Holds all state for the dissection of a single byte array, including session, buffer,...
Definition epan_dissect.h:28
Holds expert info data for a single packet event; used internally and for display purposes only.
Definition expert.h:26
tap_packet_status
Definition tap.h:22