diff options
Diffstat (limited to 'ui/capture_ui_utils.c')
-rw-r--r-- | ui/capture_ui_utils.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/ui/capture_ui_utils.c b/ui/capture_ui_utils.c index 1d60aed891..b6aa4ad1d8 100644 --- a/ui/capture_ui_utils.c +++ b/ui/capture_ui_utils.c @@ -549,6 +549,56 @@ set_active_dlt(interface_t *device, int global_default_dlt) } } +GString * +get_iface_list_string(capture_options *capture_opts, guint32 style) +{ + GString *iface_list_string = g_string_new(""); + guint i; + + /* + * If we have a descriptive name for the interface, show that, + * rather than its raw name. On NT 5.x (2K/XP/Server2K3), the + * interface name is something like "\Device\NPF_{242423..." + * which is pretty useless to the normal user. On other platforms, + * it might be less cryptic, but if a more descriptive name is + * available, we should still use that. + */ +#ifdef _WIN32 + if (capture_opts->ifaces->len < 2) { +#else + if (capture_opts->ifaces->len < 4) { +#endif + for (i = 0; i < capture_opts->ifaces->len; i++) { + if (i > 0) { + if (capture_opts->ifaces->len > 2) { + g_string_append_printf(iface_list_string, ","); + } + g_string_append_printf(iface_list_string, " "); + if (i == capture_opts->ifaces->len - 1) { + g_string_append_printf(iface_list_string, "and "); + } + } + if (style & IFLIST_QUOTE_IF_DESCRIPTION) + g_string_append_printf(iface_list_string, "'"); + g_string_append_printf(iface_list_string, "%s", get_iface_description_for_interface(capture_opts, i)); + if (style & IFLIST_QUOTE_IF_DESCRIPTION) + g_string_append_printf(iface_list_string, "'"); + if (style & IFLIST_SHOW_FILTER) { + interface_options interface_opts; + + interface_opts = g_array_index(capture_opts->ifaces, interface_options, i); + if (interface_opts.cfilter != NULL && + strlen(interface_opts.cfilter) > 0) { + g_string_append_printf(iface_list_string, " (%s)", interface_opts.cfilter); + } + } + } + } else { + g_string_append_printf(iface_list_string, "%u interfaces", capture_opts->ifaces->len); + } + return iface_list_string; +} + #endif /* HAVE_LIBPCAP */ /* |