Wireshark  4.3.0
The Wireshark network protocol analyzer
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 {
28 public:
29  DecodeAsItem(const char *table_name = NULL, gconstpointer selector = NULL);
30  DecodeAsItem(const decode_as_t *entry, gconstpointer 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 
47 private:
48  void init(const char *table_name, gconstpointer 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 
64 class DecodeAsModel : public QAbstractTableModel
65 {
66  Q_OBJECT
67 
68 public:
69  DecodeAsModel(QObject *parent, capture_file *cf = NULL);
70  virtual ~DecodeAsModel();
71 
72  enum DecodeAsColumn {
73  colTable = 0, // aka "Field" (or dissector table like "TCP Port")
74  colSelector, // the actual table value (e.g., port number 80)
75  colType, // field type (e.g. "Integer, base 16")
76  colDefault, // aka "initial" protocol chosen by Wireshark
77  colProtocol, // aka "current" protocol selected by user
78  colDecodeAsMax //not used
79  };
80 
81  Qt::ItemFlags flags(const QModelIndex &index) const;
82  QVariant data(const QModelIndex &index, int role) const;
83  QVariant headerData(int section, Qt::Orientation orientation,
84  int role = Qt::DisplayRole) const;
85  int rowCount(const QModelIndex &parent = QModelIndex()) const;
86  int columnCount(const QModelIndex &parent = QModelIndex()) const;
87 
88  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
89  void fillTable();
90 
91  void setDissectorHandle(const QModelIndex &index, dissector_handle_t dissector_handle);
92 
93  bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
94  bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
95  void clearAll();
96  bool copyRow(int dst_row, int src_row);
97  bool copyFromProfile(QString filename, const char **err);
98 
99  static QString entryString(const char *table_name, gconstpointer value);
100 
101  void applyChanges();
102 
103 protected:
104  static void buildChangedList(const char *table_name, ftenum_t selector_type,
105  void *key, void *value, void *user_data);
106  static void buildDceRpcChangedList(void *data, void *user_data);
107  static void gatherChangedEntries(const char *table_name, ftenum_t selector_type,
108  void *key, void *value, void *user_data);
109  static prefs_set_pref_e readDecodeAsEntry(char *key, const char *value,
110  void *user_data, bool);
111 
112 private:
113  capture_file *cap_file_;
114  QList<DecodeAsItem *> decode_as_items_;
115  QList<QPair<const char *, uint32_t> > changed_uint_entries_;
116  QList<QPair<const char *, const char *> > changed_string_entries_;
117 };
118 
119 #endif // DECODE_AS_MODEL_H
Definition: decode_as_model.h:27
Definition: decode_as_model.h:65
prefs_set_pref_e
Definition: prefs.h:959
Definition: cfile.h:67
Definition: decode_as.h:71
Definition: packet-dcerpc.h:487
Definition: packet.c:763