void DecodeAsDialog::on_decodeAsTreeWidget_itemActivated(QTreeWidgetItem *item, int column) { Q_UNUSED(column); GList *cur; table_names_combo_box_ = new QComboBox(); QString current_text = item->text(table_col_); QSet<QString> da_set; // If a packet is selected group its tables at the top in order // from last-dissected to first. for (cur = decode_as_list; cur; cur = cur->next) { decode_as_t *entry = (decode_as_t *) cur->data; const char *table_name = get_dissector_table_ui_name(entry->table_name); if (table_name) { da_set.insert(get_dissector_table_ui_name(entry->table_name)); } } if (cap_file_ && cap_file_->edt) { bool copying = !current_text.isEmpty(); wmem_list_frame_t * protos = wmem_list_head(cap_file_->edt->pi.layers); while (protos != NULL) { int proto_id = GPOINTER_TO_INT(wmem_list_frame_data(protos)); const gchar * proto_name = proto_get_protocol_filter_name(proto_id); for (cur = decode_as_list; cur; cur = cur->next) { decode_as_t *entry = (decode_as_t *) cur->data; if (g_strcmp0(proto_name, entry->name) == 0) { QString table_ui_name = get_dissector_table_ui_name(entry->table_name); table_names_combo_box_->insertItem(0, table_ui_name, entry->table_name); da_set.remove(table_ui_name); if (!copying) { current_text = table_ui_name; } } } protos = wmem_list_frame_next(protos); } } if (table_names_combo_box_->count() > 0) { table_names_combo_box_->insertSeparator(table_names_combo_box_->count()); } QList<QString> da_list = da_set.toList(); qSort(da_list.begin(), da_list.end()); foreach (QString table_ui_name, da_list) { table_names_combo_box_->addItem(table_ui_name, ui_name_to_name_[table_ui_name]); }
DecodeAsDialog::DecodeAsDialog(QWidget *parent, capture_file *cf, bool create_new) : QDialog(parent), ui(new Ui::DecodeAsDialog), cap_file_(cf), table_names_combo_box_(NULL), selector_combo_box_(NULL) { ui->setupUi(this); setWindowTitle(wsApp->windowTitleString(tr("Decode As" UTF8_HORIZONTAL_ELLIPSIS))); ui->deleteToolButton->setEnabled(false); GList *cur; for (cur = decode_as_list; cur; cur = cur->next) { decode_as_t *entry = (decode_as_t *) cur->data; QString table_ui_name = get_dissector_table_ui_name(entry->table_name); if (!table_ui_name.isEmpty()) { ui_name_to_name_[table_ui_name] = entry->table_name; } } connect(wsApp, SIGNAL(preferencesChanged()), this, SLOT(fillTable())); fillTable(); if (create_new) on_newToolButton_clicked(); }
/* * This routine creates one entry in the list of protocol dissector * that have been changed. It is called by the g_hash_foreach routine * once for each changed entry in a dissector table. * * @param table_name The table name in which this dissector is found. * * @param key A pointer to the key for this entry in the dissector * hash table. This is generally the numeric selector of the * protocol, i.e. the ethernet type code, IP port number, TCP port * number, etc. * * @param value A pointer to the value for this entry in the dissector * hash table. This is an opaque pointer that can only be handed back * to routine in the file packet.c * * @param user_data A pointer to the list in which this information * should be stored. */ static void decode_build_show_list (const gchar *table_name, ftenum_t selector_type, gpointer key, gpointer value, gpointer user_data) { dissector_handle_t current, initial; const gchar *current_proto_name, *initial_proto_name; gchar *selector_name; gchar string1[20]; da_entry_t *entry; entry = g_new(da_entry_t,1); g_assert(user_data); g_assert(value); current = dtbl_entry_get_handle((dtbl_entry_t *)value); if (current == NULL) current_proto_name = DECODE_AS_NONE; else current_proto_name = dissector_handle_get_short_name(current); initial = dtbl_entry_get_initial_handle((dtbl_entry_t *)value); if (initial == NULL) initial_proto_name = DECODE_AS_NONE; else initial_proto_name = dissector_handle_get_short_name(initial); switch (selector_type) { case FT_UINT8: case FT_UINT16: case FT_UINT24: case FT_UINT32: switch (get_dissector_table_param(table_name)) { case BASE_DEC: g_snprintf(string1, sizeof(string1), "%u", GPOINTER_TO_UINT(key)); break; case BASE_HEX: switch (get_dissector_table_selector_type(table_name)) { case FT_UINT8: g_snprintf(string1, sizeof(string1), "0x%02x", GPOINTER_TO_UINT(key)); break; case FT_UINT16: g_snprintf(string1, sizeof(string1), "0x%04x", GPOINTER_TO_UINT(key)); break; case FT_UINT24: g_snprintf(string1, sizeof(string1), "0x%06x", GPOINTER_TO_UINT(key)); break; case FT_UINT32: g_snprintf(string1, sizeof(string1), "0x%08x", GPOINTER_TO_UINT(key)); break; default: g_assert_not_reached(); break; } break; case BASE_OCT: g_snprintf(string1, sizeof(string1), "%#o", GPOINTER_TO_UINT(key)); break; } selector_name = string1; break; case FT_STRING: case FT_STRINGZ: case FT_UINT_STRING: case FT_STRINGZPAD: selector_name = (gchar *)key; break; default: g_assert_not_reached(); selector_name = NULL; break; } decode_add_to_show_list ( user_data, get_dissector_table_ui_name(table_name), selector_name, initial_proto_name, current_proto_name); entry->table = g_strdup(table_name); entry->selector = GPOINTER_TO_UINT(key); entry->initial = g_strdup(initial_proto_name); entry->current = g_strdup(current_proto_name); da_entries = g_slist_append(da_entries, entry); }