You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
Staging: Added Realtek rtl8192u driver to staging
Add Realtek linux driver for rtl8192u as provided by Realtek rtl8192u_linux_2.6.0006.1031.2008.tar.gz, send to me C/C staging ML. This version won't compile against upstream, doesn't follow Linux CodingStyle and has their own ieee80211 stack. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
9b84375747
commit
8fc8598e61
6
drivers/staging/rtl8192u/Kconfig
Normal file
6
drivers/staging/rtl8192u/Kconfig
Normal file
@@ -0,0 +1,6 @@
|
||||
config RTL8192U
|
||||
tristate "RealTek RTL8192U Wireless LAN NIC driver"
|
||||
depends on PCI && WLAN
|
||||
depends on WIRELESS_EXT
|
||||
default N
|
||||
---help---
|
||||
32
drivers/staging/rtl8192u/Makefile
Normal file
32
drivers/staging/rtl8192u/Makefile
Normal file
@@ -0,0 +1,32 @@
|
||||
NIC_SELECT = RTL8192U
|
||||
|
||||
EXTRA_CFLAGS += -std=gnu89
|
||||
EXTRA_CFLAGS += -O2
|
||||
|
||||
EXTRA_CFLAGS += -mhard-float -DCONFIG_FORCE_HARD_FLOAT=y
|
||||
EXTRA_CFLAGS += -DJACKSON_NEW_8187 -DJACKSON_NEW_RX
|
||||
EXTRA_CFLAGS += -DTHOMAS_BEACON -DTHOMAS_TASKLET -DTHOMAS_SKB -DTHOMAS_TURBO
|
||||
#EXTRA_CFLAGS += -DUSB_TX_DRIVER_AGGREGATION_ENABLE
|
||||
#EXTRA_CFLAGS += -DUSB_RX_AGGREGATION_SUPPORT
|
||||
EXTRA_CFLAGS += -DUSE_ONE_PIPE
|
||||
EXTRA_CFLAGS += -DENABLE_DOT11D
|
||||
|
||||
r8192u_usb-objs := r8192U_core.o r8180_93cx6.o r8192U_wx.o \
|
||||
r8190_rtl8256.o r819xU_phy.o r819xU_firmware.o \
|
||||
r819xU_cmdpkt.o r8192U_dm.o r819xU_firmware_img.o \
|
||||
ieee80211/ieee80211_crypt.o \
|
||||
ieee80211/ieee80211_crypt_tkip.o \
|
||||
ieee80211/ieee80211_crypt_ccmp.o \
|
||||
ieee80211/ieee80211_crypt_wep.o \
|
||||
ieee80211/ieee80211_rx.o \
|
||||
ieee80211/ieee80211_softmac.o \
|
||||
ieee80211/ieee80211_tx.o \
|
||||
ieee80211/ieee80211_wx.o \
|
||||
ieee80211/ieee80211_module.o \
|
||||
ieee80211/ieee80211_softmac_wx.o \
|
||||
ieee80211/rtl819x_HTProc.o \
|
||||
ieee80211/rtl819x_TSProc.o \
|
||||
ieee80211/rtl819x_BAProc.o \
|
||||
ieee80211/dot11d.o
|
||||
|
||||
obj-$(CONFIG_RTL8192U) += r8192u_usb.o
|
||||
1
drivers/staging/rtl8192u/authors
Normal file
1
drivers/staging/rtl8192u/authors
Normal file
@@ -0,0 +1 @@
|
||||
Andrea Merello <andreamrl@tiscali.it>
|
||||
5
drivers/staging/rtl8192u/changes
Normal file
5
drivers/staging/rtl8192u/changes
Normal file
@@ -0,0 +1,5 @@
|
||||
v 0.1
|
||||
|
||||
First version.
|
||||
This is based on the rtl8180-sa2400 pre-0.22-CVS code..
|
||||
|
||||
340
drivers/staging/rtl8192u/copying
Normal file
340
drivers/staging/rtl8192u/copying
Normal file
@@ -0,0 +1,340 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
102
drivers/staging/rtl8192u/dot11d.h
Normal file
102
drivers/staging/rtl8192u/dot11d.h
Normal file
@@ -0,0 +1,102 @@
|
||||
#ifndef __INC_DOT11D_H
|
||||
#define __INC_DOT11D_H
|
||||
|
||||
#ifdef ENABLE_DOT11D
|
||||
#include "ieee80211.h"
|
||||
|
||||
//#define ENABLE_DOT11D
|
||||
|
||||
//#define DOT11D_MAX_CHNL_NUM 83
|
||||
|
||||
typedef struct _CHNL_TXPOWER_TRIPLE {
|
||||
u8 FirstChnl;
|
||||
u8 NumChnls;
|
||||
u8 MaxTxPowerInDbm;
|
||||
}CHNL_TXPOWER_TRIPLE, *PCHNL_TXPOWER_TRIPLE;
|
||||
|
||||
typedef enum _DOT11D_STATE {
|
||||
DOT11D_STATE_NONE = 0,
|
||||
DOT11D_STATE_LEARNED,
|
||||
DOT11D_STATE_DONE,
|
||||
}DOT11D_STATE;
|
||||
|
||||
typedef struct _RT_DOT11D_INFO {
|
||||
//DECLARE_RT_OBJECT(RT_DOT11D_INFO);
|
||||
|
||||
bool bEnabled; // dot11MultiDomainCapabilityEnabled
|
||||
|
||||
u16 CountryIeLen; // > 0 if CountryIeBuf[] contains valid country information element.
|
||||
u8 CountryIeBuf[MAX_IE_LEN];
|
||||
u8 CountryIeSrcAddr[6]; // Source AP of the country IE.
|
||||
u8 CountryIeWatchdog;
|
||||
|
||||
u8 channel_map[MAX_CHANNEL_NUMBER+1]; //!!!Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan)
|
||||
//u8 ChnlListLen; // #Bytes valid in ChnlList[].
|
||||
//u8 ChnlList[DOT11D_MAX_CHNL_NUM];
|
||||
u8 MaxTxPwrDbmList[MAX_CHANNEL_NUMBER+1];
|
||||
|
||||
DOT11D_STATE State;
|
||||
}RT_DOT11D_INFO, *PRT_DOT11D_INFO;
|
||||
#define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 )
|
||||
#define cpMacAddr(des,src) ((des)[0]=(src)[0],(des)[1]=(src)[1],(des)[2]=(src)[2],(des)[3]=(src)[3],(des)[4]=(src)[4],(des)[5]=(src)[5])
|
||||
#define GET_DOT11D_INFO(__pIeeeDev) ((PRT_DOT11D_INFO)((__pIeeeDev)->pDot11dInfo))
|
||||
|
||||
#define IS_DOT11D_ENABLE(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->bEnabled
|
||||
#define IS_COUNTRY_IE_VALID(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0)
|
||||
|
||||
#define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
|
||||
#define UPDATE_CIE_SRC(__pIeeeDev, __pTa) cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
|
||||
|
||||
#define IS_COUNTRY_IE_CHANGED(__pIeeeDev, __Ie) \
|
||||
(((__Ie).Length == 0 || (__Ie).Length != GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen) ? \
|
||||
FALSE : \
|
||||
(!memcmp(GET_DOT11D_INFO(__pIeeeDev)->CountryIeBuf, (__Ie).Octet, (__Ie).Length)))
|
||||
|
||||
#define CIE_WATCHDOG_TH 1
|
||||
#define GET_CIE_WATCHDOG(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->CountryIeWatchdog
|
||||
#define RESET_CIE_WATCHDOG(__pIeeeDev) GET_CIE_WATCHDOG(__pIeeeDev) = 0
|
||||
#define UPDATE_CIE_WATCHDOG(__pIeeeDev) ++GET_CIE_WATCHDOG(__pIeeeDev)
|
||||
|
||||
#define IS_DOT11D_STATE_DONE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->State == DOT11D_STATE_DONE)
|
||||
|
||||
|
||||
void
|
||||
Dot11d_Init(
|
||||
struct ieee80211_device *dev
|
||||
);
|
||||
|
||||
void
|
||||
Dot11d_Reset(
|
||||
struct ieee80211_device *dev
|
||||
);
|
||||
|
||||
void
|
||||
Dot11d_UpdateCountryIe(
|
||||
struct ieee80211_device *dev,
|
||||
u8 * pTaddr,
|
||||
u16 CoutryIeLen,
|
||||
u8 * pCoutryIe
|
||||
);
|
||||
|
||||
u8
|
||||
DOT11D_GetMaxTxPwrInDbm(
|
||||
struct ieee80211_device *dev,
|
||||
u8 Channel
|
||||
);
|
||||
|
||||
void
|
||||
DOT11D_ScanComplete(
|
||||
struct ieee80211_device * dev
|
||||
);
|
||||
|
||||
int IsLegalChannel(
|
||||
struct ieee80211_device * dev,
|
||||
u8 channel
|
||||
);
|
||||
|
||||
int ToLegalChannel(
|
||||
struct ieee80211_device * dev,
|
||||
u8 channel
|
||||
);
|
||||
#endif //ENABLE_DOT11D
|
||||
#endif // #ifndef __INC_DOT11D_H
|
||||
2795
drivers/staging/rtl8192u/ieee80211.h
Normal file
2795
drivers/staging/rtl8192u/ieee80211.h
Normal file
File diff suppressed because it is too large
Load Diff
199
drivers/staging/rtl8192u/ieee80211/EndianFree.h
Normal file
199
drivers/staging/rtl8192u/ieee80211/EndianFree.h
Normal file
@@ -0,0 +1,199 @@
|
||||
#ifndef __INC_ENDIANFREE_H
|
||||
#define __INC_ENDIANFREE_H
|
||||
|
||||
/*
|
||||
* Call endian free function when
|
||||
* 1. Read/write packet content.
|
||||
* 2. Before write integer to IO.
|
||||
* 3. After read integer from IO.
|
||||
*/
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
|
||||
#ifndef bool
|
||||
typedef enum{false = 0, true} bool;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define __MACHINE_LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
|
||||
#define __MACHINE_BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net, ppc */
|
||||
|
||||
#define BYTE_ORDER __MACHINE_LITTLE_ENDIAN
|
||||
|
||||
#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN
|
||||
// Convert data
|
||||
#define EF1Byte(_val) ((u8)(_val))
|
||||
#define EF2Byte(_val) ((u16)(_val))
|
||||
#define EF4Byte(_val) ((u32)(_val))
|
||||
|
||||
#else
|
||||
// Convert data
|
||||
#define EF1Byte(_val) ((u8)(_val))
|
||||
#define EF2Byte(_val) (((((u16)(_val))&0x00ff)<<8)|((((u16)(_val))&0xff00)>>8))
|
||||
#define EF4Byte(_val) (((((u32)(_val))&0x000000ff)<<24)|\
|
||||
((((u32)(_val))&0x0000ff00)<<8)|\
|
||||
((((u32)(_val))&0x00ff0000)>>8)|\
|
||||
((((u32)(_val))&0xff000000)>>24))
|
||||
#endif
|
||||
|
||||
// Read data from memory
|
||||
#define ReadEF1Byte(_ptr) EF1Byte(*((u8 *)(_ptr)))
|
||||
#define ReadEF2Byte(_ptr) EF2Byte(*((u16 *)(_ptr)))
|
||||
#define ReadEF4Byte(_ptr) EF4Byte(*((u32 *)(_ptr)))
|
||||
|
||||
// Write data to memory
|
||||
#define WriteEF1Byte(_ptr, _val) (*((u8 *)(_ptr)))=EF1Byte(_val)
|
||||
#define WriteEF2Byte(_ptr, _val) (*((u16 *)(_ptr)))=EF2Byte(_val)
|
||||
#define WriteEF4Byte(_ptr, _val) (*((u32 *)(_ptr)))=EF4Byte(_val)
|
||||
// Convert Host system specific byte ording (litten or big endia) to Network byte ording (big endian).
|
||||
// 2006.05.07, by rcnjko.
|
||||
#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN
|
||||
#define H2N1BYTE(_val) ((u8)(_val))
|
||||
#define H2N2BYTE(_val) (((((u16)(_val))&0x00ff)<<8)|\
|
||||
((((u16)(_val))&0xff00)>>8))
|
||||
#define H2N4BYTE(_val) (((((u32)(_val))&0x000000ff)<<24)|\
|
||||
((((u32)(_val))&0x0000ff00)<<8) |\
|
||||
((((u32)(_val))&0x00ff0000)>>8) |\
|
||||
((((u32)(_val))&0xff000000)>>24))
|
||||
#else
|
||||
#define H2N1BYTE(_val) ((u8)(_val))
|
||||
#define H2N2BYTE(_val) ((u16)(_val))
|
||||
#define H2N4BYTE(_val) ((u32)(_val))
|
||||
#endif
|
||||
|
||||
// Convert from Network byte ording (big endian) to Host system specific byte ording (litten or big endia).
|
||||
// 2006.05.07, by rcnjko.
|
||||
#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN
|
||||
#define N2H1BYTE(_val) ((u8)(_val))
|
||||
#define N2H2BYTE(_val) (((((u16)(_val))&0x00ff)<<8)|\
|
||||
((((u16)(_val))&0xff00)>>8))
|
||||
#define N2H4BYTE(_val) (((((u32)(_val))&0x000000ff)<<24)|\
|
||||
((((u32)(_val))&0x0000ff00)<<8) |\
|
||||
((((u32)(_val))&0x00ff0000)>>8) |\
|
||||
((((u32)(_val))&0xff000000)>>24))
|
||||
#else
|
||||
#define N2H1BYTE(_val) ((u8)(_val))
|
||||
#define N2H2BYTE(_val) ((u16)(_val))
|
||||
#define N2H4BYTE(_val) ((u32)(_val))
|
||||
#endif
|
||||
|
||||
//
|
||||
// Example:
|
||||
// BIT_LEN_MASK_32(0) => 0x00000000
|
||||
// BIT_LEN_MASK_32(1) => 0x00000001
|
||||
// BIT_LEN_MASK_32(2) => 0x00000003
|
||||
// BIT_LEN_MASK_32(32) => 0xFFFFFFFF
|
||||
//
|
||||
#define BIT_LEN_MASK_32(__BitLen) (0xFFFFFFFF >> (32 - (__BitLen)))
|
||||
//
|
||||
// Example:
|
||||
// BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003
|
||||
// BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000
|
||||
//
|
||||
#define BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) (BIT_LEN_MASK_32(__BitLen) << (__BitOffset))
|
||||
|
||||
//
|
||||
// Description:
|
||||
// Return 4-byte value in host byte ordering from
|
||||
// 4-byte pointer in litten-endian system.
|
||||
//
|
||||
#define LE_P4BYTE_TO_HOST_4BYTE(__pStart) (EF4Byte(*((u32 *)(__pStart))))
|
||||
|
||||
//
|
||||
// Description:
|
||||
// Translate subfield (continuous bits in little-endian) of 4-byte value in litten byte to
|
||||
// 4-byte value in host byte ordering.
|
||||
//
|
||||
#define LE_BITS_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
( LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset) ) \
|
||||
& \
|
||||
BIT_LEN_MASK_32(__BitLen) \
|
||||
)
|
||||
|
||||
//
|
||||
// Description:
|
||||
// Mask subfield (continuous bits in little-endian) of 4-byte value in litten byte oredering
|
||||
// and return the result in 4-byte value in host byte ordering.
|
||||
//
|
||||
#define LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
LE_P4BYTE_TO_HOST_4BYTE(__pStart) \
|
||||
& \
|
||||
( ~BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) ) \
|
||||
)
|
||||
|
||||
//
|
||||
// Description:
|
||||
// Set subfield of little-endian 4-byte value to specified value.
|
||||
//
|
||||
#define SET_BITS_TO_LE_4BYTE(__pStart, __BitOffset, __BitLen, __Value) \
|
||||
*((u32 *)(__pStart)) = \
|
||||
EF4Byte( \
|
||||
LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
| \
|
||||
( (((u32)__Value) & BIT_LEN_MASK_32(__BitLen)) << (__BitOffset) ) \
|
||||
);
|
||||
|
||||
|
||||
#define BIT_LEN_MASK_16(__BitLen) \
|
||||
(0xFFFF >> (16 - (__BitLen)))
|
||||
|
||||
#define BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) \
|
||||
(BIT_LEN_MASK_16(__BitLen) << (__BitOffset))
|
||||
|
||||
#define LE_P2BYTE_TO_HOST_2BYTE(__pStart) \
|
||||
(EF2Byte(*((u16 *)(__pStart))))
|
||||
|
||||
#define LE_BITS_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
( LE_P2BYTE_TO_HOST_2BYTE(__pStart) >> (__BitOffset) ) \
|
||||
& \
|
||||
BIT_LEN_MASK_16(__BitLen) \
|
||||
)
|
||||
|
||||
#define LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
LE_P2BYTE_TO_HOST_2BYTE(__pStart) \
|
||||
& \
|
||||
( ~BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) ) \
|
||||
)
|
||||
|
||||
#define SET_BITS_TO_LE_2BYTE(__pStart, __BitOffset, __BitLen, __Value) \
|
||||
*((u16 *)(__pStart)) = \
|
||||
EF2Byte( \
|
||||
LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
| \
|
||||
( (((u16)__Value) & BIT_LEN_MASK_16(__BitLen)) << (__BitOffset) ) \
|
||||
);
|
||||
|
||||
#define BIT_LEN_MASK_8(__BitLen) \
|
||||
(0xFF >> (8 - (__BitLen)))
|
||||
|
||||
#define BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) \
|
||||
(BIT_LEN_MASK_8(__BitLen) << (__BitOffset))
|
||||
|
||||
#define LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
|
||||
(EF1Byte(*((u8 *)(__pStart))))
|
||||
|
||||
#define LE_BITS_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
( LE_P1BYTE_TO_HOST_1BYTE(__pStart) >> (__BitOffset) ) \
|
||||
& \
|
||||
BIT_LEN_MASK_8(__BitLen) \
|
||||
)
|
||||
|
||||
#define LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
|
||||
& \
|
||||
( ~BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) ) \
|
||||
)
|
||||
|
||||
#define SET_BITS_TO_LE_1BYTE(__pStart, __BitOffset, __BitLen, __Value) \
|
||||
*((u8 *)(__pStart)) = \
|
||||
EF1Byte( \
|
||||
LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
| \
|
||||
( (((u8)__Value) & BIT_LEN_MASK_8(__BitLen)) << (__BitOffset) ) \
|
||||
);
|
||||
|
||||
#endif // #ifndef __INC_ENDIANFREE_H
|
||||
139
drivers/staging/rtl8192u/ieee80211/Makefile
Normal file
139
drivers/staging/rtl8192u/ieee80211/Makefile
Normal file
@@ -0,0 +1,139 @@
|
||||
NIC_SELECT = RTL8192U
|
||||
|
||||
KVER := $(shell uname -r)
|
||||
MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless/$(NIC_SELECT)
|
||||
|
||||
CC = gcc
|
||||
ifneq ($(shell uname -r|cut -d. -f1,2), 2.4)
|
||||
EXTRA_CFLAGS += -I$(TOPDIR)/drivers/net/wireless
|
||||
EXTRA_CFLAGS += -O2
|
||||
EXTRA_CFLAGS += -DJACKSON_NEW_8187 -DJACKSON_NEW_RX
|
||||
|
||||
#it will fail to compile in suse linux enterprise 10 sp2. This flag is to solve this problem.
|
||||
ifeq ($(shell uname -r | cut -d. -f1,2,3,4), 2.6.16.60-0)
|
||||
EXTRA_CFLAGS += -DOPENSUSE_SLED
|
||||
endif
|
||||
|
||||
ifeq ($(NIC_SELECT),RTL8192U)
|
||||
#EXTRA_CFLAGS += -DUSB_TX_DRIVER_AGGREGATION_ENABLE
|
||||
#EXTRA_CFLAGS += -DUSB_RX_AGGREGATION_SUPPORT
|
||||
endif
|
||||
#EXTRA_CFLAGS += -DJOHN_NOCPY
|
||||
#flags to enable or disble 80211D feature
|
||||
EXTRA_CFLAGS += -DENABLE_DOT11D
|
||||
ieee80211-rsl-objs := ieee80211_rx.o \
|
||||
ieee80211_softmac.o \
|
||||
ieee80211_tx.o \
|
||||
ieee80211_wx.o \
|
||||
ieee80211_module.o \
|
||||
ieee80211_softmac_wx.o\
|
||||
rtl819x_HTProc.o\
|
||||
rtl819x_TSProc.o\
|
||||
rtl819x_BAProc.o\
|
||||
dot11d.o
|
||||
|
||||
ieee80211_crypt-rsl-objs := ieee80211_crypt.o
|
||||
ieee80211_crypt_tkip-rsl-objs := ieee80211_crypt_tkip.o
|
||||
ieee80211_crypt_ccmp-rsl-objs := ieee80211_crypt_ccmp.o
|
||||
ieee80211_crypt_wep-rsl-objs := ieee80211_crypt_wep.o
|
||||
|
||||
obj-m +=ieee80211-rsl.o
|
||||
obj-m +=ieee80211_crypt-rsl.o
|
||||
obj-m +=ieee80211_crypt_wep-rsl.o
|
||||
obj-m +=ieee80211_crypt_tkip-rsl.o
|
||||
obj-m +=ieee80211_crypt_ccmp-rsl.o
|
||||
|
||||
KSRC := /lib/modules/$(KVER)/build
|
||||
INSTALL_PREFIX :=
|
||||
|
||||
all: modules
|
||||
|
||||
modules:
|
||||
$(MAKE) -C $(KSRC) M=$(PWD) CC=$(CC) modules
|
||||
|
||||
install: modules
|
||||
rm -fr $(MODDESTDIR)
|
||||
mkdir -p $(MODDESTDIR)
|
||||
@install -p -m 644 ieee80211_crypt-rsl.ko $(MODDESTDIR)
|
||||
@install -p -m 644 ieee80211_crypt_wep-rsl.ko $(MODDESTDIR)
|
||||
@install -p -m 644 ieee80211_crypt_tkip-rsl.ko $(MODDESTDIR)
|
||||
@install -p -m 644 ieee80211_crypt_ccmp-rsl.ko $(MODDESTDIR)
|
||||
@install -p -m 644 ieee80211-rsl.ko $(MODDESTDIR)
|
||||
depmod -a
|
||||
uninstall:
|
||||
rm -fr $(MODDESTDIR)
|
||||
depmod -a
|
||||
|
||||
else
|
||||
LD := ld
|
||||
KSRC := /lib/modules/$(KVER)/build
|
||||
CONFIG_FILE := $(KSRC)/include/linux/autoconf.h
|
||||
|
||||
CFLAGS += -DLINUX -D__KERNEL__ -DMODULE -O2 -pipe -Wall
|
||||
CFLAGS += -I$(KSRC)/include -I.
|
||||
#Kernel 2.4.31
|
||||
CFLAGS += -DMODVERSIONS -DEXPORT_SYMTAB -include $(KSRC)/include/linux/modversions.h
|
||||
#Kernel 2.4.20
|
||||
#CFLAGS += -D__NO_VERSION__ -DEXPORT_SYMTAB
|
||||
#CFLAGS += -DENABLE_DOT11D
|
||||
SMP := $(shell $(CC) $(MODCFLAGS) -E -dM $(CONFIG_FILE) | \
|
||||
grep CONFIG_SMP | awk '{print $$3}')
|
||||
ifneq ($(SMP),1)
|
||||
SMP := 0
|
||||
endif
|
||||
ifeq ($(SMP),1)
|
||||
CFLAGS += -D__SMP__
|
||||
endif
|
||||
|
||||
#CFLAGS += -DJOHN_NOCPY
|
||||
|
||||
OBJS := ${patsubst %.c, %.o, ${wildcard *.c}}
|
||||
all:${OBJS} ieee80211_crypt-rsl.o michael_mic-rsl.o aes-rsl.o ieee80211_crypt_wep-rsl.o ieee80211_crypt_tkip-rsl.o ieee80211_crypt_ccmp-rsl.o crypto-rsl.o ieee80211-rsl.o
|
||||
|
||||
ieee80211_crypt-rsl.o: ieee80211_crypt.o
|
||||
mv $^ $@
|
||||
|
||||
michael_mic-rsl.o: michael_mic.o
|
||||
mv $^ $@
|
||||
|
||||
aes-rsl.o: aes.o
|
||||
mv $^ $@
|
||||
|
||||
ieee80211_crypt_wep-rsl.o: ieee80211_crypt_wep.o
|
||||
mv $^ $@
|
||||
|
||||
ieee80211_crypt_tkip-rsl.o: ieee80211_crypt_tkip.o
|
||||
mv $^ $@
|
||||
|
||||
ieee80211_crypt_ccmp-rsl.o: ieee80211_crypt_ccmp.o
|
||||
mv $^ $@
|
||||
|
||||
crypto-rsl.o: arc4.o api.o autoload.o cipher.o compress.o digest.o scatterwalk.o proc.o
|
||||
$(LD) -r $^ -o $@
|
||||
|
||||
ieee80211-rsl.o: ieee80211_rx.o ieee80211_tx.o ieee80211_wx.o ieee80211_module.o ieee80211_softmac_wx.o ieee80211_softmac.o rtl819x_HTProc.o rtl819x_TSProc.o rtl819x_BAProc.o dot11d.o
|
||||
$(LD) -r $^ -o $@
|
||||
install:
|
||||
rm -fr $(MODDESTDIR)
|
||||
mkdir -p $(MODDESTDIR)
|
||||
@install -p -m 644 ieee80211_crypt-rsl.o $(MODDESTDIR)
|
||||
@install -p -m 644 crypto-rsl.o $(MODDESTDIR)
|
||||
@install -p -m 644 michael_mic-rsl.o $(MODDESTDIR)
|
||||
@install -p -m 644 aes-rsl.o $(MODDESTDIR)
|
||||
@install -p -m 644 ieee80211_crypt_wep-rsl.o $(MODDESTDIR)
|
||||
@install -p -m 644 ieee80211_crypt_tkip-rsl.o $(MODDESTDIR)
|
||||
@install -p -m 644 ieee80211_crypt_ccmp-rsl.o $(MODDESTDIR)
|
||||
@install -p -m 644 ieee80211-rsl.o $(MODDESTDIR)
|
||||
/sbin/depmod -a ${shell uname -r}
|
||||
|
||||
uninstall:
|
||||
rm -fr $(MODDESTDIR)
|
||||
/sbin/depmod -a ${shell uname -r}
|
||||
|
||||
endif
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -fr *.mod.c *.mod *.o .*.cmd *.mod.* *.ko *.o *~
|
||||
rm -rf .tmp_versions
|
||||
rm -rf Module.symvers
|
||||
469
drivers/staging/rtl8192u/ieee80211/aes.c
Normal file
469
drivers/staging/rtl8192u/ieee80211/aes.c
Normal file
@@ -0,0 +1,469 @@
|
||||
/*
|
||||
* Cryptographic API.
|
||||
*
|
||||
* AES Cipher Algorithm.
|
||||
*
|
||||
* Based on Brian Gladman's code.
|
||||
*
|
||||
* Linux developers:
|
||||
* Alexander Kjeldaas <astor@fast.no>
|
||||
* Herbert Valerio Riedel <hvr@hvrlab.org>
|
||||
* Kyle McMartin <kyle@debian.org>
|
||||
* Adam J. Richter <adam@yggdrasil.com> (conversion to 2.5 API).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ---------------------------------------------------------------------------
|
||||
* Copyright (c) 2002, Dr Brian Gladman <brg@gladman.me.uk>, Worcester, UK.
|
||||
* All rights reserved.
|
||||
*
|
||||
* LICENSE TERMS
|
||||
*
|
||||
* The free distribution and use of this software in both source and binary
|
||||
* form is allowed (with or without changes) provided that:
|
||||
*
|
||||
* 1. distributions of this source code include the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
*
|
||||
* 2. distributions in binary form include the above copyright
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other associated materials;
|
||||
*
|
||||
* 3. the copyright holder's name is not used to endorse products
|
||||
* built using this software without specific written permission.
|
||||
*
|
||||
* ALTERNATIVELY, provided that this notice is retained in full, this product
|
||||
* may be distributed under the terms of the GNU General Public License (GPL),
|
||||
* in which case the provisions of the GPL apply INSTEAD OF those given above.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* This software is provided 'as is' with no explicit or implied warranties
|
||||
* in respect of its properties, including, but not limited to, correctness
|
||||
* and/or fitness for purpose.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* Some changes from the Gladman version:
|
||||
s/RIJNDAEL(e_key)/E_KEY/g
|
||||
s/RIJNDAEL(d_key)/D_KEY/g
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/errno.h>
|
||||
//#include <linux/crypto.h>
|
||||
#include "rtl_crypto.h"
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
#define AES_MIN_KEY_SIZE 16
|
||||
#define AES_MAX_KEY_SIZE 32
|
||||
|
||||
#define AES_BLOCK_SIZE 16
|
||||
|
||||
static inline
|
||||
u32 generic_rotr32 (const u32 x, const unsigned bits)
|
||||
{
|
||||
const unsigned n = bits % 32;
|
||||
return (x >> n) | (x << (32 - n));
|
||||
}
|
||||
|
||||
static inline
|
||||
u32 generic_rotl32 (const u32 x, const unsigned bits)
|
||||
{
|
||||
const unsigned n = bits % 32;
|
||||
return (x << n) | (x >> (32 - n));
|
||||
}
|
||||
|
||||
#define rotl generic_rotl32
|
||||
#define rotr generic_rotr32
|
||||
|
||||
/*
|
||||
* #define byte(x, nr) ((unsigned char)((x) >> (nr*8)))
|
||||
*/
|
||||
inline static u8
|
||||
byte(const u32 x, const unsigned n)
|
||||
{
|
||||
return x >> (n << 3);
|
||||
}
|
||||
|
||||
#define u32_in(x) le32_to_cpu(*(const u32 *)(x))
|
||||
#define u32_out(to, from) (*(u32 *)(to) = cpu_to_le32(from))
|
||||
|
||||
struct aes_ctx {
|
||||
int key_length;
|
||||
u32 E[60];
|
||||
u32 D[60];
|
||||
};
|
||||
|
||||
#define E_KEY ctx->E
|
||||
#define D_KEY ctx->D
|
||||
|
||||
static u8 pow_tab[256] __initdata;
|
||||
static u8 log_tab[256] __initdata;
|
||||
static u8 sbx_tab[256] __initdata;
|
||||
static u8 isb_tab[256] __initdata;
|
||||
static u32 rco_tab[10];
|
||||
static u32 ft_tab[4][256];
|
||||
static u32 it_tab[4][256];
|
||||
|
||||
static u32 fl_tab[4][256];
|
||||
static u32 il_tab[4][256];
|
||||
|
||||
static inline u8 __init
|
||||
f_mult (u8 a, u8 b)
|
||||
{
|
||||
u8 aa = log_tab[a], cc = aa + log_tab[b];
|
||||
|
||||
return pow_tab[cc + (cc < aa ? 1 : 0)];
|
||||
}
|
||||
|
||||
#define ff_mult(a,b) (a && b ? f_mult(a, b) : 0)
|
||||
|
||||
#define f_rn(bo, bi, n, k) \
|
||||
bo[n] = ft_tab[0][byte(bi[n],0)] ^ \
|
||||
ft_tab[1][byte(bi[(n + 1) & 3],1)] ^ \
|
||||
ft_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
|
||||
ft_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n)
|
||||
|
||||
#define i_rn(bo, bi, n, k) \
|
||||
bo[n] = it_tab[0][byte(bi[n],0)] ^ \
|
||||
it_tab[1][byte(bi[(n + 3) & 3],1)] ^ \
|
||||
it_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
|
||||
it_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n)
|
||||
|
||||
#define ls_box(x) \
|
||||
( fl_tab[0][byte(x, 0)] ^ \
|
||||
fl_tab[1][byte(x, 1)] ^ \
|
||||
fl_tab[2][byte(x, 2)] ^ \
|
||||
fl_tab[3][byte(x, 3)] )
|
||||
|
||||
#define f_rl(bo, bi, n, k) \
|
||||
bo[n] = fl_tab[0][byte(bi[n],0)] ^ \
|
||||
fl_tab[1][byte(bi[(n + 1) & 3],1)] ^ \
|
||||
fl_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
|
||||
fl_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n)
|
||||
|
||||
#define i_rl(bo, bi, n, k) \
|
||||
bo[n] = il_tab[0][byte(bi[n],0)] ^ \
|
||||
il_tab[1][byte(bi[(n + 3) & 3],1)] ^ \
|
||||
il_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
|
||||
il_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n)
|
||||
|
||||
static void __init
|
||||
gen_tabs (void)
|
||||
{
|
||||
u32 i, t;
|
||||
u8 p, q;
|
||||
|
||||
/* log and power tables for GF(2**8) finite field with
|
||||
0x011b as modular polynomial - the simplest primitive
|
||||
root is 0x03, used here to generate the tables */
|
||||
|
||||
for (i = 0, p = 1; i < 256; ++i) {
|
||||
pow_tab[i] = (u8) p;
|
||||
log_tab[p] = (u8) i;
|
||||
|
||||
p ^= (p << 1) ^ (p & 0x80 ? 0x01b : 0);
|
||||
}
|
||||
|
||||
log_tab[1] = 0;
|
||||
|
||||
for (i = 0, p = 1; i < 10; ++i) {
|
||||
rco_tab[i] = p;
|
||||
|
||||
p = (p << 1) ^ (p & 0x80 ? 0x01b : 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < 256; ++i) {
|
||||
p = (i ? pow_tab[255 - log_tab[i]] : 0);
|
||||
q = ((p >> 7) | (p << 1)) ^ ((p >> 6) | (p << 2));
|
||||
p ^= 0x63 ^ q ^ ((q >> 6) | (q << 2));
|
||||
sbx_tab[i] = p;
|
||||
isb_tab[p] = (u8) i;
|
||||
}
|
||||
|
||||
for (i = 0; i < 256; ++i) {
|
||||
p = sbx_tab[i];
|
||||
|
||||
t = p;
|
||||
fl_tab[0][i] = t;
|
||||
fl_tab[1][i] = rotl (t, 8);
|
||||
fl_tab[2][i] = rotl (t, 16);
|
||||
fl_tab[3][i] = rotl (t, 24);
|
||||
|
||||
t = ((u32) ff_mult (2, p)) |
|
||||
((u32) p << 8) |
|
||||
((u32) p << 16) | ((u32) ff_mult (3, p) << 24);
|
||||
|
||||
ft_tab[0][i] = t;
|
||||
ft_tab[1][i] = rotl (t, 8);
|
||||
ft_tab[2][i] = rotl (t, 16);
|
||||
ft_tab[3][i] = rotl (t, 24);
|
||||
|
||||
p = isb_tab[i];
|
||||
|
||||
t = p;
|
||||
il_tab[0][i] = t;
|
||||
il_tab[1][i] = rotl (t, 8);
|
||||
il_tab[2][i] = rotl (t, 16);
|
||||
il_tab[3][i] = rotl (t, 24);
|
||||
|
||||
t = ((u32) ff_mult (14, p)) |
|
||||
((u32) ff_mult (9, p) << 8) |
|
||||
((u32) ff_mult (13, p) << 16) |
|
||||
((u32) ff_mult (11, p) << 24);
|
||||
|
||||
it_tab[0][i] = t;
|
||||
it_tab[1][i] = rotl (t, 8);
|
||||
it_tab[2][i] = rotl (t, 16);
|
||||
it_tab[3][i] = rotl (t, 24);
|
||||
}
|
||||
}
|
||||
|
||||
#define star_x(x) (((x) & 0x7f7f7f7f) << 1) ^ ((((x) & 0x80808080) >> 7) * 0x1b)
|
||||
|
||||
#define imix_col(y,x) \
|
||||
u = star_x(x); \
|
||||
v = star_x(u); \
|
||||
w = star_x(v); \
|
||||
t = w ^ (x); \
|
||||
(y) = u ^ v ^ w; \
|
||||
(y) ^= rotr(u ^ t, 8) ^ \
|
||||
rotr(v ^ t, 16) ^ \
|
||||
rotr(t,24)
|
||||
|
||||
/* initialise the key schedule from the user supplied key */
|
||||
|
||||
#define loop4(i) \
|
||||
{ t = rotr(t, 8); t = ls_box(t) ^ rco_tab[i]; \
|
||||
t ^= E_KEY[4 * i]; E_KEY[4 * i + 4] = t; \
|
||||
t ^= E_KEY[4 * i + 1]; E_KEY[4 * i + 5] = t; \
|
||||
t ^= E_KEY[4 * i + 2]; E_KEY[4 * i + 6] = t; \
|
||||
t ^= E_KEY[4 * i + 3]; E_KEY[4 * i + 7] = t; \
|
||||
}
|
||||
|
||||
#define loop6(i) \
|
||||
{ t = rotr(t, 8); t = ls_box(t) ^ rco_tab[i]; \
|
||||
t ^= E_KEY[6 * i]; E_KEY[6 * i + 6] = t; \
|
||||
t ^= E_KEY[6 * i + 1]; E_KEY[6 * i + 7] = t; \
|
||||
t ^= E_KEY[6 * i + 2]; E_KEY[6 * i + 8] = t; \
|
||||
t ^= E_KEY[6 * i + 3]; E_KEY[6 * i + 9] = t; \
|
||||
t ^= E_KEY[6 * i + 4]; E_KEY[6 * i + 10] = t; \
|
||||
t ^= E_KEY[6 * i + 5]; E_KEY[6 * i + 11] = t; \
|
||||
}
|
||||
|
||||
#define loop8(i) \
|
||||
{ t = rotr(t, 8); ; t = ls_box(t) ^ rco_tab[i]; \
|
||||
t ^= E_KEY[8 * i]; E_KEY[8 * i + 8] = t; \
|
||||
t ^= E_KEY[8 * i + 1]; E_KEY[8 * i + 9] = t; \
|
||||
t ^= E_KEY[8 * i + 2]; E_KEY[8 * i + 10] = t; \
|
||||
t ^= E_KEY[8 * i + 3]; E_KEY[8 * i + 11] = t; \
|
||||
t = E_KEY[8 * i + 4] ^ ls_box(t); \
|
||||
E_KEY[8 * i + 12] = t; \
|
||||
t ^= E_KEY[8 * i + 5]; E_KEY[8 * i + 13] = t; \
|
||||
t ^= E_KEY[8 * i + 6]; E_KEY[8 * i + 14] = t; \
|
||||
t ^= E_KEY[8 * i + 7]; E_KEY[8 * i + 15] = t; \
|
||||
}
|
||||
|
||||
static int
|
||||
aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
|
||||
{
|
||||
struct aes_ctx *ctx = ctx_arg;
|
||||
u32 i, t, u, v, w;
|
||||
|
||||
if (key_len != 16 && key_len != 24 && key_len != 32) {
|
||||
*flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx->key_length = key_len;
|
||||
|
||||
E_KEY[0] = u32_in (in_key);
|
||||
E_KEY[1] = u32_in (in_key + 4);
|
||||
E_KEY[2] = u32_in (in_key + 8);
|
||||
E_KEY[3] = u32_in (in_key + 12);
|
||||
|
||||
switch (key_len) {
|
||||
case 16:
|
||||
t = E_KEY[3];
|
||||
for (i = 0; i < 10; ++i)
|
||||
loop4 (i);
|
||||
break;
|
||||
|
||||
case 24:
|
||||
E_KEY[4] = u32_in (in_key + 16);
|
||||
t = E_KEY[5] = u32_in (in_key + 20);
|
||||
for (i = 0; i < 8; ++i)
|
||||
loop6 (i);
|
||||
break;
|
||||
|
||||
case 32:
|
||||
E_KEY[4] = u32_in (in_key + 16);
|
||||
E_KEY[5] = u32_in (in_key + 20);
|
||||
E_KEY[6] = u32_in (in_key + 24);
|
||||
t = E_KEY[7] = u32_in (in_key + 28);
|
||||
for (i = 0; i < 7; ++i)
|
||||
loop8 (i);
|
||||
break;
|
||||
}
|
||||
|
||||
D_KEY[0] = E_KEY[0];
|
||||
D_KEY[1] = E_KEY[1];
|
||||
D_KEY[2] = E_KEY[2];
|
||||
D_KEY[3] = E_KEY[3];
|
||||
|
||||
for (i = 4; i < key_len + 24; ++i) {
|
||||
imix_col (D_KEY[i], E_KEY[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* encrypt a block of text */
|
||||
|
||||
#define f_nround(bo, bi, k) \
|
||||
f_rn(bo, bi, 0, k); \
|
||||
f_rn(bo, bi, 1, k); \
|
||||
f_rn(bo, bi, 2, k); \
|
||||
f_rn(bo, bi, 3, k); \
|
||||
k += 4
|
||||
|
||||
#define f_lround(bo, bi, k) \
|
||||
f_rl(bo, bi, 0, k); \
|
||||
f_rl(bo, bi, 1, k); \
|
||||
f_rl(bo, bi, 2, k); \
|
||||
f_rl(bo, bi, 3, k)
|
||||
|
||||
static void aes_encrypt(void *ctx_arg, u8 *out, const u8 *in)
|
||||
{
|
||||
const struct aes_ctx *ctx = ctx_arg;
|
||||
u32 b0[4], b1[4];
|
||||
const u32 *kp = E_KEY + 4;
|
||||
|
||||
b0[0] = u32_in (in) ^ E_KEY[0];
|
||||
b0[1] = u32_in (in + 4) ^ E_KEY[1];
|
||||
b0[2] = u32_in (in + 8) ^ E_KEY[2];
|
||||
b0[3] = u32_in (in + 12) ^ E_KEY[3];
|
||||
|
||||
if (ctx->key_length > 24) {
|
||||
f_nround (b1, b0, kp);
|
||||
f_nround (b0, b1, kp);
|
||||
}
|
||||
|
||||
if (ctx->key_length > 16) {
|
||||
f_nround (b1, b0, kp);
|
||||
f_nround (b0, b1, kp);
|
||||
}
|
||||
|
||||
f_nround (b1, b0, kp);
|
||||
f_nround (b0, b1, kp);
|
||||
f_nround (b1, b0, kp);
|
||||
f_nround (b0, b1, kp);
|
||||
f_nround (b1, b0, kp);
|
||||
f_nround (b0, b1, kp);
|
||||
f_nround (b1, b0, kp);
|
||||
f_nround (b0, b1, kp);
|
||||
f_nround (b1, b0, kp);
|
||||
f_lround (b0, b1, kp);
|
||||
|
||||
u32_out (out, b0[0]);
|
||||
u32_out (out + 4, b0[1]);
|
||||
u32_out (out + 8, b0[2]);
|
||||
u32_out (out + 12, b0[3]);
|
||||
}
|
||||
|
||||
/* decrypt a block of text */
|
||||
|
||||
#define i_nround(bo, bi, k) \
|
||||
i_rn(bo, bi, 0, k); \
|
||||
i_rn(bo, bi, 1, k); \
|
||||
i_rn(bo, bi, 2, k); \
|
||||
i_rn(bo, bi, 3, k); \
|
||||
k -= 4
|
||||
|
||||
#define i_lround(bo, bi, k) \
|
||||
i_rl(bo, bi, 0, k); \
|
||||
i_rl(bo, bi, 1, k); \
|
||||
i_rl(bo, bi, 2, k); \
|
||||
i_rl(bo, bi, 3, k)
|
||||
|
||||
static void aes_decrypt(void *ctx_arg, u8 *out, const u8 *in)
|
||||
{
|
||||
const struct aes_ctx *ctx = ctx_arg;
|
||||
u32 b0[4], b1[4];
|
||||
const int key_len = ctx->key_length;
|
||||
const u32 *kp = D_KEY + key_len + 20;
|
||||
|
||||
b0[0] = u32_in (in) ^ E_KEY[key_len + 24];
|
||||
b0[1] = u32_in (in + 4) ^ E_KEY[key_len + 25];
|
||||
b0[2] = u32_in (in + 8) ^ E_KEY[key_len + 26];
|
||||
b0[3] = u32_in (in + 12) ^ E_KEY[key_len + 27];
|
||||
|
||||
if (key_len > 24) {
|
||||
i_nround (b1, b0, kp);
|
||||
i_nround (b0, b1, kp);
|
||||
}
|
||||
|
||||
if (key_len > 16) {
|
||||
i_nround (b1, b0, kp);
|
||||
i_nround (b0, b1, kp);
|
||||
}
|
||||
|
||||
i_nround (b1, b0, kp);
|
||||
i_nround (b0, b1, kp);
|
||||
i_nround (b1, b0, kp);
|
||||
i_nround (b0, b1, kp);
|
||||
i_nround (b1, b0, kp);
|
||||
i_nround (b0, b1, kp);
|
||||
i_nround (b1, b0, kp);
|
||||
i_nround (b0, b1, kp);
|
||||
i_nround (b1, b0, kp);
|
||||
i_lround (b0, b1, kp);
|
||||
|
||||
u32_out (out, b0[0]);
|
||||
u32_out (out + 4, b0[1]);
|
||||
u32_out (out + 8, b0[2]);
|
||||
u32_out (out + 12, b0[3]);
|
||||
}
|
||||
|
||||
|
||||
static struct crypto_alg aes_alg = {
|
||||
.cra_name = "aes",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||
.cra_blocksize = AES_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct aes_ctx),
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(aes_alg.cra_list),
|
||||
.cra_u = {
|
||||
.cipher = {
|
||||
.cia_min_keysize = AES_MIN_KEY_SIZE,
|
||||
.cia_max_keysize = AES_MAX_KEY_SIZE,
|
||||
.cia_setkey = aes_set_key,
|
||||
.cia_encrypt = aes_encrypt,
|
||||
.cia_decrypt = aes_decrypt
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static int __init aes_init(void)
|
||||
{
|
||||
gen_tabs();
|
||||
return crypto_register_alg(&aes_alg);
|
||||
}
|
||||
|
||||
static void __exit aes_fini(void)
|
||||
{
|
||||
crypto_unregister_alg(&aes_alg);
|
||||
}
|
||||
|
||||
module_init(aes_init);
|
||||
module_exit(aes_fini);
|
||||
|
||||
MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm");
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
|
||||
246
drivers/staging/rtl8192u/ieee80211/api.c
Normal file
246
drivers/staging/rtl8192u/ieee80211/api.c
Normal file
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* Scatterlist Cryptographic API.
|
||||
*
|
||||
* Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
|
||||
* Copyright (c) 2002 David S. Miller (davem@redhat.com)
|
||||
*
|
||||
* Portions derived from Cryptoapi, by Alexander Kjeldaas <astor@fast.no>
|
||||
* and Nettle, by Niels M鰈ler.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
*/
|
||||
#include "kmap_types.h"
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
//#include <linux/crypto.h>
|
||||
#include "rtl_crypto.h"
|
||||
#include <linux/errno.h>
|
||||
#include <linux/rwsem.h>
|
||||
#include <linux/slab.h>
|
||||
#include "internal.h"
|
||||
|
||||
LIST_HEAD(crypto_alg_list);
|
||||
DECLARE_RWSEM(crypto_alg_sem);
|
||||
|
||||
static inline int crypto_alg_get(struct crypto_alg *alg)
|
||||
{
|
||||
return try_inc_mod_count(alg->cra_module);
|
||||
}
|
||||
|
||||
static inline void crypto_alg_put(struct crypto_alg *alg)
|
||||
{
|
||||
if (alg->cra_module)
|
||||
__MOD_DEC_USE_COUNT(alg->cra_module);
|
||||
}
|
||||
|
||||
struct crypto_alg *crypto_alg_lookup(const char *name)
|
||||
{
|
||||
struct crypto_alg *q, *alg = NULL;
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
down_read(&crypto_alg_sem);
|
||||
|
||||
list_for_each_entry(q, &crypto_alg_list, cra_list) {
|
||||
if (!(strcmp(q->cra_name, name))) {
|
||||
if (crypto_alg_get(q))
|
||||
alg = q;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
up_read(&crypto_alg_sem);
|
||||
return alg;
|
||||
}
|
||||
|
||||
static int crypto_init_flags(struct crypto_tfm *tfm, u32 flags)
|
||||
{
|
||||
tfm->crt_flags = 0;
|
||||
|
||||
switch (crypto_tfm_alg_type(tfm)) {
|
||||
case CRYPTO_ALG_TYPE_CIPHER:
|
||||
return crypto_init_cipher_flags(tfm, flags);
|
||||
|
||||
case CRYPTO_ALG_TYPE_DIGEST:
|
||||
return crypto_init_digest_flags(tfm, flags);
|
||||
|
||||
case CRYPTO_ALG_TYPE_COMPRESS:
|
||||
return crypto_init_compress_flags(tfm, flags);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
BUG();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int crypto_init_ops(struct crypto_tfm *tfm)
|
||||
{
|
||||
switch (crypto_tfm_alg_type(tfm)) {
|
||||
case CRYPTO_ALG_TYPE_CIPHER:
|
||||
return crypto_init_cipher_ops(tfm);
|
||||
|
||||
case CRYPTO_ALG_TYPE_DIGEST:
|
||||
return crypto_init_digest_ops(tfm);
|
||||
|
||||
case CRYPTO_ALG_TYPE_COMPRESS:
|
||||
return crypto_init_compress_ops(tfm);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
BUG();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static void crypto_exit_ops(struct crypto_tfm *tfm)
|
||||
{
|
||||
switch (crypto_tfm_alg_type(tfm)) {
|
||||
case CRYPTO_ALG_TYPE_CIPHER:
|
||||
crypto_exit_cipher_ops(tfm);
|
||||
break;
|
||||
|
||||
case CRYPTO_ALG_TYPE_DIGEST:
|
||||
crypto_exit_digest_ops(tfm);
|
||||
break;
|
||||
|
||||
case CRYPTO_ALG_TYPE_COMPRESS:
|
||||
crypto_exit_compress_ops(tfm);
|
||||
break;
|
||||
|
||||
default:
|
||||
BUG();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
|
||||
{
|
||||
struct crypto_tfm *tfm = NULL;
|
||||
struct crypto_alg *alg;
|
||||
|
||||
alg = crypto_alg_mod_lookup(name);
|
||||
if (alg == NULL)
|
||||
goto out;
|
||||
|
||||
tfm = kmalloc(sizeof(*tfm) + alg->cra_ctxsize, GFP_KERNEL);
|
||||
if (tfm == NULL)
|
||||
goto out_put;
|
||||
|
||||
memset(tfm, 0, sizeof(*tfm) + alg->cra_ctxsize);
|
||||
|
||||
tfm->__crt_alg = alg;
|
||||
|
||||
if (crypto_init_flags(tfm, flags))
|
||||
goto out_free_tfm;
|
||||
|
||||
if (crypto_init_ops(tfm)) {
|
||||
crypto_exit_ops(tfm);
|
||||
goto out_free_tfm;
|
||||
}
|
||||
|
||||
goto out;
|
||||
|
||||
out_free_tfm:
|
||||
kfree(tfm);
|
||||
tfm = NULL;
|
||||
out_put:
|
||||
crypto_alg_put(alg);
|
||||
out:
|
||||
return tfm;
|
||||
}
|
||||
|
||||
void crypto_free_tfm(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct crypto_alg *alg = tfm->__crt_alg;
|
||||
int size = sizeof(*tfm) + alg->cra_ctxsize;
|
||||
|
||||
crypto_exit_ops(tfm);
|
||||
crypto_alg_put(alg);
|
||||
memset(tfm, 0, size);
|
||||
kfree(tfm);
|
||||
}
|
||||
|
||||
int crypto_register_alg(struct crypto_alg *alg)
|
||||
{
|
||||
int ret = 0;
|
||||
struct crypto_alg *q;
|
||||
|
||||
down_write(&crypto_alg_sem);
|
||||
|
||||
list_for_each_entry(q, &crypto_alg_list, cra_list) {
|
||||
if (!(strcmp(q->cra_name, alg->cra_name))) {
|
||||
ret = -EEXIST;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
list_add_tail(&alg->cra_list, &crypto_alg_list);
|
||||
out:
|
||||
up_write(&crypto_alg_sem);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int crypto_unregister_alg(struct crypto_alg *alg)
|
||||
{
|
||||
int ret = -ENOENT;
|
||||
struct crypto_alg *q;
|
||||
|
||||
BUG_ON(!alg->cra_module);
|
||||
|
||||
down_write(&crypto_alg_sem);
|
||||
list_for_each_entry(q, &crypto_alg_list, cra_list) {
|
||||
if (alg == q) {
|
||||
list_del(&alg->cra_list);
|
||||
ret = 0;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
out:
|
||||
up_write(&crypto_alg_sem);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int crypto_alg_available(const char *name, u32 flags)
|
||||
{
|
||||
int ret = 0;
|
||||
struct crypto_alg *alg = crypto_alg_mod_lookup(name);
|
||||
|
||||
if (alg) {
|
||||
crypto_alg_put(alg);
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __init init_crypto(void)
|
||||
{
|
||||
printk(KERN_INFO "Initializing Cryptographic API\n");
|
||||
crypto_init_proc();
|
||||
return 0;
|
||||
}
|
||||
|
||||
__initcall(init_crypto);
|
||||
|
||||
/*
|
||||
EXPORT_SYMBOL_GPL(crypto_register_alg);
|
||||
EXPORT_SYMBOL_GPL(crypto_unregister_alg);
|
||||
EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
|
||||
EXPORT_SYMBOL_GPL(crypto_free_tfm);
|
||||
EXPORT_SYMBOL_GPL(crypto_alg_available);
|
||||
*/
|
||||
|
||||
EXPORT_SYMBOL_NOVERS(crypto_register_alg);
|
||||
EXPORT_SYMBOL_NOVERS(crypto_unregister_alg);
|
||||
EXPORT_SYMBOL_NOVERS(crypto_alloc_tfm);
|
||||
EXPORT_SYMBOL_NOVERS(crypto_free_tfm);
|
||||
EXPORT_SYMBOL_NOVERS(crypto_alg_available);
|
||||
103
drivers/staging/rtl8192u/ieee80211/arc4.c
Normal file
103
drivers/staging/rtl8192u/ieee80211/arc4.c
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Cryptographic API
|
||||
*
|
||||
* ARC4 Cipher Algorithm
|
||||
*
|
||||
* Jon Oberheide <jon@oberheide.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
*/
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include "rtl_crypto.h"
|
||||
|
||||
#define ARC4_MIN_KEY_SIZE 1
|
||||
#define ARC4_MAX_KEY_SIZE 256
|
||||
#define ARC4_BLOCK_SIZE 1
|
||||
|
||||
struct arc4_ctx {
|
||||
u8 S[256];
|
||||
u8 x, y;
|
||||
};
|
||||
|
||||
static int arc4_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
|
||||
{
|
||||
struct arc4_ctx *ctx = ctx_arg;
|
||||
int i, j = 0, k = 0;
|
||||
|
||||
ctx->x = 1;
|
||||
ctx->y = 0;
|
||||
|
||||
for(i = 0; i < 256; i++)
|
||||
ctx->S[i] = i;
|
||||
|
||||
for(i = 0; i < 256; i++)
|
||||
{
|
||||
u8 a = ctx->S[i];
|
||||
j = (j + in_key[k] + a) & 0xff;
|
||||
ctx->S[i] = ctx->S[j];
|
||||
ctx->S[j] = a;
|
||||
if((unsigned int)++k >= key_len)
|
||||
k = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void arc4_crypt(void *ctx_arg, u8 *out, const u8 *in)
|
||||
{
|
||||
struct arc4_ctx *ctx = ctx_arg;
|
||||
|
||||
u8 *const S = ctx->S;
|
||||
u8 x = ctx->x;
|
||||
u8 y = ctx->y;
|
||||
u8 a, b;
|
||||
|
||||
a = S[x];
|
||||
y = (y + a) & 0xff;
|
||||
b = S[y];
|
||||
S[x] = b;
|
||||
S[y] = a;
|
||||
x = (x + 1) & 0xff;
|
||||
*out++ = *in ^ S[(a + b) & 0xff];
|
||||
|
||||
ctx->x = x;
|
||||
ctx->y = y;
|
||||
}
|
||||
|
||||
static struct crypto_alg arc4_alg = {
|
||||
.cra_name = "arc4",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||
.cra_blocksize = ARC4_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct arc4_ctx),
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(arc4_alg.cra_list),
|
||||
.cra_u = { .cipher = {
|
||||
.cia_min_keysize = ARC4_MIN_KEY_SIZE,
|
||||
.cia_max_keysize = ARC4_MAX_KEY_SIZE,
|
||||
.cia_setkey = arc4_set_key,
|
||||
.cia_encrypt = arc4_crypt,
|
||||
.cia_decrypt = arc4_crypt } }
|
||||
};
|
||||
|
||||
static int __init arc4_init(void)
|
||||
{
|
||||
return crypto_register_alg(&arc4_alg);
|
||||
}
|
||||
|
||||
|
||||
static void __exit arc4_exit(void)
|
||||
{
|
||||
crypto_unregister_alg(&arc4_alg);
|
||||
}
|
||||
|
||||
module_init(arc4_init);
|
||||
module_exit(arc4_exit);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("ARC4 Cipher Algorithm");
|
||||
MODULE_AUTHOR("Jon Oberheide <jon@oberheide.org>");
|
||||
40
drivers/staging/rtl8192u/ieee80211/autoload.c
Normal file
40
drivers/staging/rtl8192u/ieee80211/autoload.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Cryptographic API.
|
||||
*
|
||||
* Algorithm autoloader.
|
||||
*
|
||||
* Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
*/
|
||||
#include "kmap_types.h"
|
||||
|
||||
#include <linux/kernel.h>
|
||||
//#include <linux/crypto.h>
|
||||
#include "rtl_crypto.h"
|
||||
#include <linux/string.h>
|
||||
#include <linux/kmod.h>
|
||||
#include "internal.h"
|
||||
|
||||
/*
|
||||
* A far more intelligent version of this is planned. For now, just
|
||||
* try an exact match on the name of the algorithm.
|
||||
*/
|
||||
void crypto_alg_autoload(const char *name)
|
||||
{
|
||||
request_module(name);
|
||||
}
|
||||
|
||||
struct crypto_alg *crypto_alg_mod_lookup(const char *name)
|
||||
{
|
||||
struct crypto_alg *alg = crypto_alg_lookup(name);
|
||||
if (alg == NULL) {
|
||||
crypto_alg_autoload(name);
|
||||
alg = crypto_alg_lookup(name);
|
||||
}
|
||||
return alg;
|
||||
}
|
||||
299
drivers/staging/rtl8192u/ieee80211/cipher.c
Normal file
299
drivers/staging/rtl8192u/ieee80211/cipher.c
Normal file
@@ -0,0 +1,299 @@
|
||||
/*
|
||||
* Cryptographic API.
|
||||
*
|
||||
* Cipher operations.
|
||||
*
|
||||
* Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
*/
|
||||
#include <linux/kernel.h>
|
||||
//#include <linux/crypto.h>
|
||||
#include "rtl_crypto.h"
|
||||
#include <linux/errno.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/slab.h>
|
||||
#include <asm/scatterlist.h>
|
||||
#include "internal.h"
|
||||
#include "scatterwalk.h"
|
||||
|
||||
typedef void (cryptfn_t)(void *, u8 *, const u8 *);
|
||||
typedef void (procfn_t)(struct crypto_tfm *, u8 *,
|
||||
u8*, cryptfn_t, int enc, void *, int);
|
||||
|
||||
static inline void xor_64(u8 *a, const u8 *b)
|
||||
{
|
||||
((u32 *)a)[0] ^= ((u32 *)b)[0];
|
||||
((u32 *)a)[1] ^= ((u32 *)b)[1];
|
||||
}
|
||||
|
||||
static inline void xor_128(u8 *a, const u8 *b)
|
||||
{
|
||||
((u32 *)a)[0] ^= ((u32 *)b)[0];
|
||||
((u32 *)a)[1] ^= ((u32 *)b)[1];
|
||||
((u32 *)a)[2] ^= ((u32 *)b)[2];
|
||||
((u32 *)a)[3] ^= ((u32 *)b)[3];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Generic encrypt/decrypt wrapper for ciphers, handles operations across
|
||||
* multiple page boundaries by using temporary blocks. In user context,
|
||||
* the kernel is given a chance to schedule us once per block.
|
||||
*/
|
||||
static int crypt(struct crypto_tfm *tfm,
|
||||
struct scatterlist *dst,
|
||||
struct scatterlist *src,
|
||||
unsigned int nbytes, cryptfn_t crfn,
|
||||
procfn_t prfn, int enc, void *info)
|
||||
{
|
||||
struct scatter_walk walk_in, walk_out;
|
||||
const unsigned int bsize = crypto_tfm_alg_blocksize(tfm);
|
||||
u8 tmp_src[bsize];
|
||||
u8 tmp_dst[bsize];
|
||||
|
||||
if (!nbytes)
|
||||
return 0;
|
||||
|
||||
if (nbytes % bsize) {
|
||||
tfm->crt_flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
scatterwalk_start(&walk_in, src);
|
||||
scatterwalk_start(&walk_out, dst);
|
||||
|
||||
for(;;) {
|
||||
u8 *src_p, *dst_p;
|
||||
int in_place;
|
||||
|
||||
scatterwalk_map(&walk_in, 0);
|
||||
scatterwalk_map(&walk_out, 1);
|
||||
src_p = scatterwalk_whichbuf(&walk_in, bsize, tmp_src);
|
||||
dst_p = scatterwalk_whichbuf(&walk_out, bsize, tmp_dst);
|
||||
in_place = scatterwalk_samebuf(&walk_in, &walk_out,
|
||||
src_p, dst_p);
|
||||
|
||||
nbytes -= bsize;
|
||||
|
||||
scatterwalk_copychunks(src_p, &walk_in, bsize, 0);
|
||||
|
||||
prfn(tfm, dst_p, src_p, crfn, enc, info, in_place);
|
||||
|
||||
scatterwalk_done(&walk_in, 0, nbytes);
|
||||
|
||||
scatterwalk_copychunks(dst_p, &walk_out, bsize, 1);
|
||||
scatterwalk_done(&walk_out, 1, nbytes);
|
||||
|
||||
if (!nbytes)
|
||||
return 0;
|
||||
|
||||
crypto_yield(tfm);
|
||||
}
|
||||
}
|
||||
|
||||
static void cbc_process(struct crypto_tfm *tfm, u8 *dst, u8 *src,
|
||||
cryptfn_t fn, int enc, void *info, int in_place)
|
||||
{
|
||||
u8 *iv = info;
|
||||
|
||||
/* Null encryption */
|
||||
if (!iv)
|
||||
return;
|
||||
|
||||
if (enc) {
|
||||
tfm->crt_u.cipher.cit_xor_block(iv, src);
|
||||
fn(crypto_tfm_ctx(tfm), dst, iv);
|
||||
memcpy(iv, dst, crypto_tfm_alg_blocksize(tfm));
|
||||
} else {
|
||||
u8 stack[in_place ? crypto_tfm_alg_blocksize(tfm) : 0];
|
||||
u8 *buf = in_place ? stack : dst;
|
||||
|
||||
fn(crypto_tfm_ctx(tfm), buf, src);
|
||||
tfm->crt_u.cipher.cit_xor_block(buf, iv);
|
||||
memcpy(iv, src, crypto_tfm_alg_blocksize(tfm));
|
||||
if (buf != dst)
|
||||
memcpy(dst, buf, crypto_tfm_alg_blocksize(tfm));
|
||||
}
|
||||
}
|
||||
|
||||
static void ecb_process(struct crypto_tfm *tfm, u8 *dst, u8 *src,
|
||||
cryptfn_t fn, int enc, void *info, int in_place)
|
||||
{
|
||||
fn(crypto_tfm_ctx(tfm), dst, src);
|
||||
}
|
||||
|
||||
static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
|
||||
{
|
||||
struct cipher_alg *cia = &tfm->__crt_alg->cra_cipher;
|
||||
|
||||
if (keylen < cia->cia_min_keysize || keylen > cia->cia_max_keysize) {
|
||||
tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
|
||||
return -EINVAL;
|
||||
} else
|
||||
return cia->cia_setkey(crypto_tfm_ctx(tfm), key, keylen,
|
||||
&tfm->crt_flags);
|
||||
}
|
||||
|
||||
static int ecb_encrypt(struct crypto_tfm *tfm,
|
||||
struct scatterlist *dst,
|
||||
struct scatterlist *src, unsigned int nbytes)
|
||||
{
|
||||
return crypt(tfm, dst, src, nbytes,
|
||||
tfm->__crt_alg->cra_cipher.cia_encrypt,
|
||||
ecb_process, 1, NULL);
|
||||
}
|
||||
|
||||
static int ecb_decrypt(struct crypto_tfm *tfm,
|
||||
struct scatterlist *dst,
|
||||
struct scatterlist *src,
|
||||
unsigned int nbytes)
|
||||
{
|
||||
return crypt(tfm, dst, src, nbytes,
|
||||
tfm->__crt_alg->cra_cipher.cia_decrypt,
|
||||
ecb_process, 1, NULL);
|
||||
}
|
||||
|
||||
static int cbc_encrypt(struct crypto_tfm *tfm,
|
||||
struct scatterlist *dst,
|
||||
struct scatterlist *src,
|
||||
unsigned int nbytes)
|
||||
{
|
||||
return crypt(tfm, dst, src, nbytes,
|
||||
tfm->__crt_alg->cra_cipher.cia_encrypt,
|
||||
cbc_process, 1, tfm->crt_cipher.cit_iv);
|
||||
}
|
||||
|
||||
static int cbc_encrypt_iv(struct crypto_tfm *tfm,
|
||||
struct scatterlist *dst,
|
||||
struct scatterlist *src,
|
||||
unsigned int nbytes, u8 *iv)
|
||||
{
|
||||
return crypt(tfm, dst, src, nbytes,
|
||||
tfm->__crt_alg->cra_cipher.cia_encrypt,
|
||||
cbc_process, 1, iv);
|
||||
}
|
||||
|
||||
static int cbc_decrypt(struct crypto_tfm *tfm,
|
||||
struct scatterlist *dst,
|
||||
struct scatterlist *src,
|
||||
unsigned int nbytes)
|
||||
{
|
||||
return crypt(tfm, dst, src, nbytes,
|
||||
tfm->__crt_alg->cra_cipher.cia_decrypt,
|
||||
cbc_process, 0, tfm->crt_cipher.cit_iv);
|
||||
}
|
||||
|
||||
static int cbc_decrypt_iv(struct crypto_tfm *tfm,
|
||||
struct scatterlist *dst,
|
||||
struct scatterlist *src,
|
||||
unsigned int nbytes, u8 *iv)
|
||||
{
|
||||
return crypt(tfm, dst, src, nbytes,
|
||||
tfm->__crt_alg->cra_cipher.cia_decrypt,
|
||||
cbc_process, 0, iv);
|
||||
}
|
||||
|
||||
static int nocrypt(struct crypto_tfm *tfm,
|
||||
struct scatterlist *dst,
|
||||
struct scatterlist *src,
|
||||
unsigned int nbytes)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int nocrypt_iv(struct crypto_tfm *tfm,
|
||||
struct scatterlist *dst,
|
||||
struct scatterlist *src,
|
||||
unsigned int nbytes, u8 *iv)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags)
|
||||
{
|
||||
u32 mode = flags & CRYPTO_TFM_MODE_MASK;
|
||||
|
||||
tfm->crt_cipher.cit_mode = mode ? mode : CRYPTO_TFM_MODE_ECB;
|
||||
if (flags & CRYPTO_TFM_REQ_WEAK_KEY)
|
||||
tfm->crt_flags = CRYPTO_TFM_REQ_WEAK_KEY;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int crypto_init_cipher_ops(struct crypto_tfm *tfm)
|
||||
{
|
||||
int ret = 0;
|
||||
struct cipher_tfm *ops = &tfm->crt_cipher;
|
||||
|
||||
ops->cit_setkey = setkey;
|
||||
|
||||
switch (tfm->crt_cipher.cit_mode) {
|
||||
case CRYPTO_TFM_MODE_ECB:
|
||||
ops->cit_encrypt = ecb_encrypt;
|
||||
ops->cit_decrypt = ecb_decrypt;
|
||||
break;
|
||||
|
||||
case CRYPTO_TFM_MODE_CBC:
|
||||
ops->cit_encrypt = cbc_encrypt;
|
||||
ops->cit_decrypt = cbc_decrypt;
|
||||
ops->cit_encrypt_iv = cbc_encrypt_iv;
|
||||
ops->cit_decrypt_iv = cbc_decrypt_iv;
|
||||
break;
|
||||
|
||||
case CRYPTO_TFM_MODE_CFB:
|
||||
ops->cit_encrypt = nocrypt;
|
||||
ops->cit_decrypt = nocrypt;
|
||||
ops->cit_encrypt_iv = nocrypt_iv;
|
||||
ops->cit_decrypt_iv = nocrypt_iv;
|
||||
break;
|
||||
|
||||
case CRYPTO_TFM_MODE_CTR:
|
||||
ops->cit_encrypt = nocrypt;
|
||||
ops->cit_decrypt = nocrypt;
|
||||
ops->cit_encrypt_iv = nocrypt_iv;
|
||||
ops->cit_decrypt_iv = nocrypt_iv;
|
||||
break;
|
||||
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
|
||||
if (ops->cit_mode == CRYPTO_TFM_MODE_CBC) {
|
||||
|
||||
switch (crypto_tfm_alg_blocksize(tfm)) {
|
||||
case 8:
|
||||
ops->cit_xor_block = xor_64;
|
||||
break;
|
||||
|
||||
case 16:
|
||||
ops->cit_xor_block = xor_128;
|
||||
break;
|
||||
|
||||
default:
|
||||
printk(KERN_WARNING "%s: block size %u not supported\n",
|
||||
crypto_tfm_alg_name(tfm),
|
||||
crypto_tfm_alg_blocksize(tfm));
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ops->cit_ivsize = crypto_tfm_alg_blocksize(tfm);
|
||||
ops->cit_iv = kmalloc(ops->cit_ivsize, GFP_KERNEL);
|
||||
if (ops->cit_iv == NULL)
|
||||
ret = -ENOMEM;
|
||||
}
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void crypto_exit_cipher_ops(struct crypto_tfm *tfm)
|
||||
{
|
||||
if (tfm->crt_cipher.cit_iv)
|
||||
kfree(tfm->crt_cipher.cit_iv);
|
||||
}
|
||||
64
drivers/staging/rtl8192u/ieee80211/compress.c
Normal file
64
drivers/staging/rtl8192u/ieee80211/compress.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Cryptographic API.
|
||||
*
|
||||
* Compression operations.
|
||||
*
|
||||
* Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
*/
|
||||
#include <linux/types.h>
|
||||
//#include <linux/crypto.h>
|
||||
#include "rtl_crypto.h"
|
||||
#include <linux/errno.h>
|
||||
#include <asm/scatterlist.h>
|
||||
#include <linux/string.h>
|
||||
#include "internal.h"
|
||||
|
||||
static int crypto_compress(struct crypto_tfm *tfm,
|
||||
const u8 *src, unsigned int slen,
|
||||
u8 *dst, unsigned int *dlen)
|
||||
{
|
||||
return tfm->__crt_alg->cra_compress.coa_compress(crypto_tfm_ctx(tfm),
|
||||
src, slen, dst,
|
||||
dlen);
|
||||
}
|
||||
|
||||
static int crypto_decompress(struct crypto_tfm *tfm,
|
||||
const u8 *src, unsigned int slen,
|
||||
u8 *dst, unsigned int *dlen)
|
||||
{
|
||||
return tfm->__crt_alg->cra_compress.coa_decompress(crypto_tfm_ctx(tfm),
|
||||
src, slen, dst,
|
||||
dlen);
|
||||
}
|
||||
|
||||
int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags)
|
||||
{
|
||||
return flags ? -EINVAL : 0;
|
||||
}
|
||||
|
||||
int crypto_init_compress_ops(struct crypto_tfm *tfm)
|
||||
{
|
||||
int ret = 0;
|
||||
struct compress_tfm *ops = &tfm->crt_compress;
|
||||
|
||||
ret = tfm->__crt_alg->cra_compress.coa_init(crypto_tfm_ctx(tfm));
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ops->cot_compress = crypto_compress;
|
||||
ops->cot_decompress = crypto_decompress;
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void crypto_exit_compress_ops(struct crypto_tfm *tfm)
|
||||
{
|
||||
tfm->__crt_alg->cra_compress.coa_exit(crypto_tfm_ctx(tfm));
|
||||
}
|
||||
90
drivers/staging/rtl8192u/ieee80211/crypto_compat.h
Normal file
90
drivers/staging/rtl8192u/ieee80211/crypto_compat.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Header file to maintain compatibility among different kernel versions.
|
||||
*
|
||||
* Copyright (c) 2004-2006 <lawrence_wang@realsil.com.cn>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation. See README and COPYING for
|
||||
* more details.
|
||||
*/
|
||||
|
||||
#include <linux/crypto.h>
|
||||
|
||||
static inline int crypto_cipher_encrypt(struct crypto_tfm *tfm,
|
||||
struct scatterlist *dst,
|
||||
struct scatterlist *src,
|
||||
unsigned int nbytes)
|
||||
{
|
||||
BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
|
||||
return tfm->crt_cipher.cit_encrypt(tfm, dst, src, nbytes);
|
||||
}
|
||||
|
||||
|
||||
static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm,
|
||||
struct scatterlist *dst,
|
||||
struct scatterlist *src,
|
||||
unsigned int nbytes)
|
||||
{
|
||||
BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
|
||||
return tfm->crt_cipher.cit_decrypt(tfm, dst, src, nbytes);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* crypto_free_tfm - Free crypto transform
|
||||
* @tfm: Transform to free
|
||||
*
|
||||
* crypto_free_tfm() frees up the transform and any associated resources,
|
||||
* then drops the refcount on the associated algorithm.
|
||||
*/
|
||||
void crypto_free_tfm(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct crypto_alg *alg;
|
||||
int size;
|
||||
|
||||
if (unlikely(!tfm))
|
||||
return;
|
||||
|
||||
alg = tfm->__crt_alg;
|
||||
size = sizeof(*tfm) + alg->cra_ctxsize;
|
||||
|
||||
if (alg->cra_exit)
|
||||
alg->cra_exit(tfm);
|
||||
crypto_exit_ops(tfm);
|
||||
crypto_mod_put(alg);
|
||||
memset(tfm, 0, size);
|
||||
kfree(tfm);
|
||||
}
|
||||
|
||||
#endif
|
||||
#if 1
|
||||
struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
|
||||
{
|
||||
struct crypto_tfm *tfm = NULL;
|
||||
int err;
|
||||
printk("call crypto_alloc_tfm!!!\n");
|
||||
do {
|
||||
struct crypto_alg *alg;
|
||||
|
||||
alg = crypto_alg_mod_lookup(name, 0, CRYPTO_ALG_ASYNC);
|
||||
err = PTR_ERR(alg);
|
||||
if (IS_ERR(alg))
|
||||
continue;
|
||||
|
||||
tfm = __crypto_alloc_tfm(alg, flags);
|
||||
err = 0;
|
||||
if (IS_ERR(tfm)) {
|
||||
crypto_mod_put(alg);
|
||||
err = PTR_ERR(tfm);
|
||||
tfm = NULL;
|
||||
}
|
||||
} while (err == -EAGAIN && !signal_pending(current));
|
||||
|
||||
return tfm;
|
||||
}
|
||||
#endif
|
||||
//EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
|
||||
//EXPORT_SYMBOL_GPL(crypto_free_tfm);
|
||||
|
||||
|
||||
108
drivers/staging/rtl8192u/ieee80211/digest.c
Normal file
108
drivers/staging/rtl8192u/ieee80211/digest.c
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Cryptographic API.
|
||||
*
|
||||
* Digest operations.
|
||||
*
|
||||
* Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
*/
|
||||
//#include <linux/crypto.h>
|
||||
#include "rtl_crypto.h"
|
||||
#include <linux/mm.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/highmem.h>
|
||||
#include <asm/scatterlist.h>
|
||||
#include "internal.h"
|
||||
|
||||
static void init(struct crypto_tfm *tfm)
|
||||
{
|
||||
tfm->__crt_alg->cra_digest.dia_init(crypto_tfm_ctx(tfm));
|
||||
}
|
||||
|
||||
static void update(struct crypto_tfm *tfm,
|
||||
struct scatterlist *sg, unsigned int nsg)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < nsg; i++) {
|
||||
|
||||
struct page *pg = sg[i].page;
|
||||
unsigned int offset = sg[i].offset;
|
||||
unsigned int l = sg[i].length;
|
||||
|
||||
do {
|
||||
unsigned int bytes_from_page = min(l, ((unsigned int)
|
||||
(PAGE_SIZE)) -
|
||||
offset);
|
||||
char *p = crypto_kmap(pg, 0) + offset;
|
||||
|
||||
tfm->__crt_alg->cra_digest.dia_update
|
||||
(crypto_tfm_ctx(tfm), p,
|
||||
bytes_from_page);
|
||||
crypto_kunmap(p, 0);
|
||||
crypto_yield(tfm);
|
||||
offset = 0;
|
||||
pg++;
|
||||
l -= bytes_from_page;
|
||||
} while (l > 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void final(struct crypto_tfm *tfm, u8 *out)
|
||||
{
|
||||
tfm->__crt_alg->cra_digest.dia_final(crypto_tfm_ctx(tfm), out);
|
||||
}
|
||||
|
||||
static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
|
||||
{
|
||||
u32 flags;
|
||||
if (tfm->__crt_alg->cra_digest.dia_setkey == NULL)
|
||||
return -ENOSYS;
|
||||
return tfm->__crt_alg->cra_digest.dia_setkey(crypto_tfm_ctx(tfm),
|
||||
key, keylen, &flags);
|
||||
}
|
||||
|
||||
static void digest(struct crypto_tfm *tfm,
|
||||
struct scatterlist *sg, unsigned int nsg, u8 *out)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
tfm->crt_digest.dit_init(tfm);
|
||||
|
||||
for (i = 0; i < nsg; i++) {
|
||||
char *p = crypto_kmap(sg[i].page, 0) + sg[i].offset;
|
||||
tfm->__crt_alg->cra_digest.dia_update(crypto_tfm_ctx(tfm),
|
||||
p, sg[i].length);
|
||||
crypto_kunmap(p, 0);
|
||||
crypto_yield(tfm);
|
||||
}
|
||||
crypto_digest_final(tfm, out);
|
||||
}
|
||||
|
||||
int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags)
|
||||
{
|
||||
return flags ? -EINVAL : 0;
|
||||
}
|
||||
|
||||
int crypto_init_digest_ops(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct digest_tfm *ops = &tfm->crt_digest;
|
||||
|
||||
ops->dit_init = init;
|
||||
ops->dit_update = update;
|
||||
ops->dit_final = final;
|
||||
ops->dit_digest = digest;
|
||||
ops->dit_setkey = setkey;
|
||||
|
||||
return crypto_alloc_hmac_block(tfm);
|
||||
}
|
||||
|
||||
void crypto_exit_digest_ops(struct crypto_tfm *tfm)
|
||||
{
|
||||
crypto_free_hmac_block(tfm);
|
||||
}
|
||||
239
drivers/staging/rtl8192u/ieee80211/dot11d.c
Normal file
239
drivers/staging/rtl8192u/ieee80211/dot11d.c
Normal file
@@ -0,0 +1,239 @@
|
||||
#ifdef ENABLE_DOT11D
|
||||
//-----------------------------------------------------------------------------
|
||||
// File:
|
||||
// Dot11d.c
|
||||
//
|
||||
// Description:
|
||||
// Implement 802.11d.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "dot11d.h"
|
||||
|
||||
void
|
||||
Dot11d_Init(struct ieee80211_device *ieee)
|
||||
{
|
||||
PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee);
|
||||
|
||||
pDot11dInfo->bEnabled = 0;
|
||||
|
||||
pDot11dInfo->State = DOT11D_STATE_NONE;
|
||||
pDot11dInfo->CountryIeLen = 0;
|
||||
memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
|
||||
memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1);
|
||||
RESET_CIE_WATCHDOG(ieee);
|
||||
|
||||
printk("Dot11d_Init()\n");
|
||||
}
|
||||
|
||||
//
|
||||
// Description:
|
||||
// Reset to the state as we are just entering a regulatory domain.
|
||||
//
|
||||
void
|
||||
Dot11d_Reset(struct ieee80211_device *ieee)
|
||||
{
|
||||
u32 i;
|
||||
PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee);
|
||||
#if 0
|
||||
if(!pDot11dInfo->bEnabled)
|
||||
return;
|
||||
#endif
|
||||
// Clear old channel map
|
||||
memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
|
||||
memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1);
|
||||
// Set new channel map
|
||||
for (i=1; i<=11; i++) {
|
||||
(pDot11dInfo->channel_map)[i] = 1;
|
||||
}
|
||||
for (i=12; i<=14; i++) {
|
||||
(pDot11dInfo->channel_map)[i] = 2;
|
||||
}
|
||||
|
||||
pDot11dInfo->State = DOT11D_STATE_NONE;
|
||||
pDot11dInfo->CountryIeLen = 0;
|
||||
RESET_CIE_WATCHDOG(ieee);
|
||||
|
||||
//printk("Dot11d_Reset()\n");
|
||||
}
|
||||
|
||||
//
|
||||
// Description:
|
||||
// Update country IE from Beacon or Probe Resopnse
|
||||
// and configure PHY for operation in the regulatory domain.
|
||||
//
|
||||
// TODO:
|
||||
// Configure Tx power.
|
||||
//
|
||||
// Assumption:
|
||||
// 1. IS_DOT11D_ENABLE() is TRUE.
|
||||
// 2. Input IE is an valid one.
|
||||
//
|
||||
void
|
||||
Dot11d_UpdateCountryIe(
|
||||
struct ieee80211_device *dev,
|
||||
u8 * pTaddr,
|
||||
u16 CoutryIeLen,
|
||||
u8 * pCoutryIe
|
||||
)
|
||||
{
|
||||
PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
|
||||
u8 i, j, NumTriples, MaxChnlNum;
|
||||
PCHNL_TXPOWER_TRIPLE pTriple;
|
||||
|
||||
memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
|
||||
memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1);
|
||||
MaxChnlNum = 0;
|
||||
NumTriples = (CoutryIeLen - 3) / 3; // skip 3-byte country string.
|
||||
pTriple = (PCHNL_TXPOWER_TRIPLE)(pCoutryIe + 3);
|
||||
for(i = 0; i < NumTriples; i++)
|
||||
{
|
||||
if(MaxChnlNum >= pTriple->FirstChnl)
|
||||
{ // It is not in a monotonically increasing order, so stop processing.
|
||||
printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n");
|
||||
return;
|
||||
}
|
||||
if(MAX_CHANNEL_NUMBER < (pTriple->FirstChnl + pTriple->NumChnls))
|
||||
{ // It is not a valid set of channel id, so stop processing.
|
||||
printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........2\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for(j = 0 ; j < pTriple->NumChnls; j++)
|
||||
{
|
||||
pDot11dInfo->channel_map[pTriple->FirstChnl + j] = 1;
|
||||
pDot11dInfo->MaxTxPwrDbmList[pTriple->FirstChnl + j] = pTriple->MaxTxPowerInDbm;
|
||||
MaxChnlNum = pTriple->FirstChnl + j;
|
||||
}
|
||||
|
||||
pTriple = (PCHNL_TXPOWER_TRIPLE)((u8*)pTriple + 3);
|
||||
}
|
||||
#if 1
|
||||
//printk("Dot11d_UpdateCountryIe(): Channel List:\n");
|
||||
printk("Channel List:");
|
||||
for(i=1; i<= MAX_CHANNEL_NUMBER; i++)
|
||||
if(pDot11dInfo->channel_map[i] > 0)
|
||||
printk(" %d", i);
|
||||
printk("\n");
|
||||
#endif
|
||||
|
||||
UPDATE_CIE_SRC(dev, pTaddr);
|
||||
|
||||
pDot11dInfo->CountryIeLen = CoutryIeLen;
|
||||
memcpy(pDot11dInfo->CountryIeBuf, pCoutryIe,CoutryIeLen);
|
||||
pDot11dInfo->State = DOT11D_STATE_LEARNED;
|
||||
}
|
||||
|
||||
|
||||
u8
|
||||
DOT11D_GetMaxTxPwrInDbm(
|
||||
struct ieee80211_device *dev,
|
||||
u8 Channel
|
||||
)
|
||||
{
|
||||
PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
|
||||
u8 MaxTxPwrInDbm = 255;
|
||||
|
||||
if(MAX_CHANNEL_NUMBER < Channel)
|
||||
{
|
||||
printk("DOT11D_GetMaxTxPwrInDbm(): Invalid Channel\n");
|
||||
return MaxTxPwrInDbm;
|
||||
}
|
||||
if(pDot11dInfo->channel_map[Channel])
|
||||
{
|
||||
MaxTxPwrInDbm = pDot11dInfo->MaxTxPwrDbmList[Channel];
|
||||
}
|
||||
|
||||
return MaxTxPwrInDbm;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DOT11D_ScanComplete(
|
||||
struct ieee80211_device * dev
|
||||
)
|
||||
{
|
||||
PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
|
||||
|
||||
switch(pDot11dInfo->State)
|
||||
{
|
||||
case DOT11D_STATE_LEARNED:
|
||||
pDot11dInfo->State = DOT11D_STATE_DONE;
|
||||
break;
|
||||
|
||||
case DOT11D_STATE_DONE:
|
||||
if( GET_CIE_WATCHDOG(dev) == 0 )
|
||||
{ // Reset country IE if previous one is gone.
|
||||
Dot11d_Reset(dev);
|
||||
}
|
||||
break;
|
||||
case DOT11D_STATE_NONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int IsLegalChannel(
|
||||
struct ieee80211_device * dev,
|
||||
u8 channel
|
||||
)
|
||||
{
|
||||
PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
|
||||
|
||||
if(MAX_CHANNEL_NUMBER < channel)
|
||||
{
|
||||
printk("IsLegalChannel(): Invalid Channel\n");
|
||||
return 0;
|
||||
}
|
||||
if(pDot11dInfo->channel_map[channel] > 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ToLegalChannel(
|
||||
struct ieee80211_device * dev,
|
||||
u8 channel
|
||||
)
|
||||
{
|
||||
PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
|
||||
u8 default_chn = 0;
|
||||
u32 i = 0;
|
||||
|
||||
for (i=1; i<= MAX_CHANNEL_NUMBER; i++)
|
||||
{
|
||||
if(pDot11dInfo->channel_map[i] > 0)
|
||||
{
|
||||
default_chn = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(MAX_CHANNEL_NUMBER < channel)
|
||||
{
|
||||
printk("IsLegalChannel(): Invalid Channel\n");
|
||||
return default_chn;
|
||||
}
|
||||
|
||||
if(pDot11dInfo->channel_map[channel] > 0)
|
||||
return channel;
|
||||
|
||||
return default_chn;
|
||||
}
|
||||
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
|
||||
EXPORT_SYMBOL(Dot11d_Init);
|
||||
EXPORT_SYMBOL(Dot11d_Reset);
|
||||
EXPORT_SYMBOL(Dot11d_UpdateCountryIe);
|
||||
EXPORT_SYMBOL(DOT11D_GetMaxTxPwrInDbm);
|
||||
EXPORT_SYMBOL(DOT11D_ScanComplete);
|
||||
EXPORT_SYMBOL(IsLegalChannel);
|
||||
EXPORT_SYMBOL(ToLegalChannel);
|
||||
#else
|
||||
EXPORT_SYMBOL_NOVERS(Dot11d_Init);
|
||||
EXPORT_SYMBOL_NOVERS(Dot11d_Reset);
|
||||
EXPORT_SYMBOL_NOVERS(Dot11d_UpdateCountryIe);
|
||||
EXPORT_SYMBOL_NOVERS(DOT11D_GetMaxTxPwrInDbm);
|
||||
EXPORT_SYMBOL_NOVERS(DOT11D_ScanComplete);
|
||||
EXPORT_SYMBOL_NOVERS(IsLegalChannel);
|
||||
EXPORT_SYMBOL_NOVERS(ToLegalChannel);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
102
drivers/staging/rtl8192u/ieee80211/dot11d.h
Normal file
102
drivers/staging/rtl8192u/ieee80211/dot11d.h
Normal file
@@ -0,0 +1,102 @@
|
||||
#ifndef __INC_DOT11D_H
|
||||
#define __INC_DOT11D_H
|
||||
|
||||
#ifdef ENABLE_DOT11D
|
||||
#include "ieee80211.h"
|
||||
|
||||
//#define ENABLE_DOT11D
|
||||
|
||||
//#define DOT11D_MAX_CHNL_NUM 83
|
||||
|
||||
typedef struct _CHNL_TXPOWER_TRIPLE {
|
||||
u8 FirstChnl;
|
||||
u8 NumChnls;
|
||||
u8 MaxTxPowerInDbm;
|
||||
}CHNL_TXPOWER_TRIPLE, *PCHNL_TXPOWER_TRIPLE;
|
||||
|
||||
typedef enum _DOT11D_STATE {
|
||||
DOT11D_STATE_NONE = 0,
|
||||
DOT11D_STATE_LEARNED,
|
||||
DOT11D_STATE_DONE,
|
||||
}DOT11D_STATE;
|
||||
|
||||
typedef struct _RT_DOT11D_INFO {
|
||||
//DECLARE_RT_OBJECT(RT_DOT11D_INFO);
|
||||
|
||||
bool bEnabled; // dot11MultiDomainCapabilityEnabled
|
||||
|
||||
u16 CountryIeLen; // > 0 if CountryIeBuf[] contains valid country information element.
|
||||
u8 CountryIeBuf[MAX_IE_LEN];
|
||||
u8 CountryIeSrcAddr[6]; // Source AP of the country IE.
|
||||
u8 CountryIeWatchdog;
|
||||
|
||||
u8 channel_map[MAX_CHANNEL_NUMBER+1]; //!!!Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan)
|
||||
//u8 ChnlListLen; // #Bytes valid in ChnlList[].
|
||||
//u8 ChnlList[DOT11D_MAX_CHNL_NUM];
|
||||
u8 MaxTxPwrDbmList[MAX_CHANNEL_NUMBER+1];
|
||||
|
||||
DOT11D_STATE State;
|
||||
}RT_DOT11D_INFO, *PRT_DOT11D_INFO;
|
||||
#define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 )
|
||||
#define cpMacAddr(des,src) ((des)[0]=(src)[0],(des)[1]=(src)[1],(des)[2]=(src)[2],(des)[3]=(src)[3],(des)[4]=(src)[4],(des)[5]=(src)[5])
|
||||
#define GET_DOT11D_INFO(__pIeeeDev) ((PRT_DOT11D_INFO)((__pIeeeDev)->pDot11dInfo))
|
||||
|
||||
#define IS_DOT11D_ENABLE(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->bEnabled
|
||||
#define IS_COUNTRY_IE_VALID(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0)
|
||||
|
||||
#define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
|
||||
#define UPDATE_CIE_SRC(__pIeeeDev, __pTa) cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
|
||||
|
||||
#define IS_COUNTRY_IE_CHANGED(__pIeeeDev, __Ie) \
|
||||
(((__Ie).Length == 0 || (__Ie).Length != GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen) ? \
|
||||
FALSE : \
|
||||
(!memcmp(GET_DOT11D_INFO(__pIeeeDev)->CountryIeBuf, (__Ie).Octet, (__Ie).Length)))
|
||||
|
||||
#define CIE_WATCHDOG_TH 1
|
||||
#define GET_CIE_WATCHDOG(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->CountryIeWatchdog
|
||||
#define RESET_CIE_WATCHDOG(__pIeeeDev) GET_CIE_WATCHDOG(__pIeeeDev) = 0
|
||||
#define UPDATE_CIE_WATCHDOG(__pIeeeDev) ++GET_CIE_WATCHDOG(__pIeeeDev)
|
||||
|
||||
#define IS_DOT11D_STATE_DONE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->State == DOT11D_STATE_DONE)
|
||||
|
||||
|
||||
void
|
||||
Dot11d_Init(
|
||||
struct ieee80211_device *dev
|
||||
);
|
||||
|
||||
void
|
||||
Dot11d_Reset(
|
||||
struct ieee80211_device *dev
|
||||
);
|
||||
|
||||
void
|
||||
Dot11d_UpdateCountryIe(
|
||||
struct ieee80211_device *dev,
|
||||
u8 * pTaddr,
|
||||
u16 CoutryIeLen,
|
||||
u8 * pCoutryIe
|
||||
);
|
||||
|
||||
u8
|
||||
DOT11D_GetMaxTxPwrInDbm(
|
||||
struct ieee80211_device *dev,
|
||||
u8 Channel
|
||||
);
|
||||
|
||||
void
|
||||
DOT11D_ScanComplete(
|
||||
struct ieee80211_device * dev
|
||||
);
|
||||
|
||||
int IsLegalChannel(
|
||||
struct ieee80211_device * dev,
|
||||
u8 channel
|
||||
);
|
||||
|
||||
int ToLegalChannel(
|
||||
struct ieee80211_device * dev,
|
||||
u8 channel
|
||||
);
|
||||
#endif //ENABLE_DOT11D
|
||||
#endif // #ifndef __INC_DOT11D_H
|
||||
2796
drivers/staging/rtl8192u/ieee80211/ieee80211.h
Normal file
2796
drivers/staging/rtl8192u/ieee80211/ieee80211.h
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user