diff options
author | Guy Harris <guy@alum.mit.edu> | 2012-11-24 18:55:06 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2012-11-24 18:55:06 +0000 |
commit | 319891ade38636ee181b2fac91405f21b694d3fd (patch) | |
tree | e3d3bb684eb15922766339717abe7f55d8fcfbb9 /capture-pcap-util.c | |
parent | 67ea470cc872282ebf53ad55435763b213cb29be (diff) | |
download | wireshark-319891ade38636ee181b2fac91405f21b694d3fd.tar.gz |
Put the code to convert a GUID string to a GUID structure into a routine
of its own. Export that routine from capture_win_ifnames.c.
Rename GetInterfaceFriendlyNameFromDeviceGuid() to
get_interface_friendly_name_from_device_guid(), to match the style of
names of the other routines exported from capture_win_ifnames.c, and
export it as well.
Have if_info_new() use those routines, and, if parse_as_guid() fails,
treat the "description" as a friendly name rather than a vendor
description, so that we don't have a vendor description for, for
example, the device offered on some versions of Windows to handle
dial-up devices.
svn path=/trunk/; revision=46170
Diffstat (limited to 'capture-pcap-util.c')
-rw-r--r-- | capture-pcap-util.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/capture-pcap-util.c b/capture-pcap-util.c index e1ce888695..7e843220b1 100644 --- a/capture-pcap-util.c +++ b/capture-pcap-util.c @@ -62,6 +62,10 @@ if_info_t * if_info_new(const char *name, const char *description, gboolean loopback) { if_info_t *if_info; +#ifdef _WIN32 + const char *guid_text; + GUID guid; +#endif if_info = (if_info_t *)g_malloc(sizeof (if_info_t)); if_info->name = g_strdup(name); @@ -71,8 +75,37 @@ if_info_new(const char *name, const char *description, gboolean loopback) * and the friendly name isn't returned by WinPcap. * Fetch it ourselves. */ - if_info->friendly_name = get_windows_interface_friendly_name(name); - if_info->vendor_description = g_strdup(description); + + /* + * Skip over the "\Device\NPF_" prefix in the device name, + * if present. + */ + if (strncmp("\\Device\\NPF_", name, 12) == 0) + guid_text = name + 12; + else + guid_text = name; + + /* Now try to parse what remains as a GUID. */ + if (parse_as_guid(guid_text, &guid)) { + /* + * Success. Try to get a friendly name using the GUID. + * As this is a regular interface, the description is a + * vendor description. + */ + if_info->friendly_name = get_interface_friendly_name_from_device_guid(&guid); + if_info->vendor_description = g_strdup(description); + } else { + /* + * This is probably not a regular interface; we only + * support NT 5 (W2K) and later, so all regular interfaces + * should have GUIDs at the end of the name. Therefore, + * the description, if supplied, is a friendly name + * provided by WinPcap, and there is no vendor + * description. + */ + if_info->friendly_name = g_strdup(description); + if_info->description = NULL; + } #else /* * On UN*X, if there is a description, it's a friendly |