xref: /freebsd/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_snmp.h (revision 3078531de10dcae44b253a35125c949ff4235284)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
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  * $FreeBSD$
31  */
32 
33 #define	WLAN_IFMODE_MAX				WlanIfaceOperatingModeType_tdma
34 #define	WLAN_COUNTRY_CODE_SIZE			3
35 #define	WLAN_BGSCAN_IDLE_MIN			100 /* XXX */
36 #define	WLAN_SCAN_VALID_MIN			10 /* XXX */
37 #define	WLAN_TDMA_MAXSLOTS			2 /* XXX */
38 
39 struct wlan_iface;
40 
41 struct wlan_peer {
42 	uint8_t				pmac[IEEE80211_ADDR_LEN]; /* key */
43 	uint16_t			associd;
44 	uint16_t			vlan;
45 	uint16_t			frequency;
46 	uint32_t			fflags;
47 	uint8_t				txrate;
48 	int8_t				rssi;
49 	uint16_t			idle;
50 	uint16_t			txseqs;
51 	uint16_t			rxseqs;
52 	uint16_t			txpower;
53 	uint8_t				capinfo;
54 	uint32_t			state;
55 	uint16_t			local_id;
56 	uint16_t			peer_id;
57 	SLIST_ENTRY(wlan_peer)		wp;
58 };
59 
60 SLIST_HEAD(wlan_peerlist, wlan_peer);
61 
62 struct wlan_scan_result {
63 	uint8_t				ssid[IEEE80211_NWID_LEN + 1];
64 	uint8_t				bssid[IEEE80211_ADDR_LEN];
65 	uint8_t				opchannel;
66 	int8_t				rssi;
67 	uint16_t			frequency;
68 	int8_t				noise;
69 	uint16_t			bintval;
70 	uint8_t				capinfo;
71 	struct wlan_iface		*pwif;
72 	SLIST_ENTRY(wlan_scan_result)	wsr;
73 };
74 
75 SLIST_HEAD(wlan_scanlist, wlan_scan_result);
76 
77 struct wlan_mac_mac {
78 	uint8_t				mac[IEEE80211_ADDR_LEN];
79 	enum RowStatus			mac_status;
80 	SLIST_ENTRY(wlan_mac_mac)	wm;
81 };
82 
83 SLIST_HEAD(wlan_maclist, wlan_mac_mac);
84 
85 struct wlan_mesh_route {
86 	struct ieee80211req_mesh_route	imroute;
87 	enum RowStatus			mroute_status;
88 	SLIST_ENTRY(wlan_mesh_route)	wr;
89 };
90 
91 SLIST_HEAD(wlan_mesh_routes, wlan_mesh_route);
92 
93 struct wlan_iface {
94 	char				wname[IFNAMSIZ];
95 	uint32_t			index;
96 	char				pname[IFNAMSIZ];
97 	enum WlanIfaceOperatingModeType	mode;
98 	uint32_t			flags;
99 	uint8_t				dbssid[IEEE80211_ADDR_LEN];
100 	uint8_t				dlmac[IEEE80211_ADDR_LEN];
101 	enum RowStatus			status;
102 	enum wlanIfaceState		state;
103 	uint8_t				internal;
104 
105 	uint32_t			drivercaps;
106 	uint32_t			cryptocaps;
107 	uint32_t			htcaps;
108 
109 	uint32_t			packet_burst;
110 	uint8_t				country_code[WLAN_COUNTRY_CODE_SIZE];
111 	enum WlanRegDomainCode		reg_domain;
112 	uint8_t				desired_ssid[IEEE80211_NWID_LEN + 1];
113 	uint32_t			desired_channel;
114 	enum TruthValue			dyn_frequency;
115 	enum TruthValue			fast_frames;
116 	enum TruthValue			dturbo;
117 	int32_t				tx_power;
118 	int32_t				frag_threshold;
119 	int32_t				rts_threshold;
120 	enum TruthValue			priv_subscribe;
121 	enum TruthValue			bg_scan;
122 	int32_t				bg_scan_idle;
123 	int32_t				bg_scan_interval;
124 	int32_t				beacons_missed;
125 	uint8_t				desired_bssid[IEEE80211_ADDR_LEN];
126 	enum wlanIfaceRoamingMode	roam_mode;
127 	enum TruthValue			dot11d;
128 	enum TruthValue			dot11h;
129 	enum TruthValue			dynamic_wds;
130 	enum TruthValue			power_save;
131 	enum TruthValue			ap_bridge;
132 	int32_t				beacon_interval;
133 	int32_t				dtim_period;
134 	enum TruthValue			hide_ssid;
135 	enum TruthValue			inact_process;
136 	enum wlanIfaceDot11gProtMode	do11g_protect;
137 	enum TruthValue			dot11g_pure;
138 	enum TruthValue			dot11n_pure;
139 	enum WlanIfaceDot11nPduType	ampdu;
140 	int32_t				ampdu_density;
141 	int32_t				ampdu_limit;
142 	enum WlanIfaceDot11nPduType	amsdu;
143 	int32_t				amsdu_limit;
144 	enum TruthValue			ht_enabled;
145 	enum TruthValue			ht_compatible;
146 	enum wlanIfaceDot11nHTProtMode	ht_prot_mode;
147 	enum TruthValue			rifs;
148 	enum TruthValue			short_gi;
149 	enum wlanIfaceDot11nSMPSMode	smps_mode;
150 	int32_t				tdma_slot;
151 	int32_t				tdma_slot_count;
152 	int32_t				tdma_slot_length;
153 	int32_t				tdma_binterval;
154 
155 	struct wlan_peerlist		peerlist;
156 	struct ieee80211_stats		stats;
157 	uint32_t			nchannels;
158 	struct ieee80211_channel	*chanlist;
159 	struct ieee80211_roamparams_req	roamparams;
160 	struct ieee80211_txparams_req	txparams;
161 
162 	uint32_t			scan_flags;
163 	uint32_t			scan_duration;
164 	uint32_t			scan_mindwell;
165 	uint32_t			scan_maxdwell;
166 	enum wlanScanConfigStatus	scan_status;
167 	struct wlan_scanlist		scanlist;
168 
169 	uint8_t				wepsupported;
170 	enum wlanWepMode		wepmode;
171 	int32_t				weptxkey;
172 
173 	uint8_t				macsupported;
174 	enum wlanMACAccessControlPolicy	mac_policy;
175 	uint32_t			mac_nacls;
176 	struct wlan_maclist		mac_maclist;
177 
178 	uint32_t			mesh_ttl;
179 	enum wlanMeshPeeringEnabled	mesh_peering;
180 	enum wlanMeshForwardingEnabled	mesh_forwarding;
181 	enum wlanMeshMetric		mesh_metric;
182 	enum wlanMeshPath		mesh_path;
183 	enum wlanHWMPRootMode		hwmp_root_mode;
184 	uint32_t			hwmp_max_hops;
185 	struct wlan_mesh_routes		mesh_routelist;
186 
187 	SLIST_ENTRY(wlan_iface)		w_if;
188 };
189 
190 enum wlan_syscl {
191 	WLAN_MESH_RETRY_TO = 0,
192 	WLAN_MESH_HOLDING_TO,
193 	WLAN_MESH_CONFIRM_TO,
194 	WLAN_MESH_MAX_RETRIES,
195 	WLAN_HWMP_TARGET_ONLY,
196 	WLAN_HWMP_REPLY_FORWARD,
197 	WLAN_HWMP_PATH_LIFETIME,
198 	WLAN_HWMP_ROOT_TO,
199 	WLAN_HWMP_ROOT_INT,
200 	WLAN_HWMP_RANN_INT,
201 	WLAN_HWMP_INACTIVITY_TO,
202 	WLAN_SYSCTL_MAX
203 };
204 
205 struct wlan_config {
206 	int32_t				mesh_retryto;
207 	int32_t				mesh_holdingto;
208 	int32_t				mesh_confirmto;
209 	int32_t				mesh_maxretries;
210 	int32_t				hwmp_targetonly;
211 	int32_t				hwmp_replyforward;
212 	int32_t				hwmp_pathlifetime;
213 	int32_t				hwmp_roottimeout;
214 	int32_t				hwmp_rootint;
215 	int32_t				hwmp_rannint;
216 	int32_t				hwmp_inact;
217 };
218 
219 int wlan_ioctl_init(void);
220 int wlan_kmodules_load(void);
221 int wlan_check_media(char *);
222 int wlan_config_state(struct wlan_iface *, uint8_t);
223 int wlan_get_opmode(struct wlan_iface *wif);
224 int wlan_get_local_addr(struct wlan_iface *wif);
225 int wlan_get_parent(struct wlan_iface *wif);
226 int wlan_get_driver_caps(struct wlan_iface *wif);
227 uint8_t wlan_channel_state_to_snmp(uint8_t cstate);
228 uint32_t wlan_channel_flags_to_snmp(uint32_t cflags);
229 int wlan_get_channel_list(struct wlan_iface *wif);
230 int wlan_get_roam_params(struct wlan_iface *wif);
231 int wlan_get_tx_params(struct wlan_iface *wif);
232 int wlan_set_tx_params(struct wlan_iface *wif, int32_t pmode);
233 int wlan_clone_create(struct wlan_iface *);
234 int wlan_clone_destroy(struct wlan_iface *wif);
235 int wlan_config_get_dssid(struct wlan_iface *wif);
236 int wlan_config_set_dssid(struct wlan_iface *wif, char *ssid, int slen);
237 int wlan_config_get_ioctl(struct wlan_iface *wif, int which);
238 int wlan_config_set_ioctl(struct wlan_iface *wif, int which, int val,
239     char *strval, int len);
240 int wlan_set_scan_config(struct wlan_iface *wif);
241 int wlan_get_scan_results(struct wlan_iface *wif);
242 int wlan_get_stats(struct wlan_iface *wif);
243 int wlan_get_wepmode(struct wlan_iface *wif);
244 int wlan_set_wepmode(struct wlan_iface *wif);
245 int wlan_get_weptxkey(struct wlan_iface *wif);
246 int wlan_set_weptxkey(struct wlan_iface *wif);
247 int wlan_get_wepkeys(struct wlan_iface *wif);
248 int wlan_set_wepkeys(struct wlan_iface *wif);
249 int wlan_get_mac_policy(struct wlan_iface *wif);
250 int wlan_set_mac_policy(struct wlan_iface *wif);
251 int wlan_flush_mac_mac(struct wlan_iface *wif);
252 int wlan_get_mac_acl_macs(struct wlan_iface *wif);
253 int wlan_add_mac_acl_mac(struct wlan_iface *wif, struct wlan_mac_mac *mmac);
254 int wlan_del_mac_acl_mac(struct wlan_iface *wif, struct wlan_mac_mac *mmac);
255 
256 int32_t wlan_do_sysctl(struct wlan_config *cfg, enum wlan_syscl which, int set);
257 int wlan_mesh_config_get(struct wlan_iface *wif, int which);
258 int wlan_mesh_config_set(struct wlan_iface *wif, int which);
259 int wlan_mesh_flush_routes(struct wlan_iface *wif);
260 int wlan_mesh_add_route(struct wlan_iface *wif, struct wlan_mesh_route *wmr);
261 int wlan_mesh_del_route(struct wlan_iface *wif, struct wlan_mesh_route *wmr);
262 int wlan_mesh_get_routelist(struct wlan_iface *wif);
263 int wlan_hwmp_config_get(struct wlan_iface *wif, int which);
264 int wlan_hwmp_config_set(struct wlan_iface *wif, int which);
265 
266 /* XXX: static */
267 
268 int wlan_peer_set_vlan(struct wlan_iface *wif, struct wlan_peer *wip, int vlan);
269 int wlan_get_peerinfo(struct wlan_iface *wif);
270 
271 /* XXX*/
272 struct wlan_peer *wlan_new_peer(const uint8_t *pmac);
273 void wlan_free_peer(struct wlan_peer *wip);
274 int wlan_add_peer(struct wlan_iface *wif, struct wlan_peer *wip);
275 
276 struct wlan_scan_result * wlan_scan_new_result(const uint8_t *ssid,
277     const uint8_t *bssid);
278 void wlan_scan_free_result(struct wlan_scan_result *sr);
279 int wlan_scan_add_result(struct wlan_iface *wif, struct wlan_scan_result *sr);
280 
281 struct wlan_mac_mac *wlan_mac_new_mac(const uint8_t *mac);
282 void wlan_mac_free_mac(struct wlan_mac_mac *wmm);
283 int wlan_mac_add_mac(struct wlan_iface *wif, struct wlan_mac_mac *wmm);
284 
285 struct wlan_mesh_route *wlan_mesh_new_route(const uint8_t *dstmac);
286 int wlan_mesh_add_rtentry(struct wlan_iface *wif, struct wlan_mesh_route *wmr);
287 void wlan_mesh_free_route(struct wlan_mesh_route *wmr);
288