Module Name:    src
Committed By:   pgoyette
Date:           Fri Mar 30 02:28:49 UTC 2018

Modified Files:
        src/sys/compat/common [pgoyette-compat]: compat_mod.c compat_mod.h
            files.common if_43.c vfs_syscalls_20.c
        src/sys/kern [pgoyette-compat]: compat_stub.c
        src/sys/modules [pgoyette-compat]: Makefile
        src/sys/net80211 [pgoyette-compat]: ieee80211_ioctl.c ieee80211_ioctl.h
        src/sys/sys [pgoyette-compat]: compat_stub.h
Added Files:
        src/sys/compat/common [pgoyette-compat]: compat_20_mod.c ieee80211_20.c
            if43_20.c

Log Message:
Create and build the compat_20 module


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 src/sys/compat/common/compat_20_mod.c \
    src/sys/compat/common/ieee80211_20.c src/sys/compat/common/if43_20.c
cvs rdiff -u -r1.24.14.23 -r1.24.14.24 src/sys/compat/common/compat_mod.c
cvs rdiff -u -r1.1.42.12 -r1.1.42.13 src/sys/compat/common/compat_mod.h
cvs rdiff -u -r1.1.2.23 -r1.1.2.24 src/sys/compat/common/files.common
cvs rdiff -u -r1.14 -r1.14.2.1 src/sys/compat/common/if_43.c
cvs rdiff -u -r1.40 -r1.40.10.1 src/sys/compat/common/vfs_syscalls_20.c
cvs rdiff -u -r1.1.2.11 -r1.1.2.12 src/sys/kern/compat_stub.c
cvs rdiff -u -r1.202.2.12 -r1.202.2.13 src/sys/modules/Makefile
cvs rdiff -u -r1.60.16.1 -r1.60.16.2 src/sys/net80211/ieee80211_ioctl.c
cvs rdiff -u -r1.23 -r1.23.16.1 src/sys/net80211/ieee80211_ioctl.h
cvs rdiff -u -r1.1.2.11 -r1.1.2.12 src/sys/sys/compat_stub.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/common/compat_mod.c
diff -u src/sys/compat/common/compat_mod.c:1.24.14.23 src/sys/compat/common/compat_mod.c:1.24.14.24
--- src/sys/compat/common/compat_mod.c:1.24.14.23	Thu Mar 29 11:20:02 2018
+++ src/sys/compat/common/compat_mod.c	Fri Mar 30 02:28:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_mod.c,v 1.24.14.23 2018/03/29 11:20:02 pgoyette Exp $	*/
+/*	$NetBSD: compat_mod.c,v 1.24.14.24 2018/03/30 02:28:49 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.23 2018/03/29 11:20:02 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.24 2018/03/30 02:28:49 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -167,12 +167,6 @@ static const struct syscall_package comp
 #endif
 #endif
 
-#if defined(COMPAT_20)
-	{ SYS_compat_20_fhstatfs, 0, (sy_call_t *)compat_20_sys_fhstatfs },
-	{ SYS_compat_20_fstatfs, 0, (sy_call_t *)compat_20_sys_fstatfs },
-	{ SYS_compat_20_getfsstat, 0, (sy_call_t *)compat_20_sys_getfsstat },
-	{ SYS_compat_20_statfs, 0, (sy_call_t *)compat_20_sys_statfs },
-#endif
 	{ 0, 0, NULL },
 };
 
@@ -195,10 +189,10 @@ struct compat_init_fini {
 #ifdef COMPAT_30
 	{ compat_30_init, compat_30_fini },
 #endif
-#if 0	/* NOT YET */
 #ifdef COMPAT_20
 	{ compat_20_init, compat_20_fini },
 #endif
+#if 0	/* NOT YET */
 #ifdef COMPAT_16
 	{ compat_16_init, compat_16_fini },
 #endif

Index: src/sys/compat/common/compat_mod.h
diff -u src/sys/compat/common/compat_mod.h:1.1.42.12 src/sys/compat/common/compat_mod.h:1.1.42.13
--- src/sys/compat/common/compat_mod.h:1.1.42.12	Thu Mar 29 11:20:02 2018
+++ src/sys/compat/common/compat_mod.h	Fri Mar 30 02:28:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_mod.h,v 1.1.42.12 2018/03/29 11:20:02 pgoyette Exp $	*/
+/*	$NetBSD: compat_mod.h,v 1.1.42.13 2018/03/30 02:28:49 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -105,4 +105,15 @@ void usb_30_init(void);
 void usb_30_fini(void);
 #endif
 
+#ifdef COMPAT_20
+int compat_20_init(void);
+int compat_20_fini(void);
+int vfs_syscalls_20_init(void);
+int vfs_syscalls_20_fini(void);
+void ieee80211_20_init(void);
+void ieee80211_20_fini(void);
+void if43_20_init(void);
+void if43_20_fini(void);
+#endif
+
 #endif /* !_COMPAT_MOD_H_ */

Index: src/sys/compat/common/files.common
diff -u src/sys/compat/common/files.common:1.1.2.23 src/sys/compat/common/files.common:1.1.2.24
--- src/sys/compat/common/files.common:1.1.2.23	Thu Mar 29 23:23:03 2018
+++ src/sys/compat/common/files.common	Fri Mar 30 02:28:49 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.common,v 1.1.2.23 2018/03/29 23:23:03 pgoyette Exp $
+#	$NetBSD: files.common,v 1.1.2.24 2018/03/30 02:28:49 pgoyette Exp $
 
 #
 # Generic files, used by all compat options.
@@ -46,8 +46,8 @@ file	compat/common/kern_sig_16.c		compat
 # Compatibility code for NetBSD 2.0
 file	compat/common/compat_20_mod.c		compat_20
 file	compat/common/vfs_syscalls_20.c		compat_20
-file	compat_common/if43_20.c			compat_20
-file	compat_common/ieee80211_20.c		compat_20
+file	compat/common/if43_20.c			compat_20
+file	compat/common/ieee80211_20.c		compat_20
 
 # Compatibility code for NetBSD 3.0
 file	compat/common/compat_30_mod.c		compat_30

Index: src/sys/compat/common/if_43.c
diff -u src/sys/compat/common/if_43.c:1.14 src/sys/compat/common/if_43.c:1.14.2.1
--- src/sys/compat/common/if_43.c:1.14	Sat Jul 29 04:08:47 2017
+++ src/sys/compat/common/if_43.c	Fri Mar 30 02:28:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_43.c,v 1.14 2017/07/29 04:08:47 riastradh Exp $	*/
+/*	$NetBSD: if_43.c,v 1.14.2.1 2018/03/30 02:28:49 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1990, 1993
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_43.c,v 1.14 2017/07/29 04:08:47 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_43.c,v 1.14.2.1 2018/03/30 02:28:49 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -54,6 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_43.c,v 1.
 #include <sys/resourcevar.h>
 #include <sys/mbuf.h>		/* for MLEN */
 #include <sys/protosw.h>
+#include <sys/compat_stub.h>
 
 #include <sys/syscallargs.h>
 
@@ -146,10 +147,6 @@ compat_cvtcmd(u_long cmd)
 		case GRESADDRS:
 		case GRESPROTO:
 		case GRESSOCK:
-#ifdef COMPAT_20
-		case OSIOCG80211STATS:
-		case OSIOCG80211ZSTATS:
-#endif /* COMPAT_20 */
 		case SIOCADDMULTI:
 		case SIOCDELMULTI:
 		case SIOCDIFADDR:
@@ -205,7 +202,10 @@ compat_cvtcmd(u_long cmd)
 		case TAPGIFNAME:
 			return ncmd;
 		default:
-			return cmd;
+			if ((*if43_20_cvtcmd)(ncmd) == 0)
+				return ncmd;
+			else
+				return cmd;
 		}
 	}
 }

Index: src/sys/compat/common/vfs_syscalls_20.c
diff -u src/sys/compat/common/vfs_syscalls_20.c:1.40 src/sys/compat/common/vfs_syscalls_20.c:1.40.10.1
--- src/sys/compat/common/vfs_syscalls_20.c:1.40	Thu Apr 13 09:41:28 2017
+++ src/sys/compat/common/vfs_syscalls_20.c	Fri Mar 30 02:28:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls_20.c,v 1.40 2017/04/13 09:41:28 hannken Exp $	*/
+/*	$NetBSD: vfs_syscalls_20.c,v 1.40.10.1 2018/03/30 02:28:49 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_20.c,v 1.40 2017/04/13 09:41:28 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_20.c,v 1.40.10.1 2018/03/30 02:28:49 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -57,9 +57,13 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls
 #include <sys/malloc.h>
 #include <sys/dirent.h>
 #include <sys/sysctl.h>
+#include <sys/syscall.h>
+#include <sys/syscallvar.h>
 #include <sys/syscallargs.h>
 #include <sys/kauth.h>
 
+#include <compat/common/compat_mod.h>
+
 #include <compat/sys/mount.h>
 
 #define MOUNTNO_NONE	0
@@ -86,6 +90,14 @@ static const struct {
 	{ MOUNT_AFS, MOUNTNO_AFS },
 };
 
+static const struct syscall_package vfs_syscalls_20_syscalls[] = {
+	{ SYS_compat_20_fhstatfs, 0, (sy_call_t *)compat_20_sys_fhstatfs },
+	{ SYS_compat_20_fstatfs, 0, (sy_call_t *)compat_20_sys_fstatfs },
+	{ SYS_compat_20_getfsstat, 0, (sy_call_t *)compat_20_sys_getfsstat }, 
+	{ SYS_compat_20_statfs, 0, (sy_call_t *)compat_20_sys_statfs },
+	{ 0, 0, NULL }
+};
+
 static int
 vfs2fs(struct statfs12 *bfs, const struct statvfs *fs)
 {
@@ -287,3 +299,17 @@ out:
 	free(sbuf, M_TEMP);
 	return error;
 }
+
+int
+vfs_syscalls_20_init(void)
+{
+
+	return syscall_establish(NULL, vfs_syscalls_20_syscalls);
+}
+
+int
+vfs_syscalls_20_fini(void)
+{
+
+	return syscall_disestablish(NULL, vfs_syscalls_20_syscalls);
+}

Index: src/sys/kern/compat_stub.c
diff -u src/sys/kern/compat_stub.c:1.1.2.11 src/sys/kern/compat_stub.c:1.1.2.12
--- src/sys/kern/compat_stub.c:1.1.2.11	Thu Mar 29 11:20:03 2018
+++ src/sys/kern/compat_stub.c	Fri Mar 30 02:28:49 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.1.2.11 2018/03/29 11:20:03 pgoyette Exp $	*/
+/* $NetBSD: compat_stub.c,v 1.1.2.12 2018/03/30 02:28:49 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -134,3 +134,11 @@ void (*vec_usbd_devinfo_vp)(struct usbd_
 int (*vec_usbd_printBCD)(char *cp, size_t l, int bcd) = NULL;
 #endif
 
+/*
+ * ieee80211 ioctl compatability
+ */
+int (*ieee80211_get_ostats_20)(struct ieee80211_ostats *,
+    struct ieee80211_stats *) = (void *)enosys;
+
+int (*if43_20_cvtcmd)(int) = (void *)enosys;
+

Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.202.2.12 src/sys/modules/Makefile:1.202.2.13
--- src/sys/modules/Makefile:1.202.2.12	Wed Mar 28 04:18:25 2018
+++ src/sys/modules/Makefile	Fri Mar 30 02:28:49 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.202.2.12 2018/03/28 04:18:25 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.202.2.13 2018/03/30 02:28:49 pgoyette Exp $
 
 .include <bsd.own.mk>
 
@@ -7,7 +7,7 @@
 # Modules for compatability with earlier versions of NetBSD
 
 SUBDIR+=	compat    compat_80 compat_70 compat_60 compat_50
-SUBDIR+=	compat_40 compat_30 #compat_20 compat_16 compat_14
+SUBDIR+=	compat_40 compat_30 compat_20 #compat_16 compat_14
 #SUBDIR+=	compat_13 compat_12 compat_10 compat_09
 SUBDIR+=	compat_ossaudio
 SUBDIR+=	compat_sysv

Index: src/sys/net80211/ieee80211_ioctl.c
diff -u src/sys/net80211/ieee80211_ioctl.c:1.60.16.1 src/sys/net80211/ieee80211_ioctl.c:1.60.16.2
--- src/sys/net80211/ieee80211_ioctl.c:1.60.16.1	Wed Mar 28 00:30:05 2018
+++ src/sys/net80211/ieee80211_ioctl.c	Fri Mar 30 02:28:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_ioctl.c,v 1.60.16.1 2018/03/28 00:30:05 pgoyette Exp $	*/
+/*	$netBSD: ieee80211_ioctl.c,v 1.60.16.1 2018/03/28 00:30:05 pgoyette Exp $	*/
 /*-
  * Copyright (c) 2001 Atsushi Onoe
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -36,7 +36,7 @@
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_ioctl.c,v 1.35 2005/08/30 14:27:47 avatar Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_ioctl.c,v 1.60.16.1 2018/03/28 00:30:05 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_ioctl.c,v 1.60.16.2 2018/03/30 02:28:49 pgoyette Exp $");
 #endif
 
 /*
@@ -56,6 +56,7 @@ __KERNEL_RCSID(0, "$NetBSD: ieee80211_io
 #include <sys/systm.h>
 #include <sys/proc.h>
 #include <sys/kauth.h>
+#include <sys/compat_stub.h>
  
 #include <net/if.h>
 #include <net/if_arp.h>
@@ -2554,28 +2555,6 @@ ieee80211_ioctl(struct ieee80211com *ic,
 }
 #endif /* __FreeBSD__ */
 
-#ifdef COMPAT_20
-static void
-ieee80211_get_ostats(struct ieee80211_ostats *ostats,
-    struct ieee80211_stats *stats)
-{
-#define	COPYSTATS1(__ostats, __nstats, __dstmemb, __srcmemb, __lastmemb)\
-	(void)memcpy(&(__ostats)->__dstmemb, &(__nstats)->__srcmemb,	\
-	    offsetof(struct ieee80211_stats, __lastmemb) -		\
-	    offsetof(struct ieee80211_stats, __srcmemb))
-#define	COPYSTATS(__ostats, __nstats, __dstmemb, __lastmemb)		\
-	COPYSTATS1(__ostats, __nstats, __dstmemb, __dstmemb, __lastmemb)
-
-	COPYSTATS(ostats, stats, is_rx_badversion, is_rx_unencrypted);
-	COPYSTATS(ostats, stats, is_rx_wepfail, is_rx_beacon);
-	COPYSTATS(ostats, stats, is_rx_rstoobig, is_rx_auth_countermeasures);
-	COPYSTATS(ostats, stats, is_rx_assoc_bss, is_rx_assoc_badwpaie);
-	COPYSTATS(ostats, stats, is_rx_deauth, is_rx_unauth);
-	COPYSTATS1(ostats, stats, is_tx_nombuf, is_tx_nobuf, is_tx_badcipher);
-	COPYSTATS(ostats, stats, is_scan_active, is_crypto_tkip);
-}
-#endif /* COMPAT_20 */
-
 #ifdef __NetBSD__
 int
 ieee80211_ioctl(struct ieee80211com *ic, u_long cmd, void *data)
@@ -2591,9 +2570,6 @@ ieee80211_ioctl(struct ieee80211com *ic,
 	struct ieee80211chanreq *chanreq;
 	struct ieee80211_channel *chan;
 	uint32_t oflags;
-#ifdef COMPAT_20
-	struct ieee80211_ostats ostats;
-#endif /* COMPAT_20 */
 	static const u_int8_t zerobssid[IEEE80211_ADDR_LEN];
 	u_int8_t tmpkey[IEEE80211_WEP_NKID][IEEE80211_KEYBUF_SIZE];
 
@@ -2872,18 +2848,23 @@ ieee80211_ioctl(struct ieee80211com *ic,
 			break;
 		error = ieee80211_cfgset(ic, cmd, data);
 		break;
-#ifdef COMPAT_20
 	case OSIOCG80211STATS:
 	case OSIOCG80211ZSTATS:
+	    {
+		struct ieee80211_ostats ostats;
+
 		ifr = (struct ifreq *)data;
 		s = splnet();
-		ieee80211_get_ostats(&ostats, &ic->ic_stats);
-		error = copyout(&ostats, ifr->ifr_data, sizeof(ostats));
+		error = (*ieee80211_get_ostats_20)(&ostats, &ic->ic_stats);
+		if (error == ENOSYS)
+			error = EINVAL;
+		if (error == 0)
+			error = copyout(&ostats, ifr->ifr_data, sizeof(ostats));
 		if (error == 0 && cmd == OSIOCG80211ZSTATS)
 			(void)memset(&ic->ic_stats, 0, sizeof(ic->ic_stats));
 		splx(s);
 		break;
-#endif /* COMPAT_20 */
+	    }
 	case SIOCG80211ZSTATS:
 	case SIOCG80211STATS:
 		ifr = (struct ifreq *)data;

Index: src/sys/net80211/ieee80211_ioctl.h
diff -u src/sys/net80211/ieee80211_ioctl.h:1.23 src/sys/net80211/ieee80211_ioctl.h:1.23.16.1
--- src/sys/net80211/ieee80211_ioctl.h:1.23	Fri Apr  8 14:30:47 2016
+++ src/sys/net80211/ieee80211_ioctl.h	Fri Mar 30 02:28:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211_ioctl.h,v 1.23 2016/04/08 14:30:47 roy Exp $	*/
+/*	$NetBSD: ieee80211_ioctl.h,v 1.23.16.1 2018/03/30 02:28:49 pgoyette Exp $	*/
 /*-
  * Copyright (c) 2001 Atsushi Onoe
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -91,7 +91,6 @@ struct ieee80211_nodestats {
 	u_int32_t	ns_tx_disassoc_code;	/* last disassociation reason */
 };
 
-#ifdef COMPAT_20
 struct ieee80211_ostats {
 	u_int32_t	is_rx_badversion;	/* rx frame with bad version */
 	u_int32_t	is_rx_tooshort;		/* rx frame too short */
@@ -135,7 +134,6 @@ struct ieee80211_ostats {
 	u_int32_t	is_node_timeout;	/* nodes timed out inactivity */
 	u_int32_t	is_crypto_nomem;	/* no memory for crypto ctx */
 };
-#endif /* COMPAT_20 */
 
 /*
  * Summary statistics.
@@ -429,10 +427,8 @@ struct ieee80211req {
 #define	SIOCG80211		_IOWR('i', 245, struct ieee80211req)
 #define	SIOCG80211STATS		_IOWR('i', 246, struct ifreq)
 #define	SIOCG80211ZSTATS	_IOWR('i', 247, struct ifreq)
-#ifdef COMPAT_20
 #define	OSIOCG80211STATS	_IOWR('i', 242, struct ifreq)
 #define	OSIOCG80211ZSTATS	_IOWR('i', 243, struct ifreq)
-#endif /* COMPAT_20 */
 #endif /* __NetBSD__ */
 
 #if defined(__FreeBSD__) || defined(COMPAT_FREEBSD_NET80211)

Index: src/sys/sys/compat_stub.h
diff -u src/sys/sys/compat_stub.h:1.1.2.11 src/sys/sys/compat_stub.h:1.1.2.12
--- src/sys/sys/compat_stub.h:1.1.2.11	Thu Mar 29 11:20:03 2018
+++ src/sys/sys/compat_stub.h	Fri Mar 30 02:28:49 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.h,v 1.1.2.11 2018/03/29 11:20:03 pgoyette Exp $	*/
+/* $NetBSD: compat_stub.h,v 1.1.2.12 2018/03/30 02:28:49 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -149,4 +149,15 @@ extern void (*vec_usbd_devinfo_vp)(struc
 
 extern int (*vec_usbd_printBCD)(char *cp, size_t l, int bcd);
 
+/*
+ * ieee80211 ioctl compatability
+ */
+struct ieee80211_ostats;
+struct ieee80211_stats; 
+
+extern int (*ieee80211_get_ostats_20)(struct ieee80211_ostats *, 
+    struct ieee80211_stats *);
+
+extern int (*if43_20_cvtcmd)(int);
+
 #endif	/* _SYS_COMPAT_STUB_H */

Added files:

Index: src/sys/compat/common/compat_20_mod.c
diff -u /dev/null src/sys/compat/common/compat_20_mod.c:1.1.2.1
--- /dev/null	Fri Mar 30 02:28:49 2018
+++ src/sys/compat/common/compat_20_mod.c	Fri Mar 30 02:28:49 2018
@@ -0,0 +1,100 @@
+/*	$NetBSD: compat_20_mod.c,v 1.1.2.1 2018/03/30 02:28:49 pgoyette Exp $	*/
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software developed for The NetBSD Foundation
+ * by Paul Goyette
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*
+ * Linkage for the compat module: spaghetti.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: compat_20_mod.c,v 1.1.2.1 2018/03/30 02:28:49 pgoyette Exp $");
+
+#include <sys/systm.h>
+#include <sys/module.h>
+#include <sys/sysctl.h>
+#include <sys/syscall.h>
+#include <sys/syscallvar.h>
+#include <sys/syscallargs.h>
+
+#include <compat/common/compat_util.h>
+#include <compat/common/compat_mod.h>
+
+int
+compat_20_init(void)
+{
+	int error = 0;
+
+	error = vfs_syscalls_20_init();
+	if (error != 0)
+		return error;
+
+	if43_20_init();
+	ieee80211_20_init();
+
+	return error;
+}
+
+int
+compat_20_fini(void)
+{
+	int error = 0;
+
+	ieee80211_20_fini();
+	if43_20_fini();
+
+	error = vfs_syscalls_20_fini();
+	if (error != 0) {
+		if43_20_init();
+		ieee80211_20_init();
+	}
+
+	return error;
+}
+
+#ifdef _MODULE
+
+#define REQD_20	"compat_80,compat_70,compat_60,compat_50,compat_40,compat_30"
+
+MODULE(MODULE_CLASS_EXEC, compat_20, REQD_20);
+
+static int
+compat_20_modcmd(modcmd_t cmd, void *arg)
+{
+
+	switch (cmd) {
+	case MODULE_CMD_INIT:
+		return compat_20_init();
+	case MODULE_CMD_FINI:
+		return compat_20_init();
+	default:
+		return ENOTTY;
+	}
+}
+#endif
Index: src/sys/compat/common/ieee80211_20.c
diff -u /dev/null src/sys/compat/common/ieee80211_20.c:1.1.2.1
--- /dev/null	Fri Mar 30 02:28:49 2018
+++ src/sys/compat/common/ieee80211_20.c	Fri Mar 30 02:28:49 2018
@@ -0,0 +1,108 @@
+/*	$NetBSD: ieee80211_20.c,v 1.1.2.1 2018/03/30 02:28:49 pgoyette Exp $	*/
+/*-
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * 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. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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>
+#ifdef __FreeBSD__
+__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_ioctl.c,v 1.35 2005/08/30 14:27:47 avatar Exp $");
+#endif
+#ifdef __NetBSD__
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_20.c,v 1.1.2.1 2018/03/30 02:28:49 pgoyette Exp $");
+#endif
+
+/*
+ * IEEE 802.11 ioctl support
+ */
+
+#ifdef _KERNEL_OPT
+#include "opt_inet.h"
+#include "opt_compat_netbsd.h"
+#endif
+
+#include <sys/endian.h>
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/kauth.h>
+#include <sys/compat_stub.h>
+ 
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <net/if_media.h>
+#include <net/if_ether.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_ioctl.h>
+
+#include <dev/ic/wi_ieee.h>
+
+#include <compat/common/compat_mod.h>
+
+#include <compat/sys/sockio.h>
+
+static int
+ieee80211_get_ostats(struct ieee80211_ostats *ostats,
+    struct ieee80211_stats *stats)
+{
+#define	COPYSTATS1(__ostats, __nstats, __dstmemb, __srcmemb, __lastmemb)\
+	(void)memcpy(&(__ostats)->__dstmemb, &(__nstats)->__srcmemb,	\
+	    offsetof(struct ieee80211_stats, __lastmemb) -		\
+	    offsetof(struct ieee80211_stats, __srcmemb))
+#define	COPYSTATS(__ostats, __nstats, __dstmemb, __lastmemb)		\
+	COPYSTATS1(__ostats, __nstats, __dstmemb, __dstmemb, __lastmemb)
+
+	COPYSTATS(ostats, stats, is_rx_badversion, is_rx_unencrypted);
+	COPYSTATS(ostats, stats, is_rx_wepfail, is_rx_beacon);
+	COPYSTATS(ostats, stats, is_rx_rstoobig, is_rx_auth_countermeasures);
+	COPYSTATS(ostats, stats, is_rx_assoc_bss, is_rx_assoc_badwpaie);
+	COPYSTATS(ostats, stats, is_rx_deauth, is_rx_unauth);
+	COPYSTATS1(ostats, stats, is_tx_nombuf, is_tx_nobuf, is_tx_badcipher);
+	COPYSTATS(ostats, stats, is_scan_active, is_crypto_tkip);
+
+	return 0;
+}
+
+void
+ieee80211_20_init(void)
+{
+
+	ieee80211_get_ostats_20 = ieee80211_get_ostats;
+}
+void
+ieee80211_20_fini(void)
+{
+
+	ieee80211_get_ostats_20 = (void *)enosys;
+}
Index: src/sys/compat/common/if43_20.c
diff -u /dev/null src/sys/compat/common/if43_20.c:1.1.2.1
--- /dev/null	Fri Mar 30 02:28:49 2018
+++ src/sys/compat/common/if43_20.c	Fri Mar 30 02:28:49 2018
@@ -0,0 +1,91 @@
+/*	$NetBSD: if43_20.c,v 1.1.2.1 2018/03/30 02:28:49 pgoyette Exp $	*/
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Paul Goyette
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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>
+__KERNEL_RCSID(0, "$NetBSD: if43_20.c,v 1.1.2.1 2018/03/30 02:28:49 pgoyette Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/filedesc.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/fcntl.h>
+#include <sys/syslog.h>
+#include <sys/unistd.h>
+#include <sys/resourcevar.h>
+#include <sys/mbuf.h>		/* for MLEN */
+#include <sys/protosw.h>
+#include <sys/compat_stub.h>
+
+#include <net/if.h>
+#include <net/bpf.h>
+#include <net/route.h>
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <net/if_gre.h>
+#include <net/if_atm.h>
+#include <net/if_tap.h>
+#include <net80211/ieee80211_ioctl.h>
+
+#include <compat/common/compat_mod.h>
+
+static int
+if43_cvtcmd_20(int ncmd)
+{
+
+	switch (ncmd) {
+	case OSIOCG80211STATS:
+	case OSIOCG80211ZSTATS:
+		return 0;
+	default:
+		return EINVAL;
+	}
+}
+
+void
+if43_20_init(void)
+{
+
+	if43_20_cvtcmd = if43_cvtcmd_20;
+}
+
+void
+if43_20_fini(void)
+{
+
+	if43_20_cvtcmd = (void *)enosys;
+}

Reply via email to