Restore ABI compatibility with SIOCG80211STATS, SIOCG80211ZSTATS

in NetBSD 2.0:

        * If 2.x compatibility is enabled (#ifdef COMPAT_20),
          compile support for OSIOCG80211STATS and OSIOCG80211ZSTATS,
          with the same ioctl numbers as SIOCG80211STATS and
          SIOCG80211ZSTATS in 2.x.  OSIOCG80211STATS and
          OSIOCG80211ZSTATS return an ieee80211_ostats struct,
          which has the same layout as ieee80211_stats in 2.x.

        * Add new ioctl numbers for SIOCG80211STATS and SIOCG80211ZSTATS.
          Both these ioctls will copy at most ifr_buflen bytes of
          the new ieee80211_stats to ifr_buf.
This commit is contained in:
dyoung 2005-07-27 06:52:27 +00:00
parent 1d1035405a
commit d6d1366732
2 changed files with 95 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ieee80211_ioctl.c,v 1.21 2005/07/26 22:52:48 dyoung Exp $ */
/* $NetBSD: ieee80211_ioctl.c,v 1.22 2005/07/27 06:52:27 dyoung 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.25 2005/07/06 15:38:27 sam Exp $");
#endif
#ifdef __NetBSD__
__KERNEL_RCSID(0, "$NetBSD: ieee80211_ioctl.c,v 1.21 2005/07/26 22:52:48 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: ieee80211_ioctl.c,v 1.22 2005/07/27 06:52:27 dyoung Exp $");
#endif
/*
@ -2455,6 +2455,28 @@ ieee80211_ioctl(struct ieee80211com *ic, u_long cmd, caddr_t data)
}
#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, caddr_t data)
@ -2470,6 +2492,9 @@ ieee80211_ioctl(struct ieee80211com *ic, u_long cmd, caddr_t data)
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 empty_macaddr[IEEE80211_ADDR_LEN] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@ -2750,12 +2775,25 @@ ieee80211_ioctl(struct ieee80211com *ic, u_long cmd, caddr_t data)
break;
error = ieee80211_cfgset(ic, cmd, data);
break;
#ifdef COMPAT_20
case OSIOCG80211STATS:
case OSIOCG80211ZSTATS:
ifr = (struct ifreq *)data;
s = splnet();
ieee80211_get_ostats(&ostats, &ic->ic_stats);
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;
s = splnet();
copyout(&ic->ic_stats, ifr->ifr_data, sizeof (ic->ic_stats));
if (cmd == SIOCG80211ZSTATS)
error = copyout(&ic->ic_stats, ifr->ifr_buf,
MIN(sizeof(ic->ic_stats), ifr->ifr_buflen));
if (error == 0 && cmd == SIOCG80211ZSTATS)
(void)memset(&ic->ic_stats, 0, sizeof(ic->ic_stats));
splx(s);
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ieee80211_ioctl.h,v 1.10 2005/07/26 22:52:48 dyoung Exp $ */
/* $NetBSD: ieee80211_ioctl.h,v 1.11 2005/07/27 06:52:27 dyoung Exp $ */
/*-
* Copyright (c) 2001 Atsushi Onoe
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@ -90,6 +90,52 @@ 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 */
u_int32_t is_rx_wrongbss; /* rx from wrong bssid */
u_int32_t is_rx_dup; /* rx discard 'cuz dup */
u_int32_t is_rx_wrongdir; /* rx w/ wrong direction */
u_int32_t is_rx_mcastecho; /* rx discard 'cuz mcast echo */
u_int32_t is_rx_notassoc; /* rx discard 'cuz sta !assoc */
u_int32_t is_rx_nowep; /* rx w/ wep but wep !config */
u_int32_t is_rx_wepfail; /* rx wep processing failed */
u_int32_t is_rx_decap; /* rx decapsulation failed */
u_int32_t is_rx_mgtdiscard; /* rx discard mgt frames */
u_int32_t is_rx_ctl; /* rx discard ctrl frames */
u_int32_t is_rx_rstoobig; /* rx rate set truncated */
u_int32_t is_rx_elem_missing; /* rx required element missing*/
u_int32_t is_rx_elem_toobig; /* rx element too big */
u_int32_t is_rx_elem_toosmall; /* rx element too small */
u_int32_t is_rx_elem_unknown; /* rx element unknown */
u_int32_t is_rx_badchan; /* rx frame w/ invalid chan */
u_int32_t is_rx_chanmismatch; /* rx frame chan mismatch */
u_int32_t is_rx_nodealloc; /* rx frame dropped */
u_int32_t is_rx_ssidmismatch; /* rx frame ssid mismatch */
u_int32_t is_rx_auth_unsupported; /* rx w/ unsupported auth alg */
u_int32_t is_rx_auth_fail; /* rx sta auth failure */
u_int32_t is_rx_assoc_bss; /* rx assoc from wrong bssid */
u_int32_t is_rx_assoc_notauth; /* rx assoc w/o auth */
u_int32_t is_rx_assoc_capmismatch;/* rx assoc w/ cap mismatch */
u_int32_t is_rx_assoc_norate; /* rx assoc w/ no rate match */
u_int32_t is_rx_deauth; /* rx deauthentication */
u_int32_t is_rx_disassoc; /* rx disassociation */
u_int32_t is_rx_badsubtype; /* rx frame w/ unknown subtype*/
u_int32_t is_rx_nombuf; /* rx failed for lack of mbuf */
u_int32_t is_rx_decryptcrc; /* rx decrypt failed on crc */
u_int32_t is_rx_ahdemo_mgt; /* rx discard ahdemo mgt frame*/
u_int32_t is_rx_bad_auth; /* rx bad auth request */
u_int32_t is_tx_nombuf; /* tx failed for lack of mbuf */
u_int32_t is_tx_nonode; /* tx failed for no node */
u_int32_t is_tx_unknownmgt; /* tx of unknown mgt frame */
u_int32_t is_scan_active; /* active scans started */
u_int32_t is_scan_passive; /* passive scans started */
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.
*/
@ -522,10 +568,14 @@ struct ieee80211_bssid {
#define SIOCS80211BSSID _IOW('i', 240, struct ieee80211_bssid)
#define SIOCG80211BSSID _IOWR('i', 241, struct ieee80211_bssid)
#define SIOCG80211STATS _IOWR('i', 242, struct ifreq)
#define SIOCG80211ZSTATS _IOWR('i', 243, struct ifreq)
#ifdef COMPAT_20
#define OSIOCG80211STATS _IOWR('i', 242, struct ifreq)
#define OSIOCG80211ZSTATS _IOWR('i', 243, struct ifreq)
#endif /* COMPAT_20 */
#define SIOCS80211 _IOW('i', 244, struct ieee80211req)
#define SIOCG80211 _IOWR('i', 245, struct ieee80211req)
#define SIOCG80211STATS _IOWR('i', 246, struct ifreq)
#define SIOCG80211ZSTATS _IOWR('i', 247, struct ifreq)
#endif
#endif /* _NET80211_IEEE80211_IOCTL_H_ */