Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
0002 /*
0003  *
0004  * WLAN net device structure and functions
0005  *
0006  * Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.
0007  * --------------------------------------------------------------------
0008  *
0009  * linux-wlan
0010  *
0011  *   The contents of this file are subject to the Mozilla Public
0012  *   License Version 1.1 (the "License"); you may not use this file
0013  *   except in compliance with the License. You may obtain a copy of
0014  *   the License at http://www.mozilla.org/MPL/
0015  *
0016  *   Software distributed under the License is distributed on an "AS
0017  *   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
0018  *   implied. See the License for the specific language governing
0019  *   rights and limitations under the License.
0020  *
0021  *   Alternatively, the contents of this file may be used under the
0022  *   terms of the GNU Public License version 2 (the "GPL"), in which
0023  *   case the provisions of the GPL are applicable instead of the
0024  *   above.  If you wish to allow the use of your version of this file
0025  *   only under the terms of the GPL and not to allow others to use
0026  *   your version of this file under the MPL, indicate your decision
0027  *   by deleting the provisions above and replace them with the notice
0028  *   and other provisions required by the GPL.  If you do not delete
0029  *   the provisions above, a recipient may use your version of this
0030  *   file under either the MPL or the GPL.
0031  *
0032  * --------------------------------------------------------------------
0033  *
0034  * Inquiries regarding the linux-wlan Open Source project can be
0035  * made directly to:
0036  *
0037  * AbsoluteValue Systems Inc.
0038  * info@linux-wlan.com
0039  * http://www.linux-wlan.com
0040  *
0041  * --------------------------------------------------------------------
0042  *
0043  * Portions of the development of this software were funded by
0044  * Intersil Corporation as part of PRISM(R) chipset product development.
0045  *
0046  * --------------------------------------------------------------------
0047  *
0048  * This file declares the structure type that represents each wlan
0049  * interface.
0050  *
0051  * --------------------------------------------------------------------
0052  */
0053 
0054 #ifndef _LINUX_P80211NETDEV_H
0055 #define _LINUX_P80211NETDEV_H
0056 
0057 #include <linux/interrupt.h>
0058 #include <linux/wireless.h>
0059 #include <linux/netdevice.h>
0060 
0061 #define WLAN_RELEASE    "0.3.0-staging"
0062 
0063 #define WLAN_DEVICE_CLOSED  0
0064 #define WLAN_DEVICE_OPEN    1
0065 
0066 #define WLAN_MACMODE_NONE   0
0067 #define WLAN_MACMODE_IBSS_STA   1
0068 #define WLAN_MACMODE_ESS_STA    2
0069 #define WLAN_MACMODE_ESS_AP 3
0070 
0071 /* MSD States */
0072 #define WLAN_MSD_HWPRESENT_PENDING  1
0073 #define WLAN_MSD_HWFAIL         2
0074 #define WLAN_MSD_HWPRESENT      3
0075 #define WLAN_MSD_FWLOAD_PENDING     4
0076 #define WLAN_MSD_FWLOAD         5
0077 #define WLAN_MSD_RUNNING_PENDING    6
0078 #define WLAN_MSD_RUNNING        7
0079 
0080 #ifndef ETH_P_ECONET
0081 #define ETH_P_ECONET   0x0018   /* needed for 2.2.x kernels */
0082 #endif
0083 
0084 #define ETH_P_80211_RAW        (ETH_P_ECONET + 1)
0085 
0086 #ifndef ARPHRD_IEEE80211
0087 #define ARPHRD_IEEE80211 801    /* kernel 2.4.6 */
0088 #endif
0089 
0090 #ifndef ARPHRD_IEEE80211_PRISM  /* kernel 2.4.18 */
0091 #define ARPHRD_IEEE80211_PRISM 802
0092 #endif
0093 
0094 /*--- NSD Capabilities Flags ------------------------------*/
0095 #define P80211_NSDCAP_HARDWAREWEP           0x01  /* hardware wep engine */
0096 #define P80211_NSDCAP_SHORT_PREAMBLE        0x10  /* hardware supports */
0097 #define P80211_NSDCAP_HWFRAGMENT            0x80  /* nsd handles frag/defrag */
0098 #define P80211_NSDCAP_AUTOJOIN              0x100 /* nsd does autojoin */
0099 #define P80211_NSDCAP_NOSCAN                0x200 /* nsd can scan */
0100 
0101 /* Received frame statistics */
0102 struct p80211_frmrx {
0103     u32 mgmt;
0104     u32 assocreq;
0105     u32 assocresp;
0106     u32 reassocreq;
0107     u32 reassocresp;
0108     u32 probereq;
0109     u32 proberesp;
0110     u32 beacon;
0111     u32 atim;
0112     u32 disassoc;
0113     u32 authen;
0114     u32 deauthen;
0115     u32 mgmt_unknown;
0116     u32 ctl;
0117     u32 pspoll;
0118     u32 rts;
0119     u32 cts;
0120     u32 ack;
0121     u32 cfend;
0122     u32 cfendcfack;
0123     u32 ctl_unknown;
0124     u32 data;
0125     u32 dataonly;
0126     u32 data_cfack;
0127     u32 data_cfpoll;
0128     u32 data__cfack_cfpoll;
0129     u32 null;
0130     u32 cfack;
0131     u32 cfpoll;
0132     u32 cfack_cfpoll;
0133     u32 data_unknown;
0134     u32 decrypt;
0135     u32 decrypt_err;
0136 };
0137 
0138 /* called by /proc/net/wireless */
0139 struct iw_statistics *p80211wext_get_wireless_stats(struct net_device *dev);
0140 /* wireless extensions' ioctls */
0141 extern struct iw_handler_def p80211wext_handler_def;
0142 
0143 /* WEP stuff */
0144 #define NUM_WEPKEYS 4
0145 #define MAX_KEYLEN 32
0146 
0147 #define HOSTWEP_DEFAULTKEY_MASK GENMASK(1, 0)
0148 #define HOSTWEP_SHAREDKEY BIT(3)
0149 #define HOSTWEP_DECRYPT  BIT(4)
0150 #define HOSTWEP_ENCRYPT  BIT(5)
0151 #define HOSTWEP_PRIVACYINVOKED BIT(6)
0152 #define HOSTWEP_EXCLUDEUNENCRYPTED BIT(7)
0153 
0154 extern int wlan_watchdog;
0155 extern int wlan_wext_write;
0156 
0157 /* WLAN device type */
0158 struct wlandevice {
0159     void *priv;     /* private data for MSD */
0160 
0161     /* Subsystem State */
0162     char name[WLAN_DEVNAMELEN_MAX]; /* Dev name, from register_wlandev() */
0163     char *nsdname;
0164 
0165     u32 state;      /* Device I/F state (open/closed) */
0166     u32 msdstate;       /* state of underlying driver */
0167     u32 hwremoved;      /* Has the hw been yanked out? */
0168 
0169     /* Hardware config */
0170     unsigned int irq;
0171     unsigned int iobase;
0172     unsigned int membase;
0173     u32 nsdcaps;        /* NSD Capabilities flags */
0174 
0175     /* Config vars */
0176     unsigned int ethconv;
0177 
0178     /* device methods (init by MSD, used by p80211 */
0179     int (*open)(struct wlandevice *wlandev);
0180     int (*close)(struct wlandevice *wlandev);
0181     void (*reset)(struct wlandevice *wlandev);
0182     int (*txframe)(struct wlandevice *wlandev, struct sk_buff *skb,
0183                struct p80211_hdr *p80211_hdr,
0184                struct p80211_metawep *p80211_wep);
0185     int (*mlmerequest)(struct wlandevice *wlandev, struct p80211msg *msg);
0186     int (*set_multicast_list)(struct wlandevice *wlandev,
0187                   struct net_device *dev);
0188     void (*tx_timeout)(struct wlandevice *wlandev);
0189 
0190     /* 802.11 State */
0191     u8 bssid[WLAN_BSSID_LEN];
0192     struct p80211pstr32 ssid;
0193     u32 macmode;
0194     int linkstatus;
0195 
0196     /* WEP State */
0197     u8 wep_keys[NUM_WEPKEYS][MAX_KEYLEN];
0198     u8 wep_keylens[NUM_WEPKEYS];
0199     int hostwep;
0200 
0201     /* Request/Confirm i/f state (used by p80211) */
0202     unsigned long request_pending;  /* flag, access atomically */
0203 
0204     /* netlink socket */
0205     /* queue for indications waiting for cmd completion */
0206     /* Linux netdevice and support */
0207     struct net_device *netdev;  /* ptr to linux netdevice */
0208 
0209     /* Rx bottom half */
0210     struct tasklet_struct rx_bh;
0211 
0212     struct sk_buff_head nsd_rxq;
0213 
0214     /* 802.11 device statistics */
0215     struct p80211_frmrx rx;
0216 
0217     struct iw_statistics wstats;
0218 
0219     /* jkriegl: iwspy fields */
0220     u8 spy_number;
0221     char spy_address[IW_MAX_SPY][ETH_ALEN];
0222     struct iw_quality spy_stat[IW_MAX_SPY];
0223 };
0224 
0225 /* WEP stuff */
0226 int wep_change_key(struct wlandevice *wlandev, int keynum, u8 *key, int keylen);
0227 int wep_decrypt(struct wlandevice *wlandev, u8 *buf, u32 len, int key_override,
0228         u8 *iv, u8 *icv);
0229 int wep_encrypt(struct wlandevice *wlandev, u8 *buf, u8 *dst, u32 len,
0230         int keynum, u8 *iv, u8 *icv);
0231 
0232 int wlan_setup(struct wlandevice *wlandev, struct device *physdev);
0233 void wlan_unsetup(struct wlandevice *wlandev);
0234 int register_wlandev(struct wlandevice *wlandev);
0235 int unregister_wlandev(struct wlandevice *wlandev);
0236 void p80211netdev_rx(struct wlandevice *wlandev, struct sk_buff *skb);
0237 void p80211netdev_hwremoved(struct wlandevice *wlandev);
0238 #endif