From owner-svn-src-all@FreeBSD.ORG Wed Nov 25 00:00:57 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E3F221065694; Wed, 25 Nov 2009 00:00:57 +0000 (UTC) (envelope-from will@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D314D8FC15; Wed, 25 Nov 2009 00:00:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nAP00vgi033400; Wed, 25 Nov 2009 00:00:57 GMT (envelope-from will@svn.freebsd.org) Received: (from will@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nAP00vnl033398; Wed, 25 Nov 2009 00:00:57 GMT (envelope-from will@svn.freebsd.org) Message-Id: <200911250000.nAP00vnl033398@svn.freebsd.org> From: Will Andrews Date: Wed, 25 Nov 2009 00:00:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r199770 - head/sbin/ifconfig X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Nov 2009 00:00:58 -0000 Author: will Date: Wed Nov 25 00:00:57 2009 New Revision: 199770 URL: http://svn.freebsd.org/changeset/base/199770 Log: Make ``ifconfig -l ether'' only list interfaces that speak Ethernet. PR: 118987 Approved by: ken (mentor) Modified: head/sbin/ifconfig/ifconfig.c Modified: head/sbin/ifconfig/ifconfig.c ============================================================================== --- head/sbin/ifconfig/ifconfig.c Tue Nov 24 22:37:04 2009 (r199769) +++ head/sbin/ifconfig/ifconfig.c Wed Nov 25 00:00:57 2009 (r199770) @@ -147,7 +147,7 @@ main(int argc, char *argv[]) struct ifaddrs *ifap, *ifa; struct ifreq paifr; const struct sockaddr_dl *sdl; - char options[1024], *cp; + char options[1024], *cp, *namecp = NULL; const char *ifname; struct option *p; size_t iflen; @@ -294,7 +294,7 @@ main(int argc, char *argv[]) sdl = (const struct sockaddr_dl *) ifa->ifa_addr; else sdl = NULL; - if (cp != NULL && strcmp(cp, ifa->ifa_name) == 0) + if (cp != NULL && strcmp(cp, ifa->ifa_name) == 0 && !namesonly) continue; iflen = strlcpy(name, ifa->ifa_name, sizeof(name)); if (iflen >= sizeof(name)) { @@ -308,16 +308,32 @@ main(int argc, char *argv[]) continue; if (uponly && (ifa->ifa_flags & IFF_UP) == 0) continue; - ifindex++; /* * Are we just listing the interfaces? */ if (namesonly) { + if (namecp == cp) + continue; + if (afp != NULL) { + /* special case for "ether" address family */ + if (!strcmp(afp->af_name, "ether")) { + if (sdl == NULL || + sdl->sdl_type != IFT_ETHER || + sdl->sdl_alen != ETHER_ADDR_LEN) + continue; + } else { + if (ifa->ifa_addr->sa_family != afp->af_af) + continue; + } + } + namecp = cp; + ifindex++; if (ifindex > 1) printf(" "); fputs(name, stdout); continue; } + ifindex++; if (argc > 0) ifconfig(argc, argv, 0, afp);