1/*-
2 * Copyright (c) 2010 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Shteryana Sotirova Shopova under
6 * sponsorship from the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $FreeBSD$
30 */
31
32#define	WLAN_IFMODE_MAX				WlanIfaceOperatingModeType_tdma
33#define	WLAN_COUNTRY_CODE_SIZE			3
34#define	WLAN_BGSCAN_IDLE_MIN			100 /* XXX */
35#define	WLAN_SCAN_VALID_MIN			10 /* XXX */
36#define	WLAN_TDMA_MAXSLOTS			2 /* XXX */
37
38struct wlan_iface;
39
40struct wlan_peer {
41	uint8_t				pmac[IEEE80211_ADDR_LEN]; /* key */
42	uint16_t			associd;
43	uint16_t			vlan;
44	uint16_t			frequency;
45	uint32_t			fflags;
46	uint8_t				txrate;
47	int8_t				rssi;
48	uint16_t			idle;
49	uint16_t			txseqs;
50	uint16_t			rxseqs;
51	uint16_t			txpower;
52	uint8_t				capinfo;
53	uint32_t			state;
54	uint16_t			local_id;
55	uint16_t			peer_id;
56	SLIST_ENTRY(wlan_peer)		wp;
57};
58
59SLIST_HEAD(wlan_peerlist, wlan_peer);
60
61struct wlan_scan_result {
62	uint8_t				ssid[IEEE80211_NWID_LEN + 1];
63	uint8_t				bssid[IEEE80211_ADDR_LEN];
64	uint8_t				opchannel;
65	int8_t				rssi;
66	uint16_t			frequency;
67	int8_t				noise;
68	uint16_t			bintval;
69	uint8_t				capinfo;
70	struct wlan_iface		*pwif;
71	SLIST_ENTRY(wlan_scan_result)	wsr;
72};
73
74SLIST_HEAD(wlan_scanlist, wlan_scan_result);
75
76struct wlan_mac_mac {
77	uint8_t				mac[IEEE80211_ADDR_LEN];
78	enum RowStatus			mac_status;
79	SLIST_ENTRY(wlan_mac_mac)	wm;
80};
81
82SLIST_HEAD(wlan_maclist, wlan_mac_mac);
83
84struct wlan_mesh_route {
85	struct ieee80211req_mesh_route	imroute;
86	enum RowStatus			mroute_status;
87	SLIST_ENTRY(wlan_mesh_route)	wr;
88};
89
90SLIST_HEAD(wlan_mesh_routes, wlan_mesh_route);
91
92struct wlan_iface {
93	char				wname[IFNAMSIZ];
94	uint32_t			index;
95	char				pname[IFNAMSIZ];
96	enum WlanIfaceOperatingModeType	mode;
97	uint32_t			flags;
98	uint8_t				dbssid[IEEE80211_ADDR_LEN];
99	uint8_t				dlmac[IEEE80211_ADDR_LEN];
100	enum RowStatus			status;
101	enum wlanIfaceState		state;
102	uint8_t				internal;
103
104	uint32_t			drivercaps;
105	uint32_t			cryptocaps;
106	uint32_t			htcaps;
107
108	uint32_t			packet_burst;
109	uint8_t				country_code[WLAN_COUNTRY_CODE_SIZE];
110	enum WlanRegDomainCode		reg_domain;
111	uint8_t				desired_ssid[IEEE80211_NWID_LEN + 1];
112	uint32_t			desired_channel;
113	enum TruthValue			dyn_frequency;
114	enum TruthValue			fast_frames;
115	enum TruthValue			dturbo;
116	int32_t				tx_power;
117	int32_t				frag_threshold;
118	int32_t				rts_threshold;
119	enum TruthValue			priv_subscribe;
120	enum TruthValue			bg_scan;
121	int32_t				bg_scan_idle;
122	int32_t				bg_scan_interval;
123	int32_t				beacons_missed;
124	uint8_t				desired_bssid[IEEE80211_ADDR_LEN];
125	enum wlanIfaceRoamingMode	roam_mode;
126	enum TruthValue			dot11d;
127	enum TruthValue			dot11h;
128	enum TruthValue			dynamic_wds;
129	enum TruthValue			power_save;
130	enum TruthValue			ap_bridge;
131	int32_t				beacon_interval;
132	int32_t				dtim_period;
133	enum TruthValue			hide_ssid;
134	enum TruthValue			inact_process;
135	enum wlanIfaceDot11gProtMode	do11g_protect;
136	enum TruthValue			dot11g_pure;
137	enum TruthValue			dot11n_pure;
138	enum WlanIfaceDot11nPduType	ampdu;
139	int32_t				ampdu_density;
140	int32_t				ampdu_limit;
141	enum WlanIfaceDot11nPduType	amsdu;
142	int32_t				amsdu_limit;
143	enum TruthValue			ht_enabled;
144	enum TruthValue			ht_compatible;
145	enum wlanIfaceDot11nHTProtMode	ht_prot_mode;
146	enum TruthValue			rifs;
147	enum TruthValue			short_gi;
148	enum wlanIfaceDot11nSMPSMode	smps_mode;
149	int32_t				tdma_slot;
150	int32_t				tdma_slot_count;
151	int32_t				tdma_slot_length;
152	int32_t				tdma_binterval;
153
154	struct wlan_peerlist		peerlist;
155	struct ieee80211_stats		stats;
156	uint32_t			nchannels;
157	struct ieee80211_channel	*chanlist;
158	struct ieee80211_roamparams_req	roamparams;
159	struct ieee80211_txparams_req	txparams;
160
161	uint32_t			scan_flags;
162	uint32_t			scan_duration;
163	uint32_t			scan_mindwell;
164	uint32_t			scan_maxdwell;
165	enum wlanScanConfigStatus	scan_status;
166	struct wlan_scanlist		scanlist;
167
168	uint8_t				wepsupported;
169	enum wlanWepMode		wepmode;
170	int32_t				weptxkey;
171
172	uint8_t				macsupported;
173	enum wlanMACAccessControlPolicy	mac_policy;
174	uint32_t			mac_nacls;
175	struct wlan_maclist		mac_maclist;
176
177	uint32_t			mesh_ttl;
178	enum wlanMeshPeeringEnabled	mesh_peering;
179	enum wlanMeshForwardingEnabled	mesh_forwarding;
180	enum wlanMeshMetric		mesh_metric;
181	enum wlanMeshPath		mesh_path;
182	enum wlanHWMPRootMode		hwmp_root_mode;
183	uint32_t			hwmp_max_hops;
184	struct wlan_mesh_routes		mesh_routelist;
185
186	SLIST_ENTRY(wlan_iface)		w_if;
187};
188
189enum wlan_syscl {
190	WLAN_MESH_RETRY_TO = 0,
191	WLAN_MESH_HOLDING_TO,
192	WLAN_MESH_CONFIRM_TO,
193	WLAN_MESH_MAX_RETRIES,
194	WLAN_HWMP_TARGET_ONLY,
195	WLAN_HWMP_REPLY_FORWARD,
196	WLAN_HWMP_PATH_LIFETIME,
197	WLAN_HWMP_ROOT_TO,
198	WLAN_HWMP_ROOT_INT,
199	WLAN_HWMP_RANN_INT,
200	WLAN_HWMP_INACTIVITY_TO,
201	WLAN_SYSCTL_MAX
202};
203
204struct wlan_config {
205	int32_t				mesh_retryto;
206	int32_t				mesh_holdingto;
207	int32_t				mesh_confirmto;
208	int32_t				mesh_maxretries;
209	int32_t				hwmp_targetonly;
210	int32_t				hwmp_replyforward;
211	int32_t				hwmp_pathlifetime;
212	int32_t				hwmp_roottimeout;
213	int32_t				hwmp_rootint;
214	int32_t				hwmp_rannint;
215	int32_t				hwmp_inact;
216};
217
218int wlan_ioctl_init(void);
219int wlan_kmodules_load(void);
220int wlan_check_media(char *);
221int wlan_config_state(struct wlan_iface *, uint8_t);
222int wlan_get_opmode(struct wlan_iface *wif);
223int wlan_get_local_addr(struct wlan_iface *wif);
224int wlan_get_parent(struct wlan_iface *wif);
225int wlan_get_driver_caps(struct wlan_iface *wif);
226uint8_t wlan_channel_state_to_snmp(uint8_t cstate);
227uint32_t wlan_channel_flags_to_snmp(uint32_t cflags);
228int wlan_get_channel_list(struct wlan_iface *wif);
229int wlan_get_roam_params(struct wlan_iface *wif);
230int wlan_get_tx_params(struct wlan_iface *wif);
231int wlan_set_tx_params(struct wlan_iface *wif, int32_t pmode);
232int wlan_clone_create(struct wlan_iface *);
233int wlan_clone_destroy(struct wlan_iface *wif);
234int wlan_config_get_dssid(struct wlan_iface *wif);
235int wlan_config_set_dssid(struct wlan_iface *wif, char *ssid, int slen);
236int wlan_config_get_ioctl(struct wlan_iface *wif, int which);
237int wlan_config_set_ioctl(struct wlan_iface *wif, int which, int val,
238    char *strval, int len);
239int wlan_set_scan_config(struct wlan_iface *wif);
240int wlan_get_scan_results(struct wlan_iface *wif);
241int wlan_get_stats(struct wlan_iface *wif);
242int wlan_get_wepmode(struct wlan_iface *wif);
243int wlan_set_wepmode(struct wlan_iface *wif);
244int wlan_get_weptxkey(struct wlan_iface *wif);
245int wlan_set_weptxkey(struct wlan_iface *wif);
246int wlan_get_wepkeys(struct wlan_iface *wif);
247int wlan_set_wepkeys(struct wlan_iface *wif);
248int wlan_get_mac_policy(struct wlan_iface *wif);
249int wlan_set_mac_policy(struct wlan_iface *wif);
250int wlan_flush_mac_mac(struct wlan_iface *wif);
251int wlan_get_mac_acl_macs(struct wlan_iface *wif);
252int wlan_add_mac_acl_mac(struct wlan_iface *wif, struct wlan_mac_mac *mmac);
253int wlan_del_mac_acl_mac(struct wlan_iface *wif, struct wlan_mac_mac *mmac);
254
255int32_t wlan_do_sysctl(struct wlan_config *cfg, enum wlan_syscl which, int set);
256int wlan_mesh_config_get(struct wlan_iface *wif, int which);
257int wlan_mesh_config_set(struct wlan_iface *wif, int which);
258int wlan_mesh_flush_routes(struct wlan_iface *wif);
259int wlan_mesh_add_route(struct wlan_iface *wif, struct wlan_mesh_route *wmr);
260int wlan_mesh_del_route(struct wlan_iface *wif, struct wlan_mesh_route *wmr);
261int wlan_mesh_get_routelist(struct wlan_iface *wif);
262int wlan_hwmp_config_get(struct wlan_iface *wif, int which);
263int wlan_hwmp_config_set(struct wlan_iface *wif, int which);
264
265/* XXX: static */
266
267int wlan_peer_set_vlan(struct wlan_iface *wif, struct wlan_peer *wip, int vlan);
268int wlan_get_peerinfo(struct wlan_iface *wif);
269
270/* XXX*/
271struct wlan_peer *wlan_new_peer(const uint8_t *pmac);
272void wlan_free_peer(struct wlan_peer *wip);
273int wlan_add_peer(struct wlan_iface *wif, struct wlan_peer *wip);
274
275struct wlan_scan_result * wlan_scan_new_result(const uint8_t *ssid,
276    const uint8_t *bssid);
277void wlan_scan_free_result(struct wlan_scan_result *sr);
278int wlan_scan_add_result(struct wlan_iface *wif, struct wlan_scan_result *sr);
279
280struct wlan_mac_mac *wlan_mac_new_mac(const uint8_t *mac);
281void wlan_mac_free_mac(struct wlan_mac_mac *wmm);
282int wlan_mac_add_mac(struct wlan_iface *wif, struct wlan_mac_mac *wmm);
283
284struct wlan_mesh_route *wlan_mesh_new_route(const uint8_t *dstmac);
285int wlan_mesh_add_rtentry(struct wlan_iface *wif, struct wlan_mesh_route *wmr);
286void wlan_mesh_free_route(struct wlan_mesh_route *wmr);
287