home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / src / linux-headers-2.6.17-6 / include / wlan / p80211netdev.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-08-11  |  9.8 KB  |  334 lines

  1. /* src/include/wlan/p80211netdev.h
  2. *
  3. * WLAN net device structure and functions
  4. *
  5. * Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.
  6. * --------------------------------------------------------------------
  7. *
  8. * linux-wlan
  9. *
  10. *   The contents of this file are subject to the Mozilla Public
  11. *   License Version 1.1 (the "License"); you may not use this file
  12. *   except in compliance with the License. You may obtain a copy of
  13. *   the License at http://www.mozilla.org/MPL/
  14. *
  15. *   Software distributed under the License is distributed on an "AS
  16. *   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  17. *   implied. See the License for the specific language governing
  18. *   rights and limitations under the License.
  19. *
  20. *   Alternatively, the contents of this file may be used under the
  21. *   terms of the GNU Public License version 2 (the "GPL"), in which
  22. *   case the provisions of the GPL are applicable instead of the
  23. *   above.  If you wish to allow the use of your version of this file
  24. *   only under the terms of the GPL and not to allow others to use
  25. *   your version of this file under the MPL, indicate your decision
  26. *   by deleting the provisions above and replace them with the notice
  27. *   and other provisions required by the GPL.  If you do not delete
  28. *   the provisions above, a recipient may use your version of this
  29. *   file under either the MPL or the GPL.
  30. *
  31. * --------------------------------------------------------------------
  32. *
  33. * Inquiries regarding the linux-wlan Open Source project can be
  34. * made directly to:
  35. *
  36. * AbsoluteValue Systems Inc.
  37. * info@linux-wlan.com
  38. * http://www.linux-wlan.com
  39. *
  40. * --------------------------------------------------------------------
  41. *
  42. * Portions of the development of this software were funded by 
  43. * Intersil Corporation as part of PRISM(R) chipset product development.
  44. *
  45. * --------------------------------------------------------------------
  46. *
  47. * This file declares the structure type that represents each wlan
  48. * interface.  
  49. *
  50. * --------------------------------------------------------------------
  51. */
  52.  
  53. #ifndef _LINUX_P80211NETDEV_H
  54. #define _LINUX_P80211NETDEV_H
  55.  
  56. #include <linux/interrupt.h>
  57. #include <linux/wireless.h>
  58.  
  59. /*================================================================*/
  60. /* Constants */
  61.  
  62. #define WLAN_DEVICE_CLOSED    0
  63. #define WLAN_DEVICE_OPEN    1
  64.  
  65. #define WLAN_MACMODE_NONE    0
  66. #define WLAN_MACMODE_IBSS_STA    1
  67. #define WLAN_MACMODE_ESS_STA    2
  68. #define WLAN_MACMODE_ESS_AP    3
  69.  
  70. /* MSD States */
  71. #define WLAN_MSD_START            -1
  72. #define WLAN_MSD_DRIVERLOADED        0
  73. #define WLAN_MSD_HWPRESENT_PENDING    1
  74. #define WLAN_MSD_HWFAIL            2
  75. #define WLAN_MSD_HWPRESENT        3
  76. #define WLAN_MSD_FWLOAD_PENDING        4
  77. #define WLAN_MSD_FWLOAD            5
  78. #define WLAN_MSD_RUNNING_PENDING    6
  79. #define WLAN_MSD_RUNNING        7
  80.  
  81. #ifndef ETH_P_ECONET
  82. #define ETH_P_ECONET   0x0018    /* needed for 2.2.x kernels */
  83. #endif
  84.  
  85. #define ETH_P_80211_RAW        (ETH_P_ECONET + 1)
  86.  
  87. #ifndef ARPHRD_IEEE80211
  88. #define ARPHRD_IEEE80211 801     /* kernel 2.4.6 */
  89. #endif
  90.  
  91. #ifndef ARPHRD_IEEE80211_PRISM  /* kernel 2.4.18 */
  92. #define ARPHRD_IEEE80211_PRISM 802
  93. #endif
  94.  
  95. /*--- NSD Capabilities Flags ------------------------------*/
  96. #define P80211_NSDCAP_HARDWAREWEP           0x01  /* hardware wep engine */
  97. #define P80211_NSDCAP_TIEDWEP               0x02  /* can't decouple en/de */
  98. #define P80211_NSDCAP_NOHOSTWEP             0x04  /* must use hardware wep */
  99. #define P80211_NSDCAP_PBCC                  0x08  /* hardware supports PBCC */
  100. #define P80211_NSDCAP_SHORT_PREAMBLE        0x10  /* hardware supports */
  101. #define P80211_NSDCAP_AGILITY               0x20  /* hardware supports */
  102. #define P80211_NSDCAP_AP_RETRANSMIT         0x40  /* nsd handles retransmits */
  103. #define P80211_NSDCAP_HWFRAGMENT            0x80  /* nsd handles frag/defrag */
  104. #define P80211_NSDCAP_AUTOJOIN              0x100  /* nsd does autojoin */
  105. #define P80211_NSDCAP_NOSCAN                0x200  /* nsd can scan */
  106.  
  107. /*================================================================*/
  108. /* Macros */
  109.  
  110. /*================================================================*/
  111. /* Types */
  112.  
  113. /* Received frame statistics */
  114. typedef struct p80211_frmrx_t 
  115. {
  116.     UINT32    mgmt;
  117.     UINT32    assocreq;
  118.     UINT32    assocresp;
  119.     UINT32    reassocreq;
  120.     UINT32    reassocresp;
  121.     UINT32    probereq;
  122.     UINT32    proberesp;
  123.     UINT32    beacon;
  124.     UINT32    atim;
  125.     UINT32    disassoc;
  126.     UINT32    authen;
  127.     UINT32    deauthen;
  128.     UINT32    mgmt_unknown;
  129.     UINT32    ctl;
  130.     UINT32    pspoll;
  131.     UINT32    rts;
  132.     UINT32    cts;
  133.     UINT32    ack;
  134.     UINT32    cfend;
  135.     UINT32    cfendcfack;
  136.     UINT32    ctl_unknown;
  137.     UINT32    data;
  138.     UINT32    dataonly;
  139.     UINT32    data_cfack;
  140.     UINT32    data_cfpoll;
  141.     UINT32    data__cfack_cfpoll;
  142.     UINT32    null;
  143.     UINT32    cfack;
  144.     UINT32    cfpoll;
  145.     UINT32    cfack_cfpoll;
  146.     UINT32    data_unknown;
  147.     UINT32  decrypt;
  148.     UINT32  decrypt_err;
  149. } p80211_frmrx_t;
  150.  
  151.  
  152. #ifdef WIRELESS_EXT
  153. /* called by /proc/net/wireless */
  154. struct iw_statistics* p80211wext_get_wireless_stats(netdevice_t *dev);
  155. /* wireless extensions' ioctls */ 
  156. int p80211wext_support_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd);
  157. #if WIRELESS_EXT > 12
  158. extern struct iw_handler_def p80211wext_handler_def;
  159. #endif
  160. #endif /* wireless extensions */
  161.  
  162. /* WEP stuff */
  163. #define NUM_WEPKEYS 4
  164. #define MAX_KEYLEN 32
  165.  
  166. #define HOSTWEP_DEFAULTKEY_MASK (BIT1|BIT0)
  167. #define HOSTWEP_DECRYPT  BIT4
  168. #define HOSTWEP_ENCRYPT  BIT5
  169. #define HOSTWEP_PRIVACYINVOKED BIT6
  170. #define HOSTWEP_EXCLUDEUNENCRYPTED BIT7
  171.  
  172. extern int wlan_watchdog;
  173. extern int wlan_wext_write;
  174.  
  175. /* WLAN device type */
  176. typedef struct wlandevice
  177. {
  178.     struct wlandevice    *next;        /* link for list of devices */
  179.     void            *priv;        /* private data for MSD */
  180.  
  181.     /* Subsystem State */
  182.     char        name[WLAN_DEVNAMELEN_MAX]; /* Dev name, from register_wlandev()*/
  183.     char        *nsdname; 
  184.  
  185.     UINT32          state;          /* Device I/F state (open/closed) */
  186.     UINT32        msdstate;    /* state of underlying driver */
  187.     UINT32        hwremoved;    /* Has the hw been yanked out? */
  188.  
  189.     /* Hardware config */
  190.     UINT        irq;
  191.     UINT        iobase;
  192.     UINT        membase;
  193.     UINT32          nsdcaps;  /* NSD Capabilities flags */
  194.  
  195.     /* Config vars */
  196.     UINT        ethconv;
  197.  
  198.     /* device methods (init by MSD, used by p80211 */
  199.     int        (*open)(struct wlandevice *wlandev);
  200.     int        (*close)(struct wlandevice *wlandev);
  201.     void        (*reset)(struct wlandevice *wlandev );
  202.     int        (*txframe)(struct wlandevice *wlandev, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep);
  203.     int        (*mlmerequest)(struct wlandevice *wlandev, p80211msg_t *msg);
  204.     int             (*set_multicast_list)(struct wlandevice *wlandev, 
  205.                           netdevice_t *dev);
  206.     void        (*tx_timeout)(struct wlandevice *wlandev);
  207.  
  208. #ifdef CONFIG_PROC_FS
  209.     int             (*nsd_proc_read)(char *page, char **start, off_t offset, int count, int    *eof, void *data);
  210. #endif
  211.  
  212.     /* 802.11 State */
  213.     UINT8        bssid[WLAN_BSSID_LEN];
  214.     p80211pstr32_t    ssid;
  215.     UINT32        macmode;
  216.     UINT            shortpreamble;  /* C bool */
  217.  
  218.     /* WEP State */
  219.     UINT8 wep_keys[NUM_WEPKEYS][MAX_KEYLEN];
  220.     UINT8 wep_keylens[NUM_WEPKEYS];
  221.     int   hostwep;
  222.   
  223.     /* Request/Confirm i/f state (used by p80211) */
  224.     long            request_pending; /* flag, access atomically */
  225.  
  226.     /* netlink socket */
  227.     /* queue for indications waiting for cmd completion */
  228.     /* Linux netdevice and support */
  229.     netdevice_t        *netdev;    /* ptr to linux netdevice */
  230.     struct net_device_stats linux_stats;
  231.  
  232. #ifdef CONFIG_PROC_FS
  233.     /* Procfs support */
  234.     struct proc_dir_entry    *procdir;
  235.     struct proc_dir_entry    *procwlandev;
  236. #endif
  237.  
  238.     /* Rx bottom half */
  239.     struct tasklet_struct    rx_bh;
  240.  
  241.     struct sk_buff_head    nsd_rxq;
  242.  
  243.     /* 802.11 device statistics */
  244.     struct p80211_frmrx_t    rx;
  245.  
  246. /* compatibility to wireless extensions */
  247. #ifdef WIRELESS_EXT
  248.     struct iw_statistics    wstats;
  249.  
  250.     /* jkriegl: iwspy fields */
  251.         UINT8            spy_number;
  252.         char            spy_address[IW_MAX_SPY][ETH_ALEN];
  253.         struct iw_quality       spy_stat[IW_MAX_SPY];
  254.  
  255. #endif
  256.  
  257. } wlandevice_t;
  258.  
  259. /* WEP stuff */
  260. int wep_change_key(wlandevice_t *wlandev, int keynum, UINT8* key, int keylen);
  261. int wep_decrypt(wlandevice_t *wlandev, UINT8 *buf, UINT32 len, int key_override, UINT8 *iv, UINT8 *icv);
  262. int wep_encrypt(wlandevice_t *wlandev, UINT8 *buf, UINT8 *dst, UINT32 len, int keynum, UINT8 *iv, UINT8 *icv);
  263.  
  264. /*================================================================*/
  265. /* Externs */
  266.  
  267. /*================================================================*/
  268. /* Function Declarations */
  269.  
  270. void    p80211netdev_startup(void);
  271. void    p80211netdev_shutdown(void);
  272. int    wlan_setup(wlandevice_t *wlandev);
  273. int    wlan_unsetup(wlandevice_t *wlandev);
  274. int    register_wlandev(wlandevice_t *wlandev);
  275. int    unregister_wlandev(wlandevice_t *wlandev);
  276. void    p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb);
  277. void    p80211netdev_hwremoved(wlandevice_t *wlandev);
  278. void    p80211_suspend(wlandevice_t *wlandev);
  279. void    p80211_resume(wlandevice_t *wlandev);
  280.  
  281. /*================================================================*/
  282. /* Function Definitions */
  283.  
  284. static inline void
  285. p80211netdev_stop_queue(wlandevice_t *wlandev)
  286. {
  287.     if ( !wlandev ) return;
  288.     if ( !wlandev->netdev ) return;
  289. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
  290.     wlandev->netdev->tbusy = 1;
  291.     wlandev->netdev->start = 0;
  292. #else
  293.     netif_stop_queue(wlandev->netdev);
  294. #endif
  295. }
  296.  
  297. static inline void
  298. p80211netdev_start_queue(wlandevice_t *wlandev)
  299. {
  300.     if ( !wlandev ) return;
  301.     if ( !wlandev->netdev ) return;
  302. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
  303.     wlandev->netdev->tbusy = 0;
  304.     wlandev->netdev->start = 1;
  305. #else
  306.     netif_start_queue(wlandev->netdev);
  307. #endif
  308. }
  309.  
  310. static inline void
  311. p80211netdev_wake_queue(wlandevice_t *wlandev)
  312. {
  313.     if ( !wlandev ) return;
  314.     if ( !wlandev->netdev ) return;
  315. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
  316.     wlandev->netdev->tbusy = 0;
  317.     mark_bh(NET_BH);
  318. #else
  319.     netif_wake_queue(wlandev->netdev);
  320. #endif
  321. }
  322.  
  323. #ifdef CONFIG_HOTPLUG
  324. #define WLAN_HOTPLUG_REGISTER "register"
  325. #define WLAN_HOTPLUG_REMOVE   "remove"
  326. #define WLAN_HOTPLUG_STARTUP  "startup"
  327. #define WLAN_HOTPLUG_SHUTDOWN "shutdown"
  328. #define WLAN_HOTPLUG_SUSPEND "suspend"
  329. #define WLAN_HOTPLUG_RESUME "resume"
  330. int p80211_run_sbin_hotplug(wlandevice_t *wlandev, char *action);
  331. #endif
  332.  
  333. #endif
  334.