xref: /freebsd/usr.sbin/bsnmpd/modules/snmp_wlan/wlan_snmp.h (revision 1de7b4b805ddbf2429da511c053686ac4591ed89)
109cbe818SShteryana Shopova /*-
2*1de7b4b8SPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3*1de7b4b8SPedro F. Giffuni  *
409cbe818SShteryana Shopova  * Copyright (c) 2010 The FreeBSD Foundation
509cbe818SShteryana Shopova  * All rights reserved.
609cbe818SShteryana Shopova  *
709cbe818SShteryana Shopova  * This software was developed by Shteryana Sotirova Shopova under
809cbe818SShteryana Shopova  * sponsorship from the FreeBSD Foundation.
909cbe818SShteryana Shopova  *
1009cbe818SShteryana Shopova  * Redistribution and use in source and binary forms, with or without
1109cbe818SShteryana Shopova  * modification, are permitted provided that the following conditions
1209cbe818SShteryana Shopova  * are met:
1309cbe818SShteryana Shopova  * 1. Redistributions of source code must retain the above copyright
1409cbe818SShteryana Shopova  *    notice, this list of conditions and the following disclaimer.
1509cbe818SShteryana Shopova  * 2. Redistributions in binary form must reproduce the above copyright
1609cbe818SShteryana Shopova  *    notice, this list of conditions and the following disclaimer in the
1709cbe818SShteryana Shopova  *    documentation and/or other materials provided with the distribution.
1809cbe818SShteryana Shopova  *
1909cbe818SShteryana Shopova  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2009cbe818SShteryana Shopova  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2109cbe818SShteryana Shopova  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2209cbe818SShteryana Shopova  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2309cbe818SShteryana Shopova  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2409cbe818SShteryana Shopova  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2509cbe818SShteryana Shopova  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2609cbe818SShteryana Shopova  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2709cbe818SShteryana Shopova  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2809cbe818SShteryana Shopova  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2909cbe818SShteryana Shopova  * SUCH DAMAGE.
3009cbe818SShteryana Shopova  *
3109cbe818SShteryana Shopova  * $FreeBSD$
3209cbe818SShteryana Shopova  */
3309cbe818SShteryana Shopova 
3409cbe818SShteryana Shopova #define	WLAN_IFMODE_MAX				WlanIfaceOperatingModeType_tdma
3509cbe818SShteryana Shopova #define	WLAN_COUNTRY_CODE_SIZE			3
3609cbe818SShteryana Shopova #define	WLAN_BGSCAN_IDLE_MIN			100 /* XXX */
3709cbe818SShteryana Shopova #define	WLAN_SCAN_VALID_MIN			10 /* XXX */
3809cbe818SShteryana Shopova #define	WLAN_TDMA_MAXSLOTS			2 /* XXX */
3909cbe818SShteryana Shopova 
4009cbe818SShteryana Shopova struct wlan_iface;
4109cbe818SShteryana Shopova 
4209cbe818SShteryana Shopova struct wlan_peer {
4309cbe818SShteryana Shopova 	uint8_t				pmac[IEEE80211_ADDR_LEN]; /* key */
4409cbe818SShteryana Shopova 	uint16_t			associd;
4509cbe818SShteryana Shopova 	uint16_t			vlan;
4609cbe818SShteryana Shopova 	uint16_t			frequency;
4709cbe818SShteryana Shopova 	uint32_t			fflags;
4809cbe818SShteryana Shopova 	uint8_t				txrate;
4909cbe818SShteryana Shopova 	int8_t				rssi;
5009cbe818SShteryana Shopova 	uint16_t			idle;
5109cbe818SShteryana Shopova 	uint16_t			txseqs;
5209cbe818SShteryana Shopova 	uint16_t			rxseqs;
5309cbe818SShteryana Shopova 	uint16_t			txpower;
5409cbe818SShteryana Shopova 	uint8_t				capinfo;
5509cbe818SShteryana Shopova 	uint32_t			state;
5609cbe818SShteryana Shopova 	uint16_t			local_id;
5709cbe818SShteryana Shopova 	uint16_t			peer_id;
5809cbe818SShteryana Shopova 	SLIST_ENTRY(wlan_peer)		wp;
5909cbe818SShteryana Shopova };
6009cbe818SShteryana Shopova 
6109cbe818SShteryana Shopova SLIST_HEAD(wlan_peerlist, wlan_peer);
6209cbe818SShteryana Shopova 
6309cbe818SShteryana Shopova struct wlan_scan_result {
6409cbe818SShteryana Shopova 	uint8_t				ssid[IEEE80211_NWID_LEN + 1];
6509cbe818SShteryana Shopova 	uint8_t				bssid[IEEE80211_ADDR_LEN];
6609cbe818SShteryana Shopova 	uint8_t				opchannel;
6709cbe818SShteryana Shopova 	int8_t				rssi;
6809cbe818SShteryana Shopova 	uint16_t			frequency;
6909cbe818SShteryana Shopova 	int8_t				noise;
7009cbe818SShteryana Shopova 	uint16_t			bintval;
7109cbe818SShteryana Shopova 	uint8_t				capinfo;
7209cbe818SShteryana Shopova 	struct wlan_iface		*pwif;
7309cbe818SShteryana Shopova 	SLIST_ENTRY(wlan_scan_result)	wsr;
7409cbe818SShteryana Shopova };
7509cbe818SShteryana Shopova 
7609cbe818SShteryana Shopova SLIST_HEAD(wlan_scanlist, wlan_scan_result);
7709cbe818SShteryana Shopova 
7809cbe818SShteryana Shopova struct wlan_mac_mac {
7909cbe818SShteryana Shopova 	uint8_t				mac[IEEE80211_ADDR_LEN];
8009cbe818SShteryana Shopova 	enum RowStatus			mac_status;
8109cbe818SShteryana Shopova 	SLIST_ENTRY(wlan_mac_mac)	wm;
8209cbe818SShteryana Shopova };
8309cbe818SShteryana Shopova 
8409cbe818SShteryana Shopova SLIST_HEAD(wlan_maclist, wlan_mac_mac);
8509cbe818SShteryana Shopova 
8609cbe818SShteryana Shopova struct wlan_mesh_route {
8709cbe818SShteryana Shopova 	struct ieee80211req_mesh_route	imroute;
8809cbe818SShteryana Shopova 	enum RowStatus			mroute_status;
8909cbe818SShteryana Shopova 	SLIST_ENTRY(wlan_mesh_route)	wr;
9009cbe818SShteryana Shopova };
9109cbe818SShteryana Shopova 
9209cbe818SShteryana Shopova SLIST_HEAD(wlan_mesh_routes, wlan_mesh_route);
9309cbe818SShteryana Shopova 
9409cbe818SShteryana Shopova struct wlan_iface {
9509cbe818SShteryana Shopova 	char				wname[IFNAMSIZ];
9609cbe818SShteryana Shopova 	uint32_t			index;
9709cbe818SShteryana Shopova 	char				pname[IFNAMSIZ];
9809cbe818SShteryana Shopova 	enum WlanIfaceOperatingModeType	mode;
9909cbe818SShteryana Shopova 	uint32_t			flags;
10009cbe818SShteryana Shopova 	uint8_t				dbssid[IEEE80211_ADDR_LEN];
10109cbe818SShteryana Shopova 	uint8_t				dlmac[IEEE80211_ADDR_LEN];
10209cbe818SShteryana Shopova 	enum RowStatus			status;
10309cbe818SShteryana Shopova 	enum wlanIfaceState		state;
10409cbe818SShteryana Shopova 	uint8_t				internal;
10509cbe818SShteryana Shopova 
10609cbe818SShteryana Shopova 	uint32_t			drivercaps;
10709cbe818SShteryana Shopova 	uint32_t			cryptocaps;
10809cbe818SShteryana Shopova 	uint32_t			htcaps;
10909cbe818SShteryana Shopova 
11009cbe818SShteryana Shopova 	uint32_t			packet_burst;
11109cbe818SShteryana Shopova 	uint8_t				country_code[WLAN_COUNTRY_CODE_SIZE];
11209cbe818SShteryana Shopova 	enum WlanRegDomainCode		reg_domain;
11309cbe818SShteryana Shopova 	uint8_t				desired_ssid[IEEE80211_NWID_LEN + 1];
11409cbe818SShteryana Shopova 	uint32_t			desired_channel;
11509cbe818SShteryana Shopova 	enum TruthValue			dyn_frequency;
11609cbe818SShteryana Shopova 	enum TruthValue			fast_frames;
11709cbe818SShteryana Shopova 	enum TruthValue			dturbo;
11809cbe818SShteryana Shopova 	int32_t				tx_power;
11909cbe818SShteryana Shopova 	int32_t				frag_threshold;
12009cbe818SShteryana Shopova 	int32_t				rts_threshold;
12109cbe818SShteryana Shopova 	enum TruthValue			priv_subscribe;
12209cbe818SShteryana Shopova 	enum TruthValue			bg_scan;
12309cbe818SShteryana Shopova 	int32_t				bg_scan_idle;
12409cbe818SShteryana Shopova 	int32_t				bg_scan_interval;
12509cbe818SShteryana Shopova 	int32_t				beacons_missed;
12609cbe818SShteryana Shopova 	uint8_t				desired_bssid[IEEE80211_ADDR_LEN];
12709cbe818SShteryana Shopova 	enum wlanIfaceRoamingMode	roam_mode;
12809cbe818SShteryana Shopova 	enum TruthValue			dot11d;
12909cbe818SShteryana Shopova 	enum TruthValue			dot11h;
13009cbe818SShteryana Shopova 	enum TruthValue			dynamic_wds;
13109cbe818SShteryana Shopova 	enum TruthValue			power_save;
13209cbe818SShteryana Shopova 	enum TruthValue			ap_bridge;
13309cbe818SShteryana Shopova 	int32_t				beacon_interval;
13409cbe818SShteryana Shopova 	int32_t				dtim_period;
13509cbe818SShteryana Shopova 	enum TruthValue			hide_ssid;
13609cbe818SShteryana Shopova 	enum TruthValue			inact_process;
13709cbe818SShteryana Shopova 	enum wlanIfaceDot11gProtMode	do11g_protect;
13809cbe818SShteryana Shopova 	enum TruthValue			dot11g_pure;
13909cbe818SShteryana Shopova 	enum TruthValue			dot11n_pure;
14009cbe818SShteryana Shopova 	enum WlanIfaceDot11nPduType	ampdu;
14109cbe818SShteryana Shopova 	int32_t				ampdu_density;
14209cbe818SShteryana Shopova 	int32_t				ampdu_limit;
14309cbe818SShteryana Shopova 	enum WlanIfaceDot11nPduType	amsdu;
14409cbe818SShteryana Shopova 	int32_t				amsdu_limit;
14509cbe818SShteryana Shopova 	enum TruthValue			ht_enabled;
14609cbe818SShteryana Shopova 	enum TruthValue			ht_compatible;
14709cbe818SShteryana Shopova 	enum wlanIfaceDot11nHTProtMode	ht_prot_mode;
14809cbe818SShteryana Shopova 	enum TruthValue			rifs;
14909cbe818SShteryana Shopova 	enum TruthValue			short_gi;
15009cbe818SShteryana Shopova 	enum wlanIfaceDot11nSMPSMode	smps_mode;
15109cbe818SShteryana Shopova 	int32_t				tdma_slot;
15209cbe818SShteryana Shopova 	int32_t				tdma_slot_count;
15309cbe818SShteryana Shopova 	int32_t				tdma_slot_length;
15409cbe818SShteryana Shopova 	int32_t				tdma_binterval;
15509cbe818SShteryana Shopova 
15609cbe818SShteryana Shopova 	struct wlan_peerlist		peerlist;
15709cbe818SShteryana Shopova 	struct ieee80211_stats		stats;
15809cbe818SShteryana Shopova 	uint32_t			nchannels;
15909cbe818SShteryana Shopova 	struct ieee80211_channel	*chanlist;
16009cbe818SShteryana Shopova 	struct ieee80211_roamparams_req	roamparams;
16109cbe818SShteryana Shopova 	struct ieee80211_txparams_req	txparams;
16209cbe818SShteryana Shopova 
16309cbe818SShteryana Shopova 	uint32_t			scan_flags;
16409cbe818SShteryana Shopova 	uint32_t			scan_duration;
16509cbe818SShteryana Shopova 	uint32_t			scan_mindwell;
16609cbe818SShteryana Shopova 	uint32_t			scan_maxdwell;
16709cbe818SShteryana Shopova 	enum wlanScanConfigStatus	scan_status;
16809cbe818SShteryana Shopova 	struct wlan_scanlist		scanlist;
16909cbe818SShteryana Shopova 
17009cbe818SShteryana Shopova 	uint8_t				wepsupported;
17109cbe818SShteryana Shopova 	enum wlanWepMode		wepmode;
17209cbe818SShteryana Shopova 	int32_t				weptxkey;
17309cbe818SShteryana Shopova 
17409cbe818SShteryana Shopova 	uint8_t				macsupported;
17509cbe818SShteryana Shopova 	enum wlanMACAccessControlPolicy	mac_policy;
17609cbe818SShteryana Shopova 	uint32_t			mac_nacls;
17709cbe818SShteryana Shopova 	struct wlan_maclist		mac_maclist;
17809cbe818SShteryana Shopova 
17909cbe818SShteryana Shopova 	uint32_t			mesh_ttl;
1801605515dSDimitry Andric 	enum wlanMeshPeeringEnabled	mesh_peering;
1811605515dSDimitry Andric 	enum wlanMeshForwardingEnabled	mesh_forwarding;
18209cbe818SShteryana Shopova 	enum wlanMeshMetric		mesh_metric;
18309cbe818SShteryana Shopova 	enum wlanMeshPath		mesh_path;
18409cbe818SShteryana Shopova 	enum wlanHWMPRootMode		hwmp_root_mode;
18509cbe818SShteryana Shopova 	uint32_t			hwmp_max_hops;
18609cbe818SShteryana Shopova 	struct wlan_mesh_routes		mesh_routelist;
18709cbe818SShteryana Shopova 
18809cbe818SShteryana Shopova 	SLIST_ENTRY(wlan_iface)		w_if;
18909cbe818SShteryana Shopova };
19009cbe818SShteryana Shopova 
19109cbe818SShteryana Shopova enum wlan_syscl {
19209cbe818SShteryana Shopova 	WLAN_MESH_RETRY_TO = 0,
19309cbe818SShteryana Shopova 	WLAN_MESH_HOLDING_TO,
19409cbe818SShteryana Shopova 	WLAN_MESH_CONFIRM_TO,
19509cbe818SShteryana Shopova 	WLAN_MESH_MAX_RETRIES,
19609cbe818SShteryana Shopova 	WLAN_HWMP_TARGET_ONLY,
19709cbe818SShteryana Shopova 	WLAN_HWMP_REPLY_FORWARD,
19809cbe818SShteryana Shopova 	WLAN_HWMP_PATH_LIFETIME,
19909cbe818SShteryana Shopova 	WLAN_HWMP_ROOT_TO,
20009cbe818SShteryana Shopova 	WLAN_HWMP_ROOT_INT,
20109cbe818SShteryana Shopova 	WLAN_HWMP_RANN_INT,
20209cbe818SShteryana Shopova 	WLAN_HWMP_INACTIVITY_TO,
20309cbe818SShteryana Shopova 	WLAN_SYSCTL_MAX
20409cbe818SShteryana Shopova };
20509cbe818SShteryana Shopova 
20609cbe818SShteryana Shopova struct wlan_config {
20709cbe818SShteryana Shopova 	int32_t				mesh_retryto;
20809cbe818SShteryana Shopova 	int32_t				mesh_holdingto;
20909cbe818SShteryana Shopova 	int32_t				mesh_confirmto;
21009cbe818SShteryana Shopova 	int32_t				mesh_maxretries;
21109cbe818SShteryana Shopova 	int32_t				hwmp_targetonly;
21209cbe818SShteryana Shopova 	int32_t				hwmp_replyforward;
21309cbe818SShteryana Shopova 	int32_t				hwmp_pathlifetime;
21409cbe818SShteryana Shopova 	int32_t				hwmp_roottimeout;
21509cbe818SShteryana Shopova 	int32_t				hwmp_rootint;
21609cbe818SShteryana Shopova 	int32_t				hwmp_rannint;
21709cbe818SShteryana Shopova 	int32_t				hwmp_inact;
21809cbe818SShteryana Shopova };
21909cbe818SShteryana Shopova 
22009cbe818SShteryana Shopova int wlan_ioctl_init(void);
22109cbe818SShteryana Shopova int wlan_kmodules_load(void);
22209cbe818SShteryana Shopova int wlan_check_media(char *);
22309cbe818SShteryana Shopova int wlan_config_state(struct wlan_iface *, uint8_t);
22409cbe818SShteryana Shopova int wlan_get_opmode(struct wlan_iface *wif);
22509cbe818SShteryana Shopova int wlan_get_local_addr(struct wlan_iface *wif);
22609cbe818SShteryana Shopova int wlan_get_parent(struct wlan_iface *wif);
22709cbe818SShteryana Shopova int wlan_get_driver_caps(struct wlan_iface *wif);
22809cbe818SShteryana Shopova uint8_t wlan_channel_state_to_snmp(uint8_t cstate);
22909cbe818SShteryana Shopova uint32_t wlan_channel_flags_to_snmp(uint32_t cflags);
23009cbe818SShteryana Shopova int wlan_get_channel_list(struct wlan_iface *wif);
23109cbe818SShteryana Shopova int wlan_get_roam_params(struct wlan_iface *wif);
23209cbe818SShteryana Shopova int wlan_get_tx_params(struct wlan_iface *wif);
23309cbe818SShteryana Shopova int wlan_set_tx_params(struct wlan_iface *wif, int32_t pmode);
23409cbe818SShteryana Shopova int wlan_clone_create(struct wlan_iface *);
23509cbe818SShteryana Shopova int wlan_clone_destroy(struct wlan_iface *wif);
23609cbe818SShteryana Shopova int wlan_config_get_dssid(struct wlan_iface *wif);
23709cbe818SShteryana Shopova int wlan_config_set_dssid(struct wlan_iface *wif, char *ssid, int slen);
23809cbe818SShteryana Shopova int wlan_config_get_ioctl(struct wlan_iface *wif, int which);
23909cbe818SShteryana Shopova int wlan_config_set_ioctl(struct wlan_iface *wif, int which, int val,
24009cbe818SShteryana Shopova     char *strval, int len);
24109cbe818SShteryana Shopova int wlan_set_scan_config(struct wlan_iface *wif);
24209cbe818SShteryana Shopova int wlan_get_scan_results(struct wlan_iface *wif);
24309cbe818SShteryana Shopova int wlan_get_stats(struct wlan_iface *wif);
24409cbe818SShteryana Shopova int wlan_get_wepmode(struct wlan_iface *wif);
24509cbe818SShteryana Shopova int wlan_set_wepmode(struct wlan_iface *wif);
24609cbe818SShteryana Shopova int wlan_get_weptxkey(struct wlan_iface *wif);
24709cbe818SShteryana Shopova int wlan_set_weptxkey(struct wlan_iface *wif);
24809cbe818SShteryana Shopova int wlan_get_wepkeys(struct wlan_iface *wif);
24909cbe818SShteryana Shopova int wlan_set_wepkeys(struct wlan_iface *wif);
25009cbe818SShteryana Shopova int wlan_get_mac_policy(struct wlan_iface *wif);
25109cbe818SShteryana Shopova int wlan_set_mac_policy(struct wlan_iface *wif);
25209cbe818SShteryana Shopova int wlan_flush_mac_mac(struct wlan_iface *wif);
25309cbe818SShteryana Shopova int wlan_get_mac_acl_macs(struct wlan_iface *wif);
25409cbe818SShteryana Shopova int wlan_add_mac_acl_mac(struct wlan_iface *wif, struct wlan_mac_mac *mmac);
25509cbe818SShteryana Shopova int wlan_del_mac_acl_mac(struct wlan_iface *wif, struct wlan_mac_mac *mmac);
25609cbe818SShteryana Shopova 
25709cbe818SShteryana Shopova int32_t wlan_do_sysctl(struct wlan_config *cfg, enum wlan_syscl which, int set);
25809cbe818SShteryana Shopova int wlan_mesh_config_get(struct wlan_iface *wif, int which);
25909cbe818SShteryana Shopova int wlan_mesh_config_set(struct wlan_iface *wif, int which);
26009cbe818SShteryana Shopova int wlan_mesh_flush_routes(struct wlan_iface *wif);
26109cbe818SShteryana Shopova int wlan_mesh_add_route(struct wlan_iface *wif, struct wlan_mesh_route *wmr);
26209cbe818SShteryana Shopova int wlan_mesh_del_route(struct wlan_iface *wif, struct wlan_mesh_route *wmr);
26309cbe818SShteryana Shopova int wlan_mesh_get_routelist(struct wlan_iface *wif);
26409cbe818SShteryana Shopova int wlan_hwmp_config_get(struct wlan_iface *wif, int which);
26509cbe818SShteryana Shopova int wlan_hwmp_config_set(struct wlan_iface *wif, int which);
26609cbe818SShteryana Shopova 
26709cbe818SShteryana Shopova /* XXX: static */
26809cbe818SShteryana Shopova 
26909cbe818SShteryana Shopova int wlan_peer_set_vlan(struct wlan_iface *wif, struct wlan_peer *wip, int vlan);
27009cbe818SShteryana Shopova int wlan_get_peerinfo(struct wlan_iface *wif);
27109cbe818SShteryana Shopova 
27209cbe818SShteryana Shopova /* XXX*/
27309cbe818SShteryana Shopova struct wlan_peer *wlan_new_peer(const uint8_t *pmac);
27409cbe818SShteryana Shopova void wlan_free_peer(struct wlan_peer *wip);
27509cbe818SShteryana Shopova int wlan_add_peer(struct wlan_iface *wif, struct wlan_peer *wip);
27609cbe818SShteryana Shopova 
27709cbe818SShteryana Shopova struct wlan_scan_result * wlan_scan_new_result(const uint8_t *ssid,
27809cbe818SShteryana Shopova     const uint8_t *bssid);
27909cbe818SShteryana Shopova void wlan_scan_free_result(struct wlan_scan_result *sr);
28009cbe818SShteryana Shopova int wlan_scan_add_result(struct wlan_iface *wif, struct wlan_scan_result *sr);
28109cbe818SShteryana Shopova 
28209cbe818SShteryana Shopova struct wlan_mac_mac *wlan_mac_new_mac(const uint8_t *mac);
28309cbe818SShteryana Shopova void wlan_mac_free_mac(struct wlan_mac_mac *wmm);
28409cbe818SShteryana Shopova int wlan_mac_add_mac(struct wlan_iface *wif, struct wlan_mac_mac *wmm);
28509cbe818SShteryana Shopova 
28609cbe818SShteryana Shopova struct wlan_mesh_route *wlan_mesh_new_route(const uint8_t *dstmac);
28709cbe818SShteryana Shopova int wlan_mesh_add_rtentry(struct wlan_iface *wif, struct wlan_mesh_route *wmr);
28809cbe818SShteryana Shopova void wlan_mesh_free_route(struct wlan_mesh_route *wmr);
289