Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
decode_as_model.h
Go to the documentation of this file.
1
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
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_;
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_;
117 //for special handling of DCE/RPC
118 decode_dcerpc_bind_values_t* selectorDCERPC_;
119 guid_key selectorUUID_;
121 QString default_dissector_;
122 QString current_dissector_;
123 dissector_handle_t dissector_handle_;
124};
125
126typedef struct _dissector_info_t {
127 QString proto_name;
128 guid_key dcerpc_uuid;
131
132Q_DECLARE_METATYPE(dissector_info_t*)
133
134
141class DecodeAsModel : public QAbstractTableModel
142{
143 Q_OBJECT
144
145public:
152 DecodeAsModel(QObject *parent, capture_file *cf = NULL);
153
155 virtual ~DecodeAsModel();
156
157
161 struct UIntEntry {
162 QByteArray table;
163 uint32_t key;
164 QByteArray pref_name;
171 UIntEntry(const char* t, uint32_t k, const char* pref_suffix) :
172 table(t), key(k), pref_name(t) { pref_name.append(pref_suffix); }
173 };
174
175
187
188
192 Qt::ItemFlags flags(const QModelIndex &index) const;
193
198 QVariant data(const QModelIndex &index, int role) const;
199
205 QVariant headerData(int section, Qt::Orientation orientation,
206 int role = Qt::DisplayRole) const;
207
211 int rowCount(const QModelIndex &parent = QModelIndex()) const;
212
216 int columnCount(const QModelIndex &parent = QModelIndex()) const;
217
218
224 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
225
229 void fillTable();
230
231
235 void setDissectorHandle(const QModelIndex &index, dissector_handle_t dissector_handle);
236
237
243 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
244
250 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
251
255 void clearAll();
256
261 bool copyRow(int dst_row, int src_row);
262
267 bool copyFromProfile(QString filename, const char **err);
268
273 static QString entryString(const char *table_name, const void *value);
274
278 void applyChanges();
279
280protected:
287 static void buildChangedList(const char *table_name, ftenum_t selector_type,
288 void *key, void *value, void *user_data);
289
293 static void buildDceRpcChangedList(void *data, void *user_data);
294
301 static void gatherChangedEntries(const char *table_name, ftenum_t selector_type,
302 void *key, void *value, void *user_data);
303
309 static prefs_set_pref_e readDecodeAsEntry(char *key, const char *value,
310 void *user_data, bool);
311
312private:
313 capture_file *cap_file_;
314 QList<DecodeAsItem *> decode_as_items_;
315 QList<UIntEntry> changed_uint_entries_;
316 QList<QPair<const char *, const char *> > changed_string_entries_;
317};
318
319#endif // DECODE_AS_MODEL_H
Represents a single "Decode As" mapping entry in the UI.
Definition decode_as_model.h:30
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
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
Table model backing the Decode As dialog.
Definition decode_as_model.h:142
DecodeAsColumn
Column indices for the Decode As table.
Definition decode_as_model.h:179
@ colProtocol
Definition decode_as_model.h:184
@ colDefault
Definition decode_as_model.h:183
@ colType
Definition decode_as_model.h:182
@ colSelector
Definition decode_as_model.h:181
enum ftenum ftenum_t
Convenience typedef for ftenum.
Definition ftypes.h:190
prefs_set_pref_e
Result of setting a preference.
Definition prefs.h:1271
Represents a capture file and its associated metadata.
Definition cfile.h:84
Definition decode_as_model.h:126
Lookup key for GUID-indexed dissector tables, combining a GUID with an optional version field.
Definition packet.h:558
A pending change to a uint-keyed dissector table entry.
Definition decode_as_model.h:161
UIntEntry(const char *t, uint32_t k, const char *pref_suffix)
Construct a UIntEntry.
Definition decode_as_model.h:171
QByteArray table
Definition decode_as_model.h:162
QByteArray pref_name
Definition decode_as_model.h:164
uint32_t key
Definition decode_as_model.h:163
Definition decode_as.h:73
Definition packet-dcerpc.h:471
Definition packet.c:852