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