Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

p80211netdev.h

Go to the documentation of this file.
00001 /* src/include/wlan/p80211netdev.h
00002 *
00003 * WLAN net device structure and functions
00004 *
00005 * Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.
00006 * --------------------------------------------------------------------
00007 *
00008 * linux-wlan
00009 *
00010 *   The contents of this file are subject to the Mozilla Public
00011 *   License Version 1.1 (the "License"); you may not use this file
00012 *   except in compliance with the License. You may obtain a copy of
00013 *   the License at http://www.mozilla.org/MPL/
00014 *
00015 *   Software distributed under the License is distributed on an "AS
00016 *   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
00017 *   implied. See the License for the specific language governing
00018 *   rights and limitations under the License.
00019 *
00020 *   Alternatively, the contents of this file may be used under the
00021 *   terms of the GNU Public License version 2 (the "GPL"), in which
00022 *   case the provisions of the GPL are applicable instead of the
00023 *   above.  If you wish to allow the use of your version of this file
00024 *   only under the terms of the GPL and not to allow others to use
00025 *   your version of this file under the MPL, indicate your decision
00026 *   by deleting the provisions above and replace them with the notice
00027 *   and other provisions required by the GPL.  If you do not delete
00028 *   the provisions above, a recipient may use your version of this
00029 *   file under either the MPL or the GPL.
00030 *
00031 * --------------------------------------------------------------------
00032 *
00033 * Inquiries regarding the linux-wlan Open Source project can be
00034 * made directly to:
00035 *
00036 * AbsoluteValue Systems Inc.
00037 * info@linux-wlan.com
00038 * http://www.linux-wlan.com
00039 *
00040 * --------------------------------------------------------------------
00041 *
00042 * Portions of the development of this software were funded by 
00043 * Intersil Corporation as part of PRISM(R) chipset product development.
00044 *
00045 * --------------------------------------------------------------------
00046 *
00047 * This file declares the structure type that represents each wlan
00048 * interface.  
00049 *
00050 * --------------------------------------------------------------------
00051 */
00052 
00053 #ifndef _LINUX_P80211NETDEV_H
00054 #define _LINUX_P80211NETDEV_H
00055 
00056 /*================================================================*/
00057 /* Constants */
00058 
00059 #define WLAN_DEVICE_CLOSED      0
00060 #define WLAN_DEVICE_OPEN        1
00061 
00062 #define WLAN_MACMODE_NONE       0
00063 #define WLAN_MACMODE_IBSS_STA   1
00064 #define WLAN_MACMODE_ESS_STA    2
00065 #define WLAN_MACMODE_ESS_AP     3
00066 
00067 /* MSD States */
00068 #define WLAN_MSD_START                  -1
00069 #define WLAN_MSD_DRIVERLOADED           0
00070 #define WLAN_MSD_HWPRESENT_PENDING      1
00071 #define WLAN_MSD_HWFAIL                 2
00072 #define WLAN_MSD_HWPRESENT              3
00073 #define WLAN_MSD_FWLOAD_PENDING         4
00074 #define WLAN_MSD_FWLOAD                 5
00075 #define WLAN_MSD_RUNNING_PENDING        6
00076 #define WLAN_MSD_RUNNING                7
00077 
00078 #ifndef ETH_P_ECONET
00079 #define ETH_P_ECONET   0x0018    /* needed for 2.2.x kernels */
00080 #endif
00081 
00082 #define ETH_P_80211_RAW        (ETH_P_ECONET + 1)
00083 
00084 #ifndef ARPHRD_IEEE80211
00085 #define ARPHRD_IEEE80211 801     /* kernel 2.4.6 */
00086 #endif
00087 
00088 #ifndef ARPHRD_IEEE80211_PRISM  /* kernel 2.4.18 */
00089 #define ARPHRD_IEEE80211_PRISM 802
00090 #endif
00091 
00092 /*--- NSD Capabilities Flags ------------------------------*/
00093 #define P80211_NSDCAP_HARDWAREWEP           0x01  /* hardware wep engine */
00094 #define P80211_NSDCAP_TIEDWEP               0x02  /* can't decouple en/de */
00095 #define P80211_NSDCAP_NOHOSTWEP             0x04  /* must use hardware wep */
00096 #define P80211_NSDCAP_PBCC                  0x08  /* hardware supports PBCC */
00097 #define P80211_NSDCAP_SHORT_PREAMBLE        0x10  /* hardware supports */
00098 #define P80211_NSDCAP_AGILITY               0x20  /* hardware supports */
00099 #define P80211_NSDCAP_AP_RETRANSMIT         0x40  /* nsd handles retransmits */
00100 #define P80211_NSDCAP_HWFRAGMENT            0x80  /* nsd handles frag/defrag */
00101 #define P80211_NSDCAP_AUTOJOIN              0x100  /* nsd does autojoin */
00102 #define P80211_NSDCAP_NOSCAN                0x200  /* nsd can scan */
00103 
00104 /*================================================================*/
00105 /* Macros */
00106 
00107 /*================================================================*/
00108 /* Types */
00109 
00110 /* Received frame statistics */
00111 typedef struct p80211_frmrx_t 
00112 {
00113         UINT32  mgmt;
00114         UINT32  assocreq;
00115         UINT32  assocresp;
00116         UINT32  reassocreq;
00117         UINT32  reassocresp;
00118         UINT32  probereq;
00119         UINT32  proberesp;
00120         UINT32  beacon;
00121         UINT32  atim;
00122         UINT32  disassoc;
00123         UINT32  authen;
00124         UINT32  deauthen;
00125         UINT32  mgmt_unknown;
00126         UINT32  ctl;
00127         UINT32  pspoll;
00128         UINT32  rts;
00129         UINT32  cts;
00130         UINT32  ack;
00131         UINT32  cfend;
00132         UINT32  cfendcfack;
00133         UINT32  ctl_unknown;
00134         UINT32  data;
00135         UINT32  dataonly;
00136         UINT32  data_cfack;
00137         UINT32  data_cfpoll;
00138         UINT32  data__cfack_cfpoll;
00139         UINT32  null;
00140         UINT32  cfack;
00141         UINT32  cfpoll;
00142         UINT32  cfack_cfpoll;
00143         UINT32  data_unknown;
00144         UINT32  decrypt;
00145         UINT32  decrypt_err;
00146 } p80211_frmrx_t;
00147 
00148 
00149 #ifdef WIRELESS_EXT
00150 /* called by /proc/net/wireless */
00151 struct iw_statistics* p80211wext_get_wireless_stats(netdevice_t *dev);
00152 /* wireless extensions' ioctls */ 
00153 int p80211wext_support_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd);
00154 #if WIRELESS_EXT > 12
00155 extern struct iw_handler_def p80211wext_handler_def;
00156 #endif
00157 #endif /* wireless extensions */
00158 
00159 /* WEP stuff */
00160 #define NUM_WEPKEYS 4
00161 #define MAX_KEYLEN 32
00162 
00163 #define HOSTWEP_DEFAULTKEY_MASK (BIT1|BIT0)
00164 #define HOSTWEP_DECRYPT  BIT4
00165 #define HOSTWEP_ENCRYPT  BIT5
00166 #define HOSTWEP_PRIVACYINVOKED BIT6
00167 #define HOSTWEP_EXCLUDEUNENCRYPTED BIT7
00168 
00169 extern int wlan_watchdog;
00170 extern int wlan_wext_write;
00171 
00172 /* WLAN device type */
00173 typedef struct wlandevice
00174 {
00175         struct wlandevice       *next;          /* link for list of devices */
00176         void                    *priv;          /* private data for MSD */
00177 
00178         /* Subsystem State */
00179         char            name[WLAN_DEVNAMELEN_MAX]; /* Dev name, from register_wlandev()*/
00180         char            *nsdname; 
00181 
00182         UINT32          state;          /* Device I/F state (open/closed) */
00183         UINT32          msdstate;       /* state of underlying driver */
00184         UINT32          hwremoved;      /* Has the hw been yanked out? */
00185 
00186         /* Hardware config */
00187         UINT            irq;
00188         UINT            iobase;
00189         UINT            membase;
00190         UINT32          nsdcaps;  /* NSD Capabilities flags */
00191 
00192         /* Config vars */
00193         UINT            ethconv;
00194 
00195         /* device methods (init by MSD, used by p80211 */
00196         int             (*open)(struct wlandevice *wlandev);
00197         int             (*close)(struct wlandevice *wlandev);
00198         void            (*reset)(struct wlandevice *wlandev );
00199         int             (*txframe)(struct wlandevice *wlandev, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep);
00200         int             (*mlmerequest)(struct wlandevice *wlandev, p80211msg_t *msg);
00201         int             (*set_multicast_list)(struct wlandevice *wlandev, 
00202                                               netdevice_t *dev);
00203         void            (*tx_timeout)(struct wlandevice *wlandev);
00204 
00205 #ifdef CONFIG_PROC_FS
00206         int             (*nsd_proc_read)(char *page, char **start, off_t offset, int count, int *eof, void *data);
00207 #endif
00208 
00209         /* 802.11 State */
00210         UINT8           bssid[WLAN_BSSID_LEN];
00211         p80211pstr32_t  ssid;
00212         UINT32          macmode;
00213         UINT            shortpreamble;  /* C bool */
00214 
00215         /* WEP State */
00216         UINT8 wep_keys[NUM_WEPKEYS][MAX_KEYLEN];
00217         UINT8 wep_keylens[NUM_WEPKEYS];
00218         int   hostwep;
00219   
00220         /* Request/Confirm i/f state (used by p80211) */
00221         UINT32                  request_pending; /* flag, access atomically */
00222 
00223         /* netlink socket */
00224         /* queue for indications waiting for cmd completion */
00225         /* Linux netdevice and support */
00226         netdevice_t             *netdev;        /* ptr to linux netdevice */
00227         struct net_device_stats linux_stats;
00228 
00229 #ifdef CONFIG_PROC_FS
00230         /* Procfs support */
00231         struct proc_dir_entry   *procdir;
00232         struct proc_dir_entry   *procwlandev;
00233 #endif
00234 
00235         /* Rx bottom half */
00236 #ifndef _LINUX_INTERRUPT_H
00237 #error "You forgot to #include <linux/interrupt.h>!"
00238 #endif
00239 
00240 #ifdef DECLARE_TASKLET  /* use tasklets */
00241         struct tasklet_struct   rx_bh;
00242 #else
00243         struct work_struct      rx_bh;
00244 #endif
00245         struct sk_buff_head     nsd_rxq;
00246 
00247         /* 802.11 device statistics */
00248         struct p80211_frmrx_t   rx;
00249 
00250 /* compatibility to wireless extensions */
00251 #ifndef WIRELESS_EXT
00252 #error "you forgot to include linux/wireless.h"
00253 #endif
00254 
00255 #ifdef WIRELESS_EXT
00256 
00257         struct iw_statistics    wstats;
00258 
00259         /* jkriegl: iwspy fields */
00260         UINT8                   spy_number;
00261         char                    spy_address[IW_MAX_SPY][ETH_ALEN];
00262         struct iw_quality       spy_stat[IW_MAX_SPY];
00263 
00264 #endif
00265 
00266 } wlandevice_t;
00267 
00268 /* WEP stuff */
00269 int wep_change_key(wlandevice_t *wlandev, int keynum, UINT8* key, int keylen);
00270 int wep_decrypt(wlandevice_t *wlandev, UINT8 *buf, UINT32 len, int key_override, UINT8 *iv, UINT8 *icv);
00271 int wep_encrypt(wlandevice_t *wlandev, UINT8 *buf, UINT8 *dst, UINT32 len, int keynum, UINT8 *iv, UINT8 *icv);
00272 
00273 /*================================================================*/
00274 /* Externs */
00275 
00276 /*================================================================*/
00277 /* Function Declarations */
00278 
00279 void    p80211netdev_startup(void);
00280 void    p80211netdev_shutdown(void);
00281 int     wlan_setup(wlandevice_t *wlandev);
00282 int     wlan_unsetup(wlandevice_t *wlandev);
00283 int     register_wlandev(wlandevice_t *wlandev);
00284 int     unregister_wlandev(wlandevice_t *wlandev);
00285 void    p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb);
00286 void    p80211netdev_hwremoved(wlandevice_t *wlandev);
00287 void    p80211_suspend(wlandevice_t *wlandev);
00288 void    p80211_resume(wlandevice_t *wlandev);
00289 
00290 /*================================================================*/
00291 /* Function Definitions */
00292 
00293 static inline void
00294 p80211netdev_stop_queue(wlandevice_t *wlandev)
00295 {
00296         if ( !wlandev ) return;
00297         if ( !wlandev->netdev ) return;
00298 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
00299         wlandev->netdev->tbusy = 1;
00300         wlandev->netdev->start = 0;
00301 #else
00302         netif_stop_queue(wlandev->netdev);
00303 #endif
00304 }
00305 
00306 static inline void
00307 p80211netdev_start_queue(wlandevice_t *wlandev)
00308 {
00309         if ( !wlandev ) return;
00310         if ( !wlandev->netdev ) return;
00311 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
00312         wlandev->netdev->tbusy = 0;
00313         wlandev->netdev->start = 1;
00314 #else
00315         netif_start_queue(wlandev->netdev);
00316 #endif
00317 }
00318 
00319 static inline void
00320 p80211netdev_wake_queue(wlandevice_t *wlandev)
00321 {
00322         if ( !wlandev ) return;
00323         if ( !wlandev->netdev ) return;
00324 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
00325         wlandev->netdev->tbusy = 0;
00326         mark_bh(NET_BH);
00327 #else
00328         netif_wake_queue(wlandev->netdev);
00329 #endif
00330 }
00331 
00332 #ifdef CONFIG_HOTPLUG
00333 #define WLAN_HOTPLUG_REGISTER "register"
00334 #define WLAN_HOTPLUG_REMOVE   "remove"
00335 #define WLAN_HOTPLUG_STARTUP  "startup"
00336 #define WLAN_HOTPLUG_SHUTDOWN "shutdown"
00337 #define WLAN_HOTPLUG_SUSPEND "suspend"
00338 #define WLAN_HOTPLUG_RESUME "resume"
00339 int p80211_run_sbin_hotplug(wlandevice_t *wlandev, char *action);
00340 #endif
00341 
00342 #endif

Generated on Fri Feb 25 12:02:37 2005 for WifiScanner by  doxygen 1.4.1