Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-6]: src/sys/net Pull up revision 1.105 (requested by martin in ...
details: https://anonhg.NetBSD.org/src/rev/8a4e9309271c
branches: netbsd-1-6
changeset: 529200:8a4e9309271c
user: tron <tron%NetBSD.org@localhost>
date: Fri Nov 01 10:56:17 2002 +0000
description:
Pull up revision 1.105 (requested by martin in ticket #32):
Add SIOCGIFDATA and SIOCZIFDATA ioctl's to get interface data. (the Z
variant also zeroes the counters after copying them). In ifunit, add
support for dealing all numeric ifname by treating them as an ifindex
which is used to look up the interface.
diffstat:
sys/net/if.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 42 insertions(+), 2 deletions(-)
diffs (86 lines):
diff -r a02d90637eb7 -r 8a4e9309271c sys/net/if.c
--- a/sys/net/if.c Fri Nov 01 10:56:03 2002 +0000
+++ b/sys/net/if.c Fri Nov 01 10:56:17 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.104 2002/05/12 20:40:11 matt Exp $ */
+/* $NetBSD: if.c,v 1.104.4.1 2002/11/01 10:56:17 tron Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.104 2002/05/12 20:40:11 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.104.4.1 2002/11/01 10:56:17 tron Exp $");
#include "opt_inet.h"
@@ -1235,6 +1235,28 @@
const char *name;
{
struct ifnet *ifp;
+ const char *cp = name;
+ u_int unit = 0;
+ u_int i;
+
+ /*
+ * If the entire name is a number, treat it as an ifindex.
+ */
+ for (i = 0; i < IFNAMSIZ && *cp >= '0' && *cp <= '9'; i++, cp++) {
+ unit = unit * 10 + (*cp - '0');
+ }
+
+ /*
+ * If the number took all of the name, then it's a valid ifindex.
+ */
+ if (i == IFNAMSIZ || (cp != name && *cp == '\0')) {
+ if (unit >= if_index)
+ return (NULL);
+ ifp = ifindex2ifnet[unit];
+ if (ifp == NULL || ifp->if_output == if_nulloutput)
+ return (NULL);
+ return (ifp);
+ }
for (ifp = TAILQ_FIRST(&ifnet); ifp != NULL;
ifp = TAILQ_NEXT(ifp, if_list)) {
@@ -1259,6 +1281,7 @@
struct ifnet *ifp;
struct ifreq *ifr;
struct ifcapreq *ifcr;
+ struct ifdatareq *ifdr;
int s, error = 0;
short oif_flags;
@@ -1270,6 +1293,7 @@
}
ifr = (struct ifreq *)data;
ifcr = (struct ifcapreq *)data;
+ ifdr = (struct ifdatareq *)data;
switch (cmd) {
case SIOCIFCREATE:
@@ -1394,6 +1418,22 @@
ifp->if_metric = ifr->ifr_metric;
break;
+ case SIOCGIFDATA:
+ ifdr->ifdr_data = ifp->if_data;
+ break;
+
+ case SIOCZIFDATA:
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
+ return (error);
+ ifdr->ifdr_data = ifp->if_data;
+ /*
+ * Assumes that the volatile counters that can be
+ * zero'ed are at the end of if_data.
+ */
+ memset(&ifp->if_data.ifi_ipackets, 0, sizeof(ifp->if_data) -
+ offsetof(struct if_data, ifi_ipackets));
+ break;
+
case SIOCSIFMTU:
{
u_long oldmtu = ifp->if_mtu;
Home |
Main Index |
Thread Index |
Old Index