QString DecodeAsDialog::entryString(const gchar *table_name, gpointer value) { QString entry_str; ftenum_t selector_type = get_dissector_table_selector_type(table_name); switch (selector_type) { case FT_UINT8: case FT_UINT16: case FT_UINT24: case FT_UINT32: { uint num_val = GPOINTER_TO_UINT(value); switch (get_dissector_table_base(table_name)) { case BASE_DEC: entry_str = QString::number(num_val); break; case BASE_HEX: int width; switch (selector_type) { case FT_UINT8: width = 2; break; case FT_UINT16: width = 4; break; case FT_UINT24: width = 6; break; case FT_UINT32: width = 8; break; default: g_assert_not_reached(); break; } entry_str = QString("0x%1").arg(num_val, width, 16, QChar('0')); break; case BASE_OCT: entry_str = "0" + QString::number(num_val, 8); break; } break; } case FT_STRING: case FT_STRINGZ: entry_str = (char *)value; break; default: g_assert_not_reached(); break; } return entry_str; }
/* * 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); }