Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add SIOCGIFINDEX from Ty Sarna and Matthew Sporleder.



details:   https://anonhg.NetBSD.org/src/rev/c9c7fcc7544b
branches:  trunk
changeset: 790399:c9c7fcc7544b
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Oct 05 23:16:54 2013 +0000

description:
Add SIOCGIFINDEX from Ty Sarna and Matthew Sporleder.

diffstat:

 share/man/man4/netintro.4 |  12 +++++++++++-
 sys/net/if.c              |  11 ++++++++---
 sys/net/if.h              |   3 ++-
 sys/sys/sockio.h          |   3 ++-
 4 files changed, 23 insertions(+), 6 deletions(-)

diffs (109 lines):

diff -r 5488309c1dc3 -r c9c7fcc7544b share/man/man4/netintro.4
--- a/share/man/man4/netintro.4 Sat Oct 05 22:38:52 2013 +0000
+++ b/share/man/man4/netintro.4 Sat Oct 05 23:16:54 2013 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: netintro.4,v 1.25 2013/03/01 18:25:27 joerg Exp $
+.\"    $NetBSD: netintro.4,v 1.26 2013/10/05 23:16:54 christos Exp $
 .\"
 .\" Copyright (c) 1983, 1990, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -197,9 +197,17 @@
 #define ifr_addr      ifr_ifru.ifru_addr    /* address */
 #define ifr_dstaddr   ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
+#define ifr_space     ifr_ifru.ifru_space     /* sockaddr_storage */
 #define ifr_flags     ifr_ifru.ifru_flags   /* flags */
 #define ifr_metric    ifr_ifru.ifru_metric  /* metric */
+#define ifr_mtu       ifr_ifru.ifru_mtu       /* mtu */
+#define ifr_dlt       ifr_ifru.ifru_dlt       /* data link type (DLT_*) */
+#define ifr_value     ifr_ifru.ifru_value     /* generic value */
+#define ifr_media     ifr_ifru.ifru_metric    /* media options (overload) */
 #define ifr_data      ifr_ifru.ifru_data    /* for use by interface */
+#define ifr_buf       ifr_ifru.ifru_b.b_buf   /* new interface ioctls */
+#define ifr_buflen    ifr_ifru.ifru_b.b_buflen
+#define ifr_index     ifr_ifru.ifru_value     /* interface index */
 };
 .Ed
 .Pp
@@ -241,6 +249,8 @@
 The metric is used only by user-level routers.
 .It Dv SIOCGIFMETRIC
 Get interface metric.
+.It Dv SIOCGIFINDEX
+Get the interface index and populate ifr_index.
 .El
 .Pp
 There are two requests that make use of a new structure:
diff -r 5488309c1dc3 -r c9c7fcc7544b sys/net/if.c
--- a/sys/net/if.c      Sat Oct 05 22:38:52 2013 +0000
+++ b/sys/net/if.c      Sat Oct 05 23:16:54 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.265 2013/06/29 21:06:58 rmind Exp $   */
+/*     $NetBSD: if.c,v 1.266 2013/10/05 23:16:54 christos Exp $        */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.265 2013/06/29 21:06:58 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.266 2013/10/05 23:16:54 christos Exp $");
 
 #include "opt_inet.h"
 
@@ -990,7 +990,7 @@
 
        if (ifc == NULL) {
                if (*ifname == '\0' ||
-                   module_autoload(ifname, MODULE_CLASS_DRIVER))
+                   module_autoload(ifname, MODULE_CLASS_DRIVER, "if"))
                        return NULL;
                *ifname = '\0';
                goto again;
@@ -1644,6 +1644,11 @@
                ifdr->ifdr_data = ifp->if_data;
                break;
 
+       case SIOCGIFINDEX:
+               ifr = data;
+               ifr->ifr_index = ifp->if_index;
+               break;
+
        case SIOCZIFDATA:
                ifdr = data;
                ifdr->ifdr_data = ifp->if_data;
diff -r 5488309c1dc3 -r c9c7fcc7544b sys/net/if.h
--- a/sys/net/if.h      Sat Oct 05 22:38:52 2013 +0000
+++ b/sys/net/if.h      Sat Oct 05 23:16:54 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.h,v 1.156 2013/06/29 21:06:58 rmind Exp $   */
+/*     $NetBSD: if.h,v 1.157 2013/10/05 23:16:54 christos Exp $        */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -598,6 +598,7 @@
                                                 */
 #define        ifr_buf         ifr_ifru.ifru_b.b_buf   /* new interface ioctls */
 #define        ifr_buflen      ifr_ifru.ifru_b.b_buflen
+#define        ifr_index       ifr_ifru.ifru_index     /* interface index */
 };
 
 #ifdef _KERNEL
diff -r 5488309c1dc3 -r c9c7fcc7544b sys/sys/sockio.h
--- a/sys/sys/sockio.h  Sat Oct 05 22:38:52 2013 +0000
+++ b/sys/sys/sockio.h  Sat Oct 05 23:16:54 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sockio.h,v 1.31 2012/10/31 10:17:35 msaitoh Exp $      */
+/*     $NetBSD: sockio.h,v 1.32 2013/10/05 23:16:54 christos Exp $     */
 
 /*-
  * Copyright (c) 1982, 1986, 1990, 1993, 1994
@@ -136,6 +136,7 @@
 /* 138 is SIOCGATHDIAG in athioctl.h */
 
 #define        SIOCGETHERCAP   _IOWR('i', 139, struct eccapreq) /* get ethercap */
+#define SIOCGIFINDEX  _IOWR('i', 140, struct ifreq)   /* get ifnet index */
 
 #define        SIOCSETPFSYNC   _IOW('i', 247, struct ifreq)    
 #define        SIOCGETPFSYNC   _IOWR('i', 248, struct ifreq)



Home | Main Index | Thread Index | Old Index