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