Nut/OS  4.10.3
API Reference
wlandrv.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 *  This file is part of the WLAN-Ethernut device driver.
00003 *
00004 *  Copyright (c) 2004 by Michael Fischer. All rights reserved.
00005 *
00006 *  Redistribution and use in source and binary forms, with or without 
00007 *  modification, are permitted provided that the following conditions 
00008 *  are met:
00009 *  
00010 *  1. Redistributions of source code must retain the above copyright 
00011 *     notice, this list of conditions and the following disclaimer.
00012 *  2. Redistributions in binary form must reproduce the above copyright
00013 *     notice, this list of conditions and the following disclaimer in the 
00014 *     documentation and/or other materials provided with the distribution.
00015 *  3. Neither the name of the author nor the names of its contributors may 
00016 *     be used to endorse or promote products derived from this software 
00017 *     without specific prior written permission.
00018 *
00019 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00020 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00021 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
00022 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
00023 *  THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
00024 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
00025 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 
00026 *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
00027 *  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
00028 *  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
00029 *  THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
00030 *  SUCH DAMAGE.
00031 *
00032 ****************************************************************************
00033 *  Portions Copyright: 
00034 *
00035 *  Copyright (c) 2001 Atsushi Onoe
00036 *  Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
00037 *  Copyright (c) 2002 M Warner Losh <imp@freebsd.org>.  All rights reserved.
00038 *  Copyright (c) 1997, 1998, 1999
00039 *        Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
00040 *
00041 *  Redistribution and use in source and binary forms, with or without
00042 *  modification, are permitted provided that the following conditions
00043 *  are met:
00044 *  1. Redistributions of source code must retain the above copyright
00045 *     notice, this list of conditions and the following disclaimer.
00046 *  2. Redistributions in binary form must reproduce the above copyright
00047 *     notice, this list of conditions and the following disclaimer in the
00048 *     documentation and/or other materials provided with the distribution.
00049 *  3. Neither the name of the author nor the names of any co-contributors
00050 *     may be used to endorse or promote products derived from this software
00051 *     without specific prior written permission.
00052 *
00053 *  THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
00054 *  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00055 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00056 *  ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
00057 *  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00058 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00059 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00060 *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00061 *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00062 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
00063 *  THE POSSIBILITY OF SUCH DAMAGE.
00064 *
00065 ****************************************************************************
00066 *  History:
00067 *
00068 *  28.02.04  mifi   First Version 
00069 *                   This file is a mix of several FreeBSD header files.
00070 *                   I have put all the files together, because it was
00071 *                   difficult to use the original files. I have try this
00072 *                   but I must comment out to much to get it to work.
00073 *                   The other "define" file is wlandef.h, 
00074 *                   here you will the rest of it.
00075 *  03.03.04  mifi   Move debug switch to wlancfg.h
00076 ****************************************************************************/
00077 #ifndef __WLANDRV_H__
00078 #define __WLANDRV_H__
00079 
00080 #include <compiler.h>
00081 #include <dev/wlantypes.h>
00082 #include <dev/wlan.h>
00083 #include <dev/wlandef.h>
00084 
00085 /*-------------------------------------------------------------------------*/
00086 /* global defines and types                                                */
00087 /*-------------------------------------------------------------------------*/
00088 
00089 /*
00090  * Resetport definition
00091 */
00092 #define RESET_EN_PORT           DDRD
00093 #define RESET_PORT                        PORTD
00094 #define RESET_BIT                           0x20
00095 
00096 /***************************************************************************/
00097 /*                           if_wivar.h                                    */
00098 /***************************************************************************/
00099 
00100 /*
00101  * Driver Flags
00102 */
00103 #define WI_FLAGS_ATTACHED       0x0001
00104 #define WI_FLAGS_INITIALIZED    0x0002
00105 #define WI_FLAGS_OUTRANGE       0x0004
00106 #define WI_FLAGS_HAS_MOR        0x0010
00107 #define WI_FLAGS_HAS_ROAMING    0x0020
00108 #define WI_FLAGS_HAS_DIVERSITY  0x0040
00109 #define WI_FLAGS_HAS_SYSSCALE   0x0080
00110 #define WI_FLAGS_BUG_AUTOINC    0x0100
00111 #define WI_FLAGS_HAS_FRAGTHR    0x0200
00112 #define WI_FLAGS_HAS_DBMADJUST  0x0400
00113 
00114 /*
00115  * TX Buffer count
00116 */ 
00117 #define WI_NTXBUF               3
00118 
00119 /***************************************************************************/
00120 /*                          ieee80211.h                                    */
00121 /***************************************************************************/
00122 
00123 #define IEEE80211_ADDR_LEN      6
00124 #define IEEE80211_NWID_LEN      32
00125 
00126 
00127 #define IEEE80211_WEP_KEYLEN    5 /* 40bit */
00128 #define IEEE80211_WEP_IVLEN     3       /* 24bit */
00129 #define IEEE80211_WEP_KIDLEN    1       /* 1 octet */
00130 #define IEEE80211_WEP_CRCLEN    4       /* CRC-32 */
00131 #define IEEE80211_WEP_NKID      4       /* number of key ids */
00132 
00133 #define IEEE80211_CRC_LEN       4
00134 
00135 
00136 /***************************************************************************/
00137 /*                          ieee80211_var.h                                */
00138 /***************************************************************************/
00139 
00140 /*
00141  * ic_flags 
00142 */
00143 #define IEEE80211_F_ASCAN       0x00000001  /* STATUS: active scan */
00144 #define IEEE80211_F_SIBSS       0x00000002  /* STATUS: start IBSS */
00145 #define IEEE80211_F_WEPON       0x00000100  /* CONF: WEP enabled */
00146 #define IEEE80211_F_IBSSON      0x00000200  /* CONF: IBSS creation enable */
00147 #define IEEE80211_F_PMGTON      0x00000400  /* CONF: Power mgmt enable */
00148 #define IEEE80211_F_DESBSSID    0x00000800  /* CONF: des_bssid is set */
00149 #define IEEE80211_F_SCANAP      0x00001000  /* CONF: Scanning AP */
00150 #define IEEE80211_F_ROAMING     0x00002000  /* CONF: roaming enabled */
00151 #define IEEE80211_F_SWRETRY     0x00004000  /* CONF: sw tx retry enabled */
00152 #define IEEE80211_F_TXPMGT      0x00018000  /* STATUS: tx power */
00153 #define IEEE80211_F_TXPOW_OFF   0x00000000  /* TX Power: radio disabled */
00154 #define IEEE80211_F_TXPOW_FIXED 0x00008000  /* TX Power: fixed rate */
00155 #define IEEE80211_F_TXPOW_AUTO  0x00010000  /* TX Power: undefined */
00156 #define IEEE80211_F_SHSLOT      0x00020000  /* CONF: short slot time */
00157 #define IEEE80211_F_SHPREAMBLE  0x00040000  /* CONF: short preamble */
00158 
00159 /*
00160  * ic_caps
00161 */
00162 #define IEEE80211_C_WEP         0x0001  /* CAPABILITY: WEP available  */
00163 #define IEEE80211_C_IBSS        0x0002  /* CAPABILITY: IBSS available */
00164 #define IEEE80211_C_PMGT        0x0004  /* CAPABILITY: Power mgmt     */
00165 #define IEEE80211_C_HOSTAP      0x0008  /* CAPABILITY: HOSTAP avail   */
00166 #define IEEE80211_C_AHDEMO      0x0010  /* CAPABILITY: Old Adhoc Demo */
00167 #define IEEE80211_C_SWRETRY     0x0020  /* CAPABILITY: sw tx retry    */
00168 #define IEEE80211_C_TXPMGT      0x0040  /* CAPABILITY: tx power mgmt  */
00169 #define IEEE80211_C_SHSLOT      0x0080  /* CAPABILITY: short slottime */
00170 #define IEEE80211_C_SHPREAMBLE  0x0100  /* CAPABILITY: short preamble */
00171 #define IEEE80211_C_MONITOR     0x0200  /* CAPABILITY: monitor mode   */
00172 #define IEEE80211_C_RCVMGT      0x0400  /* CAPABILITY: rcv mgt frames */
00173 
00174 enum ieee80211_opmode {
00175   IEEE80211_M_STA     = 1,      /* infrastructure station */
00176   IEEE80211_M_IBSS    = 0,      /* IBSS (adhoc) station */
00177   IEEE80211_M_AHDEMO  = 3,      /* Old lucent compatible adhoc demo */
00178   IEEE80211_M_HOSTAP  = 6,      /* Software Access Point */
00179   IEEE80211_M_MONITOR = 8       /* Monitor mode */
00180 };
00181 
00182 /***************************************************************************/
00183 /*                          ieee80211_prot.h                               */
00184 /***************************************************************************/
00185 
00186 /*
00187  * 802.11 protocol implementation definitions.
00188 */
00189 enum ieee80211_state {
00190         IEEE80211_S_INIT        = 0,          /* default state */
00191         IEEE80211_S_SCAN        = 1,          /* scanning */
00192         IEEE80211_S_AUTH        = 2,          /* try to authenticate */
00193         IEEE80211_S_ASSOC       = 3,          /* try to assoc */
00194         IEEE80211_S_RUN         = 4,          /* associated */
00195 };
00196 #define IEEE80211_S_MAX         (IEEE80211_S_RUN+1)
00197 
00198 /***************************************************************************/
00199 /*                          ieee80211_crypto.h                             */
00200 /***************************************************************************/
00201 
00202 /*
00203  * 802.11 protocol crypto-related definitions.
00204  */
00205 #define IEEE80211_KEYBUF_SIZE   16
00206 struct ieee80211_wepkey {
00207   int wk_len;
00208   u_int8_t wk_key[IEEE80211_KEYBUF_SIZE];
00209 };
00210 
00211 /***************************************************************************/
00212 /*                          ieee80211_node.h                               */
00213 /***************************************************************************/
00214 
00215 struct ieee80211_rateset {
00216   u_int8_t rs_nrates;
00217   u_int8_t rs_rates[IEEE80211_RATE_MAXSIZE];
00218 };
00219 
00220 /***************************************************************************/
00221 /*                          ieee80211_var.h                                */
00222 /***************************************************************************/
00223 
00224 struct ieee80211com {
00225   u_int8_t                  ic_myaddr[IEEE80211_ADDR_LEN];
00226 
00227   struct ieee80211_rateset  ic_sup_rates[IEEE80211_MODE_MAX];
00228   u_int16_t                 ChannelList;
00229 
00230   u_int32_t                 ic_flags;           /* state flags */
00231   u_int32_t                 ic_caps;            /* capabilities */
00232 
00233   enum ieee80211_opmode     ic_opmode;          /* operation mode */
00234   enum ieee80211_state      ic_state;           /* 802.11 state */
00235 
00236   u_int16_t                 ic_ibss_chan;
00237   int                       ic_fixed_rate;      /* index to ic_sup_rates[] */
00238 
00239   int                       ic_des_esslen;
00240   u_int8_t                  ic_des_essid[IEEE80211_NWID_LEN];
00241 
00242   struct ieee80211_wepkey   ic_nw_keys[IEEE80211_WEP_NKID];
00243   int                       ic_wep_txkey;       /* default tx key index */
00244 };
00245 
00246 /***************************************************************************/
00247 /*                             if_wivar.h                                  */
00248 /***************************************************************************/
00249 
00250 struct wi_softc {
00251   /*
00252    * This is our Interrupt stuff
00253    */
00254   int                 InterruptInitDone; 
00255   HANDLE volatile     InterruptEvent;
00256   u_int16_t           EventStatus;
00257 
00258   /*
00259    * Now here comes the FreeBSD stuff...
00260    */
00261   struct ieee80211com sc_ic;
00262   
00263   int                 PromiscuousMode;
00264 
00265   int                 wi_gone;
00266   int                 sc_enabled;
00267   int                 sc_reset;
00268   int                 sc_firmware_type;
00269   u_int32_t           sc_pri_firmware_ver;  /* Primary firmware */
00270   u_int32_t           sc_sta_firmware_ver;  /* Station firmware */
00271 
00272   int                 wi_cmd_count;
00273 
00274   int                 sc_flags;
00275   int                 sc_bap_id;
00276   int                 sc_bap_off;
00277 
00278   u_int16_t           sc_portnum;
00279 
00280   /*
00281    * RSSI interpretation 
00282    */
00283   u_int16_t           sc_min_rssi;          /* clamp sc_min_rssi < RSSI */
00284   u_int16_t           sc_max_rssi;          /* clamp RSSI < sc_max_rssi */
00285   u_int16_t           sc_dbm_offset;        /* dBm ~ RSSI - sc_dbm_offset */
00286 
00287   u_int16_t           sc_max_datalen;
00288   u_int16_t           sc_system_scale;
00289   u_int16_t           sc_cnfauthmode;
00290   u_int16_t           sc_roaming_mode;
00291   u_int16_t           sc_microwave_oven;
00292   u_int16_t           sc_authtype;
00293 
00294   int                 sc_buflen;            /* TX buffer size */
00295   int                 sc_ntxbuf;
00296   struct {
00297     int d_fid;
00298     int d_len;
00299   } sc_txd[WI_NTXBUF];                      /* TX buffers */
00300   int                 sc_txnext;            /* index of next TX */
00301   int                 sc_txcur;             /* index of current TX */
00302   int                 sc_tx_timer;
00303   int                 sc_scan_timer;
00304 
00305   u_int16_t           sc_ibss_port;
00306 };
00307 
00308 typedef struct wi_softc WI_SOFTC;
00309 
00310 /*-------------------------------------------------------------------------*/
00311 /* global macros                                                           */
00312 /*-------------------------------------------------------------------------*/
00313 #define device_t              NUTDEVICE*
00314 #define device_get_softc(_a)  (struct wi_softc*)_a->dev_dcb
00315 
00316 /*-------------------------------------------------------------------------*/
00317 /* Prototypes                                                              */
00318 /*-------------------------------------------------------------------------*/
00319 int   wlandrv_ProbeDevice (void);
00320 int   wlandrv_Attach      (device_t dev);
00321 void  wlandrv_Init        (device_t dev);
00322 int   wlandrv_PutPacket   (NUTDEVICE * dev, NETBUF * nb);
00323 int   wlandrv_IOCTL       (NUTDEVICE * dev, int req, void *conf);
00324 
00325 #endif /* !__WLANDRV_H__ */