Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / dev / netif / wi / wi_hostap.h
1 /*
2  * Copyright (c) 2002
3  *      Thomas Skibo <skibo@pacbell.net>.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *      This product includes software developed by Thomas Skibo.
16  * 4. Neither the name of the author nor the names of any co-contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY Thomas Skibo AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL Thomas Skibo OR HIS DRINKING PALS
24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30  * THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * $FreeBSD: src/sys/dev/wi/wi_hostap.h,v 1.3.2.3 2002/08/02 07:11:34 imp Exp $
33  */
34
35 #ifndef __WI_HOSTAP_H__
36 #define __WI_HOSTAP_H__
37
38 #define WIHAP_MAX_STATIONS      1800
39
40 struct hostap_sta {
41         u_int8_t        addr[6];
42         u_int16_t       asid;
43         u_int16_t       flags;
44         u_int16_t       sig_info;       /* 15:8 signal, 7:0 noise */
45         u_int16_t       capinfo;
46         u_int8_t        rates;
47 };
48
49 #define HOSTAP_FLAGS_AUTHEN     0x0001
50 #define HOSTAP_FLAGS_ASSOC      0x0002
51 #define HOSTAP_FLAGS_PERM       0x0004
52 #define HOSTAP_FLAGS_BITS       "\20\01ASSOC\02AUTH\03PERM"
53
54 #define SIOCHOSTAP_GET          _IOWR('i', 210, struct ifreq)
55 #define SIOCHOSTAP_ADD          _IOWR('i', 211, struct ifreq)
56 #define SIOCHOSTAP_DEL          _IOWR('i', 212, struct ifreq)
57 #define SIOCHOSTAP_GETALL       _IOWR('i', 213, struct ifreq)
58 #define SIOCHOSTAP_GFLAGS       _IOWR('i', 214, struct ifreq)
59 #define SIOCHOSTAP_SFLAGS       _IOWR('i', 215, struct ifreq)
60
61 /* Flags for SIOCHOSTAP_GFLAGS/SFLAGS */
62 #define WIHAPFL_ACTIVE          0x0001
63 #define WIHAPFL_MAC_FILT        0x0002
64
65 /* Flags set inernally only: */
66 #define WIHAPFL_CANTCHANGE      (WIHAPFL_ACTIVE)
67
68 struct hostap_getall {
69         int             nstations;
70         struct hostap_sta *addr;
71         int             size;
72 };
73
74
75
76 #ifdef _KERNEL
77 struct wihap_sta_info {
78         LIST_ENTRY(wihap_sta_info) list;
79         LIST_ENTRY(wihap_sta_info) hash;
80
81         struct wi_softc *sc;
82         u_int8_t        addr[6];
83         u_short         flags;
84         int             inactivity_timer;
85
86         u_int16_t       asid;
87         u_int16_t       capinfo;
88         u_int16_t       sig_info;       /* 15:8 signal, 7:0 noise */
89         u_int8_t        rates;
90         u_int8_t        tx_curr_rate;
91         u_int8_t        tx_max_rate;
92         u_int32_t       *challenge;
93         struct callout_handle   tmo;
94 };
95
96 #define WI_SIFLAGS_ASSOC        HOSTAP_FLAGS_ASSOC
97 #define WI_SIFLAGS_AUTHEN       HOSTAP_FLAGS_AUTHEN
98 #define WI_SIFLAGS_PERM         HOSTAP_FLAGS_PERM
99
100 #define WI_STA_HASH_SIZE        113
101
102 #if WI_STA_HASH_SIZE*16 >= 2007 /* will generate ASID's too large. */
103 #error "WI_STA_HASH_SIZE too big"
104 #endif
105 #if WI_STA_HASH_SIZE*16 < WIHAP_MAX_STATIONS
106 #error "WI_STA_HASH_SIZE too small"
107 #endif
108
109 struct wihap_info {
110         LIST_HEAD(sta_list, wihap_sta_info)     sta_list;
111         LIST_HEAD(sta_hash, wihap_sta_info)     sta_hash[WI_STA_HASH_SIZE];
112
113         u_int16_t               apflags;
114
115         int                     n_stations;
116         u_int16_t               asid_inuse_mask[WI_STA_HASH_SIZE];
117
118         int                     inactivity_time;
119 };
120
121 #define WIHAP_INTERVAL                  5
122 #define WIHAP_DFLT_INACTIVITY_TIME      120     /* 2 minutes */
123
124 struct wi_softc;
125 struct wi_frame;
126
127 void wihap_timer(void *);
128 void wihap_mgmt_input(struct wi_softc *, struct wi_frame *, struct mbuf *);
129 int  wihap_data_input(struct wi_softc *, struct wi_frame *, struct mbuf *);
130 int  wihap_check_tx(struct wihap_info *, u_int8_t [], u_int8_t *);
131 void wihap_init(struct wi_softc *);
132 void wihap_shutdown(struct wi_softc *);
133 int  wihap_ioctl(struct wi_softc *, u_long, caddr_t);
134
135 #endif /* _KERNEL */
136 #endif /* __WI_HOSTAP_H__ */