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