| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
decode_as_model.h
Go to the documentation of this file.
1
11
12#ifndef DECODE_AS_MODEL_H
13#define DECODE_AS_MODEL_H
14
15#include <config.h>
16
17#include <QAbstractItemModel>
18#include <QList>
19
20#include <epan/cfile.h>
21
22#include <epan/packet.h>
23#include <epan/decode_as.h>
24#include <epan/dissectors/packet-dcerpc.h>
25
29 class DecodeAsItem
30{
31 public:
35 DecodeAsItem(const char *table_name = NULL, const void *selector = NULL);
36
40 DecodeAsItem(const decode_as_t *entry, const void *selector = NULL);
41
43 virtual ~DecodeAsItem();
44
47 const char* tableName() const { return tableName_; }
48
51 const char* tableUIName() const { return tableUIName_; }
52
55 uint selectorUint() const { return selectorUint_; }
56
59 QString selectorString() const { return selectorString_; }
60
63 decode_dcerpc_bind_values_t* selectorDCERPC() const { return selectorDCERPC_; }
64
67 const guid_key* selectorUUID() const { return &selectorUUID_; }
68
71 QString defaultDissector() const { return default_dissector_; }
72
75 QString currentDissector() const { return current_dissector_; }
76
79 dissector_handle_t dissectorHandle() const { return dissector_handle_; }
80
83 void setTable(const decode_as_t *entry);
84
87 void setSelector(const QString &value);
88
91 void setDissectorHandle(dissector_handle_t handle);
92
95 void setUUID(const guid_key& key);
96
101 void updateHandles();
102
103 private:
107 void init(const char *table_name, const void *selector = NULL);
108
109 const char* tableName_;
110 const char* tableUIName_;
111
112 // Selector values are stored by value to avoid memory management issues
113 // between the transient GUI state and the underlying dissector data.
114 uint selectorUint_;
115 QString selectorString_;
116
117 //for special handling of DCE/RPC
118 decode_dcerpc_bind_values_t* selectorDCERPC_;
119 guid_key selectorUUID_;
120
121 QString default_dissector_;
122 QString current_dissector_;
123 dissector_handle_t dissector_handle_;
124};
125
129 typedef struct _dissector_info_t {
130 QString proto_name;
131 guid_key dcerpc_uuid;
132 dissector_handle_t dissector_handle;
133} dissector_info_t;
134
135Q_DECLARE_METATYPE(dissector_info_t*)
136
137
144class DecodeAsModel : public QAbstractTableModel
145{
146 Q_OBJECT
147
148 public:
155 DecodeAsModel(QObject *parent, capture_file *cf = NULL);
156
158 virtual ~DecodeAsModel();
159
160
164 struct UIntEntry {
165 QByteArray table;
166 uint32_t key;
167 QByteArray pref_name;
168
174 UIntEntry(const char* t, uint32_t k, const char* pref_suffix) :
175 table(t), key(k), pref_name(t) { pref_name.append(pref_suffix); }
176 };
177
178
182 enum DecodeAsColumn {
183 colTable = 0,
184 colSelector,
185 colType,
186 colDefault,
187 colProtocol,
188 colDecodeAsMax
189 };
190
191
195 Qt::ItemFlags flags(const QModelIndex &index) const override;
196
201 QVariant data(const QModelIndex &index, int role) const override;
202
208 QVariant headerData(int section, Qt::Orientation orientation,
209 int role = Qt::DisplayRole) const override;
210
214 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
215
219 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
220
221
227 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
228
232 void fillTable();
233
234
238 void setDissectorHandle(const QModelIndex &index, dissector_handle_t dissector_handle);
239
240
246 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
247
253 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
254
258 void clearAll();
259
264 bool copyRow(int dst_row, int src_row);
265
270 bool copyFromProfile(QString filename, const char **err);
271
276 static QString entryString(const char *table_name, const void *value);
277
281 void applyChanges();
282
283 protected:
290 static void buildChangedList(const char *table_name, ftenum_t selector_type,
291 void *key, void *value, void *user_data);
292
296 static void buildDceRpcChangedList(void *data, void *user_data);
297
304 static void gatherChangedEntries(const char *table_name, ftenum_t selector_type,
305 void *key, void *value, void *user_data);
306
312 static prefs_set_pref_e readDecodeAsEntry(char *key, const char *value,
313 void *user_data, bool);
314
315 private:
316 capture_file *cap_file_;
317 QList<DecodeAsItem *> decode_as_items_;
318 QList<UIntEntry> changed_uint_entries_;
319 QList<QPair<const char *, const char *> > changed_string_entries_;
320};
321
322#endif // DECODE_AS_MODEL_H
cfile.h
capture_file
struct _capture_file capture_file
Represents a capture file and its associated metadata.
DecodeAsItem::selectorUUID
const guid_key * selectorUUID() const
Return the selector as a UUID key.
Definition decode_as_model.h:67
DecodeAsItem::~DecodeAsItem
virtual ~DecodeAsItem()
Destroy the DecodeAsItem.
Definition decode_as_model.cpp:64
DecodeAsItem::dissectorHandle
dissector_handle_t dissectorHandle() const
Return the handle of the currently selected dissector.
Definition decode_as_model.h:79
DecodeAsItem::selectorString
QString selectorString() const
Return the selector as a string.
Definition decode_as_model.h:59
DecodeAsItem::setUUID
void setUUID(const guid_key &key)
Set the UUID selector key.
Definition decode_as_model.cpp:147
DecodeAsItem::selectorDCERPC
decode_dcerpc_bind_values_t * selectorDCERPC() const
Return the selector as a DCE/RPC bind value.
Definition decode_as_model.h:63
DecodeAsItem::setTable
void setTable(const decode_as_t *entry)
Set the dissector table from a decode_as_t entry.
Definition decode_as_model.cpp:108
DecodeAsItem::tableName
const char * tableName() const
Return the dissector table name.
Definition decode_as_model.h:47
DecodeAsItem::setSelector
void setSelector(const QString &value)
Set the selector value from a string.
Definition decode_as_model.cpp:124
DecodeAsItem::selectorUint
uint selectorUint() const
Return the selector as an unsigned integer.
Definition decode_as_model.h:55
DecodeAsItem::DecodeAsItem
DecodeAsItem(const char *table_name=NULL, const void *selector=NULL)
Construct a DecodeAsItem from a raw table name and selector.
Definition decode_as_model.cpp:32
DecodeAsItem::updateHandles
void updateHandles()
Refresh the default and current dissector name strings from the current dissector handle.
Definition decode_as_model.cpp:153
DecodeAsItem::currentDissector
QString currentDissector() const
Return the name of the currently selected dissector.
Definition decode_as_model.h:75
DecodeAsItem::setDissectorHandle
void setDissectorHandle(dissector_handle_t handle)
Set the dissector handle.
Definition decode_as_model.cpp:137
DecodeAsItem::defaultDissector
QString defaultDissector() const
Return the name of the default dissector for this entry.
Definition decode_as_model.h:71
DecodeAsItem::tableUIName
const char * tableUIName() const
Return the dissector table name for display in the UI.
Definition decode_as_model.h:51
DecodeAsModel::DecodeAsModel
DecodeAsModel(QObject *parent, capture_file *cf=NULL)
Construct a DecodeAsModel.
Definition decode_as_model.cpp:170
DecodeAsModel::DecodeAsColumn
DecodeAsColumn
Column indices for the Decode As table.
Definition decode_as_model.h:182
DecodeAsModel::colProtocol
@ colProtocol
Definition decode_as_model.h:187
DecodeAsModel::colDefault
@ colDefault
Definition decode_as_model.h:186
DecodeAsModel::colTable
@ colTable
Definition decode_as_model.h:183
DecodeAsModel::colType
@ colType
Definition decode_as_model.h:185
DecodeAsModel::colDecodeAsMax
@ colDecodeAsMax
Definition decode_as_model.h:188
DecodeAsModel::colSelector
@ colSelector
Definition decode_as_model.h:184
decode_as.h
decode_as_t
struct decode_as_s decode_as_t
dissector_info_t
struct _dissector_info_t dissector_info_t
Bundles identifying metadata and a handle for a single registered dissector.
ftenum_t
enum ftenum ftenum_t
Convenience typedef for ftenum.
Definition ftypes.h:190
guid_key
struct _guid_key guid_key
Lookup key for GUID-indexed dissector tables, combining a GUID with an optional version field.
packet.h
prefs_set_pref_e
prefs_set_pref_e
Result of setting a preference.
Definition prefs.h:1267
_dissector_info_t
Bundles identifying metadata and a handle for a single registered dissector.
Definition decode_as_model.h:129
_dissector_info_t::proto_name
QString proto_name
Definition decode_as_model.h:130
_dissector_info_t::dcerpc_uuid
guid_key dcerpc_uuid
Definition decode_as_model.h:131
_dissector_info_t::dissector_handle
dissector_handle_t dissector_handle
Definition decode_as_model.h:132
DecodeAsModel::UIntEntry::UIntEntry
UIntEntry(const char *t, uint32_t k, const char *pref_suffix)
Construct a UIntEntry.
Definition decode_as_model.h:174
DecodeAsModel::UIntEntry::table
QByteArray table
Definition decode_as_model.h:165
DecodeAsModel::UIntEntry::pref_name
QByteArray pref_name
Definition decode_as_model.h:167
DecodeAsModel::UIntEntry::key
uint32_t key
Definition decode_as_model.h:166
dissector_handle
Definition packet.c:867