aboutsummaryrefslogtreecommitdiffstats
path: root/capture-pcap-util-unix.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2012-11-22 06:02:49 +0000
committerGuy Harris <guy@alum.mit.edu>2012-11-22 06:02:49 +0000
commitbd976ae6c06b2111bd82df16b77739731dc17402 (patch)
tree406d65d00129abb45868150687f267a139bbf670 /capture-pcap-util-unix.c
parentb9e8e95ffe9f352cde5847d458081826523cf46f (diff)
On UN*X, if an interface has a description, use it as the "friendly
name". If it doesn't have a description, on OS X, use the System Configuration framework to attempt to get a "friendly name" for interfaces. If a loopback device doesn't have a friendly name, give it "Loopback" as the friendly name. Move the "turn a CFString into a mallocated C string" routine into common code, as it's used in more than one place. svn path=/trunk/; revision=46131
Diffstat (limited to 'capture-pcap-util-unix.c')
-rw-r--r--capture-pcap-util-unix.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/capture-pcap-util-unix.c b/capture-pcap-util-unix.c
index df78f03176..6149acc675 100644
--- a/capture-pcap-util-unix.c
+++ b/capture-pcap-util-unix.c
@@ -119,6 +119,7 @@ get_interface_list(int *err, char **err_str)
char *buf;
if_info_t *if_info;
char errbuf[PCAP_ERRBUF_SIZE];
+ gboolean loopback;
if (sock < 0) {
*err = CANT_GET_INTERFACE_LIST;
@@ -234,14 +235,14 @@ get_interface_list(int *err, char **err_str)
* don't want a loopback interface to be the default capture
* device unless there are no non-loopback devices.
*/
- if_info = if_info_new(ifr->ifr_name, NULL);
+ loopback = ((ifrflags.ifr_flags & IFF_LOOPBACK) ||
+ strncmp(ifr->ifr_name, "lo", 2) == 0);
+ if_info = if_info_new(ifr->ifr_name, loopback ? "Loopback" : NULL,
+ NULL, loopback);
if_info_add_address(if_info, &ifr->ifr_addr);
- if ((ifrflags.ifr_flags & IFF_LOOPBACK) ||
- strncmp(ifr->ifr_name, "lo", 2) == 0) {
- if_info->loopback = TRUE;
+ if (loopback)
il = g_list_append(il, if_info);
- } else {
- if_info->loopback = FALSE;
+ else {
il = g_list_insert(il, if_info, nonloopback_pos);
/*
* Insert the next non-loopback interface after this
@@ -274,7 +275,8 @@ get_interface_list(int *err, char **err_str)
* It worked; we can use the "any" device.
*/
if_info = if_info_new("any",
- "Pseudo-device that captures on all interfaces");
+ "Pseudo-device that captures on all interfaces",
+ NULL, FALSE);
il = g_list_insert(il, if_info, -1);
pcap_close(pch);
}