Wireshark 4.5.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 "cfile.h"
21
22#include <epan/packet.h>
23#include <epan/decode_as.h>
24#include <epan/dissectors/packet-dcerpc.h>
25
27{
28public:
29 DecodeAsItem(const char *table_name = NULL, const void *selector = NULL);
30 DecodeAsItem(const decode_as_t *entry, const void *selector = NULL);
31 virtual ~DecodeAsItem();
32
33 const char* tableName() const { return tableName_; }
34 const char* tableUIName() const { return tableUIName_; }
35 uint selectorUint() const { return selectorUint_; }
36 QString selectorString() const { return selectorString_; }
37 decode_dcerpc_bind_values_t* selectorDCERPC() const { return selectorDCERPC_; }
38 QString defaultDissector() const { return default_dissector_; }
39 QString currentDissector() const { return current_dissector_; }
40 dissector_handle_t dissectorHandle() const { return dissector_handle_; }
41 void setTable(const decode_as_t *entry);
42 void setSelector(const QString &value);
43 void setDissectorHandle(dissector_handle_t handle);
44
45 void updateHandles();
46
47private:
48 void init(const char *table_name, const void *selector = NULL);
49
50 const char* tableName_;
51 const char* tableUIName_;
52
53 //save our sanity and not have to worry about memory management
54 //between (lack of) persistent data in GUI and underlying data
55 uint selectorUint_;
56 QString selectorString_;
57 decode_dcerpc_bind_values_t* selectorDCERPC_; //for special handling of DCE/RPC
58
59 QString default_dissector_;
60 QString current_dissector_;
61 dissector_handle_t dissector_handle_;
62};
63
64class DecodeAsModel : public QAbstractTableModel
65{
66 Q_OBJECT
67
68public:
69 DecodeAsModel(QObject *parent, capture_file *cf = NULL);
70 virtual ~DecodeAsModel();
71
72 struct UIntEntry {
73 QByteArray table;
74 uint32_t key;
75 QByteArray pref_name;
76
77 UIntEntry(const char* t, uint32_t k, const char* pref_suffix) :
78 table(t), key(k), pref_name(t) { pref_name.append(pref_suffix); }
79 };
80
81 enum DecodeAsColumn {
82 colTable = 0, // aka "Field" (or dissector table like "TCP Port")
83 colSelector, // the actual table value (e.g., port number 80)
84 colType, // field type (e.g. "Integer, base 16")
85 colDefault, // aka "initial" protocol chosen by Wireshark
86 colProtocol, // aka "current" protocol selected by user
87 colDecodeAsMax //not used
88 };
89
90 Qt::ItemFlags flags(const QModelIndex &index) const;
91 QVariant data(const QModelIndex &index, int role) const;
92 QVariant headerData(int section, Qt::Orientation orientation,
93 int role = Qt::DisplayRole) const;
94 int rowCount(const QModelIndex &parent = QModelIndex()) const;
95 int columnCount(const QModelIndex &parent = QModelIndex()) const;
96
97 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
98 void fillTable();
99
100 void setDissectorHandle(const QModelIndex &index, dissector_handle_t dissector_handle);
101
102 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
103 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
104 void clearAll();
105 bool copyRow(int dst_row, int src_row);
106 bool copyFromProfile(QString filename, const char **err);
107
108 static QString entryString(const char *table_name, const void *value);
109
110 void applyChanges();
111
112protected:
113 static void buildChangedList(const char *table_name, ftenum_t selector_type,
114 void *key, void *value, void *user_data);
115 static void buildDceRpcChangedList(void *data, void *user_data);
116 static void gatherChangedEntries(const char *table_name, ftenum_t selector_type,
117 void *key, void *value, void *user_data);
118 static prefs_set_pref_e readDecodeAsEntry(char *key, const char *value,
119 void *user_data, bool);
120
121private:
122 capture_file *cap_file_;
123 QList<DecodeAsItem *> decode_as_items_;
124 QList<UIntEntry> changed_uint_entries_;
125 QList<QPair<const char *, const char *> > changed_string_entries_;
126};
127
128#endif // DECODE_AS_MODEL_H
Definition decode_as_model.h:27
Definition decode_as_model.h:65
prefs_set_pref_e
Definition prefs.h:983
Definition cfile.h:67
Definition decode_as_model.h:72
Definition decode_as.h:71
Definition packet-dcerpc.h:488
Definition packet.c:763