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
30{
31public:
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
103private:
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
134
135Q_DECLARE_METATYPE(dissector_info_t*)
136
137
144class DecodeAsModel : public QAbstractTableModel
145{
146 Q_OBJECT
147
148public:
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
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
283protected:
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
315private:
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
struct _capture_file capture_file
Represents a capture file and its associated metadata.
const guid_key * selectorUUID() const
Return the selector as a UUID key.
Definition decode_as_model.h:67
virtual ~DecodeAsItem()
Destroy the DecodeAsItem.
Definition decode_as_model.cpp:64
dissector_handle_t dissectorHandle() const
Return the handle of the currently selected dissector.
Definition decode_as_model.h:79
QString selectorString() const
Return the selector as a string.
Definition decode_as_model.h:59
void setUUID(const guid_key &key)
Set the UUID selector key.
Definition decode_as_model.cpp:147
decode_dcerpc_bind_values_t * selectorDCERPC() const
Return the selector as a DCE/RPC bind value.
Definition decode_as_model.h:63
void setTable(const decode_as_t *entry)
Set the dissector table from a decode_as_t entry.
Definition decode_as_model.cpp:108
const char * tableName() const
Return the dissector table name.
Definition decode_as_model.h:47
void setSelector(const QString &value)
Set the selector value from a string.
Definition decode_as_model.cpp:124
uint selectorUint() const
Return the selector as an unsigned integer.
Definition decode_as_model.h:55
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
void updateHandles()
Refresh the default and current dissector name strings from the current dissector handle.
Definition decode_as_model.cpp:153
QString currentDissector() const
Return the name of the currently selected dissector.
Definition decode_as_model.h:75
void setDissectorHandle(dissector_handle_t handle)
Set the dissector handle.
Definition decode_as_model.cpp:137
QString defaultDissector() const
Return the name of the default dissector for this entry.
Definition decode_as_model.h:71
const char * tableUIName() const
Return the dissector table name for display in the UI.
Definition decode_as_model.h:51
DecodeAsModel(QObject *parent, capture_file *cf=NULL)
Construct a DecodeAsModel.
Definition decode_as_model.cpp:170
DecodeAsColumn
Column indices for the Decode As table.
Definition decode_as_model.h:182
@ colProtocol
Definition decode_as_model.h:187
@ colDefault
Definition decode_as_model.h:186
@ colTable
Definition decode_as_model.h:183
@ colType
Definition decode_as_model.h:185
@ colDecodeAsMax
Definition decode_as_model.h:188
@ colSelector
Definition decode_as_model.h:184
struct decode_as_s decode_as_t
struct _dissector_info_t dissector_info_t
Bundles identifying metadata and a handle for a single registered dissector.
enum ftenum ftenum_t
Convenience typedef for ftenum.
Definition ftypes.h:190
struct _guid_key guid_key
Lookup key for GUID-indexed dissector tables, combining a GUID with an optional version field.
prefs_set_pref_e
Result of setting a preference.
Definition prefs.h:1268
Bundles identifying metadata and a handle for a single registered dissector.
Definition decode_as_model.h:129
QString proto_name
Definition decode_as_model.h:130
guid_key dcerpc_uuid
Definition decode_as_model.h:131
dissector_handle_t dissector_handle
Definition decode_as_model.h:132
UIntEntry(const char *t, uint32_t k, const char *pref_suffix)
Construct a UIntEntry.
Definition decode_as_model.h:174
QByteArray table
Definition decode_as_model.h:165
QByteArray pref_name
Definition decode_as_model.h:167
uint32_t key
Definition decode_as_model.h:166
Definition packet.c:867