summaryrefslogtreecommitdiff
path: root/ui/capture_ui_utils.c
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2015-12-02 07:32:48 +0100
committerAnders Broman <a.broman58@gmail.com>2015-12-02 09:57:35 +0000
commit631172f2f4046255a78a5628b5499f38054039bb (patch)
tree640e725ead042cea2baee469451fe7eb5ce8dfa0 /ui/capture_ui_utils.c
parent3f3de12a881d2fba2d733fda0b3dad2f025cc0b9 (diff)
downloadwireshark-631172f2f4046255a78a5628b5499f38054039bb.tar.gz
Qt: Use uniform interface display name
Use common function to generate the interface display name, both when scanning for interfaces (scan_local_interfaces()) and when changing Comment in the Manage Interfaces dialog. Change-Id: I3260208856563aaf387ce397d4ae61bddcc89b4f Reviewed-on: https://code.wireshark.org/review/12362 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/capture_ui_utils.c')
-rw-r--r--ui/capture_ui_utils.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/ui/capture_ui_utils.c b/ui/capture_ui_utils.c
index b6aa4ad1d8..36e75b37e9 100644
--- a/ui/capture_ui_utils.c
+++ b/ui/capture_ui_utils.c
@@ -599,6 +599,48 @@ get_iface_list_string(capture_options *capture_opts, guint32 style)
return iface_list_string;
}
+gchar *
+get_iface_display_name(const gchar *description, const if_info_t *if_info)
+{
+ if (description && description[0]) {
+ /* We have a user-supplied description. */
+#ifdef _WIN32
+ gchar *if_string = if_info->friendly_name ? if_info->friendly_name : if_info->name;
+ return g_strdup_printf("%s: %s", description, if_string);
+#else
+ return g_strdup_printf("%s: %s", description, if_info->name);
+#endif
+ }
+
+ if (if_info->friendly_name) {
+ /* We have a friendly name from the OS. */
+#ifdef _WIN32
+ /*
+ * On Windows, if we have a friendly name, just show it,
+ * don't show the name, as that's a string made out of
+ * the device GUID, and not at all friendly.
+ */
+ return g_strdup_printf("%s", if_info->friendly_name);
+#else
+ /*
+ * On UN*X, if we have a friendly name, show it along
+ * with the interface name; the interface name is short
+ * and somewhat friendly, and many UN*X users are used
+ * to interface names, so we should show it.
+ */
+ return g_strdup_printf("%s: %s", if_info->friendly_name, if_info->name);
+#endif
+ }
+
+ if (if_info->vendor_description) {
+ /* We have a device description from libpcap. */
+ return g_strdup_printf("%s: %s", if_info->vendor_description, if_info->name);
+ }
+
+ /* No additional descriptions found. */
+ return g_strdup(if_info->name);
+}
+
#endif /* HAVE_LIBPCAP */
/*