Wireshark 4.5.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
28{
29public:
30 ExpertPacketItem(const expert_info_t& expert_info, column_info *cinfo, ExpertPacketItem* parent);
31 virtual ~ExpertPacketItem();
32
33 unsigned int packetNum() const { return packet_num_; }
34 int group() const { return group_; }
35 int severity() const { return severity_; }
36 int hfId() const { return hf_id_; }
37 QString protocol() const { return protocol_; }
38 QString summary() const { return summary_; }
39 QString colInfo() const { return info_; }
40
41 static QString groupKey(bool group_by_summary, int severity, int group, QString protocol, int expert_hf);
42 QString groupKey(bool group_by_summary);
43
44 void appendChild(ExpertPacketItem* child, QString hash);
45 ExpertPacketItem* child(int row);
46 ExpertPacketItem* child(QString hash);
47 int childCount() const;
48 int row() const;
49 ExpertPacketItem* parentItem();
50
51private:
52 unsigned int packet_num_;
53 int group_;
54 int severity_;
55 int hf_id_;
56 // Half-hearted attempt at conserving memory. If this isn't sufficient,
57 // PacketListRecord interns column strings in a GStringChunk.
58 QByteArray protocol_;
59 QByteArray summary_;
60 QByteArray info_;
61
62 QList<ExpertPacketItem*> childItems_;
63 ExpertPacketItem* parentItem_;
64 QHash<QString, ExpertPacketItem*> hashChild_; //optimization for insertion
65};
66
67class ExpertInfoModel : public QAbstractItemModel
68{
69public:
70 ExpertInfoModel(CaptureFile& capture_file, QObject *parent = 0);
71 virtual ~ExpertInfoModel();
72
73 enum ExpertColumn {
74 colSeverity = 0,
75 colSummary,
76 colGroup,
77 colProtocol,
78 colCount,
79 colPacket,
80 colHf,
81 colLast
82 };
83
84 enum ExpertSeverity {
85 severityError = PI_ERROR,
86 severityWarn = PI_WARN,
87 severityNote = PI_NOTE,
88 severityChat = PI_CHAT,
89 severityComment = PI_COMMENT
90 };
91
92 QModelIndex index(int row, int column,
93 const QModelIndex & = QModelIndex()) const;
94 QModelIndex parent(const QModelIndex &) const;
95#if 0
96 Qt::ItemFlags flags(const QModelIndex &index) const;
97#endif
98 QVariant data(const QModelIndex &index, int role) const;
99
100 int rowCount(const QModelIndex &parent = QModelIndex()) const;
101 int columnCount(const QModelIndex &parent = QModelIndex()) const;
102
103 int numEvents(enum ExpertSeverity severity);
104
105 void clear();
106
107 //GUI helpers
108 void setGroupBySummary(bool group_by_summary);
109
110 // Called from tapPacket
111 void addExpertInfo(const struct expert_info_s& expert_info);
112
113 // Callbacks for register_tap_listener
114 static void tapReset(void *eid_ptr);
115 static tap_packet_status tapPacket(void *eid_ptr, struct _packet_info *pinfo, struct epan_dissect *, const void *data, tap_flags_t flags);
116 static void tapDraw(void *eid_ptr);
117
118private:
119 CaptureFile& capture_file_;
120
121 ExpertPacketItem* createRootItem();
122
123 bool group_by_summary_;
124 ExpertPacketItem* root_;
125
126 QHash<enum ExpertSeverity, int> eventCounts_;
127};
128#endif // EXPERT_INFO_MODEL_H
Definition capture_file.h:21
Definition expert_info_model.h:68
Definition expert_info_model.h:28
#define PI_CHAT
Definition proto.h:930
#define PI_WARN
Definition proto.h:934
#define PI_NOTE
Definition proto.h:932
#define PI_COMMENT
Definition proto.h:928
#define PI_ERROR
Definition proto.h:936
Definition cfile.h:67
Definition packet_info.h:43
Definition column-info.h:62
Definition epan_dissect.h:28
Definition expert.h:27
tap_packet_status
Definition tap.h:25