Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat Provide SIOCGIFNAME.
details: https://anonhg.NetBSD.org/src/rev/3639f01bd9a4
branches: trunk
changeset: 749019:3639f01bd9a4
user: joerg <joerg%NetBSD.org@localhost>
date: Fri Nov 13 21:45:03 2009 +0000
description:
Provide SIOCGIFNAME.
diffstat:
sys/compat/linux/common/linux_socket.c | 34 ++++++++++++++++++++++++++++-
sys/compat/linux/common/linux_sockio.h | 4 ++-
sys/compat/linux32/common/linux32_socket.c | 34 ++++++++++++++++++++++++++++-
sys/compat/linux32/common/linux32_sockio.h | 3 +-
4 files changed, 69 insertions(+), 6 deletions(-)
diffs (180 lines):
diff -r 6d2fd0bd6d75 -r 3639f01bd9a4 sys/compat/linux/common/linux_socket.c
--- a/sys/compat/linux/common/linux_socket.c Fri Nov 13 19:15:24 2009 +0000
+++ b/sys/compat/linux/common/linux_socket.c Fri Nov 13 21:45:03 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_socket.c,v 1.104 2009/06/17 14:18:51 njoly Exp $ */
+/* $NetBSD: linux_socket.c,v 1.105 2009/11/13 21:45:03 joerg Exp $ */
/*-
* Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.104 2009/06/17 14:18:51 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.105 2009/11/13 21:45:03 joerg Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -114,6 +114,7 @@
int linux_to_bsd_ip_sockopt(int);
int linux_to_bsd_tcp_sockopt(int);
int linux_to_bsd_udp_sockopt(int);
+int linux_getifname(struct lwp *, register_t *, void *);
int linux_getifconf(struct lwp *, register_t *, void *);
int linux_getifhwaddr(struct lwp *, register_t *, u_int, void *);
static int linux_get_sa(struct lwp *, int, struct mbuf **,
@@ -1005,6 +1006,31 @@
}
int
+linux_getifname(struct lwp *l, register_t *retval, void *data)
+{
+ struct ifnet *ifp;
+ struct linux_ifreq ifr;
+ int error;
+
+ error = copyin(data, &ifr, sizeof(ifr));
+ if (error)
+ return error;
+
+ if (ifr.ifr_ifru.ifru_ifindex >= if_indexlim)
+ return ENODEV;
+
+ ifp = ifindex2ifnet[ifr.ifr_ifru.ifru_ifindex];
+ if (ifp == NULL)
+ return ENODEV;
+
+ strncpy(ifr.ifr_name, ifp->if_xname, sizeof(ifr.ifr_name));
+
+ error = copyout(&ifr, data, sizeof(ifr));
+
+ return 0;
+}
+
+int
linux_getifconf(struct lwp *l, register_t *retval, void *data)
{
struct linux_ifreq ifr, *ifrp;
@@ -1225,6 +1251,10 @@
retval[0] = 0;
switch (com) {
+ case LINUX_SIOCGIFNAME:
+ error = linux_getifname(l, retval, SCARG(uap, data));
+ dosys = 0;
+ break;
case LINUX_SIOCGIFCONF:
error = linux_getifconf(l, retval, SCARG(uap, data));
dosys = 0;
diff -r 6d2fd0bd6d75 -r 3639f01bd9a4 sys/compat/linux/common/linux_sockio.h
--- a/sys/compat/linux/common/linux_sockio.h Fri Nov 13 19:15:24 2009 +0000
+++ b/sys/compat/linux/common/linux_sockio.h Fri Nov 13 21:45:03 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_sockio.h,v 1.16 2008/07/03 14:07:09 njoly Exp $ */
+/* $NetBSD: linux_sockio.h,v 1.17 2009/11/13 21:45:03 joerg Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -32,6 +32,7 @@
#ifndef _LINUX_SOCKIO_H
#define _LINUX_SOCKIO_H
+#define LINUX_SIOCGIFNAME _LINUX_IO(0x89, 0x10)
#define LINUX_SIOCGIFCONF _LINUX_IO(0x89, 0x12)
#define LINUX_SIOCGIFFLAGS _LINUX_IO(0x89, 0x13)
#define LINUX_SIOCSIFFLAGS _LINUX_IO(0x89, 0x14)
@@ -66,6 +67,7 @@
struct osockaddr ifru_addr;
struct osockaddr ifru_hwaddr;
struct linux_ifmap ifru_map;
+ int ifru_ifindex;
} ifr_ifru;
#define ifr_name ifr_ifrn.ifrn_name /* interface name */
#define ifr_addr ifr_ifru.ifru_addr /* address */
diff -r 6d2fd0bd6d75 -r 3639f01bd9a4 sys/compat/linux32/common/linux32_socket.c
--- a/sys/compat/linux32/common/linux32_socket.c Fri Nov 13 19:15:24 2009 +0000
+++ b/sys/compat/linux32/common/linux32_socket.c Fri Nov 13 21:45:03 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_socket.c,v 1.10 2008/11/19 18:36:04 ad Exp $ */
+/* $NetBSD: linux32_socket.c,v 1.11 2009/11/13 21:45:03 joerg Exp $ */
/*-
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.10 2008/11/19 18:36:04 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.11 2009/11/13 21:45:03 joerg Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -91,6 +91,7 @@
#include <compat/linux32/common/linux32_ioctl.h>
#include <compat/linux32/linux32_syscallargs.h>
+int linux32_getifname(struct lwp *, register_t *, void *);
int linux32_getifconf(struct lwp *, register_t *, void *);
int linux32_getifhwaddr(struct lwp *, register_t *, u_int, void *);
@@ -387,6 +388,31 @@
}
int
+linux32_getifname(struct lwp *l, register_t *retval, void *data)
+{
+ struct ifnet *ifp;
+ struct linux32_ifreq ifr;
+ int error;
+
+ error = copyin(data, &ifr, sizeof(ifr));
+ if (error)
+ return error;
+
+ if (ifr.ifr_ifru.ifru_ifindex >= if_indexlim)
+ return ENODEV;
+
+ ifp = ifindex2ifnet[ifr.ifr_ifru.ifru_ifindex];
+ if (ifp == NULL)
+ return ENODEV;
+
+ strncpy(ifr.ifr_name, ifp->if_xname, sizeof(ifr.ifr_name));
+
+ error = copyout(&ifr, data, sizeof(ifr));
+
+ return 0;
+}
+
+int
linux32_getifconf(struct lwp *l, register_t *retval, void *data)
{
struct linux32_ifreq ifr, *ifrp;
@@ -606,6 +632,10 @@
retval[0] = 0;
switch (com) {
+ case LINUX_SIOCGIFNAME:
+ error = linux32_getifname(l, retval, SCARG_P32(uap, data));
+ dosys = 0;
+ break;
case LINUX_SIOCGIFCONF:
error = linux32_getifconf(l, retval, SCARG_P32(uap, data));
dosys = 0;
diff -r 6d2fd0bd6d75 -r 3639f01bd9a4 sys/compat/linux32/common/linux32_sockio.h
--- a/sys/compat/linux32/common/linux32_sockio.h Fri Nov 13 19:15:24 2009 +0000
+++ b/sys/compat/linux32/common/linux32_sockio.h Fri Nov 13 21:45:03 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_sockio.h,v 1.2 2008/07/23 12:32:09 njoly Exp $ */
+/* $NetBSD: linux32_sockio.h,v 1.3 2009/11/13 21:45:03 joerg Exp $ */
/*
* Copyright (c) 2008 Nicolas Joly
@@ -48,6 +48,7 @@
struct osockaddr ifru_addr;
struct osockaddr ifru_hwaddr;
struct linux32_ifmap ifru_map;
+ int ifru_ifindex;
} ifr_ifru;
#define ifr_name ifr_ifrn.ifrn_name /* interface name */
#define ifr_addr ifr_ifru.ifru_addr /* address */
Home |
Main Index |
Thread Index |
Old Index