Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | List of all members
DecodeAsModel Class Reference

Table model backing the Decode As dialog. More...

#include <decode_as_model.h>

Inheritance diagram for DecodeAsModel:

Classes

struct  UIntEntry
 A pending change to a uint-keyed dissector table entry. More...
 

Public Types

enum  DecodeAsColumn {
  colTable = 0 , colSelector , colType , colDefault ,
  colProtocol , colDecodeAsMax
}
 Column indices for the Decode As table. More...
 

Public Member Functions

 DecodeAsModel (QObject *parent, capture_file *cf=NULL)
 Construct a DecodeAsModel.
 
virtual ~DecodeAsModel ()
 Destroy the DecodeAsModel.
 
Qt::ItemFlags flags (const QModelIndex &index) const
 Return the item flags for the given index.
 
QVariant data (const QModelIndex &index, int role) const
 Return data for the given index and role.
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 Return header data for the given section, orientation, and role.
 
int rowCount (const QModelIndex &parent=QModelIndex()) const
 Return the number of rows in the model.
 
int columnCount (const QModelIndex &parent=QModelIndex()) const
 Return the number of columns in the model.
 
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 Set data for the given index and role.
 
void fillTable ()
 Populate the model from the current decode-as configuration.
 
void setDissectorHandle (const QModelIndex &index, dissector_handle_t dissector_handle)
 Set the dissector handle for the entry at the given index.
 
bool insertRows (int row, int count, const QModelIndex &parent=QModelIndex())
 Insert rows into the model.
 
bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
 Remove rows from the model.
 
void clearAll ()
 Remove all decode-as entries from the model.
 
bool copyRow (int dst_row, int src_row)
 Copy a row within the model.
 
bool copyFromProfile (QString filename, const char **err)
 Import decode-as entries from a Wireshark profile file.
 
void applyChanges ()
 Apply all pending decode-as changes to the dissector tables.
 

Static Public Member Functions

static QString entryString (const char *table_name, const void *value)
 Return a human-readable string describing a dissector table entry.
 

Static Protected Member Functions

static void buildChangedList (const char *table_name, ftenum_t selector_type, void *key, void *value, void *user_data)
 Callback to record a changed uint or string dissector table entry.
 
static void buildDceRpcChangedList (void *data, void *user_data)
 Callback to record a changed DCE/RPC dissector table entry.
 
static void gatherChangedEntries (const char *table_name, ftenum_t selector_type, void *key, void *value, void *user_data)
 Callback to collect entries that differ from their defaults.
 
static prefs_set_pref_e readDecodeAsEntry (char *key, const char *value, void *user_data, bool)
 Callback to parse and apply a single decode-as preference entry.
 

Detailed Description

Table model backing the Decode As dialog.

Manages the list of DecodeAsItem entries that map dissector table selectors to user-chosen dissectors, and provides methods to apply, import, and reset those mappings.

Member Enumeration Documentation

◆ DecodeAsColumn

Column indices for the Decode As table.

Enumerator
colTable 

The dissector table (aka "Field", e.g. "TCP Port").

colSelector 

The selector value (e.g., port number 80).

colType 

The field type (e.g. "Integer, base 16").

colDefault 

The initial protocol chosen by Wireshark.

colProtocol 

The current protocol selected by the user.

colDecodeAsMax 

Sentinel value; not used as a column.

Constructor & Destructor Documentation

◆ DecodeAsModel()

DecodeAsModel::DecodeAsModel ( QObject *  parent,
capture_file cf = NULL 
)

Construct a DecodeAsModel.

Parameters
parentThe parent object.
cfThe capture file, or NULL if none is open.

Member Function Documentation

◆ buildChangedList()

void DecodeAsModel::buildChangedList ( const char *  table_name,
ftenum_t  selector_type,
void *  key,
void *  value,
void *  user_data 
)
staticprotected

Callback to record a changed uint or string dissector table entry.

Parameters
table_nameThe dissector table name.
selector_typeThe field type of the selector.
keyThe selector key.
valueThe dissector handle value.
user_dataPointer to the DecodeAsModel instance.

◆ buildDceRpcChangedList()

void DecodeAsModel::buildDceRpcChangedList ( void *  data,
void *  user_data 
)
staticprotected

Callback to record a changed DCE/RPC dissector table entry.

Parameters
dataThe DCE/RPC bind values.
user_dataPointer to the DecodeAsModel instance.

◆ columnCount()

int DecodeAsModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const

Return the number of columns in the model.

Parameters
parentUnused; present for API compatibility.
Returns
The number of columns.

◆ copyFromProfile()

bool DecodeAsModel::copyFromProfile ( QString  filename,
const char **  err 
)

Import decode-as entries from a Wireshark profile file.

Parameters
filenameThe path to the profile file.
errOutput pointer for an error message on failure.
Returns
true if the import succeeded, false otherwise.

◆ copyRow()

bool DecodeAsModel::copyRow ( int  dst_row,
int  src_row 
)

Copy a row within the model.

Parameters
dst_rowThe destination row index.
src_rowThe source row index.
Returns
true if the row was copied successfully.

◆ data()

QVariant DecodeAsModel::data ( const QModelIndex &  index,
int  role 
) const

Return data for the given index and role.

Parameters
indexThe model index to query.
roleThe data role.
Returns
The data, or an invalid QVariant if unsupported.

◆ entryString()

QString DecodeAsModel::entryString ( const char *  table_name,
const void *  value 
)
static

Return a human-readable string describing a dissector table entry.

Parameters
table_nameThe dissector table name.
valueThe selector value.
Returns
A display string for the entry.

◆ flags()

Qt::ItemFlags DecodeAsModel::flags ( const QModelIndex &  index) const

Return the item flags for the given index.

Parameters
indexThe model index to query.
Returns
The item flags.

◆ gatherChangedEntries()

void DecodeAsModel::gatherChangedEntries ( const char *  table_name,
ftenum_t  selector_type,
void *  key,
void *  value,
void *  user_data 
)
staticprotected

Callback to collect entries that differ from their defaults.

Parameters
table_nameThe dissector table name.
selector_typeThe field type of the selector.
keyThe selector key.
valueThe dissector handle value.
user_dataPointer to the DecodeAsModel instance.

◆ headerData()

QVariant DecodeAsModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const

Return header data for the given section, orientation, and role.

Parameters
sectionThe section index.
orientationThe header orientation.
roleThe data role.
Returns
The header data, or an invalid QVariant if unsupported.

◆ insertRows()

bool DecodeAsModel::insertRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
)

Insert rows into the model.

Parameters
rowThe row before which to insert.
countThe number of rows to insert.
parentUnused; present for API compatibility.
Returns
true if the rows were inserted successfully.

◆ readDecodeAsEntry()

prefs_set_pref_e DecodeAsModel::readDecodeAsEntry ( char *  key,
const char *  value,
void *  user_data,
bool   
)
staticprotected

Callback to parse and apply a single decode-as preference entry.

Parameters
keyThe preference key string.
valueThe preference value string.
user_dataPointer to the DecodeAsModel instance.
Returns
The result of the preference set operation.

◆ removeRows()

bool DecodeAsModel::removeRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
)

Remove rows from the model.

Parameters
rowThe first row to remove.
countThe number of rows to remove.
parentUnused; present for API compatibility.
Returns
true if the rows were removed successfully.

◆ rowCount()

int DecodeAsModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const

Return the number of rows in the model.

Parameters
parentUnused; present for API compatibility.
Returns
The number of decode-as entries.

◆ setData()

bool DecodeAsModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)

Set data for the given index and role.

Parameters
indexThe model index to update.
valueThe new value.
roleThe data role.
Returns
true if the data was set successfully, false otherwise.

◆ setDissectorHandle()

void DecodeAsModel::setDissectorHandle ( const QModelIndex &  index,
dissector_handle_t  dissector_handle 
)

Set the dissector handle for the entry at the given index.

Parameters
indexThe model index of the entry to update.
dissector_handleThe dissector handle to assign.

The documentation for this class was generated from the following files: