forked from osmocom/wireshark
Qt: fix missing IP hosts in Resolved Addresses dialog
Fix several issues in the Resolved Addresses dialog: - Missing IP hosts because the list was populated with one tab-separated item while the caller expected space-separated items. - Fix duplicate entries due to the "values" list not being cleared. - Remove IPv4/IPv6 Hash Tables since these are a superset of IPv4/IPv6 Hosts, except that the former also includes mappings without a known name (e.g. 8.8.8.8 -> 8.8.8.8). - Fold both IPv4 and IPv6 hosts into one as before. Users like me usually look for any IP match, regardless of the address family. - Minor optimizations: do not construct the label every time. - Rename "Mac Address" [sic] to simply "Address", that covers both IP addresses and MAC addresses. Bug: 16366 Change-Id: I6253fc01da7b6429ce093e7db9fe58e235b7c137 Fixes: v3.1.1rc0-244-g743f8598cd0b ("Qt: Rework Resolved Addresses dialog") Reviewed-on: https://code.wireshark.org/review/36022 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
fcc90461fb
commit
0596047e3f
|
@ -37,63 +37,27 @@ serv_port_hash_to_qstringlist(gpointer key, gpointer value, gpointer sl_ptr)
|
|||
}
|
||||
|
||||
static void
|
||||
ipv4_hash_table_resolved_to_qstringlist(gpointer, gpointer value, gpointer sl_ptr)
|
||||
ipv4_hash_table_resolved_to_list(gpointer, gpointer value, gpointer sl_ptr)
|
||||
{
|
||||
QStringList *string_list = (QStringList *) sl_ptr;
|
||||
QList<QStringList> *hosts = (QList<QStringList> *) sl_ptr;
|
||||
hashipv4_t *ipv4_hash_table_entry = (hashipv4_t *) value;
|
||||
|
||||
if ((ipv4_hash_table_entry->flags & NAME_RESOLVED)) {
|
||||
QString entry = QString("%1\t%2")
|
||||
.arg(ipv4_hash_table_entry->ip)
|
||||
.arg(ipv4_hash_table_entry->name);
|
||||
*string_list << entry;
|
||||
*hosts << (QStringList() << QString(ipv4_hash_table_entry->ip) << QString(ipv4_hash_table_entry->name));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ipv6_hash_table_resolved_to_qstringlist(gpointer, gpointer value, gpointer sl_ptr)
|
||||
ipv6_hash_table_resolved_to_list(gpointer, gpointer value, gpointer sl_ptr)
|
||||
{
|
||||
QStringList *string_list = (QStringList *) sl_ptr;
|
||||
QList<QStringList> *hosts = (QList<QStringList> *) sl_ptr;
|
||||
hashipv6_t *ipv6_hash_table_entry = (hashipv6_t *) value;
|
||||
|
||||
if ((ipv6_hash_table_entry->flags & NAME_RESOLVED)) {
|
||||
QString entry = QString("%1\t%2")
|
||||
.arg(ipv6_hash_table_entry->ip6)
|
||||
.arg(ipv6_hash_table_entry->name);
|
||||
*string_list << entry;
|
||||
*hosts << (QStringList() << QString(ipv6_hash_table_entry->ip6) << QString(ipv6_hash_table_entry->name));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ipv4_hash_table_to_qstringlist(gpointer key, gpointer value, gpointer sl_ptr)
|
||||
{
|
||||
QStringList *string_list = (QStringList *) sl_ptr;
|
||||
hashipv4_t *ipv4_hash_table_entry = (hashipv4_t *)value;
|
||||
guint addr = GPOINTER_TO_UINT(key);
|
||||
|
||||
QString entry = QString("Key: 0x%1 IPv4: %2, Name: %3")
|
||||
.arg(QString::number(addr, 16))
|
||||
.arg(ipv4_hash_table_entry->ip)
|
||||
.arg(ipv4_hash_table_entry->name);
|
||||
|
||||
*string_list << entry;
|
||||
}
|
||||
|
||||
static void
|
||||
ipv6_hash_table_to_qstringlist(gpointer key, gpointer value, gpointer sl_ptr)
|
||||
{
|
||||
QStringList *string_list = (QStringList *) sl_ptr;
|
||||
hashipv6_t *ipv6_hash_table_entry = (hashipv6_t *)value;
|
||||
guint addr = GPOINTER_TO_UINT(key);
|
||||
|
||||
QString entry = QString("Key: 0x%1 IPv4: %2, Name: %3")
|
||||
.arg(QString::number(addr, 16))
|
||||
.arg(ipv6_hash_table_entry->ip6)
|
||||
.arg(ipv6_hash_table_entry->name);
|
||||
|
||||
*string_list << entry;
|
||||
}
|
||||
|
||||
static void
|
||||
eth_hash_to_qstringlist(gpointer, gpointer value, gpointer sl_ptr)
|
||||
{
|
||||
|
@ -152,61 +116,44 @@ EthernetAddressModel::EthernetAddressModel(QObject * parent):
|
|||
|
||||
QStringList EthernetAddressModel::headerColumns() const
|
||||
{
|
||||
return QStringList() << tr("Type") << tr("Mac Address") << tr("Name");
|
||||
return QStringList() << tr("Type") << tr("Address") << tr("Name");
|
||||
}
|
||||
|
||||
QStringList EthernetAddressModel::filterValues() const
|
||||
{
|
||||
return QStringList()
|
||||
<< tr("All entries")
|
||||
<< tr("IPv4 Hosts") << tr("IPv4 Hash Table")
|
||||
<< tr("IPv6 Hosts") << tr("IPv6 Hash Table")
|
||||
<< tr("Hosts")
|
||||
<< tr("Ethernet Addresses") << tr("Ethernet Manufacturers")
|
||||
<< tr("Ethernet Well-Known Addresses");
|
||||
}
|
||||
|
||||
void EthernetAddressModel::populate()
|
||||
{
|
||||
QList<QStringList> hosts; // List of (address, names)
|
||||
if (wmem_map_t *ipv4_hash_table = get_ipv4_hash_table()) {
|
||||
wmem_map_foreach(ipv4_hash_table, ipv4_hash_table_resolved_to_list, &hosts);
|
||||
}
|
||||
if (wmem_map_t *ipv6_hash_table = get_ipv6_hash_table()) {
|
||||
wmem_map_foreach(ipv6_hash_table, ipv6_hash_table_resolved_to_list, &hosts);
|
||||
}
|
||||
const QString &hosts_label = tr("Hosts");
|
||||
foreach (const QStringList &addr_name, hosts)
|
||||
appendRow(QStringList() << hosts_label << addr_name);
|
||||
|
||||
QStringList values;
|
||||
wmem_map_t *ipv4_hash_table = get_ipv4_hash_table();
|
||||
if (ipv4_hash_table) {
|
||||
wmem_map_foreach(ipv4_hash_table, ipv4_hash_table_resolved_to_qstringlist, &values);
|
||||
foreach(QString line, values)
|
||||
appendRow(QStringList() << tr("IPv4 Hosts") << line.split(" "));
|
||||
wmem_map_foreach(ipv4_hash_table, ipv4_hash_table_to_qstringlist, &values);
|
||||
foreach(QString line, values)
|
||||
appendRow(QStringList() << tr("IPv4 Hash Table") << line.split(" "));
|
||||
}
|
||||
|
||||
wmem_map_t *ipv6_hash_table = get_ipv6_hash_table();
|
||||
if (ipv6_hash_table) {
|
||||
wmem_map_foreach(ipv6_hash_table, ipv6_hash_table_resolved_to_qstringlist, &values);
|
||||
foreach(QString line, values)
|
||||
appendRow(QStringList() << tr("IPv6 Hosts") << line.split(" "));
|
||||
wmem_map_foreach(ipv6_hash_table, ipv6_hash_table_to_qstringlist, &values);
|
||||
foreach(QString line, values)
|
||||
appendRow(QStringList() << tr("IPv6 Hash Table") << line.split(" "));
|
||||
}
|
||||
|
||||
wmem_map_t *eth_hashtable = get_eth_hashtable();
|
||||
if (eth_hashtable)
|
||||
if (wmem_map_t *eth_hashtable = get_eth_hashtable()) {
|
||||
wmem_map_foreach(eth_hashtable, eth_hash_to_qstringlist, &values);
|
||||
foreach(QString line, values)
|
||||
appendRow(QStringList() << tr("Ethernet Addresses") << line.split(" "));
|
||||
|
||||
eth_hashtable = get_manuf_hashtable();
|
||||
if (eth_hashtable)
|
||||
}
|
||||
if (wmem_map_t *eth_hashtable = get_manuf_hashtable()) {
|
||||
wmem_map_foreach(eth_hashtable, manuf_hash_to_qstringlist, &values);
|
||||
|
||||
foreach(QString line, values)
|
||||
appendRow(QStringList() << tr("Ethernet Manufacturers") << line.split(" "));
|
||||
|
||||
eth_hashtable = get_wka_hashtable();
|
||||
if (eth_hashtable)
|
||||
}
|
||||
if (wmem_map_t *eth_hashtable = get_wka_hashtable()) {
|
||||
wmem_map_foreach(eth_hashtable, wka_hash_to_qstringlist, &values);
|
||||
|
||||
foreach(QString line, values)
|
||||
appendRow(QStringList() << tr("Ethernet Well-Known Addresses") << line.split(" "));
|
||||
}
|
||||
const QString &wka_label = tr("Ethernet Well-Known Addresses");
|
||||
foreach (const QString &line, values)
|
||||
appendRow(QStringList() << wka_label << line.split(" "));
|
||||
}
|
||||
|
||||
PortsModel::PortsModel(QObject * parent):
|
||||
|
|
Loading…
Reference in New Issue