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 #include <linux/interrupt.h>
00057 #include <linux/wireless.h>
00058 
00059 /*================================================================*/
00060 /* Constants */
00061 
00062 #define WLAN_DEVICE_CLOSED  0
00063 #define WLAN_DEVICE_OPEN  1
00064 
00065 #define WLAN_MACMODE_NONE 0
00066 #define WLAN_MACMODE_IBSS_STA 1
00067 #define WLAN_MACMODE_ESS_STA  2
00068 #define WLAN_MACMODE_ESS_AP 3
00069 
00070 /* MSD States */
00071 #define WLAN_MSD_START      -1
00072 #define WLAN_MSD_DRIVERLOADED   0
00073 #define WLAN_MSD_HWPRESENT_PENDING  1
00074 #define WLAN_MSD_HWFAIL     2
00075 #define WLAN_MSD_HWPRESENT    3
00076 #define WLAN_MSD_FWLOAD_PENDING   4
00077 #define WLAN_MSD_FWLOAD     5
00078 #define WLAN_MSD_RUNNING_PENDING  6
00079 #define WLAN_MSD_RUNNING    7
00080 
00081 #ifndef ETH_P_ECONET
00082 #define ETH_P_ECONET   0x0018    /* needed for 2.2.x kernels */
00083 #endif
00084 
00085 #define ETH_P_80211_RAW        (ETH_P_ECONET + 1)
00086 
00087 #ifndef ARPHRD_IEEE80211
00088 #define ARPHRD_IEEE80211 801     /* kernel 2.4.6 */
00089 #endif
00090 
00091 #ifndef ARPHRD_IEEE80211_PRISM  /* kernel 2.4.18 */
00092 #define ARPHRD_IEEE80211_PRISM 802
00093 #endif
00094 
00095 /*--- NSD Capabilities Flags ------------------------------*/
00096 #define P80211_NSDCAP_HARDWAREWEP           0x01  /* hardware wep engine */
00097 #define P80211_NSDCAP_TIEDWEP               0x02  /* can't decouple en/de */
00098 #define P80211_NSDCAP_NOHOSTWEP             0x04  /* must use hardware wep */
00099 #define P80211_NSDCAP_PBCC                  0x08  /* hardware supports PBCC */
00100 #define P80211_NSDCAP_SHORT_PREAMBLE        0x10  /* hardware supports */
00101 #define P80211_NSDCAP_AGILITY               0x20  /* hardware supports */
00102 #define P80211_NSDCAP_AP_RETRANSMIT         0x40  /* nsd handles retransmits */
00103 #define P80211_NSDCAP_HWFRAGMENT            0x80  /* nsd handles frag/defrag */
00104 #define P80211_NSDCAP_AUTOJOIN              0x100  /* nsd does autojoin */
00105 #define P80211_NSDCAP_NOSCAN                0x200  /* nsd can scan */
00106 
00107 /*================================================================*/
00108 /* Macros */
00109 
00110 /*================================================================*/
00111 /* Types */
00112 
00113 /* Received frame statistics */
00114 typedef struct p80211_frmrx_t 
00115 {
00116   UINT32  mgmt;
00117   UINT32  assocreq;
00118   UINT32  assocresp;
00119   UINT32  reassocreq;
00120   UINT32  reassocresp;
00121   UINT32  probereq;
00122   UINT32  proberesp;
00123   UINT32  beacon;
00124   UINT32  atim;
00125   UINT32  disassoc;
00126   UINT32  authen;
00127   UINT32  deauthen;
00128   UINT32  mgmt_unknown;
00129   UINT32  ctl;
00130   UINT32  pspoll;
00131   UINT32  rts;
00132   UINT32  cts;
00133   UINT32  ack;
00134   UINT32  cfend;
00135   UINT32  cfendcfack;
00136   UINT32  ctl_unknown;
00137   UINT32  data;
00138   UINT32  dataonly;
00139   UINT32  data_cfack;
00140   UINT32  data_cfpoll;
00141   UINT32  data__cfack_cfpoll;
00142   UINT32  null;
00143   UINT32  cfack;
00144   UINT32  cfpoll;
00145   UINT32  cfack_cfpoll;
00146   UINT32  data_unknown;
00147   UINT32  decrypt;
00148   UINT32  decrypt_err;
00149 } p80211_frmrx_t;
00150 
00151 #ifdef WIRELESS_EXT
00152 /* called by /proc/net/wireless */
00153 struct iw_statistics* p80211wext_get_wireless_stats(netdevice_t *dev);
00154 /* wireless extensions' ioctls */ 
00155 int p80211wext_support_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd);
00156 #if WIRELESS_EXT > 12
00157 extern struct iw_handler_def p80211wext_handler_def;
00158 #endif
00159 
00160 int p80211wext_event_associated(struct wlandevice *wlandev, int assoc);
00161 
00162 #endif /* wireless extensions */
00163 
00164 /* WEP stuff */
00165 #define NUM_WEPKEYS 4
00166 #define MAX_KEYLEN 32
00167 
00168 #define HOSTWEP_DEFAULTKEY_MASK (BIT1|BIT0)
00169 #define HOSTWEP_DECRYPT  BIT4
00170 #define HOSTWEP_ENCRYPT  BIT5
00171 #define HOSTWEP_PRIVACYINVOKED BIT6
00172 #define HOSTWEP_EXCLUDEUNENCRYPTED BIT7
00173 
00174 extern int wlan_watchdog;
00175 extern int wlan_wext_write;
00176 
00177 /* WLAN device type */
00178 typedef struct wlandevice
00179 {
00180   struct wlandevice *next;    /* link for list of devices */
00181   void      *priv;    /* private data for MSD */
00182 
00183   /* Subsystem State */
00184   char    name[WLAN_DEVNAMELEN_MAX]; /* Dev name, from register_wlandev()*/
00185   char    *nsdname; 
00186 
00187   UINT32          state;          /* Device I/F state (open/closed) */
00188   UINT32    msdstate; /* state of underlying driver */
00189   UINT32    hwremoved;  /* Has the hw been yanked out? */
00190 
00191   /* Hardware config */
00192   UINT    irq;
00193   UINT    iobase;
00194   UINT    membase;
00195   UINT32          nsdcaps;  /* NSD Capabilities flags */
00196 
00197   /* Config vars */
00198   UINT    ethconv;
00199 
00200   /* device methods (init by MSD, used by p80211 */
00201   int   (*open)(struct wlandevice *wlandev);
00202   int   (*close)(struct wlandevice *wlandev);
00203   void    (*reset)(struct wlandevice *wlandev );
00204   int   (*txframe)(struct wlandevice *wlandev, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep);
00205   int   (*mlmerequest)(struct wlandevice *wlandev, p80211msg_t *msg);
00206   int             (*set_multicast_list)(struct wlandevice *wlandev, 
00207                 netdevice_t *dev);
00208   void    (*tx_timeout)(struct wlandevice *wlandev);
00209 
00210 #ifdef CONFIG_PROC_FS
00211   int             (*nsd_proc_read)(char *page, char **start, off_t offset, int count, int *eof, void *data);
00212 #endif
00213 
00214   /* 802.11 State */
00215   UINT8   bssid[WLAN_BSSID_LEN];
00216   p80211pstr32_t  ssid;
00217   UINT32    macmode;
00218   int             linkstatus;
00219   int             shortpreamble;  /* C bool */
00220 
00221   /* WEP State */
00222   UINT8 wep_keys[NUM_WEPKEYS][MAX_KEYLEN];
00223   UINT8 wep_keylens[NUM_WEPKEYS];
00224   int   hostwep;
00225   
00226   /* Request/Confirm i/f state (used by p80211) */
00227   long      request_pending; /* flag, access atomically */
00228 
00229   /* netlink socket */
00230   /* queue for indications waiting for cmd completion */
00231   /* Linux netdevice and support */
00232   netdevice_t   *netdev;  /* ptr to linux netdevice */
00233   struct net_device_stats linux_stats;
00234 
00235 #ifdef CONFIG_PROC_FS
00236   /* Procfs support */
00237   struct proc_dir_entry *procdir;
00238   struct proc_dir_entry *procwlandev;
00239 #endif
00240 
00241   /* Rx bottom half */
00242   struct tasklet_struct rx_bh;
00243 
00244   struct sk_buff_head nsd_rxq;
00245 
00246   /* 802.11 device statistics */
00247   struct p80211_frmrx_t rx;
00248 
00249 /* compatibility to wireless extensions */
00250 #ifdef WIRELESS_EXT
00251   struct iw_statistics  wstats;
00252 
00253   /* jkriegl: iwspy fields */
00254         UINT8     spy_number;
00255         char      spy_address[IW_MAX_SPY][ETH_ALEN];
00256         struct iw_quality       spy_stat[IW_MAX_SPY];
00257 
00258 #endif
00259 
00260 } wlandevice_t;
00261 
00262 /* WEP stuff */
00263 int wep_change_key(wlandevice_t *wlandev, int keynum, UINT8* key, int keylen);
00264 int wep_decrypt(wlandevice_t *wlandev, UINT8 *buf, UINT32 len, int key_override, UINT8 *iv, UINT8 *icv);
00265 int wep_encrypt(wlandevice_t *wlandev, UINT8 *buf, UINT8 *dst, UINT32 len, int keynum, UINT8 *iv, UINT8 *icv);
00266 
00267 /*================================================================*/
00268 /* Externs */
00269 
00270 /*================================================================*/
00271 /* Function Declarations */
00272 
00273 void  p80211netdev_startup(void);
00274 void  p80211netdev_shutdown(void);
00275 int wlan_setup(wlandevice_t *wlandev);
00276 int wlan_unsetup(wlandevice_t *wlandev);
00277 int register_wlandev(wlandevice_t *wlandev);
00278 int unregister_wlandev(wlandevice_t *wlandev);
00279 void  p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb);
00280 void  p80211netdev_hwremoved(wlandevice_t *wlandev);
00281 void    p80211_suspend(wlandevice_t *wlandev);
00282 void    p80211_resume(wlandevice_t *wlandev);
00283 
00284 /*================================================================*/
00285 /* Function Definitions */
00286 
00287 static inline void
00288 p80211netdev_stop_queue(wlandevice_t *wlandev)
00289 {
00290   if ( !wlandev ) return;
00291   if ( !wlandev->netdev ) return;
00292 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
00293   wlandev->netdev->tbusy = 1;
00294   wlandev->netdev->start = 0;
00295 #else
00296   netif_stop_queue(wlandev->netdev);
00297 #endif
00298 }
00299 
00300 static inline void
00301 p80211netdev_start_queue(wlandevice_t *wlandev)
00302 {
00303   if ( !wlandev ) return;
00304   if ( !wlandev->netdev ) return;
00305 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
00306   wlandev->netdev->tbusy = 0;
00307   wlandev->netdev->start = 1;
00308 #else
00309   netif_start_queue(wlandev->netdev);
00310 #endif
00311 }
00312 
00313 static inline void
00314 p80211netdev_wake_queue(wlandevice_t *wlandev)
00315 {
00316   if ( !wlandev ) return;
00317   if ( !wlandev->netdev ) return;
00318 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
00319   wlandev->netdev->tbusy = 0;
00320   mark_bh(NET_BH);
00321 #else
00322   netif_wake_queue(wlandev->netdev);
00323 #endif
00324 }
00325 
00326 #ifdef CONFIG_HOTPLUG
00327 #define WLAN_HOTPLUG_REGISTER "register"
00328 #define WLAN_HOTPLUG_REMOVE   "remove"
00329 #define WLAN_HOTPLUG_STARTUP  "startup"
00330 #define WLAN_HOTPLUG_SHUTDOWN "shutdown"
00331 #define WLAN_HOTPLUG_SUSPEND "suspend"
00332 #define WLAN_HOTPLUG_RESUME "resume"
00333 int p80211_run_sbin_hotplug(wlandevice_t *wlandev, char *action);
00334 #endif
00335 
00336 #endif

Generated on Fri Jul 25 17:10:36 2008 for WifiScanner by  doxygen 1.5.5