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