xref: /openbsd-src/sys/dev/ic/if_wi_hostap.h (revision cfe90bb7c292585e6ed2549277afb2dd7b4e76b4)
1*cfe90bb7Szhuk /*	$OpenBSD: if_wi_hostap.h,v 1.10 2014/08/24 18:01:27 zhuk Exp $	*/
21de77e4fSmickey 
31de77e4fSmickey /*
41de77e4fSmickey  * Copyright (c) 2002
51de77e4fSmickey  *	Thomas Skibo <skibo@pacbell.net>.  All rights reserved.
61de77e4fSmickey  *
71de77e4fSmickey  * Redistribution and use in source and binary forms, with or without
81de77e4fSmickey  * modification, are permitted provided that the following conditions
91de77e4fSmickey  * are met:
101de77e4fSmickey  * 1. Redistributions of source code must retain the above copyright
111de77e4fSmickey  *    notice, this list of conditions and the following disclaimer.
121de77e4fSmickey  * 2. Redistributions in binary form must reproduce the above copyright
131de77e4fSmickey  *    notice, this list of conditions and the following disclaimer in the
141de77e4fSmickey  *    documentation and/or other materials provided with the distribution.
151de77e4fSmickey  * 3. All advertising materials mentioning features or use of this software
161de77e4fSmickey  *    must display the following acknowledgement:
171de77e4fSmickey  *	This product includes software developed by Thomas Skibo.
181de77e4fSmickey  * 4. Neither the name of the author nor the names of any co-contributors
191de77e4fSmickey  *    may be used to endorse or promote products derived from this software
201de77e4fSmickey  *    without specific prior written permission.
211de77e4fSmickey  *
221de77e4fSmickey  * THIS SOFTWARE IS PROVIDED BY Thomas Skibo AND CONTRIBUTORS ``AS IS'' AND
231de77e4fSmickey  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
241de77e4fSmickey  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
251de77e4fSmickey  * ARE DISCLAIMED.  IN NO EVENT SHALL Thomas Skibo OR HIS DRINKING PALS
261de77e4fSmickey  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
271de77e4fSmickey  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
281de77e4fSmickey  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
291de77e4fSmickey  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
301de77e4fSmickey  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
311de77e4fSmickey  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
321de77e4fSmickey  * THE POSSIBILITY OF SUCH DAMAGE.
331de77e4fSmickey  *
341de77e4fSmickey  * $FreeBSD: $
351de77e4fSmickey  */
361de77e4fSmickey 
371de77e4fSmickey #ifndef __WI_HOSTAP_H__
381de77e4fSmickey #define __WI_HOSTAP_H__
391de77e4fSmickey 
401de77e4fSmickey #define WIHAP_MAX_STATIONS	1800
411de77e4fSmickey 
421de77e4fSmickey struct hostap_sta {
431de77e4fSmickey 	u_int8_t	addr[6];
441de77e4fSmickey 	u_int16_t	asid;
451de77e4fSmickey 	u_int16_t	flags;
461de77e4fSmickey 	u_int16_t	sig_info;	/* 15:8 signal, 7:0 noise */
471de77e4fSmickey 	u_int16_t	capinfo;
481de77e4fSmickey 	u_int8_t	rates;
491de77e4fSmickey };
501de77e4fSmickey 
511de77e4fSmickey #define HOSTAP_FLAGS_AUTHEN	0x0001
521de77e4fSmickey #define HOSTAP_FLAGS_ASSOC	0x0002
531de77e4fSmickey #define HOSTAP_FLAGS_PERM	0x0004
54a0ba2fb4Smickey #define	HOSTAP_FLAGS_BITS	"\20\01AUTH\02ASSOC\03PERM"
551de77e4fSmickey 
56*cfe90bb7Szhuk #define SIOCHOSTAP_GET		_IOWR('i', 200, struct ifreq)
57*cfe90bb7Szhuk #define SIOCHOSTAP_ADD		_IOWR('i', 201, struct ifreq)
58*cfe90bb7Szhuk #define SIOCHOSTAP_DEL		_IOWR('i', 202, struct ifreq)
59*cfe90bb7Szhuk #define SIOCHOSTAP_GETALL	_IOWR('i', 203, struct ifreq)
60*cfe90bb7Szhuk #define SIOCHOSTAP_GFLAGS	_IOWR('i', 204, struct ifreq)
61*cfe90bb7Szhuk #define SIOCHOSTAP_SFLAGS	_IOWR('i', 205, struct ifreq)
621de77e4fSmickey 
631de77e4fSmickey /* Flags for SIOCHOSTAP_GFLAGS/SFLAGS */
641de77e4fSmickey #define WIHAPFL_ACTIVE		0x0001
651de77e4fSmickey #define WIHAPFL_MAC_FILT	0x0002
661de77e4fSmickey 
672408ed96Sjmc /* Flags set internally only: */
681de77e4fSmickey #define WIHAPFL_CANTCHANGE	(WIHAPFL_ACTIVE)
691de77e4fSmickey 
701de77e4fSmickey struct hostap_getall {
711de77e4fSmickey 	int		nstations;
721de77e4fSmickey 	struct hostap_sta *addr;
731de77e4fSmickey 	int		size;
741de77e4fSmickey };
751de77e4fSmickey 
761de77e4fSmickey 
771de77e4fSmickey 
781de77e4fSmickey #ifdef _KERNEL
791de77e4fSmickey struct wihap_sta_info {
804870d24cSmillert 	TAILQ_ENTRY(wihap_sta_info) list;
811de77e4fSmickey 	LIST_ENTRY(wihap_sta_info) hash;
821de77e4fSmickey 
831de77e4fSmickey 	struct wi_softc	*sc;
841de77e4fSmickey 	u_int8_t	addr[6];
851de77e4fSmickey 	u_short		flags;
861de77e4fSmickey 	struct timeout	tmo;
871de77e4fSmickey 
881de77e4fSmickey 	u_int16_t	asid;
891de77e4fSmickey 	u_int16_t	capinfo;
901de77e4fSmickey 	u_int16_t	sig_info;	/* 15:8 signal, 7:0 noise */
911de77e4fSmickey 	u_int8_t	rates;
921de77e4fSmickey 	u_int8_t	tx_curr_rate;
931de77e4fSmickey 	u_int8_t	tx_max_rate;
9441ad21efSmillert 	u_int32_t	*challenge;
951de77e4fSmickey };
961de77e4fSmickey 
971de77e4fSmickey #define WI_SIFLAGS_ASSOC	HOSTAP_FLAGS_ASSOC
981de77e4fSmickey #define WI_SIFLAGS_AUTHEN	HOSTAP_FLAGS_AUTHEN
991de77e4fSmickey #define WI_SIFLAGS_PERM		HOSTAP_FLAGS_PERM
1004870d24cSmillert #define WI_SIFLAGS_DEAD		0x1000
1011de77e4fSmickey 
1021de77e4fSmickey #define WI_STA_HASH_SIZE	113
1031de77e4fSmickey 
1041de77e4fSmickey #if WI_STA_HASH_SIZE*16 >= 2007 /* will generate ASID's too large. */
1051de77e4fSmickey #error "WI_STA_HASH_SIZE too big"
1061de77e4fSmickey #endif
1071de77e4fSmickey #if WI_STA_HASH_SIZE*16 < WIHAP_MAX_STATIONS
1081de77e4fSmickey #error "WI_STA_HASH_SIZE too small"
1091de77e4fSmickey #endif
1101de77e4fSmickey 
1111de77e4fSmickey struct wihap_info {
1124870d24cSmillert 	TAILQ_HEAD(sta_list, wihap_sta_info)	sta_list;
1131de77e4fSmickey 	LIST_HEAD(sta_hash, wihap_sta_info)	sta_hash[WI_STA_HASH_SIZE];
1141de77e4fSmickey 
1151de77e4fSmickey 	u_int16_t		apflags;
1161de77e4fSmickey 
1171de77e4fSmickey 	int			n_stations;
1181de77e4fSmickey 	u_int16_t		asid_inuse_mask[WI_STA_HASH_SIZE];
1191de77e4fSmickey 
1201de77e4fSmickey 	int			inactivity_time;
1214870d24cSmillert 	struct timeout		tmo;
1221de77e4fSmickey };
1231de77e4fSmickey 
12418a12528Smickey #define WIHAP_DFLT_INACTIVITY_TIME	(120) /* 2 minutes */
1251de77e4fSmickey 
1261de77e4fSmickey struct wi_softc;
1271de77e4fSmickey struct wi_frame;
1281de77e4fSmickey 
129251746b5Smillert int	wihap_check_tx(struct wihap_info *, u_int8_t [], u_int8_t *);
130251746b5Smillert int	wihap_data_input(struct wi_softc *, struct wi_frame *, struct mbuf *);
131251746b5Smillert int	wihap_ioctl(struct wi_softc *, u_long, caddr_t);
132251746b5Smillert void	wihap_init(struct wi_softc *);
133251746b5Smillert void	wihap_mgmt_input(struct wi_softc *, struct wi_frame *, struct mbuf *);
134251746b5Smillert void	wihap_shutdown(struct wi_softc *);
1351de77e4fSmickey 
1361de77e4fSmickey #endif /* _KERNEL */
1371de77e4fSmickey #endif /* __WI_HOSTAP_H__ */
138