1*4bc2832dSnaddy.\" $OpenBSD: ieee80211.9,v 1.15 2022/03/29 18:15:52 naddy Exp $ 2f903018eSjsg.\" 3f903018eSjsg.\" Copyright (c) 2004 Bruce M. Simpson <bms@spc.org> 4f903018eSjsg.\" Copyright (c) 2004 Darron Broad <darron@kewl.org> 5f903018eSjsg.\" All rights reserved. 6f903018eSjsg.\" 7f903018eSjsg.\" Redistribution and use in source and binary forms, with or without 8f903018eSjsg.\" modification, are permitted provided that the following conditions 9f903018eSjsg.\" are met: 10f903018eSjsg.\" 1. Redistributions of source code must retain the above copyright 11f903018eSjsg.\" notice, this list of conditions and the following disclaimer. 12f903018eSjsg.\" 2. Redistributions in binary form must reproduce the above copyright 13f903018eSjsg.\" notice, this list of conditions and the following disclaimer in the 14f903018eSjsg.\" documentation and/or other materials provided with the distribution. 15f903018eSjsg.\" 16f903018eSjsg.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17f903018eSjsg.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18f903018eSjsg.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19f903018eSjsg.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20f903018eSjsg.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21f903018eSjsg.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22f903018eSjsg.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23f903018eSjsg.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24f903018eSjsg.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25f903018eSjsg.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26f903018eSjsg.\" SUCH DAMAGE. 27f903018eSjsg.\" 28f903018eSjsg.\" $FreeBSD: src/share/man/man9/ieee80211.9,v 1.3 2004/07/07 12:59:39 ru Exp $ 29*4bc2832dSnaddy.\" $Id: ieee80211.9,v 1.15 2022/03/29 18:15:52 naddy Exp $ 30f903018eSjsg.\" 31*4bc2832dSnaddy.Dd $Mdocdate: March 29 2022 $ 3233378d91Sjmc.Dt IEEE80211_IFATTACH 9 33f903018eSjsg.Os 34f903018eSjsg.Sh NAME 35f903018eSjsg.Nm ieee80211_ifattach , ieee80211_ifdetach , 36f903018eSjsg.Nm ieee80211_mhz2ieee , ieee80211_chan2ieee , ieee80211_ieee2mhz , 37f903018eSjsg.Nm ieee80211_media_init , ieee80211_media_change , ieee80211_media_status , 38f903018eSjsg.Nm ieee80211_watchdog , 39f903018eSjsg.Nm ieee80211_setmode , ieee80211_chan2mode , 405b47c825Smglocker.Nm ieee80211_rate2media , ieee80211_media2rate , 415b47c825Smglocker.Nm ieee80211_rate2plcp , ieee80211_plcp2rate 42f903018eSjsg.Nd core 802.11 network stack functions 43f903018eSjsg.Sh SYNOPSIS 44f903018eSjsg.In net80211/ieee80211_var.h 45f903018eSjsg.In net80211/ieee80211_proto.h 46f903018eSjsg.Ft void 47f903018eSjsg.Fn ieee80211_ifattach "struct ifnet *ifp" 48f903018eSjsg.Ft void 49f903018eSjsg.Fn ieee80211_ifdetach "struct ifnet *ifp" 50f903018eSjsg.Ft u_int 51f903018eSjsg.Fn ieee80211_mhz2ieee "u_int freq" "u_int flags" 52f903018eSjsg.Ft u_int 53f22d9adcSdamien.Fn ieee80211_chan2ieee "struct ieee80211com *ic" \ 54f22d9adcSdamien"const struct ieee80211_channel *c" 55f903018eSjsg.Ft u_int 56f903018eSjsg.Fn ieee80211_ieee2mhz "u_int chan" "u_int flags" 57f903018eSjsg.Ft void 58f903018eSjsg.Fo ieee80211_media_init 59f903018eSjsg.Fa "struct ifnet *ifp" "ifm_change_cb_t media_change" 60f903018eSjsg.Fa "ifm_stat_cb_t media_stat" 61f903018eSjsg.Fc 62be43dfe7Sschwarze.Ft int 63f903018eSjsg.Fn ieee80211_media_change "struct ifnet *ifp" 64be43dfe7Sschwarze.Ft void 65f903018eSjsg.Fn ieee80211_media_status "struct ifnet *ifp" "struct ifmediareq *imr" 66f903018eSjsg.Ft void 67f903018eSjsg.Fn ieee80211_watchdog "struct ifnet *ifp" 68f903018eSjsg.Ft int 69f903018eSjsg.Fn ieee80211_setmode "struct ieee80211com *ic" "enum ieee80211_phymode mode" 70f903018eSjsg.Ft enum ieee80211_phymode 71f903018eSjsg.Fo ieee80211_chan2mode 72f22d9adcSdamien.Fa "struct ieee80211com *ic" "const struct ieee80211_channel *chan" 73f903018eSjsg.Fc 74f903018eSjsg.Ft int 75f903018eSjsg.Fo ieee80211_rate2media 76f903018eSjsg.Fa "struct ieee80211com *ic" "int rate" "enum ieee80211_phymode mode" 77f903018eSjsg.Fc 78f903018eSjsg.Ft int 79f903018eSjsg.Fn ieee80211_media2rate "int mword" 80f494b02fSdamien.Ft u_int8_t 81f494b02fSdamien.Fn ieee80211_rate2plcp "u_int8_t rate" "enum ieee80211_phymode mode" 82f494b02fSdamien.Ft u_int8_t 83f494b02fSdamien.Fn ieee80211_plcp2rate "u_int8_t plcp" "enum ieee80211_phymode mode" 84f903018eSjsg.Sh DESCRIPTION 85f903018eSjsgThe 86f903018eSjsg.Nm ieee80211 87f903018eSjsgcollection of functions are used to manage wireless network interfaces in the 88f903018eSjsgsystem which use the system's software 802.11 network stack. 89f903018eSjsgMost of these functions require that attachment to the stack is performed 90f903018eSjsgbefore calling. 91f903018eSjsgSeveral utility functions are also provided; these are safe to call from 92f903018eSjsgany driver without prior initialization. 93f903018eSjsg.Pp 94f903018eSjsg.\" 95f903018eSjsgThe 96f903018eSjsg.Fn ieee80211_ifattach 97f903018eSjsgfunction attaches the network interface 98f903018eSjsg.Fa ifp 99f903018eSjsgto the 802.11 network stack layer. 100f903018eSjsgThis function must be called before using any of the 101f903018eSjsg.Nm ieee80211 10231888060Sjmcfunctions which need to store driver state across invocations. 103f903018eSjsgThe 104f903018eSjsg.Vt struct ifnet 105f903018eSjsginstance pointed to by 106f903018eSjsg.Fa ifp 107f903018eSjsgMUST be an instance of 108f903018eSjsg.Vt struct ieee80211com , 109f903018eSjsgwith various fields initialized to tell 110f903018eSjsg.Nm ieee80211 111f903018eSjsgabout its capabilities. 112f903018eSjsgThis function performs Ethernet and BPF attachment (by calling 113f903018eSjsg.Fn ether_ifattach 114f903018eSjsgand 115f903018eSjsg.Fn bpfattach ) 116f903018eSjsgon behalf of the caller. 117f903018eSjsgIt also implements the 118f903018eSjsg.Vt ifmedia 119f903018eSjsginterface. 120f903018eSjsg.Pp 121f903018eSjsg.\" 122f903018eSjsgThe 123f903018eSjsg.Fn ieee80211_ifdetach 124f903018eSjsgfunction frees any 125f903018eSjsg.Nm ieee80211 126f903018eSjsgstructures associated with the driver, and performs Ethernet and BPF 127f903018eSjsgdetachment on behalf of the caller. 128f903018eSjsg.Pp 129f903018eSjsg.\" 130f903018eSjsgThe 131f903018eSjsg.Fn ieee80211_mhz2ieee 132f903018eSjsgutility function converts the frequency 133f903018eSjsg.Fa freq 134f903018eSjsg(specified in MHz) to an IEEE 802.11 channel number. 135f903018eSjsgThe 136f903018eSjsg.Fa flags 137f903018eSjsgargument is a hint which specifies whether the frequency is in 138f903018eSjsgthe 2GHz ISM band 139f903018eSjsg.Pq Vt IEEE80211_CHAN_2GHZ 140f903018eSjsgor the 5GHz band 141f903018eSjsg.Pq Vt IEEE80211_CHAN_5GHZ ; 142f903018eSjsgappropriate clipping of the result is then performed. 143f903018eSjsg.Pp 144f903018eSjsg.\" 145f903018eSjsgThe 146f903018eSjsg.Fn ieee80211_chan2ieee 147f903018eSjsgfunction converts the channel specified in 148f903018eSjsg.Fa *c 149f903018eSjsgto an IEEE channel number for the driver 150f903018eSjsg.Fa ic . 151f903018eSjsgIf the conversion would be invalid, an error message is printed to the 152f903018eSjsgsystem console. 15331888060SjmcThis function requires that the driver is hooked up to the 154f903018eSjsg.Nm ieee80211 155f903018eSjsgsubsystem. 156f903018eSjsg.Pp 157f903018eSjsg.\" 158f903018eSjsgThe 159f903018eSjsg.Fn ieee80211_ieee2mhz 160f903018eSjsgutility function converts the IEEE channel number 161f903018eSjsg.Ft chan 162f903018eSjsgto a frequency (in MHz). 163f903018eSjsgThe 164f903018eSjsg.Fa flags 165f903018eSjsgargument is a hint which specifies whether the frequency is in 166f903018eSjsgthe 2GHz ISM band 167f903018eSjsg.Pq Vt IEEE80211_CHAN_2GHZ 168f903018eSjsgor the 5GHz band 169f903018eSjsg.Pq Vt IEEE80211_CHAN_5GHZ ; 170f903018eSjsgappropriate clipping of the result is then performed. 171f903018eSjsg.Pp 172f903018eSjsg.\" 173f903018eSjsgThe 174f903018eSjsg.Fn ieee80211_media_init 175f903018eSjsgfunction initializes media data structures used by the 176f903018eSjsg.Vt ifmedia 177f903018eSjsginterface, for the driver 178f903018eSjsg.Fa ifp . 179f903018eSjsgIt must be called by the driver after calling 180f903018eSjsg.Fn ieee80211_ifattach 181f903018eSjsgand before calling most 182f903018eSjsg.Nm ieee80211 183f903018eSjsgfunctions. 184f903018eSjsgThe 185f903018eSjsg.Fa media_change 186f903018eSjsgand 187f903018eSjsg.Fa media_stat 188f903018eSjsgarguments specify helper functions which will be invoked by the 189f903018eSjsg.Vt ifmedia 190f903018eSjsgframework when the user changes or queries media options, 191f903018eSjsgusing a command such as 192f903018eSjsg.Xr ifconfig 8 . 193f903018eSjsg.Pp 194f903018eSjsg.\" 195f903018eSjsgThe 196f903018eSjsg.Fn ieee80211_media_status 197f903018eSjsgand 198f903018eSjsg.Fn ieee80211_media_change 199f903018eSjsgfunctions are device-independent handlers for 200f903018eSjsg.Vt ifmedia 201f903018eSjsgcommands and are not intended to be called directly. 202f903018eSjsg.Pp 203f903018eSjsg.\" 204f903018eSjsgThe 205f903018eSjsg.Fn ieee80211_watchdog 206f903018eSjsgfunction is intended to be called from a driver's 207f903018eSjsg.Va if_watchdog 208f903018eSjsgroutine. 209f903018eSjsgIt is used to perform periodic cleanup of state within the software 802.11 210f903018eSjsgstack, as well as timing out scans. 211f903018eSjsg.Pp 212f903018eSjsg.\" 213f903018eSjsgThe 214f903018eSjsg.Fn ieee80211_setmode 215f903018eSjsgfunction is called from within the 802.11 stack to change the mode 216f903018eSjsgof the driver's PHY; it is not intended to be called directly. 217f903018eSjsg.Pp 218f903018eSjsg.\" 219f903018eSjsgThe 220f903018eSjsg.Fn ieee80211_chan2mode 221f903018eSjsgfunction returns the PHY mode required for use with the channel 222f903018eSjsg.Fa chan 223f903018eSjsgon the device 224f903018eSjsg.Fa ic . 225f903018eSjsgThis is typically used when selecting a rate set, to be advertised in 226f903018eSjsgbeacons, for example. 227f903018eSjsg.Pp 228f903018eSjsg.\" 229f903018eSjsgThe 230f903018eSjsg.Fn ieee80211_rate2media 231f903018eSjsgfunction converts the bit rate 232f903018eSjsg.Fa rate 233f903018eSjsg(measured in units of 0.5Mbps) to an 234f903018eSjsg.Vt ifmedia 235f903018eSjsgsub-type, for the device 236f903018eSjsg.Fa ic 237f903018eSjsgrunning in PHY mode 238f903018eSjsg.Fa mode . 239f903018eSjsgThe 240f903018eSjsg.Fn ieee80211_media2rate 241*4bc2832dSnaddyfunction performs the reverse of this conversion, 242*4bc2832dSnaddyreturning the bit rate (in 0.5Mbps units) corresponding to an 243f903018eSjsg.Vt ifmedia 244f903018eSjsgsub-type. 2455b47c825Smglocker.Pp 2465b47c825Smglocker.\" 2475b47c825SmglockerThe 2485b47c825Smglocker.Fn ieee80211_rate2plcp 2495b47c825Smglockerfunction converts the bit rate 2505b47c825Smglocker.Fa rate 2515b47c825Smglocker(measured in units of 0.5Mbps) to a 2525b47c825Smglocker.Vt plcp 253f494b02fSdamiensignal (in msb-first R4-R1 format). 2545b47c825SmglockerThe 2555b47c825Smglocker.Fn ieee80211_plcp2rate 2565b47c825Smglockerfunction performs the reverse of this conversion, 2575b47c825Smglockerreturning the bit rate (in 0.5Mbps units) corresponding to a 2585b47c825Smglocker.Vt plcp 259f494b02fSdamiensignal (in msb-first R4-R1 format). 260f903018eSjsg.\" 261f903018eSjsg.Sh SEE ALSO 262f903018eSjsg.Xr ifmedia 4 , 263f903018eSjsg.Xr ieee80211_crypto 9 , 264f903018eSjsg.Xr ieee80211_input 9 , 265f903018eSjsg.Xr ieee80211_ioctl 9 , 266f903018eSjsg.Xr ieee80211_node 9 , 267f903018eSjsg.Xr ieee80211_output 9 , 268f903018eSjsg.Xr ieee80211_proto 9 , 269d3603060Sjmc.Xr ieee80211_radiotap 9 , 270d3603060Sjmc.Xr rssadapt 9 271f903018eSjsg.Sh HISTORY 272f903018eSjsgThe 273f903018eSjsg.Nm ieee80211 274f903018eSjsgseries of functions first appeared in 275f903018eSjsg.Nx 1.5 , 276f903018eSjsgand were later ported to 277f903018eSjsg.Fx 4.6 278f903018eSjsgand 279f903018eSjsg.Ox 3.6 . 280f903018eSjsg.Sh AUTHORS 281d281945cSjaredy.An -nosplit 282f903018eSjsgThis man page was written by 283f0641c22Sschwarze.An Bruce M. Simpson Aq Mt bms@FreeBSD.org 284f903018eSjsgand 285f0641c22Sschwarze.An Darron Broad Aq Mt darron@kewl.org . 286