Module Name: src Committed By: msaitoh Date: Wed Oct 31 10:17:35 UTC 2012
Modified Files: src/sbin/ifconfig: Makefile.inc src/sys/net: if_ether.h if_ethersubr.c src/sys/sys: sockio.h Added Files: src/sbin/ifconfig: ether.c Log Message: Add SIOCGETHERCAP ioctl. There was no way to know the setting of ec_capabilities and ec_capenable other than grepping the source. See http://mail-index.netbsd.org/tech-kern/2010/07/28/msg008613.html To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sbin/ifconfig/Makefile.inc cvs rdiff -u -r0 -r1.1 src/sbin/ifconfig/ether.c cvs rdiff -u -r1.60 -r1.61 src/sys/net/if_ether.h cvs rdiff -u -r1.192 -r1.193 src/sys/net/if_ethersubr.c cvs rdiff -u -r1.30 -r1.31 src/sys/sys/sockio.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/ifconfig/Makefile.inc diff -u src/sbin/ifconfig/Makefile.inc:1.8 src/sbin/ifconfig/Makefile.inc:1.9 --- src/sbin/ifconfig/Makefile.inc:1.8 Mon Dec 13 17:35:08 2010 +++ src/sbin/ifconfig/Makefile.inc Wed Oct 31 10:17:34 2012 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.8 2010/12/13 17:35:08 pooka Exp $ +# $NetBSD: Makefile.inc,v 1.9 2012/10/31 10:17:34 msaitoh Exp $ # shared stuff with src/distrib/utils/x_ifconfig for install media. # stuff not required by install media should be into Makefile. @@ -13,6 +13,7 @@ SRCS+= af_inet.c SRCS+= af_inetany.c SRCS+= agr.c SRCS+= env.c +SRCS+= ether.c SRCS+= ieee80211.c SRCS+= ifconfig.c SRCS+= media.c Index: src/sys/net/if_ether.h diff -u src/sys/net/if_ether.h:1.60 src/sys/net/if_ether.h:1.61 --- src/sys/net/if_ether.h:1.60 Thu Oct 25 11:53:14 2012 +++ src/sys/net/if_ether.h Wed Oct 31 10:17:34 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ether.h,v 1.60 2012/10/25 11:53:14 msaitoh Exp $ */ +/* $NetBSD: if_ether.h,v 1.61 2012/10/31 10:17:34 msaitoh Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -187,6 +187,19 @@ struct ethercom { #define ETHERCAP_VLAN_HWTAGGING 0x00000002 /* hardware VLAN tag support */ #define ETHERCAP_JUMBO_MTU 0x00000004 /* 9000 byte MTU supported */ +#define ECCAPBITS \ + "\020" \ + "\1VLAN_MTU" \ + "\2VLAN_HWTAGGING" \ + "\3JUMBO_MTU" + +/* ioctl() for Ethernet capabilities */ +struct eccapreq { + char eccr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + int eccr_capabilities; /* supported capabiliites */ + int eccr_capenable; /* capabilities enabled */ +}; + #ifdef _KERNEL extern const uint8_t etherbroadcastaddr[ETHER_ADDR_LEN]; extern const uint8_t ethermulticastaddr_slowprotocols[ETHER_ADDR_LEN]; Index: src/sys/net/if_ethersubr.c diff -u src/sys/net/if_ethersubr.c:1.192 src/sys/net/if_ethersubr.c:1.193 --- src/sys/net/if_ethersubr.c:1.192 Thu Oct 11 20:05:50 2012 +++ src/sys/net/if_ethersubr.c Wed Oct 31 10:17:34 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ethersubr.c,v 1.192 2012/10/11 20:05:50 christos Exp $ */ +/* $NetBSD: if_ethersubr.c,v 1.193 2012/10/31 10:17:34 msaitoh Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.192 2012/10/11 20:05:50 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.193 2012/10/31 10:17:34 msaitoh Exp $"); #include "opt_inet.h" #include "opt_atalk.h" @@ -1494,6 +1494,7 @@ int ether_ioctl(struct ifnet *ifp, u_long cmd, void *data) { struct ethercom *ec = (void *) ifp; + struct eccapreq *eccr; struct ifreq *ifr = (struct ifreq *)data; struct if_laddrreq *iflr = data; const struct sockaddr_dl *sdl; @@ -1571,6 +1572,11 @@ ether_ioctl(struct ifnet *ifp, u_long cm break; } return 0; + case SIOCGETHERCAP: + eccr = (struct eccapreq *)data; + eccr->eccr_capabilities = ec->ec_capabilities; + eccr->eccr_capenable = ec->ec_capenable; + return 0; case SIOCADDMULTI: return ether_addmulti(ifreq_getaddr(cmd, ifr), ec); case SIOCDELMULTI: Index: src/sys/sys/sockio.h diff -u src/sys/sys/sockio.h:1.30 src/sys/sys/sockio.h:1.31 --- src/sys/sys/sockio.h:1.30 Mon Nov 15 22:42:36 2010 +++ src/sys/sys/sockio.h Wed Oct 31 10:17:35 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: sockio.h,v 1.30 2010/11/15 22:42:36 pooka Exp $ */ +/* $NetBSD: sockio.h,v 1.31 2012/10/31 10:17:35 msaitoh Exp $ */ /*- * Copyright (c) 1982, 1986, 1990, 1993, 1994 @@ -132,6 +132,11 @@ #define SIOCGLINKSTR _IOWR('i', 135, struct ifdrv) #define SIOCSLINKSTR _IOW('i', 136, struct ifdrv) +/* 137 is SIOCGATHSTATS in athioctl.h */ +/* 138 is SIOCGATHDIAG in athioctl.h */ + +#define SIOCGETHERCAP _IOWR('i', 139, struct eccapreq) /* get ethercap */ + #define SIOCSETPFSYNC _IOW('i', 247, struct ifreq) #define SIOCGETPFSYNC _IOWR('i', 248, struct ifreq) Added files: Index: src/sbin/ifconfig/ether.c diff -u /dev/null src/sbin/ifconfig/ether.c:1.1 --- /dev/null Wed Oct 31 10:17:35 2012 +++ src/sbin/ifconfig/ether.c Wed Oct 31 10:17:34 2012 @@ -0,0 +1,88 @@ +/* $NetBSD: ether.c,v 1.1 2012/10/31 10:17:34 msaitoh Exp $ */ + +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +#ifndef lint +__RCSID("$NetBSD: ether.c,v 1.1 2012/10/31 10:17:34 msaitoh Exp $"); +#endif /* not lint */ + +#include <sys/param.h> +#include <sys/ioctl.h> + +#include <net/if.h> +#include <net/if_ether.h> + +#include <ctype.h> +#include <err.h> +#include <errno.h> +#include <string.h> +#include <stdlib.h> +#include <stdio.h> +#include <util.h> + +#include "env.h" +#include "parse.h" +#include "extern.h" +#include "prog_ops.h" + +static void ether_status(prop_dictionary_t, prop_dictionary_t); +static void ether_constructor(void) __attribute__((constructor)); + +static status_func_t status; + +void +ether_status(prop_dictionary_t env, prop_dictionary_t oenv) +{ + struct eccapreq eccr; + char fbuf[BUFSIZ]; + + memset(&eccr, 0, sizeof(eccr)); + + if (direct_ioctl(env, SIOCGETHERCAP, &eccr) == -1) + return; + + if (eccr.eccr_capabilities != 0) { + (void)snprintb(fbuf, sizeof(fbuf), ECCAPBITS, + eccr.eccr_capabilities); + printf("\tec_capabilities=%s\n", &fbuf[2]); + (void)snprintb(fbuf, sizeof(fbuf), ECCAPBITS, + eccr.eccr_capenable); + printf("\tec_enabled=%s\n", &fbuf[2]); + } +} + +static void +ether_constructor(void) +{ + + status_func_init(&status, ether_status); + register_status(&status); +}