aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2014-09-11 18:03:31 -0700
committerGerald Combs <gerald@wireshark.org>2014-09-17 18:49:37 +0000
commit478fab5206bf30a639ec9ba71edff2fb6ec2cad4 (patch)
tree4193cf3be89df709b902f38459c5f955c0efae1d /ui
parentf0b44117831a502027799cd01c4537422ed466b6 (diff)
Qt: Remove duplicate GeoIP columns.
Different GeoIP databases have the same column name, e.g. "City" currently matches two revisions each for IPv4 and IPv6. Map each uniquely named column to a list of databases and populate EndpointTreeWidgetItem columns based on the first database match. Fix a copy/pasteo introduced in g30f3d52: Make sure geoip_db_lookup_ipv[46] returns longitude instead of latitude. Change-Id: Idd31f976dfd1cb011cfa7b5aec14b7031ee0e25e Reviewed-on: https://code.wireshark.org/review/4157 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/endpoint_dialog.cpp45
-rw-r--r--ui/qt/endpoint_dialog.h9
2 files changed, 37 insertions, 17 deletions
diff --git a/ui/qt/endpoint_dialog.cpp b/ui/qt/endpoint_dialog.cpp
index 81c5756eda..9855c11566 100644
--- a/ui/qt/endpoint_dialog.cpp
+++ b/ui/qt/endpoint_dialog.cpp
@@ -38,7 +38,6 @@
#include <QMessageBox>
-
const QString table_name_ = QObject::tr("Endpoint");
EndpointDialog::EndpointDialog(QWidget *parent, capture_file *cf, int cli_proto_id, const char *filter) :
TrafficTableDialog(parent, cf, filter, table_name_)
@@ -220,14 +219,22 @@ public:
#ifdef HAVE_GEOIP
/* Filled in from the GeoIP config, if any */
- for (unsigned i = 0; i < geoip_db_num_dbs(); i++) {
- if (endp_item->myaddress.type == AT_IPv4) {
- setText(ENDP_NUM_COLUMNS+i, geoip_db_lookup_ipv4(i, pntoh32(endp_item->myaddress.data), geoip_none_));
- } else if (endp_item->myaddress.type == AT_IPv6) {
- const struct e_in6_addr *addr = (const struct e_in6_addr *) endp_item->myaddress.data;
- setText(ENDP_NUM_COLUMNS+i, geoip_db_lookup_ipv6(i, *addr, geoip_none_));
- } else {
- setText(ENDP_NUM_COLUMNS+i, geoip_none_);
+ EndpointTreeWidget *ep_tree = qobject_cast<EndpointTreeWidget *>(treeWidget());
+ if (ep_tree) {
+ for (int col = ENDP_NUM_COLUMNS; col < ep_tree->columnCount(); col++) {
+ const char *col_text = NULL;
+ foreach (unsigned db, ep_tree->columnToDb(col)) {
+ if (endp_item->myaddress.type == AT_IPv4) {
+ col_text = geoip_db_lookup_ipv4(db, pntoh32(endp_item->myaddress.data), NULL);
+ } else if (endp_item->myaddress.type == AT_IPv6) {
+ const struct e_in6_addr *addr = (const struct e_in6_addr *) endp_item->myaddress.data;
+ col_text = geoip_db_lookup_ipv6(db, *addr, NULL);
+ }
+ if (col_text) {
+ break;
+ }
+ }
+ setText(col, col_text ? col_text : geoip_none_);
}
}
#endif
@@ -354,11 +361,7 @@ public:
EndpointTreeWidget::EndpointTreeWidget(QWidget *parent, register_ct_t *table) :
TrafficTableTreeWidget(parent, table)
{
-#ifdef HAVE_GEOIP
- setColumnCount(ENDP_NUM_COLUMNS + geoip_db_num_dbs());
-#else
setColumnCount(ENDP_NUM_COLUMNS);
-#endif
for (int i = 0; i < ENDP_NUM_COLUMNS; i++) {
headerItem()->setText(i, endp_column_titles[i]);
@@ -371,9 +374,19 @@ EndpointTreeWidget::EndpointTreeWidget(QWidget *parent, register_ct_t *table) :
}
#ifdef HAVE_GEOIP
- for (unsigned i = 0; i < geoip_db_num_dbs(); i++) {
- headerItem()->setText(ENDP_NUM_COLUMNS + i, geoip_db_name(i));
- hideColumn(ENDP_NUM_COLUMNS + i);
+ QMap<QString, int> db_name_to_col;
+ for (unsigned db = 0; db < geoip_db_num_dbs(); db++) {
+ QString db_name = geoip_db_name(db);
+ int col = db_name_to_col.value(db_name, -1);
+
+ if (col < 0) {
+ col = columnCount();
+ setColumnCount(col + 1);
+ headerItem()->setText(col, db_name);
+ hideColumn(col);
+ db_name_to_col[db_name] = col;
+ }
+ col_to_db_[col] << db;
}
#endif
diff --git a/ui/qt/endpoint_dialog.h b/ui/qt/endpoint_dialog.h
index bc9744ad9c..b97cb53486 100644
--- a/ui/qt/endpoint_dialog.h
+++ b/ui/qt/endpoint_dialog.h
@@ -36,10 +36,17 @@ public:
static void tapReset(void *conv_hash_ptr);
static void tapDraw(void *conv_hash_ptr);
+#ifdef HAVE_GEOIP
+public:
+ const QList<int> columnToDb(int column) const { return col_to_db_.value(column, QList<int>()); }
+
+private:
+ QMap<int, QList<int> > col_to_db_; // Map tree columns to GeoIP databases
+#endif
+
private slots:
void updateItems();
void filterActionTriggered();
-
};
class EndpointDialog : public TrafficTableDialog